@@ -66,7 +66,7 @@ def delete_data_source_rule_by_vo(data_source_rule_vo):
66
66
data_source_rule_vo .delete ()
67
67
68
68
def get_data_source_rule (
69
- self , data_source_rule_id : str , domain_id : str , workspace_id : str = None
69
+ self , data_source_rule_id : str , domain_id : str , workspace_id : str = None
70
70
):
71
71
conditions = {
72
72
"data_source_rule_id" : data_source_rule_id ,
@@ -106,11 +106,11 @@ def change_cost_data(self, cost_data: dict, workspace_id: str = None) -> dict:
106
106
return cost_data
107
107
108
108
def _apply_data_source_rule_to_cost_data (
109
- self ,
110
- cost_data : dict ,
111
- data_source_rule_vos : QuerySet ,
112
- domain_id : str ,
113
- workspace_id : str = None ,
109
+ self ,
110
+ cost_data : dict ,
111
+ data_source_rule_vos : QuerySet ,
112
+ domain_id : str ,
113
+ workspace_id : str = None ,
114
114
):
115
115
for data_source_rule_vo in data_source_rule_vos :
116
116
is_match = self ._change_cost_data_by_rule (cost_data , data_source_rule_vo )
@@ -128,11 +128,11 @@ def _apply_data_source_rule_to_cost_data(
128
128
return cost_data
129
129
130
130
def _change_cost_data_with_actions (
131
- self ,
132
- cost_data : dict ,
133
- actions : dict ,
134
- domain_id : str ,
135
- workspace_id : str = None ,
131
+ self ,
132
+ cost_data : dict ,
133
+ actions : dict ,
134
+ domain_id : str ,
135
+ workspace_id : str = None ,
136
136
):
137
137
for action , value in actions .items ():
138
138
if action == "change_project" and value :
@@ -148,7 +148,7 @@ def _change_cost_data_with_actions(
148
148
)
149
149
if project_info :
150
150
cost_data ["project_id" ] = project_info ["project_id" ]
151
- if not workspace_id :
151
+ if cost_data . get ( " workspace_id" ) is None :
152
152
cost_data ["workspace_id" ] = project_info ["workspace_id" ]
153
153
154
154
elif action == "match_service_account" and value :
@@ -164,7 +164,7 @@ def _change_cost_data_with_actions(
164
164
"service_account_id"
165
165
]
166
166
cost_data ["project_id" ] = service_account_info .get ("project_id" )
167
- if not workspace_id :
167
+ if cost_data . get ( " workspace_id" ) is None :
168
168
cost_data ["workspace_id" ] = service_account_info .get (
169
169
"workspace_id"
170
170
)
@@ -176,11 +176,11 @@ def _change_cost_data_with_actions(
176
176
return cost_data
177
177
178
178
def _get_service_account (
179
- self , target_key , target_value , domain_id : str , workspace_id : str = None
179
+ self , target_key , target_value , domain_id : str , workspace_id : str = None
180
180
):
181
181
if (
182
- f"service-account:{ domain_id } :{ target_key } :{ target_value } "
183
- in self ._service_account_info
182
+ f"service-account:{ domain_id } :{ target_key } :{ target_value } "
183
+ in self ._service_account_info
184
184
):
185
185
return self ._service_account_info [
186
186
f"service-account:{ domain_id } :{ target_key } :{ target_value } "
@@ -212,7 +212,7 @@ def _get_service_account(
212
212
return service_account_info
213
213
214
214
def _get_project (
215
- self , target_key , target_value , domain_id : str , workspace_id : str = None
215
+ self , target_key , target_value , domain_id : str , workspace_id : str = None
216
216
):
217
217
if f"project:{ domain_id } :{ target_key } :{ target_value } " in self ._project_info :
218
218
return self ._project_info [
0 commit comments