Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

/status and ServiceBroker.status() #62

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions openbrokerapi/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,18 @@ def get_blueprint(service_brokers: Union[List[ServiceBroker], ServiceBroker],
logger.debug("Apply print_request filter for debugging")
openbroker.before_request(print_request)

@openbroker.route("/status", methods=['GET'])
def status():
"""
:return: Status of broker (Run health check for each service)
"""
logger.debug("Status check filter %s %s", request.method, request.path)
if request.method == 'GET' and request.path == '/status':
return to_json_response({broker.service_id():broker.status() for broker in service_brokers})

logger.debug("Apply status filter for health check")
openbroker.before_request(status)

if DISABLE_VERSION_CHECK:
logger.warning(
"Minimum API version is not checked, this can cause illegal contracts between service broker and platform!"
Expand Down Expand Up @@ -96,8 +108,7 @@ def add_service_id_to_async_response(response, service_id: str):
def extract_authorization_username(request: Request):
if request.authorization is not None:
return request.authorization.username
else:
return None
return None

@openbroker.errorhandler(Exception)
def error_handler(e):
Expand Down
9 changes: 9 additions & 0 deletions openbrokerapi/service_broker.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,15 @@ def check_plan_id(self, plan_id) -> bool:
return True
return False

def status(self) -> str:
"""
Returns the health status of the service provided by this broker.

:return: string "OK" or "KO" or anything usefull
:rtype: str
"""
return "OK"

def catalog(self) -> Service:
"""
Returns the services information which is provided by this broker.
Expand Down