def get_interface_swagger(swagger, interface_id, base_path, interface_paths, interface_definitions): gem_name, interface_name, interface_version = service_interface.parse_interface_id(interface_id) interface_swagger = { 'swagger': '2.0', 'info': { 'title': 'An implementation for the {} gem\'s {} interface.'.format(gem_name, interface_name), 'version': str(interface_version) }, 'paths': {}, 'definitions': {} } for interface_path in interface_paths: if not interface_path.startswith(base_path): raise RuntimeError('Interface path {} does not start with the interface base path {}.'.format(interface_path, base_path)) path_object = swagger['paths'].get(interface_path, None); if not path_object: raise RuntimeError('Missing path {} in the swagger document.'.format(interface_path)) relative_interface_path = interface_path.replace(base_path, '') interface_swagger['paths'][relative_interface_path] = path_object; for definition in interface_definitions: interface_swagger['definitions'][definition] = swagger['definitions'][definition]; return json.dumps(interface_swagger)
def get_inter_gem_dependencies(self): dependencies = [] for resource_name, definition in self.template.get("Resources", {}).iteritems(): if not definition["Type"] == "Custom::LambdaConfiguration": continue services = definition.get("Properties", {}).get("Services", []) for service in services: target_gem_name, target_interface_name, target_interface_version = service_interface.parse_interface_id(service["InterfaceId"]) dependencies.append({ "gem": target_gem_name, "id": service["InterfaceId"], "function": definition.get("Properties", {}).get("FunctionName", "") }) return dependencies
def _add_service_settings(stack, service_directory, service, services_settings, permitted_arns): target_gem_name, target_interface_name, target_interface_version = service_interface.parse_interface_id( service.InterfaceId) if target_gem_name != CLOUD_GEM_FRAMEWORK: return # try to find the interface from project stack interfaces = service_directory.get_interface_services( None, service.InterfaceId) if len(interfaces) == 0 and not service.Optional: raise RuntimeError( 'There is no service providing {}.'.format(service.InterfaceId)) if len(interfaces) > 1: raise RuntimeError( 'There are multiple services providing {}.'.format(service.InterfaceId)) if len(interfaces) > 0: interface = interfaces[0] services_settings[service.InterfaceId] = interface _add_permitted_arns(stack, interface, permitted_arns)
def parse_interface_id(interface_id): try: return service_interface.parse_interface_id(interface_id) except Exception as e: raise HandledError(str(e))
def __parse_interface_id(self, interface_id): try: return service_interface.parse_interface_id(interface_id) except Exception as e: raise ValueError(str(e))