Skip to content

Commit c7953a8

Browse files
padamstxmahakAg
andauthored
fix(User Management): re-gen user-mgmt service (#47)
Co-authored-by: Mahak <[email protected]>
1 parent c550ef9 commit c7953a8

File tree

3 files changed

+48
-24
lines changed

3 files changed

+48
-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-b734cb71-20200916-090210
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:

test/unit/test_user_management_v1.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515

16+
"""
17+
Unit Tests for UserManagementV1
18+
"""
19+
1620
from ibm_cloud_sdk_core.authenticators.no_auth_authenticator import NoAuthAuthenticator
1721
import inspect
1822
import json
@@ -45,7 +49,6 @@ def preprocess_url(self, request_url: str):
4549
"""
4650
Preprocess the request URL to ensure the mock response will be found.
4751
"""
48-
request_url = urllib.parse.quote(request_url, safe=':/')
4952
if re.fullmatch('.*/+', request_url) is None:
5053
return request_url
5154
else:
@@ -120,7 +123,6 @@ def preprocess_url(self, request_url: str):
120123
"""
121124
Preprocess the request URL to ensure the mock response will be found.
122125
"""
123-
request_url = urllib.parse.quote(request_url, safe=':/')
124126
if re.fullmatch('.*/+', request_url) is None:
125127
return request_url
126128
else:
@@ -249,7 +251,6 @@ def preprocess_url(self, request_url: str):
249251
"""
250252
Preprocess the request URL to ensure the mock response will be found.
251253
"""
252-
request_url = urllib.parse.quote(request_url, safe=':/')
253254
if re.fullmatch('.*/+', request_url) is None:
254255
return request_url
255256
else:
@@ -354,7 +355,6 @@ def preprocess_url(self, request_url: str):
354355
"""
355356
Preprocess the request URL to ensure the mock response will be found.
356357
"""
357-
request_url = urllib.parse.quote(request_url, safe=':/')
358358
if re.fullmatch('.*/+', request_url) is None:
359359
return request_url
360360
else:
@@ -394,6 +394,7 @@ def test_invite_users_all_params(self):
394394

395395
# Construct a dict representation of a InviteUserIamPolicy model
396396
invite_user_iam_policy_model = {}
397+
invite_user_iam_policy_model['type'] = 'testString'
397398
invite_user_iam_policy_model['roles'] = [role_model]
398399
invite_user_iam_policy_model['resources'] = [resource_model]
399400

@@ -487,7 +488,6 @@ def preprocess_url(self, request_url: str):
487488
"""
488489
Preprocess the request URL to ensure the mock response will be found.
489490
"""
490-
request_url = urllib.parse.quote(request_url, safe=':/')
491491
if re.fullmatch('.*/+', request_url) is None:
492492
return request_url
493493
else:
@@ -562,7 +562,6 @@ def preprocess_url(self, request_url: str):
562562
"""
563563
Preprocess the request URL to ensure the mock response will be found.
564564
"""
565-
request_url = urllib.parse.quote(request_url, safe=':/')
566565
if re.fullmatch('.*/+', request_url) is None:
567566
return request_url
568567
else:
@@ -681,7 +680,6 @@ def preprocess_url(self, request_url: str):
681680
"""
682681
Preprocess the request URL to ensure the mock response will be found.
683682
"""
684-
request_url = urllib.parse.quote(request_url, safe=':/')
685683
if re.fullmatch('.*/+', request_url) is None:
686684
return request_url
687685
else:
@@ -779,8 +777,8 @@ def test_user_list_serialization(self):
779777

780778
# Construct a json representation of a UserList model
781779
user_list_model_json = {}
782-
user_list_model_json['total_results'] = 36.0
783-
user_list_model_json['limit'] = 36.0
780+
user_list_model_json['total_results'] = 72.5
781+
user_list_model_json['limit'] = 72.5
784782
user_list_model_json['first_url'] = 'testString'
785783
user_list_model_json['next_url'] = 'testString'
786784
user_list_model_json['resources'] = [user_profile_model]
@@ -956,6 +954,7 @@ def test_invite_user_iam_policy_serialization(self):
956954

957955
# Construct a json representation of a InviteUserIamPolicy model
958956
invite_user_iam_policy_model_json = {}
957+
invite_user_iam_policy_model_json['type'] = 'testString'
959958
invite_user_iam_policy_model_json['roles'] = [role_model]
960959
invite_user_iam_policy_model_json['resources'] = [resource_model]
961960

0 commit comments

Comments
 (0)