Skip to main content
Warning: You are using the test version of PyPI. This is a pre-production deployment of Warehouse. Changes made here affect the production instance of TestPyPI (testpypi.python.org).
Help us improve Python packaging - Donate today!

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

Project Description

Open Broker API

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

Following CF Service Broker API and Open Service Broker API

Check out the documentation.

Installation

This package is available for Python 3.5+.

pip3 install openbrokerapi

Or install the development version from github:

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

Usage

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


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

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

# or with multiple service brokers
api.serve([ExampleServiceBroker(), ExampleServiceBroker()], 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")

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 ignored. This can change, when an update removes the redundant fields.

Bugs or Issues

Please report bugs, issues or feature requests to Github Issues

Release History

This version
History Node

2.0.0

History Node

1.0.0

History Node

0.5.0

History Node

0.4.1

History Node

0.3.6

History Node

0.3.5

History Node

0.3.4

History Node

0.3.3

History Node

0.3.0

History Node

0.2.0

History Node

0.1

History Node

0.1.dev3

Download Files

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

File Name & Hash SHA256 Hash Help Version File Type Upload Date
openbrokerapi-2.0.0-py3-none-any.whl
(22.6 kB) Copy SHA256 Hash SHA256
py3 Wheel Feb 3, 2018

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting