"""Call for ows-artist to validate artist.""" from owsrequest import request from requests import HTTPError from assets.constants import error, field_const, service from assets.exceptions import ArtistNotFound def check_ownership( artist_id: int, account_type: str | None, account_id: str | None ) -> None: """Check for account artist ownership. Args: account_type (str | None): Account type account_id (str | None): Account ID to check artist_id (int): Artist ID to check """ try: resource = service.OWS_ARTIST_OWNERSHIP_RESOURCE.format(artist_id=artist_id) artist_response = request.get( service.OWS_ARTIST, resource, headers={ field_const.GRASS_ACCOUNT_TYPE: account_type, field_const.GRASS_ACCOUNT_ID: account_id, "Content-Type": "application/json", }, ) artist_response.raise_for_status() except HTTPError as e: if e.response.status_code == 404: raise ArtistNotFound(error.ERROR_ARTIST_NOT_FOUND) from e raise