"""Logic for ows-assets.""" from kafka_utils.exceptions import IneligibleEventException from owsrequest import request from src import config from src import constants def get_matches_by_product_id(product_id): """Get matches by product_id.""" response = request.process( config.APPLICATION_NAME, config.ENVIRONMENT, 'GET', constants.OWS_ASSETS, path=f'/v2/asset/product/{product_id}/match-audio' ) if response.status_code == 404: raise IneligibleEventException(f'Matches not found for product_id {product_id}') elif response.status_code != 200: raise Exception(f'Retrieval failed for product_id {product_id}\n{response.text}') return response.json()