@@ -74,6 +74,8 @@ def setup_class(cls):
74
74
enterprise_scope_id = config ['ENTERPRISE_SCOPE_ID' ]
75
75
subacct_scope_id = config ['SUBACCT_SCOPE_ID' ]
76
76
77
+ cls .clean_rules ()
78
+
77
79
print ('Setup complete.' )
78
80
79
81
needscredentials = pytest .mark .skipif (
@@ -139,16 +141,16 @@ def test_create_attachments_example(self):
139
141
try :
140
142
# begin-create_attachments
141
143
142
- rule_scope_model = {
143
- 'note' : 'My enterprise ' ,
144
- 'scope_id' : enterprise_scope_id ,
145
- 'scope_type' : 'enterprise'
144
+ excluded_scope_model = {
145
+ 'note' : 'Development account ' ,
146
+ 'scope_id' : subacct_scope_id ,
147
+ 'scope_type' : 'enterprise.account '
146
148
}
147
149
148
150
attachment_request_model = {
149
151
'account_id' : account_id ,
150
152
'included_scope' : {'note' :'My enterprise' ,'scope_id' :enterprise_scope_id ,'scope_type' :'enterprise' },
151
- 'excluded_scopes' : [rule_scope_model ]
153
+ 'excluded_scopes' : [excluded_scope_model ]
152
154
}
153
155
154
156
create_attachments_response = configuration_governance_service .create_attachments (
@@ -183,7 +185,8 @@ def test_get_attachment_example(self):
183
185
# end-get_attachment
184
186
185
187
global attachment_etag_link
186
- attachment_etag_link = attachment ['' ];
188
+ attachment_etag_link = configuration_governance_service .get_attachment (
189
+ rule_id = rule_id_link , attachment_id = attachment_id_link ).get_headers ().get ('Etag' )
187
190
except ApiException as e :
188
191
pytest .fail (str (e ))
189
192
@@ -204,7 +207,7 @@ def test_get_rule_example(self):
204
207
# end-get_rule
205
208
206
209
global rule_etag_link
207
- rule_etag_link = rule [ '' ];
210
+ rule_etag_link = configuration_governance_service . get_rule ( rule_id = rule_id_link ). get_headers (). get ( 'etag' )
208
211
except ApiException as e :
209
212
pytest .fail (str (e ))
210
213
@@ -257,7 +260,7 @@ def test_update_rule_example(self):
257
260
258
261
rule = configuration_governance_service .update_rule (
259
262
rule_id = rule_id_link ,
260
- if_match = 'testString' ,
263
+ if_match = rule_etag_link ,
261
264
name = 'Disable public access' ,
262
265
description = 'Ensure that public access to account resources is disabled.' ,
263
266
target = {'service_name' :service_name ,'resource_kind' :'service' ,'additional_target_attributes' :[]},
@@ -303,19 +306,19 @@ def test_update_attachment_example(self):
303
306
try :
304
307
# begin-update_attachment
305
308
306
- rule_scope_model = {
307
- 'note' : 'My enterprise ' ,
308
- 'scope_id' : enterprise_scope_id ,
309
- 'scope_type' : 'enterprise'
309
+ excluded_scope_model = {
310
+ 'note' : 'Development account ' ,
311
+ 'scope_id' : subacct_scope_id ,
312
+ 'scope_type' : 'enterprise.account '
310
313
}
311
314
312
315
attachment = configuration_governance_service .update_attachment (
313
316
rule_id = rule_id_link ,
314
317
attachment_id = attachment_id_link ,
315
- if_match = 'testString' ,
318
+ if_match = attachment_etag_link ,
316
319
account_id = account_id ,
317
320
included_scope = {'note' :'My enterprise' ,'scope_id' :enterprise_scope_id ,'scope_type' :'enterprise' },
318
- excluded_scopes = [rule_scope_model ]
321
+ excluded_scopes = [excluded_scope_model ]
319
322
).get_result ()
320
323
321
324
print (json .dumps (attachment , indent = 2 ))
@@ -364,6 +367,25 @@ def test_delete_rule_example(self):
364
367
except ApiException as e :
365
368
pytest .fail (str (e ))
366
369
370
+ @classmethod
371
+ def clean_rules (cls ):
372
+ """
373
+ Clean up rules from prior test runs
374
+ """
375
+ try :
376
+ rule_list = configuration_governance_service .list_rules (
377
+ account_id = account_id ,
378
+ labels = test_label
379
+ ).get_result ()
380
+
381
+ for rule in rule_list ['rules' ]:
382
+ rule_id = rule ['rule_id' ]
383
+ print (f'deleting rule { rule_id } ' )
384
+ configuration_governance_service .delete_rule (rule_id )
385
+
386
+ except ApiException as e :
387
+ print (str (e ))
388
+
367
389
# endregion
368
390
##############################################################################
369
391
# End of Examples for Service: ConfigurationGovernanceV1
0 commit comments