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,1639 @@
|
|
|
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.70.0-7df966bf-20230419-195904
|
|
18
|
+
|
|
19
|
+
"""
|
|
20
|
+
Manage the lifecycle of your users using User Management APIs.
|
|
21
|
+
|
|
22
|
+
API Version: 1.0
|
|
23
|
+
"""
|
|
24
|
+
|
|
25
|
+
from typing import Dict, List
|
|
26
|
+
import json
|
|
27
|
+
|
|
28
|
+
from ibm_cloud_sdk_core import BaseService, DetailedResponse, get_query_param
|
|
29
|
+
from ibm_cloud_sdk_core.authenticators.authenticator import Authenticator
|
|
30
|
+
from ibm_cloud_sdk_core.get_authenticator import get_authenticator_from_environment
|
|
31
|
+
from ibm_cloud_sdk_core.utils import convert_model
|
|
32
|
+
|
|
33
|
+
from .common import get_sdk_headers
|
|
34
|
+
|
|
35
|
+
##############################################################################
|
|
36
|
+
# Service
|
|
37
|
+
##############################################################################
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
class UserManagementV1(BaseService):
|
|
41
|
+
"""The User Management V1 service."""
|
|
42
|
+
|
|
43
|
+
DEFAULT_SERVICE_URL = 'https://user-management.cloud.ibm.com'
|
|
44
|
+
DEFAULT_SERVICE_NAME = 'user_management'
|
|
45
|
+
|
|
46
|
+
@classmethod
|
|
47
|
+
def new_instance(
|
|
48
|
+
cls,
|
|
49
|
+
service_name: str = DEFAULT_SERVICE_NAME,
|
|
50
|
+
) -> 'UserManagementV1':
|
|
51
|
+
"""
|
|
52
|
+
Return a new client for the User Management service using the specified
|
|
53
|
+
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 User Management 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
|
+
# Users
|
|
75
|
+
#########################
|
|
76
|
+
|
|
77
|
+
def list_users(
|
|
78
|
+
self,
|
|
79
|
+
account_id: str,
|
|
80
|
+
*,
|
|
81
|
+
limit: int = None,
|
|
82
|
+
include_settings: bool = None,
|
|
83
|
+
search: str = None,
|
|
84
|
+
start: str = None,
|
|
85
|
+
user_id: str = None,
|
|
86
|
+
**kwargs,
|
|
87
|
+
) -> DetailedResponse:
|
|
88
|
+
"""
|
|
89
|
+
List users.
|
|
90
|
+
|
|
91
|
+
Retrieve users in the account. You can use the IAM service token or a user token
|
|
92
|
+
for authorization. To use this method, the requesting user or service ID must have
|
|
93
|
+
at least the viewer, editor, or administrator role on the User Management service.
|
|
94
|
+
If unrestricted view is enabled, the user can see all users in the same account
|
|
95
|
+
without an IAM role. If restricted view is enabled and user has the viewer,
|
|
96
|
+
editor, or administrator role on the user management service, the API returns all
|
|
97
|
+
users in the account. If unrestricted view is enabled and the user does not have
|
|
98
|
+
these roles, the API returns only the current user. Users are returned in a
|
|
99
|
+
paginated list with a default limit of 100 users. You can iterate through all
|
|
100
|
+
users by following the `next_url` field. Additional substring search fields are
|
|
101
|
+
supported to filter the users.
|
|
102
|
+
|
|
103
|
+
:param str account_id: The account ID of the specified user.
|
|
104
|
+
:param int limit: (optional) The number of results to be returned.
|
|
105
|
+
:param bool include_settings: (optional) The user settings to be returned.
|
|
106
|
+
Set to true to view language, allowed IP address, and authentication
|
|
107
|
+
settings.
|
|
108
|
+
:param str search: (optional) The desired search results to be returned. To
|
|
109
|
+
view the list of users with the additional search filter, use the following
|
|
110
|
+
query options: `firstname`, `lastname`, `email`, `state`, `substate`,
|
|
111
|
+
`iam_id`, `realm`, and `userId`. HTML URL encoding for the search query and
|
|
112
|
+
`:` must be used. For example, search=state%3AINVALID returns a list of
|
|
113
|
+
invalid users. Multiple search queries can be combined to obtain `OR`
|
|
114
|
+
results using `,` operator (not URL encoded). For example,
|
|
115
|
+
search=state%3AINVALID,email%3Amail.test.ibm.com.
|
|
116
|
+
:param str start: (optional) An optional token that indicates the beginning
|
|
117
|
+
of the page of results to be returned. If omitted, the first page of
|
|
118
|
+
results is returned. This value is obtained from the 'next_url' field of
|
|
119
|
+
the operation response.
|
|
120
|
+
:param str user_id: (optional) Filter users based on their user ID.
|
|
121
|
+
:param dict headers: A `dict` containing the request headers
|
|
122
|
+
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
|
|
123
|
+
:rtype: DetailedResponse with `dict` result representing a `UserList` object
|
|
124
|
+
"""
|
|
125
|
+
|
|
126
|
+
if not account_id:
|
|
127
|
+
raise ValueError('account_id must be provided')
|
|
128
|
+
headers = {}
|
|
129
|
+
sdk_headers = get_sdk_headers(
|
|
130
|
+
service_name=self.DEFAULT_SERVICE_NAME,
|
|
131
|
+
service_version='V1',
|
|
132
|
+
operation_id='list_users',
|
|
133
|
+
)
|
|
134
|
+
headers.update(sdk_headers)
|
|
135
|
+
|
|
136
|
+
params = {
|
|
137
|
+
'limit': limit,
|
|
138
|
+
'include_settings': include_settings,
|
|
139
|
+
'search': search,
|
|
140
|
+
'_start': start,
|
|
141
|
+
'user_id': user_id,
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
if 'headers' in kwargs:
|
|
145
|
+
headers.update(kwargs.get('headers'))
|
|
146
|
+
del kwargs['headers']
|
|
147
|
+
headers['Accept'] = 'application/json'
|
|
148
|
+
|
|
149
|
+
path_param_keys = ['account_id']
|
|
150
|
+
path_param_values = self.encode_path_vars(account_id)
|
|
151
|
+
path_param_dict = dict(zip(path_param_keys, path_param_values))
|
|
152
|
+
url = '/v2/accounts/{account_id}/users'.format(**path_param_dict)
|
|
153
|
+
request = self.prepare_request(
|
|
154
|
+
method='GET',
|
|
155
|
+
url=url,
|
|
156
|
+
headers=headers,
|
|
157
|
+
params=params,
|
|
158
|
+
)
|
|
159
|
+
|
|
160
|
+
response = self.send(request, **kwargs)
|
|
161
|
+
return response
|
|
162
|
+
|
|
163
|
+
def invite_users(
|
|
164
|
+
self,
|
|
165
|
+
account_id: str,
|
|
166
|
+
*,
|
|
167
|
+
users: List['InviteUser'] = None,
|
|
168
|
+
iam_policy: List['InviteUserIamPolicy'] = None,
|
|
169
|
+
access_groups: List[str] = None,
|
|
170
|
+
**kwargs,
|
|
171
|
+
) -> DetailedResponse:
|
|
172
|
+
"""
|
|
173
|
+
Invite users to an account.
|
|
174
|
+
|
|
175
|
+
Invite users to the account. You must use a user token for authorization. Service
|
|
176
|
+
IDs can't invite users to the account. To use this method, the requesting user
|
|
177
|
+
must have the editor or administrator role on the User Management service. For
|
|
178
|
+
more information, see the [Inviting
|
|
179
|
+
users](https://cloud.ibm.com/docs/account?topic=account-iamuserinv) documentation.
|
|
180
|
+
You can specify the user account role and the corresponding IAM policy information
|
|
181
|
+
in the request body. <br/><br/>When you invite a user to an account, the user is
|
|
182
|
+
initially created in the `PROCESSING` state. After the user is successfully
|
|
183
|
+
created, all specified permissions are configured, and the activation email is
|
|
184
|
+
sent, the invited user is transitioned to the `PENDING` state. When the invited
|
|
185
|
+
user clicks the activation email and creates and confirms their IBM Cloud account,
|
|
186
|
+
the user is transitioned to `ACTIVE` state. If the user email is already verified,
|
|
187
|
+
no email is generated.
|
|
188
|
+
|
|
189
|
+
:param str account_id: The account ID of the specified user.
|
|
190
|
+
:param List[InviteUser] users: (optional) A list of users to be invited.
|
|
191
|
+
:param List[InviteUserIamPolicy] iam_policy: (optional) A list of IAM
|
|
192
|
+
policies.
|
|
193
|
+
:param List[str] access_groups: (optional) A list of access groups.
|
|
194
|
+
:param dict headers: A `dict` containing the request headers
|
|
195
|
+
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
|
|
196
|
+
:rtype: DetailedResponse with `dict` result representing a `InvitedUserList` object
|
|
197
|
+
"""
|
|
198
|
+
|
|
199
|
+
if not account_id:
|
|
200
|
+
raise ValueError('account_id must be provided')
|
|
201
|
+
if users is not None:
|
|
202
|
+
users = [convert_model(x) for x in users]
|
|
203
|
+
if iam_policy is not None:
|
|
204
|
+
iam_policy = [convert_model(x) for x in iam_policy]
|
|
205
|
+
headers = {}
|
|
206
|
+
sdk_headers = get_sdk_headers(
|
|
207
|
+
service_name=self.DEFAULT_SERVICE_NAME,
|
|
208
|
+
service_version='V1',
|
|
209
|
+
operation_id='invite_users',
|
|
210
|
+
)
|
|
211
|
+
headers.update(sdk_headers)
|
|
212
|
+
|
|
213
|
+
data = {
|
|
214
|
+
'users': users,
|
|
215
|
+
'iam_policy': iam_policy,
|
|
216
|
+
'access_groups': access_groups,
|
|
217
|
+
}
|
|
218
|
+
data = {k: v for (k, v) in data.items() if v is not None}
|
|
219
|
+
data = json.dumps(data)
|
|
220
|
+
headers['content-type'] = 'application/json'
|
|
221
|
+
|
|
222
|
+
if 'headers' in kwargs:
|
|
223
|
+
headers.update(kwargs.get('headers'))
|
|
224
|
+
del kwargs['headers']
|
|
225
|
+
headers['Accept'] = 'application/json'
|
|
226
|
+
|
|
227
|
+
path_param_keys = ['account_id']
|
|
228
|
+
path_param_values = self.encode_path_vars(account_id)
|
|
229
|
+
path_param_dict = dict(zip(path_param_keys, path_param_values))
|
|
230
|
+
url = '/v2/accounts/{account_id}/users'.format(**path_param_dict)
|
|
231
|
+
request = self.prepare_request(
|
|
232
|
+
method='POST',
|
|
233
|
+
url=url,
|
|
234
|
+
headers=headers,
|
|
235
|
+
data=data,
|
|
236
|
+
)
|
|
237
|
+
|
|
238
|
+
response = self.send(request, **kwargs)
|
|
239
|
+
return response
|
|
240
|
+
|
|
241
|
+
def get_user_profile(
|
|
242
|
+
self,
|
|
243
|
+
account_id: str,
|
|
244
|
+
iam_id: str,
|
|
245
|
+
*,
|
|
246
|
+
include_activity: str = None,
|
|
247
|
+
**kwargs,
|
|
248
|
+
) -> DetailedResponse:
|
|
249
|
+
"""
|
|
250
|
+
Get user profile.
|
|
251
|
+
|
|
252
|
+
Retrieve a user's profile by the user's IAM ID in your account. You can use the
|
|
253
|
+
IAM service token or a user token for authorization. To use this method, the
|
|
254
|
+
requesting user or service ID must have at least the viewer, editor, or
|
|
255
|
+
administrator role on the User Management service.
|
|
256
|
+
|
|
257
|
+
:param str account_id: The account ID of the specified user.
|
|
258
|
+
:param str iam_id: The user's IAM ID.
|
|
259
|
+
:param str include_activity: (optional) Include activity information of the
|
|
260
|
+
user, such as the last authentication timestamp.
|
|
261
|
+
:param dict headers: A `dict` containing the request headers
|
|
262
|
+
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
|
|
263
|
+
:rtype: DetailedResponse with `dict` result representing a `UserProfile` object
|
|
264
|
+
"""
|
|
265
|
+
|
|
266
|
+
if not account_id:
|
|
267
|
+
raise ValueError('account_id must be provided')
|
|
268
|
+
if not iam_id:
|
|
269
|
+
raise ValueError('iam_id must be provided')
|
|
270
|
+
headers = {}
|
|
271
|
+
sdk_headers = get_sdk_headers(
|
|
272
|
+
service_name=self.DEFAULT_SERVICE_NAME,
|
|
273
|
+
service_version='V1',
|
|
274
|
+
operation_id='get_user_profile',
|
|
275
|
+
)
|
|
276
|
+
headers.update(sdk_headers)
|
|
277
|
+
|
|
278
|
+
params = {
|
|
279
|
+
'include_activity': include_activity,
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
if 'headers' in kwargs:
|
|
283
|
+
headers.update(kwargs.get('headers'))
|
|
284
|
+
del kwargs['headers']
|
|
285
|
+
headers['Accept'] = 'application/json'
|
|
286
|
+
|
|
287
|
+
path_param_keys = ['account_id', 'iam_id']
|
|
288
|
+
path_param_values = self.encode_path_vars(account_id, iam_id)
|
|
289
|
+
path_param_dict = dict(zip(path_param_keys, path_param_values))
|
|
290
|
+
url = '/v2/accounts/{account_id}/users/{iam_id}'.format(**path_param_dict)
|
|
291
|
+
request = self.prepare_request(
|
|
292
|
+
method='GET',
|
|
293
|
+
url=url,
|
|
294
|
+
headers=headers,
|
|
295
|
+
params=params,
|
|
296
|
+
)
|
|
297
|
+
|
|
298
|
+
response = self.send(request, **kwargs)
|
|
299
|
+
return response
|
|
300
|
+
|
|
301
|
+
def update_user_profile(
|
|
302
|
+
self,
|
|
303
|
+
account_id: str,
|
|
304
|
+
iam_id: str,
|
|
305
|
+
*,
|
|
306
|
+
firstname: str = None,
|
|
307
|
+
lastname: str = None,
|
|
308
|
+
state: str = None,
|
|
309
|
+
email: str = None,
|
|
310
|
+
phonenumber: str = None,
|
|
311
|
+
altphonenumber: str = None,
|
|
312
|
+
photo: str = None,
|
|
313
|
+
include_activity: str = None,
|
|
314
|
+
**kwargs,
|
|
315
|
+
) -> DetailedResponse:
|
|
316
|
+
"""
|
|
317
|
+
Partially update user profile.
|
|
318
|
+
|
|
319
|
+
Partially update a user's profile by user's IAM ID. You can use the IAM service
|
|
320
|
+
token or a user token for authorization. To use this method, the requesting user
|
|
321
|
+
or service ID must have at least the editor or administrator role on the User
|
|
322
|
+
Management service. A user or service ID with these roles can change a user's
|
|
323
|
+
state between `ACTIVE`, `VPN_ONLY`, or `DISABLED_CLASSIC_INFRASTRUCTURE`, but they
|
|
324
|
+
can't change the state to `PROCESSING` or `PENDING` because these are system
|
|
325
|
+
states. For other request body fields, a user can update their own profile without
|
|
326
|
+
having User Management service permissions.
|
|
327
|
+
|
|
328
|
+
:param str account_id: The account ID of the specified user.
|
|
329
|
+
:param str iam_id: The user's IAM ID.
|
|
330
|
+
:param str firstname: (optional) The first name of the user.
|
|
331
|
+
:param str lastname: (optional) The last name of the user.
|
|
332
|
+
:param str state: (optional) The state of the user. Possible values are
|
|
333
|
+
`PROCESSING`, `PENDING`, `ACTIVE`, `DISABLED_CLASSIC_INFRASTRUCTURE`, and
|
|
334
|
+
`VPN_ONLY`.
|
|
335
|
+
:param str email: (optional) The email address of the user.
|
|
336
|
+
:param str phonenumber: (optional) The phone number of the user.
|
|
337
|
+
:param str altphonenumber: (optional) The alternative phone number of the
|
|
338
|
+
user.
|
|
339
|
+
:param str photo: (optional) A link to a photo of the user.
|
|
340
|
+
:param str include_activity: (optional) Include activity information of the
|
|
341
|
+
user, such as the last authentication timestamp.
|
|
342
|
+
:param dict headers: A `dict` containing the request headers
|
|
343
|
+
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
|
|
344
|
+
:rtype: DetailedResponse
|
|
345
|
+
"""
|
|
346
|
+
|
|
347
|
+
if not account_id:
|
|
348
|
+
raise ValueError('account_id must be provided')
|
|
349
|
+
if not iam_id:
|
|
350
|
+
raise ValueError('iam_id must be provided')
|
|
351
|
+
headers = {}
|
|
352
|
+
sdk_headers = get_sdk_headers(
|
|
353
|
+
service_name=self.DEFAULT_SERVICE_NAME,
|
|
354
|
+
service_version='V1',
|
|
355
|
+
operation_id='update_user_profile',
|
|
356
|
+
)
|
|
357
|
+
headers.update(sdk_headers)
|
|
358
|
+
|
|
359
|
+
params = {
|
|
360
|
+
'include_activity': include_activity,
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
data = {
|
|
364
|
+
'firstname': firstname,
|
|
365
|
+
'lastname': lastname,
|
|
366
|
+
'state': state,
|
|
367
|
+
'email': email,
|
|
368
|
+
'phonenumber': phonenumber,
|
|
369
|
+
'altphonenumber': altphonenumber,
|
|
370
|
+
'photo': photo,
|
|
371
|
+
}
|
|
372
|
+
data = {k: v for (k, v) in data.items() if v is not None}
|
|
373
|
+
data = json.dumps(data)
|
|
374
|
+
headers['content-type'] = 'application/json'
|
|
375
|
+
|
|
376
|
+
if 'headers' in kwargs:
|
|
377
|
+
headers.update(kwargs.get('headers'))
|
|
378
|
+
del kwargs['headers']
|
|
379
|
+
|
|
380
|
+
path_param_keys = ['account_id', 'iam_id']
|
|
381
|
+
path_param_values = self.encode_path_vars(account_id, iam_id)
|
|
382
|
+
path_param_dict = dict(zip(path_param_keys, path_param_values))
|
|
383
|
+
url = '/v2/accounts/{account_id}/users/{iam_id}'.format(**path_param_dict)
|
|
384
|
+
request = self.prepare_request(
|
|
385
|
+
method='PATCH',
|
|
386
|
+
url=url,
|
|
387
|
+
headers=headers,
|
|
388
|
+
params=params,
|
|
389
|
+
data=data,
|
|
390
|
+
)
|
|
391
|
+
|
|
392
|
+
response = self.send(request, **kwargs)
|
|
393
|
+
return response
|
|
394
|
+
|
|
395
|
+
def remove_user(
|
|
396
|
+
self,
|
|
397
|
+
account_id: str,
|
|
398
|
+
iam_id: str,
|
|
399
|
+
*,
|
|
400
|
+
include_activity: str = None,
|
|
401
|
+
**kwargs,
|
|
402
|
+
) -> DetailedResponse:
|
|
403
|
+
"""
|
|
404
|
+
Remove user from account.
|
|
405
|
+
|
|
406
|
+
Remove users from an account by user's IAM ID. You must use a user token for
|
|
407
|
+
authorization. Service IDs can't remove users from an account. To use this method,
|
|
408
|
+
the requesting user must have the editor or administrator role on the User
|
|
409
|
+
Management service. For more information, see the [Removing
|
|
410
|
+
users](https://cloud.ibm.com/docs/account?topic=account-remove) documentation.
|
|
411
|
+
|
|
412
|
+
:param str account_id: The account ID of the specified user.
|
|
413
|
+
:param str iam_id: The user's IAM ID.
|
|
414
|
+
:param str include_activity: (optional) Include activity information of the
|
|
415
|
+
user, such as the last authentication timestamp.
|
|
416
|
+
:param dict headers: A `dict` containing the request headers
|
|
417
|
+
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
|
|
418
|
+
:rtype: DetailedResponse
|
|
419
|
+
"""
|
|
420
|
+
|
|
421
|
+
if not account_id:
|
|
422
|
+
raise ValueError('account_id must be provided')
|
|
423
|
+
if not iam_id:
|
|
424
|
+
raise ValueError('iam_id must be provided')
|
|
425
|
+
headers = {}
|
|
426
|
+
sdk_headers = get_sdk_headers(
|
|
427
|
+
service_name=self.DEFAULT_SERVICE_NAME,
|
|
428
|
+
service_version='V1',
|
|
429
|
+
operation_id='remove_user',
|
|
430
|
+
)
|
|
431
|
+
headers.update(sdk_headers)
|
|
432
|
+
|
|
433
|
+
params = {
|
|
434
|
+
'include_activity': include_activity,
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
if 'headers' in kwargs:
|
|
438
|
+
headers.update(kwargs.get('headers'))
|
|
439
|
+
del kwargs['headers']
|
|
440
|
+
|
|
441
|
+
path_param_keys = ['account_id', 'iam_id']
|
|
442
|
+
path_param_values = self.encode_path_vars(account_id, iam_id)
|
|
443
|
+
path_param_dict = dict(zip(path_param_keys, path_param_values))
|
|
444
|
+
url = '/v2/accounts/{account_id}/users/{iam_id}'.format(**path_param_dict)
|
|
445
|
+
request = self.prepare_request(
|
|
446
|
+
method='DELETE',
|
|
447
|
+
url=url,
|
|
448
|
+
headers=headers,
|
|
449
|
+
params=params,
|
|
450
|
+
)
|
|
451
|
+
|
|
452
|
+
response = self.send(request, **kwargs)
|
|
453
|
+
return response
|
|
454
|
+
|
|
455
|
+
def accept(
|
|
456
|
+
self,
|
|
457
|
+
*,
|
|
458
|
+
account_id: str = None,
|
|
459
|
+
**kwargs,
|
|
460
|
+
) -> DetailedResponse:
|
|
461
|
+
"""
|
|
462
|
+
Accept an invitation.
|
|
463
|
+
|
|
464
|
+
Accept a user invitation to an account. You can use the user's token for
|
|
465
|
+
authorization. To use this method, the requesting user must provide the account ID
|
|
466
|
+
for the account that they are accepting an invitation for. If the user already
|
|
467
|
+
accepted the invitation request, it returns 204 with no response body.
|
|
468
|
+
|
|
469
|
+
:param str account_id: (optional) The account ID.
|
|
470
|
+
:param dict headers: A `dict` containing the request headers
|
|
471
|
+
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
|
|
472
|
+
:rtype: DetailedResponse
|
|
473
|
+
"""
|
|
474
|
+
|
|
475
|
+
headers = {}
|
|
476
|
+
sdk_headers = get_sdk_headers(
|
|
477
|
+
service_name=self.DEFAULT_SERVICE_NAME,
|
|
478
|
+
service_version='V1',
|
|
479
|
+
operation_id='accept',
|
|
480
|
+
)
|
|
481
|
+
headers.update(sdk_headers)
|
|
482
|
+
|
|
483
|
+
data = {
|
|
484
|
+
'account_id': account_id,
|
|
485
|
+
}
|
|
486
|
+
data = {k: v for (k, v) in data.items() if v is not None}
|
|
487
|
+
data = json.dumps(data)
|
|
488
|
+
headers['content-type'] = 'application/json'
|
|
489
|
+
|
|
490
|
+
if 'headers' in kwargs:
|
|
491
|
+
headers.update(kwargs.get('headers'))
|
|
492
|
+
del kwargs['headers']
|
|
493
|
+
|
|
494
|
+
url = '/v2/users/accept'
|
|
495
|
+
request = self.prepare_request(
|
|
496
|
+
method='POST',
|
|
497
|
+
url=url,
|
|
498
|
+
headers=headers,
|
|
499
|
+
data=data,
|
|
500
|
+
)
|
|
501
|
+
|
|
502
|
+
response = self.send(request, **kwargs)
|
|
503
|
+
return response
|
|
504
|
+
|
|
505
|
+
def v3_remove_user(
|
|
506
|
+
self,
|
|
507
|
+
account_id: str,
|
|
508
|
+
iam_id: str,
|
|
509
|
+
**kwargs,
|
|
510
|
+
) -> DetailedResponse:
|
|
511
|
+
"""
|
|
512
|
+
Remove user from account (Asynchronous).
|
|
513
|
+
|
|
514
|
+
Remove users from an account by using the user's IAM ID. You must use a user token
|
|
515
|
+
for authorization. Service IDs can't remove users from an account. If removing the
|
|
516
|
+
user fails it will set the user's state to ERROR_WHILE_DELETING. To use this
|
|
517
|
+
method, the requesting user must have the editor or administrator role on the User
|
|
518
|
+
Management service. For more information, see the [Removing
|
|
519
|
+
users](https://cloud.ibm.com/docs/account?topic=account-remove) documentation.
|
|
520
|
+
|
|
521
|
+
:param str account_id: The account ID of the specified user.
|
|
522
|
+
:param str iam_id: The user's IAM ID.
|
|
523
|
+
:param dict headers: A `dict` containing the request headers
|
|
524
|
+
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
|
|
525
|
+
:rtype: DetailedResponse
|
|
526
|
+
"""
|
|
527
|
+
|
|
528
|
+
if not account_id:
|
|
529
|
+
raise ValueError('account_id must be provided')
|
|
530
|
+
if not iam_id:
|
|
531
|
+
raise ValueError('iam_id must be provided')
|
|
532
|
+
headers = {}
|
|
533
|
+
sdk_headers = get_sdk_headers(
|
|
534
|
+
service_name=self.DEFAULT_SERVICE_NAME,
|
|
535
|
+
service_version='V1',
|
|
536
|
+
operation_id='v3_remove_user',
|
|
537
|
+
)
|
|
538
|
+
headers.update(sdk_headers)
|
|
539
|
+
|
|
540
|
+
if 'headers' in kwargs:
|
|
541
|
+
headers.update(kwargs.get('headers'))
|
|
542
|
+
del kwargs['headers']
|
|
543
|
+
|
|
544
|
+
path_param_keys = ['account_id', 'iam_id']
|
|
545
|
+
path_param_values = self.encode_path_vars(account_id, iam_id)
|
|
546
|
+
path_param_dict = dict(zip(path_param_keys, path_param_values))
|
|
547
|
+
url = '/v3/accounts/{account_id}/users/{iam_id}'.format(**path_param_dict)
|
|
548
|
+
request = self.prepare_request(
|
|
549
|
+
method='DELETE',
|
|
550
|
+
url=url,
|
|
551
|
+
headers=headers,
|
|
552
|
+
)
|
|
553
|
+
|
|
554
|
+
response = self.send(request, **kwargs)
|
|
555
|
+
return response
|
|
556
|
+
|
|
557
|
+
#########################
|
|
558
|
+
# User Settings
|
|
559
|
+
#########################
|
|
560
|
+
|
|
561
|
+
def get_user_settings(
|
|
562
|
+
self,
|
|
563
|
+
account_id: str,
|
|
564
|
+
iam_id: str,
|
|
565
|
+
**kwargs,
|
|
566
|
+
) -> DetailedResponse:
|
|
567
|
+
"""
|
|
568
|
+
Get user settings.
|
|
569
|
+
|
|
570
|
+
Retrieve a user's settings by the user's IAM ID. You can use the IAM service token
|
|
571
|
+
or a user token for authorization. To use this method, the requesting user or
|
|
572
|
+
service ID must have the viewer, editor, or administrator role on the User
|
|
573
|
+
Management service. <br/><br/>The user settings have several fields. The
|
|
574
|
+
`language` field is the language setting for the user interface display language.
|
|
575
|
+
The `notification_language` field is the language setting for phone and email
|
|
576
|
+
notifications. The `allowed_ip_addresses` field specifies a list of IP addresses
|
|
577
|
+
that the user can log in and perform operations from as described in [Allowing
|
|
578
|
+
specific IP addresses for a
|
|
579
|
+
user](https://cloud.ibm.com/docs/account?topic=account-ips). For information about
|
|
580
|
+
the `self_manage` field, review information about the [user-managed login
|
|
581
|
+
setting](https://cloud.ibm.com/docs/account?topic=account-types).
|
|
582
|
+
|
|
583
|
+
:param str account_id: The account ID of the specified user.
|
|
584
|
+
:param str iam_id: The user's IAM ID.
|
|
585
|
+
:param dict headers: A `dict` containing the request headers
|
|
586
|
+
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
|
|
587
|
+
:rtype: DetailedResponse with `dict` result representing a `UserSettings` object
|
|
588
|
+
"""
|
|
589
|
+
|
|
590
|
+
if not account_id:
|
|
591
|
+
raise ValueError('account_id must be provided')
|
|
592
|
+
if not iam_id:
|
|
593
|
+
raise ValueError('iam_id must be provided')
|
|
594
|
+
headers = {}
|
|
595
|
+
sdk_headers = get_sdk_headers(
|
|
596
|
+
service_name=self.DEFAULT_SERVICE_NAME,
|
|
597
|
+
service_version='V1',
|
|
598
|
+
operation_id='get_user_settings',
|
|
599
|
+
)
|
|
600
|
+
headers.update(sdk_headers)
|
|
601
|
+
|
|
602
|
+
if 'headers' in kwargs:
|
|
603
|
+
headers.update(kwargs.get('headers'))
|
|
604
|
+
del kwargs['headers']
|
|
605
|
+
headers['Accept'] = 'application/json'
|
|
606
|
+
|
|
607
|
+
path_param_keys = ['account_id', 'iam_id']
|
|
608
|
+
path_param_values = self.encode_path_vars(account_id, iam_id)
|
|
609
|
+
path_param_dict = dict(zip(path_param_keys, path_param_values))
|
|
610
|
+
url = '/v2/accounts/{account_id}/users/{iam_id}/settings'.format(**path_param_dict)
|
|
611
|
+
request = self.prepare_request(
|
|
612
|
+
method='GET',
|
|
613
|
+
url=url,
|
|
614
|
+
headers=headers,
|
|
615
|
+
)
|
|
616
|
+
|
|
617
|
+
response = self.send(request, **kwargs)
|
|
618
|
+
return response
|
|
619
|
+
|
|
620
|
+
def update_user_settings(
|
|
621
|
+
self,
|
|
622
|
+
account_id: str,
|
|
623
|
+
iam_id: str,
|
|
624
|
+
*,
|
|
625
|
+
language: str = None,
|
|
626
|
+
notification_language: str = None,
|
|
627
|
+
allowed_ip_addresses: str = None,
|
|
628
|
+
self_manage: bool = None,
|
|
629
|
+
**kwargs,
|
|
630
|
+
) -> DetailedResponse:
|
|
631
|
+
"""
|
|
632
|
+
Partially update user settings.
|
|
633
|
+
|
|
634
|
+
Update a user's settings by the user's IAM ID. You can use the IAM service token
|
|
635
|
+
or a user token for authorization. To fully use this method, the user or service
|
|
636
|
+
ID must have the editor or administrator role on the User Management service.
|
|
637
|
+
Without these roles, a user can update only their own `language` or
|
|
638
|
+
`notification_language` fields. If `self_manage` is `true`, the user can also
|
|
639
|
+
update the `allowed_ip_addresses` field.
|
|
640
|
+
|
|
641
|
+
:param str account_id: The account ID of the specified user.
|
|
642
|
+
:param str iam_id: The user's IAM ID.
|
|
643
|
+
:param str language: (optional) The console UI language. By default, this
|
|
644
|
+
field is empty.
|
|
645
|
+
:param str notification_language: (optional) The language for email and
|
|
646
|
+
phone notifications. By default, this field is empty.
|
|
647
|
+
:param str allowed_ip_addresses: (optional) A comma-separated list of IP
|
|
648
|
+
addresses.
|
|
649
|
+
:param bool self_manage: (optional) Whether user managed login is enabled.
|
|
650
|
+
The default value is `false`.
|
|
651
|
+
:param dict headers: A `dict` containing the request headers
|
|
652
|
+
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
|
|
653
|
+
:rtype: DetailedResponse
|
|
654
|
+
"""
|
|
655
|
+
|
|
656
|
+
if not account_id:
|
|
657
|
+
raise ValueError('account_id must be provided')
|
|
658
|
+
if not iam_id:
|
|
659
|
+
raise ValueError('iam_id must be provided')
|
|
660
|
+
headers = {}
|
|
661
|
+
sdk_headers = get_sdk_headers(
|
|
662
|
+
service_name=self.DEFAULT_SERVICE_NAME,
|
|
663
|
+
service_version='V1',
|
|
664
|
+
operation_id='update_user_settings',
|
|
665
|
+
)
|
|
666
|
+
headers.update(sdk_headers)
|
|
667
|
+
|
|
668
|
+
data = {
|
|
669
|
+
'language': language,
|
|
670
|
+
'notification_language': notification_language,
|
|
671
|
+
'allowed_ip_addresses': allowed_ip_addresses,
|
|
672
|
+
'self_manage': self_manage,
|
|
673
|
+
}
|
|
674
|
+
data = {k: v for (k, v) in data.items() if v is not None}
|
|
675
|
+
data = json.dumps(data)
|
|
676
|
+
headers['content-type'] = 'application/json'
|
|
677
|
+
|
|
678
|
+
if 'headers' in kwargs:
|
|
679
|
+
headers.update(kwargs.get('headers'))
|
|
680
|
+
del kwargs['headers']
|
|
681
|
+
|
|
682
|
+
path_param_keys = ['account_id', 'iam_id']
|
|
683
|
+
path_param_values = self.encode_path_vars(account_id, iam_id)
|
|
684
|
+
path_param_dict = dict(zip(path_param_keys, path_param_values))
|
|
685
|
+
url = '/v2/accounts/{account_id}/users/{iam_id}/settings'.format(**path_param_dict)
|
|
686
|
+
request = self.prepare_request(
|
|
687
|
+
method='PATCH',
|
|
688
|
+
url=url,
|
|
689
|
+
headers=headers,
|
|
690
|
+
data=data,
|
|
691
|
+
)
|
|
692
|
+
|
|
693
|
+
response = self.send(request, **kwargs)
|
|
694
|
+
return response
|
|
695
|
+
|
|
696
|
+
|
|
697
|
+
##############################################################################
|
|
698
|
+
# Models
|
|
699
|
+
##############################################################################
|
|
700
|
+
|
|
701
|
+
|
|
702
|
+
class InvitedUser:
|
|
703
|
+
"""
|
|
704
|
+
Information about a user that has been invited to join an account.
|
|
705
|
+
|
|
706
|
+
:attr str email: (optional) The email address associated with the invited user.
|
|
707
|
+
:attr str id: (optional) The id associated with the invited user.
|
|
708
|
+
:attr str state: (optional) The state of the invitation for the user.
|
|
709
|
+
"""
|
|
710
|
+
|
|
711
|
+
def __init__(
|
|
712
|
+
self,
|
|
713
|
+
*,
|
|
714
|
+
email: str = None,
|
|
715
|
+
id: str = None,
|
|
716
|
+
state: str = None,
|
|
717
|
+
) -> None:
|
|
718
|
+
"""
|
|
719
|
+
Initialize a InvitedUser object.
|
|
720
|
+
|
|
721
|
+
:param str email: (optional) The email address associated with the invited
|
|
722
|
+
user.
|
|
723
|
+
:param str id: (optional) The id associated with the invited user.
|
|
724
|
+
:param str state: (optional) The state of the invitation for the user.
|
|
725
|
+
"""
|
|
726
|
+
self.email = email
|
|
727
|
+
self.id = id
|
|
728
|
+
self.state = state
|
|
729
|
+
|
|
730
|
+
@classmethod
|
|
731
|
+
def from_dict(cls, _dict: Dict) -> 'InvitedUser':
|
|
732
|
+
"""Initialize a InvitedUser object from a json dictionary."""
|
|
733
|
+
args = {}
|
|
734
|
+
if 'email' in _dict:
|
|
735
|
+
args['email'] = _dict.get('email')
|
|
736
|
+
if 'id' in _dict:
|
|
737
|
+
args['id'] = _dict.get('id')
|
|
738
|
+
if 'state' in _dict:
|
|
739
|
+
args['state'] = _dict.get('state')
|
|
740
|
+
return cls(**args)
|
|
741
|
+
|
|
742
|
+
@classmethod
|
|
743
|
+
def _from_dict(cls, _dict):
|
|
744
|
+
"""Initialize a InvitedUser object from a json dictionary."""
|
|
745
|
+
return cls.from_dict(_dict)
|
|
746
|
+
|
|
747
|
+
def to_dict(self) -> Dict:
|
|
748
|
+
"""Return a json dictionary representing this model."""
|
|
749
|
+
_dict = {}
|
|
750
|
+
if hasattr(self, 'email') and self.email is not None:
|
|
751
|
+
_dict['email'] = self.email
|
|
752
|
+
if hasattr(self, 'id') and self.id is not None:
|
|
753
|
+
_dict['id'] = self.id
|
|
754
|
+
if hasattr(self, 'state') and self.state is not None:
|
|
755
|
+
_dict['state'] = self.state
|
|
756
|
+
return _dict
|
|
757
|
+
|
|
758
|
+
def _to_dict(self):
|
|
759
|
+
"""Return a json dictionary representing this model."""
|
|
760
|
+
return self.to_dict()
|
|
761
|
+
|
|
762
|
+
def __str__(self) -> str:
|
|
763
|
+
"""Return a `str` version of this InvitedUser object."""
|
|
764
|
+
return json.dumps(self.to_dict(), indent=2)
|
|
765
|
+
|
|
766
|
+
def __eq__(self, other: 'InvitedUser') -> bool:
|
|
767
|
+
"""Return `true` when self and other are equal, false otherwise."""
|
|
768
|
+
if not isinstance(other, self.__class__):
|
|
769
|
+
return False
|
|
770
|
+
return self.__dict__ == other.__dict__
|
|
771
|
+
|
|
772
|
+
def __ne__(self, other: 'InvitedUser') -> bool:
|
|
773
|
+
"""Return `true` when self and other are not equal, false otherwise."""
|
|
774
|
+
return not self == other
|
|
775
|
+
|
|
776
|
+
|
|
777
|
+
class InvitedUserList:
|
|
778
|
+
"""
|
|
779
|
+
A collection of invited users. This is the response returned by the invite_users
|
|
780
|
+
operation.
|
|
781
|
+
|
|
782
|
+
:attr List[InvitedUser] resources: (optional) The list of users that have been
|
|
783
|
+
invited to join the account.
|
|
784
|
+
"""
|
|
785
|
+
|
|
786
|
+
def __init__(
|
|
787
|
+
self,
|
|
788
|
+
*,
|
|
789
|
+
resources: List['InvitedUser'] = None,
|
|
790
|
+
) -> None:
|
|
791
|
+
"""
|
|
792
|
+
Initialize a InvitedUserList object.
|
|
793
|
+
|
|
794
|
+
:param List[InvitedUser] resources: (optional) The list of users that have
|
|
795
|
+
been invited to join the account.
|
|
796
|
+
"""
|
|
797
|
+
self.resources = resources
|
|
798
|
+
|
|
799
|
+
@classmethod
|
|
800
|
+
def from_dict(cls, _dict: Dict) -> 'InvitedUserList':
|
|
801
|
+
"""Initialize a InvitedUserList object from a json dictionary."""
|
|
802
|
+
args = {}
|
|
803
|
+
if 'resources' in _dict:
|
|
804
|
+
args['resources'] = [InvitedUser.from_dict(v) for v in _dict.get('resources')]
|
|
805
|
+
return cls(**args)
|
|
806
|
+
|
|
807
|
+
@classmethod
|
|
808
|
+
def _from_dict(cls, _dict):
|
|
809
|
+
"""Initialize a InvitedUserList object from a json dictionary."""
|
|
810
|
+
return cls.from_dict(_dict)
|
|
811
|
+
|
|
812
|
+
def to_dict(self) -> Dict:
|
|
813
|
+
"""Return a json dictionary representing this model."""
|
|
814
|
+
_dict = {}
|
|
815
|
+
if hasattr(self, 'resources') and self.resources is not None:
|
|
816
|
+
resources_list = []
|
|
817
|
+
for v in self.resources:
|
|
818
|
+
if isinstance(v, dict):
|
|
819
|
+
resources_list.append(v)
|
|
820
|
+
else:
|
|
821
|
+
resources_list.append(v.to_dict())
|
|
822
|
+
_dict['resources'] = resources_list
|
|
823
|
+
return _dict
|
|
824
|
+
|
|
825
|
+
def _to_dict(self):
|
|
826
|
+
"""Return a json dictionary representing this model."""
|
|
827
|
+
return self.to_dict()
|
|
828
|
+
|
|
829
|
+
def __str__(self) -> str:
|
|
830
|
+
"""Return a `str` version of this InvitedUserList object."""
|
|
831
|
+
return json.dumps(self.to_dict(), indent=2)
|
|
832
|
+
|
|
833
|
+
def __eq__(self, other: 'InvitedUserList') -> bool:
|
|
834
|
+
"""Return `true` when self and other are equal, false otherwise."""
|
|
835
|
+
if not isinstance(other, self.__class__):
|
|
836
|
+
return False
|
|
837
|
+
return self.__dict__ == other.__dict__
|
|
838
|
+
|
|
839
|
+
def __ne__(self, other: 'InvitedUserList') -> bool:
|
|
840
|
+
"""Return `true` when self and other are not equal, false otherwise."""
|
|
841
|
+
return not self == other
|
|
842
|
+
|
|
843
|
+
|
|
844
|
+
class UserList:
|
|
845
|
+
"""
|
|
846
|
+
The users returned.
|
|
847
|
+
|
|
848
|
+
:attr int total_results: The number of users returned.
|
|
849
|
+
:attr int limit: A limit to the number of users returned in a page.
|
|
850
|
+
:attr str first_url: (optional) The first URL of the get users API.
|
|
851
|
+
:attr str next_url: (optional) The next URL of the get users API.
|
|
852
|
+
:attr List[UserProfile] resources: (optional) A list of users in the account.
|
|
853
|
+
"""
|
|
854
|
+
|
|
855
|
+
def __init__(
|
|
856
|
+
self,
|
|
857
|
+
total_results: int,
|
|
858
|
+
limit: int,
|
|
859
|
+
*,
|
|
860
|
+
first_url: str = None,
|
|
861
|
+
next_url: str = None,
|
|
862
|
+
resources: List['UserProfile'] = None,
|
|
863
|
+
) -> None:
|
|
864
|
+
"""
|
|
865
|
+
Initialize a UserList object.
|
|
866
|
+
|
|
867
|
+
:param int total_results: The number of users returned.
|
|
868
|
+
:param int limit: A limit to the number of users returned in a page.
|
|
869
|
+
:param str first_url: (optional) The first URL of the get users API.
|
|
870
|
+
:param str next_url: (optional) The next URL of the get users API.
|
|
871
|
+
:param List[UserProfile] resources: (optional) A list of users in the
|
|
872
|
+
account.
|
|
873
|
+
"""
|
|
874
|
+
self.total_results = total_results
|
|
875
|
+
self.limit = limit
|
|
876
|
+
self.first_url = first_url
|
|
877
|
+
self.next_url = next_url
|
|
878
|
+
self.resources = resources
|
|
879
|
+
|
|
880
|
+
@classmethod
|
|
881
|
+
def from_dict(cls, _dict: Dict) -> 'UserList':
|
|
882
|
+
"""Initialize a UserList object from a json dictionary."""
|
|
883
|
+
args = {}
|
|
884
|
+
if 'total_results' in _dict:
|
|
885
|
+
args['total_results'] = _dict.get('total_results')
|
|
886
|
+
else:
|
|
887
|
+
raise ValueError('Required property \'total_results\' not present in UserList JSON')
|
|
888
|
+
if 'limit' in _dict:
|
|
889
|
+
args['limit'] = _dict.get('limit')
|
|
890
|
+
else:
|
|
891
|
+
raise ValueError('Required property \'limit\' not present in UserList JSON')
|
|
892
|
+
if 'first_url' in _dict:
|
|
893
|
+
args['first_url'] = _dict.get('first_url')
|
|
894
|
+
if 'next_url' in _dict:
|
|
895
|
+
args['next_url'] = _dict.get('next_url')
|
|
896
|
+
if 'resources' in _dict:
|
|
897
|
+
args['resources'] = [UserProfile.from_dict(v) for v in _dict.get('resources')]
|
|
898
|
+
return cls(**args)
|
|
899
|
+
|
|
900
|
+
@classmethod
|
|
901
|
+
def _from_dict(cls, _dict):
|
|
902
|
+
"""Initialize a UserList object from a json dictionary."""
|
|
903
|
+
return cls.from_dict(_dict)
|
|
904
|
+
|
|
905
|
+
def to_dict(self) -> Dict:
|
|
906
|
+
"""Return a json dictionary representing this model."""
|
|
907
|
+
_dict = {}
|
|
908
|
+
if hasattr(self, 'total_results') and self.total_results is not None:
|
|
909
|
+
_dict['total_results'] = self.total_results
|
|
910
|
+
if hasattr(self, 'limit') and self.limit is not None:
|
|
911
|
+
_dict['limit'] = self.limit
|
|
912
|
+
if hasattr(self, 'first_url') and self.first_url is not None:
|
|
913
|
+
_dict['first_url'] = self.first_url
|
|
914
|
+
if hasattr(self, 'next_url') and self.next_url is not None:
|
|
915
|
+
_dict['next_url'] = self.next_url
|
|
916
|
+
if hasattr(self, 'resources') and self.resources is not None:
|
|
917
|
+
resources_list = []
|
|
918
|
+
for v in self.resources:
|
|
919
|
+
if isinstance(v, dict):
|
|
920
|
+
resources_list.append(v)
|
|
921
|
+
else:
|
|
922
|
+
resources_list.append(v.to_dict())
|
|
923
|
+
_dict['resources'] = resources_list
|
|
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 UserList object."""
|
|
932
|
+
return json.dumps(self.to_dict(), indent=2)
|
|
933
|
+
|
|
934
|
+
def __eq__(self, other: 'UserList') -> 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: 'UserList') -> bool:
|
|
941
|
+
"""Return `true` when self and other are not equal, false otherwise."""
|
|
942
|
+
return not self == other
|
|
943
|
+
|
|
944
|
+
|
|
945
|
+
class UserProfile:
|
|
946
|
+
"""
|
|
947
|
+
Returned the user profile.
|
|
948
|
+
|
|
949
|
+
:attr str id: (optional) An alphanumeric value identifying the user profile.
|
|
950
|
+
:attr str iam_id: (optional) An alphanumeric value identifying the user's IAM
|
|
951
|
+
ID.
|
|
952
|
+
:attr str realm: (optional) The realm of the user. The value is either `IBMid`
|
|
953
|
+
or `SL`.
|
|
954
|
+
:attr str user_id: (optional) The user ID used for login.
|
|
955
|
+
:attr str firstname: (optional) The first name of the user.
|
|
956
|
+
:attr str lastname: (optional) The last name of the user.
|
|
957
|
+
:attr str state: (optional) The state of the user. Possible values are
|
|
958
|
+
`PROCESSING`, `PENDING`, `ACTIVE`, `DISABLED_CLASSIC_INFRASTRUCTURE`, and
|
|
959
|
+
`VPN_ONLY`.
|
|
960
|
+
:attr str email: (optional) The email address of the user.
|
|
961
|
+
:attr str phonenumber: (optional) The phone number of the user.
|
|
962
|
+
:attr str altphonenumber: (optional) The alternative phone number of the user.
|
|
963
|
+
:attr str photo: (optional) A link to a photo of the user.
|
|
964
|
+
:attr str account_id: (optional) An alphanumeric value identifying the account
|
|
965
|
+
ID.
|
|
966
|
+
:attr str added_on: (optional) The timestamp for when the user was added to the
|
|
967
|
+
account.
|
|
968
|
+
"""
|
|
969
|
+
|
|
970
|
+
def __init__(
|
|
971
|
+
self,
|
|
972
|
+
*,
|
|
973
|
+
id: str = None,
|
|
974
|
+
iam_id: str = None,
|
|
975
|
+
realm: str = None,
|
|
976
|
+
user_id: str = None,
|
|
977
|
+
firstname: str = None,
|
|
978
|
+
lastname: str = None,
|
|
979
|
+
state: str = None,
|
|
980
|
+
email: str = None,
|
|
981
|
+
phonenumber: str = None,
|
|
982
|
+
altphonenumber: str = None,
|
|
983
|
+
photo: str = None,
|
|
984
|
+
account_id: str = None,
|
|
985
|
+
added_on: str = None,
|
|
986
|
+
) -> None:
|
|
987
|
+
"""
|
|
988
|
+
Initialize a UserProfile object.
|
|
989
|
+
|
|
990
|
+
:param str id: (optional) An alphanumeric value identifying the user
|
|
991
|
+
profile.
|
|
992
|
+
:param str iam_id: (optional) An alphanumeric value identifying the user's
|
|
993
|
+
IAM ID.
|
|
994
|
+
:param str realm: (optional) The realm of the user. The value is either
|
|
995
|
+
`IBMid` or `SL`.
|
|
996
|
+
:param str user_id: (optional) The user ID used for login.
|
|
997
|
+
:param str firstname: (optional) The first name of the user.
|
|
998
|
+
:param str lastname: (optional) The last name of the user.
|
|
999
|
+
:param str state: (optional) The state of the user. Possible values are
|
|
1000
|
+
`PROCESSING`, `PENDING`, `ACTIVE`, `DISABLED_CLASSIC_INFRASTRUCTURE`, and
|
|
1001
|
+
`VPN_ONLY`.
|
|
1002
|
+
:param str email: (optional) The email address of the user.
|
|
1003
|
+
:param str phonenumber: (optional) The phone number of the user.
|
|
1004
|
+
:param str altphonenumber: (optional) The alternative phone number of the
|
|
1005
|
+
user.
|
|
1006
|
+
:param str photo: (optional) A link to a photo of the user.
|
|
1007
|
+
:param str account_id: (optional) An alphanumeric value identifying the
|
|
1008
|
+
account ID.
|
|
1009
|
+
:param str added_on: (optional) The timestamp for when the user was added
|
|
1010
|
+
to the account.
|
|
1011
|
+
"""
|
|
1012
|
+
self.id = id
|
|
1013
|
+
self.iam_id = iam_id
|
|
1014
|
+
self.realm = realm
|
|
1015
|
+
self.user_id = user_id
|
|
1016
|
+
self.firstname = firstname
|
|
1017
|
+
self.lastname = lastname
|
|
1018
|
+
self.state = state
|
|
1019
|
+
self.email = email
|
|
1020
|
+
self.phonenumber = phonenumber
|
|
1021
|
+
self.altphonenumber = altphonenumber
|
|
1022
|
+
self.photo = photo
|
|
1023
|
+
self.account_id = account_id
|
|
1024
|
+
self.added_on = added_on
|
|
1025
|
+
|
|
1026
|
+
@classmethod
|
|
1027
|
+
def from_dict(cls, _dict: Dict) -> 'UserProfile':
|
|
1028
|
+
"""Initialize a UserProfile object from a json dictionary."""
|
|
1029
|
+
args = {}
|
|
1030
|
+
if 'id' in _dict:
|
|
1031
|
+
args['id'] = _dict.get('id')
|
|
1032
|
+
if 'iam_id' in _dict:
|
|
1033
|
+
args['iam_id'] = _dict.get('iam_id')
|
|
1034
|
+
if 'realm' in _dict:
|
|
1035
|
+
args['realm'] = _dict.get('realm')
|
|
1036
|
+
if 'user_id' in _dict:
|
|
1037
|
+
args['user_id'] = _dict.get('user_id')
|
|
1038
|
+
if 'firstname' in _dict:
|
|
1039
|
+
args['firstname'] = _dict.get('firstname')
|
|
1040
|
+
if 'lastname' in _dict:
|
|
1041
|
+
args['lastname'] = _dict.get('lastname')
|
|
1042
|
+
if 'state' in _dict:
|
|
1043
|
+
args['state'] = _dict.get('state')
|
|
1044
|
+
if 'email' in _dict:
|
|
1045
|
+
args['email'] = _dict.get('email')
|
|
1046
|
+
if 'phonenumber' in _dict:
|
|
1047
|
+
args['phonenumber'] = _dict.get('phonenumber')
|
|
1048
|
+
if 'altphonenumber' in _dict:
|
|
1049
|
+
args['altphonenumber'] = _dict.get('altphonenumber')
|
|
1050
|
+
if 'photo' in _dict:
|
|
1051
|
+
args['photo'] = _dict.get('photo')
|
|
1052
|
+
if 'account_id' in _dict:
|
|
1053
|
+
args['account_id'] = _dict.get('account_id')
|
|
1054
|
+
if 'added_on' in _dict:
|
|
1055
|
+
args['added_on'] = _dict.get('added_on')
|
|
1056
|
+
return cls(**args)
|
|
1057
|
+
|
|
1058
|
+
@classmethod
|
|
1059
|
+
def _from_dict(cls, _dict):
|
|
1060
|
+
"""Initialize a UserProfile object from a json dictionary."""
|
|
1061
|
+
return cls.from_dict(_dict)
|
|
1062
|
+
|
|
1063
|
+
def to_dict(self) -> Dict:
|
|
1064
|
+
"""Return a json dictionary representing this model."""
|
|
1065
|
+
_dict = {}
|
|
1066
|
+
if hasattr(self, 'id') and self.id is not None:
|
|
1067
|
+
_dict['id'] = self.id
|
|
1068
|
+
if hasattr(self, 'iam_id') and self.iam_id is not None:
|
|
1069
|
+
_dict['iam_id'] = self.iam_id
|
|
1070
|
+
if hasattr(self, 'realm') and self.realm is not None:
|
|
1071
|
+
_dict['realm'] = self.realm
|
|
1072
|
+
if hasattr(self, 'user_id') and self.user_id is not None:
|
|
1073
|
+
_dict['user_id'] = self.user_id
|
|
1074
|
+
if hasattr(self, 'firstname') and self.firstname is not None:
|
|
1075
|
+
_dict['firstname'] = self.firstname
|
|
1076
|
+
if hasattr(self, 'lastname') and self.lastname is not None:
|
|
1077
|
+
_dict['lastname'] = self.lastname
|
|
1078
|
+
if hasattr(self, 'state') and self.state is not None:
|
|
1079
|
+
_dict['state'] = self.state
|
|
1080
|
+
if hasattr(self, 'email') and self.email is not None:
|
|
1081
|
+
_dict['email'] = self.email
|
|
1082
|
+
if hasattr(self, 'phonenumber') and self.phonenumber is not None:
|
|
1083
|
+
_dict['phonenumber'] = self.phonenumber
|
|
1084
|
+
if hasattr(self, 'altphonenumber') and self.altphonenumber is not None:
|
|
1085
|
+
_dict['altphonenumber'] = self.altphonenumber
|
|
1086
|
+
if hasattr(self, 'photo') and self.photo is not None:
|
|
1087
|
+
_dict['photo'] = self.photo
|
|
1088
|
+
if hasattr(self, 'account_id') and self.account_id is not None:
|
|
1089
|
+
_dict['account_id'] = self.account_id
|
|
1090
|
+
if hasattr(self, 'added_on') and self.added_on is not None:
|
|
1091
|
+
_dict['added_on'] = self.added_on
|
|
1092
|
+
return _dict
|
|
1093
|
+
|
|
1094
|
+
def _to_dict(self):
|
|
1095
|
+
"""Return a json dictionary representing this model."""
|
|
1096
|
+
return self.to_dict()
|
|
1097
|
+
|
|
1098
|
+
def __str__(self) -> str:
|
|
1099
|
+
"""Return a `str` version of this UserProfile object."""
|
|
1100
|
+
return json.dumps(self.to_dict(), indent=2)
|
|
1101
|
+
|
|
1102
|
+
def __eq__(self, other: 'UserProfile') -> bool:
|
|
1103
|
+
"""Return `true` when self and other are equal, false otherwise."""
|
|
1104
|
+
if not isinstance(other, self.__class__):
|
|
1105
|
+
return False
|
|
1106
|
+
return self.__dict__ == other.__dict__
|
|
1107
|
+
|
|
1108
|
+
def __ne__(self, other: 'UserProfile') -> bool:
|
|
1109
|
+
"""Return `true` when self and other are not equal, false otherwise."""
|
|
1110
|
+
return not self == other
|
|
1111
|
+
|
|
1112
|
+
|
|
1113
|
+
class UserSettings:
|
|
1114
|
+
"""
|
|
1115
|
+
The user settings returned.
|
|
1116
|
+
|
|
1117
|
+
:attr str language: (optional) The console UI language. By default, this field
|
|
1118
|
+
is empty.
|
|
1119
|
+
:attr str notification_language: (optional) The language for email and phone
|
|
1120
|
+
notifications. By default, this field is empty.
|
|
1121
|
+
:attr str allowed_ip_addresses: (optional) A comma-separated list of IP
|
|
1122
|
+
addresses.
|
|
1123
|
+
:attr bool self_manage: (optional) Whether user managed login is enabled. The
|
|
1124
|
+
default value is `false`.
|
|
1125
|
+
"""
|
|
1126
|
+
|
|
1127
|
+
def __init__(
|
|
1128
|
+
self,
|
|
1129
|
+
*,
|
|
1130
|
+
language: str = None,
|
|
1131
|
+
notification_language: str = None,
|
|
1132
|
+
allowed_ip_addresses: str = None,
|
|
1133
|
+
self_manage: bool = None,
|
|
1134
|
+
) -> None:
|
|
1135
|
+
"""
|
|
1136
|
+
Initialize a UserSettings object.
|
|
1137
|
+
|
|
1138
|
+
:param str language: (optional) The console UI language. By default, this
|
|
1139
|
+
field is empty.
|
|
1140
|
+
:param str notification_language: (optional) The language for email and
|
|
1141
|
+
phone notifications. By default, this field is empty.
|
|
1142
|
+
:param str allowed_ip_addresses: (optional) A comma-separated list of IP
|
|
1143
|
+
addresses.
|
|
1144
|
+
:param bool self_manage: (optional) Whether user managed login is enabled.
|
|
1145
|
+
The default value is `false`.
|
|
1146
|
+
"""
|
|
1147
|
+
self.language = language
|
|
1148
|
+
self.notification_language = notification_language
|
|
1149
|
+
self.allowed_ip_addresses = allowed_ip_addresses
|
|
1150
|
+
self.self_manage = self_manage
|
|
1151
|
+
|
|
1152
|
+
@classmethod
|
|
1153
|
+
def from_dict(cls, _dict: Dict) -> 'UserSettings':
|
|
1154
|
+
"""Initialize a UserSettings object from a json dictionary."""
|
|
1155
|
+
args = {}
|
|
1156
|
+
if 'language' in _dict:
|
|
1157
|
+
args['language'] = _dict.get('language')
|
|
1158
|
+
if 'notification_language' in _dict:
|
|
1159
|
+
args['notification_language'] = _dict.get('notification_language')
|
|
1160
|
+
if 'allowed_ip_addresses' in _dict:
|
|
1161
|
+
args['allowed_ip_addresses'] = _dict.get('allowed_ip_addresses')
|
|
1162
|
+
if 'self_manage' in _dict:
|
|
1163
|
+
args['self_manage'] = _dict.get('self_manage')
|
|
1164
|
+
return cls(**args)
|
|
1165
|
+
|
|
1166
|
+
@classmethod
|
|
1167
|
+
def _from_dict(cls, _dict):
|
|
1168
|
+
"""Initialize a UserSettings object from a json dictionary."""
|
|
1169
|
+
return cls.from_dict(_dict)
|
|
1170
|
+
|
|
1171
|
+
def to_dict(self) -> Dict:
|
|
1172
|
+
"""Return a json dictionary representing this model."""
|
|
1173
|
+
_dict = {}
|
|
1174
|
+
if hasattr(self, 'language') and self.language is not None:
|
|
1175
|
+
_dict['language'] = self.language
|
|
1176
|
+
if hasattr(self, 'notification_language') and self.notification_language is not None:
|
|
1177
|
+
_dict['notification_language'] = self.notification_language
|
|
1178
|
+
if hasattr(self, 'allowed_ip_addresses') and self.allowed_ip_addresses is not None:
|
|
1179
|
+
_dict['allowed_ip_addresses'] = self.allowed_ip_addresses
|
|
1180
|
+
if hasattr(self, 'self_manage') and self.self_manage is not None:
|
|
1181
|
+
_dict['self_manage'] = self.self_manage
|
|
1182
|
+
return _dict
|
|
1183
|
+
|
|
1184
|
+
def _to_dict(self):
|
|
1185
|
+
"""Return a json dictionary representing this model."""
|
|
1186
|
+
return self.to_dict()
|
|
1187
|
+
|
|
1188
|
+
def __str__(self) -> str:
|
|
1189
|
+
"""Return a `str` version of this UserSettings object."""
|
|
1190
|
+
return json.dumps(self.to_dict(), indent=2)
|
|
1191
|
+
|
|
1192
|
+
def __eq__(self, other: 'UserSettings') -> bool:
|
|
1193
|
+
"""Return `true` when self and other are equal, false otherwise."""
|
|
1194
|
+
if not isinstance(other, self.__class__):
|
|
1195
|
+
return False
|
|
1196
|
+
return self.__dict__ == other.__dict__
|
|
1197
|
+
|
|
1198
|
+
def __ne__(self, other: 'UserSettings') -> bool:
|
|
1199
|
+
"""Return `true` when self and other are not equal, false otherwise."""
|
|
1200
|
+
return not self == other
|
|
1201
|
+
|
|
1202
|
+
|
|
1203
|
+
class Attribute:
|
|
1204
|
+
"""
|
|
1205
|
+
An attribute/value pair.
|
|
1206
|
+
|
|
1207
|
+
:attr str name: (optional) The name of the attribute.
|
|
1208
|
+
:attr str value: (optional) The value of the attribute.
|
|
1209
|
+
"""
|
|
1210
|
+
|
|
1211
|
+
def __init__(
|
|
1212
|
+
self,
|
|
1213
|
+
*,
|
|
1214
|
+
name: str = None,
|
|
1215
|
+
value: str = None,
|
|
1216
|
+
) -> None:
|
|
1217
|
+
"""
|
|
1218
|
+
Initialize a Attribute object.
|
|
1219
|
+
|
|
1220
|
+
:param str name: (optional) The name of the attribute.
|
|
1221
|
+
:param str value: (optional) The value of the attribute.
|
|
1222
|
+
"""
|
|
1223
|
+
self.name = name
|
|
1224
|
+
self.value = value
|
|
1225
|
+
|
|
1226
|
+
@classmethod
|
|
1227
|
+
def from_dict(cls, _dict: Dict) -> 'Attribute':
|
|
1228
|
+
"""Initialize a Attribute object from a json dictionary."""
|
|
1229
|
+
args = {}
|
|
1230
|
+
if 'name' in _dict:
|
|
1231
|
+
args['name'] = _dict.get('name')
|
|
1232
|
+
if 'value' in _dict:
|
|
1233
|
+
args['value'] = _dict.get('value')
|
|
1234
|
+
return cls(**args)
|
|
1235
|
+
|
|
1236
|
+
@classmethod
|
|
1237
|
+
def _from_dict(cls, _dict):
|
|
1238
|
+
"""Initialize a Attribute object from a json dictionary."""
|
|
1239
|
+
return cls.from_dict(_dict)
|
|
1240
|
+
|
|
1241
|
+
def to_dict(self) -> Dict:
|
|
1242
|
+
"""Return a json dictionary representing this model."""
|
|
1243
|
+
_dict = {}
|
|
1244
|
+
if hasattr(self, 'name') and self.name is not None:
|
|
1245
|
+
_dict['name'] = self.name
|
|
1246
|
+
if hasattr(self, 'value') and self.value is not None:
|
|
1247
|
+
_dict['value'] = self.value
|
|
1248
|
+
return _dict
|
|
1249
|
+
|
|
1250
|
+
def _to_dict(self):
|
|
1251
|
+
"""Return a json dictionary representing this model."""
|
|
1252
|
+
return self.to_dict()
|
|
1253
|
+
|
|
1254
|
+
def __str__(self) -> str:
|
|
1255
|
+
"""Return a `str` version of this Attribute object."""
|
|
1256
|
+
return json.dumps(self.to_dict(), indent=2)
|
|
1257
|
+
|
|
1258
|
+
def __eq__(self, other: 'Attribute') -> bool:
|
|
1259
|
+
"""Return `true` when self and other are equal, false otherwise."""
|
|
1260
|
+
if not isinstance(other, self.__class__):
|
|
1261
|
+
return False
|
|
1262
|
+
return self.__dict__ == other.__dict__
|
|
1263
|
+
|
|
1264
|
+
def __ne__(self, other: 'Attribute') -> bool:
|
|
1265
|
+
"""Return `true` when self and other are not equal, false otherwise."""
|
|
1266
|
+
return not self == other
|
|
1267
|
+
|
|
1268
|
+
|
|
1269
|
+
class InviteUser:
|
|
1270
|
+
"""
|
|
1271
|
+
Invite a user.
|
|
1272
|
+
|
|
1273
|
+
:attr str email: (optional) The email of the user to be invited.
|
|
1274
|
+
:attr str account_role: (optional) The account role of the user to be invited.
|
|
1275
|
+
"""
|
|
1276
|
+
|
|
1277
|
+
def __init__(
|
|
1278
|
+
self,
|
|
1279
|
+
*,
|
|
1280
|
+
email: str = None,
|
|
1281
|
+
account_role: str = None,
|
|
1282
|
+
) -> None:
|
|
1283
|
+
"""
|
|
1284
|
+
Initialize a InviteUser object.
|
|
1285
|
+
|
|
1286
|
+
:param str email: (optional) The email of the user to be invited.
|
|
1287
|
+
:param str account_role: (optional) The account role of the user to be
|
|
1288
|
+
invited.
|
|
1289
|
+
"""
|
|
1290
|
+
self.email = email
|
|
1291
|
+
self.account_role = account_role
|
|
1292
|
+
|
|
1293
|
+
@classmethod
|
|
1294
|
+
def from_dict(cls, _dict: Dict) -> 'InviteUser':
|
|
1295
|
+
"""Initialize a InviteUser object from a json dictionary."""
|
|
1296
|
+
args = {}
|
|
1297
|
+
if 'email' in _dict:
|
|
1298
|
+
args['email'] = _dict.get('email')
|
|
1299
|
+
if 'account_role' in _dict:
|
|
1300
|
+
args['account_role'] = _dict.get('account_role')
|
|
1301
|
+
return cls(**args)
|
|
1302
|
+
|
|
1303
|
+
@classmethod
|
|
1304
|
+
def _from_dict(cls, _dict):
|
|
1305
|
+
"""Initialize a InviteUser object from a json dictionary."""
|
|
1306
|
+
return cls.from_dict(_dict)
|
|
1307
|
+
|
|
1308
|
+
def to_dict(self) -> Dict:
|
|
1309
|
+
"""Return a json dictionary representing this model."""
|
|
1310
|
+
_dict = {}
|
|
1311
|
+
if hasattr(self, 'email') and self.email is not None:
|
|
1312
|
+
_dict['email'] = self.email
|
|
1313
|
+
if hasattr(self, 'account_role') and self.account_role is not None:
|
|
1314
|
+
_dict['account_role'] = self.account_role
|
|
1315
|
+
return _dict
|
|
1316
|
+
|
|
1317
|
+
def _to_dict(self):
|
|
1318
|
+
"""Return a json dictionary representing this model."""
|
|
1319
|
+
return self.to_dict()
|
|
1320
|
+
|
|
1321
|
+
def __str__(self) -> str:
|
|
1322
|
+
"""Return a `str` version of this InviteUser object."""
|
|
1323
|
+
return json.dumps(self.to_dict(), indent=2)
|
|
1324
|
+
|
|
1325
|
+
def __eq__(self, other: 'InviteUser') -> bool:
|
|
1326
|
+
"""Return `true` when self and other are equal, false otherwise."""
|
|
1327
|
+
if not isinstance(other, self.__class__):
|
|
1328
|
+
return False
|
|
1329
|
+
return self.__dict__ == other.__dict__
|
|
1330
|
+
|
|
1331
|
+
def __ne__(self, other: 'InviteUser') -> bool:
|
|
1332
|
+
"""Return `true` when self and other are not equal, false otherwise."""
|
|
1333
|
+
return not self == other
|
|
1334
|
+
|
|
1335
|
+
|
|
1336
|
+
class InviteUserIamPolicy:
|
|
1337
|
+
"""
|
|
1338
|
+
Invite a user to an IAM policy.
|
|
1339
|
+
|
|
1340
|
+
:attr str type: The policy type. This can be either "access" or "authorization".
|
|
1341
|
+
:attr List[Role] roles: (optional) A list of IAM roles.
|
|
1342
|
+
:attr List[Resource] resources: (optional) A list of resources.
|
|
1343
|
+
"""
|
|
1344
|
+
|
|
1345
|
+
def __init__(
|
|
1346
|
+
self,
|
|
1347
|
+
type: str,
|
|
1348
|
+
*,
|
|
1349
|
+
roles: List['Role'] = None,
|
|
1350
|
+
resources: List['Resource'] = None,
|
|
1351
|
+
) -> None:
|
|
1352
|
+
"""
|
|
1353
|
+
Initialize a InviteUserIamPolicy object.
|
|
1354
|
+
|
|
1355
|
+
:param str type: The policy type. This can be either "access" or
|
|
1356
|
+
"authorization".
|
|
1357
|
+
:param List[Role] roles: (optional) A list of IAM roles.
|
|
1358
|
+
:param List[Resource] resources: (optional) A list of resources.
|
|
1359
|
+
"""
|
|
1360
|
+
self.type = type
|
|
1361
|
+
self.roles = roles
|
|
1362
|
+
self.resources = resources
|
|
1363
|
+
|
|
1364
|
+
@classmethod
|
|
1365
|
+
def from_dict(cls, _dict: Dict) -> 'InviteUserIamPolicy':
|
|
1366
|
+
"""Initialize a InviteUserIamPolicy object from a json dictionary."""
|
|
1367
|
+
args = {}
|
|
1368
|
+
if 'type' in _dict:
|
|
1369
|
+
args['type'] = _dict.get('type')
|
|
1370
|
+
else:
|
|
1371
|
+
raise ValueError('Required property \'type\' not present in InviteUserIamPolicy JSON')
|
|
1372
|
+
if 'roles' in _dict:
|
|
1373
|
+
args['roles'] = [Role.from_dict(v) for v in _dict.get('roles')]
|
|
1374
|
+
if 'resources' in _dict:
|
|
1375
|
+
args['resources'] = [Resource.from_dict(v) for v in _dict.get('resources')]
|
|
1376
|
+
return cls(**args)
|
|
1377
|
+
|
|
1378
|
+
@classmethod
|
|
1379
|
+
def _from_dict(cls, _dict):
|
|
1380
|
+
"""Initialize a InviteUserIamPolicy object from a json dictionary."""
|
|
1381
|
+
return cls.from_dict(_dict)
|
|
1382
|
+
|
|
1383
|
+
def to_dict(self) -> Dict:
|
|
1384
|
+
"""Return a json dictionary representing this model."""
|
|
1385
|
+
_dict = {}
|
|
1386
|
+
if hasattr(self, 'type') and self.type is not None:
|
|
1387
|
+
_dict['type'] = self.type
|
|
1388
|
+
if hasattr(self, 'roles') and self.roles is not None:
|
|
1389
|
+
roles_list = []
|
|
1390
|
+
for v in self.roles:
|
|
1391
|
+
if isinstance(v, dict):
|
|
1392
|
+
roles_list.append(v)
|
|
1393
|
+
else:
|
|
1394
|
+
roles_list.append(v.to_dict())
|
|
1395
|
+
_dict['roles'] = roles_list
|
|
1396
|
+
if hasattr(self, 'resources') and self.resources is not None:
|
|
1397
|
+
resources_list = []
|
|
1398
|
+
for v in self.resources:
|
|
1399
|
+
if isinstance(v, dict):
|
|
1400
|
+
resources_list.append(v)
|
|
1401
|
+
else:
|
|
1402
|
+
resources_list.append(v.to_dict())
|
|
1403
|
+
_dict['resources'] = resources_list
|
|
1404
|
+
return _dict
|
|
1405
|
+
|
|
1406
|
+
def _to_dict(self):
|
|
1407
|
+
"""Return a json dictionary representing this model."""
|
|
1408
|
+
return self.to_dict()
|
|
1409
|
+
|
|
1410
|
+
def __str__(self) -> str:
|
|
1411
|
+
"""Return a `str` version of this InviteUserIamPolicy object."""
|
|
1412
|
+
return json.dumps(self.to_dict(), indent=2)
|
|
1413
|
+
|
|
1414
|
+
def __eq__(self, other: 'InviteUserIamPolicy') -> bool:
|
|
1415
|
+
"""Return `true` when self and other are equal, false otherwise."""
|
|
1416
|
+
if not isinstance(other, self.__class__):
|
|
1417
|
+
return False
|
|
1418
|
+
return self.__dict__ == other.__dict__
|
|
1419
|
+
|
|
1420
|
+
def __ne__(self, other: 'InviteUserIamPolicy') -> bool:
|
|
1421
|
+
"""Return `true` when self and other are not equal, false otherwise."""
|
|
1422
|
+
return not self == other
|
|
1423
|
+
|
|
1424
|
+
|
|
1425
|
+
class Resource:
|
|
1426
|
+
"""
|
|
1427
|
+
A collection of attribute value pairs.
|
|
1428
|
+
|
|
1429
|
+
:attr List[Attribute] attributes: (optional) A list of IAM attributes.
|
|
1430
|
+
"""
|
|
1431
|
+
|
|
1432
|
+
def __init__(
|
|
1433
|
+
self,
|
|
1434
|
+
*,
|
|
1435
|
+
attributes: List['Attribute'] = None,
|
|
1436
|
+
) -> None:
|
|
1437
|
+
"""
|
|
1438
|
+
Initialize a Resource object.
|
|
1439
|
+
|
|
1440
|
+
:param List[Attribute] attributes: (optional) A list of IAM attributes.
|
|
1441
|
+
"""
|
|
1442
|
+
self.attributes = attributes
|
|
1443
|
+
|
|
1444
|
+
@classmethod
|
|
1445
|
+
def from_dict(cls, _dict: Dict) -> 'Resource':
|
|
1446
|
+
"""Initialize a Resource object from a json dictionary."""
|
|
1447
|
+
args = {}
|
|
1448
|
+
if 'attributes' in _dict:
|
|
1449
|
+
args['attributes'] = [Attribute.from_dict(v) for v in _dict.get('attributes')]
|
|
1450
|
+
return cls(**args)
|
|
1451
|
+
|
|
1452
|
+
@classmethod
|
|
1453
|
+
def _from_dict(cls, _dict):
|
|
1454
|
+
"""Initialize a Resource object from a json dictionary."""
|
|
1455
|
+
return cls.from_dict(_dict)
|
|
1456
|
+
|
|
1457
|
+
def to_dict(self) -> Dict:
|
|
1458
|
+
"""Return a json dictionary representing this model."""
|
|
1459
|
+
_dict = {}
|
|
1460
|
+
if hasattr(self, 'attributes') and self.attributes is not None:
|
|
1461
|
+
attributes_list = []
|
|
1462
|
+
for v in self.attributes:
|
|
1463
|
+
if isinstance(v, dict):
|
|
1464
|
+
attributes_list.append(v)
|
|
1465
|
+
else:
|
|
1466
|
+
attributes_list.append(v.to_dict())
|
|
1467
|
+
_dict['attributes'] = attributes_list
|
|
1468
|
+
return _dict
|
|
1469
|
+
|
|
1470
|
+
def _to_dict(self):
|
|
1471
|
+
"""Return a json dictionary representing this model."""
|
|
1472
|
+
return self.to_dict()
|
|
1473
|
+
|
|
1474
|
+
def __str__(self) -> str:
|
|
1475
|
+
"""Return a `str` version of this Resource object."""
|
|
1476
|
+
return json.dumps(self.to_dict(), indent=2)
|
|
1477
|
+
|
|
1478
|
+
def __eq__(self, other: 'Resource') -> bool:
|
|
1479
|
+
"""Return `true` when self and other are equal, false otherwise."""
|
|
1480
|
+
if not isinstance(other, self.__class__):
|
|
1481
|
+
return False
|
|
1482
|
+
return self.__dict__ == other.__dict__
|
|
1483
|
+
|
|
1484
|
+
def __ne__(self, other: 'Resource') -> bool:
|
|
1485
|
+
"""Return `true` when self and other are not equal, false otherwise."""
|
|
1486
|
+
return not self == other
|
|
1487
|
+
|
|
1488
|
+
|
|
1489
|
+
class Role:
|
|
1490
|
+
"""
|
|
1491
|
+
The role of an IAM policy.
|
|
1492
|
+
|
|
1493
|
+
:attr str role_id: (optional) An alphanumeric value identifying the origin.
|
|
1494
|
+
"""
|
|
1495
|
+
|
|
1496
|
+
def __init__(
|
|
1497
|
+
self,
|
|
1498
|
+
*,
|
|
1499
|
+
role_id: str = None,
|
|
1500
|
+
) -> None:
|
|
1501
|
+
"""
|
|
1502
|
+
Initialize a Role object.
|
|
1503
|
+
|
|
1504
|
+
:param str role_id: (optional) An alphanumeric value identifying the
|
|
1505
|
+
origin.
|
|
1506
|
+
"""
|
|
1507
|
+
self.role_id = role_id
|
|
1508
|
+
|
|
1509
|
+
@classmethod
|
|
1510
|
+
def from_dict(cls, _dict: Dict) -> 'Role':
|
|
1511
|
+
"""Initialize a Role object from a json dictionary."""
|
|
1512
|
+
args = {}
|
|
1513
|
+
if 'role_id' in _dict:
|
|
1514
|
+
args['role_id'] = _dict.get('role_id')
|
|
1515
|
+
return cls(**args)
|
|
1516
|
+
|
|
1517
|
+
@classmethod
|
|
1518
|
+
def _from_dict(cls, _dict):
|
|
1519
|
+
"""Initialize a Role object from a json dictionary."""
|
|
1520
|
+
return cls.from_dict(_dict)
|
|
1521
|
+
|
|
1522
|
+
def to_dict(self) -> Dict:
|
|
1523
|
+
"""Return a json dictionary representing this model."""
|
|
1524
|
+
_dict = {}
|
|
1525
|
+
if hasattr(self, 'role_id') and self.role_id is not None:
|
|
1526
|
+
_dict['role_id'] = self.role_id
|
|
1527
|
+
return _dict
|
|
1528
|
+
|
|
1529
|
+
def _to_dict(self):
|
|
1530
|
+
"""Return a json dictionary representing this model."""
|
|
1531
|
+
return self.to_dict()
|
|
1532
|
+
|
|
1533
|
+
def __str__(self) -> str:
|
|
1534
|
+
"""Return a `str` version of this Role object."""
|
|
1535
|
+
return json.dumps(self.to_dict(), indent=2)
|
|
1536
|
+
|
|
1537
|
+
def __eq__(self, other: 'Role') -> bool:
|
|
1538
|
+
"""Return `true` when self and other are equal, false otherwise."""
|
|
1539
|
+
if not isinstance(other, self.__class__):
|
|
1540
|
+
return False
|
|
1541
|
+
return self.__dict__ == other.__dict__
|
|
1542
|
+
|
|
1543
|
+
def __ne__(self, other: 'Role') -> bool:
|
|
1544
|
+
"""Return `true` when self and other are not equal, false otherwise."""
|
|
1545
|
+
return not self == other
|
|
1546
|
+
|
|
1547
|
+
|
|
1548
|
+
##############################################################################
|
|
1549
|
+
# Pagers
|
|
1550
|
+
##############################################################################
|
|
1551
|
+
|
|
1552
|
+
|
|
1553
|
+
class UsersPager:
|
|
1554
|
+
"""
|
|
1555
|
+
UsersPager can be used to simplify the use of the "list_users" method.
|
|
1556
|
+
"""
|
|
1557
|
+
|
|
1558
|
+
def __init__(
|
|
1559
|
+
self,
|
|
1560
|
+
*,
|
|
1561
|
+
client: UserManagementV1,
|
|
1562
|
+
account_id: str,
|
|
1563
|
+
limit: int = None,
|
|
1564
|
+
include_settings: bool = None,
|
|
1565
|
+
search: str = None,
|
|
1566
|
+
user_id: str = None,
|
|
1567
|
+
) -> None:
|
|
1568
|
+
"""
|
|
1569
|
+
Initialize a UsersPager object.
|
|
1570
|
+
:param str account_id: The account ID of the specified user.
|
|
1571
|
+
:param int limit: (optional) The number of results to be returned.
|
|
1572
|
+
:param bool include_settings: (optional) The user settings to be returned.
|
|
1573
|
+
Set to true to view language, allowed IP address, and authentication
|
|
1574
|
+
settings.
|
|
1575
|
+
:param str search: (optional) The desired search results to be returned. To
|
|
1576
|
+
view the list of users with the additional search filter, use the following
|
|
1577
|
+
query options: `firstname`, `lastname`, `email`, `state`, `substate`,
|
|
1578
|
+
`iam_id`, `realm`, and `userId`. HTML URL encoding for the search query and
|
|
1579
|
+
`:` must be used. For example, search=state%3AINVALID returns a list of
|
|
1580
|
+
invalid users. Multiple search queries can be combined to obtain `OR`
|
|
1581
|
+
results using `,` operator (not URL encoded). For example,
|
|
1582
|
+
search=state%3AINVALID,email%3Amail.test.ibm.com.
|
|
1583
|
+
:param str user_id: (optional) Filter users based on their user ID.
|
|
1584
|
+
"""
|
|
1585
|
+
self._has_next = True
|
|
1586
|
+
self._client = client
|
|
1587
|
+
self._page_context = {'next': None}
|
|
1588
|
+
self._account_id = account_id
|
|
1589
|
+
self._limit = limit
|
|
1590
|
+
self._include_settings = include_settings
|
|
1591
|
+
self._search = search
|
|
1592
|
+
self._user_id = user_id
|
|
1593
|
+
|
|
1594
|
+
def has_next(self) -> bool:
|
|
1595
|
+
"""
|
|
1596
|
+
Returns true if there are potentially more results to be retrieved.
|
|
1597
|
+
"""
|
|
1598
|
+
return self._has_next
|
|
1599
|
+
|
|
1600
|
+
def get_next(self) -> List[dict]:
|
|
1601
|
+
"""
|
|
1602
|
+
Returns the next page of results.
|
|
1603
|
+
:return: A List[dict], where each element is a dict that represents an instance of UserProfile.
|
|
1604
|
+
:rtype: List[dict]
|
|
1605
|
+
"""
|
|
1606
|
+
if not self.has_next():
|
|
1607
|
+
raise StopIteration(message='No more results available')
|
|
1608
|
+
|
|
1609
|
+
result = self._client.list_users(
|
|
1610
|
+
account_id=self._account_id,
|
|
1611
|
+
limit=self._limit,
|
|
1612
|
+
include_settings=self._include_settings,
|
|
1613
|
+
search=self._search,
|
|
1614
|
+
user_id=self._user_id,
|
|
1615
|
+
start=self._page_context.get('next'),
|
|
1616
|
+
).get_result()
|
|
1617
|
+
|
|
1618
|
+
next = None
|
|
1619
|
+
next_page_link = result.get('next_url')
|
|
1620
|
+
if next_page_link is not None:
|
|
1621
|
+
next = get_query_param(next_page_link, '_start')
|
|
1622
|
+
self._page_context['next'] = next
|
|
1623
|
+
if next is None:
|
|
1624
|
+
self._has_next = False
|
|
1625
|
+
|
|
1626
|
+
return result.get('resources')
|
|
1627
|
+
|
|
1628
|
+
def get_all(self) -> List[dict]:
|
|
1629
|
+
"""
|
|
1630
|
+
Returns all results by invoking get_next() repeatedly
|
|
1631
|
+
until all pages of results have been retrieved.
|
|
1632
|
+
:return: A List[dict], where each element is a dict that represents an instance of UserProfile.
|
|
1633
|
+
:rtype: List[dict]
|
|
1634
|
+
"""
|
|
1635
|
+
results = []
|
|
1636
|
+
while self.has_next():
|
|
1637
|
+
next_page = self.get_next()
|
|
1638
|
+
results.extend(next_page)
|
|
1639
|
+
return results
|