internal

package
v6.28.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2017 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DeleteIsolationSegmentRelationshipOrganizationRequest = "DeleteIsolationSegmentRelationshipOrganization"
	DeleteIsolationSegmentRequest                         = "DeleteIsolationSegment"
	GetAppsRequest                                        = "GetApps"
	GetAppProcessesRequest                                = "GetAppProcesses"
	GetAppTasksRequest                                    = "GetAppTasks"
	GetAppDropletCurrent                                  = "GetAppDropletCurrent"
	GetProcessInstancesRequest                            = "GetProcessInstances"
	GetBuildRequest                                       = "GetBuild"
	GetIsolationSegmentOrganizationsRequest               = "GetIsolationSegmentRelationshipOrganizations"
	GetIsolationSegmentRequest                            = "GetIsolationSegment"
	GetIsolationSegmentsRequest                           = "GetIsolationSegments"
	GetOrganizationDefaultIsolationSegmentRequest         = "GetOrganizationDefaultIsolationSegment"
	GetOrgsRequest                                        = "GetOrgs"
	GetPackageRequest                                     = "GetPackage"
	GetSpaceRelationshipIsolationSegmentRequest           = "GetSpaceRelationshipIsolationSegmentRequest"
	PatchApplicationCurrentDropletRequest                 = "PatchApplicationCurrentDroplet"
	PatchSpaceRelationshipIsolationSegmentRequest         = "PatchSpaceRelationshipIsolationSegmentRequest"
	PostApplicationRequest                                = "PostApplicationRequest"
	PostAppTasksRequest                                   = "PostAppTasks"
	PostBuildRequest                                      = "PostBuild"
	PostIsolationSegmentRelationshipOrganizationsRequest  = "PostIsolationSegmentRelationshipOrganizations"
	PostIsolationSegmentsRequest                          = "PostIsolationSegments"
	PostPackageRequest                                    = "PostPackageRequest"
	PutTaskCancelRequest                                  = "PutTaskCancelRequest"
	PutApplicationStartRequest                            = "PutApplicationStart"
	PutApplicationStopRequest                             = "PutApplicationStop"
)

Naming convention:

Method + non-parameter parts of the path

If the request returns a single entity by GUID, use the singular (for example /v2/organizations/:organization_guid is GetOrganization).

The const name should always be the const value + Request.

View Source
const (
	AppsResource              = "apps"
	BuildsResource            = "builds"
	IsolationSegmentsResource = "isolation_segments"
	OrgsResource              = "organizations"
	PackagesResource          = "packages"
	ProcessesResource         = "processes"
	SpaceResource             = "spaces"
	TasksResource             = "tasks"
)

Variables

View Source
var APIRoutes = []Route{
	{Path: "/", Method: http.MethodGet, Name: GetAppsRequest, Resource: AppsResource},
	{Path: "/", Method: http.MethodGet, Name: GetIsolationSegmentsRequest, Resource: IsolationSegmentsResource},
	{Path: "/", Method: http.MethodGet, Name: GetOrgsRequest, Resource: OrgsResource},
	{Path: "/", Method: http.MethodPost, Name: PostApplicationRequest, Resource: AppsResource},
	{Path: "/", Method: http.MethodPost, Name: PostBuildRequest, Resource: BuildsResource},
	{Path: "/", Method: http.MethodPost, Name: PostIsolationSegmentsRequest, Resource: IsolationSegmentsResource},
	{Path: "/", Method: http.MethodPost, Name: PostPackageRequest, Resource: PackagesResource},
	{Path: "/:guid", Method: http.MethodDelete, Name: DeleteIsolationSegmentRequest, Resource: IsolationSegmentsResource},
	{Path: "/:guid", Method: http.MethodGet, Name: GetBuildRequest, Resource: BuildsResource},
	{Path: "/:guid", Method: http.MethodGet, Name: GetIsolationSegmentRequest, Resource: IsolationSegmentsResource},
	{Path: "/:guid", Method: http.MethodGet, Name: GetPackageRequest, Resource: PackagesResource},
	{Path: "/:guid/cancel", Method: http.MethodPut, Name: PutTaskCancelRequest, Resource: TasksResource},
	{Path: "/:guid/droplets/current", Method: http.MethodGet, Name: GetAppDropletCurrent, Resource: AppsResource},
	{Path: "/:guid/organizations", Method: http.MethodGet, Name: GetIsolationSegmentOrganizationsRequest, Resource: IsolationSegmentsResource},
	{Path: "/:guid/processes", Method: http.MethodGet, Name: GetAppProcessesRequest, Resource: AppsResource},
	{Path: "/:guid/stats", Method: http.MethodGet, Name: GetProcessInstancesRequest, Resource: ProcessesResource},
	{Path: "/:guid/relationships/default_isolation_segment", Method: http.MethodGet, Name: GetOrganizationDefaultIsolationSegmentRequest, Resource: OrgsResource},
	{Path: "/:guid/relationships/isolation_segment", Method: http.MethodGet, Name: GetSpaceRelationshipIsolationSegmentRequest, Resource: SpaceResource},
	{Path: "/:guid/relationships/current_droplet", Method: http.MethodPatch, Name: PatchApplicationCurrentDropletRequest, Resource: AppsResource},
	{Path: "/:guid/relationships/isolation_segment", Method: http.MethodPatch, Name: PatchSpaceRelationshipIsolationSegmentRequest, Resource: SpaceResource},
	{Path: "/:guid/relationships/organizations", Method: http.MethodPost, Name: PostIsolationSegmentRelationshipOrganizationsRequest, Resource: IsolationSegmentsResource},
	{Path: "/:guid/relationships/organizations/:org_guid", Method: http.MethodDelete, Name: DeleteIsolationSegmentRelationshipOrganizationRequest, Resource: IsolationSegmentsResource},
	{Path: "/:guid/start", Method: http.MethodPut, Name: PutApplicationStartRequest, Resource: AppsResource},
	{Path: "/:guid/stop", Method: http.MethodPut, Name: PutApplicationStopRequest, Resource: AppsResource},
	{Path: "/:guid/tasks", Method: http.MethodGet, Name: GetAppTasksRequest, Resource: AppsResource},
	{Path: "/:guid/tasks", Method: http.MethodPost, Name: PostAppTasksRequest, Resource: AppsResource},
}

APIRoutes is a list of routes used by the router to construct request URLs.

Functions

This section is empty.

Types

type Params

type Params map[string]string

Params map path keys to values. For example, if your route has the path pattern:

/person/:person_id/pets/:pet_type

Then a correct Params map would lool like:

router.Params{
  "person_id": "123",
  "pet_type": "cats",
}

type Route

type Route struct {
	// Name is a key specifying which HTTP route the router should associate with
	// the endpoint at runtime.
	Name string
	// Method is any valid HTTP method
	Method string
	// Path contains a path pattern
	Path string
	// Resource is a key specifying which resource root the router should
	// associate with the endpoint at runtime.
	Resource string
}

Route defines the property of a Cloud Controller V3 endpoint.

Method can be one of the following:

GET HEAD POST PUT PATCH DELETE CONNECT OPTIONS TRACE

Path conforms to Pat-style pattern matching. The following docs are taken from http://godoc.org/github.com/bmizerany/pat#PatternServeMux

Path Patterns may contain literals or captures. Capture names start with a colon and consist of letters A-Z, a-z, _, and 0-9. The rest of the pattern matches literally. The portion of the URL matching each name ends with an occurrence of the character in the pattern immediately following the name, or a /, whichever comes first. It is possible for a name to match the empty string.

Example pattern with one capture:

/hello/:name

Will match:

/hello/blake
/hello/keith

Will not match:

/hello/blake/
/hello/blake/foo
/foo
/foo/bar

Example 2:

/hello/:name/

Will match:

/hello/blake/
/hello/keith/foo
/hello/blake
/hello/keith

Will not match:

/foo
/foo/bar

func (Route) CreatePath

func (r Route) CreatePath(params Params) (string, error)

CreatePath combines the route's path pattern with a Params map to produce a valid path.

type Router

type Router struct {
	// contains filtered or unexported fields
}

Router combines route and resource information in order to generate HTTP requests.

func NewRouter

func NewRouter(routes []Route, resources map[string]string) *Router

NewRouter returns a pointer to a new Router.

func (Router) CreateRequest

func (router Router) CreateRequest(name string, params Params, body io.Reader) (*http.Request, error)

CreateRequest returns a request key'd off of the name given. The params are merged into the URL and body is set as the request body.

Jump to

Keyboard shortcuts

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