5050
5151config = None
5252
53- apikey_name = 'Example-ApiKey'
54- serviceid_name = 'Example-ServiceId'
55- serviceid_group_name = 'Example-ServiceId'
53+ now = str (round (time .time () * 1000 ))
54+
55+ apikey_name = 'Python-SDK-Example-ApiKey-' + now
56+ serviceid_name = 'Python-SDK-Example-ServiceId-' + now
57+ serviceid_group_name = 'Python-SDK-Example-ServiceId-' + now
5658service = 'console'
5759value_string = '/billing'
5860preference_id1 = 'landing_page'
5961
6062# config property values
6163account_id = None
6264iam_id = None
63- iam_id_member = None
6465apikey = None
6566enterprise_account_id = None
6667enterprise_subaccount_id = None
9293profile_template_etag = None
9394profile_template_assignment_id = None
9495profile_template_assignment_etag = None
96+ profile_template_name = 'Python-SDK-Example-Profile-Template-' + now
97+ profile_template_profile_name = 'Python-SDK-Example-Profile-From-Template-' + now
9598
9699account_settings_template_id = None
97100account_settings_template_version = None
98101account_settings_template_etag = None
99102account_settings_template_assignment_id = None
100103account_settings_template_assignment_etag = None
104+ account_settings_template_name = 'Python-SDK-Example-AccountSettings-Template-' + now
101105
102106iam_id_for_preferences = None
103107
@@ -134,9 +138,6 @@ def setup_class(cls):
134138 global iam_id
135139 iam_id = config ['IAM_ID' ]
136140
137- global iam_id_member
138- iam_id_member = config ['IAM_ID_MEMBER' ]
139-
140141 global apikey
141142 apikey = config ['APIKEY' ]
142143
@@ -146,9 +147,6 @@ def setup_class(cls):
146147 global enterprise_subaccount_id
147148 enterprise_subaccount_id = config ['ENTERPRISE_SUBACCOUNT_ID' ]
148149
149- global iam_id_for_preferences
150- iam_id_for_preferences = config ['IAM_ID_FOR_PREFERENCES' ]
151-
152150 print ('Setup complete.' )
153151
154152 needscredentials = pytest .mark .skipif (
@@ -570,9 +568,7 @@ def test_list_service_id_group_example(self):
570568 print ('\n list_service_id_group() result:' )
571569 # begin-list_service_id_group
572570
573- service_id_group_list = iam_identity_service .list_service_id_group (
574- account_id = account_id , name = serviceid_name
575- ).get_result ()
571+ service_id_group_list = iam_identity_service .list_service_id_group (account_id = account_id ).get_result ()
576572 print (json .dumps (service_id_group_list , indent = 2 ))
577573
578574 # end-list_service_id_group
@@ -638,6 +634,9 @@ def test_create_profile_example(self):
638634 global profile_id
639635 profile_id = profile ['id' ]
640636
637+ global iam_id_for_preferences
638+ iam_id_for_preferences = profile ['iam_id' ]
639+
641640 except ApiException as e :
642641 pytest .fail (str (e ))
643642
@@ -968,6 +967,11 @@ def test_set_profile_identities(self):
968967
969968 print ('\n set_profile_identities() response status code: ' , response .get_status_code ())
970969
970+ # delete identity so we can set again in the next test
971+ iam_identity_service .delete_profile_identity (
972+ profile_id = profile_id , identity_type = "user" , identifier_id = iam_id
973+ )
974+
971975 except ApiException as e :
972976 pytest .fail (str (e ))
973977
@@ -983,7 +987,7 @@ def test_set_profile_identity(self):
983987 response = iam_identity_service .set_profile_identity (
984988 profile_id = profile_id ,
985989 identity_type = "user" ,
986- identifier = iam_id_member ,
990+ identifier = iam_id ,
987991 type = "user" ,
988992 accounts = accounts ,
989993 description = "Identity description" ,
@@ -1004,7 +1008,7 @@ def test_get_profile_identity(self):
10041008 # begin-get_profile_identity
10051009
10061010 response = iam_identity_service .get_profile_identity (
1007- profile_id = profile_id , identity_type = "user" , identifier_id = iam_id_member
1011+ profile_id = profile_id , identity_type = "user" , identifier_id = iam_id
10081012 )
10091013
10101014 # end-get_profile_identity
@@ -1022,7 +1026,7 @@ def test_delete_profile_identity(self):
10221026 # begin-delete_profile_identity
10231027
10241028 response = iam_identity_service .delete_profile_identity (
1025- profile_id = profile_id , identity_type = "user" , identifier_id = iam_id_member
1029+ profile_id = profile_id , identity_type = "user" , identifier_id = iam_id
10261030 )
10271031
10281032 # end-delete_profile_identity
@@ -1031,23 +1035,6 @@ def test_delete_profile_identity(self):
10311035 except ApiException as e :
10321036 pytest .fail (str (e ))
10331037
1034- @needscredentials
1035- def test_delete_profile_example (self ):
1036- """
1037- delete_profile request example
1038- """
1039- try :
1040- # begin-delete_profile
1041-
1042- response = iam_identity_service .delete_profile (profile_id = profile_id )
1043-
1044- # end-delete_profile
1045-
1046- print ('\n delete_profile() response status code: ' , response .get_status_code ())
1047-
1048- except ApiException as e :
1049- pytest .fail (str (e ))
1050-
10511038 @needscredentials
10521039 def test_get_account_settings_example (self ):
10531040 """
@@ -1079,13 +1066,21 @@ def test_update_account_settings_example(self):
10791066 # begin-updateAccountSettings
10801067
10811068 account_settings_user_mfa = {}
1082- account_settings_user_mfa ['iam_id' ] = iam_id_member
1069+ account_settings_user_mfa ['iam_id' ] = iam_id
10831070 account_settings_user_mfa ['mfa' ] = 'NONE'
1071+
1072+ account_settings_user_domain_restriction_model = {}
1073+ account_settings_user_domain_restriction_model ['realm_id' ] = 'IBMid'
1074+ account_settings_user_domain_restriction_model ['invitation_email_allow_patterns' ] = ['*.*@company.com' ]
1075+ account_settings_user_domain_restriction_model ['restrict_invitation' ] = True
1076+
10841077 account_settings_response = iam_identity_service .update_account_settings (
10851078 account_id = account_id ,
10861079 if_match = account_settings_etag ,
10871080 restrict_create_service_id = "NOT_RESTRICTED" ,
10881081 restrict_create_platform_apikey = "NOT_RESTRICTED" ,
1082+ restrict_user_list_visibility = "NOT_RESTRICTED" ,
1083+ restrict_user_domains = [account_settings_user_domain_restriction_model ],
10891084 mfa = "NONE" ,
10901085 user_mfa = [account_settings_user_mfa ],
10911086 session_expiration_in_seconds = "86400" ,
@@ -1240,12 +1235,12 @@ def test_create_profile_template(self):
12401235 profile_claim_rule ['conditions' ] = [profile_claim_rule_conditions ]
12411236
12421237 profile = {}
1243- profile ['name' ] = 'Profile-From-Example-Template'
1238+ profile ['name' ] = profile_template_profile_name
12441239 profile ['description' ] = 'Trusted profile created from a template'
12451240 profile ['rules' ] = [profile_claim_rule ]
12461241
12471242 create_response = iam_identity_service .create_profile_template (
1248- name = 'Example-Profile-Template' ,
1243+ name = profile_template_name ,
12491244 description = 'IAM enterprise trusted profile template example' ,
12501245 account_id = enterprise_account_id ,
12511246 profile = profile ,
@@ -1317,7 +1312,7 @@ def test_update_profile_template(self):
13171312 template_id = profile_template_id ,
13181313 version = str (profile_template_version ),
13191314 if_match = profile_template_etag ,
1320- name = 'Example-Profile-Template' ,
1315+ name = profile_template_name ,
13211316 description = 'IAM enterprise trusted profile template example - updated' ,
13221317 )
13231318 profile_template = update_response .get_result ()
@@ -1433,14 +1428,14 @@ def test_create_new_profile_template_version(self):
14331428 profile_identity ['description' ] = 'Identity description'
14341429
14351430 profile = {}
1436- profile ['name' ] = 'Profile-From-Example-Template'
1431+ profile ['name' ] = profile_template_profile_name
14371432 profile ['description' ] = 'Trusted profile created from a template - new version'
14381433 profile ['rules' ] = [profile_claim_rule ]
14391434 profile ['identities' ] = [profile_identity ]
14401435
14411436 create_response = iam_identity_service .create_profile_template_version (
14421437 template_id = profile_template_id ,
1443- name = 'Example-Profile-Template' ,
1438+ name = profile_template_name ,
14441439 description = 'IAM enterprise trusted profile template example - new version' ,
14451440 account_id = enterprise_account_id ,
14461441 profile = profile ,
@@ -1586,7 +1581,7 @@ def test_create_account_settings_template(self):
15861581 account_settings ['system_access_token_expiration_in_seconds' ] = 3000
15871582
15881583 create_response = iam_identity_service .create_account_settings_template (
1589- name = 'Example-Account-Settings-Template' ,
1584+ name = account_settings_template_name ,
15901585 description = 'IAM enterprise account settings template example' ,
15911586 account_id = enterprise_account_id ,
15921587 account_settings = account_settings ,
@@ -1662,7 +1657,7 @@ def test_update_account_settings_template(self):
16621657 template_id = account_settings_template_id ,
16631658 version = str (account_settings_template_version ),
16641659 if_match = account_settings_template_etag ,
1665- name = 'Example-Account-Settings-Template' ,
1660+ name = account_settings_template_name ,
16661661 description = 'IAM enterprise account settings template example - updated' ,
16671662 account_settings = account_settings ,
16681663 )
@@ -1769,7 +1764,7 @@ def test_create_new_account_settings_template_version(self):
17691764
17701765 create_response = iam_identity_service .create_account_settings_template_version (
17711766 template_id = account_settings_template_id ,
1772- name = 'Example-Account-Settings-Template' ,
1767+ name = account_settings_template_name ,
17731768 description = 'IAM enterprise account settings template example - new version' ,
17741769 account_id = enterprise_account_id ,
17751770 account_settings = account_settings ,
@@ -2004,6 +1999,23 @@ def test_delete_preferences_on_scope_account(self):
20041999 except ApiException as e :
20052000 pytest .fail (str (e ))
20062001
2002+ @needscredentials
2003+ def test_delete_profile_example (self ):
2004+ """
2005+ delete_profile request example
2006+ """
2007+ try :
2008+ # begin-delete_profile
2009+
2010+ response = iam_identity_service .delete_profile (profile_id = profile_id )
2011+
2012+ # end-delete_profile
2013+
2014+ print ('\n delete_profile() response status code: ' , response .get_status_code ())
2015+
2016+ except ApiException as e :
2017+ pytest .fail (str (e ))
2018+
20072019
20082020# endregion
20092021##############################################################################
0 commit comments