"""Interface to the ows-permissions microservice.""" from typing import Any from ddtrace import tracer from oto import response as oto_response from charts.constants import service as service_constants from charts.services import request def _get_resources(profile_type, profile_id, resource): """Get resources. Args: profile_type (str): The profile type. profile_id (int): The profile id. resource (str): The resource to retrieve. Returns: oto.response.Response with resources. """ ows_permissions_response = request.get( service_constants.OWS_PERMISSIONS, service_constants.OWS_PERMISSIONS_PROFILE_RESOURCE.format( profile_type=profile_type, profile_id=profile_id, resource=resource ) ) if ows_permissions_response.status_code != 200: return oto_response.Response( status=ows_permissions_response.status_code ) json = ows_permissions_response.json() return oto_response.Response(message=json) @tracer.wrap(name='get_all_resources') def get_all_resources(profile_type: str, profile_id: str) -> Any: """Get all resources for an Insights profile. Args: profile_type (str): The profile type. profile_id ([type]): The profile id. Returns: oto.response.Response: all the resources. """ return _get_resources(profile_type, profile_id, service_constants.ALL_RESOURCE)