"""Config file for lambda function.""" import os from botocore.exceptions import ClientError from secrets_manager.lambda_ext import LambdaSecretsManager APPLICATION_NAME = 'lambda-mcc-check-ddex-generation' # AWS region configuration DEFAULT_AWS_REGION = 'us-east-1' AWS_REGION = os.environ.get('AWS_REGION', DEFAULT_AWS_REGION) # Environment setup DEV_ENVIRONMENT = 'dev' QA_ENVIRONMENT = 'qa' PROD_ENVIRONMENT = 'prod' ENVIRONMENT = os.environ.get('ENVIRONMENT', DEV_ENVIRONMENT) secrets_manager_client = LambdaSecretsManager( environment=ENVIRONMENT, service_name=APPLICATION_NAME) try: SENTRY_DSN = secrets_manager_client.get_cred('SENTRY_DSN') except ClientError as e: if e.response['Error']['Code'] == 'ResourceNotFoundException': SENTRY_DSN = os.environ.get('SENTRY_DSN') else: raise DDEX_GENERATION_URL = os.environ.get('DDEX_GENERATION_URL', 'webservices.qaorch.com') DDEX_GENERATION_URLS = ( 'https://' + DDEX_GENERATION_URL + '/oa/metadata/generate/' 'dms_id/286/storename/ddexern/version/3.8.0/returnErr/1/xml_only/0/delivery_type/' 'complete_album/upc/{upc}', 'https://' + DDEX_GENERATION_URL + '/oa/metadata/generate/' 'dms_id/1/subformat/music/returnErr/1/xml_only/0/delivery_type/complete_album/upc/{upc}', ) # Substring for a DDEX return of a taken down product, to ignore TAKEN_DOWN_DDEX = 'has been taken down' IS_NOT_IN_CONTENT = 'is not in content in OA' RESTRICTED_SALES = 'restricted from sales' RESTRICTED_FROM_EVERY_SUBSTORE = 'restricted from every substore' NO_ACTIVE_CONTRACT = 'Label does not have an active contract.' LABEL_DELETED = 'Label is deleted.' PRODUCT_CARVED_OUT = 'CARVED_OUT' PRODUCT_NOT_FOR_DISTRIBUTION = 'PRODUCT_NOT_FOR_DISTRIBUTION' DDEX_ERRORS_TO_IGNORE = ( TAKEN_DOWN_DDEX, IS_NOT_IN_CONTENT, RESTRICTED_SALES, RESTRICTED_FROM_EVERY_SUBSTORE, NO_ACTIVE_CONTRACT, LABEL_DELETED, PRODUCT_CARVED_OUT, PRODUCT_NOT_FOR_DISTRIBUTION, )