ibm-platform-services 0.55.3__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. ibm_platform_services/__init__.py +43 -0
  2. ibm_platform_services/case_management_v1.py +2414 -0
  3. ibm_platform_services/catalog_management_v1.py +10127 -0
  4. ibm_platform_services/common.py +56 -0
  5. ibm_platform_services/context_based_restrictions_v1.py +3633 -0
  6. ibm_platform_services/enterprise_billing_units_v1.py +1324 -0
  7. ibm_platform_services/enterprise_management_v1.py +2497 -0
  8. ibm_platform_services/enterprise_usage_reports_v1.py +978 -0
  9. ibm_platform_services/global_catalog_v1.py +5129 -0
  10. ibm_platform_services/global_search_v2.py +497 -0
  11. ibm_platform_services/global_tagging_v1.py +1601 -0
  12. ibm_platform_services/iam_access_groups_v2.py +7684 -0
  13. ibm_platform_services/iam_identity_v1.py +11525 -0
  14. ibm_platform_services/iam_policy_management_v1.py +9016 -0
  15. ibm_platform_services/ibm_cloud_shell_v1.py +480 -0
  16. ibm_platform_services/open_service_broker_v1.py +1774 -0
  17. ibm_platform_services/partner_billing_units_v1.py +1381 -0
  18. ibm_platform_services/partner_usage_reports_v1.py +1091 -0
  19. ibm_platform_services/resource_controller_v2.py +4868 -0
  20. ibm_platform_services/resource_manager_v2.py +986 -0
  21. ibm_platform_services/usage_metering_v4.py +470 -0
  22. ibm_platform_services/usage_reports_v4.py +5165 -0
  23. ibm_platform_services/user_management_v1.py +1639 -0
  24. ibm_platform_services/version.py +5 -0
  25. ibm_platform_services-0.55.3.dist-info/LICENSE +201 -0
  26. ibm_platform_services-0.55.3.dist-info/METADATA +165 -0
  27. ibm_platform_services-0.55.3.dist-info/RECORD +29 -0
  28. ibm_platform_services-0.55.3.dist-info/WHEEL +5 -0
  29. ibm_platform_services-0.55.3.dist-info/top_level.txt +1 -0
@@ -0,0 +1,978 @@
1
+ # coding: utf-8
2
+
3
+ # (C) Copyright IBM Corp. 2022.
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ # IBM OpenAPI SDK Code Generator Version: 3.60.0-13f6e1ba-20221019-164457
18
+
19
+ """
20
+ Usage reports for IBM Cloud enterprise entities
21
+
22
+ API Version: 1.0.0-beta.1
23
+ """
24
+
25
+ from enum import Enum
26
+ from typing import Dict, List
27
+ import json
28
+
29
+ from ibm_cloud_sdk_core import BaseService, DetailedResponse, get_query_param
30
+ from ibm_cloud_sdk_core.authenticators.authenticator import Authenticator
31
+ from ibm_cloud_sdk_core.get_authenticator import get_authenticator_from_environment
32
+
33
+ from .common import get_sdk_headers
34
+
35
+ ##############################################################################
36
+ # Service
37
+ ##############################################################################
38
+
39
+
40
+ class EnterpriseUsageReportsV1(BaseService):
41
+ """The Enterprise Usage Reports V1 service."""
42
+
43
+ DEFAULT_SERVICE_URL = 'https://enterprise.cloud.ibm.com'
44
+ DEFAULT_SERVICE_NAME = 'enterprise_usage_reports'
45
+
46
+ @classmethod
47
+ def new_instance(
48
+ cls,
49
+ service_name: str = DEFAULT_SERVICE_NAME,
50
+ ) -> 'EnterpriseUsageReportsV1':
51
+ """
52
+ Return a new client for the Enterprise Usage Reports service using the
53
+ specified parameters and external configuration.
54
+ """
55
+ authenticator = get_authenticator_from_environment(service_name)
56
+ service = cls(authenticator)
57
+ service.configure_service(service_name)
58
+ return service
59
+
60
+ def __init__(
61
+ self,
62
+ authenticator: Authenticator = None,
63
+ ) -> None:
64
+ """
65
+ Construct a new client for the Enterprise Usage Reports service.
66
+
67
+ :param Authenticator authenticator: The authenticator specifies the authentication mechanism.
68
+ Get up to date information from https://github.com/IBM/python-sdk-core/blob/main/README.md
69
+ about initializing the authenticator of your choice.
70
+ """
71
+ BaseService.__init__(self, service_url=self.DEFAULT_SERVICE_URL, authenticator=authenticator)
72
+
73
+ #########################
74
+ # Enterprise Usage Reports
75
+ #########################
76
+
77
+ def get_resource_usage_report(
78
+ self,
79
+ *,
80
+ enterprise_id: str = None,
81
+ account_group_id: str = None,
82
+ account_id: str = None,
83
+ children: bool = None,
84
+ month: str = None,
85
+ billing_unit_id: str = None,
86
+ limit: int = None,
87
+ offset: str = None,
88
+ **kwargs,
89
+ ) -> DetailedResponse:
90
+ """
91
+ Get usage reports for enterprise entities.
92
+
93
+ Usage reports for entities in the IBM Cloud enterprise. These entities can be the
94
+ enterprise, an account group, or an account.
95
+
96
+ :param str enterprise_id: (optional) The ID of the enterprise for which the
97
+ reports are queried. This parameter cannot be used with the `account_id` or
98
+ `account_group_id` query parameters.
99
+ :param str account_group_id: (optional) The ID of the account group for
100
+ which the reports are queried. This parameter cannot be used with the
101
+ `account_id` or `enterprise_id` query parameters.
102
+ :param str account_id: (optional) The ID of the account for which the
103
+ reports are queried. This parameter cannot be used with the
104
+ `account_group_id` or `enterprise_id` query parameters.
105
+ :param bool children: (optional) Returns the reports for the immediate
106
+ child entities under the current account group or enterprise. This
107
+ parameter cannot be used with the `account_id` query parameter.
108
+ :param str month: (optional) The billing month for which the usage report
109
+ is requested. The format is in yyyy-mm. Defaults to the month in which the
110
+ report is queried.
111
+ :param str billing_unit_id: (optional) The ID of the billing unit by which
112
+ to filter the reports.
113
+ :param int limit: (optional) The maximum number of search results to be
114
+ returned.
115
+ :param str offset: (optional) An opaque value representing the offset of
116
+ the first item to be returned by a search query. If not specified, then the
117
+ first page of results is returned. To retrieve the next page of search
118
+ results, use the 'offset' query parameter value within the 'next.href' URL
119
+ found within a prior search query response.
120
+ :param dict headers: A `dict` containing the request headers
121
+ :return: A `DetailedResponse` containing the result, headers and HTTP status code.
122
+ :rtype: DetailedResponse with `dict` result representing a `Reports` object
123
+ """
124
+
125
+ headers = {}
126
+ sdk_headers = get_sdk_headers(
127
+ service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='get_resource_usage_report'
128
+ )
129
+ headers.update(sdk_headers)
130
+
131
+ params = {
132
+ 'enterprise_id': enterprise_id,
133
+ 'account_group_id': account_group_id,
134
+ 'account_id': account_id,
135
+ 'children': children,
136
+ 'month': month,
137
+ 'billing_unit_id': billing_unit_id,
138
+ 'limit': limit,
139
+ 'offset': offset,
140
+ }
141
+
142
+ if 'headers' in kwargs:
143
+ headers.update(kwargs.get('headers'))
144
+ del kwargs['headers']
145
+ headers['Accept'] = 'application/json'
146
+
147
+ url = '/v1/resource-usage-reports'
148
+ request = self.prepare_request(method='GET', url=url, headers=headers, params=params)
149
+
150
+ response = self.send(request, **kwargs)
151
+ return response
152
+
153
+
154
+ ##############################################################################
155
+ # Models
156
+ ##############################################################################
157
+
158
+
159
+ class Link:
160
+ """
161
+ An object that contains a link to a page of search results.
162
+
163
+ :attr str href: (optional) A link to a page of search results.
164
+ """
165
+
166
+ def __init__(self, *, href: str = None) -> None:
167
+ """
168
+ Initialize a Link object.
169
+
170
+ :param str href: (optional) A link to a page of search results.
171
+ """
172
+ self.href = href
173
+
174
+ @classmethod
175
+ def from_dict(cls, _dict: Dict) -> 'Link':
176
+ """Initialize a Link object from a json dictionary."""
177
+ args = {}
178
+ if 'href' in _dict:
179
+ args['href'] = _dict.get('href')
180
+ return cls(**args)
181
+
182
+ @classmethod
183
+ def _from_dict(cls, _dict):
184
+ """Initialize a Link object from a json dictionary."""
185
+ return cls.from_dict(_dict)
186
+
187
+ def to_dict(self) -> Dict:
188
+ """Return a json dictionary representing this model."""
189
+ _dict = {}
190
+ if hasattr(self, 'href') and self.href is not None:
191
+ _dict['href'] = self.href
192
+ return _dict
193
+
194
+ def _to_dict(self):
195
+ """Return a json dictionary representing this model."""
196
+ return self.to_dict()
197
+
198
+ def __str__(self) -> str:
199
+ """Return a `str` version of this Link object."""
200
+ return json.dumps(self.to_dict(), indent=2)
201
+
202
+ def __eq__(self, other: 'Link') -> bool:
203
+ """Return `true` when self and other are equal, false otherwise."""
204
+ if not isinstance(other, self.__class__):
205
+ return False
206
+ return self.__dict__ == other.__dict__
207
+
208
+ def __ne__(self, other: 'Link') -> bool:
209
+ """Return `true` when self and other are not equal, false otherwise."""
210
+ return not self == other
211
+
212
+
213
+ class MetricUsage:
214
+ """
215
+ An object that represents a metric.
216
+
217
+ :attr str metric: The name of the metric.
218
+ :attr str unit: A unit to qualify the quantity.
219
+ :attr float quantity: The aggregated value for the metric.
220
+ :attr float rateable_quantity: The quantity that is used for calculating
221
+ charges.
222
+ :attr float cost: The cost that was incurred by the metric.
223
+ :attr float rated_cost: The pre-discounted cost that was incurred by the metric.
224
+ :attr List[dict] price: (optional) The price with which cost was calculated.
225
+ """
226
+
227
+ def __init__(
228
+ self,
229
+ metric: str,
230
+ unit: str,
231
+ quantity: float,
232
+ rateable_quantity: float,
233
+ cost: float,
234
+ rated_cost: float,
235
+ *,
236
+ price: List[dict] = None,
237
+ ) -> None:
238
+ """
239
+ Initialize a MetricUsage object.
240
+
241
+ :param str metric: The name of the metric.
242
+ :param str unit: A unit to qualify the quantity.
243
+ :param float quantity: The aggregated value for the metric.
244
+ :param float rateable_quantity: The quantity that is used for calculating
245
+ charges.
246
+ :param float cost: The cost that was incurred by the metric.
247
+ :param float rated_cost: The pre-discounted cost that was incurred by the
248
+ metric.
249
+ :param List[dict] price: (optional) The price with which cost was
250
+ calculated.
251
+ """
252
+ self.metric = metric
253
+ self.unit = unit
254
+ self.quantity = quantity
255
+ self.rateable_quantity = rateable_quantity
256
+ self.cost = cost
257
+ self.rated_cost = rated_cost
258
+ self.price = price
259
+
260
+ @classmethod
261
+ def from_dict(cls, _dict: Dict) -> 'MetricUsage':
262
+ """Initialize a MetricUsage object from a json dictionary."""
263
+ args = {}
264
+ if 'metric' in _dict:
265
+ args['metric'] = _dict.get('metric')
266
+ else:
267
+ raise ValueError('Required property \'metric\' not present in MetricUsage JSON')
268
+ if 'unit' in _dict:
269
+ args['unit'] = _dict.get('unit')
270
+ else:
271
+ raise ValueError('Required property \'unit\' not present in MetricUsage JSON')
272
+ if 'quantity' in _dict:
273
+ args['quantity'] = _dict.get('quantity')
274
+ else:
275
+ raise ValueError('Required property \'quantity\' not present in MetricUsage JSON')
276
+ if 'rateable_quantity' in _dict:
277
+ args['rateable_quantity'] = _dict.get('rateable_quantity')
278
+ else:
279
+ raise ValueError('Required property \'rateable_quantity\' not present in MetricUsage JSON')
280
+ if 'cost' in _dict:
281
+ args['cost'] = _dict.get('cost')
282
+ else:
283
+ raise ValueError('Required property \'cost\' not present in MetricUsage JSON')
284
+ if 'rated_cost' in _dict:
285
+ args['rated_cost'] = _dict.get('rated_cost')
286
+ else:
287
+ raise ValueError('Required property \'rated_cost\' not present in MetricUsage JSON')
288
+ if 'price' in _dict:
289
+ args['price'] = _dict.get('price')
290
+ return cls(**args)
291
+
292
+ @classmethod
293
+ def _from_dict(cls, _dict):
294
+ """Initialize a MetricUsage object from a json dictionary."""
295
+ return cls.from_dict(_dict)
296
+
297
+ def to_dict(self) -> Dict:
298
+ """Return a json dictionary representing this model."""
299
+ _dict = {}
300
+ if hasattr(self, 'metric') and self.metric is not None:
301
+ _dict['metric'] = self.metric
302
+ if hasattr(self, 'unit') and self.unit is not None:
303
+ _dict['unit'] = self.unit
304
+ if hasattr(self, 'quantity') and self.quantity is not None:
305
+ _dict['quantity'] = self.quantity
306
+ if hasattr(self, 'rateable_quantity') and self.rateable_quantity is not None:
307
+ _dict['rateable_quantity'] = self.rateable_quantity
308
+ if hasattr(self, 'cost') and self.cost is not None:
309
+ _dict['cost'] = self.cost
310
+ if hasattr(self, 'rated_cost') and self.rated_cost is not None:
311
+ _dict['rated_cost'] = self.rated_cost
312
+ if hasattr(self, 'price') and self.price is not None:
313
+ _dict['price'] = self.price
314
+ return _dict
315
+
316
+ def _to_dict(self):
317
+ """Return a json dictionary representing this model."""
318
+ return self.to_dict()
319
+
320
+ def __str__(self) -> str:
321
+ """Return a `str` version of this MetricUsage object."""
322
+ return json.dumps(self.to_dict(), indent=2)
323
+
324
+ def __eq__(self, other: 'MetricUsage') -> bool:
325
+ """Return `true` when self and other are equal, false otherwise."""
326
+ if not isinstance(other, self.__class__):
327
+ return False
328
+ return self.__dict__ == other.__dict__
329
+
330
+ def __ne__(self, other: 'MetricUsage') -> bool:
331
+ """Return `true` when self and other are not equal, false otherwise."""
332
+ return not self == other
333
+
334
+
335
+ class PlanUsage:
336
+ """
337
+ Aggregated values for the plan.
338
+
339
+ :attr str plan_id: The ID of the plan.
340
+ :attr str pricing_region: (optional) The pricing region for the plan.
341
+ :attr str pricing_plan_id: (optional) The pricing plan with which the usage was
342
+ rated.
343
+ :attr bool billable: Whether the plan charges are billed to the customer.
344
+ :attr float cost: The total cost that was incurred by the plan.
345
+ :attr float rated_cost: The total pre-discounted cost that was incurred by the
346
+ plan.
347
+ :attr List[MetricUsage] usage: All of the metrics in the plan.
348
+ """
349
+
350
+ def __init__(
351
+ self,
352
+ plan_id: str,
353
+ billable: bool,
354
+ cost: float,
355
+ rated_cost: float,
356
+ usage: List['MetricUsage'],
357
+ *,
358
+ pricing_region: str = None,
359
+ pricing_plan_id: str = None,
360
+ ) -> None:
361
+ """
362
+ Initialize a PlanUsage object.
363
+
364
+ :param str plan_id: The ID of the plan.
365
+ :param bool billable: Whether the plan charges are billed to the customer.
366
+ :param float cost: The total cost that was incurred by the plan.
367
+ :param float rated_cost: The total pre-discounted cost that was incurred by
368
+ the plan.
369
+ :param List[MetricUsage] usage: All of the metrics in the plan.
370
+ :param str pricing_region: (optional) The pricing region for the plan.
371
+ :param str pricing_plan_id: (optional) The pricing plan with which the
372
+ usage was rated.
373
+ """
374
+ self.plan_id = plan_id
375
+ self.pricing_region = pricing_region
376
+ self.pricing_plan_id = pricing_plan_id
377
+ self.billable = billable
378
+ self.cost = cost
379
+ self.rated_cost = rated_cost
380
+ self.usage = usage
381
+
382
+ @classmethod
383
+ def from_dict(cls, _dict: Dict) -> 'PlanUsage':
384
+ """Initialize a PlanUsage object from a json dictionary."""
385
+ args = {}
386
+ if 'plan_id' in _dict:
387
+ args['plan_id'] = _dict.get('plan_id')
388
+ else:
389
+ raise ValueError('Required property \'plan_id\' not present in PlanUsage JSON')
390
+ if 'pricing_region' in _dict:
391
+ args['pricing_region'] = _dict.get('pricing_region')
392
+ if 'pricing_plan_id' in _dict:
393
+ args['pricing_plan_id'] = _dict.get('pricing_plan_id')
394
+ if 'billable' in _dict:
395
+ args['billable'] = _dict.get('billable')
396
+ else:
397
+ raise ValueError('Required property \'billable\' not present in PlanUsage JSON')
398
+ if 'cost' in _dict:
399
+ args['cost'] = _dict.get('cost')
400
+ else:
401
+ raise ValueError('Required property \'cost\' not present in PlanUsage JSON')
402
+ if 'rated_cost' in _dict:
403
+ args['rated_cost'] = _dict.get('rated_cost')
404
+ else:
405
+ raise ValueError('Required property \'rated_cost\' not present in PlanUsage JSON')
406
+ if 'usage' in _dict:
407
+ args['usage'] = [MetricUsage.from_dict(x) for x in _dict.get('usage')]
408
+ else:
409
+ raise ValueError('Required property \'usage\' not present in PlanUsage JSON')
410
+ return cls(**args)
411
+
412
+ @classmethod
413
+ def _from_dict(cls, _dict):
414
+ """Initialize a PlanUsage object from a json dictionary."""
415
+ return cls.from_dict(_dict)
416
+
417
+ def to_dict(self) -> Dict:
418
+ """Return a json dictionary representing this model."""
419
+ _dict = {}
420
+ if hasattr(self, 'plan_id') and self.plan_id is not None:
421
+ _dict['plan_id'] = self.plan_id
422
+ if hasattr(self, 'pricing_region') and self.pricing_region is not None:
423
+ _dict['pricing_region'] = self.pricing_region
424
+ if hasattr(self, 'pricing_plan_id') and self.pricing_plan_id is not None:
425
+ _dict['pricing_plan_id'] = self.pricing_plan_id
426
+ if hasattr(self, 'billable') and self.billable is not None:
427
+ _dict['billable'] = self.billable
428
+ if hasattr(self, 'cost') and self.cost is not None:
429
+ _dict['cost'] = self.cost
430
+ if hasattr(self, 'rated_cost') and self.rated_cost is not None:
431
+ _dict['rated_cost'] = self.rated_cost
432
+ if hasattr(self, 'usage') and self.usage is not None:
433
+ _dict['usage'] = [x.to_dict() for x in self.usage]
434
+ return _dict
435
+
436
+ def _to_dict(self):
437
+ """Return a json dictionary representing this model."""
438
+ return self.to_dict()
439
+
440
+ def __str__(self) -> str:
441
+ """Return a `str` version of this PlanUsage object."""
442
+ return json.dumps(self.to_dict(), indent=2)
443
+
444
+ def __eq__(self, other: 'PlanUsage') -> bool:
445
+ """Return `true` when self and other are equal, false otherwise."""
446
+ if not isinstance(other, self.__class__):
447
+ return False
448
+ return self.__dict__ == other.__dict__
449
+
450
+ def __ne__(self, other: 'PlanUsage') -> bool:
451
+ """Return `true` when self and other are not equal, false otherwise."""
452
+ return not self == other
453
+
454
+
455
+ class Reports:
456
+ """
457
+ Resource Usage Reports API response.
458
+
459
+ :attr int limit: (optional) The maximum number of reports in the response.
460
+ :attr Link first: (optional) An object that contains the link to the first page
461
+ of the search query.
462
+ :attr Link next: (optional) An object that contains the link to the next page of
463
+ the search query.
464
+ :attr List[ResourceUsageReport] reports: (optional) The list of usage reports.
465
+ """
466
+
467
+ def __init__(
468
+ self,
469
+ *,
470
+ limit: int = None,
471
+ first: 'Link' = None,
472
+ next: 'Link' = None,
473
+ reports: List['ResourceUsageReport'] = None,
474
+ ) -> None:
475
+ """
476
+ Initialize a Reports object.
477
+
478
+ :param int limit: (optional) The maximum number of reports in the response.
479
+ :param Link first: (optional) An object that contains the link to the first
480
+ page of the search query.
481
+ :param Link next: (optional) An object that contains the link to the next
482
+ page of the search query.
483
+ :param List[ResourceUsageReport] reports: (optional) The list of usage
484
+ reports.
485
+ """
486
+ self.limit = limit
487
+ self.first = first
488
+ self.next = next
489
+ self.reports = reports
490
+
491
+ @classmethod
492
+ def from_dict(cls, _dict: Dict) -> 'Reports':
493
+ """Initialize a Reports object from a json dictionary."""
494
+ args = {}
495
+ if 'limit' in _dict:
496
+ args['limit'] = _dict.get('limit')
497
+ if 'first' in _dict:
498
+ args['first'] = Link.from_dict(_dict.get('first'))
499
+ if 'next' in _dict:
500
+ args['next'] = Link.from_dict(_dict.get('next'))
501
+ if 'reports' in _dict:
502
+ args['reports'] = [ResourceUsageReport.from_dict(x) for x in _dict.get('reports')]
503
+ return cls(**args)
504
+
505
+ @classmethod
506
+ def _from_dict(cls, _dict):
507
+ """Initialize a Reports object from a json dictionary."""
508
+ return cls.from_dict(_dict)
509
+
510
+ def to_dict(self) -> Dict:
511
+ """Return a json dictionary representing this model."""
512
+ _dict = {}
513
+ if hasattr(self, 'limit') and self.limit is not None:
514
+ _dict['limit'] = self.limit
515
+ if hasattr(self, 'first') and self.first is not None:
516
+ _dict['first'] = self.first.to_dict()
517
+ if hasattr(self, 'next') and self.next is not None:
518
+ _dict['next'] = self.next.to_dict()
519
+ if hasattr(self, 'reports') and self.reports is not None:
520
+ _dict['reports'] = [x.to_dict() for x in self.reports]
521
+ return _dict
522
+
523
+ def _to_dict(self):
524
+ """Return a json dictionary representing this model."""
525
+ return self.to_dict()
526
+
527
+ def __str__(self) -> str:
528
+ """Return a `str` version of this Reports object."""
529
+ return json.dumps(self.to_dict(), indent=2)
530
+
531
+ def __eq__(self, other: 'Reports') -> bool:
532
+ """Return `true` when self and other are equal, false otherwise."""
533
+ if not isinstance(other, self.__class__):
534
+ return False
535
+ return self.__dict__ == other.__dict__
536
+
537
+ def __ne__(self, other: 'Reports') -> bool:
538
+ """Return `true` when self and other are not equal, false otherwise."""
539
+ return not self == other
540
+
541
+
542
+ class ResourceUsage:
543
+ """
544
+ A container for all the plans in the resource.
545
+
546
+ :attr str resource_id: The ID of the resource.
547
+ :attr float billable_cost: The billable charges for the account.
548
+ :attr float billable_rated_cost: The pre-discounted billable charges for the
549
+ account.
550
+ :attr float non_billable_cost: The non-billable charges for the account.
551
+ :attr float non_billable_rated_cost: The pre-discounted, non-billable charges
552
+ for the account.
553
+ :attr List[PlanUsage] plans: All of the plans in the resource.
554
+ """
555
+
556
+ def __init__(
557
+ self,
558
+ resource_id: str,
559
+ billable_cost: float,
560
+ billable_rated_cost: float,
561
+ non_billable_cost: float,
562
+ non_billable_rated_cost: float,
563
+ plans: List['PlanUsage'],
564
+ ) -> None:
565
+ """
566
+ Initialize a ResourceUsage object.
567
+
568
+ :param str resource_id: The ID of the resource.
569
+ :param float billable_cost: The billable charges for the account.
570
+ :param float billable_rated_cost: The pre-discounted billable charges for
571
+ the account.
572
+ :param float non_billable_cost: The non-billable charges for the account.
573
+ :param float non_billable_rated_cost: The pre-discounted, non-billable
574
+ charges for the account.
575
+ :param List[PlanUsage] plans: All of the plans in the resource.
576
+ """
577
+ self.resource_id = resource_id
578
+ self.billable_cost = billable_cost
579
+ self.billable_rated_cost = billable_rated_cost
580
+ self.non_billable_cost = non_billable_cost
581
+ self.non_billable_rated_cost = non_billable_rated_cost
582
+ self.plans = plans
583
+
584
+ @classmethod
585
+ def from_dict(cls, _dict: Dict) -> 'ResourceUsage':
586
+ """Initialize a ResourceUsage object from a json dictionary."""
587
+ args = {}
588
+ if 'resource_id' in _dict:
589
+ args['resource_id'] = _dict.get('resource_id')
590
+ else:
591
+ raise ValueError('Required property \'resource_id\' not present in ResourceUsage JSON')
592
+ if 'billable_cost' in _dict:
593
+ args['billable_cost'] = _dict.get('billable_cost')
594
+ else:
595
+ raise ValueError('Required property \'billable_cost\' not present in ResourceUsage JSON')
596
+ if 'billable_rated_cost' in _dict:
597
+ args['billable_rated_cost'] = _dict.get('billable_rated_cost')
598
+ else:
599
+ raise ValueError('Required property \'billable_rated_cost\' not present in ResourceUsage JSON')
600
+ if 'non_billable_cost' in _dict:
601
+ args['non_billable_cost'] = _dict.get('non_billable_cost')
602
+ else:
603
+ raise ValueError('Required property \'non_billable_cost\' not present in ResourceUsage JSON')
604
+ if 'non_billable_rated_cost' in _dict:
605
+ args['non_billable_rated_cost'] = _dict.get('non_billable_rated_cost')
606
+ else:
607
+ raise ValueError('Required property \'non_billable_rated_cost\' not present in ResourceUsage JSON')
608
+ if 'plans' in _dict:
609
+ args['plans'] = [PlanUsage.from_dict(x) for x in _dict.get('plans')]
610
+ else:
611
+ raise ValueError('Required property \'plans\' not present in ResourceUsage JSON')
612
+ return cls(**args)
613
+
614
+ @classmethod
615
+ def _from_dict(cls, _dict):
616
+ """Initialize a ResourceUsage object from a json dictionary."""
617
+ return cls.from_dict(_dict)
618
+
619
+ def to_dict(self) -> Dict:
620
+ """Return a json dictionary representing this model."""
621
+ _dict = {}
622
+ if hasattr(self, 'resource_id') and self.resource_id is not None:
623
+ _dict['resource_id'] = self.resource_id
624
+ if hasattr(self, 'billable_cost') and self.billable_cost is not None:
625
+ _dict['billable_cost'] = self.billable_cost
626
+ if hasattr(self, 'billable_rated_cost') and self.billable_rated_cost is not None:
627
+ _dict['billable_rated_cost'] = self.billable_rated_cost
628
+ if hasattr(self, 'non_billable_cost') and self.non_billable_cost is not None:
629
+ _dict['non_billable_cost'] = self.non_billable_cost
630
+ if hasattr(self, 'non_billable_rated_cost') and self.non_billable_rated_cost is not None:
631
+ _dict['non_billable_rated_cost'] = self.non_billable_rated_cost
632
+ if hasattr(self, 'plans') and self.plans is not None:
633
+ _dict['plans'] = [x.to_dict() for x in self.plans]
634
+ return _dict
635
+
636
+ def _to_dict(self):
637
+ """Return a json dictionary representing this model."""
638
+ return self.to_dict()
639
+
640
+ def __str__(self) -> str:
641
+ """Return a `str` version of this ResourceUsage object."""
642
+ return json.dumps(self.to_dict(), indent=2)
643
+
644
+ def __eq__(self, other: 'ResourceUsage') -> bool:
645
+ """Return `true` when self and other are equal, false otherwise."""
646
+ if not isinstance(other, self.__class__):
647
+ return False
648
+ return self.__dict__ == other.__dict__
649
+
650
+ def __ne__(self, other: 'ResourceUsage') -> bool:
651
+ """Return `true` when self and other are not equal, false otherwise."""
652
+ return not self == other
653
+
654
+
655
+ class ResourceUsageReport:
656
+ """
657
+ An object that represents a usage report.
658
+
659
+ :attr str entity_id: The ID of the entity.
660
+ :attr str entity_type: The entity type.
661
+ :attr str entity_crn: The Cloud Resource Name (CRN) of the entity towards which
662
+ the resource usages were rolled up.
663
+ :attr str entity_name: A user-defined name for the entity, such as the
664
+ enterprise name or account group name.
665
+ :attr str billing_unit_id: The ID of the billing unit.
666
+ :attr str billing_unit_crn: The CRN of the billing unit.
667
+ :attr str billing_unit_name: The name of the billing unit.
668
+ :attr str country_code: The country code of the billing unit.
669
+ :attr str currency_code: The currency code of the billing unit.
670
+ :attr str month: Billing month.
671
+ :attr float billable_cost: Billable charges that are aggregated from all
672
+ entities in the report.
673
+ :attr float non_billable_cost: Non-billable charges that are aggregated from all
674
+ entities in the report.
675
+ :attr float billable_rated_cost: Aggregated billable charges before discounts.
676
+ :attr float non_billable_rated_cost: Aggregated non-billable charges before
677
+ discounts.
678
+ :attr List[ResourceUsage] resources: Details about all the resources that are
679
+ included in the aggregated charges.
680
+ """
681
+
682
+ def __init__(
683
+ self,
684
+ entity_id: str,
685
+ entity_type: str,
686
+ entity_crn: str,
687
+ entity_name: str,
688
+ billing_unit_id: str,
689
+ billing_unit_crn: str,
690
+ billing_unit_name: str,
691
+ country_code: str,
692
+ currency_code: str,
693
+ month: str,
694
+ billable_cost: float,
695
+ non_billable_cost: float,
696
+ billable_rated_cost: float,
697
+ non_billable_rated_cost: float,
698
+ resources: List['ResourceUsage'],
699
+ ) -> None:
700
+ """
701
+ Initialize a ResourceUsageReport object.
702
+
703
+ :param str entity_id: The ID of the entity.
704
+ :param str entity_type: The entity type.
705
+ :param str entity_crn: The Cloud Resource Name (CRN) of the entity towards
706
+ which the resource usages were rolled up.
707
+ :param str entity_name: A user-defined name for the entity, such as the
708
+ enterprise name or account group name.
709
+ :param str billing_unit_id: The ID of the billing unit.
710
+ :param str billing_unit_crn: The CRN of the billing unit.
711
+ :param str billing_unit_name: The name of the billing unit.
712
+ :param str country_code: The country code of the billing unit.
713
+ :param str currency_code: The currency code of the billing unit.
714
+ :param str month: Billing month.
715
+ :param float billable_cost: Billable charges that are aggregated from all
716
+ entities in the report.
717
+ :param float non_billable_cost: Non-billable charges that are aggregated
718
+ from all entities in the report.
719
+ :param float billable_rated_cost: Aggregated billable charges before
720
+ discounts.
721
+ :param float non_billable_rated_cost: Aggregated non-billable charges
722
+ before discounts.
723
+ :param List[ResourceUsage] resources: Details about all the resources that
724
+ are included in the aggregated charges.
725
+ """
726
+ self.entity_id = entity_id
727
+ self.entity_type = entity_type
728
+ self.entity_crn = entity_crn
729
+ self.entity_name = entity_name
730
+ self.billing_unit_id = billing_unit_id
731
+ self.billing_unit_crn = billing_unit_crn
732
+ self.billing_unit_name = billing_unit_name
733
+ self.country_code = country_code
734
+ self.currency_code = currency_code
735
+ self.month = month
736
+ self.billable_cost = billable_cost
737
+ self.non_billable_cost = non_billable_cost
738
+ self.billable_rated_cost = billable_rated_cost
739
+ self.non_billable_rated_cost = non_billable_rated_cost
740
+ self.resources = resources
741
+
742
+ @classmethod
743
+ def from_dict(cls, _dict: Dict) -> 'ResourceUsageReport':
744
+ """Initialize a ResourceUsageReport object from a json dictionary."""
745
+ args = {}
746
+ if 'entity_id' in _dict:
747
+ args['entity_id'] = _dict.get('entity_id')
748
+ else:
749
+ raise ValueError('Required property \'entity_id\' not present in ResourceUsageReport JSON')
750
+ if 'entity_type' in _dict:
751
+ args['entity_type'] = _dict.get('entity_type')
752
+ else:
753
+ raise ValueError('Required property \'entity_type\' not present in ResourceUsageReport JSON')
754
+ if 'entity_crn' in _dict:
755
+ args['entity_crn'] = _dict.get('entity_crn')
756
+ else:
757
+ raise ValueError('Required property \'entity_crn\' not present in ResourceUsageReport JSON')
758
+ if 'entity_name' in _dict:
759
+ args['entity_name'] = _dict.get('entity_name')
760
+ else:
761
+ raise ValueError('Required property \'entity_name\' not present in ResourceUsageReport JSON')
762
+ if 'billing_unit_id' in _dict:
763
+ args['billing_unit_id'] = _dict.get('billing_unit_id')
764
+ else:
765
+ raise ValueError('Required property \'billing_unit_id\' not present in ResourceUsageReport JSON')
766
+ if 'billing_unit_crn' in _dict:
767
+ args['billing_unit_crn'] = _dict.get('billing_unit_crn')
768
+ else:
769
+ raise ValueError('Required property \'billing_unit_crn\' not present in ResourceUsageReport JSON')
770
+ if 'billing_unit_name' in _dict:
771
+ args['billing_unit_name'] = _dict.get('billing_unit_name')
772
+ else:
773
+ raise ValueError('Required property \'billing_unit_name\' not present in ResourceUsageReport JSON')
774
+ if 'country_code' in _dict:
775
+ args['country_code'] = _dict.get('country_code')
776
+ else:
777
+ raise ValueError('Required property \'country_code\' not present in ResourceUsageReport JSON')
778
+ if 'currency_code' in _dict:
779
+ args['currency_code'] = _dict.get('currency_code')
780
+ else:
781
+ raise ValueError('Required property \'currency_code\' not present in ResourceUsageReport JSON')
782
+ if 'month' in _dict:
783
+ args['month'] = _dict.get('month')
784
+ else:
785
+ raise ValueError('Required property \'month\' not present in ResourceUsageReport JSON')
786
+ if 'billable_cost' in _dict:
787
+ args['billable_cost'] = _dict.get('billable_cost')
788
+ else:
789
+ raise ValueError('Required property \'billable_cost\' not present in ResourceUsageReport JSON')
790
+ if 'non_billable_cost' in _dict:
791
+ args['non_billable_cost'] = _dict.get('non_billable_cost')
792
+ else:
793
+ raise ValueError('Required property \'non_billable_cost\' not present in ResourceUsageReport JSON')
794
+ if 'billable_rated_cost' in _dict:
795
+ args['billable_rated_cost'] = _dict.get('billable_rated_cost')
796
+ else:
797
+ raise ValueError('Required property \'billable_rated_cost\' not present in ResourceUsageReport JSON')
798
+ if 'non_billable_rated_cost' in _dict:
799
+ args['non_billable_rated_cost'] = _dict.get('non_billable_rated_cost')
800
+ else:
801
+ raise ValueError('Required property \'non_billable_rated_cost\' not present in ResourceUsageReport JSON')
802
+ if 'resources' in _dict:
803
+ args['resources'] = [ResourceUsage.from_dict(x) for x in _dict.get('resources')]
804
+ else:
805
+ raise ValueError('Required property \'resources\' not present in ResourceUsageReport JSON')
806
+ return cls(**args)
807
+
808
+ @classmethod
809
+ def _from_dict(cls, _dict):
810
+ """Initialize a ResourceUsageReport object from a json dictionary."""
811
+ return cls.from_dict(_dict)
812
+
813
+ def to_dict(self) -> Dict:
814
+ """Return a json dictionary representing this model."""
815
+ _dict = {}
816
+ if hasattr(self, 'entity_id') and self.entity_id is not None:
817
+ _dict['entity_id'] = self.entity_id
818
+ if hasattr(self, 'entity_type') and self.entity_type is not None:
819
+ _dict['entity_type'] = self.entity_type
820
+ if hasattr(self, 'entity_crn') and self.entity_crn is not None:
821
+ _dict['entity_crn'] = self.entity_crn
822
+ if hasattr(self, 'entity_name') and self.entity_name is not None:
823
+ _dict['entity_name'] = self.entity_name
824
+ if hasattr(self, 'billing_unit_id') and self.billing_unit_id is not None:
825
+ _dict['billing_unit_id'] = self.billing_unit_id
826
+ if hasattr(self, 'billing_unit_crn') and self.billing_unit_crn is not None:
827
+ _dict['billing_unit_crn'] = self.billing_unit_crn
828
+ if hasattr(self, 'billing_unit_name') and self.billing_unit_name is not None:
829
+ _dict['billing_unit_name'] = self.billing_unit_name
830
+ if hasattr(self, 'country_code') and self.country_code is not None:
831
+ _dict['country_code'] = self.country_code
832
+ if hasattr(self, 'currency_code') and self.currency_code is not None:
833
+ _dict['currency_code'] = self.currency_code
834
+ if hasattr(self, 'month') and self.month is not None:
835
+ _dict['month'] = self.month
836
+ if hasattr(self, 'billable_cost') and self.billable_cost is not None:
837
+ _dict['billable_cost'] = self.billable_cost
838
+ if hasattr(self, 'non_billable_cost') and self.non_billable_cost is not None:
839
+ _dict['non_billable_cost'] = self.non_billable_cost
840
+ if hasattr(self, 'billable_rated_cost') and self.billable_rated_cost is not None:
841
+ _dict['billable_rated_cost'] = self.billable_rated_cost
842
+ if hasattr(self, 'non_billable_rated_cost') and self.non_billable_rated_cost is not None:
843
+ _dict['non_billable_rated_cost'] = self.non_billable_rated_cost
844
+ if hasattr(self, 'resources') and self.resources is not None:
845
+ _dict['resources'] = [x.to_dict() for x in self.resources]
846
+ return _dict
847
+
848
+ def _to_dict(self):
849
+ """Return a json dictionary representing this model."""
850
+ return self.to_dict()
851
+
852
+ def __str__(self) -> str:
853
+ """Return a `str` version of this ResourceUsageReport object."""
854
+ return json.dumps(self.to_dict(), indent=2)
855
+
856
+ def __eq__(self, other: 'ResourceUsageReport') -> bool:
857
+ """Return `true` when self and other are equal, false otherwise."""
858
+ if not isinstance(other, self.__class__):
859
+ return False
860
+ return self.__dict__ == other.__dict__
861
+
862
+ def __ne__(self, other: 'ResourceUsageReport') -> bool:
863
+ """Return `true` when self and other are not equal, false otherwise."""
864
+ return not self == other
865
+
866
+ class EntityTypeEnum(str, Enum):
867
+ """
868
+ The entity type.
869
+ """
870
+
871
+ ENTERPRISE = 'enterprise'
872
+ ACCOUNT_GROUP = 'account-group'
873
+ ACCOUNT = 'account'
874
+
875
+
876
+ ##############################################################################
877
+ # Pagers
878
+ ##############################################################################
879
+
880
+
881
+ class GetResourceUsageReportPager:
882
+ """
883
+ GetResourceUsageReportPager can be used to simplify the use of the "get_resource_usage_report" method.
884
+ """
885
+
886
+ def __init__(
887
+ self,
888
+ *,
889
+ client: EnterpriseUsageReportsV1,
890
+ enterprise_id: str = None,
891
+ account_group_id: str = None,
892
+ account_id: str = None,
893
+ children: bool = None,
894
+ month: str = None,
895
+ billing_unit_id: str = None,
896
+ limit: int = None,
897
+ ) -> None:
898
+ """
899
+ Initialize a GetResourceUsageReportPager object.
900
+ :param str enterprise_id: (optional) The ID of the enterprise for which the
901
+ reports are queried. This parameter cannot be used with the `account_id` or
902
+ `account_group_id` query parameters.
903
+ :param str account_group_id: (optional) The ID of the account group for
904
+ which the reports are queried. This parameter cannot be used with the
905
+ `account_id` or `enterprise_id` query parameters.
906
+ :param str account_id: (optional) The ID of the account for which the
907
+ reports are queried. This parameter cannot be used with the
908
+ `account_group_id` or `enterprise_id` query parameters.
909
+ :param bool children: (optional) Returns the reports for the immediate
910
+ child entities under the current account group or enterprise. This
911
+ parameter cannot be used with the `account_id` query parameter.
912
+ :param str month: (optional) The billing month for which the usage report
913
+ is requested. The format is in yyyy-mm. Defaults to the month in which the
914
+ report is queried.
915
+ :param str billing_unit_id: (optional) The ID of the billing unit by which
916
+ to filter the reports.
917
+ :param int limit: (optional) The maximum number of search results to be
918
+ returned.
919
+ """
920
+ self._has_next = True
921
+ self._client = client
922
+ self._page_context = {'next': None}
923
+ self._enterprise_id = enterprise_id
924
+ self._account_group_id = account_group_id
925
+ self._account_id = account_id
926
+ self._children = children
927
+ self._month = month
928
+ self._billing_unit_id = billing_unit_id
929
+ self._limit = limit
930
+
931
+ def has_next(self) -> bool:
932
+ """
933
+ Returns true if there are potentially more results to be retrieved.
934
+ """
935
+ return self._has_next
936
+
937
+ def get_next(self) -> List[dict]:
938
+ """
939
+ Returns the next page of results.
940
+ :return: A List[dict], where each element is a dict that represents an instance of ResourceUsageReport.
941
+ :rtype: List[dict]
942
+ """
943
+ if not self.has_next():
944
+ raise StopIteration(message='No more results available')
945
+
946
+ result = self._client.get_resource_usage_report(
947
+ enterprise_id=self._enterprise_id,
948
+ account_group_id=self._account_group_id,
949
+ account_id=self._account_id,
950
+ children=self._children,
951
+ month=self._month,
952
+ billing_unit_id=self._billing_unit_id,
953
+ limit=self._limit,
954
+ offset=self._page_context.get('next'),
955
+ ).get_result()
956
+
957
+ next = None
958
+ next_page_link = result.get('next')
959
+ if next_page_link is not None:
960
+ next = get_query_param(next_page_link.get('href'), 'offset')
961
+ self._page_context['next'] = next
962
+ if next is None:
963
+ self._has_next = False
964
+
965
+ return result.get('reports')
966
+
967
+ def get_all(self) -> List[dict]:
968
+ """
969
+ Returns all results by invoking get_next() repeatedly
970
+ until all pages of results have been retrieved.
971
+ :return: A List[dict], where each element is a dict that represents an instance of ResourceUsageReport.
972
+ :rtype: List[dict]
973
+ """
974
+ results = []
975
+ while self.has_next():
976
+ next_page = self.get_next()
977
+ results.extend(next_page)
978
+ return results