"""Interface to ows-sound-recordings microservice.""" from owsrequest import request from conflict_manager import config from conflict_manager.constants import header from conflict_manager.constants import services from conflict_manager.utils import service_utils def get_rules(track_ids, correlation_id): """Get fingerprint rules for multiple tracks. Args: track_ids (list): list of track IDs to get rules for correlation_id (str): Correlation ID for tracing requests Returns: oto.Response: response object containing rules for the track """ endpoint = '/tracks/rules' service_name = services.OWS_SOUND_RECORDINGS headers = { header.CONTENT_TYPE: header.APPLICATION_JSON, header.ORCHARD_PROFILE_TYPE: config.ADMIN_PROFILE_TYPE, header.ORCHARD_PROFILE_ID: config.ADMIN_PROFILE_ID } params = { 'ids': ','.join(str(tid) for tid in track_ids) } get_response = request.get( service_name, endpoint, params=params, correlation_id=correlation_id, headers=headers) return service_utils.process_response(get_response, service_name) def bulk_create_fingerprint_rules( data, correlation_id): """Bulk create fingerprint rules for multiple tracks. Args: data (dict): Dictionary mapping track_ids (int) to lists of rule correlation_id (str): Correlation ID for tracing requests Returns: oto.Response: response object containing rules for the track """ endpoint = '/tracks/bulk/rules' service_name = services.OWS_SOUND_RECORDINGS headers = { header.CONTENT_TYPE: header.APPLICATION_JSON, header.ORCHARD_PROFILE_TYPE: config.ADMIN_PROFILE_TYPE, header.ORCHARD_PROFILE_ID: config.ADMIN_PROFILE_ID } get_response = request.post( service_name, endpoint, json=data, correlation_id=correlation_id, headers=headers) return service_utils.process_response(get_response, service_name)