Skip to content

Commit 56255bf

Browse files
committed
fix(User Management): re-gen user-mgmt service
1 parent c550ef9 commit 56255bf

File tree

3 files changed

+216
-24
lines changed

3 files changed

+216
-24
lines changed

ibm_platform_services/user_management_v1.py

Lines changed: 40 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616

17-
# IBM OpenAPI SDK Code Generator Version: 99-SNAPSHOT-7811f8fb-20200813-160653
17+
# IBM OpenAPI SDK Code Generator Version: 99-SNAPSHOT-ef5e13c2-20200915-144510
1818

1919
"""
2020
Manage the lifecycle of your users using User Management APIs.
@@ -116,8 +116,10 @@ def get_user_settings(self,
116116
headers.update(kwargs.get('headers'))
117117
headers['Accept'] = 'application/json'
118118

119-
url = '/v2/accounts/{0}/users/{1}/settings'.format(
120-
*self.encode_path_vars(account_id, iam_id))
119+
path_param_keys = ['account_id', 'iam_id']
120+
path_param_values = self.encode_path_vars(account_id, iam_id)
121+
path_param_dict = dict(zip(path_param_keys, path_param_values))
122+
url = '/v2/accounts/{account_id}/users/{iam_id}/settings'.format(**path_param_dict)
121123
request = self.prepare_request(method='GET',
122124
url=url,
123125
headers=headers)
@@ -185,8 +187,10 @@ def update_user_settings(self,
185187
headers.update(kwargs.get('headers'))
186188
headers['Accept'] = 'application/json'
187189

188-
url = '/v2/accounts/{0}/users/{1}/settings'.format(
189-
*self.encode_path_vars(account_id, iam_id))
190+
path_param_keys = ['account_id', 'iam_id']
191+
path_param_values = self.encode_path_vars(account_id, iam_id)
192+
path_param_dict = dict(zip(path_param_keys, path_param_values))
193+
url = '/v2/accounts/{account_id}/users/{iam_id}/settings'.format(**path_param_dict)
190194
request = self.prepare_request(method='PATCH',
191195
url=url,
192196
headers=headers,
@@ -243,8 +247,10 @@ def list_users(self,
243247
headers.update(kwargs.get('headers'))
244248
headers['Accept'] = 'application/json'
245249

246-
url = '/v2/accounts/{0}/users'.format(
247-
*self.encode_path_vars(account_id))
250+
path_param_keys = ['account_id']
251+
path_param_values = self.encode_path_vars(account_id)
252+
path_param_dict = dict(zip(path_param_keys, path_param_values))
253+
url = '/v2/accounts/{account_id}/users'.format(**path_param_dict)
248254
request = self.prepare_request(method='GET',
249255
url=url,
250256
headers=headers,
@@ -313,8 +319,10 @@ def invite_users(self,
313319
headers.update(kwargs.get('headers'))
314320
headers['Accept'] = 'application/json'
315321

316-
url = '/v2/accounts/{0}/users'.format(
317-
*self.encode_path_vars(account_id))
322+
path_param_keys = ['account_id']
323+
path_param_values = self.encode_path_vars(account_id)
324+
path_param_dict = dict(zip(path_param_keys, path_param_values))
325+
url = '/v2/accounts/{account_id}/users'.format(**path_param_dict)
318326
request = self.prepare_request(method='POST',
319327
url=url,
320328
headers=headers,
@@ -358,8 +366,10 @@ def get_user_profile(self,
358366
headers.update(kwargs.get('headers'))
359367
headers['Accept'] = 'application/json'
360368

361-
url = '/v2/accounts/{0}/users/{1}'.format(
362-
*self.encode_path_vars(account_id, iam_id))
369+
path_param_keys = ['account_id', 'iam_id']
370+
path_param_values = self.encode_path_vars(account_id, iam_id)
371+
path_param_dict = dict(zip(path_param_keys, path_param_values))
372+
url = '/v2/accounts/{account_id}/users/{iam_id}'.format(**path_param_dict)
363373
request = self.prepare_request(method='GET',
364374
url=url,
365375
headers=headers)
@@ -436,8 +446,10 @@ def update_user_profiles(self,
436446
if 'headers' in kwargs:
437447
headers.update(kwargs.get('headers'))
438448

439-
url = '/v2/accounts/{0}/users/{1}'.format(
440-
*self.encode_path_vars(account_id, iam_id))
449+
path_param_keys = ['account_id', 'iam_id']
450+
path_param_values = self.encode_path_vars(account_id, iam_id)
451+
path_param_dict = dict(zip(path_param_keys, path_param_values))
452+
url = '/v2/accounts/{account_id}/users/{iam_id}'.format(**path_param_dict)
441453
request = self.prepare_request(method='PATCH',
442454
url=url,
443455
headers=headers,
@@ -481,8 +493,10 @@ def remove_users(self,
481493
if 'headers' in kwargs:
482494
headers.update(kwargs.get('headers'))
483495

484-
url = '/v2/accounts/{0}/users/{1}'.format(
485-
*self.encode_path_vars(account_id, iam_id))
496+
path_param_keys = ['account_id', 'iam_id']
497+
path_param_values = self.encode_path_vars(account_id, iam_id)
498+
path_param_dict = dict(zip(path_param_keys, path_param_values))
499+
url = '/v2/accounts/{account_id}/users/{iam_id}'.format(**path_param_dict)
486500
request = self.prepare_request(method='DELETE',
487501
url=url,
488502
headers=headers)
@@ -958,27 +972,36 @@ class InviteUserIamPolicy():
958972
"""
959973
Invite a user to an IAM policy.
960974
975+
:attr str type: The policy type. This can be either "access" or "authorization".
961976
:attr List[Role] roles: (optional) A list of IAM roles.
962977
:attr List[Resource] resources: (optional) A list of resources.
963978
"""
964979

965980
def __init__(self,
981+
type: str,
966982
*,
967983
roles: List['Role'] = None,
968984
resources: List['Resource'] = None) -> None:
969985
"""
970986
Initialize a InviteUserIamPolicy object.
971987
988+
:param str type: The policy type. This can be either "access" or
989+
"authorization".
972990
:param List[Role] roles: (optional) A list of IAM roles.
973991
:param List[Resource] resources: (optional) A list of resources.
974992
"""
993+
self.type = type
975994
self.roles = roles
976995
self.resources = resources
977996

978997
@classmethod
979998
def from_dict(cls, _dict: Dict) -> 'InviteUserIamPolicy':
980999
"""Initialize a InviteUserIamPolicy object from a json dictionary."""
9811000
args = {}
1001+
if 'type' in _dict:
1002+
args['type'] = _dict.get('type')
1003+
else:
1004+
raise ValueError('Required property \'type\' not present in InviteUserIamPolicy JSON')
9821005
if 'roles' in _dict:
9831006
args['roles'] = [Role.from_dict(x) for x in _dict.get('roles')]
9841007
if 'resources' in _dict:
@@ -993,6 +1016,8 @@ def _from_dict(cls, _dict):
9931016
def to_dict(self) -> Dict:
9941017
"""Return a json dictionary representing this model."""
9951018
_dict = {}
1019+
if hasattr(self, 'type') and self.type is not None:
1020+
_dict['type'] = self.type
9961021
if hasattr(self, 'roles') and self.roles is not None:
9971022
_dict['roles'] = [x.to_dict() for x in self.roles]
9981023
if hasattr(self, 'resources') and self.resources is not None:
Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
# -*- coding: utf-8 -*-
2+
# (C) Copyright IBM Corp. 2020.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
"""
17+
Integration Tests for UserManagementV1
18+
"""
19+
20+
import os
21+
import pytest
22+
from ibm_platform_services.user_management_v1 import *
23+
24+
# Config file name
25+
config_file = 'user_management.env'
26+
27+
class TestUserManagementV1():
28+
"""
29+
Integration Test Class for UserManagementV1
30+
"""
31+
32+
@classmethod
33+
def setup_class(cls):
34+
if os.path.exists(config_file):
35+
os.environ['IBM_CREDENTIALS_FILE'] = config_file
36+
37+
cls.user_management_service = UserManagementV1.new_instance(
38+
)
39+
assert cls.user_management_service is not None
40+
41+
print('Setup complete.')
42+
43+
needscredentials = pytest.mark.skipif(
44+
not os.path.exists(config_file), reason="External configuration not available, skipping..."
45+
)
46+
47+
@needscredentials
48+
def test_get_user_settings(self):
49+
50+
get_user_settings_response = self.user_management_service.get_user_settings(
51+
account_id='testString',
52+
iam_id='testString'
53+
)
54+
55+
assert get_user_settings_response.get_status_code() == 200
56+
user_settings = get_user_settings_response.get_result()
57+
assert user_settings is not None
58+
59+
@needscredentials
60+
def test_update_user_settings(self):
61+
62+
update_user_settings_response = self.user_management_service.update_user_settings(
63+
account_id='testString',
64+
iam_id='testString',
65+
language='testString',
66+
notification_language='testString',
67+
allowed_ip_addresses='32.96.110.50,172.16.254.1',
68+
self_manage=True
69+
)
70+
71+
assert update_user_settings_response.get_status_code() == 200
72+
user_settings = update_user_settings_response.get_result()
73+
assert user_settings is not None
74+
75+
@needscredentials
76+
def test_list_users(self):
77+
78+
list_users_response = self.user_management_service.list_users(
79+
account_id='testString',
80+
state='testString'
81+
)
82+
83+
assert list_users_response.get_status_code() == 200
84+
user_list = list_users_response.get_result()
85+
assert user_list is not None
86+
87+
@needscredentials
88+
def test_invite_users(self):
89+
90+
# Construct a dict representation of a InviteUser model
91+
invite_user_model = {
92+
'email': 'testString',
93+
'account_role': 'testString'
94+
}
95+
96+
# Construct a dict representation of a Role model
97+
role_model = {
98+
'role_id': 'testString'
99+
}
100+
101+
# Construct a dict representation of a Attribute model
102+
attribute_model = {
103+
'name': 'testString',
104+
'value': 'testString'
105+
}
106+
107+
# Construct a dict representation of a Resource model
108+
resource_model = {
109+
'attributes': [attribute_model]
110+
}
111+
112+
# Construct a dict representation of a InviteUserIamPolicy model
113+
invite_user_iam_policy_model = {
114+
'type': 'testString',
115+
'roles': [role_model],
116+
'resources': [resource_model]
117+
}
118+
119+
invite_users_response = self.user_management_service.invite_users(
120+
account_id='testString',
121+
users=[invite_user_model],
122+
iam_policy=[invite_user_iam_policy_model],
123+
access_groups=['testString']
124+
)
125+
126+
assert invite_users_response.get_status_code() == 202
127+
user_list = invite_users_response.get_result()
128+
assert user_list is not None
129+
130+
@needscredentials
131+
def test_get_user_profile(self):
132+
133+
get_user_profile_response = self.user_management_service.get_user_profile(
134+
account_id='testString',
135+
iam_id='testString'
136+
)
137+
138+
assert get_user_profile_response.get_status_code() == 200
139+
user_profile = get_user_profile_response.get_result()
140+
assert user_profile is not None
141+
142+
@needscredentials
143+
def test_update_user_profiles(self):
144+
145+
update_user_profiles_response = self.user_management_service.update_user_profiles(
146+
account_id='testString',
147+
iam_id='testString',
148+
firstname='testString',
149+
lastname='testString',
150+
state='testString',
151+
email='testString',
152+
phonenumber='testString',
153+
altphonenumber='testString',
154+
photo='testString'
155+
)
156+
157+
assert update_user_profiles_response.get_status_code() == 204
158+
159+
@needscredentials
160+
def test_remove_users(self):
161+
162+
remove_users_response = self.user_management_service.remove_users(
163+
account_id='testString',
164+
iam_id='testString'
165+
)
166+
167+
assert remove_users_response.get_status_code() == 204
168+

0 commit comments

Comments
 (0)