Skip to content

Commit dd7db9f

Browse files
committed
feat(IAM Policy Management): re-gen service after recent API changes for role template references
Signed-off-by: Bhavana Bellamgari <[email protected]>
1 parent fe2358e commit dd7db9f

File tree

4 files changed

+954
-214
lines changed

4 files changed

+954
-214
lines changed

examples/test_iam_policy_management_v1_examples.py

Lines changed: 82 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
example_role_template_etag = None
7373
example_role_template_assignment_id = None
7474
example_role_template_assignment_etag = None
75+
example_role_policy_template_id = None
7576

7677

7778
##############################################################################
@@ -1443,10 +1444,17 @@ def test_create_role_template_example(self):
14431444
print('\ncreate_role_template() result:')
14441445

14451446
# begin-create_role_template
1446-
1447+
template_role_model = {
1448+
'name': 'SDKCustomRoleName',
1449+
'display_name': 'SDK Test Custom Role',
1450+
'service_name': 'am-test-service',
1451+
'description': 'SDK Test Custom Role',
1452+
'actions': ['am-test-service.test.create'],
1453+
}
14471454
response = iam_policy_management_service.create_role_template(
14481455
name='SDKRoleTemplateExample',
14491456
account_id=example_account_id,
1457+
role=template_role_model,
14501458
)
14511459
role_template = response.get_result()
14521460

@@ -1462,6 +1470,61 @@ def test_create_role_template_example(self):
14621470
except ApiException as e:
14631471
pytest.fail(str(e))
14641472

1473+
@needscredentials
1474+
def test_create_role_policy_template_example(self):
1475+
"""
1476+
create_role_policy_template request example
1477+
"""
1478+
try:
1479+
print('\ncreate_role_policy_template() result:')
1480+
# begin-create_role_policy_template
1481+
1482+
policy_resource_model = {
1483+
'attributes': [
1484+
{
1485+
'key': 'serviceName',
1486+
'operator': 'stringEquals',
1487+
'value': 'am-test-service',
1488+
}
1489+
],
1490+
}
1491+
1492+
control_model = TemplateControl(
1493+
grant=TemplateGrant(
1494+
roles=[
1495+
{
1496+
'role_id': 'crn:v1:bluemix:public:iam::::role:Viewer',
1497+
}
1498+
],
1499+
role_template_references=[
1500+
{'id': example_role_template_id, 'version': example_role_template_version}
1501+
],
1502+
)
1503+
)
1504+
1505+
template_policy_model = {
1506+
'type': 'access',
1507+
'resource': policy_resource_model,
1508+
'control': control_model.to_dict(),
1509+
}
1510+
1511+
response = iam_policy_management_service.create_policy_template(
1512+
name='SDKExamplesTest',
1513+
account_id=example_account_id,
1514+
policy=template_policy_model,
1515+
)
1516+
policy_template = response.get_result()
1517+
1518+
global example_role_policy_template_id
1519+
example_role_policy_template_id = policy_template['id']
1520+
1521+
print(json.dumps(policy_template, indent=2))
1522+
1523+
# end-create_policy_template
1524+
1525+
except ApiException as e:
1526+
pytest.fail(str(e))
1527+
14651528
# @needscredentials
14661529
def test_get_role_template_example(self):
14671530
"""
@@ -1498,7 +1561,6 @@ def test_replace_role_template_example(self):
14981561
# begin-replace_role_template
14991562

15001563
template_role_model = {
1501-
'name': 'SDKRoleTemplateExampleRe',
15021564
'display_name': 'am-test-service',
15031565
'service_name': 'am-test-service',
15041566
'actions': ['am-test-service.test.delete'],
@@ -1558,9 +1620,7 @@ def test_create_role_template_version_example(self):
15581620
# begin-create_role_template_version
15591621

15601622
template_role_model = {
1561-
'name': 'SDKRoleTemplateExampleVer',
15621623
'display_name': 'am-test-service',
1563-
'service_name': 'am-test-service',
15641624
'actions': ['am-test-service.test.delete', 'am-test-service.test.create'],
15651625
}
15661626

@@ -1779,6 +1839,24 @@ def test_delete_role_assignment_example(self):
17791839
except ApiException as e:
17801840
pytest.fail(str(e))
17811841

1842+
@needscredentials
1843+
def test_delete_role_policy_template_example(self):
1844+
"""
1845+
delete_role_policy_template request example
1846+
"""
1847+
try:
1848+
# begin-delete_role_policy_template
1849+
1850+
response = iam_policy_management_service.delete_policy_template(
1851+
policy_template_id=example_role_policy_template_id,
1852+
)
1853+
1854+
# end-delete_policy_template
1855+
print('\ndelete_role_policy_template() response status code: ', response.get_status_code())
1856+
1857+
except ApiException as e:
1858+
pytest.fail(str(e))
1859+
17821860
# @needscredentials
17831861
def test_delete_role_template_version_example(self):
17841862
"""

0 commit comments

Comments
 (0)