def __init__(self, url, token, key): parsed_url = urlparse(url) server = '{}://{}'.format(parsed_url.scheme, parsed_url.netloc) self._umbrella_client = UmbrellaClient(server, token, key) self._keystone_client = KeystoneClient() self._keystone_client.set_resource_url(url)
def _check_api(self, url, token, key, server): parsed_url = urlparse(url) parsed_server = urlparse(server) server_endpoint = '{}://{}'.format(parsed_server.scheme, parsed_server.netloc) umbrella_client = UmbrellaClient(server_endpoint, token, key) return umbrella_client.validate_service(parsed_url.path)
def __init__(self, url, credentials): parsed_url = urlparse(url) server = '{}://{}'.format(parsed_url.scheme, parsed_url.netloc) self._umbrella_client = UmbrellaClient(server, credentials['token'], credentials['key']) self._keystone_client = KeystoneClient() self._keystone_client.set_resource_url(url) self._keystone_client.set_app_id(credentials['app_id'])
def on_post_product_spec_validation(self, provider, asset): self._user_id = provider.name parsed_url = urlparse(asset.get_url()) # Validate that the provided URL is a valid API in API Umbrella client = UmbrellaClient() app_id = client.validate_service(parsed_url.path) # Check that the provider is authorized to create an offering in the current App keyrock_client = KeyrockClient() keyrock_client.check_ownership(app_id, provider.name) # Check that the provided role is registered in the specified App keyrock_client.check_role(app_id, asset.meta_info['role']) asset.meta_info['app_id'] = app_id asset.save()
class JointClient() def __init__(self, url, token, key): parsed_url = urlparse(url) server = '{}://{}'.format(parsed_url.scheme, parsed_url.netloc) self._umbrella_client = UmbrellaClient(server, token, key) self._keystone_client = KeystoneClient() self._keystone_client.set_resource_url(url) def check_role(self, role): self._umbrella_client.check_role(role) self._keystone_client.check_role(role) def grant_permission(self, customer, role): self._umbrella_client.grant_permission(customer, role) self._keystone_client.grant_permission(customer, role) def revoke_permission(self, customer, role): self._umbrella_client.revoke_permission(customer, role) self._keystone_client.revoke_permission(customer, role)
class JointClient(): def __init__(self, url, credentials): parsed_url = urlparse(url) server = '{}://{}'.format(parsed_url.scheme, parsed_url.netloc) self._umbrella_client = UmbrellaClient(server, credentials['token'], credentials['key']) self._keystone_client = KeystoneClient() self._keystone_client.set_resource_url(url) self._keystone_client.set_app_id(credentials['app_id']) def check_role(self, role): self._umbrella_client.check_role(role) self._keystone_client.check_role(role) def grant_permission(self, customer, role): self._umbrella_client.grant_permission(customer, role) self._keystone_client.grant_permission(customer, role) def revoke_permission(self, customer, role): self._umbrella_client.revoke_permission(customer, role) self._keystone_client.revoke_permission(customer, role)
def _get_umbrella_client(self, url, credentials): parsed_url = urlparse(url) server = '{}://{}'.format(parsed_url.scheme, parsed_url.netloc) return UmbrellaClient(server, credentials['token'], credentials['key'])
def _get_umbrella_client(self, url, token, key): parsed_url = urlparse(url) server = '{}://{}'.format(parsed_url.scheme, parsed_url.netloc) return UmbrellaClient(server, token, key)
def _check_api(self, url, token, key): parsed_url = urlparse(url) server = '{}://{}'.format(parsed_url.scheme, parsed_url.netloc) umbrella_client = UmbrellaClient(server, token, key) umbrella_client.validate_service(parsed_url.path)