ccv3

package
v6.26.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2017 License: Apache-2.0 Imports: 15 Imported by: 316

Documentation

Overview

Package ccv3 represents a Cloud Controller V3 client.

These sets of packages are still under development/pre-pre-pre...alpha. Use at your own risk! Functionality and design may change without warning.

It is currently designed to support Cloud Controller API 3.0.0. However, it may include features and endpoints of later API versions.

For more information on the Cloud Controller API see https://apidocs.cloudfoundry.org/

Method Naming Conventions

The client takes a '<Action Name><Top Level Endpoint><Return Value>' approach to method names. If the <Top Level Endpoint> and <Return Value> are similar, they do not need to be repeated. If a GUID is required for the <Top Level Endpoint>, the pluralization is removed from said endpoint in the method name.

For Example:

Method Name: GetApplication
Endpoint: /v3/applications/:guid
Action Name: Get
Top Level Endpoint: applications
Return Value: Application

Method Name: GetServiceInstances
Endpoint: /v3/service_instances
Action Name: Get
Top Level Endpoint: service_instances
Return Value: []ServiceInstance

Method Name: GetSpaceServiceInstances
Endpoint: /v3/spaces/:guid/service_instances
Action Name: Get
Top Level Endpoint: spaces
Return Value: []ServiceInstance

Method Name: CreateApplicationTask
Endpoint: /v3/apps/:application_guid/task
Action Name: Post
Top Level Endpoint: apps
Return Value: []Task

Use the following table to determine which HTTP Command equates to which Action Name:

HTTP Command -> Action Name
POST -> Create
GET -> Get
PUT -> Update
DELETE -> Delete

Method Locations

Methods exist in the same file as their return type, regardless of which endpoint they use.

Error Handling

All error handling that requires parsing the error_code/code returned back from the Cloud Controller should be placed in the errorWrapper. Everything else can be handled in the individual operations. All parsed cloud controller errors should exist in errors.go, all generic HTTP errors should exist in the cloudcontroller's errors.go. Errors related to the individaul operation should exist at the top of that operation's file.

Index

Constants

View Source
const (
	// GUIDFilter is a query paramater for listing objects by GUID.
	GUIDFilter = "guids"
	// NameFilter is a query paramater for listing objects by name.
	NameFilter = "names"
	// OrganizationGUIDFilter is a query paramater for listing objects by Organization GUID.
	OrganizationGUIDFilter = "organization_guids"
	// SpaceGUIDFilter is a query paramater for listing objects by Space GUID.
	SpaceGUIDFilter = "space_guids"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type APIInfo

type APIInfo struct {
	// Links is a list of top level Cloud Controller APIs.
	Links struct {
		// CCV3 is the link to the Cloud Controller V3 API
		CCV3 APILink `json:"cloud_controller_v3"`

		// UAA is the link to the UAA API
		UAA APILink `json:"uaa"`
	} `json:"links"`
}

APIInfo represents a GET response from the '/' endpoint of the cloud controller API.

func (APIInfo) CloudControllerAPIVersion

func (info APIInfo) CloudControllerAPIVersion() string

CloudControllerAPIVersion return the version for the CloudController.

func (APIInfo) UAA

func (info APIInfo) UAA() string

UAA return the HREF for the UAA.

type APILink struct {
	// HREF is the fully qualified URL for the link.
	HREF   string `json:"href"`
	Method string `json:"method"`

	// Meta contains additional metadata about the API.
	Meta struct {
		// Version of the API
		Version string `json:"version"`
	} `json:"meta"`
}

APILink represents a generic link from a response object.

type APILinks map[string]APILink

APILinks is a directory of follow-up urls for the resource.

type Application

type Application struct {
	Name          string                   `json:"name"`
	GUID          string                   `json:"guid,omitempty"`
	Relationships ApplicationRelationships `json:"relationships"`
}

Application represents a Cloud Controller V3 Application.

type ApplicationRelationships

type ApplicationRelationships struct {
	Space Relationship `json:"space"`
}

type Client

type Client struct {
	APIInfo
	// contains filtered or unexported fields
}

Client can be used to talk to a Cloud Controller's V3 Endpoints.

func NewClient

func NewClient(config Config) *Client

NewClient returns a new Client.

func (*Client) AssignSpaceToIsolationSegment

func (client *Client) AssignSpaceToIsolationSegment(spaceGUID string, isolationSegmentGUID string) (Relationship, Warnings, error)

func (*Client) CreateApplication

func (client *Client) CreateApplication(app Application) (Application, Warnings, error)

CreateApplication creates an application with the given settings

func (*Client) CreateApplicationTask

func (client *Client) CreateApplicationTask(appGUID string, task Task) (Task, Warnings, error)

CreateApplicationTask runs a command in the Application environment associated with the provided Application GUID.

func (*Client) CreateIsolationSegment

func (client *Client) CreateIsolationSegment(isolationSegment IsolationSegment) (IsolationSegment, Warnings, error)

CreateIsolationSegment will create an Isolation Segment on the Cloud Controller. Note: This will not validate that the placement tag exists in the diego cluster.

func (*Client) CreatePackage

func (client *Client) CreatePackage(pkg Package) (Package, Warnings, error)

CreatePackage creates a package with the given settings, Type and the Space must be set.

func (*Client) DeleteIsolationSegment

func (client *Client) DeleteIsolationSegment(guid string) (Warnings, error)

DeleteIsolationSegment removes an isolation segment from the cloud controller. Note: This will only remove it from the cloud controller database. It will not remove it from diego.

func (*Client) EntitleIsolationSegmentToOrganizations

func (client *Client) EntitleIsolationSegmentToOrganizations(isolationSegmentGUID string, organizationGUIDs []string) (RelationshipList, Warnings, error)

EntitleIsolationSegmentToOrganizations will create a link between the isolation segment and the list of organizations provided.

func (*Client) GetApplicationTasks

func (client *Client) GetApplicationTasks(appGUID string, query url.Values) ([]Task, Warnings, error)

GetApplicationTasks returns a list of tasks associated with the provided application GUID. Results can be filtered by providing URL queries.

func (*Client) GetApplications

func (client *Client) GetApplications(query url.Values) ([]Application, Warnings, error)

GetApplications lists applications with optional filters.

func (*Client) GetIsolationSegment

func (client *Client) GetIsolationSegment(guid string) (IsolationSegment, Warnings, error)

GetIsolationSegment returns back the requested isolation segment that matches the GUID.

func (*Client) GetIsolationSegmentOrganizationsByIsolationSegment

func (client *Client) GetIsolationSegmentOrganizationsByIsolationSegment(isolationSegmentGUID string) ([]Organization, Warnings, error)

GetIsolationSegmentOrganizationsByIsolationSegment lists organizations entitled to an isolation segment

func (*Client) GetIsolationSegments

func (client *Client) GetIsolationSegments(query url.Values) ([]IsolationSegment, Warnings, error)

GetIsolationSegments lists isolation segments with optional filters.

func (*Client) GetOrganizationDefaultIsolationSegment

func (client *Client) GetOrganizationDefaultIsolationSegment(orgGUID string) (Relationship, Warnings, error)

func (*Client) GetOrganizations

func (client *Client) GetOrganizations(query url.Values) ([]Organization, Warnings, error)

GetOrganizations lists organizations with optional filters.

func (*Client) GetPackage

func (client *Client) GetPackage(guid string) (Package, Warnings, error)

GetPackage returns the package with the given GUID.

func (*Client) GetSpaceIsolationSegment

func (client *Client) GetSpaceIsolationSegment(spaceGUID string) (Relationship, Warnings, error)

func (*Client) Info

func (client *Client) Info() (APIInfo, ResourceLinks, Warnings, error)

Info returns endpoint and API information from /v3.

func (*Client) RevokeIsolationSegmentFromOrganization

func (client *Client) RevokeIsolationSegmentFromOrganization(isolationSegmentGUID string, organizationGUID string) (Warnings, error)

RevokeIsolationSegmentFromOrganization will delete the relationship between the isolation segment and the organization provided.

func (*Client) TargetCF

func (client *Client) TargetCF(settings TargetSettings) (Warnings, error)

TargetCF sets the client to use the Cloud Controller specified in the configuration. Any other configuration is also applied to the client.

func (*Client) UpdateTask

func (client *Client) UpdateTask(taskGUID string) (Task, Warnings, error)

UpdateTask cancels a task.

func (*Client) UploadPackage

func (client *Client) UploadPackage(pkg Package, fileToUpload string) (Package, Warnings, error)

UploadPackage uploads a file to a given package's Upload resource.

func (*Client) WrapConnection

func (client *Client) WrapConnection(wrapper ConnectionWrapper)

WrapConnection wraps the current Client connection in the wrapper.

type Config

type Config struct {
	// AppName is the name of the application/process using the client.
	AppName string

	// AppVersion is the version of the application/process using the client.
	AppVersion string

	// Wrappers that apply to the client connection.
	Wrappers []ConnectionWrapper
}

Config allows the Client to be configured

type ConnectionWrapper

type ConnectionWrapper interface {
	cloudcontroller.Connection
	Wrap(innerconnection cloudcontroller.Connection) cloudcontroller.Connection
}

ConnectionWrapper can wrap a given connection allowing the wrapper to modify all requests going in and out of the given connection.

type IsolationSegment

type IsolationSegment struct {
	Name string `json:"name"`
	GUID string `json:"guid,omitempty"`
}

IsolationSegment represents a Cloud Controller Isolation Segment.

type Organization

type Organization struct {
	Name string `json:"name"`
	GUID string `json:"guid"`
}

Organization represents a Cloud Controller V3 Organization.

type Package

type Package struct {
	GUID          string               `json:"guid,omitempty"`
	Links         APILinks             `json:"links,omitempty"`
	Relationships PackageRelationships `json:"relationships"`
	State         PackageState         `json:"state,omitempty"`
	Type          PackageType          `json:"type"`
}

type PackageRelationships

type PackageRelationships struct {
	Application Relationship `json:"app"`
}

type PackageState

type PackageState string
const (
	PackageStateProcessingUpload PackageState = "PROCESSING_UPLOAD"
	PackageStateReady            PackageState = "READY"
	PackageStateFailed           PackageState = "FAILED"
	PackageStateAwaitingUpload   PackageState = "AWAITING_UPLOAD"
	PackageStateCopying          PackageState = "COPYING"
	PackageStateExpired          PackageState = "EXPIRED"
)

type PackageType

type PackageType string
const (
	PackageTypeBits   PackageType = "bits"
	PackageTypeDocker PackageType = "docker"
)

type PaginatedResources

type PaginatedResources struct {
	Pagination struct {
		Next struct {
			HREF string `json:"href"`
		} `json:"next"`
	} `json:"pagination"`
	ResourcesBytes json.RawMessage `json:"resources"`
	// contains filtered or unexported fields
}

PaginatedResources represents a page of resources returned by the Cloud Controller.

func NewPaginatedResources

func NewPaginatedResources(exampleResource interface{}) PaginatedResources

NewPaginatedResources returns a new PaginatedResources struct with the given resource type.

func (PaginatedResources) NextPage

func (pr PaginatedResources) NextPage() string

NextPage returns the HREF of the next page of results.

func (PaginatedResources) Resources

func (pr PaginatedResources) Resources() ([]interface{}, error)

Resources unmarshals JSON representing a page of resources and returns a slice of the given resource type.

type Relationship

type Relationship struct {
	GUID string
}

Relationship represents a one to one relationship. An empty GUID will be marshaled as `null`.

func (Relationship) MarshalJSON

func (r Relationship) MarshalJSON() ([]byte, error)

func (*Relationship) UnmarshalJSON

func (r *Relationship) UnmarshalJSON(data []byte) error

type RelationshipList

type RelationshipList struct {
	GUIDs []string
}

RelationshipList represents a one to many relationship.

func (RelationshipList) MarshalJSON

func (r RelationshipList) MarshalJSON() ([]byte, error)

func (*RelationshipList) UnmarshalJSON

func (r *RelationshipList) UnmarshalJSON(data []byte) error
type ResourceLinks map[string]APILink

ResourceLinks represents the information returned back from /v3.

func (ResourceLinks) UnmarshalJSON

func (resources ResourceLinks) UnmarshalJSON(data []byte) error

UnmarshalJSON helps unmarshal a Cloud Controller /v3 response.

type TargetSettings

type TargetSettings struct {
	// DialTimeout is the DNS timeout used to make all requests to the Cloud
	// Controller.
	DialTimeout time.Duration

	// SkipSSLValidation controls whether a client verifies the server's
	// certificate chain and host name. If SkipSSLValidation is true, TLS accepts
	// any certificate presented by the server and any host name in that
	// certificate for *all* client requests going forward.
	//
	// In this mode, TLS is susceptible to man-in-the-middle attacks. This should
	// be used only for testing.
	SkipSSLValidation bool

	// URL is a fully qualified URL to the Cloud Controller API.
	URL string
}

TargetSettings represents configuration for establishing a connection to the Cloud Controller server.

type Task

type Task struct {
	GUID       string `json:"guid,omitempty"`
	SequenceID int    `json:"sequence_id,omitempty"`
	Name       string `json:"name,omitempty"`
	Command    string `json:"command"`
	State      string `json:"state,omitempty"`
	CreatedAt  string `json:"created_at,omitempty"`
	MemoryInMB uint64 `json:"memory_in_mb,omitempty"`
	DiskInMB   uint64 `json:"disk_in_mb,omitempty"`
}

Task represents a Cloud Controller V3 Task.

type Warnings

type Warnings []string

Warnings are a collection of warnings that the Cloud Controller can return back from an API request.

Directories

Path Synopsis
This file was generated by counterfeiter
This file was generated by counterfeiter

Jump to

Keyboard shortcuts

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