def get_cli(self, name): name = self.clients_override.get(name, name) if not self.endpoints: self.fill_endpoints() ns = name.split("_")[0].lower() normalized = name.replace("_", " ").title().replace(" ", "") import_path = self.clients_map_override.get(name, {}).get('module', None) if not import_path: import_path = 'kamaki.clients.%s.%s' % (ns, normalized + 'Client') module_name = ".".join(import_path.split(".")[:-1]) cli_name = import_path.split(".")[-1] module = importlib.import_module(module_name) endpoint_type = self.clients_map_override.get( name, {}).get('endpoint', ns) try: catalog = parse_endpoints(self.endpoints, ep_type=endpoint_type) except NoEndpoints as e: if "_" not in name: raise e endpoint_type = name.split("_")[1] catalog = parse_endpoints(self.endpoints, ep_type=endpoint_type) endpoint = catalog[0]['endpoints'][0]['publicURL'] return module.__dict__[cli_name](endpoint, self.token)
def get_endpoint_url(endpoints, endpoint_type): """Get the publicURL for the specified endpoint""" service_catalog = parse_endpoints(endpoints, ep_type=endpoint_type) return service_catalog[0]['endpoints'][0]['publicURL']
def _get_endpoint_url(endpoints, endpoint_type): """Get the publicURL for the specified endpoint""" service_catalog = parse_endpoints(endpoints, ep_type=endpoint_type) return service_catalog[0]['endpoints'][0]['publicURL']