Skip to content

Commit fb85eac

Browse files
feat(Enterprise-Management): re-gen service after recent API changes
Signed-off-by: namratabhadauriya <[email protected]>
1 parent a512060 commit fb85eac

File tree

4 files changed

+304
-9
lines changed

4 files changed

+304
-9
lines changed

examples/test_enterprise_management_v1_examples.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,42 @@ def test_update_enterprise_example(self):
442442
except ApiException as e:
443443
pytest.fail(str(e))
444444

445+
@needscredentials
446+
def test_delete_account_example(self):
447+
"""
448+
delete_account request example
449+
"""
450+
try:
451+
# begin-delete_account
452+
453+
response = enterprise_management_service.delete_account(
454+
account_id=account_id,
455+
)
456+
457+
# end-delete_account
458+
print('\ndelete_account() response status code: ', response.get_status_code())
459+
460+
except ApiException as e:
461+
pytest.fail(str(e))
462+
463+
@needscredentials
464+
def test_delete_account_group_example(self):
465+
"""
466+
delete_account_group request example
467+
"""
468+
try:
469+
# begin-delete_account_group
470+
471+
response = enterprise_management_service.delete_account_group(
472+
account_group_id=account_group_id,
473+
)
474+
475+
# end-delete_account_group
476+
print('\ndelete_account_group() response status code: ', response.get_status_code())
477+
478+
except ApiException as e:
479+
pytest.fail(str(e))
480+
445481

446482
# endregion
447483
##############################################################################

ibm_platform_services/enterprise_management_v1.py

Lines changed: 107 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# coding: utf-8
22

3-
# (C) Copyright IBM Corp. 2022.
3+
# (C) Copyright IBM Corp. 2023.
44
#
55
# Licensed under the Apache License, Version 2.0 (the "License");
66
# you may not use this file except in compliance with the License.
@@ -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: 3.60.2-95dc7721-20221102-203229
17+
# IBM OpenAPI SDK Code Generator Version: 3.64.1-cee95189-20230124-211647
1818

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

355-
def create_account(self, parent: str, name: str, owner_iam_id: str, **kwargs) -> DetailedResponse:
355+
def create_account(
356+
self, parent: str, name: str, owner_iam_id: str, *, traits: dict = None, **kwargs
357+
) -> DetailedResponse:
356358
"""
357359
Create a new account in an enterprise.
358360
@@ -369,6 +371,9 @@ def create_account(self, parent: str, name: str, owner_iam_id: str, **kwargs) ->
369371
characters.
370372
:param str owner_iam_id: The IAM ID of the account owner, such as
371373
`IBMid-0123ABC`. The IAM ID must already exist.
374+
:param dict traits: (optional) The traits object can be used to opt-out of
375+
Multi-Factor Authentication setting when creating a child account in the
376+
enterprise. This is an optional field.
372377
:param dict headers: A `dict` containing the request headers
373378
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
374379
:rtype: DetailedResponse with `dict` result representing a `CreateAccountResponse` object
@@ -386,7 +391,12 @@ def create_account(self, parent: str, name: str, owner_iam_id: str, **kwargs) ->
386391
)
387392
headers.update(sdk_headers)
388393

389-
data = {'parent': parent, 'name': name, 'owner_iam_id': owner_iam_id}
394+
data = {
395+
'parent': parent,
396+
'name': name,
397+
'owner_iam_id': owner_iam_id,
398+
'traits': traits,
399+
}
390400
data = {k: v for (k, v) in data.items() if v is not None}
391401
data = json.dumps(data)
392402
headers['content-type'] = 'application/json'
@@ -410,6 +420,7 @@ def list_accounts(
410420
next_docid: str = None,
411421
parent: str = None,
412422
limit: int = None,
423+
include_deleted: bool = None,
413424
**kwargs,
414425
) -> DetailedResponse:
415426
"""
@@ -442,6 +453,8 @@ def list_accounts(
442453
children or are a part of the hierarchy for a given parent CRN.
443454
:param int limit: (optional) Return results up to this limit. Valid values
444455
are between `0` and `100`.
456+
:param bool include_deleted: (optional) Include the deleted accounts from
457+
an enterprise when used in conjunction with enterprise_id.
445458
:param dict headers: A `dict` containing the request headers
446459
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
447460
:rtype: DetailedResponse with `dict` result representing a `ListAccountsResponse` object
@@ -459,6 +472,7 @@ def list_accounts(
459472
'next_docid': next_docid,
460473
'parent': parent,
461474
'limit': limit,
475+
'include_deleted': include_deleted,
462476
}
463477

464478
if 'headers' in kwargs:
@@ -479,7 +493,7 @@ def get_account(self, account_id: str, **kwargs) -> DetailedResponse:
479493
Retrieve an account by the `account_id` parameter. All data related to the account
480494
is returned only if the caller has access to retrieve the account.
481495
482-
:param str account_id: The ID of the account to retrieve.
496+
:param str account_id: The ID of the target account.
483497
:param dict headers: A `dict` containing the request headers
484498
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
485499
:rtype: DetailedResponse with `dict` result representing a `Account` object
@@ -513,7 +527,7 @@ def update_account(self, account_id: str, parent: str, **kwargs) -> DetailedResp
513527
514528
Move an account to a different parent within the same enterprise.
515529
516-
:param str account_id: The ID of the account to retrieve.
530+
:param str account_id: The ID of the target account.
517531
:param str parent: The CRN of the new parent within the enterprise.
518532
:param dict headers: A `dict` containing the request headers
519533
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
@@ -530,7 +544,9 @@ def update_account(self, account_id: str, parent: str, **kwargs) -> DetailedResp
530544
)
531545
headers.update(sdk_headers)
532546

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

567+
def delete_account(self, account_id: str, **kwargs) -> DetailedResponse:
568+
"""
569+
Remove an account from its enterprise.
570+
571+
Remove an account from the enterprise its currently in. After an account is
572+
removed, it will be canceled and cannot be reactivated.
573+
574+
:param str account_id: The ID of the target account.
575+
:param dict headers: A `dict` containing the request headers
576+
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
577+
:rtype: DetailedResponse
578+
"""
579+
580+
if not account_id:
581+
raise ValueError('account_id must be provided')
582+
headers = {}
583+
sdk_headers = get_sdk_headers(
584+
service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='delete_account'
585+
)
586+
headers.update(sdk_headers)
587+
588+
if 'headers' in kwargs:
589+
headers.update(kwargs.get('headers'))
590+
del kwargs['headers']
591+
592+
path_param_keys = ['account_id']
593+
path_param_values = self.encode_path_vars(account_id)
594+
path_param_dict = dict(zip(path_param_keys, path_param_values))
595+
url = '/accounts/{account_id}'.format(**path_param_dict)
596+
request = self.prepare_request(method='DELETE', url=url, headers=headers)
597+
598+
response = self.send(request, **kwargs)
599+
return response
600+
551601
#########################
552602
# Account Group Operations
553603
#########################
@@ -610,6 +660,7 @@ def list_account_groups(
610660
next_docid: str = None,
611661
parent: str = None,
612662
limit: int = None,
663+
include_deleted: bool = None,
613664
**kwargs,
614665
) -> DetailedResponse:
615666
"""
@@ -644,6 +695,8 @@ def list_account_groups(
644695
children or are a part of the hierarchy for a given parent CRN.
645696
:param int limit: (optional) Return results up to this limit. Valid values
646697
are between `0` and `100`.
698+
:param bool include_deleted: (optional) Include the deleted account groups
699+
from an enterprise when used in conjunction with other query parameters.
647700
:param dict headers: A `dict` containing the request headers
648701
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
649702
:rtype: DetailedResponse with `dict` result representing a `ListAccountGroupsResponse` object
@@ -661,6 +714,7 @@ def list_account_groups(
661714
'next_docid': next_docid,
662715
'parent': parent,
663716
'limit': limit,
717+
'include_deleted': include_deleted,
664718
}
665719

666720
if 'headers' in kwargs:
@@ -755,6 +809,42 @@ def update_account_group(
755809
response = self.send(request, **kwargs)
756810
return response
757811

812+
def delete_account_group(self, account_group_id: str, **kwargs) -> DetailedResponse:
813+
"""
814+
Delete an account group from the enterprise.
815+
816+
Delete an existing account group from the enterprise. You can't delete an account
817+
group that has child account groups, the delete request will fail. This API
818+
doesn't perform a recursive delete on the child account groups, it only deletes
819+
the current account group.
820+
821+
:param str account_group_id: The ID of the account group to retrieve.
822+
:param dict headers: A `dict` containing the request headers
823+
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
824+
:rtype: DetailedResponse
825+
"""
826+
827+
if not account_group_id:
828+
raise ValueError('account_group_id must be provided')
829+
headers = {}
830+
sdk_headers = get_sdk_headers(
831+
service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='delete_account_group'
832+
)
833+
headers.update(sdk_headers)
834+
835+
if 'headers' in kwargs:
836+
headers.update(kwargs.get('headers'))
837+
del kwargs['headers']
838+
839+
path_param_keys = ['account_group_id']
840+
path_param_values = self.encode_path_vars(account_group_id)
841+
path_param_dict = dict(zip(path_param_keys, path_param_values))
842+
url = '/account-groups/{account_group_id}'.format(**path_param_dict)
843+
request = self.prepare_request(method='DELETE', url=url, headers=headers)
844+
845+
response = self.send(request, **kwargs)
846+
return response
847+
758848

759849
##############################################################################
760850
# Models
@@ -1825,6 +1915,7 @@ def __init__(
18251915
account_group_id: str = None,
18261916
parent: str = None,
18271917
limit: int = None,
1918+
include_deleted: bool = None,
18281919
) -> None:
18291920
"""
18301921
Initialize a AccountsPager object.
@@ -1837,6 +1928,8 @@ def __init__(
18371928
children or are a part of the hierarchy for a given parent CRN.
18381929
:param int limit: (optional) Return results up to this limit. Valid values
18391930
are between `0` and `100`.
1931+
:param bool include_deleted: (optional) Include the deleted accounts from
1932+
an enterprise when used in conjunction with enterprise_id.
18401933
"""
18411934
self._has_next = True
18421935
self._client = client
@@ -1845,6 +1938,7 @@ def __init__(
18451938
self._account_group_id = account_group_id
18461939
self._parent = parent
18471940
self._limit = limit
1941+
self._include_deleted = include_deleted
18481942

18491943
def has_next(self) -> bool:
18501944
"""
@@ -1866,6 +1960,7 @@ def get_next(self) -> List[dict]:
18661960
account_group_id=self._account_group_id,
18671961
parent=self._parent,
18681962
limit=self._limit,
1963+
include_deleted=self._include_deleted,
18691964
next_docid=self._page_context.get('next'),
18701965
).get_result()
18711966

@@ -1906,6 +2001,7 @@ def __init__(
19062001
parent_account_group_id: str = None,
19072002
parent: str = None,
19082003
limit: int = None,
2004+
include_deleted: bool = None,
19092005
) -> None:
19102006
"""
19112007
Initialize a AccountGroupsPager object.
@@ -1919,6 +2015,8 @@ def __init__(
19192015
children or are a part of the hierarchy for a given parent CRN.
19202016
:param int limit: (optional) Return results up to this limit. Valid values
19212017
are between `0` and `100`.
2018+
:param bool include_deleted: (optional) Include the deleted account groups
2019+
from an enterprise when used in conjunction with other query parameters.
19222020
"""
19232021
self._has_next = True
19242022
self._client = client
@@ -1927,6 +2025,7 @@ def __init__(
19272025
self._parent_account_group_id = parent_account_group_id
19282026
self._parent = parent
19292027
self._limit = limit
2028+
self._include_deleted = include_deleted
19302029

19312030
def has_next(self) -> bool:
19322031
"""
@@ -1948,6 +2047,7 @@ def get_next(self) -> List[dict]:
19482047
parent_account_group_id=self._parent_account_group_id,
19492048
parent=self._parent,
19502049
limit=self._limit,
2050+
include_deleted=self._include_deleted,
19512051
next_docid=self._page_context.get('next'),
19522052
).get_result()
19532053

test/integration/test_enterprise_management_v1.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,3 +354,21 @@ def test_update_enterprise(self):
354354
)
355355

356356
assert update_enterprise_response.get_status_code() == 204
357+
358+
@needscredentials
359+
def test_delete_account(self):
360+
361+
response = self.enterprise_management_service.delete_account(
362+
account_id=example_account_id,
363+
)
364+
365+
assert response.get_status_code() == 204
366+
367+
@needscredentials
368+
def test_delete_account_group(self):
369+
370+
response = self.enterprise_management_service.delete_account_group(
371+
account_group_id=first_example_account_group_id,
372+
)
373+
374+
assert response.get_status_code() == 204

0 commit comments

Comments
 (0)