30
30
from ibm_cloud_sdk_core import BaseService , DetailedResponse , get_query_param
31
31
from ibm_cloud_sdk_core .authenticators .authenticator import Authenticator
32
32
from ibm_cloud_sdk_core .get_authenticator import get_authenticator_from_environment
33
- from ibm_cloud_sdk_core .utils import datetime_to_string , string_to_datetime
33
+ from ibm_cloud_sdk_core .utils import convert_model , datetime_to_string , string_to_datetime
34
34
35
35
from .common import get_sdk_headers
36
36
@@ -270,7 +270,11 @@ def update_enterprise(
270
270
)
271
271
headers .update (sdk_headers )
272
272
273
- data = {'name' : name , 'domain' : domain , 'primary_contact_iam_id' : primary_contact_iam_id }
273
+ data = {
274
+ 'name' : name ,
275
+ 'domain' : domain ,
276
+ 'primary_contact_iam_id' : primary_contact_iam_id ,
277
+ }
274
278
data = {k : v for (k , v ) in data .items () if v is not None }
275
279
data = json .dumps (data )
276
280
headers ['content-type' ] = 'application/json'
@@ -334,7 +338,10 @@ def import_account_to_enterprise(
334
338
)
335
339
headers .update (sdk_headers )
336
340
337
- data = {'parent' : parent , 'billing_unit_id' : billing_unit_id }
341
+ data = {
342
+ 'parent' : parent ,
343
+ 'billing_unit_id' : billing_unit_id ,
344
+ }
338
345
data = {k : v for (k , v ) in data .items () if v is not None }
339
346
data = json .dumps (data )
340
347
headers ['content-type' ] = 'application/json'
@@ -353,7 +360,7 @@ def import_account_to_enterprise(
353
360
return response
354
361
355
362
def create_account (
356
- self , parent : str , name : str , owner_iam_id : str , * , traits : dict = None , ** kwargs
363
+ self , parent : str , name : str , owner_iam_id : str , * , traits : 'CreateAccountRequestTraits' = None , ** kwargs
357
364
) -> DetailedResponse :
358
365
"""
359
366
Create a new account in an enterprise.
@@ -371,9 +378,9 @@ def create_account(
371
378
characters.
372
379
:param str owner_iam_id: The IAM ID of the account owner, such as
373
380
`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.
381
+ :param CreateAccountRequestTraits traits: (optional) The traits object can
382
+ be used to opt-out of Multi-Factor Authentication setting when creating a
383
+ child account in the enterprise. This is an optional field.
377
384
:param dict headers: A `dict` containing the request headers
378
385
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
379
386
:rtype: DetailedResponse with `dict` result representing a `CreateAccountResponse` object
@@ -385,6 +392,8 @@ def create_account(
385
392
raise ValueError ('name must be provided' )
386
393
if owner_iam_id is None :
387
394
raise ValueError ('owner_iam_id must be provided' )
395
+ if traits is not None :
396
+ traits = convert_model (traits )
388
397
headers = {}
389
398
sdk_headers = get_sdk_headers (
390
399
service_name = self .DEFAULT_SERVICE_NAME , service_version = 'V1' , operation_id = 'create_account'
@@ -636,7 +645,11 @@ def create_account_group(self, parent: str, name: str, primary_contact_iam_id: s
636
645
)
637
646
headers .update (sdk_headers )
638
647
639
- data = {'parent' : parent , 'name' : name , 'primary_contact_iam_id' : primary_contact_iam_id }
648
+ data = {
649
+ 'parent' : parent ,
650
+ 'name' : name ,
651
+ 'primary_contact_iam_id' : primary_contact_iam_id ,
652
+ }
640
653
data = {k : v for (k , v ) in data .items () if v is not None }
641
654
data = json .dumps (data )
642
655
headers ['content-type' ] = 'application/json'
@@ -791,7 +804,10 @@ def update_account_group(
791
804
)
792
805
headers .update (sdk_headers )
793
806
794
- data = {'name' : name , 'primary_contact_iam_id' : primary_contact_iam_id }
807
+ data = {
808
+ 'name' : name ,
809
+ 'primary_contact_iam_id' : primary_contact_iam_id ,
810
+ }
795
811
data = {k : v for (k , v ) in data .items () if v is not None }
796
812
data = json .dumps (data )
797
813
headers ['content-type' ] = 'application/json'
@@ -1296,6 +1312,63 @@ def __ne__(self, other: 'CreateAccountGroupResponse') -> bool:
1296
1312
return not self == other
1297
1313
1298
1314
1315
+ class CreateAccountRequestTraits :
1316
+ """
1317
+ The traits object can be used to opt-out of Multi-Factor Authentication setting when
1318
+ creating a child account in the enterprise. This is an optional field.
1319
+
1320
+ :attr str mfa: (optional) By default MFA will be set on the account. To opt out,
1321
+ pass the traits object with the mfa field set to empty string.
1322
+ """
1323
+
1324
+ def __init__ (self , * , mfa : str = None ) -> None :
1325
+ """
1326
+ Initialize a CreateAccountRequestTraits object.
1327
+
1328
+ :param str mfa: (optional) By default MFA will be set on the account. To
1329
+ opt out, pass the traits object with the mfa field set to empty string.
1330
+ """
1331
+ self .mfa = mfa
1332
+
1333
+ @classmethod
1334
+ def from_dict (cls , _dict : Dict ) -> 'CreateAccountRequestTraits' :
1335
+ """Initialize a CreateAccountRequestTraits object from a json dictionary."""
1336
+ args = {}
1337
+ if 'mfa' in _dict :
1338
+ args ['mfa' ] = _dict .get ('mfa' )
1339
+ return cls (** args )
1340
+
1341
+ @classmethod
1342
+ def _from_dict (cls , _dict ):
1343
+ """Initialize a CreateAccountRequestTraits object from a json dictionary."""
1344
+ return cls .from_dict (_dict )
1345
+
1346
+ def to_dict (self ) -> Dict :
1347
+ """Return a json dictionary representing this model."""
1348
+ _dict = {}
1349
+ if hasattr (self , 'mfa' ) and self .mfa is not None :
1350
+ _dict ['mfa' ] = self .mfa
1351
+ return _dict
1352
+
1353
+ def _to_dict (self ):
1354
+ """Return a json dictionary representing this model."""
1355
+ return self .to_dict ()
1356
+
1357
+ def __str__ (self ) -> str :
1358
+ """Return a `str` version of this CreateAccountRequestTraits object."""
1359
+ return json .dumps (self .to_dict (), indent = 2 )
1360
+
1361
+ def __eq__ (self , other : 'CreateAccountRequestTraits' ) -> bool :
1362
+ """Return `true` when self and other are equal, false otherwise."""
1363
+ if not isinstance (other , self .__class__ ):
1364
+ return False
1365
+ return self .__dict__ == other .__dict__
1366
+
1367
+ def __ne__ (self , other : 'CreateAccountRequestTraits' ) -> bool :
1368
+ """Return `true` when self and other are not equal, false otherwise."""
1369
+ return not self == other
1370
+
1371
+
1299
1372
class CreateAccountResponse :
1300
1373
"""
1301
1374
A newly-created account.
0 commit comments