Skip to content

Commit 87da690

Browse files
committed
fix(Configuration Governance): re-gen service after recent API changes
1 parent 9e621c1 commit 87da690

File tree

3 files changed

+525
-181
lines changed

3 files changed

+525
-181
lines changed

examples/test_configuration_governance_v1_examples.py

Lines changed: 81 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
15-
1615
"""
1716
Examples for ConfigurationGovernanceV1
1817
"""
@@ -43,8 +42,6 @@
4342
enterprise_scope_id = None
4443
subacct_scope_id = None
4544

46-
transaction_id = str(uuid.uuid4())
47-
4845

4946
##############################################################################
5047
# Start of Examples for Service: ConfigurationGovernanceV1
@@ -54,7 +51,6 @@ class TestConfigurationGovernanceV1Examples():
5451
"""
5552
Example Test Class for ConfigurationGovernanceV1
5653
"""
57-
5854
@classmethod
5955
def setup_class(cls):
6056
global configuration_governance_service
@@ -84,8 +80,8 @@ def setup_class(cls):
8480
print('Setup complete.')
8581

8682
needscredentials = pytest.mark.skipif(
87-
not os.path.exists(config_file), reason="External configuration not available, skipping..."
88-
)
83+
not os.path.exists(config_file),
84+
reason="External configuration not available, skipping...")
8985

9086
@needscredentials
9187
def test_create_rules_example(self):
@@ -106,35 +102,68 @@ def test_create_rules_example(self):
106102
'operator': 'is_true'
107103
}
108104

109-
enforcement_action_model = {
110-
'action': 'disallow'
111-
}
105+
enforcement_action_model = {'action': 'disallow'}
112106

113107
rule_request_model = {
114108
'account_id': account_id,
115109
'name': 'Disable public access',
116-
'description': 'Ensure that public access to account resources is disabled.',
117-
'target': {'service_name': service_name, 'resource_kind': 'service'},
118-
'required_config': {'description': 'Public access check', 'and': [{'property': 'public_access_enabled', 'operator': 'is_false'}]},
110+
'description':
111+
'Ensure that public access to account resources is disabled.',
112+
'target': {
113+
'service_name': service_name,
114+
'resource_kind': 'service'
115+
},
116+
'required_config': {
117+
'description':
118+
'Public access check',
119+
'and': [{
120+
'property': 'public_access_enabled',
121+
'operator': 'is_false'
122+
}]
123+
},
119124
'enforcement_actions': [enforcement_action_model],
120125
'labels': [test_label]
121126
}
122127

123128
create_rule_request_model = {
124129
'request_id': '3cebc877-58e7-44a5-a292-32114fa73558',
125-
'rule': {'account_id': account_id, 'name': 'Disable public access', 'description': 'Ensure that public access to account resources is disabled.', 'labels': [test_label], 'target': {'service_name': service_name, 'resource_kind': 'service'}, 'required_config': {'description': 'Public access check', 'and': [{'property': 'public_access_enabled', 'operator': 'is_false'}]}, 'enforcement_actions': [{'action': 'disallow'}, {'action': 'audit_log'}]}
130+
'rule': {
131+
'account_id':
132+
account_id,
133+
'name':
134+
'Disable public access',
135+
'description':
136+
'Ensure that public access to account resources is disabled.',
137+
'labels': [test_label],
138+
'target': {
139+
'service_name': service_name,
140+
'resource_kind': 'service'
141+
},
142+
'required_config': {
143+
'description':
144+
'Public access check',
145+
'and': [{
146+
'property': 'public_access_enabled',
147+
'operator': 'is_false'
148+
}]
149+
},
150+
'enforcement_actions': [{
151+
'action': 'disallow'
152+
}, {
153+
'action': 'audit_log'
154+
}]
155+
}
126156
}
127157

128158
detailed_response = configuration_governance_service.create_rules(
129-
rules=[create_rule_request_model],
130-
transaction_id=transaction_id
131-
)
159+
rules=[create_rule_request_model])
132160
create_rules_response = detailed_response.get_result()
133161
if detailed_response.status_code == 207:
134162
for responseEntry in create_rules_response['rules']:
135163
if responseEntry['status_code'] > 299:
136164
raise ApiException(
137-
code=responseEntry['errors'][0]['code'], message=responseEntry['errors'][0]['message'])
165+
code=responseEntry['errors'][0]['code'],
166+
message=responseEntry['errors'][0]['message'])
138167

139168
print(json.dumps(create_rules_response, indent=2))
140169

@@ -161,22 +190,25 @@ def test_create_attachments_example(self):
161190

162191
attachment_request_model = {
163192
'account_id': account_id,
164-
'included_scope': {'note': 'My enterprise', 'scope_id': enterprise_scope_id, 'scope_type': 'enterprise'},
193+
'included_scope': {
194+
'note': 'My enterprise',
195+
'scope_id': enterprise_scope_id,
196+
'scope_type': 'enterprise'
197+
},
165198
'excluded_scopes': [excluded_scope_model]
166199
}
167200

168201
create_attachments_response = configuration_governance_service.create_attachments(
169202
rule_id=rule_id_link,
170-
attachments=[attachment_request_model],
171-
transaction_id=transaction_id
172-
).get_result()
203+
attachments=[attachment_request_model]).get_result()
173204

174205
print(json.dumps(create_attachments_response, indent=2))
175206

176207
# end-create_attachments
177208

178209
global attachment_id_link
179-
attachment_id_link = create_attachments_response['attachments'][0]['attachment_id']
210+
attachment_id_link = create_attachments_response['attachments'][0][
211+
'attachment_id']
180212
except ApiException as e:
181213
pytest.fail(str(e))
182214

@@ -190,9 +222,7 @@ def test_get_attachment_example(self):
190222

191223
attachment = configuration_governance_service.get_attachment(
192224
rule_id=rule_id_link,
193-
attachment_id=attachment_id_link,
194-
transaction_id=transaction_id
195-
).get_result()
225+
attachment_id=attachment_id_link).get_result()
196226

197227
print(json.dumps(attachment, indent=2))
198228

@@ -201,9 +231,7 @@ def test_get_attachment_example(self):
201231
global attachment_etag_link
202232
attachment_etag_link = configuration_governance_service.get_attachment(
203233
rule_id=rule_id_link,
204-
attachment_id=attachment_id_link,
205-
transaction_id=transaction_id
206-
).get_headers().get('Etag')
234+
attachment_id=attachment_id_link).get_headers().get('Etag')
207235
except ApiException as e:
208236
pytest.fail(str(e))
209237

@@ -216,19 +244,15 @@ def test_get_rule_example(self):
216244
# begin-get_rule
217245

218246
rule = configuration_governance_service.get_rule(
219-
rule_id=rule_id_link,
220-
transaction_id=transaction_id
221-
).get_result()
247+
rule_id=rule_id_link).get_result()
222248

223249
print(json.dumps(rule, indent=2))
224250

225251
# end-get_rule
226252

227253
global rule_etag_link
228254
rule_etag_link = configuration_governance_service.get_rule(
229-
rule_id=rule_id_link,
230-
transaction_id=transaction_id
231-
).get_headers().get('etag')
255+
rule_id=rule_id_link).get_headers().get('etag')
232256
except ApiException as e:
233257
pytest.fail(str(e))
234258

@@ -241,9 +265,7 @@ def test_list_rules_example(self):
241265
# begin-list_rules
242266

243267
rule_list = configuration_governance_service.list_rules(
244-
account_id=account_id,
245-
transaction_id=transaction_id
246-
).get_result()
268+
account_id=account_id).get_result()
247269

248270
print(json.dumps(rule_list, indent=2))
249271

@@ -276,25 +298,27 @@ def test_update_rule_example(self):
276298
'operator': 'is_false'
277299
}
278300

279-
enforcement_action_model = {
280-
'action': 'audit_log'
281-
}
301+
enforcement_action_model = {'action': 'audit_log'}
282302

283303
rule = configuration_governance_service.update_rule(
284304
rule_id=rule_id_link,
285-
transaction_id=transaction_id,
286305
if_match=rule_etag_link,
287306
name='Disable public access',
288-
description='Ensure that public access to account resources is disabled.',
289-
target={'service_name': service_name, 'resource_kind': 'service',
290-
'additional_target_attributes': []},
307+
description=
308+
'Ensure that public access to account resources is disabled.',
309+
target={
310+
'service_name': service_name,
311+
'resource_kind': 'service',
312+
'additional_target_attributes': []
313+
},
291314
required_config={
292-
'property': 'public_access_enabled', 'operator': 'is_false'},
315+
'property': 'public_access_enabled',
316+
'operator': 'is_false'
317+
},
293318
enforcement_actions=[enforcement_action_model],
294319
account_id=account_id,
295320
rule_type='user_defined',
296-
labels=['testString']
297-
).get_result()
321+
labels=['testString']).get_result()
298322

299323
print(json.dumps(rule, indent=2))
300324

@@ -312,9 +336,7 @@ def test_list_attachments_example(self):
312336
# begin-list_attachments
313337

314338
attachment_list = configuration_governance_service.list_attachments(
315-
rule_id=rule_id_link,
316-
transaction_id=transaction_id
317-
).get_result()
339+
rule_id=rule_id_link).get_result()
318340

319341
print(json.dumps(attachment_list, indent=2))
320342

@@ -340,13 +362,14 @@ def test_update_attachment_example(self):
340362
attachment = configuration_governance_service.update_attachment(
341363
rule_id=rule_id_link,
342364
attachment_id=attachment_id_link,
343-
transaction_id=transaction_id,
344365
if_match=attachment_etag_link,
345366
account_id=account_id,
346-
included_scope={'note': 'My enterprise',
347-
'scope_id': enterprise_scope_id, 'scope_type': 'enterprise'},
348-
excluded_scopes=[excluded_scope_model]
349-
).get_result()
367+
included_scope={
368+
'note': 'My enterprise',
369+
'scope_id': enterprise_scope_id,
370+
'scope_type': 'enterprise'
371+
},
372+
excluded_scopes=[excluded_scope_model]).get_result()
350373

351374
print(json.dumps(attachment, indent=2))
352375

@@ -365,9 +388,7 @@ def test_delete_attachment_example(self):
365388

366389
response = configuration_governance_service.delete_attachment(
367390
rule_id=rule_id_link,
368-
attachment_id=attachment_id_link,
369-
transaction_id=transaction_id
370-
).get_result()
391+
attachment_id=attachment_id_link).get_result()
371392

372393
print(json.dumps(response, indent=2))
373394

@@ -385,9 +406,7 @@ def test_delete_rule_example(self):
385406
# begin-delete_rule
386407

387408
response = configuration_governance_service.delete_rule(
388-
rule_id=rule_id_link,
389-
transaction_id=transaction_id
390-
).get_result()
409+
rule_id=rule_id_link).get_result()
391410

392411
print(json.dumps(response, indent=2))
393412

@@ -403,7 +422,6 @@ def clean_rules(cls):
403422
"""
404423
try:
405424
rule_list = configuration_governance_service.list_rules(
406-
transaction_id=transaction_id,
407425
account_id=account_id,
408426
labels=test_label,
409427
).get_result()
@@ -416,6 +434,7 @@ def clean_rules(cls):
416434
except ApiException as e:
417435
print(str(e))
418436

437+
419438
# endregion
420439
##############################################################################
421440
# End of Examples for Service: ConfigurationGovernanceV1

0 commit comments

Comments
 (0)