Documentation ¶
Index ¶
- Constants
- Variables
- type APIMetadata
- type APIResponse
- type APIResponseList
- type AuthRequestCreator
- type CFClient
- func (s *CFClient) AddOrg(orgName string) (orgGUID string, err error)
- func (s *CFClient) AddRole(rolePathPrefix string, targetGUID string, roleType string, userGUID string) (err error)
- func (s *CFClient) AddSpace(spaceName string, orgGUID string) (spaceGUID string, err error)
- func (s *CFClient) AddUser(username string) (err error)
- func (s *CFClient) Query(verb string, domain string, path string, args interface{}) (response *http.Response)
- func (s *CFClient) QueryAPIInfo() (info *CloudFoundryAPIInfo, err error)
- func (s *CFClient) QueryUserGUID(username string) (guid string, err error)
- func (s *CFClient) QueryUsers(startIndex, count int, attributes, filter string) (userList UserAPIResponse, err error)
- func (s *CFClient) RemoveOrg(orgGUID string) (err error)
- type CloudFoundryAPIInfo
- type CloudFoundryClient
- type RestRunner
- type UserAPIResponse
- type UserResource
Constants ¶
const ( //OrgCreateSuccessStatusCode - success status code from a call to the org create cc endpoint OrgCreateSuccessStatusCode = 201 //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 = 201 //ListUsersEndpoint - get a list of all users in paas ListUsersEndpoint = "/Users" //ListUsersSuccessStatus - success status code for users call ListUsersSuccessStatus = 200 //InfoURLPath - the endpoint to grab api info data InfoURLPath = "/v2/info" //InfoSuccessStatus InfoSuccessStatus = 200 //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 = 201 //OrgRemoveSuccessStatus - success status code for org removal OrgRemoveSuccessStatus = 204 )
Variables ¶
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) 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) 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 ¶
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
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()
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