1010from uuid import uuid4
1111
1212from audit_table import upsert_audit_table
13- from common .aws_s3_utils import move_file , move_file_outside_bucket
13+ from common .aws_s3_utils import move_file , move_file_to_external_bucket
1414from common .clients import STREAM_NAME , get_s3_client , logger
1515from common .log_decorator import logging_decorator
1616from common .models .errors import UnhandledAuditTableError
1717from constants import (
1818 DPS_DESTINATION_BUCKET_NAME ,
19+ DPS_DESTINATION_PREFIX ,
1920 ERROR_TYPE_TO_STATUS_CODE_MAP ,
20- EXTENDED_ATTRIBUTES_PREFIXES ,
21+ EXTENDED_ATTRIBUTES_FILE_PREFIXES ,
2122 SOURCE_BUCKET_NAME ,
2223 FileNotProcessedReason ,
2324 FileStatus ,
@@ -76,7 +77,7 @@ def handle_record(record) -> dict:
7677 s3_response = get_s3_client ().get_object (Bucket = bucket_name , Key = file_key )
7778 created_at_formatted_string , expiry_timestamp = get_creation_and_expiry_times (s3_response )
7879
79- if file_key .startswith (EXTENDED_ATTRIBUTES_PREFIXES ):
80+ if file_key .startswith (EXTENDED_ATTRIBUTES_FILE_PREFIXES ):
8081 return handle_extended_attributes_file (
8182 file_key ,
8283 bucket_name ,
@@ -106,7 +107,7 @@ def handle_unexpected_bucket_name(bucket_name: str, file_key: str) -> dict:
106107 """Handles scenario where Lambda was not invoked by the data-sources bucket. Should not occur due to terraform
107108 config and overarching design"""
108109 try :
109- if file_key .startswith (EXTENDED_ATTRIBUTES_PREFIXES ):
110+ if file_key .startswith (EXTENDED_ATTRIBUTES_FILE_PREFIXES ):
110111 extended_attribute_identifier = validate_extended_attributes_file_key (file_key )
111112 logger .error (
112113 "Unable to process file %s due to unexpected bucket name %s" ,
@@ -155,7 +156,9 @@ def handle_unexpected_bucket_name(bucket_name: str, file_key: str) -> dict:
155156 }
156157
157158
158- def handle_batch_file (file_key , bucket_name , message_id , created_at_formatted_string , expiry_timestamp ) -> dict :
159+ def handle_batch_file (
160+ file_key : str , bucket_name : str , message_id : str , created_at_formatted_string : str , expiry_timestamp : str
161+ ) -> dict :
159162 """
160163 Processes a single record for batch file.
161164 Returns a dictionary containing information to be included in the logs.
@@ -236,31 +239,32 @@ def handle_batch_file(file_key, bucket_name, message_id, created_at_formatted_st
236239
237240
238241def handle_extended_attributes_file (
239- file_key , bucket_name , message_id , created_at_formatted_string , expiry_timestamp
242+ file_key : str , bucket_name : str , message_id : str , created_at_formatted_string : str , expiry_timestamp : str
240243) -> dict :
241244 """
242245 Processes a single record for extended attributes file.
243246 Returns a dictionary containing information to be included in the logs.
244247 """
245248 try :
246249 extended_attribute_identifier = validate_extended_attributes_file_key (file_key )
247- move_file_outside_bucket (bucket_name , file_key , DPS_DESTINATION_BUCKET_NAME , f"dps_destination/{ file_key } " )
248- queue_name = extended_attribute_identifier
250+ move_file_to_external_bucket (
251+ bucket_name , file_key , DPS_DESTINATION_BUCKET_NAME , f"{ DPS_DESTINATION_PREFIX } { file_key } "
252+ )
249253
250254 upsert_audit_table (
251255 message_id ,
252256 file_key ,
253257 created_at_formatted_string ,
254258 expiry_timestamp ,
255- queue_name ,
259+ extended_attribute_identifier ,
256260 FileStatus .PROCESSING ,
257261 )
258262 return {
259263 "statusCode" : 200 ,
260264 "message" : "Extended Attributes file successfully processed" ,
261265 "file_key" : file_key ,
262266 "message_id" : message_id ,
263- "queue_name" : queue_name ,
267+ "queue_name" : extended_attribute_identifier ,
264268 }
265269 except ( # pylint: disable=broad-exception-caught
266270 VaccineTypePermissionsError ,
@@ -273,7 +277,6 @@ def handle_extended_attributes_file(
273277
274278 file_status = get_file_status_for_error (error )
275279 extended_attribute_identifier = validate_extended_attributes_file_key (file_key )
276- queue_name = extended_attribute_identifier
277280
278281 upsert_audit_table (
279282 message_id ,
0 commit comments