Package API

Api module

openbrokerapi.api.get_blueprint(service_broker: ServiceBroker, broker_credentials: None | List[BrokerCredentials] | BrokerCredentials, logger: Logger, *, authenticator: BrokerAuthenticator | None = None) Blueprint[source]

Returns the blueprint with service broker api.

Parameters:
  • service_broker – Services that this broker exposes

  • broker_credentials – Optional Usernames and passwords that will be required to communicate with service broker

  • logger – Used for api logs. This will not influence Flasks logging behavior.

  • authenticator – provide an authenticator to secure endpoints, broker_credentials will be ignored

Returns:

Blueprint to register with Flask app instance

openbrokerapi.api.serve(service_broker: ~openbrokerapi.service_broker.ServiceBroker, credentials: ~typing.List[~openbrokerapi.auth.BrokerCredentials] | ~openbrokerapi.auth.BrokerCredentials | None, logger: ~logging.Logger = <RootLogger root (WARNING)>, authenticator: ~openbrokerapi.auth.BrokerAuthenticator | None = None, host='0.0.0.0', port=5000, debug=False)[source]

Starts flask with the given brokers. You can provide a list or just one ServiceBroker

Parameters:
  • service_broker – ServicesBroker for services to provide

  • credentials – Username and password that will be required to communicate with service broker

  • logger – Used for api logs. This will not influence Flasks logging behavior

  • authenticator – provide an authenticator to secure endpoints, broker_credentials will be ignored

  • host – Host, defaults to all interfaces (0.0.0.0)

  • port – Port

  • debug – Enables debugging in flask app

openbrokerapi.api.serve_multiple(service_brokers: ~typing.List[~openbrokerapi.service_broker.ServiceBroker], credentials: ~typing.List[~openbrokerapi.auth.BrokerCredentials] | ~openbrokerapi.auth.BrokerCredentials | None, logger: ~logging.Logger = <RootLogger root (WARNING)>, host='0.0.0.0', port=5000, debug=False)[source]

Catalog module

class openbrokerapi.catalog.Schemas(service_instance: Dict | None = None, service_binding: Dict | None = None, **kwargs)[source]

Bases: object

class openbrokerapi.catalog.ServiceDashboardClient(*, id: str, secret: str | None = None, redirect_uri: str | None = None, **kwargs)[source]

Bases: object

class openbrokerapi.catalog.ServiceMetadata(displayName: str, imageUrl: str, longDescription: str, providerDisplayName: str, documentationUrl: str, supportUrl: str, shareable: bool | None = None, **kwargs)[source]

Bases: object

class openbrokerapi.catalog.ServicePlan(id: str, name: str, description: str, metadata: ServicePlanMetadata | None = None, free: bool | None = None, bindable: bool | None = None, schemas: Schemas | None = None, **kwargs)[source]

Bases: object

class openbrokerapi.catalog.ServicePlanCost(amount: Dict[str, float], unit: str, **kwargs)[source]

Bases: object

class openbrokerapi.catalog.ServicePlanMetadata(displayName: str | None = None, bullets: List[str] | None = None, costs: List[ServicePlanCost] | None = None, **kwargs)[source]

Bases: object

Log_util module

openbrokerapi.log_util.basic_config(logger: ~logging.Logger = <RootLogger root (WARNING)>, level=20)[source]

Configures a logger to log <=INFO to stdout and >INFO to stderr

Parameters:
  • logger – Logger to configure, defaults to logging.root

  • level – Defaults to INFO

Returns:

configured logger (logger from parameters)

Response module

class openbrokerapi.response.AsyncResponse[source]

Bases: object

class openbrokerapi.response.BindResponse(credentials: dict | None = None, syslog_drain_url: str | None = None, route_service_url: str | None = None, volume_mounts: List[VolumeMount] | None = None, operation: str | None = None)[source]

Bases: object

class openbrokerapi.response.CatalogResponse(services: List[Service])[source]

Bases: object

class openbrokerapi.response.DeprovisionResponse(operation: str)[source]

Bases: AsyncResponse

class openbrokerapi.response.EmptyResponse[source]

Bases: object

class openbrokerapi.response.ErrorResponse(error: str | None = None, description: str | None = None)[source]

Bases: object

class openbrokerapi.response.GetBindingResponse(credentials: dict | None = None, syslog_drain_url: str | None = None, route_service_url: str | None = None, volume_mounts: List[VolumeMount] | None = None, parameters: dict | None = None)[source]

Bases: object

class openbrokerapi.response.GetInstanceResponse(service_id: str, plan_id: str, dashboard_url: str | None = None, parameters: dict | None = None)[source]

Bases: object

class openbrokerapi.response.LastOperationResponse(state: OperationState, description: str)[source]

Bases: object

class openbrokerapi.response.ProvisioningResponse(dashboard_url: str, operation: str)[source]

Bases: AsyncResponse

class openbrokerapi.response.UnbindResponse(operation: str)[source]

Bases: AsyncResponse

class openbrokerapi.response.UpdateResponse(operation: str | None, dashboard_url: str | None)[source]

Bases: AsyncResponse

Service_broker module

class openbrokerapi.service_broker.BindDetails(service_id: str, plan_id: str, app_guid: str | None = None, bind_resource: dict | None = None, parameters: dict | None = None, context: dict | None = None, **kwargs)[source]

Bases: object

authorization_username

username of HTTP Basic Auth

originating_identity

decoded X-Broker-Originating-Identity HTTP Header

class openbrokerapi.service_broker.BindResource(app_guid: str | None = None, route: str | None = None, **kwargs)[source]

Bases: object

class openbrokerapi.service_broker.BindState(value)[source]

Bases: Enum

An enumeration.

IDENTICAL_ALREADY_EXISTS = 'exists with identical config'
IS_ASYNC = 'is_async'
SUCCESSFUL_BOUND = 'successfully created'
class openbrokerapi.service_broker.Binding(state=BindState.SUCCESSFUL_BOUND, credentials: dict | None = None, syslog_drain_url: str | None = None, route_service_url: str | None = None, volume_mounts: List[VolumeMount] | None = None, operation: str | None = None)[source]

Bases: object

class openbrokerapi.service_broker.DeprovisionDetails(service_id: str, plan_id: str)[source]

Bases: object

authorization_username

username of HTTP Basic Auth

originating_identity

decoded X-Broker-Originating-Identity HTTP Header

class openbrokerapi.service_broker.DeprovisionServiceSpec(is_async: bool, operation: str | None = None)[source]

Bases: object

class openbrokerapi.service_broker.GetBindingSpec(credentials: dict | None = None, syslog_drain_url: str | None = None, route_service_url: str | None = None, volume_mounts: List[VolumeMount] | None = None, parameters: dict | None = None, **kwargs)[source]

Bases: object

class openbrokerapi.service_broker.GetInstanceDetailsSpec(service_id: str, plan_id: str, dashboard_url: str | None = None, parameters: dict | None = None)[source]

Bases: object

class openbrokerapi.service_broker.LastOperation(state: OperationState, description: str | None = None)[source]

Bases: object

class openbrokerapi.service_broker.OperationState(value)[source]

Bases: Enum

An enumeration.

FAILED = 'failed'
IN_PROGRESS = 'in progress'
SUCCEEDED = 'succeeded'
class openbrokerapi.service_broker.PreviousValues(plan_id: str | None = None, service_id: str | None = None, organization_id: str | None = None, space_id: str | None = None, **kwargs)[source]

Bases: object

class openbrokerapi.service_broker.ProvisionDetails(service_id: str, plan_id: str, organization_guid: str | None = None, space_guid: str | None = None, parameters: dict | None = None, context: dict | None = None, **kwargs)[source]

Bases: object

authorization_username

username of HTTP Basic Auth

originating_identity

decoded X-Broker-Originating-Identity HTTP Header

class openbrokerapi.service_broker.ProvisionState(value)[source]

Bases: Enum

An enumeration.

IDENTICAL_ALREADY_EXISTS = 'exists with identical config'
IS_ASYNC = 'is_async'
SUCCESSFUL_CREATED = 'successfully created'
class openbrokerapi.service_broker.ProvisionedServiceSpec(state: ProvisionState = ProvisionState.SUCCESSFUL_CREATED, dashboard_url: str | None = None, operation: str | None = None)[source]

Bases: object

property is_async
class openbrokerapi.service_broker.Service(id: str, name: str, description: str, bindable: bool, plans: List[ServicePlan], tags: List[str] | None = None, requires: List[str] | None = None, metadata: ServiceMetadata | None = None, dashboard_client: ServiceDashboardClient | None = None, plan_updateable: bool = False, instances_retrievable: bool = False, bindings_retrievable: bool = False, **kwargs)[source]

Bases: object

class openbrokerapi.service_broker.ServiceBroker[source]

Bases: object

Provides a service. This covers catalog, provision, update, bind, unbind, deprovision and last operation.

bind(instance_id: str, binding_id: str, details: BindDetails, async_allowed: bool, **kwargs) Binding[source]

Further readings CF Broker API#Binding

Parameters:
  • instance_id – Instance id provided by the platform

  • binding_id – Binding id provided by the platform

  • details – Details about the binding to create

  • async_allowed – Client allows async binding

  • kwargs – May contain additional information, improves compatibility with upstream versions

Return type:

Binding

Raises:
catalog() Service | List[Service][source]

Returns the services information which is provided by this broker.

Returns:

Service or list of services

deprovision(instance_id: str, details: DeprovisionDetails, async_allowed: bool, **kwargs) DeprovisionServiceSpec[source]

Further readings CF Broker API#Deprovisioning

Parameters:
  • instance_id – Instance id provided by the platform

  • details – Details about the service to delete

  • async_allowed – Client allows async creation

  • kwargs – May contain additional information, improves compatibility with upstream versions

Return type:

DeprovisionServiceSpec

Raises:
get_binding(instance_id: str, binding_id: str, **kwargs) GetBindingSpec[source]

Further readings CF Broker API#FetchServiceBinding Must be implemented if “bindings_retrievable” :true is declared for a service in catalog.

Parameters:
  • instance_id – Instance id provided by the platform

  • binding_id – Instance id provided by the platform

  • kwargs – May contain additional information, improves compatibility with upstream versions

Return type:

GetBindingSpec

Raises:

ErrBindingDoesNotExist – If binding does not exist

get_instance(instance_id: str, **kwargs) GetInstanceDetailsSpec[source]

Further readings CF Broker API#FetchServiceInstance Must be implemented if “instances_retrievable” :true is declared for a service in catalog.

Parameters:
  • instance_id – Instance id provided by the platform

  • kwargs – May contain additional information, improves compatibility with upstream versions

Return type:

GetInstanceDetailsSpec

Raises:
last_binding_operation(instance_id: str, binding_id: str, operation_data: str | None, service_id: str | None, plan_id: str | None, **kwargs) LastOperation[source]

Further readings CF Broker API#LastOperationForBindings Must be implemented if Provision, Update, or Deprovision are async.

Parameters:
  • instance_id – Instance id provided by the platform

  • binding_id – Binding id provided by the platform

  • operation_data – Operation data received from async operation

  • service_id – service identifier

  • plan_id – plan identifier

  • kwargs – May contain additional information, improves compatibility with upstream versions

Return type:

LastOperation

last_operation(instance_id: str, operation_data: str | None, service_id: str | None, plan_id: str | None, **kwargs) LastOperation[source]

Further readings CF Broker API#LastOperation

Parameters:
  • instance_id – Instance id provided by the platform

  • operation_data – Operation data received from async operation

  • service_id – service identifier

  • plan_id – plan identifier

  • kwargs – May contain additional information, improves compatibility with upstream versions

Return type:

LastOperation

provision(instance_id: str, details: ProvisionDetails, async_allowed: bool, **kwargs) ProvisionedServiceSpec[source]

Further readings CF Broker API#Provisioning

Parameters:
  • instance_id – Instance id provided by the platform

  • details – Details about the service to create

  • async_allowed – Client allows async creation

  • kwargs – May contain additional information, improves compatibility with upstream versions

Return type:

ProvisionedServiceSpec

Raises:
unbind(instance_id: str, binding_id: str, details: UnbindDetails, async_allowed: bool, **kwargs) UnbindSpec[source]

Further readings CF Broker API#Unbinding

Parameters:
  • instance_id – Instance id provided by the platform

  • binding_id – Binding id provided by the platform

  • details – Details about the binding to delete

  • async_allowed – Client allows async unbind

  • kwargs – May contain additional information, improves compatibility with upstream versions

Return type:

UnbindDetails

Raises:

ErrBindingAlreadyExists – If binding already exists

update(instance_id: str, details: UpdateDetails, async_allowed: bool, **kwargs) UpdateServiceSpec[source]

Further readings CF Broker API#Update

Parameters:
  • instance_id – Instance id provided by the platform

  • details – Details about the service to update

  • async_allowed – Client allows async creation

  • kwargs – May contain additional information, improves compatibility with upstream versions

Return type:

UpdateServiceSpec

Raises:

ErrAsyncRequired – If async is required but not supported

class openbrokerapi.service_broker.SharedDevice(volume_id: str, mount_config: dict | None = None)[source]

Bases: object

class openbrokerapi.service_broker.UnbindDetails(service_id: str, plan_id: str)[source]

Bases: object

authorization_username

username of HTTP Basic Auth

originating_identity

decoded X-Broker-Originating-Identity HTTP Header

class openbrokerapi.service_broker.UnbindSpec(is_async: bool, operation: str | None = None)[source]

Bases: object

class openbrokerapi.service_broker.UpdateDetails(service_id: str, plan_id: str | None = None, parameters: dict | None = None, previous_values: dict | None = None, context: dict | None = None, **kwargs)[source]

Bases: object

authorization_username

username of HTTP Basic Auth

originating_identity

decoded X-Broker-Originating-Identity HTTP Header

class openbrokerapi.service_broker.UpdateServiceSpec(is_async: bool, operation: str | None = None, dashboard_url: str | None = None)[source]

Bases: object

class openbrokerapi.service_broker.VolumeMount(driver: str, container_dir: str, mode: str, device_type: str, device: SharedDevice)[source]

Bases: object

Authentication

openbrokerapi.auth.Authenticator

alias of BrokerAuthenticator

openbrokerapi.auth.BasicAuthenticator

alias of BasicBrokerAuthenticator

class openbrokerapi.auth.BasicBrokerAuthenticator(*credentials: BrokerCredentials)[source]

Bases: BrokerAuthenticator

Basic Authentication for openbrokerapi

authenticate()[source]

Check authentication over all provided usernames else sends a 401 response that enables basic auth

class openbrokerapi.auth.BrokerAuthenticator[source]

Bases: object

Before request filter, authenticating a request

abstract authenticate() Response | str | bytes | List[Any] | Mapping[str, Any] | Iterator[str] | Iterator[bytes] | Tuple[Response | str | bytes | List[Any] | Mapping[str, Any] | Iterator[str] | Iterator[bytes], Headers | Mapping[str, str | List[str] | Tuple[str, ...]] | Sequence[Tuple[str, str | List[str] | Tuple[str, ...]]]] | Tuple[Response | str | bytes | List[Any] | Mapping[str, Any] | Iterator[str] | Iterator[bytes], int] | Tuple[Response | str | bytes | List[Any] | Mapping[str, Any] | Iterator[str] | Iterator[bytes], int, Headers | Mapping[str, str | List[str] | Tuple[str, ...]] | Sequence[Tuple[str, str | List[str] | Tuple[str, ...]]]] | WSGIApplication | None | Awaitable[Response | str | bytes | List[Any] | Mapping[str, Any] | Iterator[str] | Iterator[bytes] | Tuple[Response | str | bytes | List[Any] | Mapping[str, Any] | Iterator[str] | Iterator[bytes], Headers | Mapping[str, str | List[str] | Tuple[str, ...]] | Sequence[Tuple[str, str | List[str] | Tuple[str, ...]]]] | Tuple[Response | str | bytes | List[Any] | Mapping[str, Any] | Iterator[str] | Iterator[bytes], int] | Tuple[Response | str | bytes | List[Any] | Mapping[str, Any] | Iterator[str] | Iterator[bytes], int, Headers | Mapping[str, str | List[str] | Tuple[str, ...]] | Sequence[Tuple[str, str | List[str] | Tuple[str, ...]]]] | WSGIApplication | None][source]

Implement an flask.typing.BeforeRequestCallable

The function will be called without any arguments. If it returns a non-None value, the value is handled as if it was the return value from the broker, and further request handling is stopped.

To deny access return something like

(
    to_json_response(
        ErrorResponse(
            description="Could not verify your access level for that URL.
You have to login with proper credentials”

)

), 401

)

class openbrokerapi.auth.BrokerCredentials(username: str, password: str)[source]

Bases: object

Credentials, which will be used to validate authenticate requests

openbrokerapi.auth.NoneAuthenticator

alias of NoneBrokerAuthenticator

class openbrokerapi.auth.NoneBrokerAuthenticator[source]

Bases: BrokerAuthenticator

No authentication at all.

authenticate()[source]

Implement an flask.typing.BeforeRequestCallable

The function will be called without any arguments. If it returns a non-None value, the value is handled as if it was the return value from the broker, and further request handling is stopped.

To deny access return something like

(
    to_json_response(
        ErrorResponse(
            description="Could not verify your access level for that URL.
You have to login with proper credentials”

)

), 401

)

Errors module

exception openbrokerapi.errors.ErrAppGuidNotProvided[source]

Bases: ServiceException

exception openbrokerapi.errors.ErrAsyncRequired[source]

Bases: ServiceException

exception openbrokerapi.errors.ErrBadRequest(msg='Malformed or missing data')[source]

Bases: ServiceException

Raise if malformed or missing mandatory data

exception openbrokerapi.errors.ErrBindingAlreadyExists[source]

Bases: ServiceException

exception openbrokerapi.errors.ErrBindingDoesNotExist[source]

Bases: ServiceException

exception openbrokerapi.errors.ErrConcurrentInstanceAccess[source]

Bases: ServiceException

exception openbrokerapi.errors.ErrInstanceAlreadyExists[source]

Bases: ServiceException

exception openbrokerapi.errors.ErrInstanceDoesNotExist[source]

Bases: ServiceException

exception openbrokerapi.errors.ErrInstanceLimitMet[source]

Bases: ServiceException

exception openbrokerapi.errors.ErrInvalidParameters(msg)[source]

Bases: ServiceException

exception openbrokerapi.errors.ErrPlanChangeNotSupported[source]

Bases: ErrInvalidParameters

exception openbrokerapi.errors.ErrPlanQuotaExceeded[source]

Bases: ServiceException

exception openbrokerapi.errors.ErrServiceQuotaExceeded[source]

Bases: ServiceException

exception openbrokerapi.errors.ServiceException[source]

Bases: Exception