"""Interface to ows-masters-registry microservice.""" from owsrequest import request from conflict_manager.constants import header from conflict_manager.constants import query_parameters from conflict_manager.constants import services from conflict_manager.utils import service_utils def bulk_remove_territories( items, account_type, account_id, correlation_id, orchard_user_id): """Bulk delete a list of territories for ISRC/TUIDs. Args: items (list): list of dicts containing: conflict_date, conflicting_owner, isrc, tuid and territories list account_type (str): vendor or subaccount account_id (str): account ID orchard_user_id (str): Orchard user_id for checking feature flags Returns: oto.Response: response object containing track dict or errors """ endpoint = '/ownership/territories' service_name = services.OWS_MASTERS_REGISTRY params = { query_parameters.ACCOUNT_TYPE: account_type, query_parameters.ACCOUNT_ID: account_id, } headers = { header.GRASS_HEADER_USER_ID: orchard_user_id, header.CONTENT_TYPE: header.APPLICATION_JSON } get_response = request.delete( service_name, endpoint, json={'items': items}, params=params, correlation_id=correlation_id, headers=headers) return service_utils.process_response(get_response, service_name)