service

package
v0.8.0-alpha Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2018 License: MIT Imports: 6 Imported by: 18

Documentation

Index

Constants

View Source
const (
	// InstanceStateProvisioning represents the state where service instance
	// provisioning is in progress
	InstanceStateProvisioning = "PROVISIONING"
	// InstanceStateProvisioned represents the state where service instance
	// provisioning has completed successfully
	InstanceStateProvisioned = "PROVISIONED"
	// InstanceStateProvisioningFailed represents the state where service instance
	// provisioning has failed
	InstanceStateProvisioningFailed = "PROVISIONING_FAILED"
	// InstanceStateUpdating represents the state where service instance
	// updating is in progress
	InstanceStateUpdating = "UPDATING"
	// InstanceStateUpdated represents the state where service instance
	// updating has completed successfully
	// It redirects to InstanceStateProvisioned because it means the same thing
	// to any other operations besides updating
	InstanceStateUpdated = InstanceStateProvisioned
	// InstanceStateUpdatingFailed represents the state where service instance
	// updating has failed
	InstanceStateUpdatingFailed = "UPDATING_FAILED"
	// InstanceStateDeprovisioning represents the state where service instance
	// deprovisioning is in progress
	InstanceStateDeprovisioning = "DEPROVISIONING"
	// InstanceStateDeprovisioningFailed represents the state where service
	// instance deprovisioning has failed
	InstanceStateDeprovisioningFailed = "DEPROVISIONING_FAILED"
	// BindingStateBound represents the state where service binding has completed
	// successfully
	BindingStateBound = "BOUND"
	// BindingStateBindingFailed represents the state where service binding has
	// failed
	BindingStateBindingFailed = "BINDING_FAILED"
	// BindingStateUnbindingFailed represents the state where service unbinding
	// has failed
	BindingStateUnbindingFailed = "UNBINDING_FAILED"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Binding

type Binding struct {
	BindingID                  string            `json:"bindingId"`
	InstanceID                 string            `json:"instanceId"`
	ServiceID                  string            `json:"serviceId"`
	EncryptedBindingParameters []byte            `json:"bindingParameters"`
	BindingParameters          BindingParameters `json:"-"`
	Status                     string            `json:"status"`
	StatusReason               string            `json:"statusReason"`
	EncryptedDetails           []byte            `json:"details"`
	Details                    BindingDetails    `json:"-"`
	Created                    time.Time         `json:"created"`
}

Binding represents a binding to a service

func NewBindingFromJSON

func NewBindingFromJSON(
	jsonBytes []byte,
	bp BindingParameters,
	bd BindingDetails,
	codec crypto.Codec,
) (Binding, error)

NewBindingFromJSON returns a new Binding unmarshalled from the provided JSON []byte

func (Binding) ToJSON

func (b Binding) ToJSON(codec crypto.Codec) ([]byte, error)

ToJSON returns a []byte containing a JSON representation of the instance

type BindingDetails added in v0.10.0

type BindingDetails interface{}

BindingDetails is an interface to be implemented by service-specific types that represent binding details. This interface doesn't require any functions to be implemented. It exists to improve the clarity of function signatures and documentation.

type BindingParameters

type BindingParameters interface{}

BindingParameters is an interface to be implemented by module-specific types that represent binding parameters. This interface doesn't require any functions to be implemented. It exists to improve the clarity of function signatures and documentation.

type Catalog

type Catalog interface {
	ToJSON() ([]byte, error)
	GetServices() []Service
	GetService(serviceID string) (Service, bool)
}

Catalog is an interface to be implemented by types that represents the service/plans offered by a service module or by the entire broker.

func NewCatalog

func NewCatalog(services []Service) Catalog

NewCatalog initializes and returns a new Catalog

func NewCatalogFromJSON

func NewCatalogFromJSON(jsonBytes []byte) (Catalog, error)

NewCatalogFromJSON returns a new Catalog unmarshalled from the provided JSON []byte

type Credentials

type Credentials interface{}

Credentials is an interface to be implemented by module-specific types that represent service credentials. This interface doesn't require any functions to be implemented. It exists to improve the clarity of function signatures and documentation.

type Deprovisioner

type Deprovisioner interface {
	GetFirstStepName() (string, bool)
	GetStep(name string) (DeprovisioningStep, bool)
	GetNextStepName(name string) (string, bool)
}

Deprovisioner is an interface to be implemented by types that model a declared chain of tasks used to asynchronously deprovision a service

func NewDeprovisioner

func NewDeprovisioner(steps ...DeprovisioningStep) (Deprovisioner, error)

NewDeprovisioner returns a new deprovisioner

type DeprovisioningStep

type DeprovisioningStep interface {
	GetName() string
	Execute(
		ctx context.Context,
		instance Instance,
	) (InstanceDetails, error)
}

DeprovisioningStep is an interface to be implemented by types that represent a single step in a chain of steps that defines a deprovisioning process

func NewDeprovisioningStep

func NewDeprovisioningStep(
	name string,
	fn DeprovisioningStepFunction,
) DeprovisioningStep

NewDeprovisioningStep returns a new DeprovisioningStep

type DeprovisioningStepFunction

type DeprovisioningStepFunction func(
	ctx context.Context,
	instance Instance,
) (InstanceDetails, error)

DeprovisioningStepFunction is the signature for functions that implement a deprovisioning step

type Instance

type Instance struct {
	InstanceID                      string                 `json:"instanceId"`
	Alias                           string                 `json:"alias"`
	ServiceID                       string                 `json:"serviceId"`
	Service                         Service                `json:"-"`
	PlanID                          string                 `json:"planId"`
	Plan                            Plan                   `json:"-"`
	EncryptedProvisioningParameters []byte                 `json:"provisioningParameters"` // nolint: lll
	ProvisioningParameters          ProvisioningParameters `json:"-"`
	EncryptedUpdatingParameters     []byte                 `json:"updatingParameters"` // nolint: lll
	UpdatingParameters              UpdatingParameters     `json:"-"`
	Status                          string                 `json:"status"`
	StatusReason                    string                 `json:"statusReason"`
	Location                        string                 `json:"location"`
	ResourceGroup                   string                 `json:"resourceGroup"`
	Parent                          *Instance              `json:"-"`
	ParentAlias                     string                 `json:"parentAlias"`
	Tags                            map[string]string      `json:"tags"`
	EncryptedDetails                []byte                 `json:"details"`
	Details                         InstanceDetails        `json:"-"`
	Created                         time.Time              `json:"created"`
}

Instance represents an instance of a service

func NewInstanceFromJSON

func NewInstanceFromJSON(
	jsonBytes []byte,
	pp ProvisioningParameters,
	up UpdatingParameters,
	dt InstanceDetails,
	codec crypto.Codec,
) (Instance, error)

NewInstanceFromJSON returns a new Instance unmarshalled from the provided JSON []byte

func (Instance) ToJSON

func (i Instance) ToJSON(codec crypto.Codec) ([]byte, error)

ToJSON returns a []byte containing a JSON representation of the instance

type InstanceDetails added in v0.10.0

type InstanceDetails interface{}

InstanceDetails is an interface to be implemented by service-specific types that represent the details of a service instance.

type Module

type Module interface {
	// GetName returns a module's name
	GetName() string
	// GetStability returns a module's relative level of stability
	GetStability() Stability
	// GetCatalog returns a Catalog of service/plans offered by a module
	GetCatalog() (Catalog, error)
}

Module is an interface to be implemented by the broker's service modules

type Plan

type Plan interface {
	ToJSON() ([]byte, error)
	GetID() string
	GetName() string
	GetProperties() *PlanProperties
}

Plan is an interface to be implemented by types that represent a single variant or "sku" of a service

func NewPlan

func NewPlan(planProperties *PlanProperties) Plan

NewPlan initializes and returns a new Plan

func NewPlanFromJSON

func NewPlanFromJSON(jsonBytes []byte) (Plan, error)

NewPlanFromJSON returns a new Plan unmarshalled from the provided JSON []byte

type PlanProperties

type PlanProperties struct {
	ID          string                 `json:"id"`
	Name        string                 `json:"name"`
	Description string                 `json:"description"`
	Free        bool                   `json:"free"`
	Extended    map[string]interface{} `json:"-"`
}

PlanProperties represent the properties of a Plan that can be directly instantiated and passed to the NewPlan() constructor function which will carry out all necessary initialization.

type Provisioner

type Provisioner interface {
	GetFirstStepName() (string, bool)
	GetStep(name string) (ProvisioningStep, bool)
	GetNextStepName(name string) (string, bool)
}

Provisioner is an interface to be implemented by types that model a declared chain of tasks used to asynchronously provision a service

func NewProvisioner

func NewProvisioner(steps ...ProvisioningStep) (Provisioner, error)

NewProvisioner returns a new provisioner

type ProvisioningParameters

type ProvisioningParameters interface{}

ProvisioningParameters is an interface to be implemented by module-specific types that represent provisioning parameters. This interface doesn't require any functions to be implemented. It exists to improve the clarity of function signatures and documentation.

type ProvisioningStep

type ProvisioningStep interface {
	GetName() string
	Execute(
		ctx context.Context,
		instance Instance,
	) (InstanceDetails, error)
}

ProvisioningStep is an interface to be implemented by types that represent a single step in a chain of steps that defines a provisioning process

func NewProvisioningStep

func NewProvisioningStep(
	name string,
	fn ProvisioningStepFunction,
) ProvisioningStep

NewProvisioningStep returns a new ProvisioningStep

type ProvisioningStepFunction

type ProvisioningStepFunction func(
	ctx context.Context,
	instance Instance,
) (InstanceDetails, error)

ProvisioningStepFunction is the signature for functions that implement a provisioning step

type Service

type Service interface {
	ToJSON() ([]byte, error)
	GetID() string
	GetName() string
	IsBindable() bool
	GetServiceManager() ServiceManager
	GetPlans() []Plan
	GetPlan(planID string) (Plan, bool)
	GetParentServiceID() string
	GetChildServiceID() string
}

Service is an interface to be implemented by types that represent a single type of service with one or more plans

func NewService

func NewService(
	serviceProperties *ServiceProperties,
	serviceManager ServiceManager,
	plans ...Plan,
) Service

NewService initialized and returns a new Service

func NewServiceFromJSON

func NewServiceFromJSON(jsonBytes []byte) (Service, error)

NewServiceFromJSON returns a new Service unmarshalled from the provided JSON []byte

type ServiceManager added in v0.10.0

type ServiceManager interface {
	// GetEmptyProvisioningParameters returns an empty instance of module-specific
	// provisioningParameters
	GetEmptyProvisioningParameters() ProvisioningParameters
	// ValidateProvisioningParameters validates the provided
	// provisioningParameters and returns an error if there is any problem
	ValidateProvisioningParameters(ProvisioningParameters) error
	// GetProvisioner returns a provisioner that defines the steps a module must
	// execute asynchronously to provision a service.
	GetProvisioner(Plan) (Provisioner, error)
	// GetEmptyInstanceDetails returns an empty instance of a service-specific
	// instance details
	GetEmptyInstanceDetails() InstanceDetails
	// GetEmptyUpdatingParameters returns an empty instance of module-specific
	// updatingParameters
	GetEmptyUpdatingParameters() UpdatingParameters
	// ValidateUpdatingParameters validates the provided
	// updatingParameters and returns an error if there is any problem
	ValidateUpdatingParameters(UpdatingParameters) error
	// GetUpdater returns a updater that defines the steps a module must
	// execute asynchronously to update a service.
	GetUpdater(Plan) (Updater, error)
	// GetEmptyBindingParameters returns an empty instance of module-specific
	// bindingParameters
	GetEmptyBindingParameters() BindingParameters
	// ValidateBindingParameters validates the provided bindingParameters and
	// returns an error if there is any problem
	ValidateBindingParameters(BindingParameters) error
	// Bind synchronously binds to a service
	Bind(Instance, BindingParameters) (BindingDetails, error)
	// GetEmptyBindingDetails returns an empty instance of service-specific
	// bindingDetails
	GetEmptyBindingDetails() BindingDetails
	// GetCredentials returns service-specific credentials populated from instance
	// and binding details
	GetCredentials(Instance, Binding) (Credentials, error)
	// Unbind synchronously unbinds from a service
	Unbind(Instance, BindingDetails) error
	// GetDeprovisioner returns a deprovisioner that defines the steps a module
	// must execute asynchronously to deprovision a service
	GetDeprovisioner(Plan) (Deprovisioner, error)
}

ServiceManager is an interface to be implemented by module components responsible for managing the lifecycle of services and plans thereof

type ServiceProperties

type ServiceProperties struct {
	Name          string   `json:"name"`
	ID            string   `json:"id"`
	Description   string   `json:"description"`
	Tags          []string `json:"tags"`
	Bindable      bool     `json:"bindable"`
	PlanUpdatable bool     `json:"plan_updateable"` // Misspelling is deliberate
	// to match the spec
	ParentServiceID string `json:"-"`
	ChildServiceID  string `json:"-"`
}

ServiceProperties represent the properties of a Service that can be directly instantiated and passed to the NewService() constructor function which will carry out all necessary initialization.

type Stability

type Stability int

Stability is a type that represents the relative stability of a service module

const (
	// StabilityExperimental represents relative stability of the most immature
	// service modules. At this level of stability, we're not even certain we've
	// built the right thing!
	StabilityExperimental Stability = iota
	// StabilityPreview represents relative stability of modules we believe are
	// approaching a stable state.
	StabilityPreview
	// StabilityStable represents relative stability of the mature, production-
	// ready service modules.
	StabilityStable
)

type Updater

type Updater interface {
	GetFirstStepName() (string, bool)
	GetStep(name string) (UpdatingStep, bool)
	GetNextStepName(name string) (string, bool)
}

Updater is an interface to be implemented by types that model a declared chain of tasks used to asynchronously update a service

func NewUpdater

func NewUpdater(steps ...UpdatingStep) (Updater, error)

NewUpdater returns a new updater

type UpdatingParameters

type UpdatingParameters interface{}

UpdatingParameters is an interface to be implemented by module-specific types that represent updating parameters. This interface doesn't require any functions to be implemented. It exists to improve the clarity of function signatures and documentation.

type UpdatingStep

type UpdatingStep interface {
	GetName() string
	Execute(
		ctx context.Context,
		instance Instance,
	) (InstanceDetails, error)
}

UpdatingStep is an interface to be implemented by types that represent a single step in a chain of steps that defines a updating process

func NewUpdatingStep

func NewUpdatingStep(
	name string,
	fn UpdatingStepFunction,
) UpdatingStep

NewUpdatingStep returns a new UpdatingStep

type UpdatingStepFunction

type UpdatingStepFunction func(
	ctx context.Context,
	instance Instance,
) (InstanceDetails, error)

UpdatingStepFunction is the signature for functions that implement a updating step

type ValidationError

type ValidationError struct {
	Field string
	Issue string
}

ValidationError represents an error validating requestParameters. This specific error type should be used to allow the broker's framework to differentiate between validation errors and other common, unexpected errors.

func NewValidationError

func NewValidationError(field, issue string) *ValidationError

NewValidationError returns a new ValidationError for the given field and issue

func (*ValidationError) Error

func (e *ValidationError) Error() string

Jump to

Keyboard shortcuts

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