Skip to content

Commit f2d6e9b

Browse files
committed
feat(Usage Reports): added subscription_id, created_at, deleted_at to usagereports instanceusage api response
Signed-off-by: Sowmya Kelam <sowmya.kelam@ibm.com>
1 parent b06ae37 commit f2d6e9b

File tree

2 files changed

+159
-181
lines changed

2 files changed

+159
-181
lines changed

ibm_platform_services/usage_reports_v4.py

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

3-
# (C) Copyright IBM Corp. 2024.
3+
# (C) Copyright IBM Corp. 2025.
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.96.0-d6dec9d7-20241008-212902
17+
# IBM OpenAPI SDK Code Generator Version: 3.102.0-615ec964-20250307-203034
1818

1919
"""
2020
Usage reports for IBM Cloud accounts
@@ -55,7 +55,9 @@ def new_instance(
5555
parameters and external configuration.
5656
"""
5757
authenticator = get_authenticator_from_environment(service_name)
58-
service = cls(authenticator)
58+
service = cls(
59+
authenticator
60+
)
5961
service.configure_service(service_name)
6062
return service
6163

@@ -253,9 +255,7 @@ def get_resource_group_usage(
253255
path_param_keys = ['account_id', 'resource_group_id', 'billingmonth']
254256
path_param_values = self.encode_path_vars(account_id, resource_group_id, billingmonth)
255257
path_param_dict = dict(zip(path_param_keys, path_param_values))
256-
url = '/v4/accounts/{account_id}/resource_groups/{resource_group_id}/usage/{billingmonth}'.format(
257-
**path_param_dict
258-
)
258+
url = '/v4/accounts/{account_id}/resource_groups/{resource_group_id}/usage/{billingmonth}'.format(**path_param_dict)
259259
request = self.prepare_request(
260260
method='GET',
261261
url=url,
@@ -445,9 +445,7 @@ def get_resource_usage_resource_group(
445445
path_param_keys = ['account_id', 'resource_group_id', 'billingmonth']
446446
path_param_values = self.encode_path_vars(account_id, resource_group_id, billingmonth)
447447
path_param_dict = dict(zip(path_param_keys, path_param_values))
448-
url = '/v4/accounts/{account_id}/resource_groups/{resource_group_id}/resource_instances/usage/{billingmonth}'.format(
449-
**path_param_dict
450-
)
448+
url = '/v4/accounts/{account_id}/resource_groups/{resource_group_id}/resource_instances/usage/{billingmonth}'.format(**path_param_dict)
451449
request = self.prepare_request(
452450
method='GET',
453451
url=url,
@@ -541,11 +539,7 @@ def get_resource_usage_org(
541539
path_param_keys = ['account_id', 'organization_id', 'billingmonth']
542540
path_param_values = self.encode_path_vars(account_id, organization_id, billingmonth)
543541
path_param_dict = dict(zip(path_param_keys, path_param_values))
544-
url = (
545-
'/v4/accounts/{account_id}/organizations/{organization_id}/resource_instances/usage/{billingmonth}'.format(
546-
**path_param_dict
547-
)
548-
)
542+
url = '/v4/accounts/{account_id}/organizations/{organization_id}/resource_instances/usage/{billingmonth}'.format(**path_param_dict)
549543
request = self.prepare_request(
550544
method='GET',
551545
url=url,
@@ -1461,6 +1455,12 @@ class InstanceUsage:
14611455
provisioned and rated.
14621456
:param str pricing_plan_id: (optional) The ID of the pricing plan used to rate
14631457
the usage.
1458+
:param str subscription_id: (optional) The ID of service subscription with
1459+
effective from timestamp.
1460+
:param datetime created_at: (optional) The timestamp in RFC 3339 string format
1461+
at which instance is created.
1462+
:param datetime deleted_at: (optional) The timestamp in RFC 3339 string format
1463+
at which instance is deleted.
14641464
:param str month: The month.
14651465
:param List[Metric] usage: All the resource used in the account.
14661466
:param bool pending: (optional) Pending charge from classic infrastructure.
@@ -1499,6 +1499,9 @@ def __init__(
14991499
parent_resource_instance_id: Optional[str] = None,
15001500
plan_name: Optional[str] = None,
15011501
pricing_plan_id: Optional[str] = None,
1502+
subscription_id: Optional[str] = None,
1503+
created_at: Optional[datetime] = None,
1504+
deleted_at: Optional[datetime] = None,
15021505
pending: Optional[bool] = None,
15031506
currency_rate: Optional[float] = None,
15041507
tags: Optional[List[object]] = None,
@@ -1538,6 +1541,12 @@ def __init__(
15381541
was provisioned and rated.
15391542
:param str pricing_plan_id: (optional) The ID of the pricing plan used to
15401543
rate the usage.
1544+
:param str subscription_id: (optional) The ID of service subscription with
1545+
effective from timestamp.
1546+
:param datetime created_at: (optional) The timestamp in RFC 3339 string
1547+
format at which instance is created.
1548+
:param datetime deleted_at: (optional) The timestamp in RFC 3339 string
1549+
format at which instance is deleted.
15411550
:param bool pending: (optional) Pending charge from classic infrastructure.
15421551
:param float currency_rate: (optional) The value of the account's currency
15431552
in USD.
@@ -1568,6 +1577,9 @@ def __init__(
15681577
self.plan_id = plan_id
15691578
self.plan_name = plan_name
15701579
self.pricing_plan_id = pricing_plan_id
1580+
self.subscription_id = subscription_id
1581+
self.created_at = created_at
1582+
self.deleted_at = deleted_at
15711583
self.month = month
15721584
self.usage = usage
15731585
self.pending = pending
@@ -1637,6 +1649,12 @@ def from_dict(cls, _dict: Dict) -> 'InstanceUsage':
16371649
args['plan_name'] = plan_name
16381650
if (pricing_plan_id := _dict.get('pricing_plan_id')) is not None:
16391651
args['pricing_plan_id'] = pricing_plan_id
1652+
if (subscription_id := _dict.get('subscription_id')) is not None:
1653+
args['subscription_id'] = subscription_id
1654+
if (created_at := _dict.get('created_at')) is not None:
1655+
args['created_at'] = string_to_datetime(created_at)
1656+
if (deleted_at := _dict.get('deleted_at')) is not None:
1657+
args['deleted_at'] = string_to_datetime(deleted_at)
16401658
if (month := _dict.get('month')) is not None:
16411659
args['month'] = month
16421660
else:
@@ -1707,6 +1725,12 @@ def to_dict(self) -> Dict:
17071725
_dict['plan_name'] = self.plan_name
17081726
if hasattr(self, 'pricing_plan_id') and self.pricing_plan_id is not None:
17091727
_dict['pricing_plan_id'] = self.pricing_plan_id
1728+
if hasattr(self, 'subscription_id') and self.subscription_id is not None:
1729+
_dict['subscription_id'] = self.subscription_id
1730+
if hasattr(self, 'created_at') and self.created_at is not None:
1731+
_dict['created_at'] = datetime_to_string(self.created_at)
1732+
if hasattr(self, 'deleted_at') and self.deleted_at is not None:
1733+
_dict['deleted_at'] = datetime_to_string(self.deleted_at)
17101734
if hasattr(self, 'month') and self.month is not None:
17111735
_dict['month'] = self.month
17121736
if hasattr(self, 'usage') and self.usage is not None:
@@ -2514,6 +2538,8 @@ class Plan:
25142538
:param bool billable: Indicates if the plan charges are billed to the customer.
25152539
:param float cost: The total cost incurred by the plan.
25162540
:param float rated_cost: Total pre-discounted cost incurred by the plan.
2541+
:param str subscription_id: (optional) The ID of service subscription with
2542+
effective from timestamp.
25172543
:param List[Metric] usage: All the metrics in the plan.
25182544
:param List[Discount] discounts: All the discounts applicable to the plan.
25192545
:param bool pending: (optional) Pending charge from classic infrastructure.
@@ -2531,6 +2557,7 @@ def __init__(
25312557
plan_name: Optional[str] = None,
25322558
pricing_region: Optional[str] = None,
25332559
pricing_plan_id: Optional[str] = None,
2560+
subscription_id: Optional[str] = None,
25342561
pending: Optional[bool] = None,
25352562
) -> None:
25362563
"""
@@ -2547,6 +2574,8 @@ def __init__(
25472574
:param str pricing_region: (optional) The pricing region for the plan.
25482575
:param str pricing_plan_id: (optional) The ID of the pricing plan used to
25492576
rate the usage.
2577+
:param str subscription_id: (optional) The ID of service subscription with
2578+
effective from timestamp.
25502579
:param bool pending: (optional) Pending charge from classic infrastructure.
25512580
"""
25522581
self.plan_id = plan_id
@@ -2556,6 +2585,7 @@ def __init__(
25562585
self.billable = billable
25572586
self.cost = cost
25582587
self.rated_cost = rated_cost
2588+
self.subscription_id = subscription_id
25592589
self.usage = usage
25602590
self.discounts = discounts
25612591
self.pending = pending
@@ -2586,6 +2616,8 @@ def from_dict(cls, _dict: Dict) -> 'Plan':
25862616
args['rated_cost'] = rated_cost
25872617
else:
25882618
raise ValueError('Required property \'rated_cost\' not present in Plan JSON')
2619+
if (subscription_id := _dict.get('subscription_id')) is not None:
2620+
args['subscription_id'] = subscription_id
25892621
if (usage := _dict.get('usage')) is not None:
25902622
args['usage'] = [Metric.from_dict(v) for v in usage]
25912623
else:
@@ -2620,6 +2652,8 @@ def to_dict(self) -> Dict:
26202652
_dict['cost'] = self.cost
26212653
if hasattr(self, 'rated_cost') and self.rated_cost is not None:
26222654
_dict['rated_cost'] = self.rated_cost
2655+
if hasattr(self, 'subscription_id') and self.subscription_id is not None:
2656+
_dict['subscription_id'] = self.subscription_id
26232657
if hasattr(self, 'usage') and self.usage is not None:
26242658
usage_list = []
26252659
for v in self.usage:
@@ -3025,9 +3059,9 @@ class SnapshotConfigHistoryItem:
30253059
"""
30263060
SnapshotConfigHistoryItem.
30273061
3028-
:param float start_time: (optional) Timestamp in milliseconds when the snapshot
3062+
:param int start_time: (optional) Timestamp in milliseconds when the snapshot
30293063
configuration was created.
3030-
:param float end_time: (optional) Timestamp in milliseconds when the snapshot
3064+
:param int end_time: (optional) Timestamp in milliseconds when the snapshot
30313065
configuration ends.
30323066
:param str updated_by: (optional) Account that updated the billing snapshot
30333067
configuration.
@@ -3057,8 +3091,8 @@ class SnapshotConfigHistoryItem:
30573091
def __init__(
30583092
self,
30593093
*,
3060-
start_time: Optional[float] = None,
3061-
end_time: Optional[float] = None,
3094+
start_time: Optional[int] = None,
3095+
end_time: Optional[int] = None,
30623096
updated_by: Optional[str] = None,
30633097
account_id: Optional[str] = None,
30643098
state: Optional[str] = None,
@@ -3076,10 +3110,10 @@ def __init__(
30763110
"""
30773111
Initialize a SnapshotConfigHistoryItem object.
30783112
3079-
:param float start_time: (optional) Timestamp in milliseconds when the
3113+
:param int start_time: (optional) Timestamp in milliseconds when the
30803114
snapshot configuration was created.
3081-
:param float end_time: (optional) Timestamp in milliseconds when the
3082-
snapshot configuration ends.
3115+
:param int end_time: (optional) Timestamp in milliseconds when the snapshot
3116+
configuration ends.
30833117
:param str updated_by: (optional) Account that updated the billing snapshot
30843118
configuration.
30853119
:param str account_id: (optional) Account ID for which billing report
@@ -3226,6 +3260,7 @@ class StateEnum(str, Enum):
32263260
ENABLED = 'enabled'
32273261
DISABLED = 'disabled'
32283262

3263+
32293264
class AccountTypeEnum(str, Enum):
32303265
"""
32313266
Type of account. Possible values [enterprise, account].
@@ -3234,13 +3269,15 @@ class AccountTypeEnum(str, Enum):
32343269
ACCOUNT = 'account'
32353270
ENTERPRISE = 'enterprise'
32363271

3272+
32373273
class IntervalEnum(str, Enum):
32383274
"""
32393275
Frequency of taking the snapshot of the billing reports.
32403276
"""
32413277

32423278
DAILY = 'daily'
32433279

3280+
32443281
class VersioningEnum(str, Enum):
32453282
"""
32463283
A new version of report is created or the existing report version is overwritten
@@ -3250,6 +3287,7 @@ class VersioningEnum(str, Enum):
32503287
NEW = 'new'
32513288
OVERWRITE = 'overwrite'
32523289

3290+
32533291
class ReportTypesEnum(str, Enum):
32543292
"""
32553293
report_types.
@@ -3260,11 +3298,12 @@ class ReportTypesEnum(str, Enum):
32603298
ACCOUNT_RESOURCE_INSTANCE_USAGE = 'account_resource_instance_usage'
32613299

32623300

3301+
32633302
class SnapshotList:
32643303
"""
32653304
List of billing reports snapshots.
32663305
3267-
:param float count: (optional) Number of total snapshots.
3306+
:param int count: (optional) Number of total snapshots.
32683307
:param SnapshotListFirst first: (optional) Reference to the first page of the
32693308
search query.
32703309
:param SnapshotListNext next: (optional) Reference to the next page of the
@@ -3275,15 +3314,15 @@ class SnapshotList:
32753314
def __init__(
32763315
self,
32773316
*,
3278-
count: Optional[float] = None,
3317+
count: Optional[int] = None,
32793318
first: Optional['SnapshotListFirst'] = None,
32803319
next: Optional['SnapshotListNext'] = None,
32813320
snapshots: Optional[List['SnapshotListSnapshotsItem']] = None,
32823321
) -> None:
32833322
"""
32843323
Initialize a SnapshotList object.
32853324
3286-
:param float count: (optional) Number of total snapshots.
3325+
:param int count: (optional) Number of total snapshots.
32873326
:param SnapshotListFirst first: (optional) Reference to the first page of
32883327
the search query.
32893328
:param SnapshotListNext next: (optional) Reference to the next page of the
@@ -3510,7 +3549,7 @@ class SnapshotListSnapshotsItem:
35103549
List of report types configured for the snapshot.
35113550
:param List[SnapshotListSnapshotsItemFilesItem] files: (optional) List of
35123551
location of reports.
3513-
:param float processed_at: (optional) Timestamp at which snapshot is captured.
3552+
:param int processed_at: (optional) Timestamp at which snapshot is captured.
35143553
"""
35153554

35163555
def __init__(
@@ -3702,6 +3741,7 @@ class AccountTypeEnum(str, Enum):
37023741
ACCOUNT = 'account'
37033742
ENTERPRISE = 'enterprise'
37043743

3744+
37053745
class StateEnum(str, Enum):
37063746
"""
37073747
Status of the billing snapshot configuration. Possible values are [enabled,
@@ -3712,6 +3752,7 @@ class StateEnum(str, Enum):
37123752
DISABLED = 'disabled'
37133753

37143754

3755+
37153756
class SnapshotListSnapshotsItemBillingPeriod:
37163757
"""
37173758
Period of billing in snapshot.
@@ -3874,6 +3915,7 @@ class ReportTypesEnum(str, Enum):
38743915
ACCOUNT_RESOURCE_INSTANCE_USAGE = 'account_resource_instance_usage'
38753916

38763917

3918+
38773919
class SnapshotListSnapshotsItemReportTypesItem:
38783920
"""
38793921
SnapshotListSnapshotsItemReportTypesItem.
@@ -3954,6 +3996,7 @@ class TypeEnum(str, Enum):
39543996
ACCOUNT_RESOURCE_INSTANCE_USAGE = 'account_resource_instance_usage'
39553997

39563998

3999+
39574000
class SnapshotConfig:
39584001
"""
39594002
Billing reports snapshot configuration.
@@ -3979,9 +4022,9 @@ class SnapshotConfig:
39794022
snapshot of the billing reports.
39804023
:param str cos_location: (optional) Region of the COS instance.
39814024
:param str cos_endpoint: (optional) The endpoint of the COS instance.
3982-
:param float created_at: (optional) Timestamp in milliseconds when the snapshot
4025+
:param int created_at: (optional) Timestamp in milliseconds when the snapshot
39834026
configuration was created.
3984-
:param float last_updated_at: (optional) Timestamp in milliseconds when the
4027+
:param int last_updated_at: (optional) Timestamp in milliseconds when the
39854028
snapshot configuration was last updated.
39864029
:param List[SnapshotConfigHistoryItem] history: (optional) List of previous
39874030
versions of the snapshot configurations.
@@ -4165,6 +4208,7 @@ class StateEnum(str, Enum):
41654208
ENABLED = 'enabled'
41664209
DISABLED = 'disabled'
41674210

4211+
41684212
class AccountTypeEnum(str, Enum):
41694213
"""
41704214
Type of account. Possible values are [enterprise, account].
@@ -4173,13 +4217,15 @@ class AccountTypeEnum(str, Enum):
41734217
ACCOUNT = 'account'
41744218
ENTERPRISE = 'enterprise'
41754219

4220+
41764221
class IntervalEnum(str, Enum):
41774222
"""
41784223
Frequency of taking the snapshot of the billing reports.
41794224
"""
41804225

41814226
DAILY = 'daily'
41824227

4228+
41834229
class VersioningEnum(str, Enum):
41844230
"""
41854231
A new version of report is created or the existing report version is overwritten
@@ -4189,6 +4235,7 @@ class VersioningEnum(str, Enum):
41894235
NEW = 'new'
41904236
OVERWRITE = 'overwrite'
41914237

4238+
41924239
class ReportTypesEnum(str, Enum):
41934240
"""
41944241
report_types.
@@ -4199,6 +4246,7 @@ class ReportTypesEnum(str, Enum):
41994246
ACCOUNT_RESOURCE_INSTANCE_USAGE = 'account_resource_instance_usage'
42004247

42014248

4249+
42024250
class SnapshotConfigValidateResponse:
42034251
"""
42044252
Validated billing service to COS bucket authorization.
@@ -4749,7 +4797,6 @@ def __ne__(self, other: 'SupportSummary') -> bool:
47494797
"""Return `true` when self and other are not equal, false otherwise."""
47504798
return not self == other
47514799

4752-
47534800
##############################################################################
47544801
# Pagers
47554802
##############################################################################

0 commit comments

Comments
 (0)