here.platform.api.registry.lookup_api_registry
Source code for here.platform.api.registry.lookup_api_registry
Copyright (C) 2020-2022 HERE Global B.V. and its affiliate(s).
All rights reserved.
This software and other materials contain proprietary information
controlled by HERE and are protected by applicable copyright legislation.
Any use and utilization of this software and other materials and
disclosure to any third parties is conditional upon having a separate
agreement with HERE for the access, use, utilization or disclosure of this
software. In the absence of such agreement, the use of the software is not
allowed.
"""
A registry for lookup apis, so that they can be managed, cached, etc.
"""
from typing import Dict, Optional
[docs]
class LookupApiRegistry:
"""HERE platform lookup api registry."""
def init(self):
"""Instantiate HERE platform schema registry."""
self._resource_registry =
[docs]
def register(self, catalog_hrn: str, resources_apis: dict):
"""Register a new resource lookup api for a given hrn."""
self._resource_registry[catalog_hrn] = resources_apis
[docs]
def has_resources_apis(self, catalog_hrn: str) -> bool:
"""
Check whether a given schema has already been registered.
:param catalog_hrn: Catalog HRN
:return: a bool flag indicating if schema is already registered.
"""
result: bool = catalog_hrn in self._resource_registry
return result
[docs]
def resources_apis(self, catalog_hrn: str) -> Optional[Dict]:
"""
Return a schema by the provided schema HRN identifier.
:param catalog_hrn: Catalog HRN
:return: Schema instance for the given hrn.
"""
if self.has_resources_apis(catalog_hrn):
resource_registry: dict = self._resource_registry[catalog_hrn]
return resource_registry
else:
return None