apiresponses

package
v13.0.21 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2026 License: Apache-2.0 Imports: 5 Imported by: 6 modules, 16 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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()

	ErrInstanceNotFound = NewFailureResponseBuilder(
		errors.New(instanceDoesntExistMsg), http.StatusNotFound, instanceNotFoundErrorKey,
	).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

func NewFailureResponse

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

NewFailureResponse returns an error of type 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.

Types

type AsyncBindResponse

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

type BindingResponse

type BindingResponse struct {
	Credentials     any                  `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"`
	Endpoints       []domain.Endpoint    `json:"endpoints,omitempty"`
	Metadata        any                  `json:"metadata,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     any                              `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 (*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() any

ErrorResponse returns an any 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 *slog.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 any `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   any    `json:"parameters,omitempty"`
	Metadata     any    `json:"metadata,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      any    `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"`
	Metadata      any    `json:"metadata,omitempty"`
}

Jump to

Keyboard shortcuts

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