openbrokerapi


Nameopenbrokerapi JSON
Version 4.7.0 PyPI version JSON
download
home_pagehttps://openbrokerapi.readthedocs.io/
SummaryA python package for the V2 CF Service Broker API and Open Broker API (version 2.13+)
upload_time2024-06-06 18:24:55
maintainerNone
docs_urlNone
authorMaic Siemering
requires_python<4.0,>=3.8
licenseMIT
keywords cloudfoundry cfbrokerapi openbrokerapi openservicebrokerapi servicebroker flask kubernetes k8s
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            |Build Status| |Coverage Status| |Known Vulnerabilities| |PYUP| |OpenSSF Best Practices|

Open Broker API
===============

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

Following `Open Service Broker
API Spec <https://github.com/openservicebrokerapi/servicebroker/blob/master/spec.md>`__ and `Open
Service Broker API <https://www.openservicebrokerapi.org/>`__

Check out the documentation_.

.. _documentation: http://openbrokerapi.readthedocs.io/en/latest/

To find out more about Platform Compatibility for OSBAPI versions, check out
`Platform Compatibility for OSBAPI <https://github.com/openservicebrokerapi/servicebroker/blob/master/compatibility.md>`__

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

Installation
------------

This package is available for Python 3.8+.

.. code:: bash

    pip3 install openbrokerapi

    # including gevent as server
    pip3 install openbrokerapi[gevent]

    # recommended production setup
    pip3 install openbrokerapi[gunicorn]

Or install the development version from github:

.. code:: bash

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

Usage
-----

You can start with a `skeleton project <https://github.com/eruvanos/openbrokerapi-skeleton>`__ or just from scratch.

.. code:: python

    from typing import Union, List

    import openbrokerapi
    from openbrokerapi import api
    from openbrokerapi.api import ServiceBroker
    from openbrokerapi.catalog import ServicePlan
    from openbrokerapi.service_broker import (
        Service,
        ProvisionDetails,
        ProvisionedServiceSpec,
        DeprovisionDetails,
        DeprovisionServiceSpec
    )


    class MyServiceBroker(ServiceBroker):
        def catalog(self) -> Union[Service, List[Service]]:
            return Service(
                id='service id',
                name='service name',
                description='service description',
                bindable=False,
                plans=[
                    ServicePlan(
                        id='plan id',
                        name='plan name',
                        description='plan description',
                    )
                ]
            )

        def provision(self,
                      instance_id: str,
                      details: ProvisionDetails,
                      async_allowed: bool,
                      **kwargs) -> ProvisionedServiceSpec:
            # Create service instance
            # ...

            return ProvisionedServiceSpec()

        def deprovision(self,
                        instance_id: str,
                        details: DeprovisionDetails,
                        async_allowed: bool,
                        **kwargs) -> DeprovisionServiceSpec:
            # Delete service instance
            # ...

            return DeprovisionServiceSpec(is_async=False)

    print('Start server on 127.0.0.1:5000')
    print('Check the catalog at:')
    print('> curl 127.0.0.1:5000/v2/catalog -H "X-Broker-API-Version: 2.14"')
    api.serve(MyServiceBroker(), None)

    # 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_util
    # openbroker_bp = api.get_blueprint(ExampleServiceBroker(), api.BrokerCredentials("", ""), logger)
    # app.register_blueprint(openbroker_bp)
    # app.run("0.0.0.0")

Deployment
----------
The included :code:`api.serve` function provides a server setup for **local usage only**.

For productive deployments use the blueprint from :code:`api.get_blueprint` to
setup a production ready server like `Waitress <https://docs.pylonsproject.org/projects/waitress/en/latest/>`__
or other mentioned in `Flask Deployment Docs <http://flask.pocoo.org/docs/dev/deploying/wsgi-standalone/>`__

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.


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 <https://stackoverflow.com/a/7244456/2947505>`_.

.. _Github Issues: https://github.com/eruvanos/openbrokerapi/issues

.. |Build Status| image:: https://github.com/eruvanos/openbrokerapi/actions/workflows/python-test.yml/badge.svg
    :target: https://github.com/eruvanos/openbrokerapi/actions/workflows/python-test.yml
.. |Coverage Status| image:: https://coveralls.io/repos/github/eruvanos/openbrokerapi/badge.svg?branch=master
   :target: https://coveralls.io/github/eruvanos/openbrokerapi?branch=main
.. |Known Vulnerabilities| image:: https://github.com/eruvanos/openbrokerapi/actions/workflows/codeql.yml/badge.svg
   :target: https://github.com/eruvanos/openbrokerapi/actions/workflows/codeql.yml
.. |PYUP| image:: https://pyup.io/repos/github/eruvanos/openbrokerapi/shield.svg
     :target: https://pyup.io/repos/github/eruvanos/openbrokerapi/
.. |OpenSSF Best Practices| image:: https://bestpractices.coreinfrastructure.org/projects/7220/badge
     :target: https://bestpractices.coreinfrastructure.org/projects/7220/badge)](https://bestpractices.coreinfrastructure.org/projects/7220


            

Raw data

            {
    "_id": null,
    "home_page": "https://openbrokerapi.readthedocs.io/",
    "name": "openbrokerapi",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.8",
    "maintainer_email": null,
    "keywords": "cloudfoundry, cfbrokerapi, openbrokerapi, openservicebrokerapi, servicebroker, flask, kubernetes, k8s",
    "author": "Maic Siemering",
    "author_email": "maic@siemering.tech",
    "download_url": "https://files.pythonhosted.org/packages/d2/19/aa1a9a86ad2bfea8584f6517bfbd673606476c3904e58ceb2af804926f1f/openbrokerapi-4.7.0.tar.gz",
    "platform": null,
    "description": "|Build Status| |Coverage Status| |Known Vulnerabilities| |PYUP| |OpenSSF Best Practices|\n\nOpen Broker API\n===============\n\nA Python package for building Service Brokers supporting API version 2.13+.\n\nFollowing `Open Service Broker\nAPI Spec <https://github.com/openservicebrokerapi/servicebroker/blob/master/spec.md>`__ and `Open\nService Broker API <https://www.openservicebrokerapi.org/>`__\n\nCheck out the documentation_.\n\n.. _documentation: http://openbrokerapi.readthedocs.io/en/latest/\n\nTo find out more about Platform Compatibility for OSBAPI versions, check out\n`Platform Compatibility for OSBAPI <https://github.com/openservicebrokerapi/servicebroker/blob/master/compatibility.md>`__\n\n Not all features are supported with this library due to conflicting features.\n\nInstallation\n------------\n\nThis package is available for Python 3.8+.\n\n.. code:: bash\n\n    pip3 install openbrokerapi\n\n    # including gevent as server\n    pip3 install openbrokerapi[gevent]\n\n    # recommended production setup\n    pip3 install openbrokerapi[gunicorn]\n\nOr install the development version from github:\n\n.. code:: bash\n\n    pip3 install git+https://github.com/eruvanos/openbrokerapi.git\n\nUsage\n-----\n\nYou can start with a `skeleton project <https://github.com/eruvanos/openbrokerapi-skeleton>`__ or just from scratch.\n\n.. code:: python\n\n    from typing import Union, List\n\n    import openbrokerapi\n    from openbrokerapi import api\n    from openbrokerapi.api import ServiceBroker\n    from openbrokerapi.catalog import ServicePlan\n    from openbrokerapi.service_broker import (\n        Service,\n        ProvisionDetails,\n        ProvisionedServiceSpec,\n        DeprovisionDetails,\n        DeprovisionServiceSpec\n    )\n\n\n    class MyServiceBroker(ServiceBroker):\n        def catalog(self) -> Union[Service, List[Service]]:\n            return Service(\n                id='service id',\n                name='service name',\n                description='service description',\n                bindable=False,\n                plans=[\n                    ServicePlan(\n                        id='plan id',\n                        name='plan name',\n                        description='plan description',\n                    )\n                ]\n            )\n\n        def provision(self,\n                      instance_id: str,\n                      details: ProvisionDetails,\n                      async_allowed: bool,\n                      **kwargs) -> ProvisionedServiceSpec:\n            # Create service instance\n            # ...\n\n            return ProvisionedServiceSpec()\n\n        def deprovision(self,\n                        instance_id: str,\n                        details: DeprovisionDetails,\n                        async_allowed: bool,\n                        **kwargs) -> DeprovisionServiceSpec:\n            # Delete service instance\n            # ...\n\n            return DeprovisionServiceSpec(is_async=False)\n\n    print('Start server on 127.0.0.1:5000')\n    print('Check the catalog at:')\n    print('> curl 127.0.0.1:5000/v2/catalog -H \"X-Broker-API-Version: 2.14\"')\n    api.serve(MyServiceBroker(), None)\n\n    # Simply start the server\n    # api.serve(ExampleServiceBroker(), api.BrokerCredentials(\"\", \"\"))\n\n    # or start the server without authentication\n    # api.serve(ExampleServiceBroker(), None)\n\n    # or start the server with multiple authentication\n    # api.serve(ExampleServiceBroker(), [api.BrokerCredentials(\"\", \"\"), api.BrokerCredentials(\"\", \"\")])\n\n    # or with multiple service brokers and multiple credentials\n    # api.serve_multiple([ExampleServiceBroker(), ExampleServiceBroker()], [api.BrokerCredentials(\"\", \"\"), api.BrokerCredentials(\"\", \"\")])\n\n    # or register blueprint to your own FlaskApp instance\n    # app = Flask(__name__)\n    # logger = basic_config()  # Use root logger with a basic configuration provided by openbrokerapi.log_util\n    # openbroker_bp = api.get_blueprint(ExampleServiceBroker(), api.BrokerCredentials(\"\", \"\"), logger)\n    # app.register_blueprint(openbroker_bp)\n    # app.run(\"0.0.0.0\")\n\nDeployment\n----------\nThe included :code:`api.serve` function provides a server setup for **local usage only**.\n\nFor productive deployments use the blueprint from :code:`api.get_blueprint` to\nsetup a production ready server like `Waitress <https://docs.pylonsproject.org/projects/waitress/en/latest/>`__\nor other mentioned in `Flask Deployment Docs <http://flask.pocoo.org/docs/dev/deploying/wsgi-standalone/>`__\n\nError Types\n-----------\n\nOpenbrokerapi defines a handful of error types in errors.py for some\ncommon error cases that your service broker may encounter. Raise these\nfrom your ServiceBroker methods where appropriate, and openbrokerapi\nwill do the \"right thing\" (\u2122), and give Cloud Foundry an appropriate\nstatus code, as per the Service Broker API specification.\n\n\nBugs or Issues\n--------------\n\nPlease report bugs, issues or feature requests to `Github\nIssues`_\n\n\nHow to contribute\n-----------------\n\nYou want to contribute, I really appreciate!\n\nSo let us check how you can contribute:\n\n- Create an issue in the `Github Issues`_. Please provide all information that you think are usefull to solve it.\n- Use the `Github Issues`_ to create a feature request, so we can discuss and find a good interface for that feature.\n- Create a Pull Request. There are some things that will make it easier to review your Pull Request:\n\n    - Use a new branch for every Pull Request\n    - Include just related commits in this branch\n    - Less commits are better, one would be the best (You can squash them.)\n    - Always add tests for your feature, if you are not familiar with writing tests, ask for help.\n    - Hint: To update your fork with the newest changes, follow `these instructions <https://stackoverflow.com/a/7244456/2947505>`_.\n\n.. _Github Issues: https://github.com/eruvanos/openbrokerapi/issues\n\n.. |Build Status| image:: https://github.com/eruvanos/openbrokerapi/actions/workflows/python-test.yml/badge.svg\n    :target: https://github.com/eruvanos/openbrokerapi/actions/workflows/python-test.yml\n.. |Coverage Status| image:: https://coveralls.io/repos/github/eruvanos/openbrokerapi/badge.svg?branch=master\n   :target: https://coveralls.io/github/eruvanos/openbrokerapi?branch=main\n.. |Known Vulnerabilities| image:: https://github.com/eruvanos/openbrokerapi/actions/workflows/codeql.yml/badge.svg\n   :target: https://github.com/eruvanos/openbrokerapi/actions/workflows/codeql.yml\n.. |PYUP| image:: https://pyup.io/repos/github/eruvanos/openbrokerapi/shield.svg\n     :target: https://pyup.io/repos/github/eruvanos/openbrokerapi/\n.. |OpenSSF Best Practices| image:: https://bestpractices.coreinfrastructure.org/projects/7220/badge\n     :target: https://bestpractices.coreinfrastructure.org/projects/7220/badge)](https://bestpractices.coreinfrastructure.org/projects/7220\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A python package for the V2 CF Service Broker API and Open Broker API (version 2.13+)",
    "version": "4.7.0",
    "project_urls": {
        "Changelog": "https://github.com/eruvanos/openbrokerapi/blob/main/CHANGELOG.rst",
        "Documentation": "https://openbrokerapi.readthedocs.io/",
        "Homepage": "https://openbrokerapi.readthedocs.io/",
        "Issue Tracker": "https://github.com/eruvanos/openbrokerapi/issues",
        "Repository": "https://github.com/eruvanos/openbrokerapi"
    },
    "split_keywords": [
        "cloudfoundry",
        " cfbrokerapi",
        " openbrokerapi",
        " openservicebrokerapi",
        " servicebroker",
        " flask",
        " kubernetes",
        " k8s"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3778d6db3b97e56c70a23b1ae176b21546db638130009ba83d541cda1d9b17ac",
                "md5": "e0b3f86872331c8c3d0b0806dc8d9418",
                "sha256": "05488896858186b5d13c5123a70e89eed726ddba04e760799d2a07041b548833"
            },
            "downloads": -1,
            "filename": "openbrokerapi-4.7.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "e0b3f86872331c8c3d0b0806dc8d9418",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.8",
            "size": 19228,
            "upload_time": "2024-06-06T18:24:54",
            "upload_time_iso_8601": "2024-06-06T18:24:54.731125Z",
            "url": "https://files.pythonhosted.org/packages/37/78/d6db3b97e56c70a23b1ae176b21546db638130009ba83d541cda1d9b17ac/openbrokerapi-4.7.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d219aa1a9a86ad2bfea8584f6517bfbd673606476c3904e58ceb2af804926f1f",
                "md5": "cbbc1d85ac1c1d6d3c2cd7851c47ccdc",
                "sha256": "d9e5669ad6cc02c01465cd4df9d78811b2933202db51de28af3fda58ffb001e0"
            },
            "downloads": -1,
            "filename": "openbrokerapi-4.7.0.tar.gz",
            "has_sig": false,
            "md5_digest": "cbbc1d85ac1c1d6d3c2cd7851c47ccdc",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.8",
            "size": 18176,
            "upload_time": "2024-06-06T18:24:55",
            "upload_time_iso_8601": "2024-06-06T18:24:55.996147Z",
            "url": "https://files.pythonhosted.org/packages/d2/19/aa1a9a86ad2bfea8584f6517bfbd673606476c3904e58ceb2af804926f1f/openbrokerapi-4.7.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-06-06 18:24:55",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "eruvanos",
    "github_project": "openbrokerapi",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "openbrokerapi"
}
        
Elapsed time: 1.60112s