Skip to content

feat(enterprise management): re-gen service after recent API changes #196

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 1 commit into from
Apr 21, 2023
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
36 changes: 36 additions & 0 deletions examples/test_enterprise_management_v1_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,42 @@ def test_update_enterprise_example(self):
except ApiException as e:
pytest.fail(str(e))

@needscredentials
def test_delete_account_example(self):
"""
delete_account request example
"""
try:
# begin-delete_account

response = enterprise_management_service.delete_account(
account_id=account_id,
)

# end-delete_account
print('\ndelete_account() response status code: ', response.get_status_code())

except ApiException as e:
pytest.fail(str(e))

@needscredentials
def test_delete_account_group_example(self):
"""
delete_account_group request example
"""
try:
# begin-delete_account_group

response = enterprise_management_service.delete_account_group(
account_group_id=account_group_id,
)

# end-delete_account_group
print('\ndelete_account_group() response status code: ', response.get_status_code())

except ApiException as e:
pytest.fail(str(e))


# endregion
##############################################################################
Expand Down
114 changes: 107 additions & 7 deletions ibm_platform_services/enterprise_management_v1.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# coding: utf-8

# (C) Copyright IBM Corp. 2022.
# (C) Copyright IBM Corp. 2023.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# IBM OpenAPI SDK Code Generator Version: 3.60.2-95dc7721-20221102-203229
# IBM OpenAPI SDK Code Generator Version: 3.64.1-cee95189-20230124-211647

"""
The Enterprise Management API enables you to create and manage an enterprise, account
Expand Down Expand Up @@ -352,7 +352,9 @@ def import_account_to_enterprise(
response = self.send(request, **kwargs)
return response

def create_account(self, parent: str, name: str, owner_iam_id: str, **kwargs) -> DetailedResponse:
def create_account(
self, parent: str, name: str, owner_iam_id: str, *, traits: dict = None, **kwargs
) -> DetailedResponse:
"""
Create a new account in an enterprise.

Expand All @@ -369,6 +371,9 @@ def create_account(self, parent: str, name: str, owner_iam_id: str, **kwargs) ->
characters.
:param str owner_iam_id: The IAM ID of the account owner, such as
`IBMid-0123ABC`. The IAM ID must already exist.
:param dict traits: (optional) The traits object can be used to opt-out of
Multi-Factor Authentication setting when creating a child account in the
enterprise. This is an optional field.
:param dict headers: A `dict` containing the request headers
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
:rtype: DetailedResponse with `dict` result representing a `CreateAccountResponse` object
Expand All @@ -386,7 +391,12 @@ def create_account(self, parent: str, name: str, owner_iam_id: str, **kwargs) ->
)
headers.update(sdk_headers)

data = {'parent': parent, 'name': name, 'owner_iam_id': owner_iam_id}
data = {
'parent': parent,
'name': name,
'owner_iam_id': owner_iam_id,
'traits': traits,
}
data = {k: v for (k, v) in data.items() if v is not None}
data = json.dumps(data)
headers['content-type'] = 'application/json'
Expand All @@ -410,6 +420,7 @@ def list_accounts(
next_docid: str = None,
parent: str = None,
limit: int = None,
include_deleted: bool = None,
**kwargs,
) -> DetailedResponse:
"""
Expand Down Expand Up @@ -442,6 +453,8 @@ def list_accounts(
children or are a part of the hierarchy for a given parent CRN.
:param int limit: (optional) Return results up to this limit. Valid values
are between `0` and `100`.
:param bool include_deleted: (optional) Include the deleted accounts from
an enterprise when used in conjunction with enterprise_id.
:param dict headers: A `dict` containing the request headers
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
:rtype: DetailedResponse with `dict` result representing a `ListAccountsResponse` object
Expand All @@ -459,6 +472,7 @@ def list_accounts(
'next_docid': next_docid,
'parent': parent,
'limit': limit,
'include_deleted': include_deleted,
}

if 'headers' in kwargs:
Expand All @@ -479,7 +493,7 @@ def get_account(self, account_id: str, **kwargs) -> DetailedResponse:
Retrieve an account by the `account_id` parameter. All data related to the account
is returned only if the caller has access to retrieve the account.

:param str account_id: The ID of the account to retrieve.
:param str account_id: The ID of the target account.
:param dict headers: A `dict` containing the request headers
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
:rtype: DetailedResponse with `dict` result representing a `Account` object
Expand Down Expand Up @@ -513,7 +527,7 @@ def update_account(self, account_id: str, parent: str, **kwargs) -> DetailedResp

Move an account to a different parent within the same enterprise.

:param str account_id: The ID of the account to retrieve.
:param str account_id: The ID of the target account.
:param str parent: The CRN of the new parent within the enterprise.
:param dict headers: A `dict` containing the request headers
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
Expand All @@ -530,7 +544,9 @@ def update_account(self, account_id: str, parent: str, **kwargs) -> DetailedResp
)
headers.update(sdk_headers)

data = {'parent': parent}
data = {
'parent': parent,
}
data = {k: v for (k, v) in data.items() if v is not None}
data = json.dumps(data)
headers['content-type'] = 'application/json'
Expand All @@ -548,6 +564,40 @@ def update_account(self, account_id: str, parent: str, **kwargs) -> DetailedResp
response = self.send(request, **kwargs)
return response

def delete_account(self, account_id: str, **kwargs) -> DetailedResponse:
"""
Remove an account from its enterprise.

Remove an account from the enterprise its currently in. After an account is
removed, it will be canceled and cannot be reactivated.

:param str account_id: The ID of the target account.
:param dict headers: A `dict` containing the request headers
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
:rtype: DetailedResponse
"""

if not account_id:
raise ValueError('account_id must be provided')
headers = {}
sdk_headers = get_sdk_headers(
service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='delete_account'
)
headers.update(sdk_headers)

if 'headers' in kwargs:
headers.update(kwargs.get('headers'))
del kwargs['headers']

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 = '/accounts/{account_id}'.format(**path_param_dict)
request = self.prepare_request(method='DELETE', url=url, headers=headers)

response = self.send(request, **kwargs)
return response

#########################
# Account Group Operations
#########################
Expand Down Expand Up @@ -610,6 +660,7 @@ def list_account_groups(
next_docid: str = None,
parent: str = None,
limit: int = None,
include_deleted: bool = None,
**kwargs,
) -> DetailedResponse:
"""
Expand Down Expand Up @@ -644,6 +695,8 @@ def list_account_groups(
children or are a part of the hierarchy for a given parent CRN.
:param int limit: (optional) Return results up to this limit. Valid values
are between `0` and `100`.
:param bool include_deleted: (optional) Include the deleted account groups
from an enterprise when used in conjunction with other query parameters.
:param dict headers: A `dict` containing the request headers
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
:rtype: DetailedResponse with `dict` result representing a `ListAccountGroupsResponse` object
Expand All @@ -661,6 +714,7 @@ def list_account_groups(
'next_docid': next_docid,
'parent': parent,
'limit': limit,
'include_deleted': include_deleted,
}

if 'headers' in kwargs:
Expand Down Expand Up @@ -755,6 +809,42 @@ def update_account_group(
response = self.send(request, **kwargs)
return response

def delete_account_group(self, account_group_id: str, **kwargs) -> DetailedResponse:
"""
Delete an account group from the enterprise.

Delete an existing account group from the enterprise. You can't delete an account
group that has child account groups, the delete request will fail. This API
doesn't perform a recursive delete on the child account groups, it only deletes
the current account group.

:param str account_group_id: The ID of the account group to retrieve.
:param dict headers: A `dict` containing the request headers
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
:rtype: DetailedResponse
"""

if not account_group_id:
raise ValueError('account_group_id must be provided')
headers = {}
sdk_headers = get_sdk_headers(
service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='delete_account_group'
)
headers.update(sdk_headers)

if 'headers' in kwargs:
headers.update(kwargs.get('headers'))
del kwargs['headers']

path_param_keys = ['account_group_id']
path_param_values = self.encode_path_vars(account_group_id)
path_param_dict = dict(zip(path_param_keys, path_param_values))
url = '/account-groups/{account_group_id}'.format(**path_param_dict)
request = self.prepare_request(method='DELETE', url=url, headers=headers)

response = self.send(request, **kwargs)
return response


##############################################################################
# Models
Expand Down Expand Up @@ -1825,6 +1915,7 @@ def __init__(
account_group_id: str = None,
parent: str = None,
limit: int = None,
include_deleted: bool = None,
) -> None:
"""
Initialize a AccountsPager object.
Expand All @@ -1837,6 +1928,8 @@ def __init__(
children or are a part of the hierarchy for a given parent CRN.
:param int limit: (optional) Return results up to this limit. Valid values
are between `0` and `100`.
:param bool include_deleted: (optional) Include the deleted accounts from
an enterprise when used in conjunction with enterprise_id.
"""
self._has_next = True
self._client = client
Expand All @@ -1845,6 +1938,7 @@ def __init__(
self._account_group_id = account_group_id
self._parent = parent
self._limit = limit
self._include_deleted = include_deleted

def has_next(self) -> bool:
"""
Expand All @@ -1866,6 +1960,7 @@ def get_next(self) -> List[dict]:
account_group_id=self._account_group_id,
parent=self._parent,
limit=self._limit,
include_deleted=self._include_deleted,
next_docid=self._page_context.get('next'),
).get_result()

Expand Down Expand Up @@ -1906,6 +2001,7 @@ def __init__(
parent_account_group_id: str = None,
parent: str = None,
limit: int = None,
include_deleted: bool = None,
) -> None:
"""
Initialize a AccountGroupsPager object.
Expand All @@ -1919,6 +2015,8 @@ def __init__(
children or are a part of the hierarchy for a given parent CRN.
:param int limit: (optional) Return results up to this limit. Valid values
are between `0` and `100`.
:param bool include_deleted: (optional) Include the deleted account groups
from an enterprise when used in conjunction with other query parameters.
"""
self._has_next = True
self._client = client
Expand All @@ -1927,6 +2025,7 @@ def __init__(
self._parent_account_group_id = parent_account_group_id
self._parent = parent
self._limit = limit
self._include_deleted = include_deleted

def has_next(self) -> bool:
"""
Expand All @@ -1948,6 +2047,7 @@ def get_next(self) -> List[dict]:
parent_account_group_id=self._parent_account_group_id,
parent=self._parent,
limit=self._limit,
include_deleted=self._include_deleted,
next_docid=self._page_context.get('next'),
).get_result()

Expand Down
18 changes: 18 additions & 0 deletions test/integration/test_enterprise_management_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,3 +354,21 @@ def test_update_enterprise(self):
)

assert update_enterprise_response.get_status_code() == 204

@needscredentials
def test_delete_account(self):

response = self.enterprise_management_service.delete_account(
account_id=example_account_id,
)

assert response.get_status_code() == 204

@needscredentials
def test_delete_account_group(self):

response = self.enterprise_management_service.delete_account_group(
account_group_id=first_example_account_group_id,
)

assert response.get_status_code() == 204
Loading