Skip to content

Commit d78df14

Browse files
authored
Merge pull request #91 from ImMin5/master
Modify usage query parameter
2 parents dfd8143 + 5c9fb94 commit d78df14

File tree

1 file changed

+20
-14
lines changed

1 file changed

+20
-14
lines changed

src/cloudforet/cost_analysis/connector/azure_cost_mgmt_connector.py

+20-14
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ def check_reservation_transaction(self) -> bool:
131131
return True
132132

133133
def list_reservation_transactions_by_billing_profile_id(
134-
self, query_filter: str
134+
self, query_filter: str
135135
) -> list:
136136
transactions = []
137137
try:
@@ -166,12 +166,12 @@ def list_billing_accounts(self) -> list:
166166
return billing_accounts_info
167167

168168
def query_usage_http(
169-
self,
170-
secret_data: dict,
171-
start: datetime,
172-
end: datetime,
173-
account_agreement_type: str,
174-
options=None,
169+
self,
170+
secret_data: dict,
171+
start: datetime,
172+
end: datetime,
173+
account_agreement_type: str,
174+
options=None,
175175
):
176176
try:
177177
billing_account_id = secret_data["billing_account_id"]
@@ -190,11 +190,17 @@ def query_usage_http(
190190
},
191191
}
192192
if account_agreement_type == "MicrosoftPartnerAgreement":
193-
parameters["dataset"]["grouping"].extend(BENEFIT_GROUPING_MPA)
193+
parameters["dataset"]["grouping"] = (
194+
BENEFIT_GROUPING + BENEFIT_GROUPING_MPA
195+
)
194196
elif account_agreement_type == "EnterpriseAgreement":
195-
parameters["dataset"]["grouping"].extend(BENEFIT_GROUPING_EA)
197+
parameters["dataset"]["grouping"] = (
198+
BENEFIT_GROUPING + BENEFIT_GROUPING_EA
199+
)
196200
else:
197-
parameters["dataset"]["grouping"].extend(BENEFIT_GROUPING_MCA)
201+
parameters["dataset"]["grouping"] = (
202+
BENEFIT_GROUPING + BENEFIT_GROUPING_MCA
203+
)
198204

199205
_LOGGER.debug(f"[query_usage] parameters: {parameters}")
200206

@@ -300,13 +306,13 @@ def _make_request_headers(self, client_type=None):
300306
def convert_nested_dictionary(self, cloud_svc_object):
301307
cloud_svc_dict = {}
302308
if hasattr(
303-
cloud_svc_object, "__dict__"
309+
cloud_svc_object, "__dict__"
304310
): # if cloud_svc_object is not a dictionary type but has dict method
305311
cloud_svc_dict = cloud_svc_object.__dict__
306312
elif isinstance(cloud_svc_object, dict):
307313
cloud_svc_dict = cloud_svc_object
308314
elif not isinstance(
309-
cloud_svc_object, list
315+
cloud_svc_object, list
310316
): # if cloud_svc_object is one of type like int, float, char, ...
311317
return cloud_svc_object
312318

@@ -394,8 +400,8 @@ def _get_access_token():
394400
@staticmethod
395401
def _check_secret_data(secret_data):
396402
if (
397-
"billing_account_id" not in secret_data
398-
and "subscription_id" not in secret_data
403+
"billing_account_id" not in secret_data
404+
and "subscription_id" not in secret_data
399405
):
400406
raise ERROR_REQUIRED_PARAMETER(
401407
key="secret_data.billing_account_id or secret_data.subscription_id"

0 commit comments

Comments
 (0)