Package: openbrokerapi
Open Broker APIA Python package for building Service Brokers supporting API version 2.13+.FollowingOpen Service Broker
API SpecandOpen
Service Broker APICheck out thedocumentation.To find out more about Platform Compatibility for OSBAPI versions, check outPlatform Compatibility for OSBAPINot all features are supported with this library due to conflicting features.InstallationThis package is available for Python 3.8+.pip3installopenbrokerapi# including gevent as serverpip3installopenbrokerapi[gevent]# recommended production setuppip3installopenbrokerapi[gunicorn]Or install the development version from github:pip3installgit+https://github.com/eruvanos/openbrokerapi.gitUsageYou can start with askeleton projector just from scratch.fromtypingimportUnion,Listimportopenbrokerapifromopenbrokerapiimportapifromopenbrokerapi.apiimportServiceBrokerfromopenbrokerapi.catalogimportServicePlanfromopenbrokerapi.service_brokerimport(Service,ProvisionDetails,ProvisionedServiceSpec,DeprovisionDetails,DeprovisionServiceSpec)classMyServiceBroker(ServiceBroker):defcatalog(self)->Union[Service,List[Service]]:returnService(id='service id',name='service name',description='service description',bindable=False,plans=[ServicePlan(id='plan id',name='plan name',description='plan description',)])defprovision(self,instance_id:str,details:ProvisionDetails,async_allowed:bool,**kwargs)->ProvisionedServiceSpec:# Create service instance# ...returnProvisionedServiceSpec()defdeprovision(self,instance_id:str,details:DeprovisionDetails,async_allowed:bool,**kwargs)->DeprovisionServiceSpec:# Delete service instance# ...returnDeprovisionServiceSpec(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")DeploymentThe includedapi.servefunction provides a server setup forlocal usage only.For productive deployments use the blueprint fromapi.get_blueprintto
setup a production ready server likeWaitressor other mentioned inFlask Deployment DocsError TypesOpenbrokerapi 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 IssuesPlease report bugs, issues or feature requests toGithub
IssuesHow to contributeYou want to contribute, I really appreciate!So let us check how you can contribute:Create an issue in theGithub Issues. Please provide all information that you think are usefull to solve it.Use theGithub Issuesto 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 RequestInclude just related commits in this branchLess 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, followthese instructions.