Skip to content

fix(User Management): re-gen user-mgmt service #47

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Sep 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 40 additions & 15 deletions ibm_platform_services/user_management_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# IBM OpenAPI SDK Code Generator Version: 99-SNAPSHOT-7811f8fb-20200813-160653
# IBM OpenAPI SDK Code Generator Version: 99-SNAPSHOT-b734cb71-20200916-090210

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

url = '/v2/accounts/{0}/users/{1}/settings'.format(
*self.encode_path_vars(account_id, iam_id))
path_param_keys = ['account_id', 'iam_id']
path_param_values = self.encode_path_vars(account_id, iam_id)
path_param_dict = dict(zip(path_param_keys, path_param_values))
url = '/v2/accounts/{account_id}/users/{iam_id}/settings'.format(**path_param_dict)
request = self.prepare_request(method='GET',
url=url,
headers=headers)
Expand Down Expand Up @@ -185,8 +187,10 @@ def update_user_settings(self,
headers.update(kwargs.get('headers'))
headers['Accept'] = 'application/json'

url = '/v2/accounts/{0}/users/{1}/settings'.format(
*self.encode_path_vars(account_id, iam_id))
path_param_keys = ['account_id', 'iam_id']
path_param_values = self.encode_path_vars(account_id, iam_id)
path_param_dict = dict(zip(path_param_keys, path_param_values))
url = '/v2/accounts/{account_id}/users/{iam_id}/settings'.format(**path_param_dict)
request = self.prepare_request(method='PATCH',
url=url,
headers=headers,
Expand Down Expand Up @@ -243,8 +247,10 @@ def list_users(self,
headers.update(kwargs.get('headers'))
headers['Accept'] = 'application/json'

url = '/v2/accounts/{0}/users'.format(
*self.encode_path_vars(account_id))
path_param_keys = ['account_id']
path_param_values = self.encode_path_vars(account_id)
path_param_dict = dict(zip(path_param_keys, path_param_values))
url = '/v2/accounts/{account_id}/users'.format(**path_param_dict)
request = self.prepare_request(method='GET',
url=url,
headers=headers,
Expand Down Expand Up @@ -313,8 +319,10 @@ def invite_users(self,
headers.update(kwargs.get('headers'))
headers['Accept'] = 'application/json'

url = '/v2/accounts/{0}/users'.format(
*self.encode_path_vars(account_id))
path_param_keys = ['account_id']
path_param_values = self.encode_path_vars(account_id)
path_param_dict = dict(zip(path_param_keys, path_param_values))
url = '/v2/accounts/{account_id}/users'.format(**path_param_dict)
request = self.prepare_request(method='POST',
url=url,
headers=headers,
Expand Down Expand Up @@ -358,8 +366,10 @@ def get_user_profile(self,
headers.update(kwargs.get('headers'))
headers['Accept'] = 'application/json'

url = '/v2/accounts/{0}/users/{1}'.format(
*self.encode_path_vars(account_id, iam_id))
path_param_keys = ['account_id', 'iam_id']
path_param_values = self.encode_path_vars(account_id, iam_id)
path_param_dict = dict(zip(path_param_keys, path_param_values))
url = '/v2/accounts/{account_id}/users/{iam_id}'.format(**path_param_dict)
request = self.prepare_request(method='GET',
url=url,
headers=headers)
Expand Down Expand Up @@ -436,8 +446,10 @@ def update_user_profiles(self,
if 'headers' in kwargs:
headers.update(kwargs.get('headers'))

url = '/v2/accounts/{0}/users/{1}'.format(
*self.encode_path_vars(account_id, iam_id))
path_param_keys = ['account_id', 'iam_id']
path_param_values = self.encode_path_vars(account_id, iam_id)
path_param_dict = dict(zip(path_param_keys, path_param_values))
url = '/v2/accounts/{account_id}/users/{iam_id}'.format(**path_param_dict)
request = self.prepare_request(method='PATCH',
url=url,
headers=headers,
Expand Down Expand Up @@ -481,8 +493,10 @@ def remove_users(self,
if 'headers' in kwargs:
headers.update(kwargs.get('headers'))

url = '/v2/accounts/{0}/users/{1}'.format(
*self.encode_path_vars(account_id, iam_id))
path_param_keys = ['account_id', 'iam_id']
path_param_values = self.encode_path_vars(account_id, iam_id)
path_param_dict = dict(zip(path_param_keys, path_param_values))
url = '/v2/accounts/{account_id}/users/{iam_id}'.format(**path_param_dict)
request = self.prepare_request(method='DELETE',
url=url,
headers=headers)
Expand Down Expand Up @@ -958,27 +972,36 @@ class InviteUserIamPolicy():
"""
Invite a user to an IAM policy.

:attr str type: The policy type. This can be either "access" or "authorization".
:attr List[Role] roles: (optional) A list of IAM roles.
:attr List[Resource] resources: (optional) A list of resources.
"""

def __init__(self,
type: str,
*,
roles: List['Role'] = None,
resources: List['Resource'] = None) -> None:
"""
Initialize a InviteUserIamPolicy object.

:param str type: The policy type. This can be either "access" or
"authorization".
:param List[Role] roles: (optional) A list of IAM roles.
:param List[Resource] resources: (optional) A list of resources.
"""
self.type = type
self.roles = roles
self.resources = resources

@classmethod
def from_dict(cls, _dict: Dict) -> 'InviteUserIamPolicy':
"""Initialize a InviteUserIamPolicy object from a json dictionary."""
args = {}
if 'type' in _dict:
args['type'] = _dict.get('type')
else:
raise ValueError('Required property \'type\' not present in InviteUserIamPolicy JSON')
if 'roles' in _dict:
args['roles'] = [Role.from_dict(x) for x in _dict.get('roles')]
if 'resources' in _dict:
Expand All @@ -993,6 +1016,8 @@ def _from_dict(cls, _dict):
def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'type') and self.type is not None:
_dict['type'] = self.type
if hasattr(self, 'roles') and self.roles is not None:
_dict['roles'] = [x.to_dict() for x in self.roles]
if hasattr(self, 'resources') and self.resources is not None:
Expand Down
17 changes: 8 additions & 9 deletions test/unit/test_user_management_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

"""
Unit Tests for UserManagementV1
"""

from ibm_cloud_sdk_core.authenticators.no_auth_authenticator import NoAuthAuthenticator
import inspect
import json
Expand Down Expand Up @@ -45,7 +49,6 @@ def preprocess_url(self, request_url: str):
"""
Preprocess the request URL to ensure the mock response will be found.
"""
request_url = urllib.parse.quote(request_url, safe=':/')
if re.fullmatch('.*/+', request_url) is None:
return request_url
else:
Expand Down Expand Up @@ -120,7 +123,6 @@ def preprocess_url(self, request_url: str):
"""
Preprocess the request URL to ensure the mock response will be found.
"""
request_url = urllib.parse.quote(request_url, safe=':/')
if re.fullmatch('.*/+', request_url) is None:
return request_url
else:
Expand Down Expand Up @@ -249,7 +251,6 @@ def preprocess_url(self, request_url: str):
"""
Preprocess the request URL to ensure the mock response will be found.
"""
request_url = urllib.parse.quote(request_url, safe=':/')
if re.fullmatch('.*/+', request_url) is None:
return request_url
else:
Expand Down Expand Up @@ -354,7 +355,6 @@ def preprocess_url(self, request_url: str):
"""
Preprocess the request URL to ensure the mock response will be found.
"""
request_url = urllib.parse.quote(request_url, safe=':/')
if re.fullmatch('.*/+', request_url) is None:
return request_url
else:
Expand Down Expand Up @@ -394,6 +394,7 @@ def test_invite_users_all_params(self):

# Construct a dict representation of a InviteUserIamPolicy model
invite_user_iam_policy_model = {}
invite_user_iam_policy_model['type'] = 'testString'
invite_user_iam_policy_model['roles'] = [role_model]
invite_user_iam_policy_model['resources'] = [resource_model]

Expand Down Expand Up @@ -487,7 +488,6 @@ def preprocess_url(self, request_url: str):
"""
Preprocess the request URL to ensure the mock response will be found.
"""
request_url = urllib.parse.quote(request_url, safe=':/')
if re.fullmatch('.*/+', request_url) is None:
return request_url
else:
Expand Down Expand Up @@ -562,7 +562,6 @@ def preprocess_url(self, request_url: str):
"""
Preprocess the request URL to ensure the mock response will be found.
"""
request_url = urllib.parse.quote(request_url, safe=':/')
if re.fullmatch('.*/+', request_url) is None:
return request_url
else:
Expand Down Expand Up @@ -681,7 +680,6 @@ def preprocess_url(self, request_url: str):
"""
Preprocess the request URL to ensure the mock response will be found.
"""
request_url = urllib.parse.quote(request_url, safe=':/')
if re.fullmatch('.*/+', request_url) is None:
return request_url
else:
Expand Down Expand Up @@ -779,8 +777,8 @@ def test_user_list_serialization(self):

# Construct a json representation of a UserList model
user_list_model_json = {}
user_list_model_json['total_results'] = 36.0
user_list_model_json['limit'] = 36.0
user_list_model_json['total_results'] = 72.5
user_list_model_json['limit'] = 72.5
user_list_model_json['first_url'] = 'testString'
user_list_model_json['next_url'] = 'testString'
user_list_model_json['resources'] = [user_profile_model]
Expand Down Expand Up @@ -956,6 +954,7 @@ def test_invite_user_iam_policy_serialization(self):

# Construct a json representation of a InviteUserIamPolicy model
invite_user_iam_policy_model_json = {}
invite_user_iam_policy_model_json['type'] = 'testString'
invite_user_iam_policy_model_json['roles'] = [role_model]
invite_user_iam_policy_model_json['resources'] = [resource_model]

Expand Down