1
1
# coding: utf-8
2
2
3
- # (C) Copyright IBM Corp. 2022 .
3
+ # (C) Copyright IBM Corp. 2023 .
4
4
#
5
5
# Licensed under the Apache License, Version 2.0 (the "License");
6
6
# you may not use this file except in compliance with the License.
14
14
# See the License for the specific language governing permissions and
15
15
# limitations under the License.
16
16
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
18
18
19
19
"""
20
20
The Enterprise Management API enables you to create and manage an enterprise, account
@@ -352,7 +352,9 @@ def import_account_to_enterprise(
352
352
response = self .send (request , ** kwargs )
353
353
return response
354
354
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 :
356
358
"""
357
359
Create a new account in an enterprise.
358
360
@@ -369,6 +371,9 @@ def create_account(self, parent: str, name: str, owner_iam_id: str, **kwargs) ->
369
371
characters.
370
372
:param str owner_iam_id: The IAM ID of the account owner, such as
371
373
`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.
372
377
:param dict headers: A `dict` containing the request headers
373
378
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
374
379
: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) ->
386
391
)
387
392
headers .update (sdk_headers )
388
393
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
+ }
390
400
data = {k : v for (k , v ) in data .items () if v is not None }
391
401
data = json .dumps (data )
392
402
headers ['content-type' ] = 'application/json'
@@ -410,6 +420,7 @@ def list_accounts(
410
420
next_docid : str = None ,
411
421
parent : str = None ,
412
422
limit : int = None ,
423
+ include_deleted : bool = None ,
413
424
** kwargs ,
414
425
) -> DetailedResponse :
415
426
"""
@@ -442,6 +453,8 @@ def list_accounts(
442
453
children or are a part of the hierarchy for a given parent CRN.
443
454
:param int limit: (optional) Return results up to this limit. Valid values
444
455
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.
445
458
:param dict headers: A `dict` containing the request headers
446
459
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
447
460
:rtype: DetailedResponse with `dict` result representing a `ListAccountsResponse` object
@@ -459,6 +472,7 @@ def list_accounts(
459
472
'next_docid' : next_docid ,
460
473
'parent' : parent ,
461
474
'limit' : limit ,
475
+ 'include_deleted' : include_deleted ,
462
476
}
463
477
464
478
if 'headers' in kwargs :
@@ -479,7 +493,7 @@ def get_account(self, account_id: str, **kwargs) -> DetailedResponse:
479
493
Retrieve an account by the `account_id` parameter. All data related to the account
480
494
is returned only if the caller has access to retrieve the account.
481
495
482
- :param str account_id: The ID of the account to retrieve .
496
+ :param str account_id: The ID of the target account .
483
497
:param dict headers: A `dict` containing the request headers
484
498
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
485
499
:rtype: DetailedResponse with `dict` result representing a `Account` object
@@ -513,7 +527,7 @@ def update_account(self, account_id: str, parent: str, **kwargs) -> DetailedResp
513
527
514
528
Move an account to a different parent within the same enterprise.
515
529
516
- :param str account_id: The ID of the account to retrieve .
530
+ :param str account_id: The ID of the target account .
517
531
:param str parent: The CRN of the new parent within the enterprise.
518
532
:param dict headers: A `dict` containing the request headers
519
533
: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
530
544
)
531
545
headers .update (sdk_headers )
532
546
533
- data = {'parent' : parent }
547
+ data = {
548
+ 'parent' : parent ,
549
+ }
534
550
data = {k : v for (k , v ) in data .items () if v is not None }
535
551
data = json .dumps (data )
536
552
headers ['content-type' ] = 'application/json'
@@ -548,6 +564,40 @@ def update_account(self, account_id: str, parent: str, **kwargs) -> DetailedResp
548
564
response = self .send (request , ** kwargs )
549
565
return response
550
566
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
+
551
601
#########################
552
602
# Account Group Operations
553
603
#########################
@@ -610,6 +660,7 @@ def list_account_groups(
610
660
next_docid : str = None ,
611
661
parent : str = None ,
612
662
limit : int = None ,
663
+ include_deleted : bool = None ,
613
664
** kwargs ,
614
665
) -> DetailedResponse :
615
666
"""
@@ -644,6 +695,8 @@ def list_account_groups(
644
695
children or are a part of the hierarchy for a given parent CRN.
645
696
:param int limit: (optional) Return results up to this limit. Valid values
646
697
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.
647
700
:param dict headers: A `dict` containing the request headers
648
701
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
649
702
:rtype: DetailedResponse with `dict` result representing a `ListAccountGroupsResponse` object
@@ -661,6 +714,7 @@ def list_account_groups(
661
714
'next_docid' : next_docid ,
662
715
'parent' : parent ,
663
716
'limit' : limit ,
717
+ 'include_deleted' : include_deleted ,
664
718
}
665
719
666
720
if 'headers' in kwargs :
@@ -755,6 +809,42 @@ def update_account_group(
755
809
response = self .send (request , ** kwargs )
756
810
return response
757
811
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
+
758
848
759
849
##############################################################################
760
850
# Models
@@ -1825,6 +1915,7 @@ def __init__(
1825
1915
account_group_id : str = None ,
1826
1916
parent : str = None ,
1827
1917
limit : int = None ,
1918
+ include_deleted : bool = None ,
1828
1919
) -> None :
1829
1920
"""
1830
1921
Initialize a AccountsPager object.
@@ -1837,6 +1928,8 @@ def __init__(
1837
1928
children or are a part of the hierarchy for a given parent CRN.
1838
1929
:param int limit: (optional) Return results up to this limit. Valid values
1839
1930
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.
1840
1933
"""
1841
1934
self ._has_next = True
1842
1935
self ._client = client
@@ -1845,6 +1938,7 @@ def __init__(
1845
1938
self ._account_group_id = account_group_id
1846
1939
self ._parent = parent
1847
1940
self ._limit = limit
1941
+ self ._include_deleted = include_deleted
1848
1942
1849
1943
def has_next (self ) -> bool :
1850
1944
"""
@@ -1866,6 +1960,7 @@ def get_next(self) -> List[dict]:
1866
1960
account_group_id = self ._account_group_id ,
1867
1961
parent = self ._parent ,
1868
1962
limit = self ._limit ,
1963
+ include_deleted = self ._include_deleted ,
1869
1964
next_docid = self ._page_context .get ('next' ),
1870
1965
).get_result ()
1871
1966
@@ -1906,6 +2001,7 @@ def __init__(
1906
2001
parent_account_group_id : str = None ,
1907
2002
parent : str = None ,
1908
2003
limit : int = None ,
2004
+ include_deleted : bool = None ,
1909
2005
) -> None :
1910
2006
"""
1911
2007
Initialize a AccountGroupsPager object.
@@ -1919,6 +2015,8 @@ def __init__(
1919
2015
children or are a part of the hierarchy for a given parent CRN.
1920
2016
:param int limit: (optional) Return results up to this limit. Valid values
1921
2017
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.
1922
2020
"""
1923
2021
self ._has_next = True
1924
2022
self ._client = client
@@ -1927,6 +2025,7 @@ def __init__(
1927
2025
self ._parent_account_group_id = parent_account_group_id
1928
2026
self ._parent = parent
1929
2027
self ._limit = limit
2028
+ self ._include_deleted = include_deleted
1930
2029
1931
2030
def has_next (self ) -> bool :
1932
2031
"""
@@ -1948,6 +2047,7 @@ def get_next(self) -> List[dict]:
1948
2047
parent_account_group_id = self ._parent_account_group_id ,
1949
2048
parent = self ._parent ,
1950
2049
limit = self ._limit ,
2050
+ include_deleted = self ._include_deleted ,
1951
2051
next_docid = self ._page_context .get ('next' ),
1952
2052
).get_result ()
1953
2053
0 commit comments