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,1324 @@
1
+ # coding: utf-8
2
+
3
+ # (C) Copyright IBM Corp. 2023.
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.64.1-cee95189-20230124-211647
18
+
19
+ """
20
+ Billing units for IBM Cloud Enterprise
21
+
22
+ API Version: 1.0.0
23
+ """
24
+
25
+ from datetime import datetime
26
+ from enum import Enum
27
+ from typing import Dict, List
28
+ import json
29
+
30
+ from ibm_cloud_sdk_core import BaseService, DetailedResponse, get_query_param
31
+ from ibm_cloud_sdk_core.authenticators.authenticator import Authenticator
32
+ from ibm_cloud_sdk_core.get_authenticator import get_authenticator_from_environment
33
+ from ibm_cloud_sdk_core.utils import datetime_to_string, string_to_datetime
34
+
35
+ from .common import get_sdk_headers
36
+
37
+ ##############################################################################
38
+ # Service
39
+ ##############################################################################
40
+
41
+
42
+ class EnterpriseBillingUnitsV1(BaseService):
43
+ """The Enterprise Billing Units V1 service."""
44
+
45
+ DEFAULT_SERVICE_URL = 'https://billing.cloud.ibm.com'
46
+ DEFAULT_SERVICE_NAME = 'enterprise_billing_units'
47
+
48
+ @classmethod
49
+ def new_instance(
50
+ cls,
51
+ service_name: str = DEFAULT_SERVICE_NAME,
52
+ ) -> 'EnterpriseBillingUnitsV1':
53
+ """
54
+ Return a new client for the Enterprise Billing Units service using the
55
+ specified parameters and external configuration.
56
+ """
57
+ authenticator = get_authenticator_from_environment(service_name)
58
+ service = cls(authenticator)
59
+ service.configure_service(service_name)
60
+ return service
61
+
62
+ def __init__(
63
+ self,
64
+ authenticator: Authenticator = None,
65
+ ) -> None:
66
+ """
67
+ Construct a new client for the Enterprise Billing Units service.
68
+
69
+ :param Authenticator authenticator: The authenticator specifies the authentication mechanism.
70
+ Get up to date information from https://github.com/IBM/python-sdk-core/blob/main/README.md
71
+ about initializing the authenticator of your choice.
72
+ """
73
+ BaseService.__init__(self, service_url=self.DEFAULT_SERVICE_URL, authenticator=authenticator)
74
+
75
+ #########################
76
+ # Billing Units
77
+ #########################
78
+
79
+ def get_billing_unit(self, billing_unit_id: str, **kwargs) -> DetailedResponse:
80
+ """
81
+ Get billing unit by ID.
82
+
83
+ Return the billing unit information if it exists.
84
+
85
+ :param str billing_unit_id: The ID of the requested billing unit.
86
+ :param dict headers: A `dict` containing the request headers
87
+ :return: A `DetailedResponse` containing the result, headers and HTTP status code.
88
+ :rtype: DetailedResponse with `dict` result representing a `BillingUnit` object
89
+ """
90
+
91
+ if not billing_unit_id:
92
+ raise ValueError('billing_unit_id must be provided')
93
+ headers = {}
94
+ sdk_headers = get_sdk_headers(
95
+ service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='get_billing_unit'
96
+ )
97
+ headers.update(sdk_headers)
98
+
99
+ if 'headers' in kwargs:
100
+ headers.update(kwargs.get('headers'))
101
+ del kwargs['headers']
102
+ headers['Accept'] = 'application/json'
103
+
104
+ path_param_keys = ['billing_unit_id']
105
+ path_param_values = self.encode_path_vars(billing_unit_id)
106
+ path_param_dict = dict(zip(path_param_keys, path_param_values))
107
+ url = '/v1/billing-units/{billing_unit_id}'.format(**path_param_dict)
108
+ request = self.prepare_request(method='GET', url=url, headers=headers)
109
+
110
+ response = self.send(request, **kwargs)
111
+ return response
112
+
113
+ def list_billing_units(
114
+ self,
115
+ *,
116
+ account_id: str = None,
117
+ enterprise_id: str = None,
118
+ account_group_id: str = None,
119
+ limit: int = None,
120
+ start: str = None,
121
+ **kwargs,
122
+ ) -> DetailedResponse:
123
+ """
124
+ List billing units.
125
+
126
+ Return matching billing unit information if any exists. Omits internal properties
127
+ and enterprise account ID from the billing unit.
128
+
129
+ :param str account_id: (optional) The enterprise account ID.
130
+ :param str enterprise_id: (optional) The enterprise ID.
131
+ :param str account_group_id: (optional) The account group ID.
132
+ :param int limit: (optional) Return results up to this limit. Valid values
133
+ are between 0 and 100.
134
+ :param str start: (optional) The pagination offset. This represents the
135
+ index of the first returned result.
136
+ :param dict headers: A `dict` containing the request headers
137
+ :return: A `DetailedResponse` containing the result, headers and HTTP status code.
138
+ :rtype: DetailedResponse with `dict` result representing a `BillingUnitsList` object
139
+ """
140
+
141
+ headers = {}
142
+ sdk_headers = get_sdk_headers(
143
+ service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='list_billing_units'
144
+ )
145
+ headers.update(sdk_headers)
146
+
147
+ params = {
148
+ 'account_id': account_id,
149
+ 'enterprise_id': enterprise_id,
150
+ 'account_group_id': account_group_id,
151
+ 'limit': limit,
152
+ 'start': start,
153
+ }
154
+
155
+ if 'headers' in kwargs:
156
+ headers.update(kwargs.get('headers'))
157
+ del kwargs['headers']
158
+ headers['Accept'] = 'application/json'
159
+
160
+ url = '/v1/billing-units'
161
+ request = self.prepare_request(method='GET', url=url, headers=headers, params=params)
162
+
163
+ response = self.send(request, **kwargs)
164
+ return response
165
+
166
+ #########################
167
+ # Billing Options
168
+ #########################
169
+
170
+ def list_billing_options(
171
+ self, billing_unit_id: str, *, limit: int = None, start: str = None, **kwargs
172
+ ) -> DetailedResponse:
173
+ """
174
+ List billing options.
175
+
176
+ Return matching billing options if any exist. Show subscriptions and promotional
177
+ offers that are available to a billing unit.
178
+
179
+ :param str billing_unit_id: The billing unit ID.
180
+ :param int limit: (optional) Return results up to this limit. Valid values
181
+ are between 0 and 100.
182
+ :param str start: (optional) The pagination offset. This represents the
183
+ index of the first returned result.
184
+ :param dict headers: A `dict` containing the request headers
185
+ :return: A `DetailedResponse` containing the result, headers and HTTP status code.
186
+ :rtype: DetailedResponse with `dict` result representing a `BillingOptionsList` object
187
+ """
188
+
189
+ if not billing_unit_id:
190
+ raise ValueError('billing_unit_id must be provided')
191
+ headers = {}
192
+ sdk_headers = get_sdk_headers(
193
+ service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='list_billing_options'
194
+ )
195
+ headers.update(sdk_headers)
196
+
197
+ params = {
198
+ 'billing_unit_id': billing_unit_id,
199
+ 'limit': limit,
200
+ 'start': start,
201
+ }
202
+
203
+ if 'headers' in kwargs:
204
+ headers.update(kwargs.get('headers'))
205
+ del kwargs['headers']
206
+ headers['Accept'] = 'application/json'
207
+
208
+ url = '/v1/billing-options'
209
+ request = self.prepare_request(method='GET', url=url, headers=headers, params=params)
210
+
211
+ response = self.send(request, **kwargs)
212
+ return response
213
+
214
+ #########################
215
+ # Credit Pools
216
+ #########################
217
+
218
+ def get_credit_pools(
219
+ self,
220
+ billing_unit_id: str,
221
+ *,
222
+ date: str = None,
223
+ type: str = None,
224
+ limit: int = None,
225
+ start: str = None,
226
+ **kwargs,
227
+ ) -> DetailedResponse:
228
+ """
229
+ Get credit pools.
230
+
231
+ Get credit pools for a billing unit. Credit pools can be either platform or
232
+ support credit pools. The platform credit pool contains credit from platform
233
+ subscriptions and promotional offers. The support credit pool contains credit from
234
+ support subscriptions.
235
+
236
+ :param str billing_unit_id: The ID of the billing unit.
237
+ :param str date: (optional) The date in the format of YYYY-MM.
238
+ :param str type: (optional) Filters the credit pool by type, either
239
+ `PLATFORM` or `SUPPORT`.
240
+ :param int limit: (optional) Return results up to this limit. Valid values
241
+ are between 0 and 100.
242
+ :param str start: (optional) The pagination offset. This represents the
243
+ index of the first returned result.
244
+ :param dict headers: A `dict` containing the request headers
245
+ :return: A `DetailedResponse` containing the result, headers and HTTP status code.
246
+ :rtype: DetailedResponse with `dict` result representing a `CreditPoolsList` object
247
+ """
248
+
249
+ if not billing_unit_id:
250
+ raise ValueError('billing_unit_id must be provided')
251
+ headers = {}
252
+ sdk_headers = get_sdk_headers(
253
+ service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='get_credit_pools'
254
+ )
255
+ headers.update(sdk_headers)
256
+
257
+ params = {
258
+ 'billing_unit_id': billing_unit_id,
259
+ 'date': date,
260
+ 'type': type,
261
+ 'limit': limit,
262
+ 'start': start,
263
+ }
264
+
265
+ if 'headers' in kwargs:
266
+ headers.update(kwargs.get('headers'))
267
+ del kwargs['headers']
268
+ headers['Accept'] = 'application/json'
269
+
270
+ url = '/v1/credit-pools'
271
+ request = self.prepare_request(method='GET', url=url, headers=headers, params=params)
272
+
273
+ response = self.send(request, **kwargs)
274
+ return response
275
+
276
+
277
+ ##############################################################################
278
+ # Models
279
+ ##############################################################################
280
+
281
+
282
+ class BillingOption:
283
+ """
284
+ Information about a billing option.
285
+
286
+ :attr str id: (optional) The ID of the billing option.
287
+ :attr str billing_unit_id: (optional) The ID of the billing unit that's
288
+ associated with the billing option.
289
+ :attr datetime start_date: (optional) The start date of billing option.
290
+ :attr datetime end_date: (optional) The end date of billing option.
291
+ :attr str state: (optional) The state of the billing option. The valid values
292
+ include `ACTIVE, `SUSPENDED`, and `CANCELED`.
293
+ :attr str type: (optional) The type of billing option. The valid values are
294
+ `SUBSCRIPTION` and `OFFER`.
295
+ :attr str category: (optional) The category of the billing option. The valid
296
+ values are `PLATFORM`, `SERVICE`, and `SUPPORT`.
297
+ :attr dict payment_instrument: (optional) The payment method for support.
298
+ :attr int duration_in_months: (optional) The duration of the billing options in
299
+ months.
300
+ :attr int line_item_id: (optional) The line item ID for support.
301
+ :attr dict billing_system: (optional) The support billing system.
302
+ :attr str renewal_mode_code: (optional) The renewal code for support. This code
303
+ denotes whether the subscription automatically renews, is assessed monthly, and
304
+ so on.
305
+ :attr datetime updated_at: (optional) The date when the billing option was
306
+ updated.
307
+ """
308
+
309
+ def __init__(
310
+ self,
311
+ *,
312
+ id: str = None,
313
+ billing_unit_id: str = None,
314
+ start_date: datetime = None,
315
+ end_date: datetime = None,
316
+ state: str = None,
317
+ type: str = None,
318
+ category: str = None,
319
+ payment_instrument: dict = None,
320
+ duration_in_months: int = None,
321
+ line_item_id: int = None,
322
+ billing_system: dict = None,
323
+ renewal_mode_code: str = None,
324
+ updated_at: datetime = None,
325
+ ) -> None:
326
+ """
327
+ Initialize a BillingOption object.
328
+
329
+ :param str id: (optional) The ID of the billing option.
330
+ :param str billing_unit_id: (optional) The ID of the billing unit that's
331
+ associated with the billing option.
332
+ :param datetime start_date: (optional) The start date of billing option.
333
+ :param datetime end_date: (optional) The end date of billing option.
334
+ :param str state: (optional) The state of the billing option. The valid
335
+ values include `ACTIVE, `SUSPENDED`, and `CANCELED`.
336
+ :param str type: (optional) The type of billing option. The valid values
337
+ are `SUBSCRIPTION` and `OFFER`.
338
+ :param str category: (optional) The category of the billing option. The
339
+ valid values are `PLATFORM`, `SERVICE`, and `SUPPORT`.
340
+ :param dict payment_instrument: (optional) The payment method for support.
341
+ :param int duration_in_months: (optional) The duration of the billing
342
+ options in months.
343
+ :param int line_item_id: (optional) The line item ID for support.
344
+ :param dict billing_system: (optional) The support billing system.
345
+ :param str renewal_mode_code: (optional) The renewal code for support. This
346
+ code denotes whether the subscription automatically renews, is assessed
347
+ monthly, and so on.
348
+ :param datetime updated_at: (optional) The date when the billing option was
349
+ updated.
350
+ """
351
+ self.id = id
352
+ self.billing_unit_id = billing_unit_id
353
+ self.start_date = start_date
354
+ self.end_date = end_date
355
+ self.state = state
356
+ self.type = type
357
+ self.category = category
358
+ self.payment_instrument = payment_instrument
359
+ self.duration_in_months = duration_in_months
360
+ self.line_item_id = line_item_id
361
+ self.billing_system = billing_system
362
+ self.renewal_mode_code = renewal_mode_code
363
+ self.updated_at = updated_at
364
+
365
+ @classmethod
366
+ def from_dict(cls, _dict: Dict) -> 'BillingOption':
367
+ """Initialize a BillingOption object from a json dictionary."""
368
+ args = {}
369
+ if 'id' in _dict:
370
+ args['id'] = _dict.get('id')
371
+ if 'billing_unit_id' in _dict:
372
+ args['billing_unit_id'] = _dict.get('billing_unit_id')
373
+ if 'start_date' in _dict:
374
+ args['start_date'] = string_to_datetime(_dict.get('start_date'))
375
+ if 'end_date' in _dict:
376
+ args['end_date'] = string_to_datetime(_dict.get('end_date'))
377
+ if 'state' in _dict:
378
+ args['state'] = _dict.get('state')
379
+ if 'type' in _dict:
380
+ args['type'] = _dict.get('type')
381
+ if 'category' in _dict:
382
+ args['category'] = _dict.get('category')
383
+ if 'payment_instrument' in _dict:
384
+ args['payment_instrument'] = _dict.get('payment_instrument')
385
+ if 'duration_in_months' in _dict:
386
+ args['duration_in_months'] = _dict.get('duration_in_months')
387
+ if 'line_item_id' in _dict:
388
+ args['line_item_id'] = _dict.get('line_item_id')
389
+ if 'billing_system' in _dict:
390
+ args['billing_system'] = _dict.get('billing_system')
391
+ if 'renewal_mode_code' in _dict:
392
+ args['renewal_mode_code'] = _dict.get('renewal_mode_code')
393
+ if 'updated_at' in _dict:
394
+ args['updated_at'] = string_to_datetime(_dict.get('updated_at'))
395
+ return cls(**args)
396
+
397
+ @classmethod
398
+ def _from_dict(cls, _dict):
399
+ """Initialize a BillingOption object from a json dictionary."""
400
+ return cls.from_dict(_dict)
401
+
402
+ def to_dict(self) -> Dict:
403
+ """Return a json dictionary representing this model."""
404
+ _dict = {}
405
+ if hasattr(self, 'id') and self.id is not None:
406
+ _dict['id'] = self.id
407
+ if hasattr(self, 'billing_unit_id') and self.billing_unit_id is not None:
408
+ _dict['billing_unit_id'] = self.billing_unit_id
409
+ if hasattr(self, 'start_date') and self.start_date is not None:
410
+ _dict['start_date'] = datetime_to_string(self.start_date)
411
+ if hasattr(self, 'end_date') and self.end_date is not None:
412
+ _dict['end_date'] = datetime_to_string(self.end_date)
413
+ if hasattr(self, 'state') and self.state is not None:
414
+ _dict['state'] = self.state
415
+ if hasattr(self, 'type') and self.type is not None:
416
+ _dict['type'] = self.type
417
+ if hasattr(self, 'category') and self.category is not None:
418
+ _dict['category'] = self.category
419
+ if hasattr(self, 'payment_instrument') and self.payment_instrument is not None:
420
+ _dict['payment_instrument'] = self.payment_instrument
421
+ if hasattr(self, 'duration_in_months') and self.duration_in_months is not None:
422
+ _dict['duration_in_months'] = self.duration_in_months
423
+ if hasattr(self, 'line_item_id') and self.line_item_id is not None:
424
+ _dict['line_item_id'] = self.line_item_id
425
+ if hasattr(self, 'billing_system') and self.billing_system is not None:
426
+ _dict['billing_system'] = self.billing_system
427
+ if hasattr(self, 'renewal_mode_code') and self.renewal_mode_code is not None:
428
+ _dict['renewal_mode_code'] = self.renewal_mode_code
429
+ if hasattr(self, 'updated_at') and self.updated_at is not None:
430
+ _dict['updated_at'] = datetime_to_string(self.updated_at)
431
+ return _dict
432
+
433
+ def _to_dict(self):
434
+ """Return a json dictionary representing this model."""
435
+ return self.to_dict()
436
+
437
+ def __str__(self) -> str:
438
+ """Return a `str` version of this BillingOption object."""
439
+ return json.dumps(self.to_dict(), indent=2)
440
+
441
+ def __eq__(self, other: 'BillingOption') -> bool:
442
+ """Return `true` when self and other are equal, false otherwise."""
443
+ if not isinstance(other, self.__class__):
444
+ return False
445
+ return self.__dict__ == other.__dict__
446
+
447
+ def __ne__(self, other: 'BillingOption') -> bool:
448
+ """Return `true` when self and other are not equal, false otherwise."""
449
+ return not self == other
450
+
451
+ class StateEnum(str, Enum):
452
+ """
453
+ The state of the billing option. The valid values include `ACTIVE, `SUSPENDED`,
454
+ and `CANCELED`.
455
+ """
456
+
457
+ ACTIVE = 'ACTIVE'
458
+ SUSPENDED = 'SUSPENDED'
459
+ CANCELED = 'CANCELED'
460
+
461
+ class TypeEnum(str, Enum):
462
+ """
463
+ The type of billing option. The valid values are `SUBSCRIPTION` and `OFFER`.
464
+ """
465
+
466
+ SUBSCRIPTION = 'SUBSCRIPTION'
467
+ OFFER = 'OFFER'
468
+
469
+ class CategoryEnum(str, Enum):
470
+ """
471
+ The category of the billing option. The valid values are `PLATFORM`, `SERVICE`,
472
+ and `SUPPORT`.
473
+ """
474
+
475
+ PLATFORM = 'PLATFORM'
476
+ SERVICE = 'SERVICE'
477
+ SUPPORT = 'SUPPORT'
478
+
479
+
480
+ class BillingOptionsList:
481
+ """
482
+ A search result containing zero or more billing options.
483
+
484
+ :attr int rows_count: (optional) A count of the billing units that were found by
485
+ the query.
486
+ :attr str next_url: (optional) Bookmark URL to query for next batch of billing
487
+ units. This returns `null` if no additional pages are required.
488
+ :attr List[BillingOption] resources: (optional) A list of billing units found.
489
+ """
490
+
491
+ def __init__(
492
+ self, *, rows_count: int = None, next_url: str = None, resources: List['BillingOption'] = None
493
+ ) -> None:
494
+ """
495
+ Initialize a BillingOptionsList object.
496
+
497
+ :param int rows_count: (optional) A count of the billing units that were
498
+ found by the query.
499
+ :param str next_url: (optional) Bookmark URL to query for next batch of
500
+ billing units. This returns `null` if no additional pages are required.
501
+ :param List[BillingOption] resources: (optional) A list of billing units
502
+ found.
503
+ """
504
+ self.rows_count = rows_count
505
+ self.next_url = next_url
506
+ self.resources = resources
507
+
508
+ @classmethod
509
+ def from_dict(cls, _dict: Dict) -> 'BillingOptionsList':
510
+ """Initialize a BillingOptionsList object from a json dictionary."""
511
+ args = {}
512
+ if 'rows_count' in _dict:
513
+ args['rows_count'] = _dict.get('rows_count')
514
+ if 'next_url' in _dict:
515
+ args['next_url'] = _dict.get('next_url')
516
+ if 'resources' in _dict:
517
+ args['resources'] = [BillingOption.from_dict(v) for v in _dict.get('resources')]
518
+ return cls(**args)
519
+
520
+ @classmethod
521
+ def _from_dict(cls, _dict):
522
+ """Initialize a BillingOptionsList object from a json dictionary."""
523
+ return cls.from_dict(_dict)
524
+
525
+ def to_dict(self) -> Dict:
526
+ """Return a json dictionary representing this model."""
527
+ _dict = {}
528
+ if hasattr(self, 'rows_count') and self.rows_count is not None:
529
+ _dict['rows_count'] = self.rows_count
530
+ if hasattr(self, 'next_url') and self.next_url is not None:
531
+ _dict['next_url'] = self.next_url
532
+ if hasattr(self, 'resources') and self.resources is not None:
533
+ resources_list = []
534
+ for v in self.resources:
535
+ if isinstance(v, dict):
536
+ resources_list.append(v)
537
+ else:
538
+ resources_list.append(v.to_dict())
539
+ _dict['resources'] = resources_list
540
+ return _dict
541
+
542
+ def _to_dict(self):
543
+ """Return a json dictionary representing this model."""
544
+ return self.to_dict()
545
+
546
+ def __str__(self) -> str:
547
+ """Return a `str` version of this BillingOptionsList object."""
548
+ return json.dumps(self.to_dict(), indent=2)
549
+
550
+ def __eq__(self, other: 'BillingOptionsList') -> bool:
551
+ """Return `true` when self and other are equal, false otherwise."""
552
+ if not isinstance(other, self.__class__):
553
+ return False
554
+ return self.__dict__ == other.__dict__
555
+
556
+ def __ne__(self, other: 'BillingOptionsList') -> bool:
557
+ """Return `true` when self and other are not equal, false otherwise."""
558
+ return not self == other
559
+
560
+
561
+ class BillingUnit:
562
+ """
563
+ Information about a billing unit.
564
+
565
+ :attr str id: (optional) The ID of the billing unit, which is a globally unique
566
+ identifier (GUID).
567
+ :attr str crn: (optional) The Cloud Resource Name (CRN) of the billing unit,
568
+ scoped to the enterprise account ID.
569
+ :attr str name: (optional) The name of the billing unit.
570
+ :attr str enterprise_id: (optional) The ID of the enterprise to which the
571
+ billing unit is associated.
572
+ :attr str currency_code: (optional) The currency code for the billing unit.
573
+ :attr str country_code: (optional) The country code for the billing unit.
574
+ :attr bool master: (optional) A flag that indicates whether this billing unit is
575
+ the primary billing mechanism for the enterprise.
576
+ :attr datetime created_at: (optional) The creation date of the billing unit.
577
+ """
578
+
579
+ def __init__(
580
+ self,
581
+ *,
582
+ id: str = None,
583
+ crn: str = None,
584
+ name: str = None,
585
+ enterprise_id: str = None,
586
+ currency_code: str = None,
587
+ country_code: str = None,
588
+ master: bool = None,
589
+ created_at: datetime = None,
590
+ ) -> None:
591
+ """
592
+ Initialize a BillingUnit object.
593
+
594
+ :param str id: (optional) The ID of the billing unit, which is a globally
595
+ unique identifier (GUID).
596
+ :param str crn: (optional) The Cloud Resource Name (CRN) of the billing
597
+ unit, scoped to the enterprise account ID.
598
+ :param str name: (optional) The name of the billing unit.
599
+ :param str enterprise_id: (optional) The ID of the enterprise to which the
600
+ billing unit is associated.
601
+ :param str currency_code: (optional) The currency code for the billing
602
+ unit.
603
+ :param str country_code: (optional) The country code for the billing unit.
604
+ :param bool master: (optional) A flag that indicates whether this billing
605
+ unit is the primary billing mechanism for the enterprise.
606
+ :param datetime created_at: (optional) The creation date of the billing
607
+ unit.
608
+ """
609
+ self.id = id
610
+ self.crn = crn
611
+ self.name = name
612
+ self.enterprise_id = enterprise_id
613
+ self.currency_code = currency_code
614
+ self.country_code = country_code
615
+ self.master = master
616
+ self.created_at = created_at
617
+
618
+ @classmethod
619
+ def from_dict(cls, _dict: Dict) -> 'BillingUnit':
620
+ """Initialize a BillingUnit object from a json dictionary."""
621
+ args = {}
622
+ if 'id' in _dict:
623
+ args['id'] = _dict.get('id')
624
+ if 'crn' in _dict:
625
+ args['crn'] = _dict.get('crn')
626
+ if 'name' in _dict:
627
+ args['name'] = _dict.get('name')
628
+ if 'enterprise_id' in _dict:
629
+ args['enterprise_id'] = _dict.get('enterprise_id')
630
+ if 'currency_code' in _dict:
631
+ args['currency_code'] = _dict.get('currency_code')
632
+ if 'country_code' in _dict:
633
+ args['country_code'] = _dict.get('country_code')
634
+ if 'master' in _dict:
635
+ args['master'] = _dict.get('master')
636
+ if 'created_at' in _dict:
637
+ args['created_at'] = string_to_datetime(_dict.get('created_at'))
638
+ return cls(**args)
639
+
640
+ @classmethod
641
+ def _from_dict(cls, _dict):
642
+ """Initialize a BillingUnit object from a json dictionary."""
643
+ return cls.from_dict(_dict)
644
+
645
+ def to_dict(self) -> Dict:
646
+ """Return a json dictionary representing this model."""
647
+ _dict = {}
648
+ if hasattr(self, 'id') and self.id is not None:
649
+ _dict['id'] = self.id
650
+ if hasattr(self, 'crn') and self.crn is not None:
651
+ _dict['crn'] = self.crn
652
+ if hasattr(self, 'name') and self.name is not None:
653
+ _dict['name'] = self.name
654
+ if hasattr(self, 'enterprise_id') and self.enterprise_id is not None:
655
+ _dict['enterprise_id'] = self.enterprise_id
656
+ if hasattr(self, 'currency_code') and self.currency_code is not None:
657
+ _dict['currency_code'] = self.currency_code
658
+ if hasattr(self, 'country_code') and self.country_code is not None:
659
+ _dict['country_code'] = self.country_code
660
+ if hasattr(self, 'master') and self.master is not None:
661
+ _dict['master'] = self.master
662
+ if hasattr(self, 'created_at') and self.created_at is not None:
663
+ _dict['created_at'] = datetime_to_string(self.created_at)
664
+ return _dict
665
+
666
+ def _to_dict(self):
667
+ """Return a json dictionary representing this model."""
668
+ return self.to_dict()
669
+
670
+ def __str__(self) -> str:
671
+ """Return a `str` version of this BillingUnit object."""
672
+ return json.dumps(self.to_dict(), indent=2)
673
+
674
+ def __eq__(self, other: 'BillingUnit') -> bool:
675
+ """Return `true` when self and other are equal, false otherwise."""
676
+ if not isinstance(other, self.__class__):
677
+ return False
678
+ return self.__dict__ == other.__dict__
679
+
680
+ def __ne__(self, other: 'BillingUnit') -> bool:
681
+ """Return `true` when self and other are not equal, false otherwise."""
682
+ return not self == other
683
+
684
+
685
+ class BillingUnitsList:
686
+ """
687
+ A search result contining zero or more billing units.
688
+
689
+ :attr int rows_count: (optional) A count of the billing units that were found by
690
+ the query.
691
+ :attr str next_url: (optional) Bookmark URL to query for next batch of billing
692
+ units. This returns `null` if no additional pages are required.
693
+ :attr List[BillingUnit] resources: (optional) A list of billing units found.
694
+ """
695
+
696
+ def __init__(self, *, rows_count: int = None, next_url: str = None, resources: List['BillingUnit'] = None) -> None:
697
+ """
698
+ Initialize a BillingUnitsList object.
699
+
700
+ :param int rows_count: (optional) A count of the billing units that were
701
+ found by the query.
702
+ :param str next_url: (optional) Bookmark URL to query for next batch of
703
+ billing units. This returns `null` if no additional pages are required.
704
+ :param List[BillingUnit] resources: (optional) A list of billing units
705
+ found.
706
+ """
707
+ self.rows_count = rows_count
708
+ self.next_url = next_url
709
+ self.resources = resources
710
+
711
+ @classmethod
712
+ def from_dict(cls, _dict: Dict) -> 'BillingUnitsList':
713
+ """Initialize a BillingUnitsList object from a json dictionary."""
714
+ args = {}
715
+ if 'rows_count' in _dict:
716
+ args['rows_count'] = _dict.get('rows_count')
717
+ if 'next_url' in _dict:
718
+ args['next_url'] = _dict.get('next_url')
719
+ if 'resources' in _dict:
720
+ args['resources'] = [BillingUnit.from_dict(v) for v in _dict.get('resources')]
721
+ return cls(**args)
722
+
723
+ @classmethod
724
+ def _from_dict(cls, _dict):
725
+ """Initialize a BillingUnitsList object from a json dictionary."""
726
+ return cls.from_dict(_dict)
727
+
728
+ def to_dict(self) -> Dict:
729
+ """Return a json dictionary representing this model."""
730
+ _dict = {}
731
+ if hasattr(self, 'rows_count') and self.rows_count is not None:
732
+ _dict['rows_count'] = self.rows_count
733
+ if hasattr(self, 'next_url') and self.next_url is not None:
734
+ _dict['next_url'] = self.next_url
735
+ if hasattr(self, 'resources') and self.resources is not None:
736
+ resources_list = []
737
+ for v in self.resources:
738
+ if isinstance(v, dict):
739
+ resources_list.append(v)
740
+ else:
741
+ resources_list.append(v.to_dict())
742
+ _dict['resources'] = resources_list
743
+ return _dict
744
+
745
+ def _to_dict(self):
746
+ """Return a json dictionary representing this model."""
747
+ return self.to_dict()
748
+
749
+ def __str__(self) -> str:
750
+ """Return a `str` version of this BillingUnitsList object."""
751
+ return json.dumps(self.to_dict(), indent=2)
752
+
753
+ def __eq__(self, other: 'BillingUnitsList') -> bool:
754
+ """Return `true` when self and other are equal, false otherwise."""
755
+ if not isinstance(other, self.__class__):
756
+ return False
757
+ return self.__dict__ == other.__dict__
758
+
759
+ def __ne__(self, other: 'BillingUnitsList') -> bool:
760
+ """Return `true` when self and other are not equal, false otherwise."""
761
+ return not self == other
762
+
763
+
764
+ class CreditPool:
765
+ """
766
+ The credit pool for a billing unit.
767
+
768
+ :attr str type: (optional) The type of credit, either `PLATFORM` or `SUPPORT`.
769
+ :attr str currency_code: (optional) The currency code of the associated billing
770
+ unit.
771
+ :attr str billing_unit_id: (optional) The ID of the billing unit that's
772
+ associated with the credit pool. This value is a globally unique identifier
773
+ (GUID).
774
+ :attr List[TermCredits] term_credits: (optional) A list of active subscription
775
+ terms available within a credit pool.
776
+ :attr CreditPoolOverage overage: (optional) Overage that was generated on the
777
+ credit pool.
778
+ """
779
+
780
+ def __init__(
781
+ self,
782
+ *,
783
+ type: str = None,
784
+ currency_code: str = None,
785
+ billing_unit_id: str = None,
786
+ term_credits: List['TermCredits'] = None,
787
+ overage: 'CreditPoolOverage' = None,
788
+ ) -> None:
789
+ """
790
+ Initialize a CreditPool object.
791
+
792
+ :param str type: (optional) The type of credit, either `PLATFORM` or
793
+ `SUPPORT`.
794
+ :param str currency_code: (optional) The currency code of the associated
795
+ billing unit.
796
+ :param str billing_unit_id: (optional) The ID of the billing unit that's
797
+ associated with the credit pool. This value is a globally unique identifier
798
+ (GUID).
799
+ :param List[TermCredits] term_credits: (optional) A list of active
800
+ subscription terms available within a credit pool.
801
+ :param CreditPoolOverage overage: (optional) Overage that was generated on
802
+ the credit pool.
803
+ """
804
+ self.type = type
805
+ self.currency_code = currency_code
806
+ self.billing_unit_id = billing_unit_id
807
+ self.term_credits = term_credits
808
+ self.overage = overage
809
+
810
+ @classmethod
811
+ def from_dict(cls, _dict: Dict) -> 'CreditPool':
812
+ """Initialize a CreditPool object from a json dictionary."""
813
+ args = {}
814
+ if 'type' in _dict:
815
+ args['type'] = _dict.get('type')
816
+ if 'currency_code' in _dict:
817
+ args['currency_code'] = _dict.get('currency_code')
818
+ if 'billing_unit_id' in _dict:
819
+ args['billing_unit_id'] = _dict.get('billing_unit_id')
820
+ if 'term_credits' in _dict:
821
+ args['term_credits'] = [TermCredits.from_dict(v) for v in _dict.get('term_credits')]
822
+ if 'overage' in _dict:
823
+ args['overage'] = CreditPoolOverage.from_dict(_dict.get('overage'))
824
+ return cls(**args)
825
+
826
+ @classmethod
827
+ def _from_dict(cls, _dict):
828
+ """Initialize a CreditPool object from a json dictionary."""
829
+ return cls.from_dict(_dict)
830
+
831
+ def to_dict(self) -> Dict:
832
+ """Return a json dictionary representing this model."""
833
+ _dict = {}
834
+ if hasattr(self, 'type') and self.type is not None:
835
+ _dict['type'] = self.type
836
+ if hasattr(self, 'currency_code') and self.currency_code is not None:
837
+ _dict['currency_code'] = self.currency_code
838
+ if hasattr(self, 'billing_unit_id') and self.billing_unit_id is not None:
839
+ _dict['billing_unit_id'] = self.billing_unit_id
840
+ if hasattr(self, 'term_credits') and self.term_credits is not None:
841
+ term_credits_list = []
842
+ for v in self.term_credits:
843
+ if isinstance(v, dict):
844
+ term_credits_list.append(v)
845
+ else:
846
+ term_credits_list.append(v.to_dict())
847
+ _dict['term_credits'] = term_credits_list
848
+ if hasattr(self, 'overage') and self.overage is not None:
849
+ if isinstance(self.overage, dict):
850
+ _dict['overage'] = self.overage
851
+ else:
852
+ _dict['overage'] = self.overage.to_dict()
853
+ return _dict
854
+
855
+ def _to_dict(self):
856
+ """Return a json dictionary representing this model."""
857
+ return self.to_dict()
858
+
859
+ def __str__(self) -> str:
860
+ """Return a `str` version of this CreditPool object."""
861
+ return json.dumps(self.to_dict(), indent=2)
862
+
863
+ def __eq__(self, other: 'CreditPool') -> bool:
864
+ """Return `true` when self and other are equal, false otherwise."""
865
+ if not isinstance(other, self.__class__):
866
+ return False
867
+ return self.__dict__ == other.__dict__
868
+
869
+ def __ne__(self, other: 'CreditPool') -> bool:
870
+ """Return `true` when self and other are not equal, false otherwise."""
871
+ return not self == other
872
+
873
+ class TypeEnum(str, Enum):
874
+ """
875
+ The type of credit, either `PLATFORM` or `SUPPORT`.
876
+ """
877
+
878
+ PLATFORM = 'PLATFORM'
879
+ SUPPORT = 'SUPPORT'
880
+
881
+
882
+ class CreditPoolOverage:
883
+ """
884
+ Overage that was generated on the credit pool.
885
+
886
+ :attr float cost: (optional) The number of credits used as overage.
887
+ :attr List[dict] resources: (optional) A list of resources that generated
888
+ overage.
889
+ """
890
+
891
+ def __init__(self, *, cost: float = None, resources: List[dict] = None) -> None:
892
+ """
893
+ Initialize a CreditPoolOverage object.
894
+
895
+ :param float cost: (optional) The number of credits used as overage.
896
+ :param List[dict] resources: (optional) A list of resources that generated
897
+ overage.
898
+ """
899
+ self.cost = cost
900
+ self.resources = resources
901
+
902
+ @classmethod
903
+ def from_dict(cls, _dict: Dict) -> 'CreditPoolOverage':
904
+ """Initialize a CreditPoolOverage object from a json dictionary."""
905
+ args = {}
906
+ if 'cost' in _dict:
907
+ args['cost'] = _dict.get('cost')
908
+ if 'resources' in _dict:
909
+ args['resources'] = _dict.get('resources')
910
+ return cls(**args)
911
+
912
+ @classmethod
913
+ def _from_dict(cls, _dict):
914
+ """Initialize a CreditPoolOverage object from a json dictionary."""
915
+ return cls.from_dict(_dict)
916
+
917
+ def to_dict(self) -> Dict:
918
+ """Return a json dictionary representing this model."""
919
+ _dict = {}
920
+ if hasattr(self, 'cost') and self.cost is not None:
921
+ _dict['cost'] = self.cost
922
+ if hasattr(self, 'resources') and self.resources is not None:
923
+ _dict['resources'] = self.resources
924
+ return _dict
925
+
926
+ def _to_dict(self):
927
+ """Return a json dictionary representing this model."""
928
+ return self.to_dict()
929
+
930
+ def __str__(self) -> str:
931
+ """Return a `str` version of this CreditPoolOverage object."""
932
+ return json.dumps(self.to_dict(), indent=2)
933
+
934
+ def __eq__(self, other: 'CreditPoolOverage') -> bool:
935
+ """Return `true` when self and other are equal, false otherwise."""
936
+ if not isinstance(other, self.__class__):
937
+ return False
938
+ return self.__dict__ == other.__dict__
939
+
940
+ def __ne__(self, other: 'CreditPoolOverage') -> bool:
941
+ """Return `true` when self and other are not equal, false otherwise."""
942
+ return not self == other
943
+
944
+
945
+ class CreditPoolsList:
946
+ """
947
+ A search result containing zero or more credit pools.
948
+
949
+ :attr int rows_count: (optional) The number of credit pools that were found by
950
+ the query.
951
+ :attr str next_url: (optional) A bookmark URL to the query for the next batch of
952
+ billing units. Use a value of `null` if no additional pages are required.
953
+ :attr List[CreditPool] resources: (optional) A list of credit pools found by the
954
+ query.
955
+ """
956
+
957
+ def __init__(self, *, rows_count: int = None, next_url: str = None, resources: List['CreditPool'] = None) -> None:
958
+ """
959
+ Initialize a CreditPoolsList object.
960
+
961
+ :param int rows_count: (optional) The number of credit pools that were
962
+ found by the query.
963
+ :param str next_url: (optional) A bookmark URL to the query for the next
964
+ batch of billing units. Use a value of `null` if no additional pages are
965
+ required.
966
+ :param List[CreditPool] resources: (optional) A list of credit pools found
967
+ by the query.
968
+ """
969
+ self.rows_count = rows_count
970
+ self.next_url = next_url
971
+ self.resources = resources
972
+
973
+ @classmethod
974
+ def from_dict(cls, _dict: Dict) -> 'CreditPoolsList':
975
+ """Initialize a CreditPoolsList object from a json dictionary."""
976
+ args = {}
977
+ if 'rows_count' in _dict:
978
+ args['rows_count'] = _dict.get('rows_count')
979
+ if 'next_url' in _dict:
980
+ args['next_url'] = _dict.get('next_url')
981
+ if 'resources' in _dict:
982
+ args['resources'] = [CreditPool.from_dict(v) for v in _dict.get('resources')]
983
+ return cls(**args)
984
+
985
+ @classmethod
986
+ def _from_dict(cls, _dict):
987
+ """Initialize a CreditPoolsList object from a json dictionary."""
988
+ return cls.from_dict(_dict)
989
+
990
+ def to_dict(self) -> Dict:
991
+ """Return a json dictionary representing this model."""
992
+ _dict = {}
993
+ if hasattr(self, 'rows_count') and self.rows_count is not None:
994
+ _dict['rows_count'] = self.rows_count
995
+ if hasattr(self, 'next_url') and self.next_url is not None:
996
+ _dict['next_url'] = self.next_url
997
+ if hasattr(self, 'resources') and self.resources is not None:
998
+ resources_list = []
999
+ for v in self.resources:
1000
+ if isinstance(v, dict):
1001
+ resources_list.append(v)
1002
+ else:
1003
+ resources_list.append(v.to_dict())
1004
+ _dict['resources'] = resources_list
1005
+ return _dict
1006
+
1007
+ def _to_dict(self):
1008
+ """Return a json dictionary representing this model."""
1009
+ return self.to_dict()
1010
+
1011
+ def __str__(self) -> str:
1012
+ """Return a `str` version of this CreditPoolsList object."""
1013
+ return json.dumps(self.to_dict(), indent=2)
1014
+
1015
+ def __eq__(self, other: 'CreditPoolsList') -> bool:
1016
+ """Return `true` when self and other are equal, false otherwise."""
1017
+ if not isinstance(other, self.__class__):
1018
+ return False
1019
+ return self.__dict__ == other.__dict__
1020
+
1021
+ def __ne__(self, other: 'CreditPoolsList') -> bool:
1022
+ """Return `true` when self and other are not equal, false otherwise."""
1023
+ return not self == other
1024
+
1025
+
1026
+ class TermCredits:
1027
+ """
1028
+ The subscription term that is active in the current month.
1029
+
1030
+ :attr str billing_option_id: (optional) The ID of the billing option from which
1031
+ the subscription term is derived.
1032
+ :attr str category: (optional) The category of the credit pool. The valid values
1033
+ are `PLATFORM`, `OFFER`, or `SERVICE` for platform credit and `SUPPORT` for
1034
+ support credit.
1035
+ :attr datetime start_date: (optional) The start date of the term in ISO format.
1036
+ :attr datetime end_date: (optional) The end date of the term in ISO format.
1037
+ :attr float total_credits: (optional) The total credit available in this term.
1038
+ :attr float starting_balance: (optional) The balance of available credit at the
1039
+ start of the current month.
1040
+ :attr float used_credits: (optional) The amount of credit used during the
1041
+ current month.
1042
+ :attr float current_balance: (optional) The balance of remaining credit in the
1043
+ subscription term.
1044
+ :attr List[dict] resources: (optional) A list of resources that used credit
1045
+ during the month.
1046
+ """
1047
+
1048
+ def __init__(
1049
+ self,
1050
+ *,
1051
+ billing_option_id: str = None,
1052
+ category: str = None,
1053
+ start_date: datetime = None,
1054
+ end_date: datetime = None,
1055
+ total_credits: float = None,
1056
+ starting_balance: float = None,
1057
+ used_credits: float = None,
1058
+ current_balance: float = None,
1059
+ resources: List[dict] = None,
1060
+ ) -> None:
1061
+ """
1062
+ Initialize a TermCredits object.
1063
+
1064
+ :param str billing_option_id: (optional) The ID of the billing option from
1065
+ which the subscription term is derived.
1066
+ :param str category: (optional) The category of the credit pool. The valid
1067
+ values are `PLATFORM`, `OFFER`, or `SERVICE` for platform credit and
1068
+ `SUPPORT` for support credit.
1069
+ :param datetime start_date: (optional) The start date of the term in ISO
1070
+ format.
1071
+ :param datetime end_date: (optional) The end date of the term in ISO
1072
+ format.
1073
+ :param float total_credits: (optional) The total credit available in this
1074
+ term.
1075
+ :param float starting_balance: (optional) The balance of available credit
1076
+ at the start of the current month.
1077
+ :param float used_credits: (optional) The amount of credit used during the
1078
+ current month.
1079
+ :param float current_balance: (optional) The balance of remaining credit in
1080
+ the subscription term.
1081
+ :param List[dict] resources: (optional) A list of resources that used
1082
+ credit during the month.
1083
+ """
1084
+ self.billing_option_id = billing_option_id
1085
+ self.category = category
1086
+ self.start_date = start_date
1087
+ self.end_date = end_date
1088
+ self.total_credits = total_credits
1089
+ self.starting_balance = starting_balance
1090
+ self.used_credits = used_credits
1091
+ self.current_balance = current_balance
1092
+ self.resources = resources
1093
+
1094
+ @classmethod
1095
+ def from_dict(cls, _dict: Dict) -> 'TermCredits':
1096
+ """Initialize a TermCredits object from a json dictionary."""
1097
+ args = {}
1098
+ if 'billing_option_id' in _dict:
1099
+ args['billing_option_id'] = _dict.get('billing_option_id')
1100
+ if 'category' in _dict:
1101
+ args['category'] = _dict.get('category')
1102
+ if 'start_date' in _dict:
1103
+ args['start_date'] = string_to_datetime(_dict.get('start_date'))
1104
+ if 'end_date' in _dict:
1105
+ args['end_date'] = string_to_datetime(_dict.get('end_date'))
1106
+ if 'total_credits' in _dict:
1107
+ args['total_credits'] = _dict.get('total_credits')
1108
+ if 'starting_balance' in _dict:
1109
+ args['starting_balance'] = _dict.get('starting_balance')
1110
+ if 'used_credits' in _dict:
1111
+ args['used_credits'] = _dict.get('used_credits')
1112
+ if 'current_balance' in _dict:
1113
+ args['current_balance'] = _dict.get('current_balance')
1114
+ if 'resources' in _dict:
1115
+ args['resources'] = _dict.get('resources')
1116
+ return cls(**args)
1117
+
1118
+ @classmethod
1119
+ def _from_dict(cls, _dict):
1120
+ """Initialize a TermCredits object from a json dictionary."""
1121
+ return cls.from_dict(_dict)
1122
+
1123
+ def to_dict(self) -> Dict:
1124
+ """Return a json dictionary representing this model."""
1125
+ _dict = {}
1126
+ if hasattr(self, 'billing_option_id') and self.billing_option_id is not None:
1127
+ _dict['billing_option_id'] = self.billing_option_id
1128
+ if hasattr(self, 'category') and self.category is not None:
1129
+ _dict['category'] = self.category
1130
+ if hasattr(self, 'start_date') and self.start_date is not None:
1131
+ _dict['start_date'] = datetime_to_string(self.start_date)
1132
+ if hasattr(self, 'end_date') and self.end_date is not None:
1133
+ _dict['end_date'] = datetime_to_string(self.end_date)
1134
+ if hasattr(self, 'total_credits') and self.total_credits is not None:
1135
+ _dict['total_credits'] = self.total_credits
1136
+ if hasattr(self, 'starting_balance') and self.starting_balance is not None:
1137
+ _dict['starting_balance'] = self.starting_balance
1138
+ if hasattr(self, 'used_credits') and self.used_credits is not None:
1139
+ _dict['used_credits'] = self.used_credits
1140
+ if hasattr(self, 'current_balance') and self.current_balance is not None:
1141
+ _dict['current_balance'] = self.current_balance
1142
+ if hasattr(self, 'resources') and self.resources is not None:
1143
+ _dict['resources'] = self.resources
1144
+ return _dict
1145
+
1146
+ def _to_dict(self):
1147
+ """Return a json dictionary representing this model."""
1148
+ return self.to_dict()
1149
+
1150
+ def __str__(self) -> str:
1151
+ """Return a `str` version of this TermCredits object."""
1152
+ return json.dumps(self.to_dict(), indent=2)
1153
+
1154
+ def __eq__(self, other: 'TermCredits') -> bool:
1155
+ """Return `true` when self and other are equal, false otherwise."""
1156
+ if not isinstance(other, self.__class__):
1157
+ return False
1158
+ return self.__dict__ == other.__dict__
1159
+
1160
+ def __ne__(self, other: 'TermCredits') -> bool:
1161
+ """Return `true` when self and other are not equal, false otherwise."""
1162
+ return not self == other
1163
+
1164
+ class CategoryEnum(str, Enum):
1165
+ """
1166
+ The category of the credit pool. The valid values are `PLATFORM`, `OFFER`, or
1167
+ `SERVICE` for platform credit and `SUPPORT` for support credit.
1168
+ """
1169
+
1170
+ PLATFORM = 'PLATFORM'
1171
+ OFFER = 'OFFER'
1172
+ SERVICE = 'SERVICE'
1173
+ SUPPORT = 'SUPPORT'
1174
+
1175
+
1176
+ ##############################################################################
1177
+ # Pagers
1178
+ ##############################################################################
1179
+
1180
+
1181
+ class BillingUnitsPager:
1182
+ """
1183
+ BillingUnitsPager can be used to simplify the use of the "list_billing_units" method.
1184
+ """
1185
+
1186
+ def __init__(
1187
+ self,
1188
+ *,
1189
+ client: EnterpriseBillingUnitsV1,
1190
+ account_id: str = None,
1191
+ enterprise_id: str = None,
1192
+ account_group_id: str = None,
1193
+ limit: int = None,
1194
+ ) -> None:
1195
+ """
1196
+ Initialize a BillingUnitsPager object.
1197
+ :param str account_id: (optional) The enterprise account ID.
1198
+ :param str enterprise_id: (optional) The enterprise ID.
1199
+ :param str account_group_id: (optional) The account group ID.
1200
+ :param int limit: (optional) Return results up to this limit. Valid values
1201
+ are between 0 and 100.
1202
+ """
1203
+ self._has_next = True
1204
+ self._client = client
1205
+ self._page_context = {'next': None}
1206
+ self._account_id = account_id
1207
+ self._enterprise_id = enterprise_id
1208
+ self._account_group_id = account_group_id
1209
+ self._limit = limit
1210
+
1211
+ def has_next(self) -> bool:
1212
+ """
1213
+ Returns true if there are potentially more results to be retrieved.
1214
+ """
1215
+ return self._has_next
1216
+
1217
+ def get_next(self) -> List[dict]:
1218
+ """
1219
+ Returns the next page of results.
1220
+ :return: A List[dict], where each element is a dict that represents an instance of BillingUnit.
1221
+ :rtype: List[dict]
1222
+ """
1223
+ if not self.has_next():
1224
+ raise StopIteration(message='No more results available')
1225
+
1226
+ result = self._client.list_billing_units(
1227
+ account_id=self._account_id,
1228
+ enterprise_id=self._enterprise_id,
1229
+ account_group_id=self._account_group_id,
1230
+ limit=self._limit,
1231
+ start=self._page_context.get('next'),
1232
+ ).get_result()
1233
+
1234
+ next = None
1235
+ next_page_link = result.get('next_url')
1236
+ if next_page_link is not None:
1237
+ next = get_query_param(next_page_link.rstrip('&'), 'start')
1238
+ self._page_context['next'] = next
1239
+ if next is None:
1240
+ self._has_next = False
1241
+
1242
+ return result.get('resources')
1243
+
1244
+ def get_all(self) -> List[dict]:
1245
+ """
1246
+ Returns all results by invoking get_next() repeatedly
1247
+ until all pages of results have been retrieved.
1248
+ :return: A List[dict], where each element is a dict that represents an instance of BillingUnit.
1249
+ :rtype: List[dict]
1250
+ """
1251
+ results = []
1252
+ while self.has_next():
1253
+ next_page = self.get_next()
1254
+ results.extend(next_page)
1255
+ return results
1256
+
1257
+
1258
+ class BillingOptionsPager:
1259
+ """
1260
+ BillingOptionsPager can be used to simplify the use of the "list_billing_options" method.
1261
+ """
1262
+
1263
+ def __init__(
1264
+ self,
1265
+ *,
1266
+ client: EnterpriseBillingUnitsV1,
1267
+ billing_unit_id: str,
1268
+ limit: int = None,
1269
+ ) -> None:
1270
+ """
1271
+ Initialize a BillingOptionsPager object.
1272
+ :param str billing_unit_id: The billing unit ID.
1273
+ :param int limit: (optional) Return results up to this limit. Valid values
1274
+ are between 0 and 100.
1275
+ """
1276
+ self._has_next = True
1277
+ self._client = client
1278
+ self._page_context = {'next': None}
1279
+ self._billing_unit_id = billing_unit_id
1280
+ self._limit = limit
1281
+
1282
+ def has_next(self) -> bool:
1283
+ """
1284
+ Returns true if there are potentially more results to be retrieved.
1285
+ """
1286
+ return self._has_next
1287
+
1288
+ def get_next(self) -> List[dict]:
1289
+ """
1290
+ Returns the next page of results.
1291
+ :return: A List[dict], where each element is a dict that represents an instance of BillingOption.
1292
+ :rtype: List[dict]
1293
+ """
1294
+ if not self.has_next():
1295
+ raise StopIteration(message='No more results available')
1296
+
1297
+ result = self._client.list_billing_options(
1298
+ billing_unit_id=self._billing_unit_id,
1299
+ limit=self._limit,
1300
+ start=self._page_context.get('next'),
1301
+ ).get_result()
1302
+
1303
+ next = None
1304
+ next_page_link = result.get('next_url')
1305
+ if next_page_link is not None:
1306
+ next = get_query_param(next_page_link.rstrip('&'), 'start')
1307
+ self._page_context['next'] = next
1308
+ if next is None:
1309
+ self._has_next = False
1310
+
1311
+ return result.get('resources')
1312
+
1313
+ def get_all(self) -> List[dict]:
1314
+ """
1315
+ Returns all results by invoking get_next() repeatedly
1316
+ until all pages of results have been retrieved.
1317
+ :return: A List[dict], where each element is a dict that represents an instance of BillingOption.
1318
+ :rtype: List[dict]
1319
+ """
1320
+ results = []
1321
+ while self.has_next():
1322
+ next_page = self.get_next()
1323
+ results.extend(next_page)
1324
+ return results