"""Data access layer for ows-artist microservice. Data access layer for extracting artist information from ows-artist. """ from oto import response from owsrequest import request from label_copy_export import config from label_copy_export.connectors import loggly from label_copy_export.constants import ows_services logger = loggly.get_current_logger() def get_ows_artist(artist_id, correlation_id=None): """Get artist data from ows-artist microservice. Args: artist_id (str): artist id. correlation_id (str): correlation id Returns: response.Response: with artist data. """ endpoint = '/artist/{}'.format(artist_id) resp = request.process( application=ows_services.APPLICATION_NAME, environment=config.ENVIRONMENT, method='GET', service_name=ows_services.OWS_ARTIST, path=endpoint, correlation_id=correlation_id, headers={'Content-Type': 'application/json'} ) if resp.status_code != 200: logger.warning( 'Artist data for artist_id: {} was not found in {}'.format( artist_id, ows_services.OWS_ARTIST)) return response.Response(errors=resp.text, status=resp.status_code) return response.Response(message=resp.json())