v2

package
v0.0.0-...-ada4d11 Latest Latest
Warning

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

Go to latest
Published: May 4, 2020 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package v2 contains a client for working with service brokers implementing v2 of the Open Service Broker API.

Index

Constants

View Source
const (
	// APIVersionHeader is the header value associated with the version of the Open
	// Service Broker API version.
	APIVersionHeader = "X-Broker-API-Version"
	// OriginatingIdentityHeader is the header associated with originating
	// identity.
	OriginatingIdentityHeader = "X-Broker-API-Originating-Identity"
)
View Source
const (
	// AcceptsIncomplete is the name of a query parameter that indicates that
	// the client allows a request to complete asynchronously.
	AcceptsIncomplete = "accepts_incomplete"

	// VarKeyInstanceID is the name to use for a mux var representing an
	// instance ID.
	VarKeyInstanceID = "instance_id"

	// VarKeyBindingID is the name to use for a mux var representing a binding
	// ID.
	VarKeyBindingID = "binding_id"

	// VarKeyServiceID is the name to use for a mux var representing a service ID.
	VarKeyServiceID = "service_id"

	// VarKeyPlanID is the name to use for a mux var representing a plan ID.
	VarKeyPlanID = "plan_id"

	// VarKeyOperation is the name to use for a mux var representing an
	// operation.
	VarKeyOperation = "operation"

	// PlatformKubernetes is the name for Kubernetes in the Platform field of
	// OriginatingIdentity.
	PlatformKubernetes = "kubernetes"

	// PlatformCloudFoundry is the name for Cloud Foundry in the Platform field
	// of OriginatingIdentity.
	PlatformCloudFoundry = "cloudfoundry"
)
View Source
const (
	AsyncErrorMessage               = "AsyncRequired"
	AsyncErrorDescription           = "This service plan requires client support for asynchronous service operations."
	AppGUIDRequiredErrorMessage     = "RequiresApp"
	AppGUIDRequiredErrorDescription = "This service supports generation of credentials through binding an application only."
	ConcurrencyErrorMessage         = "ConcurrencyError"
	ConcurrencyErrorDescription     = "The Service Broker does not support concurrent requests that mutate the same resource."
)

Constants are used to check for spec-mandated errors and their messages

Variables

This section is empty.

Functions

func IsAppGUIDRequiredError

func IsAppGUIDRequiredError(err error) bool

IsAppGUIDRequiredError returns whether the error corresponds to the conventional way of indicating that a service only supports credential-type bindings.

func IsAsyncBindingOperationsNotAllowedError

func IsAsyncBindingOperationsNotAllowedError(err error) bool

IsAsyncBindingOperationsNotAllowedError returns whether the error represents asynchronous binding operations (bind/unbind/poll) not being allowed for this client.

func IsAsyncRequiredError

func IsAsyncRequiredError(err error) bool

IsAsyncRequiredError returns whether the error corresponds to the conventional way of indicating that a service requires asynchronous operations to perform an action.

func IsConcurrencyError

func IsConcurrencyError(err error) bool

IsConcurrencyError returns whether the error corresponds to the conventional way of indicating that a service broker does not support concurrent requests to modify the same resource

func IsConflictError

func IsConflictError(err error) bool

IsConflictError returns whether the error represents a conflict.

func IsGoneError

func IsGoneError(err error) bool

IsGoneError returns whether the error represents an HTTP GONE status.

Types

type APIVersion

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

APIVersion represents a specific version of the OSB API.

func APIVersions

func APIVersions() []APIVersion

APIVersions returns a list of the APIVersions supported by this library, with no guarantees of ordering.

func LatestAPIVersion

func LatestAPIVersion() APIVersion

LatestAPIVersion returns the latest supported API version in the current release of this library.

func Version2_11

func Version2_11() APIVersion

Version2_11 returns an APIVersion struct with the internal API version set to "2.11"

func Version2_12

func Version2_12() APIVersion

Version2_12 returns an APIVersion struct with the internal API version set to "2.12"

func Version2_13

func Version2_13() APIVersion

Version2_13 returns an APIVersion struct with the internal API version set to "2.13"

func (APIVersion) AtLeast

func (v APIVersion) AtLeast(test APIVersion) bool

AtLeast returns whether the API version is greater than or equal to the given API version.

func (APIVersion) HeaderValue

func (v APIVersion) HeaderValue() string

HeaderValue returns the value that should be sent in the API version header for this API version.

func (APIVersion) String

func (v APIVersion) String() string

type AlphaAPIMethodsNotAllowedError

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

AlphaAPIMethodsNotAllowedError is an error type signifying that alpha API methods are not allowed for this client's API Version.

func (AlphaAPIMethodsNotAllowedError) Error

type AsyncBindingOperationsNotAllowedError

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

AsyncBindingOperationsNotAllowedError is an error type signifying that asynchronous binding operations (bind/unbind/poll) are not allowed for this client.

func (AsyncBindingOperationsNotAllowedError) Error

type AuthConfig

type AuthConfig struct {
	BasicAuthConfig *BasicAuthConfig
	BearerConfig    *BearerConfig
}

AuthConfig is a union-type representing the possible auth configurations a client may use to authenticate to a broker. Currently, only basic auth is supported.

type BasicAuthConfig

type BasicAuthConfig struct {
	// Username is the basic auth username.
	Username string
	// Password is the basic auth password.
	Password string
}

BasicAuthConfig represents a set of basic auth credentials.

type BearerConfig

type BearerConfig struct {
	// Token is the bearer token.
	Token string
}

BearerConfig represents bearer token credentials.

type BindRequest

type BindRequest struct {
	// BindingID is the ID of the new binding to create. The Open Service
	// Broker API specification recommends using a GUID for this field.
	BindingID string `json:"binding_id"`
	// InstanceID is the ID of the instance to bind to.
	InstanceID string `json:"instance_id"`
	// AcceptsIncomplete is an ALPHA API attribute and may change. Alpha
	// features must be enabled and the client must be using the latest API
	// Version in order to use this.
	//
	// AcceptsIncomplete indicates whether the client can accept asynchronous
	// binding. If the broker cannot fulfill a request synchronously and
	// AcceptsIncomplete is set to false, the broker will reject the request. A
	// broker may choose to response to a request with AcceptsIncomplete set to
	// true either synchronously or asynchronously.
	AcceptsIncomplete bool `json:"accepts_incomplete"`
	// ServiceID is the ID of the service the instance was provisioned from.
	ServiceID string `json:"service_id"`
	// PlanID is the ID of the plan the instance was provisioned from.
	PlanID string `json:"plan_id"`
	// Deprecated; use bind_resource.app_guid to send this value instead.
	AppGUID *string `json:"app_guid,omitempty"`
	// BindResource holds extra information about a binding. Optional, but
	// it's complicated. TODO: clarify
	BindResource *BindResource `json:"bind_resource,omitempty"`
	// Parameters is configuration parameters for the binding. Optional.
	Parameters map[string]interface{} `json:"parameters,omitempty"`
	// Context requires a client API version >= 2.13.
	//
	// Context is platform-specific contextual information under which the
	// service binding is to be created.
	Context map[string]interface{} `json:"context,omitempty"`
	// OriginatingIdentity requires a client API version >= 2.13.
	//
	// OriginatingIdentity is the identity on the platform of the user making
	// this request.
	OriginatingIdentity *OriginatingIdentity `json:"originatingIdentity,omitempty"`
}

BindRequest represents a request to create a new binding to an instance of a service.

type BindResource

type BindResource struct {
	AppGUID *string `json:"appGuid,omitempty"`
	Route   *string `json:"route,omitempty"`
}

BindResource contains data for platform resources associated with a binding.

type BindResponse

type BindResponse struct {
	// Async is an ALPHA API attribute and may change. Alpha
	// features must be enabled and the client must be using the
	// latest API Version in order to use this.
	//
	// Async indicates whether the broker is handling the bind request
	// asynchronously.
	Async bool `json:"async"`
	// Credentials is a free-form hash of credentials that can be used by
	// applications or users to access the service.
	Credentials map[string]interface{} `json:"credentials,omitempty"`
	// SyslogDrainURl is a URL to which logs must be streamed. CF-specific.
	// May only be supplied by a service that declares a requirement for the
	// 'syslog_drain' permission.
	SyslogDrainURL *string `json:"syslog_drain_url,omitempty"`
	// RouteServiceURL is a URL to which the platform must proxy requests to
	// the application the binding is for. CF-specific. May only be supplied
	// by a service that declares a requirement for the 'route_service'
	// permission.
	RouteServiceURL *string `json:"route_service_url,omitempty"`
	// VolumeMounts is an array of configuration string for mounting volumes.
	// CF-specific. May only be supplied by a service that declares a
	// requirement for the 'volume_mount' permission.
	VolumeMounts []interface{} `json:"volume_mounts,omitempty"`
	// OperationKey is an ALPHA API attribute and may change. Alpha
	// features must be enabled and the client must be using the
	// latest API Version in order to use this.
	//
	// OperationKey is an extra identifier supplied by the broker to identify
	// asynchronous operations.
	OperationKey *OperationKey `json:"operation,omitempty"`
}

BindResponse represents a broker's response to a BindRequest.

type BindingLastOperationRequest

type BindingLastOperationRequest struct {
	// InstanceID is the instance of the service to query the last operation
	// for.
	InstanceID string `json:"instance_id"`
	// BindingID is the binding to query the last operation for.
	BindingID string `json:"binding_id"`
	// ServiceID is the ID of the service the instance is provisioned from.
	// Optional, but recommended.
	ServiceID *string `json:"service_id,omitempty"`
	// PlanID is the ID of the plan the instance is provisioned from.
	// Optional, but recommended.
	PlanID *string `json:"plan_id,omitempty"`
	// OperationKey is the operation key provided by the broker in the response
	// to the initial request. Optional, but must be sent if supplied in the
	// response to the original request.
	OperationKey *OperationKey `json:"operation,omitempty"`
	// OriginatingIdentity requires a client API version >= 2.13.
	//
	// OriginatingIdentity is the identity on the platform of the user making
	// this request.
	OriginatingIdentity *OriginatingIdentity `json:"originatingIdentity,omitempty"`
}

BindingLastOperationRequest represents a request to a broker to give the state of the action on a binding it is completing asynchronously.

type CatalogResponse

type CatalogResponse struct {
	Services []Service `json:"services"`
}

CatalogResponse is sent as the response to catalog requests.

type Client

type Client interface {
	// GetCatalog returns information about the services the broker offers and
	// their plans or an error.  GetCatalog calls GET on the Broker's catalog
	// endpoint (/v2/catalog).
	GetCatalog() (*CatalogResponse, error)
	// ProvisionInstance requests that a new instance of a service be
	// provisioned and returns information about the instance or an error.
	// ProvisionInstance does a PUT on the Broker's endpoint for the requested
	// instance ID (/v2/service_instances/instance-id).
	//
	// If the AcceptsIncomplete field of the request is set to true, the
	// broker may complete the request asynchronously.  Callers should check
	// the value of the Async field on the response and check the operation
	// status using PollLastOperation if the Async field is true.
	ProvisionInstance(r *ProvisionRequest) (*ProvisionResponse, error)
	// UpdateInstance requests that an instances plan or parameters be updated
	// and returns information about asynchronous responses or an error.
	// UpdateInstance does a PATCH on the Broker's endpoint for the requested
	// instance ID (/v2/service_instances/instance-id).
	//
	// If the AcceptsIncomplete field of the request is set to true, the
	// broker may complete the request asynchronously.  Callers should check
	// the value of the Async field on the response and check the operation
	// status using PollLastOperation if the Async field is true.
	UpdateInstance(r *UpdateInstanceRequest) (*UpdateInstanceResponse, error)
	// DeprovisionInstance requests that an instances plan or parameters be
	// updated and returns information about asynchronous responses or an
	// error. DeprovisionInstance does a DELETE on the Broker's endpoint for
	// the requested instance ID (/v2/service_instances/instance-id).
	//
	// If the AcceptsIncomplete field of the request is set to true, the
	// broker may complete the request asynchronously.  Callers should check
	// the value of the Async field on the response and check the operation
	// status using PollLastOperation if the Async field is true.  Note that
	// there are special semantics for PollLastOperation when checking the
	// status of deprovision operations; see the doc for that method.
	DeprovisionInstance(r *DeprovisionRequest) (*DeprovisionResponse, error)
	// GetInstance is an ALPHA API method and may change. Alpha features must
	// be enabled and the client must be using the latest API Version in
	// order to use this method.
	//
	// GetInstance returns information about an existing instance.
	// GetInstance calls GET on the Broker's endpoint for the requested
	// instance ID (/v2/service_instances/instance-id)
	GetInstance(r *GetInstanceRequest) (*GetInstanceResponse, error)
	// PollLastOperation sends a request to query the last operation for a
	// service instance to the broker and returns information about the
	// operation or an error.  PollLastOperation does a GET on the broker's
	// last operation endpoint for the requested instance ID
	// (/v2/service_instances/instance-id/last_operation).
	//
	// Callers should periodically call PollLastOperation until they receive a
	// success response.  PollLastOperation may return an HTTP GONE error for
	// asynchronous deprovisions.  This is a valid response for async
	// operations and means that the instance has been successfully
	// deprovisioned.  When calling PollLastOperation to check the status of
	// an asynchronous deprovision, callers check the status of an
	// asynchronous deprovision, callers should test the value of the returned
	// error with IsGoneError.
	PollLastOperation(r *LastOperationRequest) (*LastOperationResponse, error)
	// PollBindingLastOperation is an ALPHA API method and may change.
	// Alpha features must be enabled and the client must be using the
	// latest API Version in order to use this method.
	//
	// PollBindingLastOperation sends a request to query the last operation
	// for a service binding to the broker and returns information about the
	// operation or an error.  PollBindingLastOperation does a GET on the broker's
	// last operation endpoint for the requested binding ID
	// (/v2/service_instances/instance-id/service_bindings/binding-id/last_operation).
	//
	// Callers should periodically call PollBindingLastOperation until they
	// receive a success response.  PollBindingLastOperation may return an
	// HTTP GONE error for asynchronous unbinding.  This is a valid response
	// for async operations and means that the binding has been successfully
	// deleted.  When calling PollBindingLastOperation to check the status of
	// an asynchronous unbind, callers should test the value of the returned
	// error with IsGoneError.
	PollBindingLastOperation(r *BindingLastOperationRequest) (*LastOperationResponse, error)
	// Bind requests a new binding between a service instance and an
	// application and returns information about the binding or an error. Bind
	// does a PUT on the Broker's endpoint for the requested instance and
	// binding IDs (/v2/service_instances/instance-id/service_bindings/binding-id).
	Bind(r *BindRequest) (*BindResponse, error)
	// Bind requests that a binding between a service instance and an
	// application be deleted and returns information about the binding or an
	// error. Unbind does a DELETE on the Broker's endpoint for the requested
	// instance and binding IDs (/v2/service_instances/instance-id/service_bindings/binding-id).
	Unbind(r *UnbindRequest) (*UnbindResponse, error)
	// GetBinding is an ALPHA API method and may change. Alpha features must
	// be enabled and the client must be using the latest API Version in
	// order to use this method.
	//
	// GetBinding returns configuration and credential information
	// about an existing binding. GetBindings calls GET on the Broker's
	// binding endpoint
	// (/v2/service_instances/instance-id/service_bindings/binding-id)
	GetBinding(r *GetBindingRequest) (*GetBindingResponse, error)
}

Client defines the interface to the v2 Open Service Broker client. The logical lifecycle of client operations is:

1. Get the broker's catalog of services with the GetCatalog method 2. Provision a new instance of a service with the ProvisionInstance method 3. Update the parameters or plan of an instance with the UpdateInstance method 4. Deprovision an instance with the DeprovisionInstance method

Some services and plans support binding from an instance of the service to an application. The logical lifecycle of a binding is:

1. Create a new binding to an instance of a service with the Bind method 2. Delete a binding to an instance with the Unbind method

func NewClient

func NewClient(config *ClientConfiguration) (Client, error)

NewClient is a CreateFunc for creating a new functional Client and implements the CreateFunc interface.

type ClientConfiguration

type ClientConfiguration struct {
	// Name is the name to use for this client in log messages.  Using the
	// logical name of the Broker this client is for is recommended.
	Name string
	// URL is the URL to use to contact the broker.
	URL string
	// APIVersion is the APIVersion to use for this client.  API features
	// adopted after the 2.11 version of the API will only be sent if
	// APIVersion is an API version that supports them.
	APIVersion APIVersion
	// AuthInfo is the auth configuration the client should use to authenticate
	// to the broker.
	AuthConfig *AuthConfig
	// TLSConfig is the TLS configuration to use when communicating with the
	// broker.
	TLSConfig *tls.Config
	// Insecure represents whether the 'InsecureSkipVerify' TLS configuration
	// field should be set.  If the TLSConfig field is set and this field is
	// set to true, it overrides the value in the TLSConfig field.
	Insecure bool
	// TimeoutSeconds is the length of the timeout of any request to the
	// broker, in seconds.
	TimeoutSeconds int
	// EnableAlphaFeatures controls whether alpha features in the Open Service
	// Broker API are enabled in a client.  Features are considered to be
	// alpha if they have been accepted into the Open Service Broker API but
	// not released in a version of the API specification.  Features are
	// indicated as being alpha when the client API fields they represent
	// begin with the 'Alpha' prefix.
	//
	// If alpha features are not enabled, the client will not send or return
	// any request parameters or request or response fields that correspond to
	// alpha features.
	EnableAlphaFeatures bool
	// CAData holds PEM-encoded bytes (typically read from a root certificates bundle).
	// This CA certificate will be added to any specified in TLSConfig.RootCAs.
	CAData []byte
	// Verbose is whether the client will log to klog.
	Verbose bool
}

ClientConfiguration represents the configuration of a Client.

func DefaultClientConfiguration

func DefaultClientConfiguration() *ClientConfiguration

DefaultClientConfiguration returns a default ClientConfiguration:

  • latest API version
  • 60 second timeout (referenced as a typical timeout in the Open Service Broker API spec)
  • alpha features disabled

type CreateFunc

type CreateFunc func(*ClientConfiguration) (Client, error)

CreateFunc allows control over which implementation of a Client is returned. Users of the Client interface may need to create clients for multiple brokers in a way that makes normal dependency injection prohibitive. In order to make such code testable, users of the API can inject a CreateFunc, and use the CreateFunc from the fake package in tests.

type DashboardClient

type DashboardClient struct {
	// ID is the ID to use for the dashboard SSO OAuth client for this service.
	ID string `json:"id"`
	// Secret is a secret for the dashboard SSO OAuth client.
	Secret string `json:"secret"`
	// RedirectURI is the redirect URI that should be used to obtain an OAuth
	// token.
	RedirectURI string `json:"redirect_uri"`
}

DashboardClient contains information about the OAuth SSO flow for a Service's dashboard.

type DeprovisionRequest

type DeprovisionRequest struct {
	// InstanceID is the ID of the instance to deprovision.
	InstanceID string `json:"instance_id"`
	// AcceptsIncomplete indicates whether the client can accept asynchronous
	// deprovisioning. If the broker cannot fulfill a request synchronously and
	// AcceptsIncomplete is set to false, the broker will reject the request.
	// A broker may choose to response to a request with AcceptsIncomplete set
	// to true either synchronously or asynchronously.
	AcceptsIncomplete bool `json:"accepts_incomplete"`
	// ServiceID is the ID of the service the instance is provisioned from.
	ServiceID string `json:"service_id"`
	// PlanID is the ID of the plan the instance is provisioned from.
	PlanID string `json:"plan_id"`
	// OriginatingIdentity requires a client API version >= 2.13.
	//
	// OriginatingIdentity is the identity on the platform of the user making
	// this request.
	OriginatingIdentity *OriginatingIdentity `json:"originatingIdentity,omitempty"`
}

DeprovisionRequest represents a request to deprovision an instance of a service.

type DeprovisionResponse

type DeprovisionResponse struct {
	// Async indicates whether the broker is handling the deprovision request
	// asynchronously.
	Async bool `json:"async"`
	// OperationKey is an extra identifier supplied by the broker to identify
	// asynchronous operations.
	OperationKey *OperationKey `json:"operation,omitempty"`
}

DeprovisionResponse represents a broker's response to a deprovision request.

type ExtensionAPI

type ExtensionAPI struct {
	// DiscoveryURL is a URI pointing to a valid OpenAPI 3.0+ document
	// describing the API extension(s) to the Open Service Broker API including,
	// endpoints, parameters, authentication mechanism and any other detail the
	// platform needs for invocation. The location of the API extension
	// endpoint(s) can be local to the Service Broker or on a remote server. If
	// local to the Service Broker the same authentication method for normal
	// Service Broker calls must be used.
	DiscoveryURL string `json:"discovery_url,omitempty"`
	// ServerURL is a URI pointing to a remote server where API extensions will
	// run. This URI will be used as the basepath for the paths objects
	// described by the `discovery_url` OpenAPI document. If ServerURL is
	// missing, it means that the paths are invoked relative to the service
	// broker URL.
	ServerURL string `json:"server_url,omitempty"`
	// Credentials is a set of authentication details for running any of the
	// extension API calls, especially for those running on remote servers.
	//
	// The information in Credentials should be treated as SECRET.
	Credentials map[string]interface{} `json:"credentials,omitempty"`
	// AdheresTo is a URI refering to a specification detailing the interface
	// the OpenAPI document hosted at the `discovery_url` adheres to.
	AdheresTo string `json:"adheres_to,omitempty"`
}

ExtensionAPI contains information about an API endpoint that describes extension operations on a ServiceInstance.

ExtensionAPI is an ALPHA API attribute and may change. Alpha features must be enabled and the client must be using the latest API Version in order to use this.

type GetBindingNotAllowedError

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

GetBindingNotAllowedError is an error type signifying that doing a GET to fetch a binding is not allowed for this client.

func (GetBindingNotAllowedError) Error

type GetBindingRequest

type GetBindingRequest struct {
	// InstanceID is the ID of the instance the binding is for.
	InstanceID string `json:"instance_id"`
	// BindingID is the ID of the binding to delete.
	BindingID string `json:"binding_id"`
}

GetBindingRequest represents a request to do a GET on a particular binding.

type GetBindingResponse

type GetBindingResponse struct {
	// Credentials is a free-form hash of credentials that can be used by
	// applications or users to access the service.
	Credentials map[string]interface{} `json:"credentials,omitempty"`
	// SyslogDrainURl is a URL to which logs must be streamed. CF-specific. May
	// only be supplied by a service that declares a requirement for the
	// 'syslog_drain' permission.
	SyslogDrainURL *string `json:"syslog_drain_url,omitempty"`
	// RouteServiceURL is a URL to which the platform must proxy requests to the
	// application the binding is for. CF-specific. May only be supplied by a
	// service that declares a requirement for the 'route_service' permission.
	RouteServiceURL *string `json:"route_service_url,omitempty"`
	// VolumeMounts is an array of configuration string for mounting volumes.
	// CF-specific. May only be supplied by a service that declares a
	// requirement for the 'volume_mount' permission.
	VolumeMounts []interface{} `json:"volume_mounts,omitempty"`
	// Parameters is configuration parameters for the binding.
	Parameters map[string]interface{} `json:"parameters,omitempty"`
}

GetBindingResponse is sent as the response to doing a GET on a particular binding.

type GetInstanceNotAllowedError

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

GetInstanceNotAllowedError is an error type signifying that doing a GET to fetch a service instance is not allowed for this client.

func (GetInstanceNotAllowedError) Error

type GetInstanceRequest

type GetInstanceRequest struct {
	// InstanceID is the ID of the instance
	InstanceID string `json:"instance_id"`
}

GetInstanceRequest represents a request to do a GET on a particular instance of a service.

type GetInstanceResponse

type GetInstanceResponse struct {
	// ServiceID is the ID of the service the instance is provisioned from.
	ServiceID string `json:"service_id"`
	// PlanID is the ID of the plan the instance is provisioned from.
	PlanID string `json:"plan_id"`
	// DashboardURL is the URL of a web-based management user interface for
	// the service instance.
	DashboardURL string `json:"dashboard_url,omitempty"`
	// Parameters is a set of configuration options for the instance.
	Parameters map[string]interface{} `json:"parameters,omitempty"`
}

GetInstanceResponse is sent as the response to doing a GET on a particular instance.

type HTTPStatusCodeError

type HTTPStatusCodeError struct {
	// StatusCode is the HTTP status code returned by the broker.
	StatusCode int
	// ErrorMessage is a machine-readable error string that may be returned by
	// the broker.
	ErrorMessage *string
	// Description is a human-readable description of the error that may be
	// returned by the broker.
	Description *string
	// ResponseError is set to the error that occurred when unmarshalling a
	// response body from the broker.
	ResponseError error
}

HTTPStatusCodeError is an error type that provides additional information based on the Open Service Broker API conventions for returning information about errors. If the response body provided by the broker to any client operation is malformed, an error of this type will be returned with the ResponseError field set to the unmarshalling error.

These errors may optionally provide a machine-readable error message and human-readable description.

The IsHTTPError method checks whether an error is of this type.

Checks for important errors in the API specification are implemented as utility methods:

- IsGoneError - IsConflictError - IsAsyncRequiredError - IsAppGUIDRequiredError

func IsHTTPError

func IsHTTPError(err error) (*HTTPStatusCodeError, bool)

IsHTTPError returns whether the error represents an HTTPStatusCodeError. A client method returning an HTTP error indicates that the broker returned an error code and a correctly formed response body.

func (HTTPStatusCodeError) Error

func (e HTTPStatusCodeError) Error() string

type InputParametersSchema

type InputParametersSchema struct {
	// The schema definition for the input parameters. Each input parameter
	// is expressed as a property within a JSON object.
	Parameters interface{} `json:"parameters,omitempty"`
}

InputParametersSchema requires a client API version >=2.13.

InputParametersSchema represents a schema for input parameters for creation or update of an API resource.

type LastOperationRequest

type LastOperationRequest struct {
	// InstanceID is the instance of the service to query the last operation
	// for.
	InstanceID string `json:"instance_id"`
	// ServiceID is the ID of the service the instance is provisioned from.
	// Optional, but recommended.
	ServiceID *string `json:"service_id,omitempty"`
	// PlanID is the ID of the plan the instance is provisioned from.
	// Optional, but recommended.
	PlanID *string `json:"plan_id,omitempty"`
	// OperationKey is the operation key provided by the broker in the response
	// to the initial request. Optional, but must be sent if supplied in the
	// response to the original request.
	OperationKey *OperationKey `json:"operation,omitempty"`
	// OriginatingIdentity requires a client API version >= 2.13.
	//
	// OriginatingIdentity is the identity on the platform of the user making
	// this request.
	OriginatingIdentity *OriginatingIdentity `json:"originatingIdentity,omitempty"`
}

LastOperationRequest represents a request to a broker to give the state of the action it is completing asynchronously.

type LastOperationResponse

type LastOperationResponse struct {
	// State is the state of the queried operation.
	State LastOperationState `json:"state"`
	// Description is a message from the broker describing the current state
	// of the operation.
	Description *string `json:"description,omitempty"`
}

LastOperationResponse represents the broker response with the state of a discrete action that the broker is completing asynchronously.

type LastOperationState

type LastOperationState string

LastOperationState is a typedef representing the state of an ongoing operation for an instance.

const (
	StateInProgress LastOperationState = "in progress"
	StateSucceeded  LastOperationState = "succeeded"
	StateFailed     LastOperationState = "failed"
)

Defines the possible states of an asynchronous request to a broker.

type OperationKey

type OperationKey string

OperationKey is an extra identifier from the broker in order to provide extra identifiers for asynchronous operations.

type OriginatingIdentity

type OriginatingIdentity struct {
	// The name of the platform to which the user belongs
	Platform string
	// A serialized JSON object that describes the user in a way that makes
	// sense to the platform
	Value string
}

OriginatingIdentity requires a client API version >=2.13.

OriginatingIdentity is used to pass to the broker service an identity from the platform

type Plan

type Plan struct {
	// ID is a globally unique ID that identifies the plan.
	ID string `json:"id"`
	// Name is the plan's display name.
	Name string `json:"name"`
	// Description is a brief description of the plan, suitable for printing by
	// a CLI.
	Description string `json:"description"`
	// Free indicates whether the plan is available without charge. Optional;
	// defaults to true.
	Free *bool `json:"free,omitempty"`
	// Bindable indicates whether the plan is bindable and overrides the value
	// of the Service.Bindable field if set. Optional; defaults to unset.
	Bindable *bool `json:"bindable,omitempty"`
	// Metadata is a blob of information about the plan, meant to be user-
	// facing content and display instructions. Metadata may contain
	// platform-conventional values. Optional.
	Metadata map[string]interface{} `json:"metadata,omitempty"`
	// Schemas requires a client API version >=2.13.
	//
	// Schemas is a set of optional JSONSchemas that describe
	// the expected parameters for creation and update of instances and
	// creation of bindings.
	Schemas *Schemas `json:"schemas,omitempty"`
}

Plan is a plan (or tier) within a service offering.

type PreviousValues

type PreviousValues struct {
	// ID of the plan prior to the update. If present, MUST be a non-empty
	// string.
	PlanID string `json:"plan_id,omitempty"`
	// Deprecated; determined to be unnecessary as the value is immutable. ID of
	// the service for the service instance. If present, MUST be a non-empty
	// string.
	ServiceID string `json:"service_id,omitempty"`
	// Deprecated; Organization for the service instance MUST be provided by
	// platforms in the top-level field context. ID of the organization
	// specified for the service instance. If present, MUST be a non-empty
	// string.
	OrgID string `json:"organization_id,omitempty"`
	// Deprecated; Space for the service instance MUST be provided by platforms
	// in the top-level field context. ID of the space specified for the service
	// instance. If present, MUST be a non-empty string.
	SpaceID string `json:"space_id,omitempty"`
}

PreviousValues represents information about the service instance prior to the update.

type ProvisionRequest

type ProvisionRequest struct {
	// InstanceID is the ID of the new instance to provision. The Open
	// Service Broker API specification recommends using a GUID for this
	// field.
	InstanceID string `json:"instance_id"`
	// AcceptsIncomplete indicates whether the client can accept asynchronous
	// provisioning. If the broker cannot fulfill a request synchronously and
	// AcceptsIncomplete is set to false, the broker will reject the request.
	// A broker may choose to response to a request with AcceptsIncomplete set
	// to true either synchronously or asynchronously.
	AcceptsIncomplete bool `json:"accepts_incomplete"`
	// ServiceID is the ID of the service to provision a new instance of.
	ServiceID string `json:"service_id"`
	// PlanID is the ID of the plan to use for the new instance.
	PlanID string `json:"plan_id"`
	// OrganizationGUID is the platform GUID for the organization under which
	// the service is to be provisioned. CF-specific.
	OrganizationGUID string `json:"organization_guid"`
	// SpaceGUID is the identifier for the project space within the platform
	// organization. CF-specific.
	SpaceGUID string `json:"space_guid"`
	// Parameters is a set of configuration options for the service instance.
	// Optional.
	Parameters map[string]interface{} `json:"parameters,omitempty"`
	// Context requires a client API version >= 2.12.
	//
	// Context is platform-specific contextual information under which the
	// service instance is to be provisioned.
	Context map[string]interface{} `json:"context,omitempty"`
	// OriginatingIdentity requires a client API version >= 2.13.
	//
	// OriginatingIdentity is the identity on the platform of the user making
	// this request.
	OriginatingIdentity *OriginatingIdentity `json:"originatingIdentity,omitempty"`
}

ProvisionRequest represents a request to provision a new instance of a service and plan.

type ProvisionResponse

type ProvisionResponse struct {
	// Async indicates whether the broker is handling the provision request
	// asynchronously.
	Async bool `json:"async"`
	// DashboardURL is the URL of a web-based management user interface for
	// the service instance.
	DashboardURL *string `json:"dashboard_url,omitempty"`
	// OperationKey is an extra identifier supplied by the broker to identify
	// asynchronous operations.
	OperationKey *OperationKey `json:"operation,omitempty"`
	// ExtensionAPIs is a list of extension APIs for this instance.
	//
	// ExtensionsAPI is an ALPHA API attribute and may change. Alpha
	// features must be enabled and the client must be using the
	// latest API Version in order to use this.
	ExtensionAPIs []ExtensionAPI `json:"extension_apis,omitempty"`
}

ProvisionResponse is sent in response to a provision call.

type Schemas

type Schemas struct {
	// ServiceInstance hold schemas for operations on service instances.
	ServiceInstance *ServiceInstanceSchema `json:"service_instance,omitempty"`
	// ServiceBinding holds schemas for operations on service bindings.
	ServiceBinding *ServiceBindingSchema `json:"service_binding,omitempty"`
}

Schemas requires a client API version >=2.13.

Schemas is a set of optional JSONSchemas that describe schema associated with creation and update of instances and creation of bindings.

type Service

type Service struct {
	// ID is a globally unique ID that identifies the service.
	ID string `json:"id"`
	// Name is the service's display name.
	Name string `json:"name"`
	// Description is a brief description of the service, suitable for
	// printing by a CLI.
	Description string `json:"description"`
	// A list of 'tags' describing different classification referents or
	// attributes of the service. CF-specific.
	Tags []string `json:"tags,omitempty"`
	// A list of permissions the user must give instances of this service.
	// CF-specific. Current valid values are:
	//
	// - syslog_drain
	// - route_forwarding
	// - volume_mount
	//
	// See the Open Service Broker API spec for information on permissions.
	Requires []string `json:"requires,omitempty"`
	// Bindable represents whether a service is bindable. May be overridden
	// on a per-plan basis by the Plan.Bindable field.
	Bindable bool `json:"bindable"`
	// InstancesRetrievable is ALPHA and may change or disappear at any time.
	// InstancesRetrievable will only be provided if alpha features are enabled.
	//
	// InstancesRetrievable represents whether fetching a service instances via a
	// GET on the service instance resource's endpoint
	// (/v2/service_instances/instance-id) is supported for all plans.
	InstancesRetrievable bool `json:"instances_retrievable,omitempty"`
	// BindingsRetrievable is ALPHA and may change or disappear at any time.
	// BindingsRetrievable will only be provided if alpha features are enabled.
	//
	// BindingsRetrievable represents whether fetching a service binding via a
	// GET on the binding resource's endpoint
	// (/v2/service_instances/instance-id/service_bindings/binding-id) is
	// supported for all plans.
	BindingsRetrievable bool `json:"bindings_retrievable,omitempty"`
	// PlanUpdatable represents whether instances of this service may be
	// updated to a different plan. The serialized form 'plan_updateable' is
	// a mistake that has become written into the API for backward
	// compatibility reasons and is intentional. Optional; defaults to false.
	PlanUpdatable *bool `json:"plan_updateable,omitempty"`
	// Plans is the list of the Plans for a service. Plans represent
	// different tiers.
	Plans []Plan `json:"plans"`
	// DashboardClient holds information about the OAuth SSO for the service's
	// dashboard. Optional.
	DashboardClient *DashboardClient `json:"dashboard_client,omitempty"`
	// Metadata is a blob of information about the plan, meant to be user-
	// facing content and display instructions. Metadata may contain
	// platform-conventional values. Optional.
	Metadata map[string]interface{} `json:"metadata,omitempty"`
}

Service is an available service listed in a broker's catalog.

type ServiceBindingSchema

type ServiceBindingSchema struct {
	// Create holds the schemas for the parameters accepted when a new binding
	// is created and for the credentials returned when a new binding is
	// created.
	Create *InputParametersSchema `json:"create,omitempty"`
}

ServiceBindingSchema requires a client API version >=2.13.

ServiceBindingSchema represents a plan's schemas associated with bindings.

type ServiceInstanceSchema

type ServiceInstanceSchema struct {
	// Create is the schema for the parameters accepted for provisioning an
	// instance of a service.
	Create *InputParametersSchema `json:"create,omitempty"`
	// Update is the schema for the parameters accepted for updating an
	// instance.
	Update *InputParametersSchema `json:"update,omitempty"`
}

ServiceInstanceSchema requires a client API version >=2.13.

ServiceInstanceSchema represents a plan's schemas for creation and update of an API resource.

type UnbindRequest

type UnbindRequest struct {
	// InstanceID is the ID of the instance the binding is for.
	InstanceID string `json:"instance_id"`
	// BindingID is the ID of the binding to delete.
	BindingID string `json:"binding_id"`
	// AcceptsIncomplete is an ALPHA API attribute and may change. Alpha
	// features must be enabled and the client must be using the latest API
	// Version in order to use this.
	//
	// AcceptsIncomplete indicates whether the client can accept asynchronous
	// unbinding. If the broker cannot fulfill a request synchronously and
	// AcceptsIncomplete is set to false, the broker will reject the request. A
	// broker may choose to response to a request with AcceptsIncomplete set to
	// true either synchronously or asynchronously.
	AcceptsIncomplete bool `json:"accepts_incomplete"`
	// ServiceID is the ID of the service the instance was provisioned from.
	ServiceID string `json:"service_id"`
	// PlanID is the ID of the plan the instance was provisioned from.
	PlanID string `json:"plan_id"`
	// OriginatingIdentity requires a client API version >= 2.13.
	//
	// OriginatingIdentity is the identity on the platform of the user making
	// this request.
	OriginatingIdentity *OriginatingIdentity `json:"originatingIdentity,omitempty"`
}

UnbindRequest represents a request to unbind a particular binding.

type UnbindResponse

type UnbindResponse struct {
	// Async is an ALPHA API attribute and may change. Alpha features must be
	// enabled and the client must be using the latest API Version in order to
	// use this.
	//
	// Async indicates whether the broker is handling the unbind request
	// asynchronously.
	Async bool `json:"async"`
	// OperationKey is an ALPHA API attribute and may change. Alpha features
	// must be enabled and the client must be using the latest API Version in
	// order to use this.
	//
	// OperationKey is an extra identifier supplied by the broker to identify
	// asynchronous operations.
	OperationKey *OperationKey `json:"operation,omitempty"`
}

UnbindResponse represents a broker's response to an UnbindRequest.

type UpdateInstanceRequest

type UpdateInstanceRequest struct {
	// InstanceID is the ID of the instance to update.
	InstanceID string `json:"instance_id"`
	// AcceptsIncomplete indicates whether the client can accept asynchronous
	// updating of an instance. If the broker cannot fulfill a request
	// synchronously and AcceptsIncomplete is set to false, the broker will
	// reject the request. A broker may choose to response to a request with
	// AcceptsIncomplete set to true either synchronously or asynchronously.
	AcceptsIncomplete bool `json:"accepts_incomplete"`
	// ServiceID is the ID of the service the instance is provisioned from.
	ServiceID string `json:"service_id"`
	// PlanID is the ID the plan to update the instance to. The service must
	// support plan updates. If unspecified, indicates that the client does not
	// wish to update the plan of the instance.
	PlanID *string `json:"plan_id,omitempty"`
	// Parameters is a set of configuration options for the instance. If
	// unset, indicates that the client does not wish to update the parameters
	// for an instance.
	Parameters map[string]interface{} `json:"parameters,omitempty"`
	// Previous values contains information about the service instance prior to
	// the update.
	PreviousValues *PreviousValues `json:"previous_values,omitempty"`
	// Context requires a client API version >= 2.12.
	//
	// Context is platform-specific contextual information under which the
	// service instance was created.
	Context map[string]interface{} `json:"context,omitempty"`
	// OriginatingIdentity requires a client API version >= 2.13.
	//
	// OriginatingIdentity is the identity on the platform of the user making
	// this request.
	OriginatingIdentity *OriginatingIdentity `json:"originatingIdentity,omitempty"`
}

UpdateInstanceRequest is the user-facing object that represents a request to update an instance's plan or parameters.

type UpdateInstanceResponse

type UpdateInstanceResponse struct {
	// Async indicates whether the broker is handling the update request
	// asynchronously.
	Async bool `json:"async"`
	// DashboardURL is an ALPHA API attribute and may change. Alpha
	// features must be enabled and the client must be using the latest
	// API Version in order to use this.
	//
	// DashboardURL is the URL of a web-based management user interface for
	// the service instance.
	DashboardURL *string `json:"dashboard_url,omitempty"`
	// OperationKey is an extra identifier supplied by the broker to identify
	// asynchronous operations.
	OperationKey *OperationKey `json:"operation,omitempty"`
}

UpdateInstanceResponse represents a broker's response to an update instance request.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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