Skip to main content

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

Project description

Build Status Coverage Status Known Vulnerabilities PYUP

Open Broker API

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

Following Open Service Broker API Spec and Open Service Broker API

Check out the documentation.

To find out more about Platform Compatibility for OSBAPI versions, check out Platform Compatibility for OSBAPI

Not all features are supported with this library due to conflicting features.

Installation

This package is available for Python 3.5+.

pip3 install openbrokerapi

# including gevent as server
pip3 install openbrokerapi[gevent]

Or install the development version from github:

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

Usage

You can start with a skeleton project or just from scratch.

from flask import Flask
from openbrokerapi import api
from openbrokerapi.catalog import (
    ServicePlan,
)
from openbrokerapi.log_util import basic_config
from openbrokerapi.service_broker import (
    ServiceBroker,
    Service,
    ProvisionedServiceSpec,
    UpdateServiceSpec,
    Binding,
    DeprovisionServiceSpec,
    LastOperation,
    UnbindDetails,
    ProvisionDetails,
    UpdateDetails,
    BindDetails,
    DeprovisionDetails
)


class ExampleServiceBroker(ServiceBroker):
    def catalog(self):
        return Service(
            id='00000000-0000-0000-0000-000000000000',
            name='example-service',
            description='Example Service does nothing',
            bindable=True,
            plans=[
                ServicePlan(
                    id='00000000-0000-0000-0000-000000000000',
                    name='small',
                    description='example service plan',
                ),
            ],
            tags=['example', 'service'],
            plan_updateable=True,
        )

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

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

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

    def unbind(self, instance_id: str, binding_id: str, details: UnbindDetails):
        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


# Simply start the server
api.serve(ExampleServiceBroker(), api.BrokerCredentials("", ""))

# or start the server without authentication
api.serve(ExampleServiceBroker(), None)

# or start the server with multiple authentication
api.serve(ExampleServiceBroker(), [api.BrokerCredentials("", ""), api.BrokerCredentials("", "")])

# or with multiple service brokers and multiple credentials
api.serve_multiple([ExampleServiceBroker(), ExampleServiceBroker()], [api.BrokerCredentials("", ""), api.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 = api.get_blueprint(ExampleServiceBroker(), api.BrokerCredentials("", ""), logger)
app.register_blueprint(openbroker_bp)
app.run("0.0.0.0")

Deployment

The included api.serve function provides a server setup for local usage only.

For productive deployments use the blueprint from api.get_blueprint to setup a production ready server like Waitress or other mentioned in Flask Deployment Docs

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.

Internal Notes

  • Context object from update 2.12 and 2.13 is made available, but partially checked (only organization_guid and space_guid). This can change, when an update removes the redundant fields.

Bugs or Issues

Please report bugs, issues or feature requests to Github Issues

How to contribute

You want to contribute, I really appreciate!

So let us check how you can contribute:

  • Create an issue in the Github Issues. Please provide all information that you think are usefull to solve it.

  • Use the Github Issues to create a feature request, so we can discuss and find a good interface for that feature.

  • Create a Pull Request. There are some things that will make it easier to review your Pull Request:
    • Use a new branch for every Pull Request

    • Include just related commits in this branch

    • Less commits are better, one would be the best (You can squash them.)

    • Always add tests for your feature, if you are not familiar with writing tests, ask for help.

    • Hint: To update your fork with the newest changes, follow these instructions.

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-4.0.0.tar.gz (15.6 kB view details)

Uploaded Source

Built Distribution

openbrokerapi-4.0.0-py3-none-any.whl (16.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: openbrokerapi-4.0.0.tar.gz
  • Upload date:
  • Size: 15.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.5.6

File hashes

Hashes for openbrokerapi-4.0.0.tar.gz
Algorithm Hash digest
SHA256 f62e6d7d9fca6dd17bfd67425736bc938924f1ab3e32213c607a4a573d643abf
MD5 07a30df664222197843ab961d9816516
BLAKE2b-256 4b2afe3f9c11dd8c07fe188dfaf2080d6ebadd75a49b3c00cca7a501153b2bd9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: openbrokerapi-4.0.0-py3-none-any.whl
  • Upload date:
  • Size: 16.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.5.6

File hashes

Hashes for openbrokerapi-4.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e87e23fcfd06c3d16817a930c9981958fa13c8d4db442be5cc9d99ee35d14b98
MD5 3db8b7d06e68655a87e81a5d7a771444
BLAKE2b-256 764883b23eb8afec9596695e785ca580fc8a186dd27387764cfc78818a79b067

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