cloudfoundryclient

package
v0.0.20 Latest Latest
Warning

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

Go to latest
Published: May 27, 2015 License: Apache-2.0, GPL-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
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
	//DefaultSpaceName - name of the default space created for each org
	DefaultSpaceName = "development"
	//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"
	//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

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 {
	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) 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) 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 {
	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)
}

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 {
	Resources []map[string]interface{}
}

UserAPIResponse - the user api response object

Jump to

Keyboard shortcuts

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