Skip to content

Commit

Permalink
feat: addition of account name (#227)
Browse files Browse the repository at this point in the history
  • Loading branch information
schniber authored Oct 24, 2024
1 parent d7fa093 commit 4e2a03c
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions data-collection/deploy/module-support-cases.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -175,12 +175,19 @@ Resources:
def main(account, role_name, module_name, bucket):
account_id = account["account_id"]
payer_id = account["payer_id"]
account_name = account.get("account_name", None)
support = get_client_with_role(role_name, account_id, region="us-east-1", service="support")
s3 = boto3.client('s3')
default_start_date = (datetime.now().date() - timedelta(days=365)).strftime('%Y-%m-%d') # Case communications are available for 12 months after creation.
status = {"last_read": default_start_date, "account_id": account_id, "last_summary": None}
status = {
"last_read": default_start_date,
"account_alias": account_name,
"account_id": account_id,
"payer_id": payer_id,
"last_summary": None
}
status_key = f"{module_name}/{module_name}-status/payer_id={payer_id}/{account_id}.json"
try:
status = json.loads(
Expand Down Expand Up @@ -220,6 +227,7 @@ Resources:
case_id = data['CaseId']
case_date = datetime.strptime(data["TimeCreated"], '%Y-%m-%dT%H:%M:%S.%fZ')
with open("/tmp/tmp.json", "w", encoding='utf-8') as f:
data['AccountAlias'] = account_name
f.write(to_json(data)) # single line per file
key = case_date.strftime(
f"{module_name}/" +
Expand All @@ -245,6 +253,7 @@ Resources:
)
with open("/tmp/tmp.json", "w", encoding='utf-8') as f:
for communication in communication_iterator:
communication['AccountAlias'] = account_name
f.write(to_json(communication) + '\n')
key = case_date.strftime(
f"{module_name}/" +
Expand Down Expand Up @@ -358,4 +367,4 @@ Resources:
Type: Custom::LambdaAnalyticsExecutor
Properties:
ServiceToken: !Ref LambdaAnalyticsARN
Name: !Ref CFDataName
Name: !Ref CFDataName

0 comments on commit 4e2a03c

Please sign in to comment.