cloudcontroller

package
v0.0.0-...-1aaa49d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 24, 2022 License: BSD-2-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Adduser functions.CCAddUserFunc = func(info functions.UserIdInfo) (err error) {
	fmt.Println(fmt.Sprintf("add user id: %s with Uaa id: %s .........", info.User.Uid, info.UserId))
	userRequest := UserRequest{
		Id: info.UserId,
	}
	data, err := json.Marshal(userRequest)
	if err != nil {
		return
	}
	body := bytes.NewBuffer(data)
	_, err = info.RequestFn(info.Token, fmt.Sprintf("%s/v2/users", info.Ccurl), "POST", "application/json", body)
	return err
}
View Source
var AssociateOrg functions.OrgFunc = func(orgInfo functions.OrgInfo) (guid string, err error) {
	response, err := orgInfo.RequestFn(orgInfo.Token, fmt.Sprintf("%s/v2/organizations?q=name:%s", orgInfo.Ccurl, orgInfo.Org.Name), "GET", "application/json", nil)
	if err != nil {
		return
	}
	guid, err = parseResponse(response)
	if err != nil {
		return
	}
	fmt.Println(fmt.Sprintf("Associate user id :%s to org: %s.........", orgInfo.User.Uid, guid))
	_, err = orgInfo.RequestFn(orgInfo.Token, fmt.Sprintf("%s/v2/organizations/%s/users/%s", orgInfo.Ccurl, guid, orgInfo.UserId), "PUT", "application/json", nil)
	if err != nil {
		return
	}
	for _, role := range orgInfo.Org.Roles {
		fmt.Println(fmt.Sprintf("Associate user id :%s to org: %s with %s role.........", orgInfo.User.Uid, guid, role))
		_, err = orgInfo.RequestFn(orgInfo.Token, fmt.Sprintf("%s/v2/organizations/%s/%s/%s", orgInfo.Ccurl, guid, role, orgInfo.UserId), "PUT", "application/json", nil)
		if err != nil {
			return
		}
	}
	return
}
View Source
var AssociateSpace functions.SpaceFunc = func(spaceInfo functions.SpaceInfo) (err error) {
	response, err := spaceInfo.RequestFn(spaceInfo.Token, fmt.Sprintf("%s/v2/spaces?q=name:%s&q=organization_guid:%s", spaceInfo.Ccurl, spaceInfo.Space.Name, spaceInfo.OrgInfo.Guid), "GET", "application/json", nil)
	if err != nil {
		return
	}
	guid, err := parseResponse(response)
	if err != nil {
		return
	}
	for _, role := range spaceInfo.Space.Roles {
		fmt.Println(fmt.Sprintf("Associate user id :%s to space: %s with %s role.........", spaceInfo.User.Uid, guid, role))
		_, err = spaceInfo.RequestFn(spaceInfo.Token, fmt.Sprintf("%s/v2/spaces/%s/%s/%s", spaceInfo.Ccurl, guid, role, spaceInfo.UserId), "PUT", "applicatio    n/json", nil)
		if err != nil {
			return
		}
	}
	return
}

Functions

This section is empty.

Types

type ApiResponse

type ApiResponse struct {
	Resources []Resource
}

type Metadata

type Metadata struct {
	Guid string
}

type Resource

type Resource struct {
	Metadata Metadata
}

type UserRequest

type UserRequest struct {
	Id string `json:"guid"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL