ibm-platform-services 0.57.1__py3-none-any.whl → 0.58.0__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.
- ibm_platform_services/__init__.py +1 -2
- ibm_platform_services/{partner_billing_units_v1.py → partner_management_v1.py} +1125 -389
- ibm_platform_services/version.py +1 -1
- {ibm_platform_services-0.57.1.dist-info → ibm_platform_services-0.58.0.dist-info}/METADATA +4 -5
- {ibm_platform_services-0.57.1.dist-info → ibm_platform_services-0.58.0.dist-info}/RECORD +8 -9
- {ibm_platform_services-0.57.1.dist-info → ibm_platform_services-0.58.0.dist-info}/WHEEL +1 -1
- ibm_platform_services/partner_usage_reports_v1.py +0 -1091
- {ibm_platform_services-0.57.1.dist-info → ibm_platform_services-0.58.0.dist-info}/LICENSE +0 -0
- {ibm_platform_services-0.57.1.dist-info → ibm_platform_services-0.58.0.dist-info}/top_level.txt +0 -0
|
@@ -1,1091 +0,0 @@
|
|
|
1
|
-
# coding: utf-8
|
|
2
|
-
|
|
3
|
-
# (C) Copyright IBM Corp. 2024.
|
|
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.85.0-75c38f8f-20240206-210220
|
|
18
|
-
|
|
19
|
-
"""
|
|
20
|
-
Usage reports for IBM Cloud partner entities
|
|
21
|
-
|
|
22
|
-
API Version: 1.0.0
|
|
23
|
-
"""
|
|
24
|
-
|
|
25
|
-
from enum import Enum
|
|
26
|
-
from typing import Dict, List, Optional
|
|
27
|
-
import json
|
|
28
|
-
|
|
29
|
-
from ibm_cloud_sdk_core import BaseService, DetailedResponse
|
|
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 PartnerUsageReportsV1(BaseService):
|
|
41
|
-
"""The Partner Usage Reports V1 service."""
|
|
42
|
-
|
|
43
|
-
DEFAULT_SERVICE_URL = 'https://partner.cloud.ibm.com'
|
|
44
|
-
DEFAULT_SERVICE_NAME = 'partner_usage_reports'
|
|
45
|
-
|
|
46
|
-
@classmethod
|
|
47
|
-
def new_instance(
|
|
48
|
-
cls,
|
|
49
|
-
service_name: str = DEFAULT_SERVICE_NAME,
|
|
50
|
-
) -> 'PartnerUsageReportsV1':
|
|
51
|
-
"""
|
|
52
|
-
Return a new client for the Partner 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 Partner 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
|
-
# Partner Usage Reports
|
|
75
|
-
#########################
|
|
76
|
-
|
|
77
|
-
def get_resource_usage_report(
|
|
78
|
-
self,
|
|
79
|
-
partner_id: str,
|
|
80
|
-
*,
|
|
81
|
-
reseller_id: Optional[str] = None,
|
|
82
|
-
customer_id: Optional[str] = None,
|
|
83
|
-
children: Optional[bool] = None,
|
|
84
|
-
month: Optional[str] = None,
|
|
85
|
-
viewpoint: Optional[str] = None,
|
|
86
|
-
recurse: Optional[bool] = None,
|
|
87
|
-
limit: Optional[int] = None,
|
|
88
|
-
offset: Optional[str] = None,
|
|
89
|
-
**kwargs,
|
|
90
|
-
) -> DetailedResponse:
|
|
91
|
-
"""
|
|
92
|
-
Get partner resource usage report.
|
|
93
|
-
|
|
94
|
-
Returns the summary for the partner for a given month. Partner billing managers
|
|
95
|
-
are authorized to access this report.
|
|
96
|
-
|
|
97
|
-
:param str partner_id: Enterprise ID of the distributor or reseller for
|
|
98
|
-
which the report is requested.
|
|
99
|
-
:param str reseller_id: (optional) Enterprise ID of the reseller for which
|
|
100
|
-
the report is requested. This parameter cannot be used along with
|
|
101
|
-
`customer_id` query parameter.
|
|
102
|
-
:param str customer_id: (optional) Enterprise ID of the child customer for
|
|
103
|
-
which the report is requested. This parameter cannot be used along with
|
|
104
|
-
`reseller_id` query parameter.
|
|
105
|
-
:param bool children: (optional) Get report rolled-up to the direct
|
|
106
|
-
children of the requested entity. Defaults to false. This parameter cannot
|
|
107
|
-
be used along with `customer_id` query parameter.
|
|
108
|
-
:param str month: (optional) The billing month for which the usage report
|
|
109
|
-
is requested. Format is `yyyy-mm`. Defaults to current month.
|
|
110
|
-
:param str viewpoint: (optional) Enables partner to view the cost of
|
|
111
|
-
provisioned services as applicable at each level of the hierarchy. Defaults
|
|
112
|
-
to the type of the calling partner. The valid values are `DISTRIBUTOR`,
|
|
113
|
-
`RESELLER` and `END_CUSTOMER`.
|
|
114
|
-
:param bool recurse: (optional) Get usage report rolled-up to the end
|
|
115
|
-
customers of the requested entity. Defaults to false. This parameter cannot
|
|
116
|
-
be used along with `reseller_id` query parameter or `customer_id` query
|
|
117
|
-
parameter.
|
|
118
|
-
:param int limit: (optional) Number of usage records to be returned. The
|
|
119
|
-
default value is 30. Maximum value is 200.
|
|
120
|
-
:param str offset: (optional) An opaque value representing the offset of
|
|
121
|
-
the first item to be returned by a search query. If not specified, then the
|
|
122
|
-
first page of results is returned. To retrieve the next page of search
|
|
123
|
-
results, use the 'offset' query parameter value within the 'next.href' URL
|
|
124
|
-
found within a prior search query response.
|
|
125
|
-
:param dict headers: A `dict` containing the request headers
|
|
126
|
-
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
|
|
127
|
-
:rtype: DetailedResponse with `dict` result representing a `PartnerUsageReportSummary` object
|
|
128
|
-
"""
|
|
129
|
-
|
|
130
|
-
if not partner_id:
|
|
131
|
-
raise ValueError('partner_id must be provided')
|
|
132
|
-
headers = {}
|
|
133
|
-
sdk_headers = get_sdk_headers(
|
|
134
|
-
service_name=self.DEFAULT_SERVICE_NAME,
|
|
135
|
-
service_version='V1',
|
|
136
|
-
operation_id='get_resource_usage_report',
|
|
137
|
-
)
|
|
138
|
-
headers.update(sdk_headers)
|
|
139
|
-
|
|
140
|
-
params = {
|
|
141
|
-
'partner_id': partner_id,
|
|
142
|
-
'reseller_id': reseller_id,
|
|
143
|
-
'customer_id': customer_id,
|
|
144
|
-
'children': children,
|
|
145
|
-
'month': month,
|
|
146
|
-
'viewpoint': viewpoint,
|
|
147
|
-
'recurse': recurse,
|
|
148
|
-
'limit': limit,
|
|
149
|
-
'offset': offset,
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
if 'headers' in kwargs:
|
|
153
|
-
headers.update(kwargs.get('headers'))
|
|
154
|
-
del kwargs['headers']
|
|
155
|
-
headers['Accept'] = 'application/json'
|
|
156
|
-
|
|
157
|
-
url = '/v1/resource-usage-reports'
|
|
158
|
-
request = self.prepare_request(
|
|
159
|
-
method='GET',
|
|
160
|
-
url=url,
|
|
161
|
-
headers=headers,
|
|
162
|
-
params=params,
|
|
163
|
-
)
|
|
164
|
-
|
|
165
|
-
response = self.send(request, **kwargs)
|
|
166
|
-
return response
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
class GetResourceUsageReportEnums:
|
|
170
|
-
"""
|
|
171
|
-
Enums for get_resource_usage_report parameters.
|
|
172
|
-
"""
|
|
173
|
-
|
|
174
|
-
class Viewpoint(str, Enum):
|
|
175
|
-
"""
|
|
176
|
-
Enables partner to view the cost of provisioned services as applicable at each
|
|
177
|
-
level of the hierarchy. Defaults to the type of the calling partner. The valid
|
|
178
|
-
values are `DISTRIBUTOR`, `RESELLER` and `END_CUSTOMER`.
|
|
179
|
-
"""
|
|
180
|
-
|
|
181
|
-
DISTRIBUTOR = 'DISTRIBUTOR'
|
|
182
|
-
RESELLER = 'RESELLER'
|
|
183
|
-
END_CUSTOMER = 'END_CUSTOMER'
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
##############################################################################
|
|
187
|
-
# Models
|
|
188
|
-
##############################################################################
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
class MetricUsage:
|
|
192
|
-
"""
|
|
193
|
-
An object that represents a metric.
|
|
194
|
-
|
|
195
|
-
:param str metric: The name of the metric.
|
|
196
|
-
:param str unit: A unit to qualify the quantity.
|
|
197
|
-
:param float quantity: The aggregated value for the metric.
|
|
198
|
-
:param float rateable_quantity: The quantity that is used for calculating
|
|
199
|
-
charges.
|
|
200
|
-
:param float cost: The cost that was incurred by the metric.
|
|
201
|
-
:param float rated_cost: The pre-discounted cost that was incurred by the
|
|
202
|
-
metric.
|
|
203
|
-
:param List[dict] price: (optional) The price with which cost was calculated.
|
|
204
|
-
"""
|
|
205
|
-
|
|
206
|
-
def __init__(
|
|
207
|
-
self,
|
|
208
|
-
metric: str,
|
|
209
|
-
unit: str,
|
|
210
|
-
quantity: float,
|
|
211
|
-
rateable_quantity: float,
|
|
212
|
-
cost: float,
|
|
213
|
-
rated_cost: float,
|
|
214
|
-
*,
|
|
215
|
-
price: Optional[List[dict]] = None,
|
|
216
|
-
) -> None:
|
|
217
|
-
"""
|
|
218
|
-
Initialize a MetricUsage object.
|
|
219
|
-
|
|
220
|
-
:param str metric: The name of the metric.
|
|
221
|
-
:param str unit: A unit to qualify the quantity.
|
|
222
|
-
:param float quantity: The aggregated value for the metric.
|
|
223
|
-
:param float rateable_quantity: The quantity that is used for calculating
|
|
224
|
-
charges.
|
|
225
|
-
:param float cost: The cost that was incurred by the metric.
|
|
226
|
-
:param float rated_cost: The pre-discounted cost that was incurred by the
|
|
227
|
-
metric.
|
|
228
|
-
:param List[dict] price: (optional) The price with which cost was
|
|
229
|
-
calculated.
|
|
230
|
-
"""
|
|
231
|
-
self.metric = metric
|
|
232
|
-
self.unit = unit
|
|
233
|
-
self.quantity = quantity
|
|
234
|
-
self.rateable_quantity = rateable_quantity
|
|
235
|
-
self.cost = cost
|
|
236
|
-
self.rated_cost = rated_cost
|
|
237
|
-
self.price = price
|
|
238
|
-
|
|
239
|
-
@classmethod
|
|
240
|
-
def from_dict(cls, _dict: Dict) -> 'MetricUsage':
|
|
241
|
-
"""Initialize a MetricUsage object from a json dictionary."""
|
|
242
|
-
args = {}
|
|
243
|
-
if (metric := _dict.get('metric')) is not None:
|
|
244
|
-
args['metric'] = metric
|
|
245
|
-
else:
|
|
246
|
-
raise ValueError('Required property \'metric\' not present in MetricUsage JSON')
|
|
247
|
-
if (unit := _dict.get('unit')) is not None:
|
|
248
|
-
args['unit'] = unit
|
|
249
|
-
else:
|
|
250
|
-
raise ValueError('Required property \'unit\' not present in MetricUsage JSON')
|
|
251
|
-
if (quantity := _dict.get('quantity')) is not None:
|
|
252
|
-
args['quantity'] = quantity
|
|
253
|
-
else:
|
|
254
|
-
raise ValueError('Required property \'quantity\' not present in MetricUsage JSON')
|
|
255
|
-
if (rateable_quantity := _dict.get('rateable_quantity')) is not None:
|
|
256
|
-
args['rateable_quantity'] = rateable_quantity
|
|
257
|
-
else:
|
|
258
|
-
raise ValueError('Required property \'rateable_quantity\' not present in MetricUsage JSON')
|
|
259
|
-
if (cost := _dict.get('cost')) is not None:
|
|
260
|
-
args['cost'] = cost
|
|
261
|
-
else:
|
|
262
|
-
raise ValueError('Required property \'cost\' not present in MetricUsage JSON')
|
|
263
|
-
if (rated_cost := _dict.get('rated_cost')) is not None:
|
|
264
|
-
args['rated_cost'] = rated_cost
|
|
265
|
-
else:
|
|
266
|
-
raise ValueError('Required property \'rated_cost\' not present in MetricUsage JSON')
|
|
267
|
-
if (price := _dict.get('price')) is not None:
|
|
268
|
-
args['price'] = price
|
|
269
|
-
return cls(**args)
|
|
270
|
-
|
|
271
|
-
@classmethod
|
|
272
|
-
def _from_dict(cls, _dict):
|
|
273
|
-
"""Initialize a MetricUsage object from a json dictionary."""
|
|
274
|
-
return cls.from_dict(_dict)
|
|
275
|
-
|
|
276
|
-
def to_dict(self) -> Dict:
|
|
277
|
-
"""Return a json dictionary representing this model."""
|
|
278
|
-
_dict = {}
|
|
279
|
-
if hasattr(self, 'metric') and self.metric is not None:
|
|
280
|
-
_dict['metric'] = self.metric
|
|
281
|
-
if hasattr(self, 'unit') and self.unit is not None:
|
|
282
|
-
_dict['unit'] = self.unit
|
|
283
|
-
if hasattr(self, 'quantity') and self.quantity is not None:
|
|
284
|
-
_dict['quantity'] = self.quantity
|
|
285
|
-
if hasattr(self, 'rateable_quantity') and self.rateable_quantity is not None:
|
|
286
|
-
_dict['rateable_quantity'] = self.rateable_quantity
|
|
287
|
-
if hasattr(self, 'cost') and self.cost is not None:
|
|
288
|
-
_dict['cost'] = self.cost
|
|
289
|
-
if hasattr(self, 'rated_cost') and self.rated_cost is not None:
|
|
290
|
-
_dict['rated_cost'] = self.rated_cost
|
|
291
|
-
if hasattr(self, 'price') and self.price is not None:
|
|
292
|
-
_dict['price'] = self.price
|
|
293
|
-
return _dict
|
|
294
|
-
|
|
295
|
-
def _to_dict(self):
|
|
296
|
-
"""Return a json dictionary representing this model."""
|
|
297
|
-
return self.to_dict()
|
|
298
|
-
|
|
299
|
-
def __str__(self) -> str:
|
|
300
|
-
"""Return a `str` version of this MetricUsage object."""
|
|
301
|
-
return json.dumps(self.to_dict(), indent=2)
|
|
302
|
-
|
|
303
|
-
def __eq__(self, other: 'MetricUsage') -> bool:
|
|
304
|
-
"""Return `true` when self and other are equal, false otherwise."""
|
|
305
|
-
if not isinstance(other, self.__class__):
|
|
306
|
-
return False
|
|
307
|
-
return self.__dict__ == other.__dict__
|
|
308
|
-
|
|
309
|
-
def __ne__(self, other: 'MetricUsage') -> bool:
|
|
310
|
-
"""Return `true` when self and other are not equal, false otherwise."""
|
|
311
|
-
return not self == other
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
class PartnerUsageReportSummaryFirst:
|
|
315
|
-
"""
|
|
316
|
-
The link to the first page of the search query.
|
|
317
|
-
|
|
318
|
-
:param str href: (optional) A link to a page of query results.
|
|
319
|
-
"""
|
|
320
|
-
|
|
321
|
-
def __init__(
|
|
322
|
-
self,
|
|
323
|
-
*,
|
|
324
|
-
href: Optional[str] = None,
|
|
325
|
-
) -> None:
|
|
326
|
-
"""
|
|
327
|
-
Initialize a PartnerUsageReportSummaryFirst object.
|
|
328
|
-
|
|
329
|
-
:param str href: (optional) A link to a page of query results.
|
|
330
|
-
"""
|
|
331
|
-
self.href = href
|
|
332
|
-
|
|
333
|
-
@classmethod
|
|
334
|
-
def from_dict(cls, _dict: Dict) -> 'PartnerUsageReportSummaryFirst':
|
|
335
|
-
"""Initialize a PartnerUsageReportSummaryFirst object from a json dictionary."""
|
|
336
|
-
args = {}
|
|
337
|
-
if (href := _dict.get('href')) is not None:
|
|
338
|
-
args['href'] = href
|
|
339
|
-
return cls(**args)
|
|
340
|
-
|
|
341
|
-
@classmethod
|
|
342
|
-
def _from_dict(cls, _dict):
|
|
343
|
-
"""Initialize a PartnerUsageReportSummaryFirst object from a json dictionary."""
|
|
344
|
-
return cls.from_dict(_dict)
|
|
345
|
-
|
|
346
|
-
def to_dict(self) -> Dict:
|
|
347
|
-
"""Return a json dictionary representing this model."""
|
|
348
|
-
_dict = {}
|
|
349
|
-
if hasattr(self, 'href') and self.href is not None:
|
|
350
|
-
_dict['href'] = self.href
|
|
351
|
-
return _dict
|
|
352
|
-
|
|
353
|
-
def _to_dict(self):
|
|
354
|
-
"""Return a json dictionary representing this model."""
|
|
355
|
-
return self.to_dict()
|
|
356
|
-
|
|
357
|
-
def __str__(self) -> str:
|
|
358
|
-
"""Return a `str` version of this PartnerUsageReportSummaryFirst object."""
|
|
359
|
-
return json.dumps(self.to_dict(), indent=2)
|
|
360
|
-
|
|
361
|
-
def __eq__(self, other: 'PartnerUsageReportSummaryFirst') -> bool:
|
|
362
|
-
"""Return `true` when self and other are equal, false otherwise."""
|
|
363
|
-
if not isinstance(other, self.__class__):
|
|
364
|
-
return False
|
|
365
|
-
return self.__dict__ == other.__dict__
|
|
366
|
-
|
|
367
|
-
def __ne__(self, other: 'PartnerUsageReportSummaryFirst') -> bool:
|
|
368
|
-
"""Return `true` when self and other are not equal, false otherwise."""
|
|
369
|
-
return not self == other
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
class PartnerUsageReportSummaryNext:
|
|
373
|
-
"""
|
|
374
|
-
The link to the next page of the search query.
|
|
375
|
-
|
|
376
|
-
:param str href: (optional) A link to a page of query results.
|
|
377
|
-
:param str offset: (optional) The value of the `_start` query parameter to fetch
|
|
378
|
-
the next page.
|
|
379
|
-
"""
|
|
380
|
-
|
|
381
|
-
def __init__(
|
|
382
|
-
self,
|
|
383
|
-
*,
|
|
384
|
-
href: Optional[str] = None,
|
|
385
|
-
offset: Optional[str] = None,
|
|
386
|
-
) -> None:
|
|
387
|
-
"""
|
|
388
|
-
Initialize a PartnerUsageReportSummaryNext object.
|
|
389
|
-
|
|
390
|
-
:param str href: (optional) A link to a page of query results.
|
|
391
|
-
:param str offset: (optional) The value of the `_start` query parameter to
|
|
392
|
-
fetch the next page.
|
|
393
|
-
"""
|
|
394
|
-
self.href = href
|
|
395
|
-
self.offset = offset
|
|
396
|
-
|
|
397
|
-
@classmethod
|
|
398
|
-
def from_dict(cls, _dict: Dict) -> 'PartnerUsageReportSummaryNext':
|
|
399
|
-
"""Initialize a PartnerUsageReportSummaryNext object from a json dictionary."""
|
|
400
|
-
args = {}
|
|
401
|
-
if (href := _dict.get('href')) is not None:
|
|
402
|
-
args['href'] = href
|
|
403
|
-
if (offset := _dict.get('offset')) is not None:
|
|
404
|
-
args['offset'] = offset
|
|
405
|
-
return cls(**args)
|
|
406
|
-
|
|
407
|
-
@classmethod
|
|
408
|
-
def _from_dict(cls, _dict):
|
|
409
|
-
"""Initialize a PartnerUsageReportSummaryNext object from a json dictionary."""
|
|
410
|
-
return cls.from_dict(_dict)
|
|
411
|
-
|
|
412
|
-
def to_dict(self) -> Dict:
|
|
413
|
-
"""Return a json dictionary representing this model."""
|
|
414
|
-
_dict = {}
|
|
415
|
-
if hasattr(self, 'href') and self.href is not None:
|
|
416
|
-
_dict['href'] = self.href
|
|
417
|
-
if hasattr(self, 'offset') and self.offset is not None:
|
|
418
|
-
_dict['offset'] = self.offset
|
|
419
|
-
return _dict
|
|
420
|
-
|
|
421
|
-
def _to_dict(self):
|
|
422
|
-
"""Return a json dictionary representing this model."""
|
|
423
|
-
return self.to_dict()
|
|
424
|
-
|
|
425
|
-
def __str__(self) -> str:
|
|
426
|
-
"""Return a `str` version of this PartnerUsageReportSummaryNext object."""
|
|
427
|
-
return json.dumps(self.to_dict(), indent=2)
|
|
428
|
-
|
|
429
|
-
def __eq__(self, other: 'PartnerUsageReportSummaryNext') -> bool:
|
|
430
|
-
"""Return `true` when self and other are equal, false otherwise."""
|
|
431
|
-
if not isinstance(other, self.__class__):
|
|
432
|
-
return False
|
|
433
|
-
return self.__dict__ == other.__dict__
|
|
434
|
-
|
|
435
|
-
def __ne__(self, other: 'PartnerUsageReportSummaryNext') -> bool:
|
|
436
|
-
"""Return `true` when self and other are not equal, false otherwise."""
|
|
437
|
-
return not self == other
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
class PartnerUsageReport:
|
|
441
|
-
"""
|
|
442
|
-
Aggregated usage report of a partner.
|
|
443
|
-
|
|
444
|
-
:param str entity_id: (optional) The ID of the entity.
|
|
445
|
-
:param str entity_type: (optional) The entity type.
|
|
446
|
-
:param str entity_crn: (optional) The Cloud Resource Name (CRN) of the entity
|
|
447
|
-
towards which the resource usages were rolled up.
|
|
448
|
-
:param str entity_name: (optional) A user-defined name for the entity, such as
|
|
449
|
-
the enterprise name or account group name.
|
|
450
|
-
:param str entity_partner_type: (optional) Role of the `entity_id` for which the
|
|
451
|
-
usage report is fetched.
|
|
452
|
-
:param str viewpoint: (optional) Enables partner to view the cost of provisioned
|
|
453
|
-
services as applicable at each level of the hierarchy.
|
|
454
|
-
:param str month: (optional) The billing month for which the usage report is
|
|
455
|
-
requested. Format is yyyy-mm.
|
|
456
|
-
:param str currency_code: (optional) The currency code of the billing unit.
|
|
457
|
-
:param str country_code: (optional) The country code of the billing unit.
|
|
458
|
-
:param float billable_cost: (optional) Billable charges that are aggregated from
|
|
459
|
-
all entities in the report.
|
|
460
|
-
:param float billable_rated_cost: (optional) Aggregated billable charges before
|
|
461
|
-
discounts.
|
|
462
|
-
:param float non_billable_cost: (optional) Non-billable charges that are
|
|
463
|
-
aggregated from all entities in the report.
|
|
464
|
-
:param float non_billable_rated_cost: (optional) Aggregated non-billable charges
|
|
465
|
-
before discounts.
|
|
466
|
-
:param List[ResourceUsage] resources: (optional)
|
|
467
|
-
"""
|
|
468
|
-
|
|
469
|
-
def __init__(
|
|
470
|
-
self,
|
|
471
|
-
*,
|
|
472
|
-
entity_id: Optional[str] = None,
|
|
473
|
-
entity_type: Optional[str] = None,
|
|
474
|
-
entity_crn: Optional[str] = None,
|
|
475
|
-
entity_name: Optional[str] = None,
|
|
476
|
-
entity_partner_type: Optional[str] = None,
|
|
477
|
-
viewpoint: Optional[str] = None,
|
|
478
|
-
month: Optional[str] = None,
|
|
479
|
-
currency_code: Optional[str] = None,
|
|
480
|
-
country_code: Optional[str] = None,
|
|
481
|
-
billable_cost: Optional[float] = None,
|
|
482
|
-
billable_rated_cost: Optional[float] = None,
|
|
483
|
-
non_billable_cost: Optional[float] = None,
|
|
484
|
-
non_billable_rated_cost: Optional[float] = None,
|
|
485
|
-
resources: Optional[List['ResourceUsage']] = None,
|
|
486
|
-
) -> None:
|
|
487
|
-
"""
|
|
488
|
-
Initialize a PartnerUsageReport object.
|
|
489
|
-
|
|
490
|
-
:param str entity_id: (optional) The ID of the entity.
|
|
491
|
-
:param str entity_type: (optional) The entity type.
|
|
492
|
-
:param str entity_crn: (optional) The Cloud Resource Name (CRN) of the
|
|
493
|
-
entity towards which the resource usages were rolled up.
|
|
494
|
-
:param str entity_name: (optional) A user-defined name for the entity, such
|
|
495
|
-
as the enterprise name or account group name.
|
|
496
|
-
:param str entity_partner_type: (optional) Role of the `entity_id` for
|
|
497
|
-
which the usage report is fetched.
|
|
498
|
-
:param str viewpoint: (optional) Enables partner to view the cost of
|
|
499
|
-
provisioned services as applicable at each level of the hierarchy.
|
|
500
|
-
:param str month: (optional) The billing month for which the usage report
|
|
501
|
-
is requested. Format is yyyy-mm.
|
|
502
|
-
:param str currency_code: (optional) The currency code of the billing unit.
|
|
503
|
-
:param str country_code: (optional) The country code of the billing unit.
|
|
504
|
-
:param float billable_cost: (optional) Billable charges that are aggregated
|
|
505
|
-
from all entities in the report.
|
|
506
|
-
:param float billable_rated_cost: (optional) Aggregated billable charges
|
|
507
|
-
before discounts.
|
|
508
|
-
:param float non_billable_cost: (optional) Non-billable charges that are
|
|
509
|
-
aggregated from all entities in the report.
|
|
510
|
-
:param float non_billable_rated_cost: (optional) Aggregated non-billable
|
|
511
|
-
charges before discounts.
|
|
512
|
-
:param List[ResourceUsage] resources: (optional)
|
|
513
|
-
"""
|
|
514
|
-
self.entity_id = entity_id
|
|
515
|
-
self.entity_type = entity_type
|
|
516
|
-
self.entity_crn = entity_crn
|
|
517
|
-
self.entity_name = entity_name
|
|
518
|
-
self.entity_partner_type = entity_partner_type
|
|
519
|
-
self.viewpoint = viewpoint
|
|
520
|
-
self.month = month
|
|
521
|
-
self.currency_code = currency_code
|
|
522
|
-
self.country_code = country_code
|
|
523
|
-
self.billable_cost = billable_cost
|
|
524
|
-
self.billable_rated_cost = billable_rated_cost
|
|
525
|
-
self.non_billable_cost = non_billable_cost
|
|
526
|
-
self.non_billable_rated_cost = non_billable_rated_cost
|
|
527
|
-
self.resources = resources
|
|
528
|
-
|
|
529
|
-
@classmethod
|
|
530
|
-
def from_dict(cls, _dict: Dict) -> 'PartnerUsageReport':
|
|
531
|
-
"""Initialize a PartnerUsageReport object from a json dictionary."""
|
|
532
|
-
args = {}
|
|
533
|
-
if (entity_id := _dict.get('entity_id')) is not None:
|
|
534
|
-
args['entity_id'] = entity_id
|
|
535
|
-
if (entity_type := _dict.get('entity_type')) is not None:
|
|
536
|
-
args['entity_type'] = entity_type
|
|
537
|
-
if (entity_crn := _dict.get('entity_crn')) is not None:
|
|
538
|
-
args['entity_crn'] = entity_crn
|
|
539
|
-
if (entity_name := _dict.get('entity_name')) is not None:
|
|
540
|
-
args['entity_name'] = entity_name
|
|
541
|
-
if (entity_partner_type := _dict.get('entity_partner_type')) is not None:
|
|
542
|
-
args['entity_partner_type'] = entity_partner_type
|
|
543
|
-
if (viewpoint := _dict.get('viewpoint')) is not None:
|
|
544
|
-
args['viewpoint'] = viewpoint
|
|
545
|
-
if (month := _dict.get('month')) is not None:
|
|
546
|
-
args['month'] = month
|
|
547
|
-
if (currency_code := _dict.get('currency_code')) is not None:
|
|
548
|
-
args['currency_code'] = currency_code
|
|
549
|
-
if (country_code := _dict.get('country_code')) is not None:
|
|
550
|
-
args['country_code'] = country_code
|
|
551
|
-
if (billable_cost := _dict.get('billable_cost')) is not None:
|
|
552
|
-
args['billable_cost'] = billable_cost
|
|
553
|
-
if (billable_rated_cost := _dict.get('billable_rated_cost')) is not None:
|
|
554
|
-
args['billable_rated_cost'] = billable_rated_cost
|
|
555
|
-
if (non_billable_cost := _dict.get('non_billable_cost')) is not None:
|
|
556
|
-
args['non_billable_cost'] = non_billable_cost
|
|
557
|
-
if (non_billable_rated_cost := _dict.get('non_billable_rated_cost')) is not None:
|
|
558
|
-
args['non_billable_rated_cost'] = non_billable_rated_cost
|
|
559
|
-
if (resources := _dict.get('resources')) is not None:
|
|
560
|
-
args['resources'] = [ResourceUsage.from_dict(v) for v in resources]
|
|
561
|
-
return cls(**args)
|
|
562
|
-
|
|
563
|
-
@classmethod
|
|
564
|
-
def _from_dict(cls, _dict):
|
|
565
|
-
"""Initialize a PartnerUsageReport object from a json dictionary."""
|
|
566
|
-
return cls.from_dict(_dict)
|
|
567
|
-
|
|
568
|
-
def to_dict(self) -> Dict:
|
|
569
|
-
"""Return a json dictionary representing this model."""
|
|
570
|
-
_dict = {}
|
|
571
|
-
if hasattr(self, 'entity_id') and self.entity_id is not None:
|
|
572
|
-
_dict['entity_id'] = self.entity_id
|
|
573
|
-
if hasattr(self, 'entity_type') and self.entity_type is not None:
|
|
574
|
-
_dict['entity_type'] = self.entity_type
|
|
575
|
-
if hasattr(self, 'entity_crn') and self.entity_crn is not None:
|
|
576
|
-
_dict['entity_crn'] = self.entity_crn
|
|
577
|
-
if hasattr(self, 'entity_name') and self.entity_name is not None:
|
|
578
|
-
_dict['entity_name'] = self.entity_name
|
|
579
|
-
if hasattr(self, 'entity_partner_type') and self.entity_partner_type is not None:
|
|
580
|
-
_dict['entity_partner_type'] = self.entity_partner_type
|
|
581
|
-
if hasattr(self, 'viewpoint') and self.viewpoint is not None:
|
|
582
|
-
_dict['viewpoint'] = self.viewpoint
|
|
583
|
-
if hasattr(self, 'month') and self.month is not None:
|
|
584
|
-
_dict['month'] = self.month
|
|
585
|
-
if hasattr(self, 'currency_code') and self.currency_code is not None:
|
|
586
|
-
_dict['currency_code'] = self.currency_code
|
|
587
|
-
if hasattr(self, 'country_code') and self.country_code is not None:
|
|
588
|
-
_dict['country_code'] = self.country_code
|
|
589
|
-
if hasattr(self, 'billable_cost') and self.billable_cost is not None:
|
|
590
|
-
_dict['billable_cost'] = self.billable_cost
|
|
591
|
-
if hasattr(self, 'billable_rated_cost') and self.billable_rated_cost is not None:
|
|
592
|
-
_dict['billable_rated_cost'] = self.billable_rated_cost
|
|
593
|
-
if hasattr(self, 'non_billable_cost') and self.non_billable_cost is not None:
|
|
594
|
-
_dict['non_billable_cost'] = self.non_billable_cost
|
|
595
|
-
if hasattr(self, 'non_billable_rated_cost') and self.non_billable_rated_cost is not None:
|
|
596
|
-
_dict['non_billable_rated_cost'] = self.non_billable_rated_cost
|
|
597
|
-
if hasattr(self, 'resources') and self.resources is not None:
|
|
598
|
-
resources_list = []
|
|
599
|
-
for v in self.resources:
|
|
600
|
-
if isinstance(v, dict):
|
|
601
|
-
resources_list.append(v)
|
|
602
|
-
else:
|
|
603
|
-
resources_list.append(v.to_dict())
|
|
604
|
-
_dict['resources'] = resources_list
|
|
605
|
-
return _dict
|
|
606
|
-
|
|
607
|
-
def _to_dict(self):
|
|
608
|
-
"""Return a json dictionary representing this model."""
|
|
609
|
-
return self.to_dict()
|
|
610
|
-
|
|
611
|
-
def __str__(self) -> str:
|
|
612
|
-
"""Return a `str` version of this PartnerUsageReport object."""
|
|
613
|
-
return json.dumps(self.to_dict(), indent=2)
|
|
614
|
-
|
|
615
|
-
def __eq__(self, other: 'PartnerUsageReport') -> bool:
|
|
616
|
-
"""Return `true` when self and other are equal, false otherwise."""
|
|
617
|
-
if not isinstance(other, self.__class__):
|
|
618
|
-
return False
|
|
619
|
-
return self.__dict__ == other.__dict__
|
|
620
|
-
|
|
621
|
-
def __ne__(self, other: 'PartnerUsageReport') -> bool:
|
|
622
|
-
"""Return `true` when self and other are not equal, false otherwise."""
|
|
623
|
-
return not self == other
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
class PartnerUsageReportSummary:
|
|
627
|
-
"""
|
|
628
|
-
The aggregated partner usage report.
|
|
629
|
-
|
|
630
|
-
:param int limit: (optional) The maximum number of usage records in the
|
|
631
|
-
response.
|
|
632
|
-
:param PartnerUsageReportSummaryFirst first: (optional) The link to the first
|
|
633
|
-
page of the search query.
|
|
634
|
-
:param PartnerUsageReportSummaryNext next: (optional) The link to the next page
|
|
635
|
-
of the search query.
|
|
636
|
-
:param List[PartnerUsageReport] reports: (optional) Aggregated usage report of
|
|
637
|
-
all requested partners.
|
|
638
|
-
"""
|
|
639
|
-
|
|
640
|
-
def __init__(
|
|
641
|
-
self,
|
|
642
|
-
*,
|
|
643
|
-
limit: Optional[int] = None,
|
|
644
|
-
first: Optional['PartnerUsageReportSummaryFirst'] = None,
|
|
645
|
-
next: Optional['PartnerUsageReportSummaryNext'] = None,
|
|
646
|
-
reports: Optional[List['PartnerUsageReport']] = None,
|
|
647
|
-
) -> None:
|
|
648
|
-
"""
|
|
649
|
-
Initialize a PartnerUsageReportSummary object.
|
|
650
|
-
|
|
651
|
-
:param int limit: (optional) The maximum number of usage records in the
|
|
652
|
-
response.
|
|
653
|
-
:param PartnerUsageReportSummaryFirst first: (optional) The link to the
|
|
654
|
-
first page of the search query.
|
|
655
|
-
:param PartnerUsageReportSummaryNext next: (optional) The link to the next
|
|
656
|
-
page of the search query.
|
|
657
|
-
:param List[PartnerUsageReport] reports: (optional) Aggregated usage report
|
|
658
|
-
of all requested partners.
|
|
659
|
-
"""
|
|
660
|
-
self.limit = limit
|
|
661
|
-
self.first = first
|
|
662
|
-
self.next = next
|
|
663
|
-
self.reports = reports
|
|
664
|
-
|
|
665
|
-
@classmethod
|
|
666
|
-
def from_dict(cls, _dict: Dict) -> 'PartnerUsageReportSummary':
|
|
667
|
-
"""Initialize a PartnerUsageReportSummary object from a json dictionary."""
|
|
668
|
-
args = {}
|
|
669
|
-
if (limit := _dict.get('limit')) is not None:
|
|
670
|
-
args['limit'] = limit
|
|
671
|
-
if (first := _dict.get('first')) is not None:
|
|
672
|
-
args['first'] = PartnerUsageReportSummaryFirst.from_dict(first)
|
|
673
|
-
if (next := _dict.get('next')) is not None:
|
|
674
|
-
args['next'] = PartnerUsageReportSummaryNext.from_dict(next)
|
|
675
|
-
if (reports := _dict.get('reports')) is not None:
|
|
676
|
-
args['reports'] = [PartnerUsageReport.from_dict(v) for v in reports]
|
|
677
|
-
return cls(**args)
|
|
678
|
-
|
|
679
|
-
@classmethod
|
|
680
|
-
def _from_dict(cls, _dict):
|
|
681
|
-
"""Initialize a PartnerUsageReportSummary object from a json dictionary."""
|
|
682
|
-
return cls.from_dict(_dict)
|
|
683
|
-
|
|
684
|
-
def to_dict(self) -> Dict:
|
|
685
|
-
"""Return a json dictionary representing this model."""
|
|
686
|
-
_dict = {}
|
|
687
|
-
if hasattr(self, 'limit') and self.limit is not None:
|
|
688
|
-
_dict['limit'] = self.limit
|
|
689
|
-
if hasattr(self, 'first') and self.first is not None:
|
|
690
|
-
if isinstance(self.first, dict):
|
|
691
|
-
_dict['first'] = self.first
|
|
692
|
-
else:
|
|
693
|
-
_dict['first'] = self.first.to_dict()
|
|
694
|
-
if hasattr(self, 'next') and self.next is not None:
|
|
695
|
-
if isinstance(self.next, dict):
|
|
696
|
-
_dict['next'] = self.next
|
|
697
|
-
else:
|
|
698
|
-
_dict['next'] = self.next.to_dict()
|
|
699
|
-
if hasattr(self, 'reports') and self.reports is not None:
|
|
700
|
-
reports_list = []
|
|
701
|
-
for v in self.reports:
|
|
702
|
-
if isinstance(v, dict):
|
|
703
|
-
reports_list.append(v)
|
|
704
|
-
else:
|
|
705
|
-
reports_list.append(v.to_dict())
|
|
706
|
-
_dict['reports'] = reports_list
|
|
707
|
-
return _dict
|
|
708
|
-
|
|
709
|
-
def _to_dict(self):
|
|
710
|
-
"""Return a json dictionary representing this model."""
|
|
711
|
-
return self.to_dict()
|
|
712
|
-
|
|
713
|
-
def __str__(self) -> str:
|
|
714
|
-
"""Return a `str` version of this PartnerUsageReportSummary object."""
|
|
715
|
-
return json.dumps(self.to_dict(), indent=2)
|
|
716
|
-
|
|
717
|
-
def __eq__(self, other: 'PartnerUsageReportSummary') -> bool:
|
|
718
|
-
"""Return `true` when self and other are equal, false otherwise."""
|
|
719
|
-
if not isinstance(other, self.__class__):
|
|
720
|
-
return False
|
|
721
|
-
return self.__dict__ == other.__dict__
|
|
722
|
-
|
|
723
|
-
def __ne__(self, other: 'PartnerUsageReportSummary') -> bool:
|
|
724
|
-
"""Return `true` when self and other are not equal, false otherwise."""
|
|
725
|
-
return not self == other
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
class PlanUsage:
|
|
729
|
-
"""
|
|
730
|
-
Aggregated values for the plan.
|
|
731
|
-
|
|
732
|
-
:param str plan_id: The ID of the plan.
|
|
733
|
-
:param str pricing_region: (optional) The pricing region for the plan.
|
|
734
|
-
:param str pricing_plan_id: (optional) The pricing plan with which the usage was
|
|
735
|
-
rated.
|
|
736
|
-
:param bool billable: Whether the plan charges are billed to the customer.
|
|
737
|
-
:param float cost: The total cost that was incurred by the plan.
|
|
738
|
-
:param float rated_cost: The total pre-discounted cost that was incurred by the
|
|
739
|
-
plan.
|
|
740
|
-
:param List[MetricUsage] usage: All of the metrics in the plan.
|
|
741
|
-
"""
|
|
742
|
-
|
|
743
|
-
def __init__(
|
|
744
|
-
self,
|
|
745
|
-
plan_id: str,
|
|
746
|
-
billable: bool,
|
|
747
|
-
cost: float,
|
|
748
|
-
rated_cost: float,
|
|
749
|
-
usage: List['MetricUsage'],
|
|
750
|
-
*,
|
|
751
|
-
pricing_region: Optional[str] = None,
|
|
752
|
-
pricing_plan_id: Optional[str] = None,
|
|
753
|
-
) -> None:
|
|
754
|
-
"""
|
|
755
|
-
Initialize a PlanUsage object.
|
|
756
|
-
|
|
757
|
-
:param str plan_id: The ID of the plan.
|
|
758
|
-
:param bool billable: Whether the plan charges are billed to the customer.
|
|
759
|
-
:param float cost: The total cost that was incurred by the plan.
|
|
760
|
-
:param float rated_cost: The total pre-discounted cost that was incurred by
|
|
761
|
-
the plan.
|
|
762
|
-
:param List[MetricUsage] usage: All of the metrics in the plan.
|
|
763
|
-
:param str pricing_region: (optional) The pricing region for the plan.
|
|
764
|
-
:param str pricing_plan_id: (optional) The pricing plan with which the
|
|
765
|
-
usage was rated.
|
|
766
|
-
"""
|
|
767
|
-
self.plan_id = plan_id
|
|
768
|
-
self.pricing_region = pricing_region
|
|
769
|
-
self.pricing_plan_id = pricing_plan_id
|
|
770
|
-
self.billable = billable
|
|
771
|
-
self.cost = cost
|
|
772
|
-
self.rated_cost = rated_cost
|
|
773
|
-
self.usage = usage
|
|
774
|
-
|
|
775
|
-
@classmethod
|
|
776
|
-
def from_dict(cls, _dict: Dict) -> 'PlanUsage':
|
|
777
|
-
"""Initialize a PlanUsage object from a json dictionary."""
|
|
778
|
-
args = {}
|
|
779
|
-
if (plan_id := _dict.get('plan_id')) is not None:
|
|
780
|
-
args['plan_id'] = plan_id
|
|
781
|
-
else:
|
|
782
|
-
raise ValueError('Required property \'plan_id\' not present in PlanUsage JSON')
|
|
783
|
-
if (pricing_region := _dict.get('pricing_region')) is not None:
|
|
784
|
-
args['pricing_region'] = pricing_region
|
|
785
|
-
if (pricing_plan_id := _dict.get('pricing_plan_id')) is not None:
|
|
786
|
-
args['pricing_plan_id'] = pricing_plan_id
|
|
787
|
-
if (billable := _dict.get('billable')) is not None:
|
|
788
|
-
args['billable'] = billable
|
|
789
|
-
else:
|
|
790
|
-
raise ValueError('Required property \'billable\' not present in PlanUsage JSON')
|
|
791
|
-
if (cost := _dict.get('cost')) is not None:
|
|
792
|
-
args['cost'] = cost
|
|
793
|
-
else:
|
|
794
|
-
raise ValueError('Required property \'cost\' not present in PlanUsage JSON')
|
|
795
|
-
if (rated_cost := _dict.get('rated_cost')) is not None:
|
|
796
|
-
args['rated_cost'] = rated_cost
|
|
797
|
-
else:
|
|
798
|
-
raise ValueError('Required property \'rated_cost\' not present in PlanUsage JSON')
|
|
799
|
-
if (usage := _dict.get('usage')) is not None:
|
|
800
|
-
args['usage'] = [MetricUsage.from_dict(v) for v in usage]
|
|
801
|
-
else:
|
|
802
|
-
raise ValueError('Required property \'usage\' not present in PlanUsage JSON')
|
|
803
|
-
return cls(**args)
|
|
804
|
-
|
|
805
|
-
@classmethod
|
|
806
|
-
def _from_dict(cls, _dict):
|
|
807
|
-
"""Initialize a PlanUsage object from a json dictionary."""
|
|
808
|
-
return cls.from_dict(_dict)
|
|
809
|
-
|
|
810
|
-
def to_dict(self) -> Dict:
|
|
811
|
-
"""Return a json dictionary representing this model."""
|
|
812
|
-
_dict = {}
|
|
813
|
-
if hasattr(self, 'plan_id') and self.plan_id is not None:
|
|
814
|
-
_dict['plan_id'] = self.plan_id
|
|
815
|
-
if hasattr(self, 'pricing_region') and self.pricing_region is not None:
|
|
816
|
-
_dict['pricing_region'] = self.pricing_region
|
|
817
|
-
if hasattr(self, 'pricing_plan_id') and self.pricing_plan_id is not None:
|
|
818
|
-
_dict['pricing_plan_id'] = self.pricing_plan_id
|
|
819
|
-
if hasattr(self, 'billable') and self.billable is not None:
|
|
820
|
-
_dict['billable'] = self.billable
|
|
821
|
-
if hasattr(self, 'cost') and self.cost is not None:
|
|
822
|
-
_dict['cost'] = self.cost
|
|
823
|
-
if hasattr(self, 'rated_cost') and self.rated_cost is not None:
|
|
824
|
-
_dict['rated_cost'] = self.rated_cost
|
|
825
|
-
if hasattr(self, 'usage') and self.usage is not None:
|
|
826
|
-
usage_list = []
|
|
827
|
-
for v in self.usage:
|
|
828
|
-
if isinstance(v, dict):
|
|
829
|
-
usage_list.append(v)
|
|
830
|
-
else:
|
|
831
|
-
usage_list.append(v.to_dict())
|
|
832
|
-
_dict['usage'] = usage_list
|
|
833
|
-
return _dict
|
|
834
|
-
|
|
835
|
-
def _to_dict(self):
|
|
836
|
-
"""Return a json dictionary representing this model."""
|
|
837
|
-
return self.to_dict()
|
|
838
|
-
|
|
839
|
-
def __str__(self) -> str:
|
|
840
|
-
"""Return a `str` version of this PlanUsage object."""
|
|
841
|
-
return json.dumps(self.to_dict(), indent=2)
|
|
842
|
-
|
|
843
|
-
def __eq__(self, other: 'PlanUsage') -> bool:
|
|
844
|
-
"""Return `true` when self and other are equal, false otherwise."""
|
|
845
|
-
if not isinstance(other, self.__class__):
|
|
846
|
-
return False
|
|
847
|
-
return self.__dict__ == other.__dict__
|
|
848
|
-
|
|
849
|
-
def __ne__(self, other: 'PlanUsage') -> bool:
|
|
850
|
-
"""Return `true` when self and other are not equal, false otherwise."""
|
|
851
|
-
return not self == other
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
class ResourceUsage:
|
|
855
|
-
"""
|
|
856
|
-
A container for all the plans in the resource.
|
|
857
|
-
|
|
858
|
-
:param str resource_id: The ID of the resource.
|
|
859
|
-
:param str resource_name: (optional) The name of the resource.
|
|
860
|
-
:param float billable_cost: The billable charges for the partner.
|
|
861
|
-
:param float billable_rated_cost: The pre-discounted billable charges for the
|
|
862
|
-
partner.
|
|
863
|
-
:param float non_billable_cost: The non-billable charges for the partner.
|
|
864
|
-
:param float non_billable_rated_cost: The pre-discounted, non-billable charges
|
|
865
|
-
for the partner.
|
|
866
|
-
:param List[PlanUsage] plans: All of the plans in the resource.
|
|
867
|
-
"""
|
|
868
|
-
|
|
869
|
-
def __init__(
|
|
870
|
-
self,
|
|
871
|
-
resource_id: str,
|
|
872
|
-
billable_cost: float,
|
|
873
|
-
billable_rated_cost: float,
|
|
874
|
-
non_billable_cost: float,
|
|
875
|
-
non_billable_rated_cost: float,
|
|
876
|
-
plans: List['PlanUsage'],
|
|
877
|
-
*,
|
|
878
|
-
resource_name: Optional[str] = None,
|
|
879
|
-
) -> None:
|
|
880
|
-
"""
|
|
881
|
-
Initialize a ResourceUsage object.
|
|
882
|
-
|
|
883
|
-
:param str resource_id: The ID of the resource.
|
|
884
|
-
:param float billable_cost: The billable charges for the partner.
|
|
885
|
-
:param float billable_rated_cost: The pre-discounted billable charges for
|
|
886
|
-
the partner.
|
|
887
|
-
:param float non_billable_cost: The non-billable charges for the partner.
|
|
888
|
-
:param float non_billable_rated_cost: The pre-discounted, non-billable
|
|
889
|
-
charges for the partner.
|
|
890
|
-
:param List[PlanUsage] plans: All of the plans in the resource.
|
|
891
|
-
:param str resource_name: (optional) The name of the resource.
|
|
892
|
-
"""
|
|
893
|
-
self.resource_id = resource_id
|
|
894
|
-
self.resource_name = resource_name
|
|
895
|
-
self.billable_cost = billable_cost
|
|
896
|
-
self.billable_rated_cost = billable_rated_cost
|
|
897
|
-
self.non_billable_cost = non_billable_cost
|
|
898
|
-
self.non_billable_rated_cost = non_billable_rated_cost
|
|
899
|
-
self.plans = plans
|
|
900
|
-
|
|
901
|
-
@classmethod
|
|
902
|
-
def from_dict(cls, _dict: Dict) -> 'ResourceUsage':
|
|
903
|
-
"""Initialize a ResourceUsage object from a json dictionary."""
|
|
904
|
-
args = {}
|
|
905
|
-
if (resource_id := _dict.get('resource_id')) is not None:
|
|
906
|
-
args['resource_id'] = resource_id
|
|
907
|
-
else:
|
|
908
|
-
raise ValueError('Required property \'resource_id\' not present in ResourceUsage JSON')
|
|
909
|
-
if (resource_name := _dict.get('resource_name')) is not None:
|
|
910
|
-
args['resource_name'] = resource_name
|
|
911
|
-
if (billable_cost := _dict.get('billable_cost')) is not None:
|
|
912
|
-
args['billable_cost'] = billable_cost
|
|
913
|
-
else:
|
|
914
|
-
raise ValueError('Required property \'billable_cost\' not present in ResourceUsage JSON')
|
|
915
|
-
if (billable_rated_cost := _dict.get('billable_rated_cost')) is not None:
|
|
916
|
-
args['billable_rated_cost'] = billable_rated_cost
|
|
917
|
-
else:
|
|
918
|
-
raise ValueError('Required property \'billable_rated_cost\' not present in ResourceUsage JSON')
|
|
919
|
-
if (non_billable_cost := _dict.get('non_billable_cost')) is not None:
|
|
920
|
-
args['non_billable_cost'] = non_billable_cost
|
|
921
|
-
else:
|
|
922
|
-
raise ValueError('Required property \'non_billable_cost\' not present in ResourceUsage JSON')
|
|
923
|
-
if (non_billable_rated_cost := _dict.get('non_billable_rated_cost')) is not None:
|
|
924
|
-
args['non_billable_rated_cost'] = non_billable_rated_cost
|
|
925
|
-
else:
|
|
926
|
-
raise ValueError('Required property \'non_billable_rated_cost\' not present in ResourceUsage JSON')
|
|
927
|
-
if (plans := _dict.get('plans')) is not None:
|
|
928
|
-
args['plans'] = [PlanUsage.from_dict(v) for v in plans]
|
|
929
|
-
else:
|
|
930
|
-
raise ValueError('Required property \'plans\' not present in ResourceUsage JSON')
|
|
931
|
-
return cls(**args)
|
|
932
|
-
|
|
933
|
-
@classmethod
|
|
934
|
-
def _from_dict(cls, _dict):
|
|
935
|
-
"""Initialize a ResourceUsage object from a json dictionary."""
|
|
936
|
-
return cls.from_dict(_dict)
|
|
937
|
-
|
|
938
|
-
def to_dict(self) -> Dict:
|
|
939
|
-
"""Return a json dictionary representing this model."""
|
|
940
|
-
_dict = {}
|
|
941
|
-
if hasattr(self, 'resource_id') and self.resource_id is not None:
|
|
942
|
-
_dict['resource_id'] = self.resource_id
|
|
943
|
-
if hasattr(self, 'resource_name') and self.resource_name is not None:
|
|
944
|
-
_dict['resource_name'] = self.resource_name
|
|
945
|
-
if hasattr(self, 'billable_cost') and self.billable_cost is not None:
|
|
946
|
-
_dict['billable_cost'] = self.billable_cost
|
|
947
|
-
if hasattr(self, 'billable_rated_cost') and self.billable_rated_cost is not None:
|
|
948
|
-
_dict['billable_rated_cost'] = self.billable_rated_cost
|
|
949
|
-
if hasattr(self, 'non_billable_cost') and self.non_billable_cost is not None:
|
|
950
|
-
_dict['non_billable_cost'] = self.non_billable_cost
|
|
951
|
-
if hasattr(self, 'non_billable_rated_cost') and self.non_billable_rated_cost is not None:
|
|
952
|
-
_dict['non_billable_rated_cost'] = self.non_billable_rated_cost
|
|
953
|
-
if hasattr(self, 'plans') and self.plans is not None:
|
|
954
|
-
plans_list = []
|
|
955
|
-
for v in self.plans:
|
|
956
|
-
if isinstance(v, dict):
|
|
957
|
-
plans_list.append(v)
|
|
958
|
-
else:
|
|
959
|
-
plans_list.append(v.to_dict())
|
|
960
|
-
_dict['plans'] = plans_list
|
|
961
|
-
return _dict
|
|
962
|
-
|
|
963
|
-
def _to_dict(self):
|
|
964
|
-
"""Return a json dictionary representing this model."""
|
|
965
|
-
return self.to_dict()
|
|
966
|
-
|
|
967
|
-
def __str__(self) -> str:
|
|
968
|
-
"""Return a `str` version of this ResourceUsage object."""
|
|
969
|
-
return json.dumps(self.to_dict(), indent=2)
|
|
970
|
-
|
|
971
|
-
def __eq__(self, other: 'ResourceUsage') -> bool:
|
|
972
|
-
"""Return `true` when self and other are equal, false otherwise."""
|
|
973
|
-
if not isinstance(other, self.__class__):
|
|
974
|
-
return False
|
|
975
|
-
return self.__dict__ == other.__dict__
|
|
976
|
-
|
|
977
|
-
def __ne__(self, other: 'ResourceUsage') -> bool:
|
|
978
|
-
"""Return `true` when self and other are not equal, false otherwise."""
|
|
979
|
-
return not self == other
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
##############################################################################
|
|
983
|
-
# Pagers
|
|
984
|
-
##############################################################################
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
class GetResourceUsageReportPager:
|
|
988
|
-
"""
|
|
989
|
-
GetResourceUsageReportPager can be used to simplify the use of the "get_resource_usage_report" method.
|
|
990
|
-
"""
|
|
991
|
-
|
|
992
|
-
def __init__(
|
|
993
|
-
self,
|
|
994
|
-
*,
|
|
995
|
-
client: PartnerUsageReportsV1,
|
|
996
|
-
partner_id: str,
|
|
997
|
-
reseller_id: str = None,
|
|
998
|
-
customer_id: str = None,
|
|
999
|
-
children: bool = None,
|
|
1000
|
-
month: str = None,
|
|
1001
|
-
viewpoint: str = None,
|
|
1002
|
-
recurse: bool = None,
|
|
1003
|
-
limit: int = None,
|
|
1004
|
-
) -> None:
|
|
1005
|
-
"""
|
|
1006
|
-
Initialize a GetResourceUsageReportPager object.
|
|
1007
|
-
:param str partner_id: Enterprise ID of the distributor or reseller for
|
|
1008
|
-
which the report is requested.
|
|
1009
|
-
:param str reseller_id: (optional) Enterprise ID of the reseller for which
|
|
1010
|
-
the report is requested. This parameter cannot be used along with
|
|
1011
|
-
`customer_id` query parameter.
|
|
1012
|
-
:param str customer_id: (optional) Enterprise ID of the child customer for
|
|
1013
|
-
which the report is requested. This parameter cannot be used along with
|
|
1014
|
-
`reseller_id` query parameter.
|
|
1015
|
-
:param bool children: (optional) Get report rolled-up to the direct
|
|
1016
|
-
children of the requested entity. Defaults to false. This parameter cannot
|
|
1017
|
-
be used along with `customer_id` query parameter.
|
|
1018
|
-
:param str month: (optional) The billing month for which the usage report
|
|
1019
|
-
is requested. Format is `yyyy-mm`. Defaults to current month.
|
|
1020
|
-
:param str viewpoint: (optional) Enables partner to view the cost of
|
|
1021
|
-
provisioned services as applicable at each level of the hierarchy. Defaults
|
|
1022
|
-
to the type of the calling partner. The valid values are `DISTRIBUTOR`,
|
|
1023
|
-
`RESELLER` and `END_CUSTOMER`.
|
|
1024
|
-
:param bool recurse: (optional) Get usage report rolled-up to the end
|
|
1025
|
-
customers of the requested entity. Defaults to false. This parameter cannot
|
|
1026
|
-
be used along with `reseller_id` query parameter or `customer_id` query
|
|
1027
|
-
parameter.
|
|
1028
|
-
:param int limit: (optional) Number of usage records to be returned. The
|
|
1029
|
-
default value is 30. Maximum value is 200.
|
|
1030
|
-
"""
|
|
1031
|
-
self._has_next = True
|
|
1032
|
-
self._client = client
|
|
1033
|
-
self._page_context = {'next': None}
|
|
1034
|
-
self._partner_id = partner_id
|
|
1035
|
-
self._reseller_id = reseller_id
|
|
1036
|
-
self._customer_id = customer_id
|
|
1037
|
-
self._children = children
|
|
1038
|
-
self._month = month
|
|
1039
|
-
self._viewpoint = viewpoint
|
|
1040
|
-
self._recurse = recurse
|
|
1041
|
-
self._limit = limit
|
|
1042
|
-
|
|
1043
|
-
def has_next(self) -> bool:
|
|
1044
|
-
"""
|
|
1045
|
-
Returns true if there are potentially more results to be retrieved.
|
|
1046
|
-
"""
|
|
1047
|
-
return self._has_next
|
|
1048
|
-
|
|
1049
|
-
def get_next(self) -> List[dict]:
|
|
1050
|
-
"""
|
|
1051
|
-
Returns the next page of results.
|
|
1052
|
-
:return: A List[dict], where each element is a dict that represents an instance of PartnerUsageReport.
|
|
1053
|
-
:rtype: List[dict]
|
|
1054
|
-
"""
|
|
1055
|
-
if not self.has_next():
|
|
1056
|
-
raise StopIteration(message='No more results available')
|
|
1057
|
-
|
|
1058
|
-
result = self._client.get_resource_usage_report(
|
|
1059
|
-
partner_id=self._partner_id,
|
|
1060
|
-
reseller_id=self._reseller_id,
|
|
1061
|
-
customer_id=self._customer_id,
|
|
1062
|
-
children=self._children,
|
|
1063
|
-
month=self._month,
|
|
1064
|
-
viewpoint=self._viewpoint,
|
|
1065
|
-
recurse=self._recurse,
|
|
1066
|
-
limit=self._limit,
|
|
1067
|
-
offset=self._page_context.get('next'),
|
|
1068
|
-
).get_result()
|
|
1069
|
-
|
|
1070
|
-
next = None
|
|
1071
|
-
next_page_link = result.get('next')
|
|
1072
|
-
if next_page_link is not None:
|
|
1073
|
-
next = next_page_link.get('offset')
|
|
1074
|
-
self._page_context['next'] = next
|
|
1075
|
-
if next is None:
|
|
1076
|
-
self._has_next = False
|
|
1077
|
-
|
|
1078
|
-
return result.get('reports')
|
|
1079
|
-
|
|
1080
|
-
def get_all(self) -> List[dict]:
|
|
1081
|
-
"""
|
|
1082
|
-
Returns all results by invoking get_next() repeatedly
|
|
1083
|
-
until all pages of results have been retrieved.
|
|
1084
|
-
:return: A List[dict], where each element is a dict that represents an instance of PartnerUsageReport.
|
|
1085
|
-
:rtype: List[dict]
|
|
1086
|
-
"""
|
|
1087
|
-
results = []
|
|
1088
|
-
while self.has_next():
|
|
1089
|
-
next_page = self.get_next()
|
|
1090
|
-
results.extend(next_page)
|
|
1091
|
-
return results
|