Skip to content

Commit 85722d1

Browse files
authored
feat(IAM Policy Management): re-gen service after recent API changes for role template references (#289)
Signed-off-by: Bhavana Bellamgari <[email protected]>
1 parent 9c9b2a2 commit 85722d1

File tree

41 files changed

+1288
-324
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1288
-324
lines changed

modules/examples/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/IamPolicyManagementExamples.java

Lines changed: 74 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,9 @@
135135
import com.ibm.cloud.platform_services.iam_policy_management.v1.model.TemplateRole;
136136
import com.ibm.cloud.platform_services.iam_policy_management.v1.model.UpdateRoleAssignmentOptions;
137137
import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ReplaceRoleTemplateOptions;
138+
import com.ibm.cloud.platform_services.iam_policy_management.v1.model.RoleTemplateReferencesItem;
139+
import com.ibm.cloud.platform_services.iam_policy_management.v1.model.TemplateControl;
140+
import com.ibm.cloud.platform_services.iam_policy_management.v1.model.TemplateGrant;
138141

139142
import com.ibm.cloud.sdk.core.http.Response;
140143
import com.ibm.cloud.sdk.core.service.exception.ServiceResponseException;
@@ -197,6 +200,7 @@ protected IamPolicyManagementExamples() { }
197200
private static String exampleRoleTemplateVersion = null;
198201
private static String exampleRoleTemplateAssignmentId = null;
199202
private static String exampleRoleTemplateAssignmentETag = null;
203+
private static String exampleRolePolicyTemplateId = null;
200204

201205
static {
202206
System.setProperty("IBM_CREDENTIALS_FILE", "../../iam_policy_management.env");
@@ -809,10 +813,10 @@ public static void main(String[] args) throws Exception {
809813
Roles rolesModel = new Roles.Builder()
810814
.roleId("crn:v1:bluemix:public:iam::::serviceRole:Writer")
811815
.build();
812-
Grant grantModel = new Grant.Builder()
816+
TemplateGrant grantModel = new TemplateGrant.Builder()
813817
.roles(java.util.Arrays.asList(rolesModel))
814818
.build();
815-
Control controlModel = new Control.Builder()
819+
TemplateControl controlModel = new TemplateControl.Builder()
816820
.grant(grantModel)
817821
.build();
818822
V2PolicySubjectAttribute subjectAttributeService = new V2PolicySubjectAttribute.Builder()
@@ -883,10 +887,10 @@ public static void main(String[] args) throws Exception {
883887
Roles rolesModel = new Roles.Builder()
884888
.roleId("crn:v1:bluemix:public:iam::::serviceRole:Reader")
885889
.build();
886-
Grant grantModel = new Grant.Builder()
890+
TemplateGrant grantModel = new TemplateGrant.Builder()
887891
.roles(java.util.Arrays.asList(rolesModel))
888892
.build();
889-
Control controlModel = new Control.Builder()
893+
TemplateControl controlModel = new TemplateControl.Builder()
890894
.grant(grantModel)
891895
.build();
892896
V2PolicySubjectAttribute subjectAttributeService = new V2PolicySubjectAttribute.Builder()
@@ -951,10 +955,10 @@ public static void main(String[] args) throws Exception {
951955
Roles rolesModel = new Roles.Builder()
952956
.roleId("crn:v1:bluemix:public:iam::::role:Viewer")
953957
.build();
954-
Grant grantModel = new Grant.Builder()
958+
TemplateGrant grantModel = new TemplateGrant.Builder()
955959
.roles(java.util.Arrays.asList(rolesModel))
956960
.build();
957-
Control controlModel = new Control.Builder()
961+
TemplateControl controlModel = new TemplateControl.Builder()
958962
.grant(grantModel)
959963
.build();
960964
V2PolicySubjectAttribute subjectAttributeService = new V2PolicySubjectAttribute.Builder()
@@ -1580,6 +1584,55 @@ public static void main(String[] args) throws Exception {
15801584
e.getStatusCode(), e.getMessage(), e.getDebuggingInfo()), e);
15811585
}
15821586

1587+
try {
1588+
System.out.println("createRolePolicyTemplate() result:");
1589+
// begin-create_policy_template
1590+
V2PolicyResourceAttribute v2PolicyResourceAttributeModel = new V2PolicyResourceAttribute.Builder()
1591+
.key("serviceName")
1592+
.value("am-test-service")
1593+
.operator("stringEquals")
1594+
.build();
1595+
V2PolicyResource v2PolicyResourceModel = new V2PolicyResource.Builder()
1596+
.attributes(java.util.Arrays.asList(v2PolicyResourceAttributeModel))
1597+
.build();
1598+
Roles rolesModel = new Roles.Builder()
1599+
.roleId("crn:v1:bluemix:public:iam::::role:Viewer")
1600+
.build();
1601+
RoleTemplateReferencesItem roleTemplateReferencesModel = new RoleTemplateReferencesItem.Builder()
1602+
.id(exampleRoleTemplateId)
1603+
.version(exampleRoleTemplateVersion)
1604+
.build();
1605+
TemplateGrant grantModel = new TemplateGrant.Builder()
1606+
.roles(java.util.Arrays.asList(rolesModel))
1607+
.roleTemplateReferences(java.util.Arrays.asList(roleTemplateReferencesModel))
1608+
.build();
1609+
TemplateControl controlModel = new TemplateControl.Builder()
1610+
.grant(grantModel)
1611+
.build();
1612+
TemplatePolicy templatePolicyModel = new TemplatePolicy.Builder()
1613+
.type("access")
1614+
.resource(v2PolicyResourceModel)
1615+
.control(controlModel)
1616+
.build();
1617+
CreatePolicyTemplateOptions createPolicyTemplateOptions = new CreatePolicyTemplateOptions.Builder()
1618+
.name("SDKRolePTExamplesTest")
1619+
.accountId(exampleAccountId)
1620+
.policy(templatePolicyModel)
1621+
.build();
1622+
1623+
Response<PolicyTemplateLimitData> response = service.createPolicyTemplate(createPolicyTemplateOptions).execute();
1624+
PolicyTemplateLimitData policyTemplate = response.getResult();
1625+
1626+
exampleRolePolicyTemplateId = policyTemplate.getId();
1627+
1628+
System.out.println(policyTemplate);
1629+
// end-create_role_policy_template
1630+
1631+
} catch (ServiceResponseException e) {
1632+
logger.error(String.format("Service returned status code %s: %s%nError details: %s",
1633+
e.getStatusCode(), e.getMessage(), e.getDebuggingInfo()), e);
1634+
}
1635+
15831636
try {
15841637
System.out.println("getRoleTemplate() result:");
15851638
// begin-get_role_template
@@ -1603,9 +1656,7 @@ public static void main(String[] args) throws Exception {
16031656
System.out.println("replaceRoleTemplate() result:");
16041657
// begin-replace_role_template
16051658
TemplateRole templateRoleModel = new TemplateRole.Builder()
1606-
.name("SDKTestRoleTemplateRep")
16071659
.displayName("SDKTestRoleTemplateRep")
1608-
.serviceName("am-test-service")
16091660
.actions(java.util.Arrays.asList("am-test-service.test.create"))
16101661
.build();
16111662
ReplaceRoleTemplateOptions replaceRoleTemplateOptions = new ReplaceRoleTemplateOptions.Builder()
@@ -1651,9 +1702,7 @@ public static void main(String[] args) throws Exception {
16511702
System.out.println("createRoleTemplateVersion() result:");
16521703
// begin-create_role_template_version
16531704
TemplateRole templateRoleModel = new TemplateRole.Builder()
1654-
.name("SDKTestRoleVersion")
16551705
.displayName("SDKTestRoleVersionDisp")
1656-
.serviceName("am-test-service")
16571706
.description("am-test-service versioon customRole")
16581707
.actions(java.util.Arrays.asList("am-test-service.test.create"))
16591708
.build();
@@ -1833,6 +1882,21 @@ public static void main(String[] args) throws Exception {
18331882
logger.error(String.format("Service returned status code %s: %s%nError details: %s",
18341883
e.getStatusCode(), e.getMessage(), e.getDebuggingInfo()), e);
18351884
}
1885+
1886+
try {
1887+
// begin-delete_role_policy_template
1888+
DeletePolicyTemplateOptions deletePolicyTemplateOptions = new DeletePolicyTemplateOptions.Builder()
1889+
.policyTemplateId(exampleRolePolicyTemplateId)
1890+
.build();
1891+
1892+
Response<Void> response = service.deletePolicyTemplate(deletePolicyTemplateOptions).execute();
1893+
// end-delete_role_policy_template
1894+
System.out.printf("deleteRolePolicyTemplate() response status code: %d%n", response.getStatusCode());
1895+
} catch (ServiceResponseException e) {
1896+
logger.error(String.format("Service returned status code %s: %s%nError details: %s",
1897+
e.getStatusCode(), e.getMessage(), e.getDebuggingInfo()), e);
1898+
}
1899+
18361900
try {
18371901
// begin-delete_role_template_version
18381902
DeleteRoleTemplateVersionOptions deleteRoleTemplateVersionOptions = new DeleteRoleTemplateVersionOptions.Builder()

modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/IamPolicyManagement.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2252,13 +2252,15 @@ public ServiceCall<RoleTemplate> createRoleTemplateVersion(CreateRoleTemplateVer
22522252
}
22532253
builder.header("Accept", "application/json");
22542254
final JsonObject contentJson = new JsonObject();
2255-
contentJson.add("role", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(createRoleTemplateVersionOptions.role()));
22562255
if (createRoleTemplateVersionOptions.name() != null) {
22572256
contentJson.addProperty("name", createRoleTemplateVersionOptions.name());
22582257
}
22592258
if (createRoleTemplateVersionOptions.description() != null) {
22602259
contentJson.addProperty("description", createRoleTemplateVersionOptions.description());
22612260
}
2261+
if (createRoleTemplateVersionOptions.role() != null) {
2262+
contentJson.add("role", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(createRoleTemplateVersionOptions.role()));
2263+
}
22622264
if (createRoleTemplateVersionOptions.committed() != null) {
22632265
contentJson.addProperty("committed", createRoleTemplateVersionOptions.committed());
22642266
}
@@ -2323,13 +2325,15 @@ public ServiceCall<RoleTemplate> replaceRoleTemplate(ReplaceRoleTemplateOptions
23232325
builder.header("Accept", "application/json");
23242326
builder.header("If-Match", replaceRoleTemplateOptions.ifMatch());
23252327
final JsonObject contentJson = new JsonObject();
2326-
contentJson.add("role", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(replaceRoleTemplateOptions.role()));
23272328
if (replaceRoleTemplateOptions.name() != null) {
23282329
contentJson.addProperty("name", replaceRoleTemplateOptions.name());
23292330
}
23302331
if (replaceRoleTemplateOptions.description() != null) {
23312332
contentJson.addProperty("description", replaceRoleTemplateOptions.description());
23322333
}
2334+
if (replaceRoleTemplateOptions.role() != null) {
2335+
contentJson.add("role", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(replaceRoleTemplateOptions.role()));
2336+
}
23332337
if (replaceRoleTemplateOptions.committed() != null) {
23342338
contentJson.addProperty("committed", replaceRoleTemplateOptions.committed());
23352339
}

modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/CreateRoleTemplateOptions.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public class CreateRoleTemplateOptions extends GenericModel {
2424
protected String accountId;
2525
protected String description;
2626
protected Boolean committed;
27-
protected TemplateRole role;
27+
protected RoleTemplatePrototypeRole role;
2828
protected String acceptLanguage;
2929

3030
/**
@@ -35,7 +35,7 @@ public static class Builder {
3535
private String accountId;
3636
private String description;
3737
private Boolean committed;
38-
private TemplateRole role;
38+
private RoleTemplatePrototypeRole role;
3939
private String acceptLanguage;
4040

4141
/**
@@ -128,7 +128,7 @@ public Builder committed(Boolean committed) {
128128
* @param role the role
129129
* @return the CreateRoleTemplateOptions builder
130130
*/
131-
public Builder role(TemplateRole role) {
131+
public Builder role(RoleTemplatePrototypeRole role) {
132132
this.role = role;
133133
return this;
134134
}
@@ -222,7 +222,7 @@ public Boolean committed() {
222222
*
223223
* @return the role
224224
*/
225-
public TemplateRole role() {
225+
public RoleTemplatePrototypeRole role() {
226226
return role;
227227
}
228228

modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/CreateRoleTemplateVersionOptions.java

Lines changed: 27 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,19 @@
2121
public class CreateRoleTemplateVersionOptions extends GenericModel {
2222

2323
protected String roleTemplateId;
24-
protected TemplateRole role;
2524
protected String name;
2625
protected String description;
26+
protected TemplateRole role;
2727
protected Boolean committed;
2828

2929
/**
3030
* Builder.
3131
*/
3232
public static class Builder {
3333
private String roleTemplateId;
34-
private TemplateRole role;
3534
private String name;
3635
private String description;
36+
private TemplateRole role;
3737
private Boolean committed;
3838

3939
/**
@@ -43,9 +43,9 @@ public static class Builder {
4343
*/
4444
private Builder(CreateRoleTemplateVersionOptions createRoleTemplateVersionOptions) {
4545
this.roleTemplateId = createRoleTemplateVersionOptions.roleTemplateId;
46-
this.role = createRoleTemplateVersionOptions.role;
4746
this.name = createRoleTemplateVersionOptions.name;
4847
this.description = createRoleTemplateVersionOptions.description;
48+
this.role = createRoleTemplateVersionOptions.role;
4949
this.committed = createRoleTemplateVersionOptions.committed;
5050
}
5151

@@ -59,11 +59,9 @@ public Builder() {
5959
* Instantiates a new builder with required properties.
6060
*
6161
* @param roleTemplateId the roleTemplateId
62-
* @param role the role
6362
*/
64-
public Builder(String roleTemplateId, TemplateRole role) {
63+
public Builder(String roleTemplateId) {
6564
this.roleTemplateId = roleTemplateId;
66-
this.role = role;
6765
}
6866

6967
/**
@@ -86,17 +84,6 @@ public Builder roleTemplateId(String roleTemplateId) {
8684
return this;
8785
}
8886

89-
/**
90-
* Set the role.
91-
*
92-
* @param role the role
93-
* @return the CreateRoleTemplateVersionOptions builder
94-
*/
95-
public Builder role(TemplateRole role) {
96-
this.role = role;
97-
return this;
98-
}
99-
10087
/**
10188
* Set the name.
10289
*
@@ -119,6 +106,17 @@ public Builder description(String description) {
119106
return this;
120107
}
121108

109+
/**
110+
* Set the role.
111+
*
112+
* @param role the role
113+
* @return the CreateRoleTemplateVersionOptions builder
114+
*/
115+
public Builder role(TemplateRole role) {
116+
this.role = role;
117+
return this;
118+
}
119+
122120
/**
123121
* Set the committed.
124122
*
@@ -136,12 +134,10 @@ protected CreateRoleTemplateVersionOptions() { }
136134
protected CreateRoleTemplateVersionOptions(Builder builder) {
137135
com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.roleTemplateId,
138136
"roleTemplateId cannot be empty");
139-
com.ibm.cloud.sdk.core.util.Validator.notNull(builder.role,
140-
"role cannot be null");
141137
roleTemplateId = builder.roleTemplateId;
142-
role = builder.role;
143138
name = builder.name;
144139
description = builder.description;
140+
role = builder.role;
145141
committed = builder.committed;
146142
}
147143

@@ -165,17 +161,6 @@ public String roleTemplateId() {
165161
return roleTemplateId;
166162
}
167163

168-
/**
169-
* Gets the role.
170-
*
171-
* The role properties that are created in an action resource when the template is assigned.
172-
*
173-
* @return the role
174-
*/
175-
public TemplateRole role() {
176-
return role;
177-
}
178-
179164
/**
180165
* Gets the name.
181166
*
@@ -200,6 +185,17 @@ public String description() {
200185
return description;
201186
}
202187

188+
/**
189+
* Gets the role.
190+
*
191+
* The role properties that are created in an action resource when the template is assigned.
192+
*
193+
* @return the role
194+
*/
195+
public TemplateRole role() {
196+
return role;
197+
}
198+
203199
/**
204200
* Gets the committed.
205201
*

0 commit comments

Comments
 (0)