@@ -329,28 +329,30 @@ def create_unified_cost_with_workspace(
329
329
330
330
identity_mgr = IdentityManager (token = config .get_global ("TOKEN" ))
331
331
workspace_ids = [workspace_id ]
332
+ workspace_name = None
333
+ project_name_map = {}
334
+ service_account_name_map = {}
332
335
333
336
if workspace_id :
334
337
workspace_name = identity_mgr .get_workspace (workspace_id , domain_id )
335
- else :
336
- workspace_name = None
338
+ v_workspace_ids = self ._get_virtual_workspace_ids_from_ds_account (
339
+ domain_id , workspace_id
340
+ )
341
+ if v_workspace_ids :
342
+ workspace_ids .extend (v_workspace_ids )
337
343
338
- v_workspace_ids = self ._get_virtual_workspace_ids_from_ds_account (
339
- domain_id , workspace_id
340
- )
341
- if v_workspace_ids :
342
- workspace_ids .extend (v_workspace_ids )
344
+ project_name_map = identity_mgr .get_project_name_map (
345
+ domain_id , workspace_id
346
+ )
347
+
348
+ service_account_name_map = identity_mgr .get_service_account_name_map (
349
+ domain_id , workspace_id
350
+ )
343
351
344
352
data_source_currency_map , data_source_name_map , data_source_ids = (
345
353
self ._get_data_source_currency_map (domain_id , workspace_id )
346
354
)
347
355
348
- project_name_map = identity_mgr .get_project_name_map (domain_id , workspace_id )
349
-
350
- service_account_name_map = identity_mgr .get_service_account_name_map (
351
- domain_id , workspace_id
352
- )
353
-
354
356
unified_cost_billed_year = aggregation_month .split ("-" )[0 ]
355
357
356
358
query = {
@@ -423,21 +425,22 @@ def create_unified_cost_with_workspace(
423
425
aggregated_unified_cost_data ["domain_id" ] = domain_id
424
426
425
427
# set workspace name
428
+ aggregated_unified_cost_data ["workspace_id" ] = workspace_id
426
429
if workspace_id :
427
- aggregated_unified_cost_data ["workspace_id" ] = workspace_id
428
430
aggregated_unified_cost_data ["workspace_name" ] = workspace_name
431
+ # set project name
432
+ project_id = aggregated_unified_cost_data .get ("project_id" , None )
433
+ aggregated_unified_cost_data ["project_name" ] = project_name_map .get (
434
+ project_id , project_id
435
+ )
429
436
430
- # set project name
431
- project_id = aggregated_unified_cost_data .get ("project_id" , None )
432
- aggregated_unified_cost_data ["project_name" ] = project_name_map .get (
433
- project_id , project_id
434
- )
435
-
436
- # set service account name
437
- service_account_id = aggregated_unified_cost_data .get ("service_account_id" )
438
- aggregated_unified_cost_data ["service_account_name" ] = (
439
- service_account_name_map .get (service_account_id )
440
- )
437
+ # set service account name
438
+ service_account_id = aggregated_unified_cost_data .get (
439
+ "service_account_id"
440
+ )
441
+ aggregated_unified_cost_data ["service_account_name" ] = (
442
+ service_account_name_map .get (service_account_id )
443
+ )
441
444
442
445
aggregated_unified_cost_data ["exchange_date" ] = exchange_date_str
443
446
aggregated_unified_cost_data ["exchange_source" ] = exchange_source
0 commit comments