Skip to main content

A python package for the V2 CF Service Broker API and Open Broker API (version 2.10+)

Project description

Build Status Coverage Status

Service Broker API

A Python package for building Service Brokers supporting API version 2.10+.

Following CF Service Broker API and Open Service Broker API

Installation

This package is available for Python 3.6+.

pip3 install openbrokerapi

Or install the development version from github:

pip3 install git+https://github.com/eruvanos/openbrokerapi.git

Getting started

from flask import Flask
from openbrokerapi import service_broker
from openbrokerapi.api import *
from openbrokerapi.log_util import *

# Implement a service broker by overriding methods of ServiceBroker
class CustomServiceBroker(service_broker.ServiceBroker):
    def catalog(self) -> List[Service]:
        pass

    def provision(self, instance_id: str, service_details: ProvisionDetails, async_allowed: bool) -> ProvisionedServiceSpec:
        pass

    def unbind(self, instance_id: str, binding_id: str, details: UnbindDetails):
        pass

    def update(self, instance_id: str, details: UpdateDetails, async_allowed: bool) -> UpdateServiceSpec:
        pass

    def bind(self, instance_id: str, binding_id: str, details: BindDetails) -> Binding:
        pass

    def deprovision(self, instance_id: str, details: DeprovisionDetails, async_allowed: bool) -> DeprovisionServiceSpec:
        pass

    def last_operation(self, instance_id: str, operation_data: str) -> LastOperation:
        pass

# Simpely start the server
serve(CustomServiceBroker(), BrokerCredentials("", ""))

# or register blueprint to your own FlaskApp instance
app = Flask(__name__)
logger = basic_config() #  Use root logger with a basic configuration provided by openbrokerapi.log_utils
openbroker_bp = get_blueprint(CustomServiceBroker(), BrokerCredentials("",""), logger)
app.register_blueprint(openbroker_bp)
app.run("0.0.0.0")

Error Types

Openbrokerapi defines a handful of error types in errors.py for some common error cases that your service broker may encounter. Raise these from your ServiceBroker methods where appropriate, and openbrokerapi will do the “right thing” (™), and give Cloud Foundry an appropriate status code, as per the Service Broker API specification.

Not Planned To Support

  • Provisioning

    • Response: 200 - If service already exists, a 409-Conflict will be returned

  • Bind

    • Response: 200 - If binding already exists, a 409-Conflict will be returned

Bugs or Issues

Please report bugs, issues or feature requests to Github Issues

Release Notes

v0.3.1

  • fix api.serve

v0.3

  • use LastOperationResponse for last_operation response

  • fix: catalog response was not convertible to json

  • fix: not required fields were still in catalog response

  • add missing tests for catalog endpoint

  • support for VolumeMounts is tested

v0.2

  • improve testing

  • fix: Bind and update getting dict instead of expected objects

  • support async for provision, update and deprovision

  • Handle unexpected exception with global error_handler (responding with 500)

  • get_blueprint() now expects a logger

  • add log_utils with basic_config()

v0.1

  • initial version

  • supported operations

  • provision

  • update

  • bind

  • unbind

  • deprovision

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

openbrokerapi-0.3.1.tar.gz (12.0 kB view details)

Uploaded Source

Built Distribution

openbrokerapi-0.3.1-py3-none-any.whl (21.3 kB view details)

Uploaded Python 3

File details

Details for the file openbrokerapi-0.3.1.tar.gz.

File metadata

File hashes

Hashes for openbrokerapi-0.3.1.tar.gz
Algorithm Hash digest
SHA256 948b8eb231a294a331b937afa258667a4a8ac0ef6e95e09e1154f73dd40e670d
MD5 ae8ea47b37d252af43c1be3c5671efd5
BLAKE2b-256 ee27874d5655952d8a1a78ce30a9ea804b053b32f87603810dd720b2e85ed3fd

See more details on using hashes here.

File details

Details for the file openbrokerapi-0.3.1-py3-none-any.whl.

File metadata

File hashes

Hashes for openbrokerapi-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 17172c5f9959bf2a597dcc043e6f7c437b112fe498c30ab0cbbd60593db9a995
MD5 6977ee59f60b1621e3ef3cbc52866202
BLAKE2b-256 4c6a1c514ff9926b402b51b460fead2b2f31591c9b82174ace27c53dcac41f24

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page