"""Interface for the ows-assets microservice.""" from oto import response from owsrequest import request as requests import sentry_sdk from ows_product_physical.constant import error from ows_product_physical.constant import service_name def get_artwork_asset(product_id): """Get artwork image url. Args: product_id (int): product id to get artwork for. Returns: Response: Response containing the artwork url. """ try: asset_response = requests.get( service_name.OWS_ASSETS, '/image/product/large_cover/{}/location'.format(product_id)) if asset_response.status_code != 200: return response.create_error_response( code=error.ASSET_ERROR, message=asset_response.reason, status=asset_response.status_code) return response.Response(message=asset_response.text) except Exception as exception: sentry_sdk.capture_exception(exception) return response.create_error_response( code=error.INTERNAL_ERROR, message='connection error', status=500)