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.
- ibm_platform_services/__init__.py +43 -0
- ibm_platform_services/case_management_v1.py +2414 -0
- ibm_platform_services/catalog_management_v1.py +10127 -0
- ibm_platform_services/common.py +56 -0
- ibm_platform_services/context_based_restrictions_v1.py +3633 -0
- ibm_platform_services/enterprise_billing_units_v1.py +1324 -0
- ibm_platform_services/enterprise_management_v1.py +2497 -0
- ibm_platform_services/enterprise_usage_reports_v1.py +978 -0
- ibm_platform_services/global_catalog_v1.py +5129 -0
- ibm_platform_services/global_search_v2.py +497 -0
- ibm_platform_services/global_tagging_v1.py +1601 -0
- ibm_platform_services/iam_access_groups_v2.py +7684 -0
- ibm_platform_services/iam_identity_v1.py +11525 -0
- ibm_platform_services/iam_policy_management_v1.py +9016 -0
- ibm_platform_services/ibm_cloud_shell_v1.py +480 -0
- ibm_platform_services/open_service_broker_v1.py +1774 -0
- ibm_platform_services/partner_billing_units_v1.py +1381 -0
- ibm_platform_services/partner_usage_reports_v1.py +1091 -0
- ibm_platform_services/resource_controller_v2.py +4868 -0
- ibm_platform_services/resource_manager_v2.py +986 -0
- ibm_platform_services/usage_metering_v4.py +470 -0
- ibm_platform_services/usage_reports_v4.py +5165 -0
- ibm_platform_services/user_management_v1.py +1639 -0
- ibm_platform_services/version.py +5 -0
- ibm_platform_services-0.55.3.dist-info/LICENSE +201 -0
- ibm_platform_services-0.55.3.dist-info/METADATA +165 -0
- ibm_platform_services-0.55.3.dist-info/RECORD +29 -0
- ibm_platform_services-0.55.3.dist-info/WHEEL +5 -0
- ibm_platform_services-0.55.3.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,497 @@
|
|
|
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.87.0-91c7c775-20240320-213027
|
|
18
|
+
|
|
19
|
+
"""
|
|
20
|
+
Search for resources with the global and shared resource properties repository that is
|
|
21
|
+
integrated in the IBM Cloud platform. The search repository stores and searches cloud
|
|
22
|
+
resources attributes, which categorize or classify resources. A resource is a physical or
|
|
23
|
+
logical component that can be created or reserved for an application or service instance.
|
|
24
|
+
They are owned by resource providers, such as IBM Kubernetes Service, or resource
|
|
25
|
+
controller in IBM Cloud. Resources are uniquely identified by a Cloud Resource Name (CRN)
|
|
26
|
+
or by an IMS ID. The properties of a resource include tags and system properties. Both
|
|
27
|
+
properties are defined in an IBM Cloud billing account, and span across many regions.
|
|
28
|
+
|
|
29
|
+
API Version: 2.0.1
|
|
30
|
+
"""
|
|
31
|
+
|
|
32
|
+
from enum import Enum
|
|
33
|
+
from typing import Dict, List, Optional
|
|
34
|
+
import json
|
|
35
|
+
|
|
36
|
+
from ibm_cloud_sdk_core import BaseService, DetailedResponse
|
|
37
|
+
from ibm_cloud_sdk_core.authenticators.authenticator import Authenticator
|
|
38
|
+
from ibm_cloud_sdk_core.get_authenticator import get_authenticator_from_environment
|
|
39
|
+
from ibm_cloud_sdk_core.utils import convert_list
|
|
40
|
+
|
|
41
|
+
from .common import get_sdk_headers
|
|
42
|
+
|
|
43
|
+
##############################################################################
|
|
44
|
+
# Service
|
|
45
|
+
##############################################################################
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
class GlobalSearchV2(BaseService):
|
|
49
|
+
"""The global_search V2 service."""
|
|
50
|
+
|
|
51
|
+
DEFAULT_SERVICE_URL = 'https://api.global-search-tagging.cloud.ibm.com'
|
|
52
|
+
DEFAULT_SERVICE_NAME = 'global_search'
|
|
53
|
+
|
|
54
|
+
@classmethod
|
|
55
|
+
def new_instance(
|
|
56
|
+
cls,
|
|
57
|
+
service_name: str = DEFAULT_SERVICE_NAME,
|
|
58
|
+
) -> 'GlobalSearchV2':
|
|
59
|
+
"""
|
|
60
|
+
Return a new client for the global_search service using the specified
|
|
61
|
+
parameters and external configuration.
|
|
62
|
+
"""
|
|
63
|
+
authenticator = get_authenticator_from_environment(service_name)
|
|
64
|
+
service = cls(authenticator)
|
|
65
|
+
service.configure_service(service_name)
|
|
66
|
+
return service
|
|
67
|
+
|
|
68
|
+
def __init__(
|
|
69
|
+
self,
|
|
70
|
+
authenticator: Authenticator = None,
|
|
71
|
+
) -> None:
|
|
72
|
+
"""
|
|
73
|
+
Construct a new client for the global_search service.
|
|
74
|
+
|
|
75
|
+
:param Authenticator authenticator: The authenticator specifies the authentication mechanism.
|
|
76
|
+
Get up to date information from https://github.com/IBM/python-sdk-core/blob/main/README.md
|
|
77
|
+
about initializing the authenticator of your choice.
|
|
78
|
+
"""
|
|
79
|
+
BaseService.__init__(self, service_url=self.DEFAULT_SERVICE_URL, authenticator=authenticator)
|
|
80
|
+
|
|
81
|
+
#########################
|
|
82
|
+
# Search
|
|
83
|
+
#########################
|
|
84
|
+
|
|
85
|
+
def search(
|
|
86
|
+
self,
|
|
87
|
+
*,
|
|
88
|
+
query: Optional[str] = None,
|
|
89
|
+
fields: Optional[List[str]] = None,
|
|
90
|
+
search_cursor: Optional[str] = None,
|
|
91
|
+
x_request_id: Optional[str] = None,
|
|
92
|
+
x_correlation_id: Optional[str] = None,
|
|
93
|
+
account_id: Optional[str] = None,
|
|
94
|
+
limit: Optional[int] = None,
|
|
95
|
+
timeout: Optional[int] = None,
|
|
96
|
+
sort: Optional[List[str]] = None,
|
|
97
|
+
is_deleted: Optional[str] = None,
|
|
98
|
+
is_reclaimed: Optional[str] = None,
|
|
99
|
+
is_public: Optional[str] = None,
|
|
100
|
+
impersonate_user: Optional[str] = None,
|
|
101
|
+
can_tag: Optional[str] = None,
|
|
102
|
+
is_project_resource: Optional[str] = None,
|
|
103
|
+
**kwargs,
|
|
104
|
+
) -> DetailedResponse:
|
|
105
|
+
"""
|
|
106
|
+
Find instances of resources (v3).
|
|
107
|
+
|
|
108
|
+
Find IAM-enabled resources or storage and network resources that run on classic
|
|
109
|
+
infrastructure in a specific account ID. You can apply query strings if necessary.
|
|
110
|
+
To filter results, you can insert a string by using the Lucene syntax and the
|
|
111
|
+
query string is parsed into a series of terms and operators. A term can be a
|
|
112
|
+
single word or a phrase, in which case the search is performed for all the words,
|
|
113
|
+
in the same order. To filter for a specific value regardless of the property that
|
|
114
|
+
contains it, type the search term without specifying a field. Only resources that
|
|
115
|
+
belong to the account ID and that are accessible by the client are returned.
|
|
116
|
+
You must use `/v3/resources/search` when you need to fetch more than `10000`
|
|
117
|
+
resource items. On the first call, the operation returns a live cursor on the data
|
|
118
|
+
that you must use on all the subsequent calls to get the next batch of results
|
|
119
|
+
until you get the empty result set.
|
|
120
|
+
By default, the fields that are returned for every resource are `crn`, `name`,
|
|
121
|
+
`family`, `type`, and `account_id`. You can specify the subset of the fields you
|
|
122
|
+
want in your request using the `fields` request body attribute. Set `"fields":
|
|
123
|
+
["*"]` to discover the set of fields which are available to request.
|
|
124
|
+
|
|
125
|
+
:param str query: (optional) The Lucene-formatted query string. Default to
|
|
126
|
+
'*' if not set.
|
|
127
|
+
:param List[str] fields: (optional) The list of the fields returned by the
|
|
128
|
+
search. By default, the returned fields are the `account_id`, `name`,
|
|
129
|
+
`type`, `family`, and `crn`. For all queries, `crn` is always returned. You
|
|
130
|
+
may set `"fields": ["*"]` to discover the set of fields available to
|
|
131
|
+
request.
|
|
132
|
+
:param str search_cursor: (optional) An opaque cursor that is returned on
|
|
133
|
+
each call and that must be set on the subsequent call to get the next batch
|
|
134
|
+
of items. If the search returns no items, then the search_cursor is not
|
|
135
|
+
present in the response.
|
|
136
|
+
:param str x_request_id: (optional) An alphanumeric string that is used to
|
|
137
|
+
trace the request. The value may include ASCII alphanumerics and any of
|
|
138
|
+
following segment separators: space ( ), comma (,), hyphen, (-), and
|
|
139
|
+
underscore (_) and may have a length up to 1024 bytes. The value is
|
|
140
|
+
considered invalid and must be ignored if that value includes any other
|
|
141
|
+
character or is longer than 1024 bytes or is fewer than 8 characters. If
|
|
142
|
+
not specified or invalid, it is automatically replaced by a random (version
|
|
143
|
+
4) UUID.
|
|
144
|
+
:param str x_correlation_id: (optional) An alphanumeric string that is used
|
|
145
|
+
to trace the request as a part of a larger context: the same value is used
|
|
146
|
+
for downstream requests and retries of those requests. The value may
|
|
147
|
+
include ASCII alphanumerics and any of following segment separators: space
|
|
148
|
+
( ), comma (,), hyphen, (-), and underscore (_) and may have a length up to
|
|
149
|
+
1024 bytes. The value is considered invalid and must be ignored if that
|
|
150
|
+
value includes any other character or is longer than 1024 bytes or is fewer
|
|
151
|
+
than 8 characters. If not specified or invalid, it is automatically
|
|
152
|
+
replaced by a random (version 4) UUID.
|
|
153
|
+
:param str account_id: (optional) The account ID to filter resources.
|
|
154
|
+
:param int limit: (optional) The maximum number of hits to return. Defaults
|
|
155
|
+
to 10.
|
|
156
|
+
:param int timeout: (optional) A search timeout in milliseconds, bounding
|
|
157
|
+
the search request to run within the specified time value and bail with the
|
|
158
|
+
hits accumulated up to that point when expired. Defaults to the system
|
|
159
|
+
defined timeout.
|
|
160
|
+
:param List[str] sort: (optional) Comma separated properties names that are
|
|
161
|
+
used for sorting.
|
|
162
|
+
:param str is_deleted: (optional) Determines if deleted documents should be
|
|
163
|
+
included in result set or not. Possible values are false (default), true or
|
|
164
|
+
any. If false, only existing documents are returned; if true, only deleted
|
|
165
|
+
documents are returned; If any, both existing and deleted documents are
|
|
166
|
+
returned. (_for administrators only_).
|
|
167
|
+
:param str is_reclaimed: (optional) Determines if reclaimed documents
|
|
168
|
+
should be included in result set or not. Possible values are false
|
|
169
|
+
(default), true or any. If false, only not reclaimed documents are
|
|
170
|
+
returned; if true, only reclaimed documents are returned; If any, both
|
|
171
|
+
reclaimed and not reclaimed documents are returned.
|
|
172
|
+
:param str is_public: (optional) Determines if public resources should be
|
|
173
|
+
included in result set or not. Possible values are false (default), true or
|
|
174
|
+
any. If false, do not search public resources; if true, search only public
|
|
175
|
+
resources; If any, search also public resources.
|
|
176
|
+
:param str impersonate_user: (optional) The user on whose behalf the search
|
|
177
|
+
must be performed. Only a GhoST admin can impersonate a user, so be sure
|
|
178
|
+
you set a GhoST admin IAM token in the Authorization header if you set this
|
|
179
|
+
parameter. (_for administrators only_).
|
|
180
|
+
:param str can_tag: (optional) Determines if the result set must return the
|
|
181
|
+
resources that the user can tag or the resources that the user can view
|
|
182
|
+
(only a GhoST admin can use this parameter). If false (default), only
|
|
183
|
+
resources user can view are returned; if true, only resources that user has
|
|
184
|
+
permissions for tagging are returned (_for administrators only_).
|
|
185
|
+
:param str is_project_resource: (optional) Determines if documents
|
|
186
|
+
belonging to Project family should be included in result set or not.
|
|
187
|
+
Possible values are false (default), true or any. If false, documents
|
|
188
|
+
belonging to all families except Project are returned; if true, only
|
|
189
|
+
documents belonging to Project family are returned; if any, documents of
|
|
190
|
+
any family are returned. Only authorized ServiceIds can use this query
|
|
191
|
+
parameter.
|
|
192
|
+
:param dict headers: A `dict` containing the request headers
|
|
193
|
+
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
|
|
194
|
+
:rtype: DetailedResponse with `dict` result representing a `ScanResult` object
|
|
195
|
+
"""
|
|
196
|
+
|
|
197
|
+
headers = {
|
|
198
|
+
'x-request-id': x_request_id,
|
|
199
|
+
'x-correlation-id': x_correlation_id,
|
|
200
|
+
}
|
|
201
|
+
sdk_headers = get_sdk_headers(
|
|
202
|
+
service_name=self.DEFAULT_SERVICE_NAME,
|
|
203
|
+
service_version='V2',
|
|
204
|
+
operation_id='search',
|
|
205
|
+
)
|
|
206
|
+
headers.update(sdk_headers)
|
|
207
|
+
|
|
208
|
+
params = {
|
|
209
|
+
'account_id': account_id,
|
|
210
|
+
'limit': limit,
|
|
211
|
+
'timeout': timeout,
|
|
212
|
+
'sort': convert_list(sort),
|
|
213
|
+
'is_deleted': is_deleted,
|
|
214
|
+
'is_reclaimed': is_reclaimed,
|
|
215
|
+
'is_public': is_public,
|
|
216
|
+
'impersonate_user': impersonate_user,
|
|
217
|
+
'can_tag': can_tag,
|
|
218
|
+
'is_project_resource': is_project_resource,
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
data = {
|
|
222
|
+
'query': query,
|
|
223
|
+
'fields': fields,
|
|
224
|
+
'search_cursor': search_cursor,
|
|
225
|
+
}
|
|
226
|
+
data = {k: v for (k, v) in data.items() if v is not None}
|
|
227
|
+
data = json.dumps(data)
|
|
228
|
+
headers['content-type'] = 'application/json'
|
|
229
|
+
|
|
230
|
+
if 'headers' in kwargs:
|
|
231
|
+
headers.update(kwargs.get('headers'))
|
|
232
|
+
del kwargs['headers']
|
|
233
|
+
headers['Accept'] = 'application/json'
|
|
234
|
+
|
|
235
|
+
url = '/v3/resources/search'
|
|
236
|
+
request = self.prepare_request(
|
|
237
|
+
method='POST',
|
|
238
|
+
url=url,
|
|
239
|
+
headers=headers,
|
|
240
|
+
params=params,
|
|
241
|
+
data=data,
|
|
242
|
+
)
|
|
243
|
+
|
|
244
|
+
response = self.send(request, **kwargs)
|
|
245
|
+
return response
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
class SearchEnums:
|
|
249
|
+
"""
|
|
250
|
+
Enums for search parameters.
|
|
251
|
+
"""
|
|
252
|
+
|
|
253
|
+
class IsDeleted(str, Enum):
|
|
254
|
+
"""
|
|
255
|
+
Determines if deleted documents should be included in result set or not. Possible
|
|
256
|
+
values are false (default), true or any. If false, only existing documents are
|
|
257
|
+
returned; if true, only deleted documents are returned; If any, both existing and
|
|
258
|
+
deleted documents are returned. (_for administrators only_).
|
|
259
|
+
"""
|
|
260
|
+
|
|
261
|
+
TRUE = 'true'
|
|
262
|
+
FALSE = 'false'
|
|
263
|
+
ANY = 'any'
|
|
264
|
+
|
|
265
|
+
class IsReclaimed(str, Enum):
|
|
266
|
+
"""
|
|
267
|
+
Determines if reclaimed documents should be included in result set or not.
|
|
268
|
+
Possible values are false (default), true or any. If false, only not reclaimed
|
|
269
|
+
documents are returned; if true, only reclaimed documents are returned; If any,
|
|
270
|
+
both reclaimed and not reclaimed documents are returned.
|
|
271
|
+
"""
|
|
272
|
+
|
|
273
|
+
TRUE = 'true'
|
|
274
|
+
FALSE = 'false'
|
|
275
|
+
ANY = 'any'
|
|
276
|
+
|
|
277
|
+
class IsPublic(str, Enum):
|
|
278
|
+
"""
|
|
279
|
+
Determines if public resources should be included in result set or not. Possible
|
|
280
|
+
values are false (default), true or any. If false, do not search public resources;
|
|
281
|
+
if true, search only public resources; If any, search also public resources.
|
|
282
|
+
"""
|
|
283
|
+
|
|
284
|
+
TRUE = 'true'
|
|
285
|
+
FALSE = 'false'
|
|
286
|
+
ANY = 'any'
|
|
287
|
+
|
|
288
|
+
class CanTag(str, Enum):
|
|
289
|
+
"""
|
|
290
|
+
Determines if the result set must return the resources that the user can tag or
|
|
291
|
+
the resources that the user can view (only a GhoST admin can use this parameter).
|
|
292
|
+
If false (default), only resources user can view are returned; if true, only
|
|
293
|
+
resources that user has permissions for tagging are returned (_for administrators
|
|
294
|
+
only_).
|
|
295
|
+
"""
|
|
296
|
+
|
|
297
|
+
TRUE = 'true'
|
|
298
|
+
FALSE = 'false'
|
|
299
|
+
|
|
300
|
+
class IsProjectResource(str, Enum):
|
|
301
|
+
"""
|
|
302
|
+
Determines if documents belonging to Project family should be included in result
|
|
303
|
+
set or not. Possible values are false (default), true or any. If false, documents
|
|
304
|
+
belonging to all families except Project are returned; if true, only documents
|
|
305
|
+
belonging to Project family are returned; if any, documents of any family are
|
|
306
|
+
returned. Only authorized ServiceIds can use this query parameter.
|
|
307
|
+
"""
|
|
308
|
+
|
|
309
|
+
TRUE = 'true'
|
|
310
|
+
FALSE = 'false'
|
|
311
|
+
ANY = 'any'
|
|
312
|
+
|
|
313
|
+
|
|
314
|
+
##############################################################################
|
|
315
|
+
# Models
|
|
316
|
+
##############################################################################
|
|
317
|
+
|
|
318
|
+
|
|
319
|
+
class ResultItem:
|
|
320
|
+
"""
|
|
321
|
+
A resource returned in a search result, which is identified by its `crn`. It contains
|
|
322
|
+
other properties that depend on the resource type.
|
|
323
|
+
|
|
324
|
+
:param str crn: Resource identifier in CRN format.
|
|
325
|
+
"""
|
|
326
|
+
|
|
327
|
+
# The set of defined properties for the class
|
|
328
|
+
_properties = frozenset(['crn'])
|
|
329
|
+
|
|
330
|
+
def __init__(
|
|
331
|
+
self,
|
|
332
|
+
crn: str,
|
|
333
|
+
**kwargs,
|
|
334
|
+
) -> None:
|
|
335
|
+
"""
|
|
336
|
+
Initialize a ResultItem object.
|
|
337
|
+
|
|
338
|
+
:param str crn: Resource identifier in CRN format.
|
|
339
|
+
:param **kwargs: (optional) Any additional properties.
|
|
340
|
+
"""
|
|
341
|
+
self.crn = crn
|
|
342
|
+
for _key, _value in kwargs.items():
|
|
343
|
+
setattr(self, _key, _value)
|
|
344
|
+
|
|
345
|
+
@classmethod
|
|
346
|
+
def from_dict(cls, _dict: Dict) -> 'ResultItem':
|
|
347
|
+
"""Initialize a ResultItem object from a json dictionary."""
|
|
348
|
+
args = {}
|
|
349
|
+
if (crn := _dict.get('crn')) is not None:
|
|
350
|
+
args['crn'] = crn
|
|
351
|
+
else:
|
|
352
|
+
raise ValueError('Required property \'crn\' not present in ResultItem JSON')
|
|
353
|
+
args.update({k: v for (k, v) in _dict.items() if k not in cls._properties})
|
|
354
|
+
return cls(**args)
|
|
355
|
+
|
|
356
|
+
@classmethod
|
|
357
|
+
def _from_dict(cls, _dict):
|
|
358
|
+
"""Initialize a ResultItem object from a json dictionary."""
|
|
359
|
+
return cls.from_dict(_dict)
|
|
360
|
+
|
|
361
|
+
def to_dict(self) -> Dict:
|
|
362
|
+
"""Return a json dictionary representing this model."""
|
|
363
|
+
_dict = {}
|
|
364
|
+
if hasattr(self, 'crn') and self.crn is not None:
|
|
365
|
+
_dict['crn'] = self.crn
|
|
366
|
+
for _key in [k for k in vars(self).keys() if k not in ResultItem._properties]:
|
|
367
|
+
_dict[_key] = getattr(self, _key)
|
|
368
|
+
return _dict
|
|
369
|
+
|
|
370
|
+
def _to_dict(self):
|
|
371
|
+
"""Return a json dictionary representing this model."""
|
|
372
|
+
return self.to_dict()
|
|
373
|
+
|
|
374
|
+
def get_properties(self) -> Dict:
|
|
375
|
+
"""Return a dictionary of arbitrary properties from this instance of ResultItem"""
|
|
376
|
+
_dict = {}
|
|
377
|
+
|
|
378
|
+
for _key in [k for k in vars(self).keys() if k not in ResultItem._properties]:
|
|
379
|
+
_dict[_key] = getattr(self, _key)
|
|
380
|
+
return _dict
|
|
381
|
+
|
|
382
|
+
def set_properties(self, _dict: dict):
|
|
383
|
+
"""Set a dictionary of arbitrary properties to this instance of ResultItem"""
|
|
384
|
+
for _key in [k for k in vars(self).keys() if k not in ResultItem._properties]:
|
|
385
|
+
delattr(self, _key)
|
|
386
|
+
|
|
387
|
+
for _key, _value in _dict.items():
|
|
388
|
+
if _key not in ResultItem._properties:
|
|
389
|
+
setattr(self, _key, _value)
|
|
390
|
+
|
|
391
|
+
def __str__(self) -> str:
|
|
392
|
+
"""Return a `str` version of this ResultItem object."""
|
|
393
|
+
return json.dumps(self.to_dict(), indent=2)
|
|
394
|
+
|
|
395
|
+
def __eq__(self, other: 'ResultItem') -> bool:
|
|
396
|
+
"""Return `true` when self and other are equal, false otherwise."""
|
|
397
|
+
if not isinstance(other, self.__class__):
|
|
398
|
+
return False
|
|
399
|
+
return self.__dict__ == other.__dict__
|
|
400
|
+
|
|
401
|
+
def __ne__(self, other: 'ResultItem') -> bool:
|
|
402
|
+
"""Return `true` when self and other are not equal, false otherwise."""
|
|
403
|
+
return not self == other
|
|
404
|
+
|
|
405
|
+
|
|
406
|
+
class ScanResult:
|
|
407
|
+
"""
|
|
408
|
+
The search scan response.
|
|
409
|
+
|
|
410
|
+
:param str search_cursor: (optional) The search cursor to use on all calls after
|
|
411
|
+
the first one.
|
|
412
|
+
:param int limit: Value of the limit parameter specified by the user.
|
|
413
|
+
:param List[ResultItem] items: The array of results. Each item represents a
|
|
414
|
+
resource. For each resource, the requested `fields` are returned. If you did not
|
|
415
|
+
set the `fields` request body parameter, then the `account_id`, `name`, `type`,
|
|
416
|
+
`family`, and `crn` are returned. An empty array signals the end of the result
|
|
417
|
+
set, which means there are no more results to fetch.
|
|
418
|
+
"""
|
|
419
|
+
|
|
420
|
+
def __init__(
|
|
421
|
+
self,
|
|
422
|
+
limit: int,
|
|
423
|
+
items: List['ResultItem'],
|
|
424
|
+
*,
|
|
425
|
+
search_cursor: Optional[str] = None,
|
|
426
|
+
) -> None:
|
|
427
|
+
"""
|
|
428
|
+
Initialize a ScanResult object.
|
|
429
|
+
|
|
430
|
+
:param int limit: Value of the limit parameter specified by the user.
|
|
431
|
+
:param List[ResultItem] items: The array of results. Each item represents a
|
|
432
|
+
resource. For each resource, the requested `fields` are returned. If you
|
|
433
|
+
did not set the `fields` request body parameter, then the `account_id`,
|
|
434
|
+
`name`, `type`, `family`, and `crn` are returned. An empty array signals
|
|
435
|
+
the end of the result set, which means there are no more results to fetch.
|
|
436
|
+
:param str search_cursor: (optional) The search cursor to use on all calls
|
|
437
|
+
after the first one.
|
|
438
|
+
"""
|
|
439
|
+
self.search_cursor = search_cursor
|
|
440
|
+
self.limit = limit
|
|
441
|
+
self.items = items
|
|
442
|
+
|
|
443
|
+
@classmethod
|
|
444
|
+
def from_dict(cls, _dict: Dict) -> 'ScanResult':
|
|
445
|
+
"""Initialize a ScanResult object from a json dictionary."""
|
|
446
|
+
args = {}
|
|
447
|
+
if (search_cursor := _dict.get('search_cursor')) is not None:
|
|
448
|
+
args['search_cursor'] = search_cursor
|
|
449
|
+
if (limit := _dict.get('limit')) is not None:
|
|
450
|
+
args['limit'] = limit
|
|
451
|
+
else:
|
|
452
|
+
raise ValueError('Required property \'limit\' not present in ScanResult JSON')
|
|
453
|
+
if (items := _dict.get('items')) is not None:
|
|
454
|
+
args['items'] = [ResultItem.from_dict(v) for v in items]
|
|
455
|
+
else:
|
|
456
|
+
raise ValueError('Required property \'items\' not present in ScanResult JSON')
|
|
457
|
+
return cls(**args)
|
|
458
|
+
|
|
459
|
+
@classmethod
|
|
460
|
+
def _from_dict(cls, _dict):
|
|
461
|
+
"""Initialize a ScanResult object from a json dictionary."""
|
|
462
|
+
return cls.from_dict(_dict)
|
|
463
|
+
|
|
464
|
+
def to_dict(self) -> Dict:
|
|
465
|
+
"""Return a json dictionary representing this model."""
|
|
466
|
+
_dict = {}
|
|
467
|
+
if hasattr(self, 'search_cursor') and self.search_cursor is not None:
|
|
468
|
+
_dict['search_cursor'] = self.search_cursor
|
|
469
|
+
if hasattr(self, 'limit') and self.limit is not None:
|
|
470
|
+
_dict['limit'] = self.limit
|
|
471
|
+
if hasattr(self, 'items') and self.items is not None:
|
|
472
|
+
items_list = []
|
|
473
|
+
for v in self.items:
|
|
474
|
+
if isinstance(v, dict):
|
|
475
|
+
items_list.append(v)
|
|
476
|
+
else:
|
|
477
|
+
items_list.append(v.to_dict())
|
|
478
|
+
_dict['items'] = items_list
|
|
479
|
+
return _dict
|
|
480
|
+
|
|
481
|
+
def _to_dict(self):
|
|
482
|
+
"""Return a json dictionary representing this model."""
|
|
483
|
+
return self.to_dict()
|
|
484
|
+
|
|
485
|
+
def __str__(self) -> str:
|
|
486
|
+
"""Return a `str` version of this ScanResult object."""
|
|
487
|
+
return json.dumps(self.to_dict(), indent=2)
|
|
488
|
+
|
|
489
|
+
def __eq__(self, other: 'ScanResult') -> bool:
|
|
490
|
+
"""Return `true` when self and other are equal, false otherwise."""
|
|
491
|
+
if not isinstance(other, self.__class__):
|
|
492
|
+
return False
|
|
493
|
+
return self.__dict__ == other.__dict__
|
|
494
|
+
|
|
495
|
+
def __ne__(self, other: 'ScanResult') -> bool:
|
|
496
|
+
"""Return `true` when self and other are not equal, false otherwise."""
|
|
497
|
+
return not self == other
|