"""Model for ows-artist.""" import logging import requests import config import const def get_artist_document(artist_id): """Get information about artist from ows-artist. Args: artist_id (int): artist id. Returns: dict: information about artist. """ result = {} if not artist_id: return result url = const.SERVICE_URL.format( environment=config.ENVIRONMENT, service_name=const.OWS_ARTIST_SERVICE_NAME, path=const.OWS_ARTIST_DOCUMENT_ENDPOINT.format(artist_id)) response = requests.get(url) if response.status_code not in (200, 404): logging.exception( 'Failed to get artist information from ows-artist.') raise Exception(const.OWS_ARTIST_ERROR) if response.status_code == 200: result = response.json() return result