23
23
from ibm_platform_services .iam_policy_management_v1 import *
24
24
25
25
#
26
- # Below are examples on how to use IAM Policy Management service
26
+ # This file provides an example of how to use the IAM Policy Management service.
27
27
#
28
- # The following environment variables are assumed to be defined when running examples below :
28
+ # The following configuration properties are assumed to be defined:
29
29
#
30
- # IAM_POLICY_MANAGEMENT_URL=https://iam.cloud.ibm.com
30
+ # IAM_POLICY_MANAGEMENT_URL=<service url>
31
31
# IAM_POLICY_MANAGEMENT_AUTH_TYPE=iam
32
- # IAM_POLICY_MANAGEMENT_AUTH_URL=https://iam.cloud.ibm.com/identity/ token
33
- # IAM_POLICY_MANAGEMENT_APIKEY= <YOUR_APIKEY>
34
- # IAM_POLICY_MANAGEMENT_TEST_ACCOUNT_ID= <YOUR_ACCOUNT_ID>
32
+ # IAM_POLICY_MANAGEMENT_AUTH_URL=<IAM token service URL - omit this if using the production environment>
33
+ # IAM_POLICY_MANAGEMENT_APIKEY=<YOUR_APIKEY>
34
+ # IAM_POLICY_MANAGEMENT_TEST_ACCOUNT_ID=<YOUR_ACCOUNT_ID>
35
35
#
36
- # Alternatively, above environment variables can be placed in a "credentials" file and then:
37
- # export IBM_CREDENTIALS_FILE=<name of credentials file>
36
+ # These configuration properties can be exported as environment variables, or stored
37
+ # in a configuration file and then:
38
+ # export IBM_CREDENTIALS_FILE=<name of config file>
38
39
#
39
-
40
40
# Config file name
41
41
config_file = 'iam_policy_management.env'
42
42
56
56
# Start of Examples for Service: IamPolicyManagementV1
57
57
##############################################################################
58
58
# region
59
+
60
+
59
61
class TestIamPolicyManagementV1Examples ():
60
62
"""
61
63
Example Test Class for IamPolicyManagementV1
@@ -77,7 +79,8 @@ def setup_class(cls):
77
79
78
80
# Load the configuration
79
81
global config , example_account_id
80
- config = read_external_sources (IamPolicyManagementV1 .DEFAULT_SERVICE_NAME )
82
+ config = read_external_sources (
83
+ IamPolicyManagementV1 .DEFAULT_SERVICE_NAME )
81
84
example_account_id = config ['TEST_ACCOUNT_ID' ]
82
85
83
86
print ('Setup complete.' )
@@ -103,7 +106,8 @@ def test_create_policy_example(self):
103
106
name = 'accountId' , value = example_account_id )
104
107
service_name_resource_attribute = ResourceAttribute (
105
108
name = 'serviceName' , value = example_service_name )
106
- policy_resource_tag = ResourceTag (name = 'project' , value = 'prototype' )
109
+ policy_resource_tag = ResourceTag (
110
+ name = 'project' , value = 'prototype' )
107
111
policy_resources = PolicyResource (
108
112
attributes = [account_id_resource_attribute ,
109
113
service_name_resource_attribute ],
@@ -160,7 +164,8 @@ def test_update_policy_example(self):
160
164
name = 'accountId' , value = example_account_id )
161
165
service_name_resource_attribute = ResourceAttribute (
162
166
name = 'serviceName' , value = example_service_name )
163
- policy_resource_tag = ResourceTag (name = 'project' , value = 'prototype' )
167
+ policy_resource_tag = ResourceTag (
168
+ name = 'project' , value = 'prototype' )
164
169
policy_resources = PolicyResource (
165
170
attributes = [account_id_resource_attribute ,
166
171
service_name_resource_attribute ],
@@ -277,7 +282,8 @@ def test_update_role_example(self):
277
282
try :
278
283
# begin-update_role
279
284
280
- updated_role_actions = ['iam-groups.groups.read' , 'iam-groups.groups.list' ]
285
+ updated_role_actions = [
286
+ 'iam-groups.groups.read' , 'iam-groups.groups.list' ]
281
287
custom_role = iam_policy_management_service .update_role (
282
288
role_id = example_custom_role_id ,
283
289
if_match = example_custom_role_etag ,
0 commit comments