cloudfoundryclient

package
v0.0.155 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2016 License: GPL-2.0 Imports: 7 Imported by: 10

Documentation

Index

Constants

View Source
const (
	//OrgCreateSuccessStatusCode - success status code from a call to the org create cc endpoint
	OrgCreateSuccessStatusCode = http.StatusCreated
	//OrgEndpoint - the endpoint to hit for org actions
	OrgEndpoint = "/v2/organizations"
	//SpacesEndpont - the endpoint to hit for spaces actions
	SpacesEndpont = "/v2/spaces"
	//SpacesCreateSuccessStatusCode = success status code of spaces rest call
	SpacesCreateSuccessStatusCode = http.StatusCreated
	//ListUsersEndpoint - get a list of all users in paas
	ListUsersEndpoint = "/Users"
	//ListUsersSuccessStatus - success status code for users call
	ListUsersSuccessStatus = http.StatusOK
	//InfoURLPath - the endpoint to grab api info data
	InfoURLPath = "/v2/info"
	//InfoSuccessStatus --
	InfoSuccessStatus = http.StatusOK
	//RoleTypeManager - this is the managers type for role assignments
	RoleTypeManager = "managers"
	//RoleTypeUser - this is the users type for role assignments
	RoleTypeUser = "users"
	//RoleTypeDeveloper - a role type for developers of a space
	RoleTypeDeveloper = "developers"
	//RoleCreationURLFormat - formatter string for role creation url generation
	RoleCreationURLFormat = "%s/%s/%s/%s"
	//RoleCreateSuccessStatusCode - success status code for role assignment calls
	RoleCreateSuccessStatusCode = http.StatusCreated
	//OrgRemoveSuccessStatus - success status code for org removal
	OrgRemoveSuccessStatus = http.StatusNoContent
)

Variables

View Source
var (
	//ErrOrgCreateAPICallFailure - error for failed call to create org endpoint
	ErrOrgCreateAPICallFailure = errors.New("failed to create org on api call")
	//ErrOrgRemoveAPICallFailure - error for failed call to remove org endpoint
	ErrOrgRemoveAPICallFailure = errors.New("failed to remove org on api call")
	//ErrSpaceCreateAPICallFailure - error for failed call to create org endpoint
	ErrSpaceCreateAPICallFailure = errors.New("failed to create space on api call")
	//ErrNoUserFound - error no user found
	ErrNoUserFound = errors.New("no matching user found in system")
	//ErrFailedStatusCode - we recieved a status code not matching the success code for the endpoint
	ErrFailedStatusCode = errors.New("status code response does not match the known success status code for rest endpoint")
)

Functions

This section is empty.

Types

type APIMetadata

type APIMetadata struct {
	GUID      string `json:"guid"`
	URL       string `json:"url"`
	CreatedAt string `json:"created_at"`
	UpdatedAt string `json:"updated_at"`
}

APIMetadata = cc http response metadata

type APIResponse

type APIResponse struct {
	Metadata APIMetadata            `json:"metadata"`
	Entity   map[string]interface{} `json:"entity"`
}

APIResponse - cc http response object

type APIResponseList

type APIResponseList struct {
	TotalResults int           `json:"total_results"`
	TotalPages   int           `json:"total_pages"`
	PrevURL      string        `json:"prev_url"`
	NextURL      string        `json:"next_url"`
	Resources    []APIResponse `json:"resources"`
}

APIResponseList - a list of resources or apiresponse objects

type AuthRequestCreator

type AuthRequestCreator interface {
	CreateAuthRequest(verb, requestURL, path string, args interface{}) (*http.Request, error)
	CCTarget() string
	HttpClient() ccclient.ClientDoer
	Login() (*ccclient.Client, error)
}

AuthRequestCreator - creates auth decorated http request objects

type CFClient

type CFClient struct {
	RequestDecorator AuthRequestCreator
	Info             *CloudFoundryAPIInfo
	Log              logger
}

CFClient - cloud foundry api client struct

func (*CFClient) AddOrg

func (s *CFClient) AddOrg(orgName string) (orgGUID string, err error)

AddOrg - add an org to the target foundation

func (*CFClient) AddRole

func (s *CFClient) AddRole(rolePathPrefix string, targetGUID string, roleType string, userGUID string) (err error)

AddRole - add a role mapping a user to a org or space

func (*CFClient) AddSpace

func (s *CFClient) AddSpace(spaceName string, orgGUID string) (spaceGUID string, err error)

AddSpace - add a space to the given org

func (*CFClient) AddUser

func (s *CFClient) AddUser(username string) (err error)

AddUser - add a user to the targetted foundation

func (*CFClient) Query added in v0.0.23

func (s *CFClient) Query(verb string, domain string, path string, args interface{}) (response *http.Response)

Query - make a generic query against any rest endpoint

func (*CFClient) QueryAPIInfo

func (s *CFClient) QueryAPIInfo() (info *CloudFoundryAPIInfo, err error)

QueryAPIInfo - get the info results for your target rest api

func (*CFClient) QueryUserGUID

func (s *CFClient) QueryUserGUID(username string) (guid string, err error)

QueryUserGUID - get the guid for the given user

func (*CFClient) QueryUsers added in v0.0.23

func (s *CFClient) QueryUsers(startIndex, count int, attributes, filter string) (userList UserAPIResponse, err error)

QueryUsers - get the guid for the given user

func (*CFClient) RemoveOrg added in v0.0.19

func (s *CFClient) RemoveOrg(orgGUID string) (err error)

RemoveOrg - remove a org by guid

type CloudFoundryAPIInfo

type CloudFoundryAPIInfo struct {
	APIEndpoint              string
	Name                     string `json:"name"`
	Build                    string `json:"build"`
	Support                  string `json:"support"`
	Version                  int    `json:"version"`
	Description              string `json:"description"`
	AuthorizationEndpoint    string `json:"authorization_endpoint"`
	TokenEndpoint            string `json:"token_endpoint"`
	MinCLIVersion            string `json:"min_cli_version"`
	MinRecommendedCLIVersion string `json:"min_recommended_cli_version"`
	APIVersion               string `json:"api_version"`
	LoggingEndpoint          string `json:"logging_endpoint"`
}

CloudFoundryAPIInfo - info response object from cc info endpoint

type CloudFoundryClient

type CloudFoundryClient interface {
	QueryAPIInfo() (*CloudFoundryAPIInfo, error)
	QueryUserGUID(username string) (string, error)
	AddRole(rolePathPrefix string, targetGUID string, roleType string, userGUID string) error
	AddOrg(orgName string) (orgGUID string, err error)
	AddSpace(spaceName string, orgGUID string) (spaceGUID string, err error)
	AddUser(username string) error
	RemoveOrg(orgGUID string) (err error)
	QueryUsers(int, int, string, string) (userList UserAPIResponse, err error)
	Query(verb string, domain string, path string, args interface{}) (response *http.Response)
}

CloudFoundryClient - interface for a cloud foundry client

func NewCloudFoundryClient

func NewCloudFoundryClient(auth AuthRequestCreator, log logger) CloudFoundryClient

NewCloudFoundryClient - generate a new cloudfoundryclient interface object

type RestRunner

type RestRunner struct {
	Verb              string
	URL               string
	Data              interface{}
	Path              string
	SuccessStatusCode int
	OnSuccess         func(*http.Response)
	OnFailure         func(*http.Response, error)
	RequestDecorator  AuthRequestCreator
	Logger            logger
}

RestRunner - runs a rest call

func (*RestRunner) Run

func (s *RestRunner) Run()

Run - runs the rest call

type UserAPIResponse

type UserAPIResponse struct {
	Schemas      []string `json:"schemas"`
	StartIndex   int      `json:"startIndex"`
	ItemsPerPage int      `json:"itemsPerPage"`
	TotalResults int      `json:"totalResults"`
	Resources    []UserResource
}

UserAPIResponse - the user api response object

type UserResource added in v0.0.23

type UserResource struct {
	Active    bool                   `json:"active"`
	Approvals []interface{}          `json:"approvals"`
	Emails    []map[string]string    `json:"emails"`
	Groups    []map[string]string    `json:"groups"`
	ID        string                 `json:"id"`
	Meta      map[string]interface{} `json:"meta"`
	Name      map[string]string      `json:"name"`
	Origin    string                 `json:"origin"`
	Schemas   []string               `json:"schemas"`
	UserName  string                 `json:"userName"`
	Verified  bool                   `json:"verified"`
}

UserResource - a user resource record

Jump to

Keyboard shortcuts

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