Skip to content

Commit 51df289

Browse files
authored
fix(Usage Reports): regen usage reports with latest API def (#195)
Signed-off-by: Jonathan Date-chong <jtdatechong@gmail.com>
1 parent 3fbfcbd commit 51df289

File tree

2 files changed

+135
-43
lines changed

2 files changed

+135
-43
lines changed

ibm_platform_services/usage_reports_v4.py

Lines changed: 92 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# coding: utf-8
22

3-
# (C) Copyright IBM Corp. 2022.
3+
# (C) Copyright IBM Corp. 2023.
44
#
55
# Licensed under the Apache License, Version 2.0 (the "License");
66
# you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616

17-
# IBM OpenAPI SDK Code Generator Version: 3.62.0-a2a22f95-20221115-162524
17+
# IBM OpenAPI SDK Code Generator Version: 3.64.1-cee95189-20230124-211647
1818

1919
"""
2020
Usage reports for IBM Cloud accounts
@@ -139,13 +139,17 @@ def get_account_usage(
139139
raise ValueError('account_id must be provided')
140140
if not billingmonth:
141141
raise ValueError('billingmonth must be provided')
142-
headers = {'Accept-Language': accept_language}
142+
headers = {
143+
'Accept-Language': accept_language,
144+
}
143145
sdk_headers = get_sdk_headers(
144146
service_name=self.DEFAULT_SERVICE_NAME, service_version='V4', operation_id='get_account_usage'
145147
)
146148
headers.update(sdk_headers)
147149

148-
params = {'_names': names}
150+
params = {
151+
'_names': names,
152+
}
149153

150154
if 'headers' in kwargs:
151155
headers.update(kwargs.get('headers'))
@@ -202,13 +206,17 @@ def get_resource_group_usage(
202206
raise ValueError('resource_group_id must be provided')
203207
if not billingmonth:
204208
raise ValueError('billingmonth must be provided')
205-
headers = {'Accept-Language': accept_language}
209+
headers = {
210+
'Accept-Language': accept_language,
211+
}
206212
sdk_headers = get_sdk_headers(
207213
service_name=self.DEFAULT_SERVICE_NAME, service_version='V4', operation_id='get_resource_group_usage'
208214
)
209215
headers.update(sdk_headers)
210216

211-
params = {'_names': names}
217+
params = {
218+
'_names': names,
219+
}
212220

213221
if 'headers' in kwargs:
214222
headers.update(kwargs.get('headers'))
@@ -276,7 +284,9 @@ def get_resource_usage_account(
276284
raise ValueError('account_id must be provided')
277285
if not billingmonth:
278286
raise ValueError('billingmonth must be provided')
279-
headers = {'Accept-Language': accept_language}
287+
headers = {
288+
'Accept-Language': accept_language,
289+
}
280290
sdk_headers = get_sdk_headers(
281291
service_name=self.DEFAULT_SERVICE_NAME, service_version='V4', operation_id='get_resource_usage_account'
282292
)
@@ -360,7 +370,9 @@ def get_resource_usage_resource_group(
360370
raise ValueError('resource_group_id must be provided')
361371
if not billingmonth:
362372
raise ValueError('billingmonth must be provided')
363-
headers = {'Accept-Language': accept_language}
373+
headers = {
374+
'Accept-Language': accept_language,
375+
}
364376
sdk_headers = get_sdk_headers(
365377
service_name=self.DEFAULT_SERVICE_NAME,
366378
service_version='V4',
@@ -445,7 +457,9 @@ def get_resource_usage_org(
445457
raise ValueError('organization_id must be provided')
446458
if not billingmonth:
447459
raise ValueError('billingmonth must be provided')
448-
headers = {'Accept-Language': accept_language}
460+
headers = {
461+
'Accept-Language': accept_language,
462+
}
449463
sdk_headers = get_sdk_headers(
450464
service_name=self.DEFAULT_SERVICE_NAME, service_version='V4', operation_id='get_resource_usage_org'
451465
)
@@ -519,13 +533,17 @@ def get_org_usage(
519533
raise ValueError('organization_id must be provided')
520534
if not billingmonth:
521535
raise ValueError('billingmonth must be provided')
522-
headers = {'Accept-Language': accept_language}
536+
headers = {
537+
'Accept-Language': accept_language,
538+
}
523539
sdk_headers = get_sdk_headers(
524540
service_name=self.DEFAULT_SERVICE_NAME, service_version='V4', operation_id='get_org_usage'
525541
)
526542
headers.update(sdk_headers)
527543

528-
params = {'_names': names}
544+
params = {
545+
'_names': names,
546+
}
529547

530548
if 'headers' in kwargs:
531549
headers.update(kwargs.get('headers'))
@@ -711,10 +729,19 @@ class AccountUsage:
711729
plans and metrics.
712730
:attr str month: The month.
713731
:attr List[Resource] resources: All the resource used in the account.
732+
:attr float currency_rate: (optional) The value of the account's currency in
733+
USD.
714734
"""
715735

716736
def __init__(
717-
self, account_id: str, pricing_country: str, currency_code: str, month: str, resources: List['Resource']
737+
self,
738+
account_id: str,
739+
pricing_country: str,
740+
currency_code: str,
741+
month: str,
742+
resources: List['Resource'],
743+
*,
744+
currency_rate: float = None,
718745
) -> None:
719746
"""
720747
Initialize a AccountUsage object.
@@ -725,12 +752,15 @@ def __init__(
725752
resources, plans and metrics.
726753
:param str month: The month.
727754
:param List[Resource] resources: All the resource used in the account.
755+
:param float currency_rate: (optional) The value of the account's currency
756+
in USD.
728757
"""
729758
self.account_id = account_id
730759
self.pricing_country = pricing_country
731760
self.currency_code = currency_code
732761
self.month = month
733762
self.resources = resources
763+
self.currency_rate = currency_rate
734764

735765
@classmethod
736766
def from_dict(cls, _dict: Dict) -> 'AccountUsage':
@@ -756,6 +786,8 @@ def from_dict(cls, _dict: Dict) -> 'AccountUsage':
756786
args['resources'] = [Resource.from_dict(v) for v in _dict.get('resources')]
757787
else:
758788
raise ValueError('Required property \'resources\' not present in AccountUsage JSON')
789+
if 'currency_rate' in _dict:
790+
args['currency_rate'] = _dict.get('currency_rate')
759791
return cls(**args)
760792

761793
@classmethod
@@ -782,6 +814,8 @@ def to_dict(self) -> Dict:
782814
else:
783815
resources_list.append(v.to_dict())
784816
_dict['resources'] = resources_list
817+
if hasattr(self, 'currency_rate') and self.currency_rate is not None:
818+
_dict['currency_rate'] = self.currency_rate
785819
return _dict
786820

787821
def _to_dict(self):
@@ -911,6 +945,9 @@ class InstanceUsage:
911945
provisioned and rated.
912946
:attr str month: The month.
913947
:attr List[Metric] usage: All the resource used in the account.
948+
:attr bool pending: (optional) Pending charge from classic infrastructure.
949+
:attr float currency_rate: (optional) The value of the account's currency in
950+
USD.
914951
"""
915952

916953
def __init__(
@@ -937,6 +974,8 @@ def __init__(
937974
region: str = None,
938975
pricing_region: str = None,
939976
plan_name: str = None,
977+
pending: bool = None,
978+
currency_rate: float = None,
940979
) -> None:
941980
"""
942981
Initialize a InstanceUsage object.
@@ -967,6 +1006,9 @@ def __init__(
9671006
that was submitted was rated.
9681007
:param str plan_name: (optional) The name of the plan where the instance
9691008
was provisioned and rated.
1009+
:param bool pending: (optional) Pending charge from classic infrastructure.
1010+
:param float currency_rate: (optional) The value of the account's currency
1011+
in USD.
9701012
"""
9711013
self.account_id = account_id
9721014
self.resource_instance_id = resource_instance_id
@@ -989,6 +1031,8 @@ def __init__(
9891031
self.plan_name = plan_name
9901032
self.month = month
9911033
self.usage = usage
1034+
self.pending = pending
1035+
self.currency_rate = currency_rate
9921036

9931037
@classmethod
9941038
def from_dict(cls, _dict: Dict) -> 'InstanceUsage':
@@ -1054,6 +1098,10 @@ def from_dict(cls, _dict: Dict) -> 'InstanceUsage':
10541098
args['usage'] = [Metric.from_dict(v) for v in _dict.get('usage')]
10551099
else:
10561100
raise ValueError('Required property \'usage\' not present in InstanceUsage JSON')
1101+
if 'pending' in _dict:
1102+
args['pending'] = _dict.get('pending')
1103+
if 'currency_rate' in _dict:
1104+
args['currency_rate'] = _dict.get('currency_rate')
10571105
return cls(**args)
10581106

10591107
@classmethod
@@ -1112,6 +1160,10 @@ def to_dict(self) -> Dict:
11121160
else:
11131161
usage_list.append(v.to_dict())
11141162
_dict['usage'] = usage_list
1163+
if hasattr(self, 'pending') and self.pending is not None:
1164+
_dict['pending'] = self.pending
1165+
if hasattr(self, 'currency_rate') and self.currency_rate is not None:
1166+
_dict['currency_rate'] = self.currency_rate
11151167
return _dict
11161168

11171169
def _to_dict(self):
@@ -1720,6 +1772,8 @@ class OrgUsage:
17201772
plans and metrics.
17211773
:attr str month: The month.
17221774
:attr List[Resource] resources: All the resource used in the account.
1775+
:attr float currency_rate: (optional) The value of the account's currency in
1776+
USD.
17231777
"""
17241778

17251779
def __init__(
@@ -1732,6 +1786,7 @@ def __init__(
17321786
resources: List['Resource'],
17331787
*,
17341788
organization_name: str = None,
1789+
currency_rate: float = None,
17351790
) -> None:
17361791
"""
17371792
Initialize a OrgUsage object.
@@ -1744,6 +1799,8 @@ def __init__(
17441799
:param str month: The month.
17451800
:param List[Resource] resources: All the resource used in the account.
17461801
:param str organization_name: (optional) The name of the organization.
1802+
:param float currency_rate: (optional) The value of the account's currency
1803+
in USD.
17471804
"""
17481805
self.account_id = account_id
17491806
self.organization_id = organization_id
@@ -1752,6 +1809,7 @@ def __init__(
17521809
self.currency_code = currency_code
17531810
self.month = month
17541811
self.resources = resources
1812+
self.currency_rate = currency_rate
17551813

17561814
@classmethod
17571815
def from_dict(cls, _dict: Dict) -> 'OrgUsage':
@@ -1783,6 +1841,8 @@ def from_dict(cls, _dict: Dict) -> 'OrgUsage':
17831841
args['resources'] = [Resource.from_dict(v) for v in _dict.get('resources')]
17841842
else:
17851843
raise ValueError('Required property \'resources\' not present in OrgUsage JSON')
1844+
if 'currency_rate' in _dict:
1845+
args['currency_rate'] = _dict.get('currency_rate')
17861846
return cls(**args)
17871847

17881848
@classmethod
@@ -1813,6 +1873,8 @@ def to_dict(self) -> Dict:
18131873
else:
18141874
resources_list.append(v.to_dict())
18151875
_dict['resources'] = resources_list
1876+
if hasattr(self, 'currency_rate') and self.currency_rate is not None:
1877+
_dict['currency_rate'] = self.currency_rate
18161878
return _dict
18171879

18181880
def _to_dict(self):
@@ -1846,6 +1908,7 @@ class Plan:
18461908
:attr float rated_cost: Total pre-discounted cost incurred by the plan.
18471909
:attr List[Metric] usage: All the metrics in the plan.
18481910
:attr List[Discount] discounts: All the discounts applicable to the plan.
1911+
:attr bool pending: (optional) Pending charge from classic infrastructure.
18491912
"""
18501913

18511914
def __init__(
@@ -1859,6 +1922,7 @@ def __init__(
18591922
*,
18601923
plan_name: str = None,
18611924
pricing_region: str = None,
1925+
pending: bool = None,
18621926
) -> None:
18631927
"""
18641928
Initialize a Plan object.
@@ -1872,6 +1936,7 @@ def __init__(
18721936
:param List[Discount] discounts: All the discounts applicable to the plan.
18731937
:param str plan_name: (optional) The name of the plan.
18741938
:param str pricing_region: (optional) The pricing region for the plan.
1939+
:param bool pending: (optional) Pending charge from classic infrastructure.
18751940
"""
18761941
self.plan_id = plan_id
18771942
self.plan_name = plan_name
@@ -1881,6 +1946,7 @@ def __init__(
18811946
self.rated_cost = rated_cost
18821947
self.usage = usage
18831948
self.discounts = discounts
1949+
self.pending = pending
18841950

18851951
@classmethod
18861952
def from_dict(cls, _dict: Dict) -> 'Plan':
@@ -1914,6 +1980,8 @@ def from_dict(cls, _dict: Dict) -> 'Plan':
19141980
args['discounts'] = [Discount.from_dict(v) for v in _dict.get('discounts')]
19151981
else:
19161982
raise ValueError('Required property \'discounts\' not present in Plan JSON')
1983+
if 'pending' in _dict:
1984+
args['pending'] = _dict.get('pending')
19171985
return cls(**args)
19181986

19191987
@classmethod
@@ -1952,6 +2020,8 @@ def to_dict(self) -> Dict:
19522020
else:
19532021
discounts_list.append(v.to_dict())
19542022
_dict['discounts'] = discounts_list
2023+
if hasattr(self, 'pending') and self.pending is not None:
2024+
_dict['pending'] = self.pending
19552025
return _dict
19562026

19572027
def _to_dict(self):
@@ -2130,6 +2200,8 @@ class ResourceGroupUsage:
21302200
plans and metrics.
21312201
:attr str month: The month.
21322202
:attr List[Resource] resources: All the resource used in the account.
2203+
:attr float currency_rate: (optional) The value of the account's currency in
2204+
USD.
21332205
"""
21342206

21352207
def __init__(
@@ -2142,6 +2214,7 @@ def __init__(
21422214
resources: List['Resource'],
21432215
*,
21442216
resource_group_name: str = None,
2217+
currency_rate: float = None,
21452218
) -> None:
21462219
"""
21472220
Initialize a ResourceGroupUsage object.
@@ -2154,6 +2227,8 @@ def __init__(
21542227
:param str month: The month.
21552228
:param List[Resource] resources: All the resource used in the account.
21562229
:param str resource_group_name: (optional) The name of the resource group.
2230+
:param float currency_rate: (optional) The value of the account's currency
2231+
in USD.
21572232
"""
21582233
self.account_id = account_id
21592234
self.resource_group_id = resource_group_id
@@ -2162,6 +2237,7 @@ def __init__(
21622237
self.currency_code = currency_code
21632238
self.month = month
21642239
self.resources = resources
2240+
self.currency_rate = currency_rate
21652241

21662242
@classmethod
21672243
def from_dict(cls, _dict: Dict) -> 'ResourceGroupUsage':
@@ -2193,6 +2269,8 @@ def from_dict(cls, _dict: Dict) -> 'ResourceGroupUsage':
21932269
args['resources'] = [Resource.from_dict(v) for v in _dict.get('resources')]
21942270
else:
21952271
raise ValueError('Required property \'resources\' not present in ResourceGroupUsage JSON')
2272+
if 'currency_rate' in _dict:
2273+
args['currency_rate'] = _dict.get('currency_rate')
21962274
return cls(**args)
21972275

21982276
@classmethod
@@ -2223,6 +2301,8 @@ def to_dict(self) -> Dict:
22232301
else:
22242302
resources_list.append(v.to_dict())
22252303
_dict['resources'] = resources_list
2304+
if hasattr(self, 'currency_rate') and self.currency_rate is not None:
2305+
_dict['currency_rate'] = self.currency_rate
22262306
return _dict
22272307

22282308
def _to_dict(self):

0 commit comments

Comments
 (0)