"""Used for mapping a GRPS account to an Orchard vendor/subaccount.""" from ddex_ingester_common.helpers.rds import run_rds_query from ddex_ingester_common.models.state_machine.body import \ Body as StateMachineBody import config from constants.sql_queries import ( SELECT_FROM_INBOUND_MAJOR_LABEL_MAPPING, SELECT_FROM_INBOUND_MAJOR_LABEL_MAPPING_BY_CODE) def get_vendor_and_subaccount_for_major_label_rows( logger, s3_context: StateMachineBody) -> list: """Lookup Orchard vendor_id and subaccount_id for the GRPS major label.""" logger.info('Reading vendor/subaccount from RDS given GRPS major label.') major_label = s3_context.product.major_label query_args = (major_label,) return run_rds_query( logger, config.RDS_HOST, config.RDS_DB_NAME, config.RDS_RW_USER, config.secrets_manager_client.get_cred('rds_read_write_password'), SELECT_FROM_INBOUND_MAJOR_LABEL_MAPPING, query_args, ) def get_vendor_and_subaccount_for_rep_owner_code_rows( logger, s3_context: StateMachineBody) -> list: """Lookup Orchard vendor_id and subaccount_id for the rep owner code.""" logger.info('Reading vendor/subaccount from RDS given rep owner code.') parent_repertoire_owner_code = (s3_context.product. parent_repertoire_owner_code) repertoire_owner_code = s3_context.product.repertoire_owner_code query_args = (parent_repertoire_owner_code, repertoire_owner_code) return run_rds_query( logger, config.RDS_HOST, config.RDS_DB_NAME, config.RDS_RW_USER, config.secrets_manager_client.get_cred('rds_read_write_password'), SELECT_FROM_INBOUND_MAJOR_LABEL_MAPPING_BY_CODE, query_args, )