apiresponses

package
v7.5.0 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2020 License: Apache-2.0 Imports: 5 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInstanceAlreadyExists = NewFailureResponseBuilder(
		errors.New(instanceExistsMsg), http.StatusConflict, instanceAlreadyExistsErrorKey,
	).WithEmptyResponse().Build()

	ErrInstanceDoesNotExist = NewFailureResponseBuilder(
		errors.New(instanceDoesntExistMsg), http.StatusGone, instanceMissingErrorKey,
	).WithEmptyResponse().Build()

	ErrInstanceLimitMet = NewFailureResponse(
		errors.New(serviceLimitReachedMsg), http.StatusInternalServerError, instanceLimitReachedErrorKey,
	)

	ErrBindingAlreadyExists = NewFailureResponse(
		errors.New(bindingExistsMsg), http.StatusConflict, bindingAlreadyExistsErrorKey,
	)

	ErrBindingDoesNotExist = NewFailureResponseBuilder(
		errors.New(bindingDoesntExistMsg), http.StatusGone, bindingMissingErrorKey,
	).WithEmptyResponse().Build()

	ErrBindingNotFound = NewFailureResponseBuilder(
		errors.New(bindingNotFoundMsg), http.StatusNotFound, bindingNotFoundErrorKey,
	).WithEmptyResponse().Build()

	ErrAsyncRequired = NewFailureResponseBuilder(
		errors.New(asyncRequiredMsg), http.StatusUnprocessableEntity, asyncRequiredKey,
	).WithErrorKey("AsyncRequired").Build()

	ErrPlanChangeNotSupported = NewFailureResponseBuilder(
		errors.New(planChangeUnsupportedMsg), http.StatusUnprocessableEntity, planChangeNotSupportedKey,
	).WithErrorKey("PlanChangeNotSupported").Build()

	ErrRawParamsInvalid = NewFailureResponse(
		errors.New(rawInvalidParamsMsg), http.StatusUnprocessableEntity, invalidRawParamsKey,
	)

	ErrAppGuidNotProvided = NewFailureResponse(
		errors.New(appGuidMissingMsg), http.StatusUnprocessableEntity, appGuidNotProvidedErrorKey,
	)

	ErrPlanQuotaExceeded    = errors.New(servicePlanQuotaExceededMsg)
	ErrServiceQuotaExceeded = errors.New(serviceQuotaExceededMsg)

	ErrConcurrentInstanceAccess = NewFailureResponseBuilder(
		errors.New(concurrentInstanceAccessMsg), http.StatusUnprocessableEntity, concurrentAccessKey,
	).WithErrorKey("ConcurrencyError").Build()

	ErrMaintenanceInfoConflict = NewFailureResponseBuilder(
		errors.New(maintenanceInfoConflictMsg), http.StatusUnprocessableEntity, maintenanceInfoConflictKey,
	).WithErrorKey("MaintenanceInfoConflict").Build()

	ErrMaintenanceInfoNilConflict = NewFailureResponseBuilder(
		errors.New(maintenanceInfoNilConflictMsg), http.StatusUnprocessableEntity, maintenanceInfoConflictKey,
	).WithErrorKey("MaintenanceInfoConflict").Build()
)

Functions

This section is empty.

Types

type AsyncBindResponse

type AsyncBindResponse struct {
	OperationData string `json:"operation,omitempty"`
}

type BindingResponse

type BindingResponse struct {
	Credentials     interface{}          `json:"credentials,omitempty"`
	SyslogDrainURL  string               `json:"syslog_drain_url,omitempty"`
	RouteServiceURL string               `json:"route_service_url,omitempty"`
	VolumeMounts    []domain.VolumeMount `json:"volume_mounts,omitempty"`
	BackupAgentURL  string               `json:"backup_agent_url,omitempty"`
}

type CatalogResponse

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

type DeprovisionResponse

type DeprovisionResponse struct {
	OperationData string `json:"operation,omitempty"`
}

type EmptyResponse

type EmptyResponse struct{}

type ErrorResponse

type ErrorResponse struct {
	Error       string `json:"error,omitempty"`
	Description string `json:"description"`
}

type ExperimentalVolumeMountBindingResponse

type ExperimentalVolumeMountBindingResponse struct {
	Credentials     interface{}                      `json:"credentials,omitempty"`
	SyslogDrainURL  string                           `json:"syslog_drain_url,omitempty"`
	RouteServiceURL string                           `json:"route_service_url,omitempty"`
	VolumeMounts    []domain.ExperimentalVolumeMount `json:"volume_mounts,omitempty"`
	BackupAgentURL  string                           `json:"backup_agent_url,omitempty"`
}

type FailureResponse

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

FailureResponse can be returned from any of the `ServiceBroker` interface methods which allow an error to be returned. Doing so will provide greater control over the HTTP response.

func NewFailureResponse

func NewFailureResponse(err error, statusCode int, loggerAction string) *FailureResponse

NewFailureResponse returns a pointer to a new instance of FailureResponse. err will by default be used as both a logging message and HTTP response description. statusCode is the HTTP status code to be returned, must be 4xx or 5xx loggerAction is a short description which will be used as the action if the error is logged.

func (*FailureResponse) AppendErrorMessage

func (f *FailureResponse) AppendErrorMessage(msg string) *FailureResponse

AppendErrorMessage returns an error with the message updated. All other properties are preserved.

func (*FailureResponse) ErrorResponse

func (f *FailureResponse) ErrorResponse() interface{}

ErrorResponse returns an interface{} which will be JSON encoded and form the body of the HTTP response

func (*FailureResponse) LoggerAction

func (f *FailureResponse) LoggerAction() string

LoggerAction returns the loggerAction, used as the action when logging

func (*FailureResponse) ValidatedStatusCode

func (f *FailureResponse) ValidatedStatusCode(logger lager.Logger) int

ValidatedStatusCode returns the HTTP response status code. If the code is not 4xx or 5xx, an InternalServerError will be returned instead.

type FailureResponseBuilder

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

FailureResponseBuilder provides a fluent set of methods to build a *FailureResponse.

func NewFailureResponseBuilder

func NewFailureResponseBuilder(err error, statusCode int, loggerAction string) *FailureResponseBuilder

NewFailureResponseBuilder returns a pointer to a newly instantiated FailureResponseBuilder Accepts required arguments to create a FailureResponse.

func (*FailureResponseBuilder) Build

Build returns the generated FailureResponse built using previously configured variables.

func (*FailureResponseBuilder) WithEmptyResponse

func (f *FailureResponseBuilder) WithEmptyResponse() *FailureResponseBuilder

WithEmptyResponse will cause the built FailureResponse to return an empty JSON object as the HTTP response body

func (*FailureResponseBuilder) WithErrorKey

func (f *FailureResponseBuilder) WithErrorKey(errorKey string) *FailureResponseBuilder

WithErrorKey adds a custom ErrorKey which will be used in FailureResponse to add an `Error` field to the JSON HTTP response body

type GetBindingResponse

type GetBindingResponse struct {
	BindingResponse
	Parameters interface{} `json:"parameters,omitempty"`
}

type GetInstanceResponse

type GetInstanceResponse struct {
	ServiceID    string      `json:"service_id"`
	PlanID       string      `json:"plan_id"`
	DashboardURL string      `json:"dashboard_url,omitempty"`
	Parameters   interface{} `json:"parameters,omitempty"`
}

type LastOperationResponse

type LastOperationResponse struct {
	State       domain.LastOperationState `json:"state"`
	Description string                    `json:"description,omitempty"`
}

type ProvisioningResponse

type ProvisioningResponse struct {
	DashboardURL  string      `json:"dashboard_url,omitempty"`
	OperationData string      `json:"operation,omitempty"`
	Metadata      interface{} `json:"metadata,omitempty"`
}

type UnbindResponse

type UnbindResponse struct {
	OperationData string `json:"operation,omitempty"`
}

type UpdateResponse

type UpdateResponse struct {
	DashboardURL  string `json:"dashboard_url,omitempty"`
	OperationData string `json:"operation,omitempty"`
}

Jump to

Keyboard shortcuts

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