"""Interface to the ows-permissions microservice.""" from oto import response from owsrequest import request from backend.constants import error from backend.constants import services from backend.utils import api as api_utils def check_profile_access_to_label(profile_uuid, label_id): """Check profile access to label.""" url = f'/profile/uuid/{profile_uuid}/resource/label/id/{label_id}' ows_permissions_response = request.head(services.OWS_PERMISSIONS, url) if ows_permissions_response.status_code == 200: return api_utils.create_ok_response() return response.create_error_response( code=error.OWS_PERMISSIONS_ERROR_CODE, message=error.OWS_PRODUCT_FORBIDDEN_MESSAGE, status=ows_permissions_response.status_code)