Skip to content

Commit

Permalink
Cleanup and make metadata optional
Browse files Browse the repository at this point in the history
  • Loading branch information
eruvanos committed Aug 27, 2024
1 parent 46027bb commit e78c3be
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 35 deletions.
2 changes: 1 addition & 1 deletion openbrokerapi/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def get_blueprint(
if openbrokerapi.settings.DISABLE_VERSION_CHECK:
logger.warning(
"Minimum API version is not checked, this can cause illegal contracts between service broker and platform!",
stacklevel=0
stacklevel=0,
)
else:
logger.debug("Apply check_version filter for version %s" % str(openbrokerapi.settings.MIN_VERSION))
Expand Down
5 changes: 1 addition & 4 deletions openbrokerapi/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@ def __call__(self, *args, **kwargs):
return self.authenticate()

@abstractmethod
def authenticate(self) -> Union[
Optional[ResponseReturnValue],
Awaitable[Optional[ResponseReturnValue]]
]:
def authenticate(self) -> Union[Optional[ResponseReturnValue], Awaitable[Optional[ResponseReturnValue]]]:
"""
Implement an `flask.typing.BeforeRequestCallable`
Expand Down
20 changes: 11 additions & 9 deletions openbrokerapi/catalog.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
from __future__ import annotations

from typing import List, Dict, Optional


class ServiceMetadata:
def __init__(
self,
displayName: str,
imageUrl: str,
longDescription: str,
providerDisplayName: str,
documentationUrl: str,
supportUrl: str,
displayName: str | None = None,
imageUrl: str | None = None,
longDescription: str | None = None,
providerDisplayName: str | None = None,
documentationUrl: str | None = None,
supportUrl: str | None = None,
shareable: Optional[bool] = None,
**kwargs
**kwargs,
):
self.displayName = displayName
self.imageUrl = imageUrl
Expand Down Expand Up @@ -47,7 +49,7 @@ def __init__(
displayName: Optional[str] = None,
bullets: Optional[List[str]] = None,
costs: Optional[List[ServicePlanCost]] = None,
**kwargs
**kwargs,
):
self.displayName = displayName
self.bullets = bullets
Expand All @@ -74,7 +76,7 @@ def __init__(
free: Optional[bool] = None,
bindable: Optional[bool] = None,
schemas: Optional[Schemas] = None,
**kwargs
**kwargs,
):
self.id = id
self.name = name
Expand Down
2 changes: 1 addition & 1 deletion openbrokerapi/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def last_operation(
operation_data: Optional[str],
service_id: Optional[str] = None,
plan_id: Optional[str] = None,
**kwargs
**kwargs,
) -> LastOperation:
if operation_data is None:
raise errors.ErrInvalidParameters("Invalid operation string")
Expand Down
16 changes: 8 additions & 8 deletions openbrokerapi/service_broker.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def __init__(
space_guid: Optional[str] = None,
parameters: Optional[dict] = None,
context: Optional[dict] = None,
**kwargs
**kwargs,
):
self.service_id = service_id
self.plan_id = plan_id
Expand Down Expand Up @@ -105,7 +105,7 @@ def __init__(
service_id: Optional[str] = None,
organization_id: Optional[str] = None,
space_id: Optional[str] = None,
**kwargs
**kwargs,
):
self.plan_id = plan_id
self.service_id = service_id
Expand All @@ -121,7 +121,7 @@ def __init__(
parameters: Optional[dict] = None,
previous_values: Optional[dict] = None,
context: Optional[dict] = None,
**kwargs
**kwargs,
):
self.service_id = service_id
self.plan_id = plan_id
Expand Down Expand Up @@ -160,7 +160,7 @@ def __init__(
bind_resource: Optional[dict] = None,
parameters: Optional[dict] = None,
context: Optional[dict] = None,
**kwargs
**kwargs,
):
self.app_guid = app_guid
self.plan_id = plan_id
Expand Down Expand Up @@ -227,7 +227,7 @@ def __init__(
route_service_url: Optional[str] = None,
volume_mounts: Optional[List[VolumeMount]] = None,
parameters: Optional[dict] = None,
**kwargs
**kwargs,
):
self.credentials = credentials
self.syslog_drain_url = syslog_drain_url
Expand Down Expand Up @@ -278,7 +278,7 @@ def __init__(
plan_updateable: bool = False,
instances_retrievable: bool = False,
bindings_retrievable: bool = False,
**kwargs
**kwargs,
):
"""
:param requires: syslog_drain, route_forwarding or volume_mount
Expand Down Expand Up @@ -420,7 +420,7 @@ def last_operation(
operation_data: Optional[str],
service_id: Optional[str],
plan_id: Optional[str],
**kwargs
**kwargs,
) -> LastOperation:
"""
Further readings `CF Broker API#LastOperation <https://docs.cloudfoundry.org/services/api.html#polling>`_
Expand All @@ -441,7 +441,7 @@ def last_binding_operation(
operation_data: Optional[str],
service_id: Optional[str],
plan_id: Optional[str],
**kwargs
**kwargs,
) -> LastOperation:
"""
Further readings `CF Broker API#LastOperationForBindings <https://github.com/openservicebrokerapi/servicebroker/blob/v2.14/spec.md#polling-last-operation-for-service-bindings>`_
Expand Down
24 changes: 12 additions & 12 deletions tests/test_integration_using_async_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def test_lifecycle(self):
# GET BINDING
response = requests.get(
"http://localhost:5003/v2/service_instances/{}/service_bindings/{}".format(instance_guid, binding_guid),
**self.request_ads
**self.request_ads,
)
self.assertEqual(HTTPStatus.OK, response.status_code)
self.assertDictEqual({}, response.json())
Expand Down Expand Up @@ -118,7 +118,7 @@ def check_unbind(self, binding_guid, instance_guid):
"plan_id": self.plan_guid,
"accepts_incomplete": "true",
},
**self.request_ads
**self.request_ads,
)
self.assertEqual(HTTPStatus.ACCEPTED, response.status_code)
operation = response.json().get("operation")
Expand All @@ -135,7 +135,7 @@ def check_last_operation_after_bind(self, binding_guid, instance_guid, operation
"plan_id": self.plan_guid,
"operation": operation,
},
**self.request_ads
**self.request_ads,
)
self.assertEqual(HTTPStatus.OK, response.status_code)
self.assertEqual("succeeded", response.json()["state"])
Expand All @@ -150,7 +150,7 @@ def check_last_operation_after_unbind(self, binding_guid, instance_guid, operati
"plan_id": self.plan_guid,
"operation": operation,
},
**self.request_ads
**self.request_ads,
)
self.assertEqual(HTTPStatus.OK, response.status_code)
self.assertEqual("succeeded", response.json()["state"])
Expand All @@ -161,7 +161,7 @@ def check_bind(self, binding_guid, instance_guid):
instance_guid, binding_guid
),
data=json.dumps({"service_id": self.service_guid, "plan_id": self.plan_guid}),
**self.request_ads
**self.request_ads,
)
self.assertEqual(HTTPStatus.ACCEPTED, response.status_code)
operation = response.json().get("operation")
Expand All @@ -176,7 +176,7 @@ def check_deprovision_after_deprovision_done(self, instance_guid):
"plan_id": self.plan_guid,
"accepts_incomplete": "true",
},
**self.request_ads
**self.request_ads,
)
self.assertEqual(HTTPStatus.GONE, response.status_code)

Expand All @@ -188,7 +188,7 @@ def check_deprovision(self, instance_guid, operation):
"plan_id": self.plan_guid,
"accepts_incomplete": "true",
},
**self.request_ads
**self.request_ads,
)
self.assertEqual(HTTPStatus.ACCEPTED, response.status_code)
operation = response.json()["operation"]
Expand All @@ -203,7 +203,7 @@ def check_last_operation_after_deprovision(self, instance_guid, operation):
"plan_id": self.plan_guid,
"operation": operation,
},
**self.request_ads
**self.request_ads,
)
self.assertEqual(HTTPStatus.GONE, response.status_code)
self.assertEqual("succeeded", response.json()["state"])
Expand All @@ -216,7 +216,7 @@ def check_last_operation_after_provision(self, instance_guid, operation):
"plan_id": self.plan_guid,
"operation": operation,
},
**self.request_ads
**self.request_ads,
)
self.assertEqual(HTTPStatus.OK, response.status_code)
self.assertEqual("succeeded", response.json()["state"])
Expand All @@ -236,7 +236,7 @@ def check_provision(self, instance_guid, org_guid, space_guid, service_guid, pla
# }
}
),
**self.request_ads
**self.request_ads,
)
self.assertEqual(HTTPStatus.ACCEPTED, response.status_code)

Expand Down Expand Up @@ -355,7 +355,7 @@ def last_operation(
operation_data: Optional[str],
service_id: Optional[str],
plan_id: Optional[str],
**kwargs
**kwargs,
) -> LastOperation:
instance = self.service_instances.get(instance_id)
if instance is None:
Expand All @@ -375,7 +375,7 @@ def last_binding_operation(
operation_data: Optional[str],
service_id: Optional[str],
plan_id: Optional[str],
**kwargs
**kwargs,
) -> LastOperation:
instance = self.service_instances.get(instance_id, {})
if instance.get("state") == self.BINDING:
Expand Down
1 change: 1 addition & 0 deletions tests/test_provisioning.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class ProvisioningTest(BrokerTestCase):
def setUp(self):
# default config
import openbrokerapi.settings

openbrokerapi.settings.DISABLE_SPACE_ORG_GUID_CHECK = False

self.broker.catalog.return_value = [
Expand Down

0 comments on commit e78c3be

Please sign in to comment.