From 2fc014bc6ee2f835d5752c3d410eaf0e6ddd8f21 Mon Sep 17 00:00:00 2001 From: Hari K Arla Date: Fri, 24 Oct 2025 19:59:01 +0530 Subject: [PATCH] feat(IAM Policy Management): add enterprise custom role template Signed-off-by: Hari K Arla --- .../v1/IamPolicyManagementExamples.java | 334 +++++ .../v1/IamPolicyManagement.java | 486 ++++++- ...ontrolAssignmentResourceActionControl.java | 6 +- .../v1/model/AssignmentResourceError.java | 88 ++ .../v1/model/CommitRoleTemplateOptions.java | 134 ++ .../CreateRoleTemplateAssignmentOptions.java | 191 +++ .../v1/model/CreateRoleTemplateOptions.java | 251 ++++ .../CreateRoleTemplateVersionOptions.java | 215 ++++ .../v1/model/DeleteRoleAssignmentOptions.java | 104 ++ .../v1/model/DeleteRoleTemplateOptions.java | 104 ++ .../DeleteRoleTemplateVersionOptions.java | 134 ++ .../v1/model/ErrorObject.java | 6 + .../v1/model/GetRoleAssignmentOptions.java | 104 ++ .../v1/model/GetRoleTemplateOptions.java | 140 ++ .../model/GetRoleTemplateVersionOptions.java | 134 ++ .../v1/model/ListRoleAssignmentsOptions.java | 245 ++++ .../ListRoleTemplateVersionsOptions.java | 192 +++ .../v1/model/ListRoleTemplatesOptions.java | 307 +++++ .../model/PolicyAssignmentResourcePolicy.java | 6 +- .../v1/model/ReplaceRoleTemplateOptions.java | 277 ++++ .../v1/model/RoleAssignment.java | 207 +++ .../v1/model/RoleAssignmentCollection.java | 88 ++ .../v1/model/RoleAssignmentResource.java | 50 + .../model/RoleAssignmentResourceCreated.java | 38 + .../v1/model/RoleAssignmentResourceRole.java | 53 + .../v1/model/RoleAssignmentTemplate.java | 134 ++ .../v1/model/RoleAssignmentsPager.java | 108 ++ .../v1/model/RoleTemplate.java | 202 +++ .../v1/model/RoleTemplateCollection.java | 90 ++ .../model/RoleTemplateVersionsCollection.java | 88 ++ .../v1/model/RoleTemplateVersionsPager.java | 108 ++ .../v1/model/RoleTemplatesPager.java | 108 ++ .../v1/model/TemplateRole.java | 243 ++++ .../v1/model/UpdateRoleAssignmentOptions.java | 166 +++ .../v1/IamPolicyManagementIT.java | 314 ++++- .../v1/IamPolicyManagementTest.java | 1130 ++++++++++++++++- ...olAssignmentResourceActionControlTest.java | 2 +- .../ActionControlAssignmentResourceTest.java | 2 +- .../v1/model/AssignmentResourceErrorTest.java | 44 + .../model/CommitRoleTemplateOptionsTest.java | 47 + ...eateRoleTemplateAssignmentOptionsTest.java | 65 + .../model/CreateRoleTemplateOptionsTest.java | 69 + .../CreateRoleTemplateVersionOptionsTest.java | 67 + .../DeleteRoleAssignmentOptionsTest.java | 45 + .../model/DeleteRoleTemplateOptionsTest.java | 45 + .../DeleteRoleTemplateVersionOptionsTest.java | 47 + .../model/GetRoleAssignmentOptionsTest.java | 45 + .../v1/model/GetRoleTemplateOptionsTest.java | 47 + .../GetRoleTemplateVersionOptionsTest.java | 47 + .../model/ListRoleAssignmentsOptionsTest.java | 55 + .../ListRoleTemplateVersionsOptionsTest.java | 51 + .../model/ListRoleTemplatesOptionsTest.java | 59 + .../PolicyAssignmentResourcePolicyTest.java | 2 +- .../model/PolicyAssignmentResourcesTest.java | 2 +- .../PolicyAssignmentV1CollectionTest.java | 2 +- .../PolicyAssignmentV1ResourcesTest.java | 2 +- .../v1/model/PolicyAssignmentV1Test.java | 2 +- ...olicyTemplateAssignmentCollectionTest.java | 2 +- ...teAssignmentItemsPolicyAssignmentTest.java | 2 +- ...AssignmentItemsPolicyAssignmentV1Test.java | 2 +- .../PolicyTemplateAssignmentItemsTest.java | 2 +- .../model/ReplaceRoleTemplateOptionsTest.java | 71 ++ .../model/RoleAssignmentCollectionTest.java | 47 + .../RoleAssignmentResourceCreatedTest.java | 37 + .../model/RoleAssignmentResourceRoleTest.java | 43 + .../v1/model/RoleAssignmentResourceTest.java | 45 + .../v1/model/RoleAssignmentTemplateTest.java | 54 + ...ponseTest.java => RoleAssignmentTest.java} | 20 +- .../v1/model/RoleTemplateCollectionTest.java | 46 + .../v1/model/RoleTemplateTest.java | 44 + .../RoleTemplateVersionsCollectionTest.java | 46 + .../v1/model/TemplateRoleTest.java | 62 + .../UpdateRoleAssignmentOptionsTest.java | 49 + 73 files changed, 7855 insertions(+), 49 deletions(-) create mode 100644 modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/AssignmentResourceError.java create mode 100644 modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/CommitRoleTemplateOptions.java create mode 100644 modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/CreateRoleTemplateAssignmentOptions.java create mode 100644 modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/CreateRoleTemplateOptions.java create mode 100644 modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/CreateRoleTemplateVersionOptions.java create mode 100644 modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/DeleteRoleAssignmentOptions.java create mode 100644 modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/DeleteRoleTemplateOptions.java create mode 100644 modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/DeleteRoleTemplateVersionOptions.java create mode 100644 modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/GetRoleAssignmentOptions.java create mode 100644 modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/GetRoleTemplateOptions.java create mode 100644 modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/GetRoleTemplateVersionOptions.java create mode 100644 modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ListRoleAssignmentsOptions.java create mode 100644 modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ListRoleTemplateVersionsOptions.java create mode 100644 modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ListRoleTemplatesOptions.java create mode 100644 modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ReplaceRoleTemplateOptions.java create mode 100644 modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/RoleAssignment.java create mode 100644 modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/RoleAssignmentCollection.java create mode 100644 modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/RoleAssignmentResource.java create mode 100644 modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/RoleAssignmentResourceCreated.java create mode 100644 modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/RoleAssignmentResourceRole.java create mode 100644 modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/RoleAssignmentTemplate.java create mode 100644 modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/RoleAssignmentsPager.java create mode 100644 modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/RoleTemplate.java create mode 100644 modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/RoleTemplateCollection.java create mode 100644 modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/RoleTemplateVersionsCollection.java create mode 100644 modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/RoleTemplateVersionsPager.java create mode 100644 modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/RoleTemplatesPager.java create mode 100644 modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/TemplateRole.java create mode 100644 modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/UpdateRoleAssignmentOptions.java create mode 100644 modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/AssignmentResourceErrorTest.java create mode 100644 modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/CommitRoleTemplateOptionsTest.java create mode 100644 modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/CreateRoleTemplateAssignmentOptionsTest.java create mode 100644 modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/CreateRoleTemplateOptionsTest.java create mode 100644 modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/CreateRoleTemplateVersionOptionsTest.java create mode 100644 modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/DeleteRoleAssignmentOptionsTest.java create mode 100644 modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/DeleteRoleTemplateOptionsTest.java create mode 100644 modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/DeleteRoleTemplateVersionOptionsTest.java create mode 100644 modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/GetRoleAssignmentOptionsTest.java create mode 100644 modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/GetRoleTemplateOptionsTest.java create mode 100644 modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/GetRoleTemplateVersionOptionsTest.java create mode 100644 modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ListRoleAssignmentsOptionsTest.java create mode 100644 modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ListRoleTemplateVersionsOptionsTest.java create mode 100644 modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ListRoleTemplatesOptionsTest.java create mode 100644 modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ReplaceRoleTemplateOptionsTest.java create mode 100644 modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/RoleAssignmentCollectionTest.java create mode 100644 modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/RoleAssignmentResourceCreatedTest.java create mode 100644 modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/RoleAssignmentResourceRoleTest.java create mode 100644 modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/RoleAssignmentResourceTest.java create mode 100644 modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/RoleAssignmentTemplateTest.java rename modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/{ErrorResponseTest.java => RoleAssignmentTest.java} (73%) create mode 100644 modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/RoleTemplateCollectionTest.java create mode 100644 modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/RoleTemplateTest.java create mode 100644 modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/RoleTemplateVersionsCollectionTest.java create mode 100644 modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/TemplateRoleTest.java create mode 100644 modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/UpdateRoleAssignmentOptionsTest.java diff --git a/modules/examples/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/IamPolicyManagementExamples.java b/modules/examples/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/IamPolicyManagementExamples.java index b92483fd3e4..e8c836dee35 100644 --- a/modules/examples/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/IamPolicyManagementExamples.java +++ b/modules/examples/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/IamPolicyManagementExamples.java @@ -13,6 +13,7 @@ package com.ibm.cloud.platform_services.iam_policy_management.v1; +// IBM Cloud IAM Policy Management Models import com.ibm.cloud.platform_services.iam_policy_management.v1.model.AccountSettingsAccessManagement; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.CreatePolicyOptions; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.CreateRoleOptions; @@ -111,6 +112,30 @@ import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ActionControlTemplateVersionsCollection; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.GetActionControlTemplateVersionOptions; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.CommitActionControlTemplateOptions; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.CommitRoleTemplateOptions; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.CreateRoleTemplateAssignmentOptions; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.CreateRoleTemplateOptions; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.CreateRoleTemplateVersionOptions; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.DeleteRoleAssignmentOptions; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.DeleteRoleTemplateOptions; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.DeleteRoleTemplateVersionOptions; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.GetRoleAssignmentOptions; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.GetRoleTemplateOptions; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.GetRoleTemplateVersionOptions; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ListRoleAssignmentsOptions; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ListRoleTemplateVersionsOptions; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ListRoleTemplatesOptions; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.RoleAssignment; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.RoleAssignmentCollection; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.RoleAssignmentTemplate; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.RoleAssignmentsPager; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.RoleTemplate; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.RoleTemplateVersionsPager; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.RoleTemplatesPager; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.TemplateRole; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.UpdateRoleAssignmentOptions; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ReplaceRoleTemplateOptions; + import com.ibm.cloud.sdk.core.http.Response; import com.ibm.cloud.sdk.core.service.exception.ServiceResponseException; import com.ibm.cloud.sdk.core.util.CredentialUtils; @@ -167,6 +192,11 @@ protected IamPolicyManagementExamples() { } private static String exampleBaseActionControlTemplateVersion = null; private static String exampleActionControlAssignmentId = null; private static String exampleActionControlAssignmentETag = null; + private static String exampleRoleTemplateId = null; + private static String exampleRoleTemplateEtag = null; + private static String exampleRoleTemplateVersion = null; + private static String exampleRoleTemplateAssignmentId = null; + private static String exampleRoleTemplateAssignmentETag = null; static { System.setProperty("IBM_CREDENTIALS_FILE", "../../iam_policy_management.env"); @@ -1528,5 +1558,309 @@ public static void main(String[] args) throws Exception { logger.error(String.format("Service returned status code %s: %s%nError details: %s", e.getStatusCode(), e.getMessage(), e.getDebuggingInfo()), e); } + + try { + System.out.println("createRoleTemplate() result:"); + // begin-create_role_template + CreateRoleTemplateOptions createRoleTemplateOptions = new CreateRoleTemplateOptions.Builder() + .name("SDKTestRoleTemplateExample") + .accountId(exampleAccountId) + .build(); + + Response response = service.createRoleTemplate(createRoleTemplateOptions).execute(); + RoleTemplate roleTemplate = response.getResult(); + + exampleRoleTemplateId = roleTemplate.getId(); + exampleRoleTemplateVersion = roleTemplate.getVersion(); + + System.out.println(roleTemplate); + // end-create_role_template + } catch (ServiceResponseException e) { + logger.error(String.format("Service returned status code %s: %s%nError details: %s", + e.getStatusCode(), e.getMessage(), e.getDebuggingInfo()), e); + } + + try { + System.out.println("getRoleTemplate() result:"); + // begin-get_role_template + GetRoleTemplateOptions getRoleTemplateOptions = new GetRoleTemplateOptions.Builder() + .roleTemplateId(exampleRoleTemplateId) + .build(); + + Response response = service.getRoleTemplate(getRoleTemplateOptions).execute(); + RoleTemplate roleTemplate = response.getResult(); + + exampleRoleTemplateEtag = response.getHeaders().values("Etag").get(0); + + System.out.println(roleTemplate); + // end-get_role_template + } catch (ServiceResponseException e) { + logger.error(String.format("Service returned status code %s: %s%nError details: %s", + e.getStatusCode(), e.getMessage(), e.getDebuggingInfo()), e); + } + + try { + System.out.println("replaceRoleTemplate() result:"); + // begin-replace_role_template + TemplateRole templateRoleModel = new TemplateRole.Builder() + .name("SDKTestRoleTemplateRep") + .displayName("SDKTestRoleTemplateRep") + .serviceName("am-test-service") + .actions(java.util.Arrays.asList("am-test-service.test.create")) + .build(); + ReplaceRoleTemplateOptions replaceRoleTemplateOptions = new ReplaceRoleTemplateOptions.Builder() + .roleTemplateId(exampleRoleTemplateId) + .version(exampleRoleTemplateVersion) + .ifMatch(exampleRoleTemplateEtag) + .role(templateRoleModel) + .build(); + + Response response = service.replaceRoleTemplate(replaceRoleTemplateOptions).execute(); + RoleTemplate roleTemplate = response.getResult(); + + System.out.println(roleTemplate); + // end-replace_role_template + } catch (ServiceResponseException e) { + logger.error(String.format("Service returned status code %s: %s%nError details: %s", + e.getStatusCode(), e.getMessage(), e.getDebuggingInfo()), e); + } + + try { + System.out.println("listRoleTemplates() result:"); + // begin-list_role_templates + ListRoleTemplatesOptions listRoleTemplatesOptions = new ListRoleTemplatesOptions.Builder() + .accountId(exampleAccountId) + .state("active") + .build(); + + RoleTemplatesPager pager = new RoleTemplatesPager(service, listRoleTemplatesOptions); + List allResults = new ArrayList<>(); + while (pager.hasNext()) { + List nextPage = pager.getNext(); + allResults.addAll(nextPage); + } + + System.out.println(allResults); + // end-list_role_templates + } catch (ServiceResponseException e) { + logger.error(String.format("Service returned status code %s: %s%nError details: %s", + e.getStatusCode(), e.getMessage(), e.getDebuggingInfo()), e); + } + + try { + System.out.println("createRoleTemplateVersion() result:"); + // begin-create_role_template_version + TemplateRole templateRoleModel = new TemplateRole.Builder() + .name("SDKTestRoleVersion") + .displayName("SDKTestRoleVersionDisp") + .serviceName("am-test-service") + .description("am-test-service versioon customRole") + .actions(java.util.Arrays.asList("am-test-service.test.create")) + .build(); + CreateRoleTemplateVersionOptions createRoleTemplateVersionOptions = new CreateRoleTemplateVersionOptions.Builder() + .roleTemplateId(exampleRoleTemplateId) + .role(templateRoleModel) + .build(); + + Response response = service.createRoleTemplateVersion(createRoleTemplateVersionOptions).execute(); + RoleTemplate roleTemplate = response.getResult(); + + exampleRoleTemplateVersion = roleTemplate.getVersion(); + + System.out.println(roleTemplate); + // end-create_role_template_version + } catch (ServiceResponseException e) { + logger.error(String.format("Service returned status code %s: %s%nError details: %s", + e.getStatusCode(), e.getMessage(), e.getDebuggingInfo()), e); + } + + try { + System.out.println("listRoleTemplateVersions() result:"); + // begin-list_role_template_versions + ListRoleTemplateVersionsOptions listRoleTemplateVersionsOptions = new ListRoleTemplateVersionsOptions.Builder() + .roleTemplateId(exampleRoleTemplateId) + .state("active") + .limit(Long.valueOf("10")) + .build(); + + RoleTemplateVersionsPager pager = new RoleTemplateVersionsPager(service, listRoleTemplateVersionsOptions); + List allResults = new ArrayList<>(); + while (pager.hasNext()) { + List nextPage = pager.getNext(); + allResults.addAll(nextPage); + } + + System.out.println(allResults); + // end-list_role_template_versions + } catch (ServiceResponseException e) { + logger.error(String.format("Service returned status code %s: %s%nError details: %s", + e.getStatusCode(), e.getMessage(), e.getDebuggingInfo()), e); + } + + try { + System.out.println("getRoleTemplateVersion() result:"); + // begin-get_role_template_version + GetRoleTemplateVersionOptions getRoleTemplateVersionOptions = new GetRoleTemplateVersionOptions.Builder() + .roleTemplateId(exampleRoleTemplateId) + .version(exampleRoleTemplateVersion) + .build(); + + Response response = service.getRoleTemplateVersion(getRoleTemplateVersionOptions).execute(); + RoleTemplate roleTemplate = response.getResult(); + + System.out.println(roleTemplate); + // end-get_role_template_version + } catch (ServiceResponseException e) { + logger.error(String.format("Service returned status code %s: %s%nError details: %s", + e.getStatusCode(), e.getMessage(), e.getDebuggingInfo()), e); + } + + try { + // begin-commit_role_template + CommitRoleTemplateOptions commitRoleTemplateOptions = new CommitRoleTemplateOptions.Builder() + .roleTemplateId(exampleRoleTemplateId) + .version(exampleRoleTemplateVersion) + .build(); + + Response response = service.commitRoleTemplate(commitRoleTemplateOptions).execute(); + // end-commit_role_template + System.out.printf("commitRoleTemplate() response status code: %d%n", response.getStatusCode()); + } catch (ServiceResponseException e) { + logger.error(String.format("Service returned status code %s: %s%nError details: %s", + e.getStatusCode(), e.getMessage(), e.getDebuggingInfo()), e); + } + + try { + System.out.println("createRoleTemplateAssignment() result:"); + // begin-create_role_template_assignment + AssignmentTargetDetails assignmentTargetDetailsModel = new AssignmentTargetDetails.Builder() + .type("Account") + .id(exampleTargetAccountId) + .build(); + RoleAssignmentTemplate roleAssignmentTemplateModel = new RoleAssignmentTemplate.Builder() + .id(exampleRoleTemplateId) + .version(exampleRoleTemplateVersion) + .build(); + CreateRoleTemplateAssignmentOptions createRoleTemplateAssignmentOptions = new CreateRoleTemplateAssignmentOptions.Builder() + .target(assignmentTargetDetailsModel) + .templates(java.util.Arrays.asList(roleAssignmentTemplateModel)) + .build(); + + Response response = service.createRoleTemplateAssignment(createRoleTemplateAssignmentOptions).execute(); + RoleAssignmentCollection result = response.getResult(); + + RoleAssignment assignment = result.getAssignments().get(0); + exampleRoleTemplateAssignmentId = assignment.getId(); + + List values = response.getHeaders().values("Etag"); + exampleRoleTemplateAssignmentETag = values.get(0); + + System.out.println(result); + // end-create_role_template_assignment + } catch (ServiceResponseException e) { + logger.error(String.format("Service returned status code %s: %s%nError details: %s", + e.getStatusCode(), e.getMessage(), e.getDebuggingInfo()), e); + } + + try { + System.out.println("getRoleAssignment() result:"); + // begin-get_role_assignment + GetRoleAssignmentOptions getRoleAssignmentOptions = new GetRoleAssignmentOptions.Builder() + .assignmentId(exampleRoleTemplateAssignmentId) + .build(); + + Response response = service.getRoleAssignment(getRoleAssignmentOptions).execute(); + RoleAssignment roleAssignment = response.getResult(); + + System.out.println(roleAssignment); + // end-get_role_assignment + } catch (ServiceResponseException e) { + logger.error(String.format("Service returned status code %s: %s%nError details: %s", + e.getStatusCode(), e.getMessage(), e.getDebuggingInfo()), e); + } + + try { + System.out.println("listRoleAssignments() result:"); + // begin-list_role_assignments + ListRoleAssignmentsOptions listRoleAssignmentsOptions = new ListRoleAssignmentsOptions.Builder() + .accountId(exampleAccountId) + .limit(Long.valueOf("10")) + .build(); + + RoleAssignmentsPager pager = new RoleAssignmentsPager(service, listRoleAssignmentsOptions); + List allResults = new ArrayList<>(); + while (pager.hasNext()) { + List nextPage = pager.getNext(); + allResults.addAll(nextPage); + } + + System.out.println(allResults); + // end-list_role_assignments + } catch (ServiceResponseException e) { + logger.error(String.format("Service returned status code %s: %s%nError details: %s", + e.getStatusCode(), e.getMessage(), e.getDebuggingInfo()), e); + } + + try { + System.out.println("updateRoleAssignment() result:"); + // begin-update_role_assignment + UpdateRoleAssignmentOptions updateRoleAssignmentOptions = new UpdateRoleAssignmentOptions.Builder() + .assignmentId(exampleRoleTemplateAssignmentId) + .ifMatch(exampleRoleTemplateAssignmentETag) + .templateVersion(exampleRoleTemplateVersion) + .build(); + + Response response = service.updateRoleAssignment(updateRoleAssignmentOptions).execute(); + RoleAssignment roleAssignment = response.getResult(); + + System.out.println(roleAssignment); + // end-update_role_assignment + } catch (ServiceResponseException e) { + logger.error(String.format("Service returned status code %s: %s%nError details: %s", + e.getStatusCode(), e.getMessage(), e.getDebuggingInfo()), e); + } + + try { + // begin-delete_role_assignment + DeleteRoleAssignmentOptions deleteRoleAssignmentOptions = new DeleteRoleAssignmentOptions.Builder() + .assignmentId(exampleRoleTemplateAssignmentId) + .build(); + + Response response = service.deleteRoleAssignment(deleteRoleAssignmentOptions).execute(); + // end-delete_role_assignment + System.out.printf("deleteRoleAssignment() response status code: %d%n", response.getStatusCode()); + } catch (ServiceResponseException e) { + logger.error(String.format("Service returned status code %s: %s%nError details: %s", + e.getStatusCode(), e.getMessage(), e.getDebuggingInfo()), e); + } + try { + // begin-delete_role_template_version + DeleteRoleTemplateVersionOptions deleteRoleTemplateVersionOptions = new DeleteRoleTemplateVersionOptions.Builder() + .roleTemplateId(exampleRoleTemplateId) + .version(exampleRoleTemplateVersion) + .build(); + + Response response = service.deleteRoleTemplateVersion(deleteRoleTemplateVersionOptions).execute(); + // end-delete_role_template_version + System.out.printf("deleteRoleTemplateVersion() response status code: %d%n", response.getStatusCode()); + } catch (ServiceResponseException e) { + logger.error(String.format("Service returned status code %s: %s%nError details: %s", + e.getStatusCode(), e.getMessage(), e.getDebuggingInfo()), e); + } + + try { + // begin-delete_role_template + DeleteRoleTemplateOptions deleteRoleTemplateOptions = new DeleteRoleTemplateOptions.Builder() + .roleTemplateId(exampleRoleTemplateId) + .build(); + + Response response = service.deleteRoleTemplate(deleteRoleTemplateOptions).execute(); + // end-delete_role_template + System.out.printf("deleteRoleTemplate() response status code: %d%n", response.getStatusCode()); + } catch (ServiceResponseException e) { + logger.error(String.format("Service returned status code %s: %s%nError details: %s", + e.getStatusCode(), e.getMessage(), e.getDebuggingInfo()), e); + } + } } diff --git a/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/IamPolicyManagement.java b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/IamPolicyManagement.java index 0416e315601..23449c10169 100644 --- a/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/IamPolicyManagement.java +++ b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/IamPolicyManagement.java @@ -12,7 +12,7 @@ */ /* - * IBM OpenAPI SDK Code Generator Version: 3.103.0-e8b84313-20250402-201816 + * IBM OpenAPI SDK Code Generator Version: 3.107.1-41b0fbd0-20250825-080732 */ package com.ibm.cloud.platform_services.iam_policy_management.v1; @@ -27,6 +27,7 @@ import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ActionControlTemplateVersionsCollection; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.CommitActionControlTemplateOptions; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.CommitPolicyTemplateOptions; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.CommitRoleTemplateOptions; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.CreateActionControlTemplateAssignmentOptions; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.CreateActionControlTemplateOptions; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.CreateActionControlTemplateVersionOptions; @@ -35,6 +36,9 @@ import com.ibm.cloud.platform_services.iam_policy_management.v1.model.CreatePolicyTemplateOptions; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.CreatePolicyTemplateVersionOptions; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.CreateRoleOptions; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.CreateRoleTemplateAssignmentOptions; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.CreateRoleTemplateOptions; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.CreateRoleTemplateVersionOptions; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.CreateV2PolicyOptions; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.CustomRole; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.DeleteActionControlAssignmentOptions; @@ -44,7 +48,10 @@ import com.ibm.cloud.platform_services.iam_policy_management.v1.model.DeletePolicyOptions; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.DeletePolicyTemplateOptions; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.DeletePolicyTemplateVersionOptions; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.DeleteRoleAssignmentOptions; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.DeleteRoleOptions; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.DeleteRoleTemplateOptions; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.DeleteRoleTemplateVersionOptions; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.DeleteV2PolicyOptions; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.GetActionControlAssignmentOptions; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.GetActionControlTemplateOptions; @@ -53,7 +60,10 @@ import com.ibm.cloud.platform_services.iam_policy_management.v1.model.GetPolicyOptions; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.GetPolicyTemplateOptions; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.GetPolicyTemplateVersionOptions; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.GetRoleAssignmentOptions; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.GetRoleOptions; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.GetRoleTemplateOptions; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.GetRoleTemplateVersionOptions; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.GetSettingsOptions; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.GetV2PolicyOptions; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ListActionControlAssignmentsOptions; @@ -63,6 +73,9 @@ import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ListPolicyAssignmentsOptions; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ListPolicyTemplateVersionsOptions; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ListPolicyTemplatesOptions; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ListRoleAssignmentsOptions; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ListRoleTemplateVersionsOptions; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ListRoleTemplatesOptions; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ListRolesOptions; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ListV2PoliciesOptions; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.Policy; @@ -80,11 +93,18 @@ import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ReplacePolicyOptions; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ReplacePolicyTemplateOptions; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ReplaceRoleOptions; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ReplaceRoleTemplateOptions; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ReplaceV2PolicyOptions; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.RoleAssignment; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.RoleAssignmentCollection; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.RoleCollection; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.RoleTemplate; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.RoleTemplateCollection; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.RoleTemplateVersionsCollection; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.UpdateActionControlAssignmentOptions; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.UpdatePolicyAssignmentOptions; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.UpdatePolicyStateOptions; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.UpdateRoleAssignmentOptions; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.UpdateSettingsOptions; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.V2Policy; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.V2PolicyCollection; @@ -2075,4 +2095,468 @@ public ServiceCall deleteActionControlAssignment(DeleteActionControlAssign return createServiceCall(builder.build(), responseConverter); } + /** + * List role templates by attributes. + * + * List role templates and filter by attributes by using query parameters. The following attributes are supported: + * `account_id`, `name`, `role_name`, `role_service_name`, `state`, `limit`, `start`. + * `account_id` is a required query parameter. Only role templates that have the specified attributes and that the + * caller has read access to are returned. If the caller does not have read access to any role templates an empty + * array is returned. + * + * @param listRoleTemplatesOptions the {@link ListRoleTemplatesOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link RoleTemplateCollection} + */ + public ServiceCall listRoleTemplates(ListRoleTemplatesOptions listRoleTemplatesOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(listRoleTemplatesOptions, + "listRoleTemplatesOptions cannot be null"); + RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/role_templates")); + Map sdkHeaders = SdkCommon.getSdkHeaders("iam_policy_management", "v1", "listRoleTemplates"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + if (listRoleTemplatesOptions.acceptLanguage() != null) { + builder.header("Accept-Language", listRoleTemplatesOptions.acceptLanguage()); + } + builder.query("account_id", String.valueOf(listRoleTemplatesOptions.accountId())); + if (listRoleTemplatesOptions.name() != null) { + builder.query("name", String.valueOf(listRoleTemplatesOptions.name())); + } + if (listRoleTemplatesOptions.roleName() != null) { + builder.query("role_name", String.valueOf(listRoleTemplatesOptions.roleName())); + } + if (listRoleTemplatesOptions.roleServiceName() != null) { + builder.query("role_service_name", String.valueOf(listRoleTemplatesOptions.roleServiceName())); + } + if (listRoleTemplatesOptions.state() != null) { + builder.query("state", String.valueOf(listRoleTemplatesOptions.state())); + } + if (listRoleTemplatesOptions.limit() != null) { + builder.query("limit", String.valueOf(listRoleTemplatesOptions.limit())); + } + if (listRoleTemplatesOptions.start() != null) { + builder.query("start", String.valueOf(listRoleTemplatesOptions.start())); + } + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Create role template. + * + * Create a role template. Role templates define roles from an existing system or service defined role. + * + * @param createRoleTemplateOptions the {@link CreateRoleTemplateOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link RoleTemplate} + */ + public ServiceCall createRoleTemplate(CreateRoleTemplateOptions createRoleTemplateOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(createRoleTemplateOptions, + "createRoleTemplateOptions cannot be null"); + RequestBuilder builder = RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/role_templates")); + Map sdkHeaders = SdkCommon.getSdkHeaders("iam_policy_management", "v1", "createRoleTemplate"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + if (createRoleTemplateOptions.acceptLanguage() != null) { + builder.header("Accept-Language", createRoleTemplateOptions.acceptLanguage()); + } + final JsonObject contentJson = new JsonObject(); + contentJson.addProperty("name", createRoleTemplateOptions.name()); + contentJson.addProperty("account_id", createRoleTemplateOptions.accountId()); + if (createRoleTemplateOptions.description() != null) { + contentJson.addProperty("description", createRoleTemplateOptions.description()); + } + if (createRoleTemplateOptions.committed() != null) { + contentJson.addProperty("committed", createRoleTemplateOptions.committed()); + } + if (createRoleTemplateOptions.role() != null) { + contentJson.add("role", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(createRoleTemplateOptions.role())); + } + builder.bodyJson(contentJson); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Retrieve the latest version of a role template. + * + * Retrieve the latest version of a role template by providing a role template ID. + * + * @param getRoleTemplateOptions the {@link GetRoleTemplateOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link RoleTemplate} + */ + public ServiceCall getRoleTemplate(GetRoleTemplateOptions getRoleTemplateOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(getRoleTemplateOptions, + "getRoleTemplateOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("role_template_id", getRoleTemplateOptions.roleTemplateId()); + RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/role_templates/{role_template_id}", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("iam_policy_management", "v1", "getRoleTemplate"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + if (getRoleTemplateOptions.state() != null) { + builder.query("state", String.valueOf(getRoleTemplateOptions.state())); + } + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Delete a Role template. + * + * Delete a role template by providing the role template ID. This deletes all versions of this template. A role + * template can't be deleted if any version of the template is assigned to one or more child accounts. You must remove + * the role assignments first. + * + * @param deleteRoleTemplateOptions the {@link DeleteRoleTemplateOptions} containing the options for the call + * @return a {@link ServiceCall} with a void result + */ + public ServiceCall deleteRoleTemplate(DeleteRoleTemplateOptions deleteRoleTemplateOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(deleteRoleTemplateOptions, + "deleteRoleTemplateOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("role_template_id", deleteRoleTemplateOptions.roleTemplateId()); + RequestBuilder builder = RequestBuilder.delete(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/role_templates/{role_template_id}", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("iam_policy_management", "v1", "deleteRoleTemplate"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Create a new role template version. + * + * Create a new version of a role template. Use this if you need to make updates to a role template that is committed. + * + * @param createRoleTemplateVersionOptions the {@link CreateRoleTemplateVersionOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link RoleTemplate} + */ + public ServiceCall createRoleTemplateVersion(CreateRoleTemplateVersionOptions createRoleTemplateVersionOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(createRoleTemplateVersionOptions, + "createRoleTemplateVersionOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("role_template_id", createRoleTemplateVersionOptions.roleTemplateId()); + RequestBuilder builder = RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/role_templates/{role_template_id}/versions", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("iam_policy_management", "v1", "createRoleTemplateVersion"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + final JsonObject contentJson = new JsonObject(); + contentJson.add("role", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(createRoleTemplateVersionOptions.role())); + if (createRoleTemplateVersionOptions.name() != null) { + contentJson.addProperty("name", createRoleTemplateVersionOptions.name()); + } + if (createRoleTemplateVersionOptions.description() != null) { + contentJson.addProperty("description", createRoleTemplateVersionOptions.description()); + } + if (createRoleTemplateVersionOptions.committed() != null) { + contentJson.addProperty("committed", createRoleTemplateVersionOptions.committed()); + } + builder.bodyJson(contentJson); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Retrieve role template versions. + * + * Retrieve the versions of a role template by providing a role template ID. + * + * @param listRoleTemplateVersionsOptions the {@link ListRoleTemplateVersionsOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link RoleTemplateVersionsCollection} + */ + public ServiceCall listRoleTemplateVersions(ListRoleTemplateVersionsOptions listRoleTemplateVersionsOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(listRoleTemplateVersionsOptions, + "listRoleTemplateVersionsOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("role_template_id", listRoleTemplateVersionsOptions.roleTemplateId()); + RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/role_templates/{role_template_id}/versions", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("iam_policy_management", "v1", "listRoleTemplateVersions"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + if (listRoleTemplateVersionsOptions.state() != null) { + builder.query("state", String.valueOf(listRoleTemplateVersionsOptions.state())); + } + if (listRoleTemplateVersionsOptions.limit() != null) { + builder.query("limit", String.valueOf(listRoleTemplateVersionsOptions.limit())); + } + if (listRoleTemplateVersionsOptions.start() != null) { + builder.query("start", String.valueOf(listRoleTemplateVersionsOptions.start())); + } + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Update a role template version. + * + * Update a specific version of a role template. You can use this only if the version isn't committed. + * + * @param replaceRoleTemplateOptions the {@link ReplaceRoleTemplateOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link RoleTemplate} + */ + public ServiceCall replaceRoleTemplate(ReplaceRoleTemplateOptions replaceRoleTemplateOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(replaceRoleTemplateOptions, + "replaceRoleTemplateOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("role_template_id", replaceRoleTemplateOptions.roleTemplateId()); + pathParamsMap.put("version", replaceRoleTemplateOptions.version()); + RequestBuilder builder = RequestBuilder.put(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/role_templates/{role_template_id}/versions/{version}", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("iam_policy_management", "v1", "replaceRoleTemplate"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + builder.header("If-Match", replaceRoleTemplateOptions.ifMatch()); + final JsonObject contentJson = new JsonObject(); + contentJson.add("role", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(replaceRoleTemplateOptions.role())); + if (replaceRoleTemplateOptions.name() != null) { + contentJson.addProperty("name", replaceRoleTemplateOptions.name()); + } + if (replaceRoleTemplateOptions.description() != null) { + contentJson.addProperty("description", replaceRoleTemplateOptions.description()); + } + if (replaceRoleTemplateOptions.committed() != null) { + contentJson.addProperty("committed", replaceRoleTemplateOptions.committed()); + } + builder.bodyJson(contentJson); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Delete a role template version. + * + * Delete a specific version of a role template by providing a role template ID and version number. You can't delete a + * role template version that is assigned to one or more child accounts. You must remove the role assignments first. + * + * @param deleteRoleTemplateVersionOptions the {@link DeleteRoleTemplateVersionOptions} containing the options for the call + * @return a {@link ServiceCall} with a void result + */ + public ServiceCall deleteRoleTemplateVersion(DeleteRoleTemplateVersionOptions deleteRoleTemplateVersionOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(deleteRoleTemplateVersionOptions, + "deleteRoleTemplateVersionOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("role_template_id", deleteRoleTemplateVersionOptions.roleTemplateId()); + pathParamsMap.put("version", deleteRoleTemplateVersionOptions.version()); + RequestBuilder builder = RequestBuilder.delete(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/role_templates/{role_template_id}/versions/{version}", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("iam_policy_management", "v1", "deleteRoleTemplateVersion"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Retrieve a role template version. + * + * Retrieve a role template by providing a role template ID and version number. + * + * @param getRoleTemplateVersionOptions the {@link GetRoleTemplateVersionOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link RoleTemplate} + */ + public ServiceCall getRoleTemplateVersion(GetRoleTemplateVersionOptions getRoleTemplateVersionOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(getRoleTemplateVersionOptions, + "getRoleTemplateVersionOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("role_template_id", getRoleTemplateVersionOptions.roleTemplateId()); + pathParamsMap.put("version", getRoleTemplateVersionOptions.version()); + RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/role_templates/{role_template_id}/versions/{version}", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("iam_policy_management", "v1", "getRoleTemplateVersion"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Commit a role template version. + * + * Commit a role template version. You cannot make any further changes to the role template once it's committed. If + * you have to make updates after committing a version, create a new version. + * + * @param commitRoleTemplateOptions the {@link CommitRoleTemplateOptions} containing the options for the call + * @return a {@link ServiceCall} with a void result + */ + public ServiceCall commitRoleTemplate(CommitRoleTemplateOptions commitRoleTemplateOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(commitRoleTemplateOptions, + "commitRoleTemplateOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("role_template_id", commitRoleTemplateOptions.roleTemplateId()); + pathParamsMap.put("version", commitRoleTemplateOptions.version()); + RequestBuilder builder = RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/role_templates/{role_template_id}/versions/{version}/commit", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("iam_policy_management", "v1", "commitRoleTemplate"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Get role template assignments. + * + * Get role template assignments by attributes. The following attributes are supported: + * `account_id`, `template_id`, `template_version`, `target`, `target_type`, `limit`, `start`. + * `account_id` is a required query parameter. Only role template assignments with the specified attributes and + * accessible by the caller are returned. If the caller does not have read access to any role template assignments, an + * empty array is returned. + * + * @param listRoleAssignmentsOptions the {@link ListRoleAssignmentsOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link RoleAssignmentCollection} + */ + public ServiceCall listRoleAssignments(ListRoleAssignmentsOptions listRoleAssignmentsOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(listRoleAssignmentsOptions, + "listRoleAssignmentsOptions cannot be null"); + RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/role_assignments")); + Map sdkHeaders = SdkCommon.getSdkHeaders("iam_policy_management", "v1", "listRoleAssignments"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + if (listRoleAssignmentsOptions.acceptLanguage() != null) { + builder.header("Accept-Language", listRoleAssignmentsOptions.acceptLanguage()); + } + builder.query("account_id", String.valueOf(listRoleAssignmentsOptions.accountId())); + if (listRoleAssignmentsOptions.templateId() != null) { + builder.query("template_id", String.valueOf(listRoleAssignmentsOptions.templateId())); + } + if (listRoleAssignmentsOptions.templateVersion() != null) { + builder.query("template_version", String.valueOf(listRoleAssignmentsOptions.templateVersion())); + } + if (listRoleAssignmentsOptions.limit() != null) { + builder.query("limit", String.valueOf(listRoleAssignmentsOptions.limit())); + } + if (listRoleAssignmentsOptions.start() != null) { + builder.query("start", String.valueOf(listRoleAssignmentsOptions.start())); + } + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Create a role template assignment. + * + * Assign a role template to child accounts and account groups. This creates the role in the accounts and account + * groups that you specify. + * + * @param createRoleTemplateAssignmentOptions the {@link CreateRoleTemplateAssignmentOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link RoleAssignmentCollection} + */ + public ServiceCall createRoleTemplateAssignment(CreateRoleTemplateAssignmentOptions createRoleTemplateAssignmentOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(createRoleTemplateAssignmentOptions, + "createRoleTemplateAssignmentOptions cannot be null"); + RequestBuilder builder = RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/role_assignments")); + Map sdkHeaders = SdkCommon.getSdkHeaders("iam_policy_management", "v1", "createRoleTemplateAssignment"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + if (createRoleTemplateAssignmentOptions.acceptLanguage() != null) { + builder.header("Accept-Language", createRoleTemplateAssignmentOptions.acceptLanguage()); + } + final JsonObject contentJson = new JsonObject(); + contentJson.add("target", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(createRoleTemplateAssignmentOptions.target())); + contentJson.add("templates", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(createRoleTemplateAssignmentOptions.templates())); + builder.bodyJson(contentJson); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Retrieve a role assignment. + * + * Retrieve a role template assignment by providing a role assignment ID. + * + * @param getRoleAssignmentOptions the {@link GetRoleAssignmentOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link RoleAssignment} + */ + public ServiceCall getRoleAssignment(GetRoleAssignmentOptions getRoleAssignmentOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(getRoleAssignmentOptions, + "getRoleAssignmentOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("assignment_id", getRoleAssignmentOptions.assignmentId()); + RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/role_assignments/{assignment_id}", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("iam_policy_management", "v1", "getRoleAssignment"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Update a role assignment. + * + * Update a role assignment by providing a role assignment ID. + * + * @param updateRoleAssignmentOptions the {@link UpdateRoleAssignmentOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link RoleAssignment} + */ + public ServiceCall updateRoleAssignment(UpdateRoleAssignmentOptions updateRoleAssignmentOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(updateRoleAssignmentOptions, + "updateRoleAssignmentOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("assignment_id", updateRoleAssignmentOptions.assignmentId()); + RequestBuilder builder = RequestBuilder.patch(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/role_assignments/{assignment_id}", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("iam_policy_management", "v1", "updateRoleAssignment"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + builder.header("If-Match", updateRoleAssignmentOptions.ifMatch()); + final JsonObject contentJson = new JsonObject(); + contentJson.addProperty("template_version", updateRoleAssignmentOptions.templateVersion()); + builder.bodyJson(contentJson); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Remove a role assignment. + * + * Remove a role template assignment by providing a role assignment ID. You can't delete a role assignment if the + * status is "in_progress". + * + * @param deleteRoleAssignmentOptions the {@link DeleteRoleAssignmentOptions} containing the options for the call + * @return a {@link ServiceCall} with a void result + */ + public ServiceCall deleteRoleAssignment(DeleteRoleAssignmentOptions deleteRoleAssignmentOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(deleteRoleAssignmentOptions, + "deleteRoleAssignmentOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("assignment_id", deleteRoleAssignmentOptions.assignmentId()); + RequestBuilder builder = RequestBuilder.delete(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/role_assignments/{assignment_id}", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("iam_policy_management", "v1", "deleteRoleAssignment"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); + return createServiceCall(builder.build(), responseConverter); + } + } diff --git a/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ActionControlAssignmentResourceActionControl.java b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ActionControlAssignmentResourceActionControl.java index b1dad838bff..0e5550eb4da 100644 --- a/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ActionControlAssignmentResourceActionControl.java +++ b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ActionControlAssignmentResourceActionControl.java @@ -24,7 +24,7 @@ public class ActionControlAssignmentResourceActionControl extends GenericModel { @SerializedName("resource_created") protected ActionControlAssignmentResourceCreated resourceCreated; @SerializedName("error_message") - protected ErrorResponse errorMessage; + protected AssignmentResourceError errorMessage; protected ActionControlAssignmentResourceActionControl() { } @@ -42,11 +42,11 @@ public ActionControlAssignmentResourceCreated getResourceCreated() { /** * Gets the errorMessage. * - * The error response from API. + * Body parameters for assignment error. * * @return the errorMessage */ - public ErrorResponse getErrorMessage() { + public AssignmentResourceError getErrorMessage() { return errorMessage; } } diff --git a/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/AssignmentResourceError.java b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/AssignmentResourceError.java new file mode 100644 index 00000000000..e74dbe58b3a --- /dev/null +++ b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/AssignmentResourceError.java @@ -0,0 +1,88 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.iam_policy_management.v1.model; + +import java.util.List; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * Body parameters for assignment error. + */ +public class AssignmentResourceError extends GenericModel { + + protected String name; + protected String errorCode; + protected String message; + protected String code; + protected List errors; + + protected AssignmentResourceError() { } + + /** + * Gets the name. + * + * Name of the error. + * + * @return the name + */ + public String getName() { + return name; + } + + /** + * Gets the errorCode. + * + * error code. + * + * @return the errorCode + */ + public String getErrorCode() { + return errorCode; + } + + /** + * Gets the message. + * + * Error message detailing the nature of the error. + * + * @return the message + */ + public String getMessage() { + return message; + } + + /** + * Gets the code. + * + * Internal status code for the error. + * + * @return the code + */ + public String getCode() { + return code; + } + + /** + * Gets the errors. + * + * The errors encountered during the response. + * + * @return the errors + */ + public List getErrors() { + return errors; + } +} + diff --git a/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/CommitRoleTemplateOptions.java b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/CommitRoleTemplateOptions.java new file mode 100644 index 00000000000..7e93c92fb0b --- /dev/null +++ b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/CommitRoleTemplateOptions.java @@ -0,0 +1,134 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.iam_policy_management.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * The commitRoleTemplate options. + */ +public class CommitRoleTemplateOptions extends GenericModel { + + protected String roleTemplateId; + protected String version; + + /** + * Builder. + */ + public static class Builder { + private String roleTemplateId; + private String version; + + /** + * Instantiates a new Builder from an existing CommitRoleTemplateOptions instance. + * + * @param commitRoleTemplateOptions the instance to initialize the Builder with + */ + private Builder(CommitRoleTemplateOptions commitRoleTemplateOptions) { + this.roleTemplateId = commitRoleTemplateOptions.roleTemplateId; + this.version = commitRoleTemplateOptions.version; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Instantiates a new builder with required properties. + * + * @param roleTemplateId the roleTemplateId + * @param version the version + */ + public Builder(String roleTemplateId, String version) { + this.roleTemplateId = roleTemplateId; + this.version = version; + } + + /** + * Builds a CommitRoleTemplateOptions. + * + * @return the new CommitRoleTemplateOptions instance + */ + public CommitRoleTemplateOptions build() { + return new CommitRoleTemplateOptions(this); + } + + /** + * Set the roleTemplateId. + * + * @param roleTemplateId the roleTemplateId + * @return the CommitRoleTemplateOptions builder + */ + public Builder roleTemplateId(String roleTemplateId) { + this.roleTemplateId = roleTemplateId; + return this; + } + + /** + * Set the version. + * + * @param version the version + * @return the CommitRoleTemplateOptions builder + */ + public Builder version(String version) { + this.version = version; + return this; + } + } + + protected CommitRoleTemplateOptions() { } + + protected CommitRoleTemplateOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.roleTemplateId, + "roleTemplateId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.version, + "version cannot be empty"); + roleTemplateId = builder.roleTemplateId; + version = builder.version; + } + + /** + * New builder. + * + * @return a CommitRoleTemplateOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the roleTemplateId. + * + * Role template ID. + * + * @return the roleTemplateId + */ + public String roleTemplateId() { + return roleTemplateId; + } + + /** + * Gets the version. + * + * The role template version. + * + * @return the version + */ + public String version() { + return version; + } +} + diff --git a/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/CreateRoleTemplateAssignmentOptions.java b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/CreateRoleTemplateAssignmentOptions.java new file mode 100644 index 00000000000..c9bef88e703 --- /dev/null +++ b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/CreateRoleTemplateAssignmentOptions.java @@ -0,0 +1,191 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.iam_policy_management.v1.model; + +import java.util.ArrayList; +import java.util.List; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * The createRoleTemplateAssignment options. + */ +public class CreateRoleTemplateAssignmentOptions extends GenericModel { + + protected AssignmentTargetDetails target; + protected List templates; + protected String acceptLanguage; + + /** + * Builder. + */ + public static class Builder { + private AssignmentTargetDetails target; + private List templates; + private String acceptLanguage; + + /** + * Instantiates a new Builder from an existing CreateRoleTemplateAssignmentOptions instance. + * + * @param createRoleTemplateAssignmentOptions the instance to initialize the Builder with + */ + private Builder(CreateRoleTemplateAssignmentOptions createRoleTemplateAssignmentOptions) { + this.target = createRoleTemplateAssignmentOptions.target; + this.templates = createRoleTemplateAssignmentOptions.templates; + this.acceptLanguage = createRoleTemplateAssignmentOptions.acceptLanguage; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Instantiates a new builder with required properties. + * + * @param target the target + * @param templates the templates + */ + public Builder(AssignmentTargetDetails target, List templates) { + this.target = target; + this.templates = templates; + } + + /** + * Builds a CreateRoleTemplateAssignmentOptions. + * + * @return the new CreateRoleTemplateAssignmentOptions instance + */ + public CreateRoleTemplateAssignmentOptions build() { + return new CreateRoleTemplateAssignmentOptions(this); + } + + /** + * Adds a new element to templates. + * + * @param templates the new element to be added + * @return the CreateRoleTemplateAssignmentOptions builder + */ + public Builder addTemplates(RoleAssignmentTemplate templates) { + com.ibm.cloud.sdk.core.util.Validator.notNull(templates, + "templates cannot be null"); + if (this.templates == null) { + this.templates = new ArrayList(); + } + this.templates.add(templates); + return this; + } + + /** + * Set the target. + * + * @param target the target + * @return the CreateRoleTemplateAssignmentOptions builder + */ + public Builder target(AssignmentTargetDetails target) { + this.target = target; + return this; + } + + /** + * Set the templates. + * Existing templates will be replaced. + * + * @param templates the templates + * @return the CreateRoleTemplateAssignmentOptions builder + */ + public Builder templates(List templates) { + this.templates = templates; + return this; + } + + /** + * Set the acceptLanguage. + * + * @param acceptLanguage the acceptLanguage + * @return the CreateRoleTemplateAssignmentOptions builder + */ + public Builder acceptLanguage(String acceptLanguage) { + this.acceptLanguage = acceptLanguage; + return this; + } + } + + protected CreateRoleTemplateAssignmentOptions() { } + + protected CreateRoleTemplateAssignmentOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.target, + "target cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.templates, + "templates cannot be null"); + target = builder.target; + templates = builder.templates; + acceptLanguage = builder.acceptLanguage; + } + + /** + * New builder. + * + * @return a CreateRoleTemplateAssignmentOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the target. + * + * assignment target account and type. + * + * @return the target + */ + public AssignmentTargetDetails target() { + return target; + } + + /** + * Gets the templates. + * + * List of role template details for role assignment. + * + * @return the templates + */ + public List templates() { + return templates; + } + + /** + * Gets the acceptLanguage. + * + * Language code for translations + * * `default` - English + * * `de` - German (Standard) + * * `en` - English + * * `es` - Spanish (Spain) + * * `fr` - French (Standard) + * * `it` - Italian (Standard) + * * `ja` - Japanese + * * `ko` - Korean + * * `pt-br` - Portuguese (Brazil) + * * `zh-cn` - Chinese (Simplified, PRC) + * * `zh-tw` - (Chinese, Taiwan). + * + * @return the acceptLanguage + */ + public String acceptLanguage() { + return acceptLanguage; + } +} + diff --git a/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/CreateRoleTemplateOptions.java b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/CreateRoleTemplateOptions.java new file mode 100644 index 00000000000..35183eb3313 --- /dev/null +++ b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/CreateRoleTemplateOptions.java @@ -0,0 +1,251 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.iam_policy_management.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * The createRoleTemplate options. + */ +public class CreateRoleTemplateOptions extends GenericModel { + + protected String name; + protected String accountId; + protected String description; + protected Boolean committed; + protected TemplateRole role; + protected String acceptLanguage; + + /** + * Builder. + */ + public static class Builder { + private String name; + private String accountId; + private String description; + private Boolean committed; + private TemplateRole role; + private String acceptLanguage; + + /** + * Instantiates a new Builder from an existing CreateRoleTemplateOptions instance. + * + * @param createRoleTemplateOptions the instance to initialize the Builder with + */ + private Builder(CreateRoleTemplateOptions createRoleTemplateOptions) { + this.name = createRoleTemplateOptions.name; + this.accountId = createRoleTemplateOptions.accountId; + this.description = createRoleTemplateOptions.description; + this.committed = createRoleTemplateOptions.committed; + this.role = createRoleTemplateOptions.role; + this.acceptLanguage = createRoleTemplateOptions.acceptLanguage; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Instantiates a new builder with required properties. + * + * @param name the name + * @param accountId the accountId + */ + public Builder(String name, String accountId) { + this.name = name; + this.accountId = accountId; + } + + /** + * Builds a CreateRoleTemplateOptions. + * + * @return the new CreateRoleTemplateOptions instance + */ + public CreateRoleTemplateOptions build() { + return new CreateRoleTemplateOptions(this); + } + + /** + * Set the name. + * + * @param name the name + * @return the CreateRoleTemplateOptions builder + */ + public Builder name(String name) { + this.name = name; + return this; + } + + /** + * Set the accountId. + * + * @param accountId the accountId + * @return the CreateRoleTemplateOptions builder + */ + public Builder accountId(String accountId) { + this.accountId = accountId; + return this; + } + + /** + * Set the description. + * + * @param description the description + * @return the CreateRoleTemplateOptions builder + */ + public Builder description(String description) { + this.description = description; + return this; + } + + /** + * Set the committed. + * + * @param committed the committed + * @return the CreateRoleTemplateOptions builder + */ + public Builder committed(Boolean committed) { + this.committed = committed; + return this; + } + + /** + * Set the role. + * + * @param role the role + * @return the CreateRoleTemplateOptions builder + */ + public Builder role(TemplateRole role) { + this.role = role; + return this; + } + + /** + * Set the acceptLanguage. + * + * @param acceptLanguage the acceptLanguage + * @return the CreateRoleTemplateOptions builder + */ + public Builder acceptLanguage(String acceptLanguage) { + this.acceptLanguage = acceptLanguage; + return this; + } + } + + protected CreateRoleTemplateOptions() { } + + protected CreateRoleTemplateOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.name, + "name cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.accountId, + "accountId cannot be null"); + name = builder.name; + accountId = builder.accountId; + description = builder.description; + committed = builder.committed; + role = builder.role; + acceptLanguage = builder.acceptLanguage; + } + + /** + * New builder. + * + * @return a CreateRoleTemplateOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the name. + * + * Required field when creating a new template. Otherwise, this field is optional. If the field is included, it + * changes the name value for all existing versions of the template. + * + * @return the name + */ + public String name() { + return name; + } + + /** + * Gets the accountId. + * + * Enterprise account ID where this template is created. + * + * @return the accountId + */ + public String accountId() { + return accountId; + } + + /** + * Gets the description. + * + * Description of the role template. This is shown to users in the enterprise account. Use this to describe the + * purpose or context of the role for enterprise users managing IAM templates. + * + * @return the description + */ + public String description() { + return description; + } + + /** + * Gets the committed. + * + * Committed status of the template. If committed is set to true, then the template version can no longer be updated. + * + * @return the committed + */ + public Boolean committed() { + return committed; + } + + /** + * Gets the role. + * + * The role properties that are created in an action resource when the template is assigned. + * + * @return the role + */ + public TemplateRole role() { + return role; + } + + /** + * Gets the acceptLanguage. + * + * Language code for translations + * * `default` - English + * * `de` - German (Standard) + * * `en` - English + * * `es` - Spanish (Spain) + * * `fr` - French (Standard) + * * `it` - Italian (Standard) + * * `ja` - Japanese + * * `ko` - Korean + * * `pt-br` - Portuguese (Brazil) + * * `zh-cn` - Chinese (Simplified, PRC) + * * `zh-tw` - (Chinese, Taiwan). + * + * @return the acceptLanguage + */ + public String acceptLanguage() { + return acceptLanguage; + } +} + diff --git a/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/CreateRoleTemplateVersionOptions.java b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/CreateRoleTemplateVersionOptions.java new file mode 100644 index 00000000000..dafc10e913b --- /dev/null +++ b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/CreateRoleTemplateVersionOptions.java @@ -0,0 +1,215 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.iam_policy_management.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * The createRoleTemplateVersion options. + */ +public class CreateRoleTemplateVersionOptions extends GenericModel { + + protected String roleTemplateId; + protected TemplateRole role; + protected String name; + protected String description; + protected Boolean committed; + + /** + * Builder. + */ + public static class Builder { + private String roleTemplateId; + private TemplateRole role; + private String name; + private String description; + private Boolean committed; + + /** + * Instantiates a new Builder from an existing CreateRoleTemplateVersionOptions instance. + * + * @param createRoleTemplateVersionOptions the instance to initialize the Builder with + */ + private Builder(CreateRoleTemplateVersionOptions createRoleTemplateVersionOptions) { + this.roleTemplateId = createRoleTemplateVersionOptions.roleTemplateId; + this.role = createRoleTemplateVersionOptions.role; + this.name = createRoleTemplateVersionOptions.name; + this.description = createRoleTemplateVersionOptions.description; + this.committed = createRoleTemplateVersionOptions.committed; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Instantiates a new builder with required properties. + * + * @param roleTemplateId the roleTemplateId + * @param role the role + */ + public Builder(String roleTemplateId, TemplateRole role) { + this.roleTemplateId = roleTemplateId; + this.role = role; + } + + /** + * Builds a CreateRoleTemplateVersionOptions. + * + * @return the new CreateRoleTemplateVersionOptions instance + */ + public CreateRoleTemplateVersionOptions build() { + return new CreateRoleTemplateVersionOptions(this); + } + + /** + * Set the roleTemplateId. + * + * @param roleTemplateId the roleTemplateId + * @return the CreateRoleTemplateVersionOptions builder + */ + public Builder roleTemplateId(String roleTemplateId) { + this.roleTemplateId = roleTemplateId; + return this; + } + + /** + * Set the role. + * + * @param role the role + * @return the CreateRoleTemplateVersionOptions builder + */ + public Builder role(TemplateRole role) { + this.role = role; + return this; + } + + /** + * Set the name. + * + * @param name the name + * @return the CreateRoleTemplateVersionOptions builder + */ + public Builder name(String name) { + this.name = name; + return this; + } + + /** + * Set the description. + * + * @param description the description + * @return the CreateRoleTemplateVersionOptions builder + */ + public Builder description(String description) { + this.description = description; + return this; + } + + /** + * Set the committed. + * + * @param committed the committed + * @return the CreateRoleTemplateVersionOptions builder + */ + public Builder committed(Boolean committed) { + this.committed = committed; + return this; + } + } + + protected CreateRoleTemplateVersionOptions() { } + + protected CreateRoleTemplateVersionOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.roleTemplateId, + "roleTemplateId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.role, + "role cannot be null"); + roleTemplateId = builder.roleTemplateId; + role = builder.role; + name = builder.name; + description = builder.description; + committed = builder.committed; + } + + /** + * New builder. + * + * @return a CreateRoleTemplateVersionOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the roleTemplateId. + * + * The role template ID. + * + * @return the roleTemplateId + */ + public String roleTemplateId() { + return roleTemplateId; + } + + /** + * Gets the role. + * + * The role properties that are created in an action resource when the template is assigned. + * + * @return the role + */ + public TemplateRole role() { + return role; + } + + /** + * Gets the name. + * + * Required field when creating a new template. Otherwise, this field is optional. If the field is included, it will + * change the name value for all existing versions of the template. + * + * @return the name + */ + public String name() { + return name; + } + + /** + * Gets the description. + * + * Description of the role template. This is shown to users in the enterprise account. Use this to describe the + * purpose or context of the role for enterprise users managing IAM templates. + * + * @return the description + */ + public String description() { + return description; + } + + /** + * Gets the committed. + * + * Committed status of the template version. If committed is set to true, then the template version can no longer be + * updated. + * + * @return the committed + */ + public Boolean committed() { + return committed; + } +} + diff --git a/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/DeleteRoleAssignmentOptions.java b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/DeleteRoleAssignmentOptions.java new file mode 100644 index 00000000000..b9341a9f414 --- /dev/null +++ b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/DeleteRoleAssignmentOptions.java @@ -0,0 +1,104 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.iam_policy_management.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * The deleteRoleAssignment options. + */ +public class DeleteRoleAssignmentOptions extends GenericModel { + + protected String assignmentId; + + /** + * Builder. + */ + public static class Builder { + private String assignmentId; + + /** + * Instantiates a new Builder from an existing DeleteRoleAssignmentOptions instance. + * + * @param deleteRoleAssignmentOptions the instance to initialize the Builder with + */ + private Builder(DeleteRoleAssignmentOptions deleteRoleAssignmentOptions) { + this.assignmentId = deleteRoleAssignmentOptions.assignmentId; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Instantiates a new builder with required properties. + * + * @param assignmentId the assignmentId + */ + public Builder(String assignmentId) { + this.assignmentId = assignmentId; + } + + /** + * Builds a DeleteRoleAssignmentOptions. + * + * @return the new DeleteRoleAssignmentOptions instance + */ + public DeleteRoleAssignmentOptions build() { + return new DeleteRoleAssignmentOptions(this); + } + + /** + * Set the assignmentId. + * + * @param assignmentId the assignmentId + * @return the DeleteRoleAssignmentOptions builder + */ + public Builder assignmentId(String assignmentId) { + this.assignmentId = assignmentId; + return this; + } + } + + protected DeleteRoleAssignmentOptions() { } + + protected DeleteRoleAssignmentOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.assignmentId, + "assignmentId cannot be empty"); + assignmentId = builder.assignmentId; + } + + /** + * New builder. + * + * @return a DeleteRoleAssignmentOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the assignmentId. + * + * Role template assignment ID. + * + * @return the assignmentId + */ + public String assignmentId() { + return assignmentId; + } +} + diff --git a/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/DeleteRoleTemplateOptions.java b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/DeleteRoleTemplateOptions.java new file mode 100644 index 00000000000..c76bf3bfda4 --- /dev/null +++ b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/DeleteRoleTemplateOptions.java @@ -0,0 +1,104 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.iam_policy_management.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * The deleteRoleTemplate options. + */ +public class DeleteRoleTemplateOptions extends GenericModel { + + protected String roleTemplateId; + + /** + * Builder. + */ + public static class Builder { + private String roleTemplateId; + + /** + * Instantiates a new Builder from an existing DeleteRoleTemplateOptions instance. + * + * @param deleteRoleTemplateOptions the instance to initialize the Builder with + */ + private Builder(DeleteRoleTemplateOptions deleteRoleTemplateOptions) { + this.roleTemplateId = deleteRoleTemplateOptions.roleTemplateId; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Instantiates a new builder with required properties. + * + * @param roleTemplateId the roleTemplateId + */ + public Builder(String roleTemplateId) { + this.roleTemplateId = roleTemplateId; + } + + /** + * Builds a DeleteRoleTemplateOptions. + * + * @return the new DeleteRoleTemplateOptions instance + */ + public DeleteRoleTemplateOptions build() { + return new DeleteRoleTemplateOptions(this); + } + + /** + * Set the roleTemplateId. + * + * @param roleTemplateId the roleTemplateId + * @return the DeleteRoleTemplateOptions builder + */ + public Builder roleTemplateId(String roleTemplateId) { + this.roleTemplateId = roleTemplateId; + return this; + } + } + + protected DeleteRoleTemplateOptions() { } + + protected DeleteRoleTemplateOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.roleTemplateId, + "roleTemplateId cannot be empty"); + roleTemplateId = builder.roleTemplateId; + } + + /** + * New builder. + * + * @return a DeleteRoleTemplateOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the roleTemplateId. + * + * Role template ID. + * + * @return the roleTemplateId + */ + public String roleTemplateId() { + return roleTemplateId; + } +} + diff --git a/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/DeleteRoleTemplateVersionOptions.java b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/DeleteRoleTemplateVersionOptions.java new file mode 100644 index 00000000000..9f974213165 --- /dev/null +++ b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/DeleteRoleTemplateVersionOptions.java @@ -0,0 +1,134 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.iam_policy_management.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * The deleteRoleTemplateVersion options. + */ +public class DeleteRoleTemplateVersionOptions extends GenericModel { + + protected String roleTemplateId; + protected String version; + + /** + * Builder. + */ + public static class Builder { + private String roleTemplateId; + private String version; + + /** + * Instantiates a new Builder from an existing DeleteRoleTemplateVersionOptions instance. + * + * @param deleteRoleTemplateVersionOptions the instance to initialize the Builder with + */ + private Builder(DeleteRoleTemplateVersionOptions deleteRoleTemplateVersionOptions) { + this.roleTemplateId = deleteRoleTemplateVersionOptions.roleTemplateId; + this.version = deleteRoleTemplateVersionOptions.version; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Instantiates a new builder with required properties. + * + * @param roleTemplateId the roleTemplateId + * @param version the version + */ + public Builder(String roleTemplateId, String version) { + this.roleTemplateId = roleTemplateId; + this.version = version; + } + + /** + * Builds a DeleteRoleTemplateVersionOptions. + * + * @return the new DeleteRoleTemplateVersionOptions instance + */ + public DeleteRoleTemplateVersionOptions build() { + return new DeleteRoleTemplateVersionOptions(this); + } + + /** + * Set the roleTemplateId. + * + * @param roleTemplateId the roleTemplateId + * @return the DeleteRoleTemplateVersionOptions builder + */ + public Builder roleTemplateId(String roleTemplateId) { + this.roleTemplateId = roleTemplateId; + return this; + } + + /** + * Set the version. + * + * @param version the version + * @return the DeleteRoleTemplateVersionOptions builder + */ + public Builder version(String version) { + this.version = version; + return this; + } + } + + protected DeleteRoleTemplateVersionOptions() { } + + protected DeleteRoleTemplateVersionOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.roleTemplateId, + "roleTemplateId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.version, + "version cannot be empty"); + roleTemplateId = builder.roleTemplateId; + version = builder.version; + } + + /** + * New builder. + * + * @return a DeleteRoleTemplateVersionOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the roleTemplateId. + * + * Role template ID. + * + * @return the roleTemplateId + */ + public String roleTemplateId() { + return roleTemplateId; + } + + /** + * Gets the version. + * + * Role template version. + * + * @return the version + */ + public String version() { + return version; + } +} + diff --git a/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ErrorObject.java b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ErrorObject.java index eec92c63423..b5411a7bb36 100644 --- a/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ErrorObject.java +++ b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ErrorObject.java @@ -65,6 +65,12 @@ public interface Code { String ACTION_CONTROL_TEMPLATE_NOT_FOUND = "action_control_template_not_found"; /** action_control_assignment_not_found. */ String ACTION_CONTROL_ASSIGNMENT_NOT_FOUND = "action_control_assignment_not_found"; + /** role_template_conflict_error. */ + String ROLE_TEMPLATE_CONFLICT_ERROR = "role_template_conflict_error"; + /** role_template_not_found. */ + String ROLE_TEMPLATE_NOT_FOUND = "role_template_not_found"; + /** role_assignment_not_found. */ + String ROLE_ASSIGNMENT_NOT_FOUND = "role_assignment_not_found"; } protected String code; diff --git a/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/GetRoleAssignmentOptions.java b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/GetRoleAssignmentOptions.java new file mode 100644 index 00000000000..35313b9b746 --- /dev/null +++ b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/GetRoleAssignmentOptions.java @@ -0,0 +1,104 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.iam_policy_management.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * The getRoleAssignment options. + */ +public class GetRoleAssignmentOptions extends GenericModel { + + protected String assignmentId; + + /** + * Builder. + */ + public static class Builder { + private String assignmentId; + + /** + * Instantiates a new Builder from an existing GetRoleAssignmentOptions instance. + * + * @param getRoleAssignmentOptions the instance to initialize the Builder with + */ + private Builder(GetRoleAssignmentOptions getRoleAssignmentOptions) { + this.assignmentId = getRoleAssignmentOptions.assignmentId; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Instantiates a new builder with required properties. + * + * @param assignmentId the assignmentId + */ + public Builder(String assignmentId) { + this.assignmentId = assignmentId; + } + + /** + * Builds a GetRoleAssignmentOptions. + * + * @return the new GetRoleAssignmentOptions instance + */ + public GetRoleAssignmentOptions build() { + return new GetRoleAssignmentOptions(this); + } + + /** + * Set the assignmentId. + * + * @param assignmentId the assignmentId + * @return the GetRoleAssignmentOptions builder + */ + public Builder assignmentId(String assignmentId) { + this.assignmentId = assignmentId; + return this; + } + } + + protected GetRoleAssignmentOptions() { } + + protected GetRoleAssignmentOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.assignmentId, + "assignmentId cannot be empty"); + assignmentId = builder.assignmentId; + } + + /** + * New builder. + * + * @return a GetRoleAssignmentOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the assignmentId. + * + * Role template assignment ID. + * + * @return the assignmentId + */ + public String assignmentId() { + return assignmentId; + } +} + diff --git a/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/GetRoleTemplateOptions.java b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/GetRoleTemplateOptions.java new file mode 100644 index 00000000000..e33fcf29b32 --- /dev/null +++ b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/GetRoleTemplateOptions.java @@ -0,0 +1,140 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.iam_policy_management.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * The getRoleTemplate options. + */ +public class GetRoleTemplateOptions extends GenericModel { + + /** + * The role template state. + */ + public interface State { + /** active. */ + String ACTIVE = "active"; + /** deleted. */ + String DELETED = "deleted"; + } + + protected String roleTemplateId; + protected String state; + + /** + * Builder. + */ + public static class Builder { + private String roleTemplateId; + private String state; + + /** + * Instantiates a new Builder from an existing GetRoleTemplateOptions instance. + * + * @param getRoleTemplateOptions the instance to initialize the Builder with + */ + private Builder(GetRoleTemplateOptions getRoleTemplateOptions) { + this.roleTemplateId = getRoleTemplateOptions.roleTemplateId; + this.state = getRoleTemplateOptions.state; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Instantiates a new builder with required properties. + * + * @param roleTemplateId the roleTemplateId + */ + public Builder(String roleTemplateId) { + this.roleTemplateId = roleTemplateId; + } + + /** + * Builds a GetRoleTemplateOptions. + * + * @return the new GetRoleTemplateOptions instance + */ + public GetRoleTemplateOptions build() { + return new GetRoleTemplateOptions(this); + } + + /** + * Set the roleTemplateId. + * + * @param roleTemplateId the roleTemplateId + * @return the GetRoleTemplateOptions builder + */ + public Builder roleTemplateId(String roleTemplateId) { + this.roleTemplateId = roleTemplateId; + return this; + } + + /** + * Set the state. + * + * @param state the state + * @return the GetRoleTemplateOptions builder + */ + public Builder state(String state) { + this.state = state; + return this; + } + } + + protected GetRoleTemplateOptions() { } + + protected GetRoleTemplateOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.roleTemplateId, + "roleTemplateId cannot be empty"); + roleTemplateId = builder.roleTemplateId; + state = builder.state; + } + + /** + * New builder. + * + * @return a GetRoleTemplateOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the roleTemplateId. + * + * Role template ID. + * + * @return the roleTemplateId + */ + public String roleTemplateId() { + return roleTemplateId; + } + + /** + * Gets the state. + * + * The role template state. + * + * @return the state + */ + public String state() { + return state; + } +} + diff --git a/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/GetRoleTemplateVersionOptions.java b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/GetRoleTemplateVersionOptions.java new file mode 100644 index 00000000000..4757484f969 --- /dev/null +++ b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/GetRoleTemplateVersionOptions.java @@ -0,0 +1,134 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.iam_policy_management.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * The getRoleTemplateVersion options. + */ +public class GetRoleTemplateVersionOptions extends GenericModel { + + protected String roleTemplateId; + protected String version; + + /** + * Builder. + */ + public static class Builder { + private String roleTemplateId; + private String version; + + /** + * Instantiates a new Builder from an existing GetRoleTemplateVersionOptions instance. + * + * @param getRoleTemplateVersionOptions the instance to initialize the Builder with + */ + private Builder(GetRoleTemplateVersionOptions getRoleTemplateVersionOptions) { + this.roleTemplateId = getRoleTemplateVersionOptions.roleTemplateId; + this.version = getRoleTemplateVersionOptions.version; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Instantiates a new builder with required properties. + * + * @param roleTemplateId the roleTemplateId + * @param version the version + */ + public Builder(String roleTemplateId, String version) { + this.roleTemplateId = roleTemplateId; + this.version = version; + } + + /** + * Builds a GetRoleTemplateVersionOptions. + * + * @return the new GetRoleTemplateVersionOptions instance + */ + public GetRoleTemplateVersionOptions build() { + return new GetRoleTemplateVersionOptions(this); + } + + /** + * Set the roleTemplateId. + * + * @param roleTemplateId the roleTemplateId + * @return the GetRoleTemplateVersionOptions builder + */ + public Builder roleTemplateId(String roleTemplateId) { + this.roleTemplateId = roleTemplateId; + return this; + } + + /** + * Set the version. + * + * @param version the version + * @return the GetRoleTemplateVersionOptions builder + */ + public Builder version(String version) { + this.version = version; + return this; + } + } + + protected GetRoleTemplateVersionOptions() { } + + protected GetRoleTemplateVersionOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.roleTemplateId, + "roleTemplateId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.version, + "version cannot be empty"); + roleTemplateId = builder.roleTemplateId; + version = builder.version; + } + + /** + * New builder. + * + * @return a GetRoleTemplateVersionOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the roleTemplateId. + * + * Role template ID. + * + * @return the roleTemplateId + */ + public String roleTemplateId() { + return roleTemplateId; + } + + /** + * Gets the version. + * + * Role template version. + * + * @return the version + */ + public String version() { + return version; + } +} + diff --git a/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ListRoleAssignmentsOptions.java b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ListRoleAssignmentsOptions.java new file mode 100644 index 00000000000..adcb3f0cc90 --- /dev/null +++ b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ListRoleAssignmentsOptions.java @@ -0,0 +1,245 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.iam_policy_management.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * The listRoleAssignments options. + */ +public class ListRoleAssignmentsOptions extends GenericModel { + + protected String accountId; + protected String acceptLanguage; + protected String templateId; + protected String templateVersion; + protected Long limit; + protected String start; + + /** + * Builder. + */ + public static class Builder { + private String accountId; + private String acceptLanguage; + private String templateId; + private String templateVersion; + private Long limit; + private String start; + + /** + * Instantiates a new Builder from an existing ListRoleAssignmentsOptions instance. + * + * @param listRoleAssignmentsOptions the instance to initialize the Builder with + */ + private Builder(ListRoleAssignmentsOptions listRoleAssignmentsOptions) { + this.accountId = listRoleAssignmentsOptions.accountId; + this.acceptLanguage = listRoleAssignmentsOptions.acceptLanguage; + this.templateId = listRoleAssignmentsOptions.templateId; + this.templateVersion = listRoleAssignmentsOptions.templateVersion; + this.limit = listRoleAssignmentsOptions.limit; + this.start = listRoleAssignmentsOptions.start; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Instantiates a new builder with required properties. + * + * @param accountId the accountId + */ + public Builder(String accountId) { + this.accountId = accountId; + } + + /** + * Builds a ListRoleAssignmentsOptions. + * + * @return the new ListRoleAssignmentsOptions instance + */ + public ListRoleAssignmentsOptions build() { + return new ListRoleAssignmentsOptions(this); + } + + /** + * Set the accountId. + * + * @param accountId the accountId + * @return the ListRoleAssignmentsOptions builder + */ + public Builder accountId(String accountId) { + this.accountId = accountId; + return this; + } + + /** + * Set the acceptLanguage. + * + * @param acceptLanguage the acceptLanguage + * @return the ListRoleAssignmentsOptions builder + */ + public Builder acceptLanguage(String acceptLanguage) { + this.acceptLanguage = acceptLanguage; + return this; + } + + /** + * Set the templateId. + * + * @param templateId the templateId + * @return the ListRoleAssignmentsOptions builder + */ + public Builder templateId(String templateId) { + this.templateId = templateId; + return this; + } + + /** + * Set the templateVersion. + * + * @param templateVersion the templateVersion + * @return the ListRoleAssignmentsOptions builder + */ + public Builder templateVersion(String templateVersion) { + this.templateVersion = templateVersion; + return this; + } + + /** + * Set the limit. + * + * @param limit the limit + * @return the ListRoleAssignmentsOptions builder + */ + public Builder limit(long limit) { + this.limit = limit; + return this; + } + + /** + * Set the start. + * + * @param start the start + * @return the ListRoleAssignmentsOptions builder + */ + public Builder start(String start) { + this.start = start; + return this; + } + } + + protected ListRoleAssignmentsOptions() { } + + protected ListRoleAssignmentsOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.accountId, + "accountId cannot be null"); + accountId = builder.accountId; + acceptLanguage = builder.acceptLanguage; + templateId = builder.templateId; + templateVersion = builder.templateVersion; + limit = builder.limit; + start = builder.start; + } + + /** + * New builder. + * + * @return a ListRoleAssignmentsOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the accountId. + * + * The account GUID in which the role assignment belongs to. + * + * @return the accountId + */ + public String accountId() { + return accountId; + } + + /** + * Gets the acceptLanguage. + * + * Language code for translations + * * `default` - English + * * `de` - German (Standard) + * * `en` - English + * * `es` - Spanish (Spain) + * * `fr` - French (Standard) + * * `it` - Italian (Standard) + * * `ja` - Japanese + * * `ko` - Korean + * * `pt-br` - Portuguese (Brazil) + * * `zh-cn` - Chinese (Simplified, PRC) + * * `zh-tw` - (Chinese, Taiwan). + * + * @return the acceptLanguage + */ + public String acceptLanguage() { + return acceptLanguage; + } + + /** + * Gets the templateId. + * + * Optional template ID. + * + * @return the templateId + */ + public String templateId() { + return templateId; + } + + /** + * Gets the templateVersion. + * + * Optional role template version. + * + * @return the templateVersion + */ + public String templateVersion() { + return templateVersion; + } + + /** + * Gets the limit. + * + * The number of documents to include in the collection. + * + * @return the limit + */ + public Long limit() { + return limit; + } + + /** + * Gets the start. + * + * Page token that refers to the page of the collection to return. + * + * @return the start + */ + public String start() { + return start; + } +} + diff --git a/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ListRoleTemplateVersionsOptions.java b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ListRoleTemplateVersionsOptions.java new file mode 100644 index 00000000000..e22751433e5 --- /dev/null +++ b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ListRoleTemplateVersionsOptions.java @@ -0,0 +1,192 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.iam_policy_management.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * The listRoleTemplateVersions options. + */ +public class ListRoleTemplateVersionsOptions extends GenericModel { + + /** + * Role template state. + */ + public interface State { + /** active. */ + String ACTIVE = "active"; + /** deleted. */ + String DELETED = "deleted"; + } + + protected String roleTemplateId; + protected String state; + protected Long limit; + protected String start; + + /** + * Builder. + */ + public static class Builder { + private String roleTemplateId; + private String state; + private Long limit; + private String start; + + /** + * Instantiates a new Builder from an existing ListRoleTemplateVersionsOptions instance. + * + * @param listRoleTemplateVersionsOptions the instance to initialize the Builder with + */ + private Builder(ListRoleTemplateVersionsOptions listRoleTemplateVersionsOptions) { + this.roleTemplateId = listRoleTemplateVersionsOptions.roleTemplateId; + this.state = listRoleTemplateVersionsOptions.state; + this.limit = listRoleTemplateVersionsOptions.limit; + this.start = listRoleTemplateVersionsOptions.start; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Instantiates a new builder with required properties. + * + * @param roleTemplateId the roleTemplateId + */ + public Builder(String roleTemplateId) { + this.roleTemplateId = roleTemplateId; + } + + /** + * Builds a ListRoleTemplateVersionsOptions. + * + * @return the new ListRoleTemplateVersionsOptions instance + */ + public ListRoleTemplateVersionsOptions build() { + return new ListRoleTemplateVersionsOptions(this); + } + + /** + * Set the roleTemplateId. + * + * @param roleTemplateId the roleTemplateId + * @return the ListRoleTemplateVersionsOptions builder + */ + public Builder roleTemplateId(String roleTemplateId) { + this.roleTemplateId = roleTemplateId; + return this; + } + + /** + * Set the state. + * + * @param state the state + * @return the ListRoleTemplateVersionsOptions builder + */ + public Builder state(String state) { + this.state = state; + return this; + } + + /** + * Set the limit. + * + * @param limit the limit + * @return the ListRoleTemplateVersionsOptions builder + */ + public Builder limit(long limit) { + this.limit = limit; + return this; + } + + /** + * Set the start. + * + * @param start the start + * @return the ListRoleTemplateVersionsOptions builder + */ + public Builder start(String start) { + this.start = start; + return this; + } + } + + protected ListRoleTemplateVersionsOptions() { } + + protected ListRoleTemplateVersionsOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.roleTemplateId, + "roleTemplateId cannot be empty"); + roleTemplateId = builder.roleTemplateId; + state = builder.state; + limit = builder.limit; + start = builder.start; + } + + /** + * New builder. + * + * @return a ListRoleTemplateVersionsOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the roleTemplateId. + * + * The role template ID. + * + * @return the roleTemplateId + */ + public String roleTemplateId() { + return roleTemplateId; + } + + /** + * Gets the state. + * + * Role template state. + * + * @return the state + */ + public String state() { + return state; + } + + /** + * Gets the limit. + * + * The number of documents to include in the collection. + * + * @return the limit + */ + public Long limit() { + return limit; + } + + /** + * Gets the start. + * + * Page token that refers to the page of the collection to return. + * + * @return the start + */ + public String start() { + return start; + } +} + diff --git a/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ListRoleTemplatesOptions.java b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ListRoleTemplatesOptions.java new file mode 100644 index 00000000000..8f889bdce96 --- /dev/null +++ b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ListRoleTemplatesOptions.java @@ -0,0 +1,307 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.iam_policy_management.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * The listRoleTemplates options. + */ +public class ListRoleTemplatesOptions extends GenericModel { + + /** + * The role template state. + */ + public interface State { + /** active. */ + String ACTIVE = "active"; + /** deleted. */ + String DELETED = "deleted"; + } + + protected String accountId; + protected String acceptLanguage; + protected String name; + protected String roleName; + protected String roleServiceName; + protected String state; + protected Long limit; + protected String start; + + /** + * Builder. + */ + public static class Builder { + private String accountId; + private String acceptLanguage; + private String name; + private String roleName; + private String roleServiceName; + private String state; + private Long limit; + private String start; + + /** + * Instantiates a new Builder from an existing ListRoleTemplatesOptions instance. + * + * @param listRoleTemplatesOptions the instance to initialize the Builder with + */ + private Builder(ListRoleTemplatesOptions listRoleTemplatesOptions) { + this.accountId = listRoleTemplatesOptions.accountId; + this.acceptLanguage = listRoleTemplatesOptions.acceptLanguage; + this.name = listRoleTemplatesOptions.name; + this.roleName = listRoleTemplatesOptions.roleName; + this.roleServiceName = listRoleTemplatesOptions.roleServiceName; + this.state = listRoleTemplatesOptions.state; + this.limit = listRoleTemplatesOptions.limit; + this.start = listRoleTemplatesOptions.start; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Instantiates a new builder with required properties. + * + * @param accountId the accountId + */ + public Builder(String accountId) { + this.accountId = accountId; + } + + /** + * Builds a ListRoleTemplatesOptions. + * + * @return the new ListRoleTemplatesOptions instance + */ + public ListRoleTemplatesOptions build() { + return new ListRoleTemplatesOptions(this); + } + + /** + * Set the accountId. + * + * @param accountId the accountId + * @return the ListRoleTemplatesOptions builder + */ + public Builder accountId(String accountId) { + this.accountId = accountId; + return this; + } + + /** + * Set the acceptLanguage. + * + * @param acceptLanguage the acceptLanguage + * @return the ListRoleTemplatesOptions builder + */ + public Builder acceptLanguage(String acceptLanguage) { + this.acceptLanguage = acceptLanguage; + return this; + } + + /** + * Set the name. + * + * @param name the name + * @return the ListRoleTemplatesOptions builder + */ + public Builder name(String name) { + this.name = name; + return this; + } + + /** + * Set the roleName. + * + * @param roleName the roleName + * @return the ListRoleTemplatesOptions builder + */ + public Builder roleName(String roleName) { + this.roleName = roleName; + return this; + } + + /** + * Set the roleServiceName. + * + * @param roleServiceName the roleServiceName + * @return the ListRoleTemplatesOptions builder + */ + public Builder roleServiceName(String roleServiceName) { + this.roleServiceName = roleServiceName; + return this; + } + + /** + * Set the state. + * + * @param state the state + * @return the ListRoleTemplatesOptions builder + */ + public Builder state(String state) { + this.state = state; + return this; + } + + /** + * Set the limit. + * + * @param limit the limit + * @return the ListRoleTemplatesOptions builder + */ + public Builder limit(long limit) { + this.limit = limit; + return this; + } + + /** + * Set the start. + * + * @param start the start + * @return the ListRoleTemplatesOptions builder + */ + public Builder start(String start) { + this.start = start; + return this; + } + } + + protected ListRoleTemplatesOptions() { } + + protected ListRoleTemplatesOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.accountId, + "accountId cannot be null"); + accountId = builder.accountId; + acceptLanguage = builder.acceptLanguage; + name = builder.name; + roleName = builder.roleName; + roleServiceName = builder.roleServiceName; + state = builder.state; + limit = builder.limit; + start = builder.start; + } + + /** + * New builder. + * + * @return a ListRoleTemplatesOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the accountId. + * + * The account GUID that the role templates belong to. + * + * @return the accountId + */ + public String accountId() { + return accountId; + } + + /** + * Gets the acceptLanguage. + * + * Language code for translations + * * `default` - English + * * `de` - German (Standard) + * * `en` - English + * * `es` - Spanish (Spain) + * * `fr` - French (Standard) + * * `it` - Italian (Standard) + * * `ja` - Japanese + * * `ko` - Korean + * * `pt-br` - Portuguese (Brazil) + * * `zh-cn` - Chinese (Simplified, PRC) + * * `zh-tw` - (Chinese, Taiwan). + * + * @return the acceptLanguage + */ + public String acceptLanguage() { + return acceptLanguage; + } + + /** + * Gets the name. + * + * The role template name. + * + * @return the name + */ + public String name() { + return name; + } + + /** + * Gets the roleName. + * + * The template role name. + * + * @return the roleName + */ + public String roleName() { + return roleName; + } + + /** + * Gets the roleServiceName. + * + * The template role service name. + * + * @return the roleServiceName + */ + public String roleServiceName() { + return roleServiceName; + } + + /** + * Gets the state. + * + * The role template state. + * + * @return the state + */ + public String state() { + return state; + } + + /** + * Gets the limit. + * + * The number of documents to include in the collection. + * + * @return the limit + */ + public Long limit() { + return limit; + } + + /** + * Gets the start. + * + * Page token that refers to the page of the collection to return. + * + * @return the start + */ + public String start() { + return start; + } +} + diff --git a/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyAssignmentResourcePolicy.java b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyAssignmentResourcePolicy.java index 03146075cea..3e566ce7bdf 100644 --- a/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyAssignmentResourcePolicy.java +++ b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyAssignmentResourcePolicy.java @@ -25,7 +25,7 @@ public class PolicyAssignmentResourcePolicy extends GenericModel { protected AssignmentResourceCreated resourceCreated; protected String status; @SerializedName("error_message") - protected ErrorResponse errorMessage; + protected AssignmentResourceError errorMessage; protected PolicyAssignmentResourcePolicy() { } @@ -54,11 +54,11 @@ public String getStatus() { /** * Gets the errorMessage. * - * The error response from API. + * Body parameters for assignment error. * * @return the errorMessage */ - public ErrorResponse getErrorMessage() { + public AssignmentResourceError getErrorMessage() { return errorMessage; } } diff --git a/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ReplaceRoleTemplateOptions.java b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ReplaceRoleTemplateOptions.java new file mode 100644 index 00000000000..ed017c6502e --- /dev/null +++ b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ReplaceRoleTemplateOptions.java @@ -0,0 +1,277 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.iam_policy_management.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * The replaceRoleTemplate options. + */ +public class ReplaceRoleTemplateOptions extends GenericModel { + + protected String roleTemplateId; + protected String version; + protected String ifMatch; + protected TemplateRole role; + protected String name; + protected String description; + protected Boolean committed; + + /** + * Builder. + */ + public static class Builder { + private String roleTemplateId; + private String version; + private String ifMatch; + private TemplateRole role; + private String name; + private String description; + private Boolean committed; + + /** + * Instantiates a new Builder from an existing ReplaceRoleTemplateOptions instance. + * + * @param replaceRoleTemplateOptions the instance to initialize the Builder with + */ + private Builder(ReplaceRoleTemplateOptions replaceRoleTemplateOptions) { + this.roleTemplateId = replaceRoleTemplateOptions.roleTemplateId; + this.version = replaceRoleTemplateOptions.version; + this.ifMatch = replaceRoleTemplateOptions.ifMatch; + this.role = replaceRoleTemplateOptions.role; + this.name = replaceRoleTemplateOptions.name; + this.description = replaceRoleTemplateOptions.description; + this.committed = replaceRoleTemplateOptions.committed; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Instantiates a new builder with required properties. + * + * @param roleTemplateId the roleTemplateId + * @param version the version + * @param ifMatch the ifMatch + * @param role the role + */ + public Builder(String roleTemplateId, String version, String ifMatch, TemplateRole role) { + this.roleTemplateId = roleTemplateId; + this.version = version; + this.ifMatch = ifMatch; + this.role = role; + } + + /** + * Builds a ReplaceRoleTemplateOptions. + * + * @return the new ReplaceRoleTemplateOptions instance + */ + public ReplaceRoleTemplateOptions build() { + return new ReplaceRoleTemplateOptions(this); + } + + /** + * Set the roleTemplateId. + * + * @param roleTemplateId the roleTemplateId + * @return the ReplaceRoleTemplateOptions builder + */ + public Builder roleTemplateId(String roleTemplateId) { + this.roleTemplateId = roleTemplateId; + return this; + } + + /** + * Set the version. + * + * @param version the version + * @return the ReplaceRoleTemplateOptions builder + */ + public Builder version(String version) { + this.version = version; + return this; + } + + /** + * Set the ifMatch. + * + * @param ifMatch the ifMatch + * @return the ReplaceRoleTemplateOptions builder + */ + public Builder ifMatch(String ifMatch) { + this.ifMatch = ifMatch; + return this; + } + + /** + * Set the role. + * + * @param role the role + * @return the ReplaceRoleTemplateOptions builder + */ + public Builder role(TemplateRole role) { + this.role = role; + return this; + } + + /** + * Set the name. + * + * @param name the name + * @return the ReplaceRoleTemplateOptions builder + */ + public Builder name(String name) { + this.name = name; + return this; + } + + /** + * Set the description. + * + * @param description the description + * @return the ReplaceRoleTemplateOptions builder + */ + public Builder description(String description) { + this.description = description; + return this; + } + + /** + * Set the committed. + * + * @param committed the committed + * @return the ReplaceRoleTemplateOptions builder + */ + public Builder committed(Boolean committed) { + this.committed = committed; + return this; + } + } + + protected ReplaceRoleTemplateOptions() { } + + protected ReplaceRoleTemplateOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.roleTemplateId, + "roleTemplateId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.version, + "version cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.ifMatch, + "ifMatch cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.role, + "role cannot be null"); + roleTemplateId = builder.roleTemplateId; + version = builder.version; + ifMatch = builder.ifMatch; + role = builder.role; + name = builder.name; + description = builder.description; + committed = builder.committed; + } + + /** + * New builder. + * + * @return a ReplaceRoleTemplateOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the roleTemplateId. + * + * Role template ID. + * + * @return the roleTemplateId + */ + public String roleTemplateId() { + return roleTemplateId; + } + + /** + * Gets the version. + * + * Role template version. + * + * @return the version + */ + public String version() { + return version; + } + + /** + * Gets the ifMatch. + * + * The revision number for updating a role template version must match the Etag value of the existing role template + * version. The Etag can be retrieved using the GET /v1/role_templates/{template_id}/versions/{version} API and + * looking at the Etag response header. + * + * @return the ifMatch + */ + public String ifMatch() { + return ifMatch; + } + + /** + * Gets the role. + * + * The role properties that are created in an action resource when the template is assigned. + * + * @return the role + */ + public TemplateRole role() { + return role; + } + + /** + * Gets the name. + * + * Required field when creating a new template. Otherwise, this field is optional. If the field is included, it will + * change the name value for all existing versions of the template. + * + * @return the name + */ + public String name() { + return name; + } + + /** + * Gets the description. + * + * Description of the role template. This is shown to users in the enterprise account. Use this to describe the + * purpose or context of the role for enterprise users managing IAM templates. + * + * @return the description + */ + public String description() { + return description; + } + + /** + * Gets the committed. + * + * Committed status of the template version. If committed is set to true, then the template version can no longer be + * updated. + * + * @return the committed + */ + public Boolean committed() { + return committed; + } +} + diff --git a/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/RoleAssignment.java b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/RoleAssignment.java new file mode 100644 index 00000000000..23bb4b65c6f --- /dev/null +++ b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/RoleAssignment.java @@ -0,0 +1,207 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.iam_policy_management.v1.model; + +import java.util.Date; +import java.util.List; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * The set of properties associated with the assigned role template. + */ +public class RoleAssignment extends GenericModel { + + /** + * The current operation of the role assignment. + */ + public interface Operation { + /** create. */ + String CREATE = "create"; + /** apply. */ + String APPLY = "apply"; + /** update. */ + String UPDATE = "update"; + /** remove. */ + String REMOVE = "remove"; + } + + /** + * The role assignment status. + */ + public interface Status { + /** accepted. */ + String ACCEPTED = "accepted"; + /** failure. */ + String FAILURE = "failure"; + /** in_progress. */ + String IN_PROGRESS = "in_progress"; + /** superseded. */ + String SUPERSEDED = "superseded"; + } + + protected String id; + @SerializedName("account_id") + protected String accountId; + protected String href; + @SerializedName("created_at") + protected Date createdAt; + @SerializedName("created_by_id") + protected String createdById; + @SerializedName("last_modified_at") + protected Date lastModifiedAt; + @SerializedName("last_modified_by_id") + protected String lastModifiedById; + protected String operation; + protected List resources; + protected RoleAssignmentTemplate template; + protected AssignmentTargetDetails target; + protected String status; + + protected RoleAssignment() { } + + /** + * Gets the id. + * + * Action control assignment ID. + * + * @return the id + */ + public String getId() { + return id; + } + + /** + * Gets the accountId. + * + * The account GUID that the role assignments belong to. + * + * @return the accountId + */ + public String getAccountId() { + return accountId; + } + + /** + * Gets the href. + * + * The href URL that links to the role assignments API by role assignment ID. + * + * @return the href + */ + public String getHref() { + return href; + } + + /** + * Gets the createdAt. + * + * The UTC timestamp when the role assignment was created. + * + * @return the createdAt + */ + public Date getCreatedAt() { + return createdAt; + } + + /** + * Gets the createdById. + * + * The IAM ID of the entity that created the role assignment. + * + * @return the createdById + */ + public String getCreatedById() { + return createdById; + } + + /** + * Gets the lastModifiedAt. + * + * The UTC timestamp when the role assignment was last modified. + * + * @return the lastModifiedAt + */ + public Date getLastModifiedAt() { + return lastModifiedAt; + } + + /** + * Gets the lastModifiedById. + * + * The IAM ID of the entity that last modified the role assignment. + * + * @return the lastModifiedById + */ + public String getLastModifiedById() { + return lastModifiedById; + } + + /** + * Gets the operation. + * + * The current operation of the role assignment. + * + * @return the operation + */ + public String getOperation() { + return operation; + } + + /** + * Gets the resources. + * + * Resources created when role template is assigned. + * + * @return the resources + */ + public List getResources() { + return resources; + } + + /** + * Gets the template. + * + * The role template id and version that will be assigned. + * + * @return the template + */ + public RoleAssignmentTemplate getTemplate() { + return template; + } + + /** + * Gets the target. + * + * assignment target account and type. + * + * @return the target + */ + public AssignmentTargetDetails getTarget() { + return target; + } + + /** + * Gets the status. + * + * The role assignment status. + * + * @return the status + */ + public String getStatus() { + return status; + } +} + diff --git a/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/RoleAssignmentCollection.java b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/RoleAssignmentCollection.java new file mode 100644 index 00000000000..658ac5b8c99 --- /dev/null +++ b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/RoleAssignmentCollection.java @@ -0,0 +1,88 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.iam_policy_management.v1.model; + +import java.util.List; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * A collection of role assignments. + */ +public class RoleAssignmentCollection extends GenericModel { + + protected Long limit; + protected First first; + protected Next next; + protected Previous previous; + protected List assignments; + + protected RoleAssignmentCollection() { } + + /** + * Gets the limit. + * + * The number of documents to include per each page of the collection. + * + * @return the limit + */ + public Long getLimit() { + return limit; + } + + /** + * Gets the first. + * + * Details with linking href to first page of requested collection. + * + * @return the first + */ + public First getFirst() { + return first; + } + + /** + * Gets the next. + * + * Details with href linking to the following page of requested collection. + * + * @return the next + */ + public Next getNext() { + return next; + } + + /** + * Gets the previous. + * + * Details with linking href to previous page of requested collection. + * + * @return the previous + */ + public Previous getPrevious() { + return previous; + } + + /** + * Gets the assignments. + * + * List of role assignments. + * + * @return the assignments + */ + public List getAssignments() { + return assignments; + } +} + diff --git a/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/RoleAssignmentResource.java b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/RoleAssignmentResource.java new file mode 100644 index 00000000000..60d7a02d604 --- /dev/null +++ b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/RoleAssignmentResource.java @@ -0,0 +1,50 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.iam_policy_management.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * The role assignment resources and target where the template is assigned. + */ +public class RoleAssignmentResource extends GenericModel { + + protected AssignmentTargetDetails target; + protected RoleAssignmentResourceRole role; + + protected RoleAssignmentResource() { } + + /** + * Gets the target. + * + * assignment target account and type. + * + * @return the target + */ + public AssignmentTargetDetails getTarget() { + return target; + } + + /** + * Gets the role. + * + * Set of properties of the assigned resource or error message if assignment failed. + * + * @return the role + */ + public RoleAssignmentResourceRole getRole() { + return role; + } +} + diff --git a/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/RoleAssignmentResourceCreated.java b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/RoleAssignmentResourceCreated.java new file mode 100644 index 00000000000..e83347c984e --- /dev/null +++ b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/RoleAssignmentResourceCreated.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.iam_policy_management.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * On success, it includes the action control assigned. + */ +public class RoleAssignmentResourceCreated extends GenericModel { + + protected String id; + + protected RoleAssignmentResourceCreated() { } + + /** + * Gets the id. + * + * role id. + * + * @return the id + */ + public String getId() { + return id; + } +} + diff --git a/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/RoleAssignmentResourceRole.java b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/RoleAssignmentResourceRole.java new file mode 100644 index 00000000000..95358784dd0 --- /dev/null +++ b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/RoleAssignmentResourceRole.java @@ -0,0 +1,53 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.iam_policy_management.v1.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * Set of properties of the assigned resource or error message if assignment failed. + */ +public class RoleAssignmentResourceRole extends GenericModel { + + @SerializedName("resource_created") + protected RoleAssignmentResourceCreated resourceCreated; + @SerializedName("error_message") + protected AssignmentResourceError errorMessage; + + protected RoleAssignmentResourceRole() { } + + /** + * Gets the resourceCreated. + * + * On success, it includes the action control assigned. + * + * @return the resourceCreated + */ + public RoleAssignmentResourceCreated getResourceCreated() { + return resourceCreated; + } + + /** + * Gets the errorMessage. + * + * Body parameters for assignment error. + * + * @return the errorMessage + */ + public AssignmentResourceError getErrorMessage() { + return errorMessage; + } +} + diff --git a/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/RoleAssignmentTemplate.java b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/RoleAssignmentTemplate.java new file mode 100644 index 00000000000..3524b91f4d5 --- /dev/null +++ b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/RoleAssignmentTemplate.java @@ -0,0 +1,134 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.iam_policy_management.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * The role template id and version that will be assigned. + */ +public class RoleAssignmentTemplate extends GenericModel { + + protected String id; + protected String version; + + /** + * Builder. + */ + public static class Builder { + private String id; + private String version; + + /** + * Instantiates a new Builder from an existing RoleAssignmentTemplate instance. + * + * @param roleAssignmentTemplate the instance to initialize the Builder with + */ + private Builder(RoleAssignmentTemplate roleAssignmentTemplate) { + this.id = roleAssignmentTemplate.id; + this.version = roleAssignmentTemplate.version; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Instantiates a new builder with required properties. + * + * @param id the id + * @param version the version + */ + public Builder(String id, String version) { + this.id = id; + this.version = version; + } + + /** + * Builds a RoleAssignmentTemplate. + * + * @return the new RoleAssignmentTemplate instance + */ + public RoleAssignmentTemplate build() { + return new RoleAssignmentTemplate(this); + } + + /** + * Set the id. + * + * @param id the id + * @return the RoleAssignmentTemplate builder + */ + public Builder id(String id) { + this.id = id; + return this; + } + + /** + * Set the version. + * + * @param version the version + * @return the RoleAssignmentTemplate builder + */ + public Builder version(String version) { + this.version = version; + return this; + } + } + + protected RoleAssignmentTemplate() { } + + protected RoleAssignmentTemplate(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.id, + "id cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.version, + "version cannot be null"); + id = builder.id; + version = builder.version; + } + + /** + * New builder. + * + * @return a RoleAssignmentTemplate builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the id. + * + * Action control template ID. + * + * @return the id + */ + public String id() { + return id; + } + + /** + * Gets the version. + * + * Action control template version. + * + * @return the version + */ + public String version() { + return version; + } +} + diff --git a/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/RoleAssignmentsPager.java b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/RoleAssignmentsPager.java new file mode 100644 index 00000000000..16296a82e40 --- /dev/null +++ b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/RoleAssignmentsPager.java @@ -0,0 +1,108 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.iam_policy_management.v1.model; + +import com.ibm.cloud.platform_services.iam_policy_management.v1.IamPolicyManagement; +import java.util.ArrayList; +import java.util.List; +import java.util.NoSuchElementException; + +/** + * RoleAssignmentsPager can be used to simplify the use of the "listRoleAssignments" method. + */ +public class RoleAssignmentsPager { + private static class PageContext { + private String next; + public String getNext() { + return next; + } + public void setNext(String next) { + this.next = next; + } + } + + protected boolean hasNext; + protected ListRoleAssignmentsOptions options; + protected IamPolicyManagement client; + protected PageContext pageContext; + + // Hide the default ctor. + protected RoleAssignmentsPager() { } + + /** + * Constructs a new RoleAssignmentsPager instance with the specified client and options model instance. + * @param client the IamPolicyManagement instance to be used to invoke the "listRoleAssignments" method + * @param options the ListRoleAssignmentsOptions instance to be used to invoke the "listRoleAssignments" method + */ + public RoleAssignmentsPager(IamPolicyManagement client, ListRoleAssignmentsOptions options) { + if (options.start() != null) { + throw new IllegalArgumentException("The options 'start' field should not be set"); + } + + this.hasNext = true; + this.client = client; + this.options = options.newBuilder().build(); + this.pageContext = new PageContext(); + } + + /** + * Returns true if there are more results to be retrieved. + * @return boolean + */ + public boolean hasNext() { + return hasNext; + } + + /** + * Returns the next page of results. + * @return a List<RoleAssignment> that contains the next page of results + */ + public List getNext() { + if (!hasNext()) { + throw new NoSuchElementException("No more results available"); + } + + ListRoleAssignmentsOptions.Builder builder = this.options.newBuilder(); + if (this.pageContext.getNext() != null) { + builder.start(this.pageContext.getNext()); + } + this.options = builder.build(); + + RoleAssignmentCollection result = client.listRoleAssignments(options).execute().getResult(); + + String next = null; + if (result.getNext() != null) { + next = result.getNext().getStart(); + } + this.pageContext.setNext(next); + if (next == null) { + this.hasNext = false; + } + + return result.getAssignments(); + } + + /** + * Returns all results by invoking getNext() repeatedly until all pages of results have been retrieved. + * @return a List<RoleAssignment> containing all results returned by the "listRoleAssignments" method + */ + public List getAll() { + List results = new ArrayList<>(); + while (hasNext()) { + List nextPage = getNext(); + results.addAll(nextPage); + } + return results; + } +} diff --git a/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/RoleTemplate.java b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/RoleTemplate.java new file mode 100644 index 00000000000..49127d6035e --- /dev/null +++ b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/RoleTemplate.java @@ -0,0 +1,202 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.iam_policy_management.v1.model; + +import java.util.Date; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * The set of properties associated with the role template. + */ +public class RoleTemplate extends GenericModel { + + /** + * State of role template. + */ + public interface State { + /** active. */ + String ACTIVE = "active"; + /** deleted. */ + String DELETED = "deleted"; + } + + protected String name; + protected String description; + @SerializedName("account_id") + protected String accountId; + protected Boolean committed; + protected TemplateRole role; + protected String id; + protected String href; + @SerializedName("created_at") + protected Date createdAt; + @SerializedName("created_by_id") + protected String createdById; + @SerializedName("last_modified_at") + protected Date lastModifiedAt; + @SerializedName("last_modified_by_id") + protected String lastModifiedById; + protected String version; + protected String state; + + protected RoleTemplate() { } + + /** + * Gets the name. + * + * Required field when creating a new template. Otherwise, this field is optional. If the field is included, it + * changes the name value for all existing versions of the template. + * + * @return the name + */ + public String getName() { + return name; + } + + /** + * Gets the description. + * + * Description of the role template. This is shown to users in the enterprise account. Use this to describe the + * purpose or context of the role for enterprise users managing IAM templates. + * + * @return the description + */ + public String getDescription() { + return description; + } + + /** + * Gets the accountId. + * + * Enterprise account ID where this template is created. + * + * @return the accountId + */ + public String getAccountId() { + return accountId; + } + + /** + * Gets the committed. + * + * Committed status of the template. If committed is set to true, then the template version can no longer be updated. + * + * @return the committed + */ + public Boolean isCommitted() { + return committed; + } + + /** + * Gets the role. + * + * The role properties that are created in an action resource when the template is assigned. + * + * @return the role + */ + public TemplateRole getRole() { + return role; + } + + /** + * Gets the id. + * + * The role template ID. + * + * @return the id + */ + public String getId() { + return id; + } + + /** + * Gets the href. + * + * The href URL that links to the role templates API by role template ID. + * + * @return the href + */ + public String getHref() { + return href; + } + + /** + * Gets the createdAt. + * + * The UTC timestamp when the role template was created. + * + * @return the createdAt + */ + public Date getCreatedAt() { + return createdAt; + } + + /** + * Gets the createdById. + * + * The IAM ID of the entity that created the role template. + * + * @return the createdById + */ + public String getCreatedById() { + return createdById; + } + + /** + * Gets the lastModifiedAt. + * + * The UTC timestamp when the role template was last modified. + * + * @return the lastModifiedAt + */ + public Date getLastModifiedAt() { + return lastModifiedAt; + } + + /** + * Gets the lastModifiedById. + * + * The IAM ID of the entity that last modified the role template. + * + * @return the lastModifiedById + */ + public String getLastModifiedById() { + return lastModifiedById; + } + + /** + * Gets the version. + * + * The version number of the template used to identify different versions of same template. + * + * @return the version + */ + public String getVersion() { + return version; + } + + /** + * Gets the state. + * + * State of role template. + * + * @return the state + */ + public String getState() { + return state; + } +} + diff --git a/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/RoleTemplateCollection.java b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/RoleTemplateCollection.java new file mode 100644 index 00000000000..22a739b4a58 --- /dev/null +++ b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/RoleTemplateCollection.java @@ -0,0 +1,90 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.iam_policy_management.v1.model; + +import java.util.List; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * A collection of role templates. + */ +public class RoleTemplateCollection extends GenericModel { + + protected Long limit; + protected First first; + protected Next next; + protected Previous previous; + @SerializedName("role_templates") + protected List roleTemplates; + + protected RoleTemplateCollection() { } + + /** + * Gets the limit. + * + * The number of documents to include per each page of the collection. + * + * @return the limit + */ + public Long getLimit() { + return limit; + } + + /** + * Gets the first. + * + * Details with linking href to first page of requested collection. + * + * @return the first + */ + public First getFirst() { + return first; + } + + /** + * Gets the next. + * + * Details with href linking to the following page of requested collection. + * + * @return the next + */ + public Next getNext() { + return next; + } + + /** + * Gets the previous. + * + * Details with linking href to previous page of requested collection. + * + * @return the previous + */ + public Previous getPrevious() { + return previous; + } + + /** + * Gets the roleTemplates. + * + * List of role templates. + * + * @return the roleTemplates + */ + public List getRoleTemplates() { + return roleTemplates; + } +} + diff --git a/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/RoleTemplateVersionsCollection.java b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/RoleTemplateVersionsCollection.java new file mode 100644 index 00000000000..a983208afe3 --- /dev/null +++ b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/RoleTemplateVersionsCollection.java @@ -0,0 +1,88 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.iam_policy_management.v1.model; + +import java.util.List; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * A collection of versions for a specific role template. + */ +public class RoleTemplateVersionsCollection extends GenericModel { + + protected Long limit; + protected First first; + protected Next next; + protected Previous previous; + protected List versions; + + protected RoleTemplateVersionsCollection() { } + + /** + * Gets the limit. + * + * The number of documents to include per each page of the collection. + * + * @return the limit + */ + public Long getLimit() { + return limit; + } + + /** + * Gets the first. + * + * Details with linking href to first page of requested collection. + * + * @return the first + */ + public First getFirst() { + return first; + } + + /** + * Gets the next. + * + * Details with href linking to the following page of requested collection. + * + * @return the next + */ + public Next getNext() { + return next; + } + + /** + * Gets the previous. + * + * Details with linking href to previous page of requested collection. + * + * @return the previous + */ + public Previous getPrevious() { + return previous; + } + + /** + * Gets the versions. + * + * List of role templates versions. + * + * @return the versions + */ + public List getVersions() { + return versions; + } +} + diff --git a/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/RoleTemplateVersionsPager.java b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/RoleTemplateVersionsPager.java new file mode 100644 index 00000000000..7af200cd72f --- /dev/null +++ b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/RoleTemplateVersionsPager.java @@ -0,0 +1,108 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.iam_policy_management.v1.model; + +import com.ibm.cloud.platform_services.iam_policy_management.v1.IamPolicyManagement; +import java.util.ArrayList; +import java.util.List; +import java.util.NoSuchElementException; + +/** + * RoleTemplateVersionsPager can be used to simplify the use of the "listRoleTemplateVersions" method. + */ +public class RoleTemplateVersionsPager { + private static class PageContext { + private String next; + public String getNext() { + return next; + } + public void setNext(String next) { + this.next = next; + } + } + + protected boolean hasNext; + protected ListRoleTemplateVersionsOptions options; + protected IamPolicyManagement client; + protected PageContext pageContext; + + // Hide the default ctor. + protected RoleTemplateVersionsPager() { } + + /** + * Constructs a new RoleTemplateVersionsPager instance with the specified client and options model instance. + * @param client the IamPolicyManagement instance to be used to invoke the "listRoleTemplateVersions" method + * @param options the ListRoleTemplateVersionsOptions instance to be used to invoke the "listRoleTemplateVersions" method + */ + public RoleTemplateVersionsPager(IamPolicyManagement client, ListRoleTemplateVersionsOptions options) { + if (options.start() != null) { + throw new IllegalArgumentException("The options 'start' field should not be set"); + } + + this.hasNext = true; + this.client = client; + this.options = options.newBuilder().build(); + this.pageContext = new PageContext(); + } + + /** + * Returns true if there are more results to be retrieved. + * @return boolean + */ + public boolean hasNext() { + return hasNext; + } + + /** + * Returns the next page of results. + * @return a List<RoleTemplate> that contains the next page of results + */ + public List getNext() { + if (!hasNext()) { + throw new NoSuchElementException("No more results available"); + } + + ListRoleTemplateVersionsOptions.Builder builder = this.options.newBuilder(); + if (this.pageContext.getNext() != null) { + builder.start(this.pageContext.getNext()); + } + this.options = builder.build(); + + RoleTemplateVersionsCollection result = client.listRoleTemplateVersions(options).execute().getResult(); + + String next = null; + if (result.getNext() != null) { + next = result.getNext().getStart(); + } + this.pageContext.setNext(next); + if (next == null) { + this.hasNext = false; + } + + return result.getVersions(); + } + + /** + * Returns all results by invoking getNext() repeatedly until all pages of results have been retrieved. + * @return a List<RoleTemplate> containing all results returned by the "listRoleTemplateVersions" method + */ + public List getAll() { + List results = new ArrayList<>(); + while (hasNext()) { + List nextPage = getNext(); + results.addAll(nextPage); + } + return results; + } +} diff --git a/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/RoleTemplatesPager.java b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/RoleTemplatesPager.java new file mode 100644 index 00000000000..3654e0757ba --- /dev/null +++ b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/RoleTemplatesPager.java @@ -0,0 +1,108 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.iam_policy_management.v1.model; + +import com.ibm.cloud.platform_services.iam_policy_management.v1.IamPolicyManagement; +import java.util.ArrayList; +import java.util.List; +import java.util.NoSuchElementException; + +/** + * RoleTemplatesPager can be used to simplify the use of the "listRoleTemplates" method. + */ +public class RoleTemplatesPager { + private static class PageContext { + private String next; + public String getNext() { + return next; + } + public void setNext(String next) { + this.next = next; + } + } + + protected boolean hasNext; + protected ListRoleTemplatesOptions options; + protected IamPolicyManagement client; + protected PageContext pageContext; + + // Hide the default ctor. + protected RoleTemplatesPager() { } + + /** + * Constructs a new RoleTemplatesPager instance with the specified client and options model instance. + * @param client the IamPolicyManagement instance to be used to invoke the "listRoleTemplates" method + * @param options the ListRoleTemplatesOptions instance to be used to invoke the "listRoleTemplates" method + */ + public RoleTemplatesPager(IamPolicyManagement client, ListRoleTemplatesOptions options) { + if (options.start() != null) { + throw new IllegalArgumentException("The options 'start' field should not be set"); + } + + this.hasNext = true; + this.client = client; + this.options = options.newBuilder().build(); + this.pageContext = new PageContext(); + } + + /** + * Returns true if there are more results to be retrieved. + * @return boolean + */ + public boolean hasNext() { + return hasNext; + } + + /** + * Returns the next page of results. + * @return a List<RoleTemplate> that contains the next page of results + */ + public List getNext() { + if (!hasNext()) { + throw new NoSuchElementException("No more results available"); + } + + ListRoleTemplatesOptions.Builder builder = this.options.newBuilder(); + if (this.pageContext.getNext() != null) { + builder.start(this.pageContext.getNext()); + } + this.options = builder.build(); + + RoleTemplateCollection result = client.listRoleTemplates(options).execute().getResult(); + + String next = null; + if (result.getNext() != null) { + next = result.getNext().getStart(); + } + this.pageContext.setNext(next); + if (next == null) { + this.hasNext = false; + } + + return result.getRoleTemplates(); + } + + /** + * Returns all results by invoking getNext() repeatedly until all pages of results have been retrieved. + * @return a List<RoleTemplate> containing all results returned by the "listRoleTemplates" method + */ + public List getAll() { + List results = new ArrayList<>(); + while (hasNext()) { + List nextPage = getNext(); + results.addAll(nextPage); + } + return results; + } +} diff --git a/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/TemplateRole.java b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/TemplateRole.java new file mode 100644 index 00000000000..c6c41a49874 --- /dev/null +++ b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/TemplateRole.java @@ -0,0 +1,243 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.iam_policy_management.v1.model; + +import java.util.ArrayList; +import java.util.List; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * The role properties that are created in an action resource when the template is assigned. + */ +public class TemplateRole extends GenericModel { + + protected String name; + @SerializedName("display_name") + protected String displayName; + @SerializedName("service_name") + protected String serviceName; + protected String description; + protected List actions; + + /** + * Builder. + */ + public static class Builder { + private String name; + private String displayName; + private String serviceName; + private String description; + private List actions; + + /** + * Instantiates a new Builder from an existing TemplateRole instance. + * + * @param templateRole the instance to initialize the Builder with + */ + private Builder(TemplateRole templateRole) { + this.name = templateRole.name; + this.displayName = templateRole.displayName; + this.serviceName = templateRole.serviceName; + this.description = templateRole.description; + this.actions = templateRole.actions; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Instantiates a new builder with required properties. + * + * @param name the name + * @param displayName the displayName + * @param serviceName the serviceName + * @param actions the actions + */ + public Builder(String name, String displayName, String serviceName, List actions) { + this.name = name; + this.displayName = displayName; + this.serviceName = serviceName; + this.actions = actions; + } + + /** + * Builds a TemplateRole. + * + * @return the new TemplateRole instance + */ + public TemplateRole build() { + return new TemplateRole(this); + } + + /** + * Adds a new element to actions. + * + * @param actions the new element to be added + * @return the TemplateRole builder + */ + public Builder addActions(String actions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(actions, + "actions cannot be null"); + if (this.actions == null) { + this.actions = new ArrayList(); + } + this.actions.add(actions); + return this; + } + + /** + * Set the name. + * + * @param name the name + * @return the TemplateRole builder + */ + public Builder name(String name) { + this.name = name; + return this; + } + + /** + * Set the displayName. + * + * @param displayName the displayName + * @return the TemplateRole builder + */ + public Builder displayName(String displayName) { + this.displayName = displayName; + return this; + } + + /** + * Set the serviceName. + * + * @param serviceName the serviceName + * @return the TemplateRole builder + */ + public Builder serviceName(String serviceName) { + this.serviceName = serviceName; + return this; + } + + /** + * Set the description. + * + * @param description the description + * @return the TemplateRole builder + */ + public Builder description(String description) { + this.description = description; + return this; + } + + /** + * Set the actions. + * Existing actions will be replaced. + * + * @param actions the actions + * @return the TemplateRole builder + */ + public Builder actions(List actions) { + this.actions = actions; + return this; + } + } + + protected TemplateRole() { } + + protected TemplateRole(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.name, + "name cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.displayName, + "displayName cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.serviceName, + "serviceName cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.actions, + "actions cannot be null"); + name = builder.name; + displayName = builder.displayName; + serviceName = builder.serviceName; + description = builder.description; + actions = builder.actions; + } + + /** + * New builder. + * + * @return a TemplateRole builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the name. + * + * The name of the role that is used in the CRN. This must be alphanumeric and capitalized. + * + * @return the name + */ + public String name() { + return name; + } + + /** + * Gets the displayName. + * + * The display the name of the role that is shown in the console. + * + * @return the displayName + */ + public String displayName() { + return displayName; + } + + /** + * Gets the serviceName. + * + * The service name that the role refers. + * + * @return the serviceName + */ + public String serviceName() { + return serviceName; + } + + /** + * Gets the description. + * + * Description of the role. + * + * @return the description + */ + public String description() { + return description; + } + + /** + * Gets the actions. + * + * The actions of the role. + * + * @return the actions + */ + public List actions() { + return actions; + } +} + diff --git a/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/UpdateRoleAssignmentOptions.java b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/UpdateRoleAssignmentOptions.java new file mode 100644 index 00000000000..f10cba5fe93 --- /dev/null +++ b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/UpdateRoleAssignmentOptions.java @@ -0,0 +1,166 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.iam_policy_management.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * The updateRoleAssignment options. + */ +public class UpdateRoleAssignmentOptions extends GenericModel { + + protected String assignmentId; + protected String ifMatch; + protected String templateVersion; + + /** + * Builder. + */ + public static class Builder { + private String assignmentId; + private String ifMatch; + private String templateVersion; + + /** + * Instantiates a new Builder from an existing UpdateRoleAssignmentOptions instance. + * + * @param updateRoleAssignmentOptions the instance to initialize the Builder with + */ + private Builder(UpdateRoleAssignmentOptions updateRoleAssignmentOptions) { + this.assignmentId = updateRoleAssignmentOptions.assignmentId; + this.ifMatch = updateRoleAssignmentOptions.ifMatch; + this.templateVersion = updateRoleAssignmentOptions.templateVersion; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Instantiates a new builder with required properties. + * + * @param assignmentId the assignmentId + * @param ifMatch the ifMatch + * @param templateVersion the templateVersion + */ + public Builder(String assignmentId, String ifMatch, String templateVersion) { + this.assignmentId = assignmentId; + this.ifMatch = ifMatch; + this.templateVersion = templateVersion; + } + + /** + * Builds a UpdateRoleAssignmentOptions. + * + * @return the new UpdateRoleAssignmentOptions instance + */ + public UpdateRoleAssignmentOptions build() { + return new UpdateRoleAssignmentOptions(this); + } + + /** + * Set the assignmentId. + * + * @param assignmentId the assignmentId + * @return the UpdateRoleAssignmentOptions builder + */ + public Builder assignmentId(String assignmentId) { + this.assignmentId = assignmentId; + return this; + } + + /** + * Set the ifMatch. + * + * @param ifMatch the ifMatch + * @return the UpdateRoleAssignmentOptions builder + */ + public Builder ifMatch(String ifMatch) { + this.ifMatch = ifMatch; + return this; + } + + /** + * Set the templateVersion. + * + * @param templateVersion the templateVersion + * @return the UpdateRoleAssignmentOptions builder + */ + public Builder templateVersion(String templateVersion) { + this.templateVersion = templateVersion; + return this; + } + } + + protected UpdateRoleAssignmentOptions() { } + + protected UpdateRoleAssignmentOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.assignmentId, + "assignmentId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.ifMatch, + "ifMatch cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.templateVersion, + "templateVersion cannot be null"); + assignmentId = builder.assignmentId; + ifMatch = builder.ifMatch; + templateVersion = builder.templateVersion; + } + + /** + * New builder. + * + * @return a UpdateRoleAssignmentOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the assignmentId. + * + * Role template assignment ID. + * + * @return the assignmentId + */ + public String assignmentId() { + return assignmentId; + } + + /** + * Gets the ifMatch. + * + * The revision number for updating a role assignment and must match the Etag value of the existing role assignment. + * The Etag can be retrieved using the GET /v1/role_assignments/{assignment_id} API and looking at the Etag response + * header. + * + * @return the ifMatch + */ + public String ifMatch() { + return ifMatch; + } + + /** + * Gets the templateVersion. + * + * The version number of the template used to identify different versions of same template. + * + * @return the templateVersion + */ + public String templateVersion() { + return templateVersion; + } +} + diff --git a/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/IamPolicyManagementIT.java b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/IamPolicyManagementIT.java index be046902a17..6553893d23d 100644 --- a/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/IamPolicyManagementIT.java +++ b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/IamPolicyManagementIT.java @@ -98,6 +98,11 @@ public class IamPolicyManagementIT extends SdkIntegrationTestBase { String testActionControlTemplateETag = null; String testActionControlAssignmentId = null; String testActionControlAssignmentETag = null; + String testRoleTemplateId = null; + String testRoleTemplateVersion = null; + String testRoleTemplateEtag = null; + String testRoleTemplateAssignmentId = null; + String testRoleTemplateAssignmentETag = null; @Override public String getConfigFilename() { @@ -1293,7 +1298,7 @@ public void testGetPolicyAssignment() throws Exception { assertNotNull(result); assertEquals(result.getId(), testAssignmentId); } - + @Test(dependsOnMethods = { "testGetPolicyAssignment" }) public void testGetTemplateMetaDataV2AccessPolicy() { assertNotNull(testAssignmentPolicyId); @@ -1311,8 +1316,8 @@ public void testGetTemplateMetaDataV2AccessPolicy() { assertEquals(result.getId(), testAssignmentPolicyId); assertNotNull(result.getTemplate()); } - - @Test(dependsOnMethods = {"testGetTemplateMetaDataV2AccessPolicy"}) + + @Test(dependsOnMethods = {"testGetPolicyAssignment"}) public void testDeletePolicyAssignment() { DeletePolicyAssignmentOptions deletePolicyAssignmentOptions = new DeletePolicyAssignmentOptions.Builder() .assignmentId(testAssignmentId) @@ -1722,6 +1727,309 @@ public void testDeleteActionControlTemplate() { assertEquals(response.getStatusCode(), 204); } + /* Role Template Integration Tests - Start */ + @Test + public void testCreateRoleTemplate() throws Exception { + TemplateRole templateRoleModel = new TemplateRole.Builder() + .name(testCustomRoleName) + .displayName(testCustomRoleDisplayName) + .serviceName(TEST_SERVICE_NAME) + .description(testCustomRoleDescription) + .actions(testCustomRoleActions) + .build(); + + CreateRoleTemplateOptions createRoleTemplateOptions = new CreateRoleTemplateOptions.Builder() + .name("SDKTestRoleTemplate") + .accountId(testAccountId) + .description("SDKTestRoleTemplate Description") + .committed(true) + .role(templateRoleModel) + .acceptLanguage("default") + .build(); + + // Invoke operation + Response response = service.createRoleTemplate(createRoleTemplateOptions).execute(); + // Validate response + assertNotNull(response); + assertEquals(response.getStatusCode(), 201); + + RoleTemplate roleTemplateResult = response.getResult(); + testRoleTemplateId = roleTemplateResult.getId(); + assertNotNull(roleTemplateResult); + } + + @Test(dependsOnMethods = { "testCreateRoleTemplate" }) + public void testGetRoleTemplate() throws Exception { + GetRoleTemplateOptions getRoleTemplateOptions = new GetRoleTemplateOptions.Builder() + .roleTemplateId(testRoleTemplateId) + .state("active") + .build(); + + // Invoke operation + Response response = service.getRoleTemplate(getRoleTemplateOptions).execute(); + // Validate response + assertNotNull(response); + assertEquals(response.getStatusCode(), 200); + + RoleTemplate roleTemplateResult = response.getResult(); + testActionControlBaseTemplateVersion = roleTemplateResult.getVersion(); + assertNotNull(roleTemplateResult); + List values = response.getHeaders().values(HEADER_ETAG); + assertNotNull(values); + testRoleTemplateEtag = values.get(0); + } + + @Test(dependsOnMethods = { "testGetRoleTemplate" }) + public void testListRoleTemplates() throws Exception { + ListRoleTemplatesOptions listRoleTemplatesOptions = new ListRoleTemplatesOptions.Builder() + .accountId(testAccountId) + .state("active") + .build(); + + // Invoke operation + Response response = service.listRoleTemplates(listRoleTemplatesOptions).execute(); + // Validate response + assertNotNull(response); + assertEquals(response.getStatusCode(), 200); + + RoleTemplateCollection roleTemplateCollectionResult = response.getResult(); + assertNotNull(roleTemplateCollectionResult); + } + + @Test(dependsOnMethods = { "testListRoleTemplates" }) + public void testCreateRoleTemplateVersion() throws Exception { + TemplateRole templateRoleModel = new TemplateRole.Builder() + .name("SDKTestRoleVersion") + .displayName("SDKTestRoleVersionDisp") + .serviceName("am-test-service") + .description("am-test-service versioon customRole") + .actions(java.util.Arrays.asList("am-test-service.test.delete")) + .build(); + + CreateRoleTemplateVersionOptions createRoleTemplateVersionOptions = new CreateRoleTemplateVersionOptions.Builder() + .roleTemplateId(testRoleTemplateId) + .role(templateRoleModel) + .name("SDKroleTemplateVersion") + .description("SDKroleTemplateVersionDesc") + .build(); + + // Invoke operation + Response response = service.createRoleTemplateVersion(createRoleTemplateVersionOptions).execute(); + // Validate response + assertNotNull(response); + assertEquals(response.getStatusCode(), 201); + + List values = response.getHeaders().values(HEADER_ETAG); + assertNotNull(values); + testRoleTemplateEtag = values.get(0); + + RoleTemplate roleTemplateResult = response.getResult(); + testRoleTemplateVersion = roleTemplateResult.getVersion(); + assertNotNull(roleTemplateResult); + } + + @Test(dependsOnMethods = { "testCreateRoleTemplateVersion" }) + public void testListRoleTemplateVersions() throws Exception { + ListRoleTemplateVersionsOptions listRoleTemplateVersionsOptions = new ListRoleTemplateVersionsOptions.Builder() + .roleTemplateId(testRoleTemplateId) + .state("active") + .limit(Long.valueOf("10")) + .build(); + + // Invoke operation + Response response = service.listRoleTemplateVersions(listRoleTemplateVersionsOptions).execute(); + // Validate response + assertNotNull(response); + assertEquals(response.getStatusCode(), 200); + + RoleTemplateVersionsCollection roleTemplateVersionsCollectionResult = response.getResult(); + assertNotNull(roleTemplateVersionsCollectionResult); + } + + @Test(dependsOnMethods = { "testListRoleTemplateVersions" }) + public void testReplaceRoleTemplate() throws Exception { + TemplateRole templateRoleModel = new TemplateRole.Builder() + .actions(java.util.Arrays.asList("testString")) + .name("SDKTestRoleVersionRep") + .displayName("SDKTestRoleVersionDispRep") + .serviceName("am-test-service") + .description("am-test-service versioon customRole Rep") + .actions(java.util.Arrays.asList("am-test-service.test.create")) + .build(); + + ReplaceRoleTemplateOptions replaceRoleTemplateOptions = new ReplaceRoleTemplateOptions.Builder() + .roleTemplateId(testRoleTemplateId) + .version(testRoleTemplateVersion) + .ifMatch(testRoleTemplateEtag) + .role(templateRoleModel) + .name("TestSDKRoleTemplateRep") + .description("TestSDKRoleTemplateRepDesc") + .build(); + + // Invoke operation + Response response = service.replaceRoleTemplate(replaceRoleTemplateOptions).execute(); + // Validate response + assertNotNull(response); + assertEquals(response.getStatusCode(), 200); + + RoleTemplate roleTemplateResult = response.getResult(); + assertNotNull(roleTemplateResult); + } + + @Test(dependsOnMethods = { "testReplaceRoleTemplate" }) + public void testGetRoleTemplateVersion() throws Exception { + GetRoleTemplateVersionOptions getRoleTemplateVersionOptions = new GetRoleTemplateVersionOptions.Builder() + .roleTemplateId(testRoleTemplateId) + .version(testRoleTemplateVersion) + .build(); + + // Invoke operation + Response response = service.getRoleTemplateVersion(getRoleTemplateVersionOptions).execute(); + // Validate response + assertNotNull(response); + assertEquals(response.getStatusCode(), 200); + + RoleTemplate roleTemplateResult = response.getResult(); + assertNotNull(roleTemplateResult); + } + + @Test(dependsOnMethods = { "testGetRoleTemplateVersion" }) + public void testCommitRoleTemplate() throws Exception { + CommitRoleTemplateOptions commitRoleTemplateOptions = new CommitRoleTemplateOptions.Builder() + .roleTemplateId(testRoleTemplateId) + .version(testRoleTemplateVersion) + .build(); + + // Invoke operation + Response response = service.commitRoleTemplate(commitRoleTemplateOptions).execute(); + // Validate response + assertNotNull(response); + assertEquals(response.getStatusCode(), 204); + } + + @Test(dependsOnMethods = { "testCommitRoleTemplate" }) + public void testCreateRoleTemplateAssignment() throws Exception { + AssignmentTargetDetails assignmentTargetDetailsModel = new AssignmentTargetDetails.Builder() + .type("Account") + .id(testTargetAccountId) + .build(); + + RoleAssignmentTemplate roleAssignmentTemplateModel = new RoleAssignmentTemplate.Builder() + .id(testRoleTemplateId) + .version(testRoleTemplateVersion) + .build(); + + CreateRoleTemplateAssignmentOptions createRoleTemplateAssignmentOptions = new CreateRoleTemplateAssignmentOptions.Builder() + .target(assignmentTargetDetailsModel) + .templates(java.util.Arrays.asList(roleAssignmentTemplateModel)) + .acceptLanguage("default") + .build(); + + // Invoke operation + Response response = service.createRoleTemplateAssignment(createRoleTemplateAssignmentOptions).execute(); + // Validate response + assertNotNull(response); + assertEquals(response.getStatusCode(), 201); + + RoleAssignmentCollection roleAssignmentCollectionResult = response.getResult(); + testRoleTemplateAssignmentId = roleAssignmentCollectionResult.getAssignments().get(0).getId(); + List values = response.getHeaders().values(HEADER_ETAG); + assertNotNull(values); + testRoleTemplateAssignmentETag = values.get(0); + assertNotNull(roleAssignmentCollectionResult); + } + + @Test(dependsOnMethods = { "testCreateRoleTemplateAssignment" }) + public void testGetRoleAssignment() throws Exception { + GetRoleAssignmentOptions getRoleAssignmentOptions = new GetRoleAssignmentOptions.Builder() + .assignmentId(testRoleTemplateAssignmentId) + .build(); + + // Invoke operation + Response response = service.getRoleAssignment(getRoleAssignmentOptions).execute(); + // Validate response + assertNotNull(response); + assertEquals(response.getStatusCode(), 200); + + RoleAssignment roleAssignmentResult = response.getResult(); + assertNotNull(roleAssignmentResult); + } + + @Test(dependsOnMethods = { "testGetRoleAssignment" }) + public void testListRoleAssignments() throws Exception { + ListRoleAssignmentsOptions listRoleAssignmentsOptions = new ListRoleAssignmentsOptions.Builder() + .accountId(testAccountId) + .build(); + + // Invoke operation + Response response = service.listRoleAssignments(listRoleAssignmentsOptions).execute(); + // Validate response + assertNotNull(response); + assertEquals(response.getStatusCode(), 200); + + RoleAssignmentCollection roleAssignmentCollectionResult = response.getResult(); + assertNotNull(roleAssignmentCollectionResult); + } + + @Test(dependsOnMethods = { "testListRoleAssignments" }) + public void testUpdateRoleAssignment() throws Exception { + UpdateRoleAssignmentOptions updateRoleAssignmentOptions = new UpdateRoleAssignmentOptions.Builder() + .assignmentId(testRoleTemplateAssignmentId) + .ifMatch(testRoleTemplateAssignmentETag) + .templateVersion(testRoleTemplateVersion) + .build(); + + // Invoke operation + Response response = service.updateRoleAssignment(updateRoleAssignmentOptions).execute(); + // Validate response + assertNotNull(response); + assertEquals(response.getStatusCode(), 200); + + RoleAssignment roleAssignmentResult = response.getResult(); + assertNotNull(roleAssignmentResult); + } + + @Test(dependsOnMethods = { "testUpdateRoleAssignment" }) + public void testDeleteRoleAssignment() throws Exception { + DeleteRoleAssignmentOptions deleteRoleAssignmentOptions = new DeleteRoleAssignmentOptions.Builder() + .assignmentId(testRoleTemplateAssignmentId) + .build(); + + // Invoke operation + Response response = service.deleteRoleAssignment(deleteRoleAssignmentOptions).execute(); + // Validate response + assertNotNull(response); + assertEquals(response.getStatusCode(), 204); + } + + @Test(dependsOnMethods = { "testDeleteRoleAssignment" }) + public void testDeleteRoleTemplateVersion() throws Exception { + DeleteRoleTemplateVersionOptions deleteRoleTemplateVersionOptions = new DeleteRoleTemplateVersionOptions.Builder() + .roleTemplateId(testRoleTemplateId) + .version(testRoleTemplateVersion) + .build(); + + // Invoke operation + Response response = service.deleteRoleTemplateVersion(deleteRoleTemplateVersionOptions).execute(); + // Validate response + assertNotNull(response); + assertEquals(response.getStatusCode(), 204); + } + + @Test(dependsOnMethods = { "testDeleteRoleTemplateVersion" }) + public void testDeleteRoleTemplate() throws Exception { + DeleteRoleTemplateOptions deleteRoleTemplateOptions = new DeleteRoleTemplateOptions.Builder() + .roleTemplateId(testRoleTemplateId) + .build(); + + // Invoke operation + Response response = service.deleteRoleTemplate(deleteRoleTemplateOptions).execute(); + // Validate response + assertNotNull(response); + assertEquals(response.getStatusCode(), 204); + } + // Role Template Integration Tests - End + @AfterClass public void tearDown() { // Delete all the access policies, roles, templates, and template assingments created during the test. diff --git a/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/IamPolicyManagementTest.java b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/IamPolicyManagementTest.java index 452e2e24cbb..aff90b34a30 100644 --- a/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/IamPolicyManagementTest.java +++ b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/IamPolicyManagementTest.java @@ -28,10 +28,12 @@ import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ActionControlTemplateVersionsPager; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ActionControlTemplatesPager; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.AssignmentResourceCreated; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.AssignmentResourceError; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.AssignmentTargetDetails; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.AssignmentTemplateDetails; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.CommitActionControlTemplateOptions; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.CommitPolicyTemplateOptions; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.CommitRoleTemplateOptions; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ConflictsWith; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.Control; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ControlResponse; @@ -45,6 +47,9 @@ import com.ibm.cloud.platform_services.iam_policy_management.v1.model.CreatePolicyTemplateOptions; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.CreatePolicyTemplateVersionOptions; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.CreateRoleOptions; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.CreateRoleTemplateAssignmentOptions; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.CreateRoleTemplateOptions; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.CreateRoleTemplateVersionOptions; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.CreateV2PolicyOptions; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.CustomRole; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.DeleteActionControlAssignmentOptions; @@ -54,12 +59,14 @@ import com.ibm.cloud.platform_services.iam_policy_management.v1.model.DeletePolicyOptions; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.DeletePolicyTemplateOptions; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.DeletePolicyTemplateVersionOptions; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.DeleteRoleAssignmentOptions; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.DeleteRoleOptions; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.DeleteRoleTemplateOptions; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.DeleteRoleTemplateVersionOptions; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.DeleteV2PolicyOptions; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.EnrichedRoles; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ErrorDetails; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ErrorObject; -import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ErrorResponse; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ExternalAccountIdentityInteraction; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ExternalAccountIdentityInteractionPatch; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.First; @@ -70,7 +77,10 @@ import com.ibm.cloud.platform_services.iam_policy_management.v1.model.GetPolicyOptions; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.GetPolicyTemplateOptions; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.GetPolicyTemplateVersionOptions; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.GetRoleAssignmentOptions; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.GetRoleOptions; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.GetRoleTemplateOptions; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.GetRoleTemplateVersionOptions; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.GetSettingsOptions; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.GetV2PolicyOptions; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.Grant; @@ -86,6 +96,9 @@ import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ListPolicyAssignmentsOptions; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ListPolicyTemplateVersionsOptions; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ListPolicyTemplatesOptions; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ListRoleAssignmentsOptions; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ListRoleTemplateVersionsOptions; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ListRoleTemplatesOptions; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ListRolesOptions; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ListV2PoliciesOptions; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.NestedCondition; @@ -121,12 +134,25 @@ import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ReplacePolicyOptions; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ReplacePolicyTemplateOptions; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ReplaceRoleOptions; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ReplaceRoleTemplateOptions; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ReplaceV2PolicyOptions; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ResourceAttribute; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ResourceTag; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.Role; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.RoleAction; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.RoleAssignment; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.RoleAssignmentCollection; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.RoleAssignmentResource; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.RoleAssignmentResourceCreated; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.RoleAssignmentResourceRole; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.RoleAssignmentTemplate; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.RoleAssignmentsPager; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.RoleCollection; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.RoleTemplate; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.RoleTemplateCollection; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.RoleTemplateVersionsCollection; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.RoleTemplateVersionsPager; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.RoleTemplatesPager; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.Roles; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.RuleAttribute; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.SubjectAttribute; @@ -134,9 +160,11 @@ import com.ibm.cloud.platform_services.iam_policy_management.v1.model.TemplateCountData; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.TemplateMetadata; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.TemplatePolicy; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.TemplateRole; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.UpdateActionControlAssignmentOptions; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.UpdatePolicyAssignmentOptions; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.UpdatePolicyStateOptions; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.UpdateRoleAssignmentOptions; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.UpdateSettingsOptions; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.V2PoliciesPager; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.V2Policy; @@ -2343,7 +2371,7 @@ public void testCommitPolicyTemplateNoOptions() throws Throwable { @Test public void testListPolicyAssignmentsWOptions() throws Throwable { // Register a mock response - String mockResponseBody = "{\"limit\": 1, \"first\": {\"href\": \"href\"}, \"next\": {\"href\": \"href\", \"start\": \"start\"}, \"previous\": {\"href\": \"href\", \"start\": \"start\"}, \"assignments\": [{\"target\": {\"type\": \"Account\", \"id\": \"id\"}, \"id\": \"id\", \"account_id\": \"accountId\", \"href\": \"href\", \"created_at\": \"2019-01-01T12:00:00.000Z\", \"created_by_id\": \"createdById\", \"last_modified_at\": \"2019-01-01T12:00:00.000Z\", \"last_modified_by_id\": \"lastModifiedById\", \"resources\": [{\"target\": {\"type\": \"Account\", \"id\": \"id\"}, \"policy\": {\"resource_created\": {\"id\": \"id\"}, \"status\": \"status\", \"error_message\": {\"trace\": \"trace\", \"errors\": [{\"code\": \"insufficent_permissions\", \"message\": \"message\", \"details\": {\"conflicts_with\": {\"etag\": \"etag\", \"role\": \"role\", \"policy\": \"policy\"}}, \"more_info\": \"moreInfo\"}], \"status_code\": 0}}}], \"subject\": {\"id\": \"id\", \"type\": \"iam_id\"}, \"template\": {\"id\": \"id\", \"version\": \"version\"}, \"status\": \"in_progress\"}]}"; + String mockResponseBody = "{\"limit\": 1, \"first\": {\"href\": \"href\"}, \"next\": {\"href\": \"href\", \"start\": \"start\"}, \"previous\": {\"href\": \"href\", \"start\": \"start\"}, \"assignments\": [{\"target\": {\"type\": \"Account\", \"id\": \"id\"}, \"id\": \"id\", \"account_id\": \"accountId\", \"href\": \"href\", \"created_at\": \"2019-01-01T12:00:00.000Z\", \"created_by_id\": \"createdById\", \"last_modified_at\": \"2019-01-01T12:00:00.000Z\", \"last_modified_by_id\": \"lastModifiedById\", \"resources\": [{\"target\": {\"type\": \"Account\", \"id\": \"id\"}, \"policy\": {\"resource_created\": {\"id\": \"id\"}, \"status\": \"status\", \"error_message\": {\"name\": \"name\", \"errorCode\": \"errorCode\", \"message\": \"message\", \"code\": \"code\", \"errors\": [{\"code\": \"insufficent_permissions\", \"message\": \"message\", \"details\": {\"conflicts_with\": {\"etag\": \"etag\", \"role\": \"role\", \"policy\": \"policy\"}}, \"more_info\": \"moreInfo\"}]}}}], \"subject\": {\"id\": \"id\", \"type\": \"iam_id\"}, \"template\": {\"id\": \"id\", \"version\": \"version\"}, \"status\": \"in_progress\"}]}"; String listPolicyAssignmentsPath = "/v1/policy_assignments"; server.enqueue(new MockResponse() .setHeader("Content-type", "application/json") @@ -2406,8 +2434,8 @@ public void testListPolicyAssignmentsNoOptions() throws Throwable { @Test public void testListPolicyAssignmentsWithPagerGetNext() throws Throwable { // Set up the two-page mock response. - String mockResponsePage1 = "{\"next\":{\"start\":\"1\"},\"assignments\":[{\"target\":{\"type\":\"Account\",\"id\":\"id\"},\"id\":\"id\",\"account_id\":\"accountId\",\"href\":\"href\",\"created_at\":\"2019-01-01T12:00:00.000Z\",\"created_by_id\":\"createdById\",\"last_modified_at\":\"2019-01-01T12:00:00.000Z\",\"last_modified_by_id\":\"lastModifiedById\",\"resources\":[{\"target\":{\"type\":\"Account\",\"id\":\"id\"},\"policy\":{\"resource_created\":{\"id\":\"id\"},\"status\":\"status\",\"error_message\":{\"trace\":\"trace\",\"errors\":[{\"code\":\"insufficent_permissions\",\"message\":\"message\",\"details\":{\"conflicts_with\":{\"etag\":\"etag\",\"role\":\"role\",\"policy\":\"policy\"}},\"more_info\":\"moreInfo\"}],\"status_code\":0}}}],\"subject\":{\"id\":\"id\",\"type\":\"iam_id\"},\"template\":{\"id\":\"id\",\"version\":\"version\"},\"status\":\"in_progress\"}],\"total_count\":2,\"limit\":1}"; - String mockResponsePage2 = "{\"assignments\":[{\"target\":{\"type\":\"Account\",\"id\":\"id\"},\"id\":\"id\",\"account_id\":\"accountId\",\"href\":\"href\",\"created_at\":\"2019-01-01T12:00:00.000Z\",\"created_by_id\":\"createdById\",\"last_modified_at\":\"2019-01-01T12:00:00.000Z\",\"last_modified_by_id\":\"lastModifiedById\",\"resources\":[{\"target\":{\"type\":\"Account\",\"id\":\"id\"},\"policy\":{\"resource_created\":{\"id\":\"id\"},\"status\":\"status\",\"error_message\":{\"trace\":\"trace\",\"errors\":[{\"code\":\"insufficent_permissions\",\"message\":\"message\",\"details\":{\"conflicts_with\":{\"etag\":\"etag\",\"role\":\"role\",\"policy\":\"policy\"}},\"more_info\":\"moreInfo\"}],\"status_code\":0}}}],\"subject\":{\"id\":\"id\",\"type\":\"iam_id\"},\"template\":{\"id\":\"id\",\"version\":\"version\"},\"status\":\"in_progress\"}],\"total_count\":2,\"limit\":1}"; + String mockResponsePage1 = "{\"next\":{\"start\":\"1\"},\"assignments\":[{\"target\":{\"type\":\"Account\",\"id\":\"id\"},\"id\":\"id\",\"account_id\":\"accountId\",\"href\":\"href\",\"created_at\":\"2019-01-01T12:00:00.000Z\",\"created_by_id\":\"createdById\",\"last_modified_at\":\"2019-01-01T12:00:00.000Z\",\"last_modified_by_id\":\"lastModifiedById\",\"resources\":[{\"target\":{\"type\":\"Account\",\"id\":\"id\"},\"policy\":{\"resource_created\":{\"id\":\"id\"},\"status\":\"status\",\"error_message\":{\"name\":\"name\",\"errorCode\":\"errorCode\",\"message\":\"message\",\"code\":\"code\",\"errors\":[{\"code\":\"insufficent_permissions\",\"message\":\"message\",\"details\":{\"conflicts_with\":{\"etag\":\"etag\",\"role\":\"role\",\"policy\":\"policy\"}},\"more_info\":\"moreInfo\"}]}}}],\"subject\":{\"id\":\"id\",\"type\":\"iam_id\"},\"template\":{\"id\":\"id\",\"version\":\"version\"},\"status\":\"in_progress\"}],\"total_count\":2,\"limit\":1}"; + String mockResponsePage2 = "{\"assignments\":[{\"target\":{\"type\":\"Account\",\"id\":\"id\"},\"id\":\"id\",\"account_id\":\"accountId\",\"href\":\"href\",\"created_at\":\"2019-01-01T12:00:00.000Z\",\"created_by_id\":\"createdById\",\"last_modified_at\":\"2019-01-01T12:00:00.000Z\",\"last_modified_by_id\":\"lastModifiedById\",\"resources\":[{\"target\":{\"type\":\"Account\",\"id\":\"id\"},\"policy\":{\"resource_created\":{\"id\":\"id\"},\"status\":\"status\",\"error_message\":{\"name\":\"name\",\"errorCode\":\"errorCode\",\"message\":\"message\",\"code\":\"code\",\"errors\":[{\"code\":\"insufficent_permissions\",\"message\":\"message\",\"details\":{\"conflicts_with\":{\"etag\":\"etag\",\"role\":\"role\",\"policy\":\"policy\"}},\"more_info\":\"moreInfo\"}]}}}],\"subject\":{\"id\":\"id\",\"type\":\"iam_id\"},\"template\":{\"id\":\"id\",\"version\":\"version\"},\"status\":\"in_progress\"}],\"total_count\":2,\"limit\":1}"; server.enqueue(new MockResponse() .setHeader("Content-type", "application/json") .setResponseCode(200) @@ -2444,8 +2472,8 @@ public void testListPolicyAssignmentsWithPagerGetNext() throws Throwable { @Test public void testListPolicyAssignmentsWithPagerGetAll() throws Throwable { // Set up the two-page mock response. - String mockResponsePage1 = "{\"next\":{\"start\":\"1\"},\"assignments\":[{\"target\":{\"type\":\"Account\",\"id\":\"id\"},\"id\":\"id\",\"account_id\":\"accountId\",\"href\":\"href\",\"created_at\":\"2019-01-01T12:00:00.000Z\",\"created_by_id\":\"createdById\",\"last_modified_at\":\"2019-01-01T12:00:00.000Z\",\"last_modified_by_id\":\"lastModifiedById\",\"resources\":[{\"target\":{\"type\":\"Account\",\"id\":\"id\"},\"policy\":{\"resource_created\":{\"id\":\"id\"},\"status\":\"status\",\"error_message\":{\"trace\":\"trace\",\"errors\":[{\"code\":\"insufficent_permissions\",\"message\":\"message\",\"details\":{\"conflicts_with\":{\"etag\":\"etag\",\"role\":\"role\",\"policy\":\"policy\"}},\"more_info\":\"moreInfo\"}],\"status_code\":0}}}],\"subject\":{\"id\":\"id\",\"type\":\"iam_id\"},\"template\":{\"id\":\"id\",\"version\":\"version\"},\"status\":\"in_progress\"}],\"total_count\":2,\"limit\":1}"; - String mockResponsePage2 = "{\"assignments\":[{\"target\":{\"type\":\"Account\",\"id\":\"id\"},\"id\":\"id\",\"account_id\":\"accountId\",\"href\":\"href\",\"created_at\":\"2019-01-01T12:00:00.000Z\",\"created_by_id\":\"createdById\",\"last_modified_at\":\"2019-01-01T12:00:00.000Z\",\"last_modified_by_id\":\"lastModifiedById\",\"resources\":[{\"target\":{\"type\":\"Account\",\"id\":\"id\"},\"policy\":{\"resource_created\":{\"id\":\"id\"},\"status\":\"status\",\"error_message\":{\"trace\":\"trace\",\"errors\":[{\"code\":\"insufficent_permissions\",\"message\":\"message\",\"details\":{\"conflicts_with\":{\"etag\":\"etag\",\"role\":\"role\",\"policy\":\"policy\"}},\"more_info\":\"moreInfo\"}],\"status_code\":0}}}],\"subject\":{\"id\":\"id\",\"type\":\"iam_id\"},\"template\":{\"id\":\"id\",\"version\":\"version\"},\"status\":\"in_progress\"}],\"total_count\":2,\"limit\":1}"; + String mockResponsePage1 = "{\"next\":{\"start\":\"1\"},\"assignments\":[{\"target\":{\"type\":\"Account\",\"id\":\"id\"},\"id\":\"id\",\"account_id\":\"accountId\",\"href\":\"href\",\"created_at\":\"2019-01-01T12:00:00.000Z\",\"created_by_id\":\"createdById\",\"last_modified_at\":\"2019-01-01T12:00:00.000Z\",\"last_modified_by_id\":\"lastModifiedById\",\"resources\":[{\"target\":{\"type\":\"Account\",\"id\":\"id\"},\"policy\":{\"resource_created\":{\"id\":\"id\"},\"status\":\"status\",\"error_message\":{\"name\":\"name\",\"errorCode\":\"errorCode\",\"message\":\"message\",\"code\":\"code\",\"errors\":[{\"code\":\"insufficent_permissions\",\"message\":\"message\",\"details\":{\"conflicts_with\":{\"etag\":\"etag\",\"role\":\"role\",\"policy\":\"policy\"}},\"more_info\":\"moreInfo\"}]}}}],\"subject\":{\"id\":\"id\",\"type\":\"iam_id\"},\"template\":{\"id\":\"id\",\"version\":\"version\"},\"status\":\"in_progress\"}],\"total_count\":2,\"limit\":1}"; + String mockResponsePage2 = "{\"assignments\":[{\"target\":{\"type\":\"Account\",\"id\":\"id\"},\"id\":\"id\",\"account_id\":\"accountId\",\"href\":\"href\",\"created_at\":\"2019-01-01T12:00:00.000Z\",\"created_by_id\":\"createdById\",\"last_modified_at\":\"2019-01-01T12:00:00.000Z\",\"last_modified_by_id\":\"lastModifiedById\",\"resources\":[{\"target\":{\"type\":\"Account\",\"id\":\"id\"},\"policy\":{\"resource_created\":{\"id\":\"id\"},\"status\":\"status\",\"error_message\":{\"name\":\"name\",\"errorCode\":\"errorCode\",\"message\":\"message\",\"code\":\"code\",\"errors\":[{\"code\":\"insufficent_permissions\",\"message\":\"message\",\"details\":{\"conflicts_with\":{\"etag\":\"etag\",\"role\":\"role\",\"policy\":\"policy\"}},\"more_info\":\"moreInfo\"}]}}}],\"subject\":{\"id\":\"id\",\"type\":\"iam_id\"},\"template\":{\"id\":\"id\",\"version\":\"version\"},\"status\":\"in_progress\"}],\"total_count\":2,\"limit\":1}"; server.enqueue(new MockResponse() .setHeader("Content-type", "application/json") .setResponseCode(200) @@ -2478,7 +2506,7 @@ public void testListPolicyAssignmentsWithPagerGetAll() throws Throwable { @Test public void testCreatePolicyTemplateAssignmentWOptions() throws Throwable { // Register a mock response - String mockResponseBody = "{\"limit\": 1, \"first\": {\"href\": \"href\"}, \"next\": {\"href\": \"href\", \"start\": \"start\"}, \"previous\": {\"href\": \"href\", \"start\": \"start\"}, \"assignments\": [{\"target\": {\"type\": \"Account\", \"id\": \"id\"}, \"id\": \"id\", \"account_id\": \"accountId\", \"href\": \"href\", \"created_at\": \"2019-01-01T12:00:00.000Z\", \"created_by_id\": \"createdById\", \"last_modified_at\": \"2019-01-01T12:00:00.000Z\", \"last_modified_by_id\": \"lastModifiedById\", \"resources\": [{\"target\": {\"type\": \"Account\", \"id\": \"id\"}, \"policy\": {\"resource_created\": {\"id\": \"id\"}, \"status\": \"status\", \"error_message\": {\"trace\": \"trace\", \"errors\": [{\"code\": \"insufficent_permissions\", \"message\": \"message\", \"details\": {\"conflicts_with\": {\"etag\": \"etag\", \"role\": \"role\", \"policy\": \"policy\"}}, \"more_info\": \"moreInfo\"}], \"status_code\": 0}}}], \"subject\": {\"id\": \"id\", \"type\": \"iam_id\"}, \"template\": {\"id\": \"id\", \"version\": \"version\"}, \"status\": \"in_progress\"}]}"; + String mockResponseBody = "{\"limit\": 1, \"first\": {\"href\": \"href\"}, \"next\": {\"href\": \"href\", \"start\": \"start\"}, \"previous\": {\"href\": \"href\", \"start\": \"start\"}, \"assignments\": [{\"target\": {\"type\": \"Account\", \"id\": \"id\"}, \"id\": \"id\", \"account_id\": \"accountId\", \"href\": \"href\", \"created_at\": \"2019-01-01T12:00:00.000Z\", \"created_by_id\": \"createdById\", \"last_modified_at\": \"2019-01-01T12:00:00.000Z\", \"last_modified_by_id\": \"lastModifiedById\", \"resources\": [{\"target\": {\"type\": \"Account\", \"id\": \"id\"}, \"policy\": {\"resource_created\": {\"id\": \"id\"}, \"status\": \"status\", \"error_message\": {\"name\": \"name\", \"errorCode\": \"errorCode\", \"message\": \"message\", \"code\": \"code\", \"errors\": [{\"code\": \"insufficent_permissions\", \"message\": \"message\", \"details\": {\"conflicts_with\": {\"etag\": \"etag\", \"role\": \"role\", \"policy\": \"policy\"}}, \"more_info\": \"moreInfo\"}]}}}], \"subject\": {\"id\": \"id\", \"type\": \"iam_id\"}, \"template\": {\"id\": \"id\", \"version\": \"version\"}, \"status\": \"in_progress\"}]}"; String createPolicyTemplateAssignmentPath = "/v1/policy_assignments"; server.enqueue(new MockResponse() .setHeader("Content-type", "application/json") @@ -2545,7 +2573,7 @@ public void testCreatePolicyTemplateAssignmentNoOptions() throws Throwable { @Test public void testGetPolicyAssignmentWOptions() throws Throwable { // Register a mock response - String mockResponseBody = "{\"target\": {\"type\": \"Account\", \"id\": \"id\"}, \"id\": \"id\", \"account_id\": \"accountId\", \"href\": \"href\", \"created_at\": \"2019-01-01T12:00:00.000Z\", \"created_by_id\": \"createdById\", \"last_modified_at\": \"2019-01-01T12:00:00.000Z\", \"last_modified_by_id\": \"lastModifiedById\", \"resources\": [{\"target\": {\"type\": \"Account\", \"id\": \"id\"}, \"policy\": {\"resource_created\": {\"id\": \"id\"}, \"status\": \"status\", \"error_message\": {\"trace\": \"trace\", \"errors\": [{\"code\": \"insufficent_permissions\", \"message\": \"message\", \"details\": {\"conflicts_with\": {\"etag\": \"etag\", \"role\": \"role\", \"policy\": \"policy\"}}, \"more_info\": \"moreInfo\"}], \"status_code\": 0}}}], \"subject\": {\"id\": \"id\", \"type\": \"iam_id\"}, \"template\": {\"id\": \"id\", \"version\": \"version\"}, \"status\": \"in_progress\"}"; + String mockResponseBody = "{\"target\": {\"type\": \"Account\", \"id\": \"id\"}, \"id\": \"id\", \"account_id\": \"accountId\", \"href\": \"href\", \"created_at\": \"2019-01-01T12:00:00.000Z\", \"created_by_id\": \"createdById\", \"last_modified_at\": \"2019-01-01T12:00:00.000Z\", \"last_modified_by_id\": \"lastModifiedById\", \"resources\": [{\"target\": {\"type\": \"Account\", \"id\": \"id\"}, \"policy\": {\"resource_created\": {\"id\": \"id\"}, \"status\": \"status\", \"error_message\": {\"name\": \"name\", \"errorCode\": \"errorCode\", \"message\": \"message\", \"code\": \"code\", \"errors\": [{\"code\": \"insufficent_permissions\", \"message\": \"message\", \"details\": {\"conflicts_with\": {\"etag\": \"etag\", \"role\": \"role\", \"policy\": \"policy\"}}, \"more_info\": \"moreInfo\"}]}}}], \"subject\": {\"id\": \"id\", \"type\": \"iam_id\"}, \"template\": {\"id\": \"id\", \"version\": \"version\"}, \"status\": \"in_progress\"}"; String getPolicyAssignmentPath = "/v1/policy_assignments/testString"; server.enqueue(new MockResponse() .setHeader("Content-type", "application/json") @@ -2598,7 +2626,7 @@ public void testGetPolicyAssignmentNoOptions() throws Throwable { @Test public void testUpdatePolicyAssignmentWOptions() throws Throwable { // Register a mock response - String mockResponseBody = "{\"target\": {\"type\": \"Account\", \"id\": \"id\"}, \"id\": \"id\", \"account_id\": \"accountId\", \"href\": \"href\", \"created_at\": \"2019-01-01T12:00:00.000Z\", \"created_by_id\": \"createdById\", \"last_modified_at\": \"2019-01-01T12:00:00.000Z\", \"last_modified_by_id\": \"lastModifiedById\", \"resources\": [{\"target\": {\"type\": \"Account\", \"id\": \"id\"}, \"policy\": {\"resource_created\": {\"id\": \"id\"}, \"status\": \"status\", \"error_message\": {\"trace\": \"trace\", \"errors\": [{\"code\": \"insufficent_permissions\", \"message\": \"message\", \"details\": {\"conflicts_with\": {\"etag\": \"etag\", \"role\": \"role\", \"policy\": \"policy\"}}, \"more_info\": \"moreInfo\"}], \"status_code\": 0}}}], \"subject\": {\"id\": \"id\", \"type\": \"iam_id\"}, \"template\": {\"id\": \"id\", \"version\": \"version\"}, \"status\": \"in_progress\"}"; + String mockResponseBody = "{\"target\": {\"type\": \"Account\", \"id\": \"id\"}, \"id\": \"id\", \"account_id\": \"accountId\", \"href\": \"href\", \"created_at\": \"2019-01-01T12:00:00.000Z\", \"created_by_id\": \"createdById\", \"last_modified_at\": \"2019-01-01T12:00:00.000Z\", \"last_modified_by_id\": \"lastModifiedById\", \"resources\": [{\"target\": {\"type\": \"Account\", \"id\": \"id\"}, \"policy\": {\"resource_created\": {\"id\": \"id\"}, \"status\": \"status\", \"error_message\": {\"name\": \"name\", \"errorCode\": \"errorCode\", \"message\": \"message\", \"code\": \"code\", \"errors\": [{\"code\": \"insufficent_permissions\", \"message\": \"message\", \"details\": {\"conflicts_with\": {\"etag\": \"etag\", \"role\": \"role\", \"policy\": \"policy\"}}, \"more_info\": \"moreInfo\"}]}}}], \"subject\": {\"id\": \"id\", \"type\": \"iam_id\"}, \"template\": {\"id\": \"id\", \"version\": \"version\"}, \"status\": \"in_progress\"}"; String updatePolicyAssignmentPath = "/v1/policy_assignments/testString"; server.enqueue(new MockResponse() .setHeader("Content-type", "application/json") @@ -3525,7 +3553,7 @@ public void testCommitActionControlTemplateNoOptions() throws Throwable { @Test public void testListActionControlAssignmentsWOptions() throws Throwable { // Register a mock response - String mockResponseBody = "{\"limit\": 1, \"first\": {\"href\": \"href\"}, \"next\": {\"href\": \"href\", \"start\": \"start\"}, \"previous\": {\"href\": \"href\", \"start\": \"start\"}, \"assignments\": [{\"id\": \"id\", \"account_id\": \"accountId\", \"href\": \"href\", \"created_at\": \"2019-01-01T12:00:00.000Z\", \"created_by_id\": \"createdById\", \"last_modified_at\": \"2019-01-01T12:00:00.000Z\", \"last_modified_by_id\": \"lastModifiedById\", \"operation\": \"create\", \"resources\": [{\"target\": {\"type\": \"Account\", \"id\": \"id\"}, \"action_control\": {\"resource_created\": {\"id\": \"id\"}, \"error_message\": {\"trace\": \"trace\", \"errors\": [{\"code\": \"insufficent_permissions\", \"message\": \"message\", \"details\": {\"conflicts_with\": {\"etag\": \"etag\", \"role\": \"role\", \"policy\": \"policy\"}}, \"more_info\": \"moreInfo\"}], \"status_code\": 0}}}], \"template\": {\"id\": \"id\", \"version\": \"version\"}, \"target\": {\"type\": \"Account\", \"id\": \"id\"}, \"status\": \"accepted\"}]}"; + String mockResponseBody = "{\"limit\": 1, \"first\": {\"href\": \"href\"}, \"next\": {\"href\": \"href\", \"start\": \"start\"}, \"previous\": {\"href\": \"href\", \"start\": \"start\"}, \"assignments\": [{\"id\": \"id\", \"account_id\": \"accountId\", \"href\": \"href\", \"created_at\": \"2019-01-01T12:00:00.000Z\", \"created_by_id\": \"createdById\", \"last_modified_at\": \"2019-01-01T12:00:00.000Z\", \"last_modified_by_id\": \"lastModifiedById\", \"operation\": \"create\", \"resources\": [{\"target\": {\"type\": \"Account\", \"id\": \"id\"}, \"action_control\": {\"resource_created\": {\"id\": \"id\"}, \"error_message\": {\"name\": \"name\", \"errorCode\": \"errorCode\", \"message\": \"message\", \"code\": \"code\", \"errors\": [{\"code\": \"insufficent_permissions\", \"message\": \"message\", \"details\": {\"conflicts_with\": {\"etag\": \"etag\", \"role\": \"role\", \"policy\": \"policy\"}}, \"more_info\": \"moreInfo\"}]}}}], \"template\": {\"id\": \"id\", \"version\": \"version\"}, \"target\": {\"type\": \"Account\", \"id\": \"id\"}, \"status\": \"accepted\"}]}"; String listActionControlAssignmentsPath = "/v1/action_control_assignments"; server.enqueue(new MockResponse() .setHeader("Content-type", "application/json") @@ -3586,8 +3614,8 @@ public void testListActionControlAssignmentsNoOptions() throws Throwable { @Test public void testListActionControlAssignmentsWithPagerGetNext() throws Throwable { // Set up the two-page mock response. - String mockResponsePage1 = "{\"next\":{\"start\":\"1\"},\"assignments\":[{\"id\":\"id\",\"account_id\":\"accountId\",\"href\":\"href\",\"created_at\":\"2019-01-01T12:00:00.000Z\",\"created_by_id\":\"createdById\",\"last_modified_at\":\"2019-01-01T12:00:00.000Z\",\"last_modified_by_id\":\"lastModifiedById\",\"operation\":\"create\",\"resources\":[{\"target\":{\"type\":\"Account\",\"id\":\"id\"},\"action_control\":{\"resource_created\":{\"id\":\"id\"},\"error_message\":{\"trace\":\"trace\",\"errors\":[{\"code\":\"insufficent_permissions\",\"message\":\"message\",\"details\":{\"conflicts_with\":{\"etag\":\"etag\",\"role\":\"role\",\"policy\":\"policy\"}},\"more_info\":\"moreInfo\"}],\"status_code\":0}}}],\"template\":{\"id\":\"id\",\"version\":\"version\"},\"target\":{\"type\":\"Account\",\"id\":\"id\"},\"status\":\"accepted\"}],\"total_count\":2,\"limit\":1}"; - String mockResponsePage2 = "{\"assignments\":[{\"id\":\"id\",\"account_id\":\"accountId\",\"href\":\"href\",\"created_at\":\"2019-01-01T12:00:00.000Z\",\"created_by_id\":\"createdById\",\"last_modified_at\":\"2019-01-01T12:00:00.000Z\",\"last_modified_by_id\":\"lastModifiedById\",\"operation\":\"create\",\"resources\":[{\"target\":{\"type\":\"Account\",\"id\":\"id\"},\"action_control\":{\"resource_created\":{\"id\":\"id\"},\"error_message\":{\"trace\":\"trace\",\"errors\":[{\"code\":\"insufficent_permissions\",\"message\":\"message\",\"details\":{\"conflicts_with\":{\"etag\":\"etag\",\"role\":\"role\",\"policy\":\"policy\"}},\"more_info\":\"moreInfo\"}],\"status_code\":0}}}],\"template\":{\"id\":\"id\",\"version\":\"version\"},\"target\":{\"type\":\"Account\",\"id\":\"id\"},\"status\":\"accepted\"}],\"total_count\":2,\"limit\":1}"; + String mockResponsePage1 = "{\"next\":{\"start\":\"1\"},\"assignments\":[{\"id\":\"id\",\"account_id\":\"accountId\",\"href\":\"href\",\"created_at\":\"2019-01-01T12:00:00.000Z\",\"created_by_id\":\"createdById\",\"last_modified_at\":\"2019-01-01T12:00:00.000Z\",\"last_modified_by_id\":\"lastModifiedById\",\"operation\":\"create\",\"resources\":[{\"target\":{\"type\":\"Account\",\"id\":\"id\"},\"action_control\":{\"resource_created\":{\"id\":\"id\"},\"error_message\":{\"name\":\"name\",\"errorCode\":\"errorCode\",\"message\":\"message\",\"code\":\"code\",\"errors\":[{\"code\":\"insufficent_permissions\",\"message\":\"message\",\"details\":{\"conflicts_with\":{\"etag\":\"etag\",\"role\":\"role\",\"policy\":\"policy\"}},\"more_info\":\"moreInfo\"}]}}}],\"template\":{\"id\":\"id\",\"version\":\"version\"},\"target\":{\"type\":\"Account\",\"id\":\"id\"},\"status\":\"accepted\"}],\"total_count\":2,\"limit\":1}"; + String mockResponsePage2 = "{\"assignments\":[{\"id\":\"id\",\"account_id\":\"accountId\",\"href\":\"href\",\"created_at\":\"2019-01-01T12:00:00.000Z\",\"created_by_id\":\"createdById\",\"last_modified_at\":\"2019-01-01T12:00:00.000Z\",\"last_modified_by_id\":\"lastModifiedById\",\"operation\":\"create\",\"resources\":[{\"target\":{\"type\":\"Account\",\"id\":\"id\"},\"action_control\":{\"resource_created\":{\"id\":\"id\"},\"error_message\":{\"name\":\"name\",\"errorCode\":\"errorCode\",\"message\":\"message\",\"code\":\"code\",\"errors\":[{\"code\":\"insufficent_permissions\",\"message\":\"message\",\"details\":{\"conflicts_with\":{\"etag\":\"etag\",\"role\":\"role\",\"policy\":\"policy\"}},\"more_info\":\"moreInfo\"}]}}}],\"template\":{\"id\":\"id\",\"version\":\"version\"},\"target\":{\"type\":\"Account\",\"id\":\"id\"},\"status\":\"accepted\"}],\"total_count\":2,\"limit\":1}"; server.enqueue(new MockResponse() .setHeader("Content-type", "application/json") .setResponseCode(200) @@ -3623,8 +3651,8 @@ public void testListActionControlAssignmentsWithPagerGetNext() throws Throwable @Test public void testListActionControlAssignmentsWithPagerGetAll() throws Throwable { // Set up the two-page mock response. - String mockResponsePage1 = "{\"next\":{\"start\":\"1\"},\"assignments\":[{\"id\":\"id\",\"account_id\":\"accountId\",\"href\":\"href\",\"created_at\":\"2019-01-01T12:00:00.000Z\",\"created_by_id\":\"createdById\",\"last_modified_at\":\"2019-01-01T12:00:00.000Z\",\"last_modified_by_id\":\"lastModifiedById\",\"operation\":\"create\",\"resources\":[{\"target\":{\"type\":\"Account\",\"id\":\"id\"},\"action_control\":{\"resource_created\":{\"id\":\"id\"},\"error_message\":{\"trace\":\"trace\",\"errors\":[{\"code\":\"insufficent_permissions\",\"message\":\"message\",\"details\":{\"conflicts_with\":{\"etag\":\"etag\",\"role\":\"role\",\"policy\":\"policy\"}},\"more_info\":\"moreInfo\"}],\"status_code\":0}}}],\"template\":{\"id\":\"id\",\"version\":\"version\"},\"target\":{\"type\":\"Account\",\"id\":\"id\"},\"status\":\"accepted\"}],\"total_count\":2,\"limit\":1}"; - String mockResponsePage2 = "{\"assignments\":[{\"id\":\"id\",\"account_id\":\"accountId\",\"href\":\"href\",\"created_at\":\"2019-01-01T12:00:00.000Z\",\"created_by_id\":\"createdById\",\"last_modified_at\":\"2019-01-01T12:00:00.000Z\",\"last_modified_by_id\":\"lastModifiedById\",\"operation\":\"create\",\"resources\":[{\"target\":{\"type\":\"Account\",\"id\":\"id\"},\"action_control\":{\"resource_created\":{\"id\":\"id\"},\"error_message\":{\"trace\":\"trace\",\"errors\":[{\"code\":\"insufficent_permissions\",\"message\":\"message\",\"details\":{\"conflicts_with\":{\"etag\":\"etag\",\"role\":\"role\",\"policy\":\"policy\"}},\"more_info\":\"moreInfo\"}],\"status_code\":0}}}],\"template\":{\"id\":\"id\",\"version\":\"version\"},\"target\":{\"type\":\"Account\",\"id\":\"id\"},\"status\":\"accepted\"}],\"total_count\":2,\"limit\":1}"; + String mockResponsePage1 = "{\"next\":{\"start\":\"1\"},\"assignments\":[{\"id\":\"id\",\"account_id\":\"accountId\",\"href\":\"href\",\"created_at\":\"2019-01-01T12:00:00.000Z\",\"created_by_id\":\"createdById\",\"last_modified_at\":\"2019-01-01T12:00:00.000Z\",\"last_modified_by_id\":\"lastModifiedById\",\"operation\":\"create\",\"resources\":[{\"target\":{\"type\":\"Account\",\"id\":\"id\"},\"action_control\":{\"resource_created\":{\"id\":\"id\"},\"error_message\":{\"name\":\"name\",\"errorCode\":\"errorCode\",\"message\":\"message\",\"code\":\"code\",\"errors\":[{\"code\":\"insufficent_permissions\",\"message\":\"message\",\"details\":{\"conflicts_with\":{\"etag\":\"etag\",\"role\":\"role\",\"policy\":\"policy\"}},\"more_info\":\"moreInfo\"}]}}}],\"template\":{\"id\":\"id\",\"version\":\"version\"},\"target\":{\"type\":\"Account\",\"id\":\"id\"},\"status\":\"accepted\"}],\"total_count\":2,\"limit\":1}"; + String mockResponsePage2 = "{\"assignments\":[{\"id\":\"id\",\"account_id\":\"accountId\",\"href\":\"href\",\"created_at\":\"2019-01-01T12:00:00.000Z\",\"created_by_id\":\"createdById\",\"last_modified_at\":\"2019-01-01T12:00:00.000Z\",\"last_modified_by_id\":\"lastModifiedById\",\"operation\":\"create\",\"resources\":[{\"target\":{\"type\":\"Account\",\"id\":\"id\"},\"action_control\":{\"resource_created\":{\"id\":\"id\"},\"error_message\":{\"name\":\"name\",\"errorCode\":\"errorCode\",\"message\":\"message\",\"code\":\"code\",\"errors\":[{\"code\":\"insufficent_permissions\",\"message\":\"message\",\"details\":{\"conflicts_with\":{\"etag\":\"etag\",\"role\":\"role\",\"policy\":\"policy\"}},\"more_info\":\"moreInfo\"}]}}}],\"template\":{\"id\":\"id\",\"version\":\"version\"},\"target\":{\"type\":\"Account\",\"id\":\"id\"},\"status\":\"accepted\"}],\"total_count\":2,\"limit\":1}"; server.enqueue(new MockResponse() .setHeader("Content-type", "application/json") .setResponseCode(200) @@ -3656,7 +3684,7 @@ public void testListActionControlAssignmentsWithPagerGetAll() throws Throwable { @Test public void testCreateActionControlTemplateAssignmentWOptions() throws Throwable { // Register a mock response - String mockResponseBody = "{\"limit\": 1, \"first\": {\"href\": \"href\"}, \"next\": {\"href\": \"href\", \"start\": \"start\"}, \"previous\": {\"href\": \"href\", \"start\": \"start\"}, \"assignments\": [{\"id\": \"id\", \"account_id\": \"accountId\", \"href\": \"href\", \"created_at\": \"2019-01-01T12:00:00.000Z\", \"created_by_id\": \"createdById\", \"last_modified_at\": \"2019-01-01T12:00:00.000Z\", \"last_modified_by_id\": \"lastModifiedById\", \"operation\": \"create\", \"resources\": [{\"target\": {\"type\": \"Account\", \"id\": \"id\"}, \"action_control\": {\"resource_created\": {\"id\": \"id\"}, \"error_message\": {\"trace\": \"trace\", \"errors\": [{\"code\": \"insufficent_permissions\", \"message\": \"message\", \"details\": {\"conflicts_with\": {\"etag\": \"etag\", \"role\": \"role\", \"policy\": \"policy\"}}, \"more_info\": \"moreInfo\"}], \"status_code\": 0}}}], \"template\": {\"id\": \"id\", \"version\": \"version\"}, \"target\": {\"type\": \"Account\", \"id\": \"id\"}, \"status\": \"accepted\"}]}"; + String mockResponseBody = "{\"limit\": 1, \"first\": {\"href\": \"href\"}, \"next\": {\"href\": \"href\", \"start\": \"start\"}, \"previous\": {\"href\": \"href\", \"start\": \"start\"}, \"assignments\": [{\"id\": \"id\", \"account_id\": \"accountId\", \"href\": \"href\", \"created_at\": \"2019-01-01T12:00:00.000Z\", \"created_by_id\": \"createdById\", \"last_modified_at\": \"2019-01-01T12:00:00.000Z\", \"last_modified_by_id\": \"lastModifiedById\", \"operation\": \"create\", \"resources\": [{\"target\": {\"type\": \"Account\", \"id\": \"id\"}, \"action_control\": {\"resource_created\": {\"id\": \"id\"}, \"error_message\": {\"name\": \"name\", \"errorCode\": \"errorCode\", \"message\": \"message\", \"code\": \"code\", \"errors\": [{\"code\": \"insufficent_permissions\", \"message\": \"message\", \"details\": {\"conflicts_with\": {\"etag\": \"etag\", \"role\": \"role\", \"policy\": \"policy\"}}, \"more_info\": \"moreInfo\"}]}}}], \"template\": {\"id\": \"id\", \"version\": \"version\"}, \"target\": {\"type\": \"Account\", \"id\": \"id\"}, \"status\": \"accepted\"}]}"; String createActionControlTemplateAssignmentPath = "/v1/action_control_assignments"; server.enqueue(new MockResponse() .setHeader("Content-type", "application/json") @@ -3721,7 +3749,7 @@ public void testCreateActionControlTemplateAssignmentNoOptions() throws Throwabl @Test public void testGetActionControlAssignmentWOptions() throws Throwable { // Register a mock response - String mockResponseBody = "{\"id\": \"id\", \"account_id\": \"accountId\", \"href\": \"href\", \"created_at\": \"2019-01-01T12:00:00.000Z\", \"created_by_id\": \"createdById\", \"last_modified_at\": \"2019-01-01T12:00:00.000Z\", \"last_modified_by_id\": \"lastModifiedById\", \"operation\": \"create\", \"resources\": [{\"target\": {\"type\": \"Account\", \"id\": \"id\"}, \"action_control\": {\"resource_created\": {\"id\": \"id\"}, \"error_message\": {\"trace\": \"trace\", \"errors\": [{\"code\": \"insufficent_permissions\", \"message\": \"message\", \"details\": {\"conflicts_with\": {\"etag\": \"etag\", \"role\": \"role\", \"policy\": \"policy\"}}, \"more_info\": \"moreInfo\"}], \"status_code\": 0}}}], \"template\": {\"id\": \"id\", \"version\": \"version\"}, \"target\": {\"type\": \"Account\", \"id\": \"id\"}, \"status\": \"accepted\"}"; + String mockResponseBody = "{\"id\": \"id\", \"account_id\": \"accountId\", \"href\": \"href\", \"created_at\": \"2019-01-01T12:00:00.000Z\", \"created_by_id\": \"createdById\", \"last_modified_at\": \"2019-01-01T12:00:00.000Z\", \"last_modified_by_id\": \"lastModifiedById\", \"operation\": \"create\", \"resources\": [{\"target\": {\"type\": \"Account\", \"id\": \"id\"}, \"action_control\": {\"resource_created\": {\"id\": \"id\"}, \"error_message\": {\"name\": \"name\", \"errorCode\": \"errorCode\", \"message\": \"message\", \"code\": \"code\", \"errors\": [{\"code\": \"insufficent_permissions\", \"message\": \"message\", \"details\": {\"conflicts_with\": {\"etag\": \"etag\", \"role\": \"role\", \"policy\": \"policy\"}}, \"more_info\": \"moreInfo\"}]}}}], \"template\": {\"id\": \"id\", \"version\": \"version\"}, \"target\": {\"type\": \"Account\", \"id\": \"id\"}, \"status\": \"accepted\"}"; String getActionControlAssignmentPath = "/v1/action_control_assignments/testString"; server.enqueue(new MockResponse() .setHeader("Content-type", "application/json") @@ -3772,7 +3800,7 @@ public void testGetActionControlAssignmentNoOptions() throws Throwable { @Test public void testUpdateActionControlAssignmentWOptions() throws Throwable { // Register a mock response - String mockResponseBody = "{\"id\": \"id\", \"account_id\": \"accountId\", \"href\": \"href\", \"created_at\": \"2019-01-01T12:00:00.000Z\", \"created_by_id\": \"createdById\", \"last_modified_at\": \"2019-01-01T12:00:00.000Z\", \"last_modified_by_id\": \"lastModifiedById\", \"operation\": \"create\", \"resources\": [{\"target\": {\"type\": \"Account\", \"id\": \"id\"}, \"action_control\": {\"resource_created\": {\"id\": \"id\"}, \"error_message\": {\"trace\": \"trace\", \"errors\": [{\"code\": \"insufficent_permissions\", \"message\": \"message\", \"details\": {\"conflicts_with\": {\"etag\": \"etag\", \"role\": \"role\", \"policy\": \"policy\"}}, \"more_info\": \"moreInfo\"}], \"status_code\": 0}}}], \"template\": {\"id\": \"id\", \"version\": \"version\"}, \"target\": {\"type\": \"Account\", \"id\": \"id\"}, \"status\": \"accepted\"}"; + String mockResponseBody = "{\"id\": \"id\", \"account_id\": \"accountId\", \"href\": \"href\", \"created_at\": \"2019-01-01T12:00:00.000Z\", \"created_by_id\": \"createdById\", \"last_modified_at\": \"2019-01-01T12:00:00.000Z\", \"last_modified_by_id\": \"lastModifiedById\", \"operation\": \"create\", \"resources\": [{\"target\": {\"type\": \"Account\", \"id\": \"id\"}, \"action_control\": {\"resource_created\": {\"id\": \"id\"}, \"error_message\": {\"name\": \"name\", \"errorCode\": \"errorCode\", \"message\": \"message\", \"code\": \"code\", \"errors\": [{\"code\": \"insufficent_permissions\", \"message\": \"message\", \"details\": {\"conflicts_with\": {\"etag\": \"etag\", \"role\": \"role\", \"policy\": \"policy\"}}, \"more_info\": \"moreInfo\"}]}}}], \"template\": {\"id\": \"id\", \"version\": \"version\"}, \"target\": {\"type\": \"Account\", \"id\": \"id\"}, \"status\": \"accepted\"}"; String updateActionControlAssignmentPath = "/v1/action_control_assignments/testString"; server.enqueue(new MockResponse() .setHeader("Content-type", "application/json") @@ -3873,6 +3901,1074 @@ public void testDeleteActionControlAssignmentNoOptions() throws Throwable { iamPolicyManagementService.deleteActionControlAssignment(null).execute(); } + // Test the listRoleTemplates operation with a valid options model parameter + @Test + public void testListRoleTemplatesWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = "{\"limit\": 1, \"first\": {\"href\": \"href\"}, \"next\": {\"href\": \"href\", \"start\": \"start\"}, \"previous\": {\"href\": \"href\", \"start\": \"start\"}, \"role_templates\": [{\"name\": \"name\", \"description\": \"description\", \"account_id\": \"accountId\", \"committed\": false, \"role\": {\"name\": \"name\", \"display_name\": \"displayName\", \"service_name\": \"serviceName\", \"description\": \"description\", \"actions\": [\"actions\"]}, \"id\": \"id\", \"href\": \"href\", \"created_at\": \"2019-01-01T12:00:00.000Z\", \"created_by_id\": \"createdById\", \"last_modified_at\": \"2019-01-01T12:00:00.000Z\", \"last_modified_by_id\": \"lastModifiedById\", \"version\": \"version\", \"state\": \"active\"}]}"; + String listRoleTemplatesPath = "/v1/role_templates"; + server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the ListRoleTemplatesOptions model + ListRoleTemplatesOptions listRoleTemplatesOptionsModel = new ListRoleTemplatesOptions.Builder() + .accountId("testString") + .acceptLanguage("default") + .name("testString") + .roleName("testString") + .roleServiceName("testString") + .state("active") + .limit(Long.valueOf("10")) + .start("testString") + .build(); + + // Invoke listRoleTemplates() with a valid options model and verify the result + Response response = iamPolicyManagementService.listRoleTemplates(listRoleTemplatesOptionsModel).execute(); + assertNotNull(response); + RoleTemplateCollection responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, listRoleTemplatesPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("account_id"), "testString"); + assertEquals(query.get("name"), "testString"); + assertEquals(query.get("role_name"), "testString"); + assertEquals(query.get("role_service_name"), "testString"); + assertEquals(query.get("state"), "active"); + assertEquals(Long.valueOf(query.get("limit")), Long.valueOf("10")); + assertEquals(query.get("start"), "testString"); + } + + // Test the listRoleTemplates operation with and without retries enabled + @Test + public void testListRoleTemplatesWRetries() throws Throwable { + iamPolicyManagementService.enableRetries(4, 30); + testListRoleTemplatesWOptions(); + + iamPolicyManagementService.disableRetries(); + testListRoleTemplatesWOptions(); + } + + // Test the listRoleTemplates operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListRoleTemplatesNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + iamPolicyManagementService.listRoleTemplates(null).execute(); + } + + // Test the listRoleTemplates operation using the RoleTemplatesPager.getNext() method + @Test + public void testListRoleTemplatesWithPagerGetNext() throws Throwable { + // Set up the two-page mock response. + String mockResponsePage1 = "{\"next\":{\"start\":\"1\"},\"total_count\":2,\"limit\":1,\"role_templates\":[{\"name\":\"name\",\"description\":\"description\",\"account_id\":\"accountId\",\"committed\":false,\"role\":{\"name\":\"name\",\"display_name\":\"displayName\",\"service_name\":\"serviceName\",\"description\":\"description\",\"actions\":[\"actions\"]},\"id\":\"id\",\"href\":\"href\",\"created_at\":\"2019-01-01T12:00:00.000Z\",\"created_by_id\":\"createdById\",\"last_modified_at\":\"2019-01-01T12:00:00.000Z\",\"last_modified_by_id\":\"lastModifiedById\",\"version\":\"version\",\"state\":\"active\"}]}"; + String mockResponsePage2 = "{\"total_count\":2,\"limit\":1,\"role_templates\":[{\"name\":\"name\",\"description\":\"description\",\"account_id\":\"accountId\",\"committed\":false,\"role\":{\"name\":\"name\",\"display_name\":\"displayName\",\"service_name\":\"serviceName\",\"description\":\"description\",\"actions\":[\"actions\"]},\"id\":\"id\",\"href\":\"href\",\"created_at\":\"2019-01-01T12:00:00.000Z\",\"created_by_id\":\"createdById\",\"last_modified_at\":\"2019-01-01T12:00:00.000Z\",\"last_modified_by_id\":\"lastModifiedById\",\"version\":\"version\",\"state\":\"active\"}]}"; + server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponsePage1)); + server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponsePage2)); + server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(400) + .setBody("{\"message\": \"No more results available!\"}")); + + ListRoleTemplatesOptions listRoleTemplatesOptions = new ListRoleTemplatesOptions.Builder() + .accountId("testString") + .acceptLanguage("default") + .name("testString") + .roleName("testString") + .roleServiceName("testString") + .state("active") + .limit(Long.valueOf("10")) + .build(); + + List allResults = new ArrayList<>(); + RoleTemplatesPager pager = new RoleTemplatesPager(iamPolicyManagementService, listRoleTemplatesOptions); + while (pager.hasNext()) { + List nextPage = pager.getNext(); + assertNotNull(nextPage); + allResults.addAll(nextPage); + } + assertEquals(allResults.size(), 2); + } + + // Test the listRoleTemplates operation using the RoleTemplatesPager.getAll() method + @Test + public void testListRoleTemplatesWithPagerGetAll() throws Throwable { + // Set up the two-page mock response. + String mockResponsePage1 = "{\"next\":{\"start\":\"1\"},\"total_count\":2,\"limit\":1,\"role_templates\":[{\"name\":\"name\",\"description\":\"description\",\"account_id\":\"accountId\",\"committed\":false,\"role\":{\"name\":\"name\",\"display_name\":\"displayName\",\"service_name\":\"serviceName\",\"description\":\"description\",\"actions\":[\"actions\"]},\"id\":\"id\",\"href\":\"href\",\"created_at\":\"2019-01-01T12:00:00.000Z\",\"created_by_id\":\"createdById\",\"last_modified_at\":\"2019-01-01T12:00:00.000Z\",\"last_modified_by_id\":\"lastModifiedById\",\"version\":\"version\",\"state\":\"active\"}]}"; + String mockResponsePage2 = "{\"total_count\":2,\"limit\":1,\"role_templates\":[{\"name\":\"name\",\"description\":\"description\",\"account_id\":\"accountId\",\"committed\":false,\"role\":{\"name\":\"name\",\"display_name\":\"displayName\",\"service_name\":\"serviceName\",\"description\":\"description\",\"actions\":[\"actions\"]},\"id\":\"id\",\"href\":\"href\",\"created_at\":\"2019-01-01T12:00:00.000Z\",\"created_by_id\":\"createdById\",\"last_modified_at\":\"2019-01-01T12:00:00.000Z\",\"last_modified_by_id\":\"lastModifiedById\",\"version\":\"version\",\"state\":\"active\"}]}"; + server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponsePage1)); + server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponsePage2)); + server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(400) + .setBody("{\"message\": \"No more results available!\"}")); + + ListRoleTemplatesOptions listRoleTemplatesOptions = new ListRoleTemplatesOptions.Builder() + .accountId("testString") + .acceptLanguage("default") + .name("testString") + .roleName("testString") + .roleServiceName("testString") + .state("active") + .limit(Long.valueOf("10")) + .build(); + + RoleTemplatesPager pager = new RoleTemplatesPager(iamPolicyManagementService, listRoleTemplatesOptions); + List allResults = pager.getAll(); + assertNotNull(allResults); + assertEquals(allResults.size(), 2); + } + + // Test the createRoleTemplate operation with a valid options model parameter + @Test + public void testCreateRoleTemplateWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = "{\"name\": \"name\", \"description\": \"description\", \"account_id\": \"accountId\", \"committed\": false, \"role\": {\"name\": \"name\", \"display_name\": \"displayName\", \"service_name\": \"serviceName\", \"description\": \"description\", \"actions\": [\"actions\"]}, \"id\": \"id\", \"href\": \"href\", \"created_at\": \"2019-01-01T12:00:00.000Z\", \"created_by_id\": \"createdById\", \"last_modified_at\": \"2019-01-01T12:00:00.000Z\", \"last_modified_by_id\": \"lastModifiedById\", \"version\": \"version\", \"state\": \"active\"}"; + String createRoleTemplatePath = "/v1/role_templates"; + server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(201) + .setBody(mockResponseBody)); + + // Construct an instance of the TemplateRole model + TemplateRole templateRoleModel = new TemplateRole.Builder() + .name("testString") + .displayName("testString") + .serviceName("testString") + .description("testString") + .actions(java.util.Arrays.asList("testString")) + .build(); + + // Construct an instance of the CreateRoleTemplateOptions model + CreateRoleTemplateOptions createRoleTemplateOptionsModel = new CreateRoleTemplateOptions.Builder() + .name("testString") + .accountId("testString") + .description("testString") + .committed(true) + .role(templateRoleModel) + .acceptLanguage("default") + .build(); + + // Invoke createRoleTemplate() with a valid options model and verify the result + Response response = iamPolicyManagementService.createRoleTemplate(createRoleTemplateOptionsModel).execute(); + assertNotNull(response); + RoleTemplate responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, createRoleTemplatePath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } + + // Test the createRoleTemplate operation with and without retries enabled + @Test + public void testCreateRoleTemplateWRetries() throws Throwable { + iamPolicyManagementService.enableRetries(4, 30); + testCreateRoleTemplateWOptions(); + + iamPolicyManagementService.disableRetries(); + testCreateRoleTemplateWOptions(); + } + + // Test the createRoleTemplate operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateRoleTemplateNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + iamPolicyManagementService.createRoleTemplate(null).execute(); + } + + // Test the getRoleTemplate operation with a valid options model parameter + @Test + public void testGetRoleTemplateWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = "{\"name\": \"name\", \"description\": \"description\", \"account_id\": \"accountId\", \"committed\": false, \"role\": {\"name\": \"name\", \"display_name\": \"displayName\", \"service_name\": \"serviceName\", \"description\": \"description\", \"actions\": [\"actions\"]}, \"id\": \"id\", \"href\": \"href\", \"created_at\": \"2019-01-01T12:00:00.000Z\", \"created_by_id\": \"createdById\", \"last_modified_at\": \"2019-01-01T12:00:00.000Z\", \"last_modified_by_id\": \"lastModifiedById\", \"version\": \"version\", \"state\": \"active\"}"; + String getRoleTemplatePath = "/v1/role_templates/testString"; + server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the GetRoleTemplateOptions model + GetRoleTemplateOptions getRoleTemplateOptionsModel = new GetRoleTemplateOptions.Builder() + .roleTemplateId("testString") + .state("active") + .build(); + + // Invoke getRoleTemplate() with a valid options model and verify the result + Response response = iamPolicyManagementService.getRoleTemplate(getRoleTemplateOptionsModel).execute(); + assertNotNull(response); + RoleTemplate responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getRoleTemplatePath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("state"), "active"); + } + + // Test the getRoleTemplate operation with and without retries enabled + @Test + public void testGetRoleTemplateWRetries() throws Throwable { + iamPolicyManagementService.enableRetries(4, 30); + testGetRoleTemplateWOptions(); + + iamPolicyManagementService.disableRetries(); + testGetRoleTemplateWOptions(); + } + + // Test the getRoleTemplate operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetRoleTemplateNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + iamPolicyManagementService.getRoleTemplate(null).execute(); + } + + // Test the deleteRoleTemplate operation with a valid options model parameter + @Test + public void testDeleteRoleTemplateWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = ""; + String deleteRoleTemplatePath = "/v1/role_templates/testString"; + server.enqueue(new MockResponse() + .setResponseCode(204) + .setBody(mockResponseBody)); + + // Construct an instance of the DeleteRoleTemplateOptions model + DeleteRoleTemplateOptions deleteRoleTemplateOptionsModel = new DeleteRoleTemplateOptions.Builder() + .roleTemplateId("testString") + .build(); + + // Invoke deleteRoleTemplate() with a valid options model and verify the result + Response response = iamPolicyManagementService.deleteRoleTemplate(deleteRoleTemplateOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + assertNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteRoleTemplatePath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } + + // Test the deleteRoleTemplate operation with and without retries enabled + @Test + public void testDeleteRoleTemplateWRetries() throws Throwable { + iamPolicyManagementService.enableRetries(4, 30); + testDeleteRoleTemplateWOptions(); + + iamPolicyManagementService.disableRetries(); + testDeleteRoleTemplateWOptions(); + } + + // Test the deleteRoleTemplate operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteRoleTemplateNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + iamPolicyManagementService.deleteRoleTemplate(null).execute(); + } + + // Test the createRoleTemplateVersion operation with a valid options model parameter + @Test + public void testCreateRoleTemplateVersionWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = "{\"name\": \"name\", \"description\": \"description\", \"account_id\": \"accountId\", \"committed\": false, \"role\": {\"name\": \"name\", \"display_name\": \"displayName\", \"service_name\": \"serviceName\", \"description\": \"description\", \"actions\": [\"actions\"]}, \"id\": \"id\", \"href\": \"href\", \"created_at\": \"2019-01-01T12:00:00.000Z\", \"created_by_id\": \"createdById\", \"last_modified_at\": \"2019-01-01T12:00:00.000Z\", \"last_modified_by_id\": \"lastModifiedById\", \"version\": \"version\", \"state\": \"active\"}"; + String createRoleTemplateVersionPath = "/v1/role_templates/testString/versions"; + server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(201) + .setBody(mockResponseBody)); + + // Construct an instance of the TemplateRole model + TemplateRole templateRoleModel = new TemplateRole.Builder() + .name("testString") + .displayName("testString") + .serviceName("testString") + .description("testString") + .actions(java.util.Arrays.asList("testString")) + .build(); + + // Construct an instance of the CreateRoleTemplateVersionOptions model + CreateRoleTemplateVersionOptions createRoleTemplateVersionOptionsModel = new CreateRoleTemplateVersionOptions.Builder() + .roleTemplateId("testString") + .role(templateRoleModel) + .name("testString") + .description("testString") + .committed(true) + .build(); + + // Invoke createRoleTemplateVersion() with a valid options model and verify the result + Response response = iamPolicyManagementService.createRoleTemplateVersion(createRoleTemplateVersionOptionsModel).execute(); + assertNotNull(response); + RoleTemplate responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, createRoleTemplateVersionPath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } + + // Test the createRoleTemplateVersion operation with and without retries enabled + @Test + public void testCreateRoleTemplateVersionWRetries() throws Throwable { + iamPolicyManagementService.enableRetries(4, 30); + testCreateRoleTemplateVersionWOptions(); + + iamPolicyManagementService.disableRetries(); + testCreateRoleTemplateVersionWOptions(); + } + + // Test the createRoleTemplateVersion operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateRoleTemplateVersionNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + iamPolicyManagementService.createRoleTemplateVersion(null).execute(); + } + + // Test the listRoleTemplateVersions operation with a valid options model parameter + @Test + public void testListRoleTemplateVersionsWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = "{\"limit\": 1, \"first\": {\"href\": \"href\"}, \"next\": {\"href\": \"href\", \"start\": \"start\"}, \"previous\": {\"href\": \"href\", \"start\": \"start\"}, \"versions\": [{\"name\": \"name\", \"description\": \"description\", \"account_id\": \"accountId\", \"committed\": false, \"role\": {\"name\": \"name\", \"display_name\": \"displayName\", \"service_name\": \"serviceName\", \"description\": \"description\", \"actions\": [\"actions\"]}, \"id\": \"id\", \"href\": \"href\", \"created_at\": \"2019-01-01T12:00:00.000Z\", \"created_by_id\": \"createdById\", \"last_modified_at\": \"2019-01-01T12:00:00.000Z\", \"last_modified_by_id\": \"lastModifiedById\", \"version\": \"version\", \"state\": \"active\"}]}"; + String listRoleTemplateVersionsPath = "/v1/role_templates/testString/versions"; + server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the ListRoleTemplateVersionsOptions model + ListRoleTemplateVersionsOptions listRoleTemplateVersionsOptionsModel = new ListRoleTemplateVersionsOptions.Builder() + .roleTemplateId("testString") + .state("active") + .limit(Long.valueOf("10")) + .start("testString") + .build(); + + // Invoke listRoleTemplateVersions() with a valid options model and verify the result + Response response = iamPolicyManagementService.listRoleTemplateVersions(listRoleTemplateVersionsOptionsModel).execute(); + assertNotNull(response); + RoleTemplateVersionsCollection responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, listRoleTemplateVersionsPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("state"), "active"); + assertEquals(Long.valueOf(query.get("limit")), Long.valueOf("10")); + assertEquals(query.get("start"), "testString"); + } + + // Test the listRoleTemplateVersions operation with and without retries enabled + @Test + public void testListRoleTemplateVersionsWRetries() throws Throwable { + iamPolicyManagementService.enableRetries(4, 30); + testListRoleTemplateVersionsWOptions(); + + iamPolicyManagementService.disableRetries(); + testListRoleTemplateVersionsWOptions(); + } + + // Test the listRoleTemplateVersions operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListRoleTemplateVersionsNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + iamPolicyManagementService.listRoleTemplateVersions(null).execute(); + } + + // Test the listRoleTemplateVersions operation using the RoleTemplateVersionsPager.getNext() method + @Test + public void testListRoleTemplateVersionsWithPagerGetNext() throws Throwable { + // Set up the two-page mock response. + String mockResponsePage1 = "{\"next\":{\"start\":\"1\"},\"versions\":[{\"name\":\"name\",\"description\":\"description\",\"account_id\":\"accountId\",\"committed\":false,\"role\":{\"name\":\"name\",\"display_name\":\"displayName\",\"service_name\":\"serviceName\",\"description\":\"description\",\"actions\":[\"actions\"]},\"id\":\"id\",\"href\":\"href\",\"created_at\":\"2019-01-01T12:00:00.000Z\",\"created_by_id\":\"createdById\",\"last_modified_at\":\"2019-01-01T12:00:00.000Z\",\"last_modified_by_id\":\"lastModifiedById\",\"version\":\"version\",\"state\":\"active\"}],\"total_count\":2,\"limit\":1}"; + String mockResponsePage2 = "{\"versions\":[{\"name\":\"name\",\"description\":\"description\",\"account_id\":\"accountId\",\"committed\":false,\"role\":{\"name\":\"name\",\"display_name\":\"displayName\",\"service_name\":\"serviceName\",\"description\":\"description\",\"actions\":[\"actions\"]},\"id\":\"id\",\"href\":\"href\",\"created_at\":\"2019-01-01T12:00:00.000Z\",\"created_by_id\":\"createdById\",\"last_modified_at\":\"2019-01-01T12:00:00.000Z\",\"last_modified_by_id\":\"lastModifiedById\",\"version\":\"version\",\"state\":\"active\"}],\"total_count\":2,\"limit\":1}"; + server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponsePage1)); + server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponsePage2)); + server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(400) + .setBody("{\"message\": \"No more results available!\"}")); + + ListRoleTemplateVersionsOptions listRoleTemplateVersionsOptions = new ListRoleTemplateVersionsOptions.Builder() + .roleTemplateId("testString") + .state("active") + .limit(Long.valueOf("10")) + .build(); + + List allResults = new ArrayList<>(); + RoleTemplateVersionsPager pager = new RoleTemplateVersionsPager(iamPolicyManagementService, listRoleTemplateVersionsOptions); + while (pager.hasNext()) { + List nextPage = pager.getNext(); + assertNotNull(nextPage); + allResults.addAll(nextPage); + } + assertEquals(allResults.size(), 2); + } + + // Test the listRoleTemplateVersions operation using the RoleTemplateVersionsPager.getAll() method + @Test + public void testListRoleTemplateVersionsWithPagerGetAll() throws Throwable { + // Set up the two-page mock response. + String mockResponsePage1 = "{\"next\":{\"start\":\"1\"},\"versions\":[{\"name\":\"name\",\"description\":\"description\",\"account_id\":\"accountId\",\"committed\":false,\"role\":{\"name\":\"name\",\"display_name\":\"displayName\",\"service_name\":\"serviceName\",\"description\":\"description\",\"actions\":[\"actions\"]},\"id\":\"id\",\"href\":\"href\",\"created_at\":\"2019-01-01T12:00:00.000Z\",\"created_by_id\":\"createdById\",\"last_modified_at\":\"2019-01-01T12:00:00.000Z\",\"last_modified_by_id\":\"lastModifiedById\",\"version\":\"version\",\"state\":\"active\"}],\"total_count\":2,\"limit\":1}"; + String mockResponsePage2 = "{\"versions\":[{\"name\":\"name\",\"description\":\"description\",\"account_id\":\"accountId\",\"committed\":false,\"role\":{\"name\":\"name\",\"display_name\":\"displayName\",\"service_name\":\"serviceName\",\"description\":\"description\",\"actions\":[\"actions\"]},\"id\":\"id\",\"href\":\"href\",\"created_at\":\"2019-01-01T12:00:00.000Z\",\"created_by_id\":\"createdById\",\"last_modified_at\":\"2019-01-01T12:00:00.000Z\",\"last_modified_by_id\":\"lastModifiedById\",\"version\":\"version\",\"state\":\"active\"}],\"total_count\":2,\"limit\":1}"; + server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponsePage1)); + server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponsePage2)); + server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(400) + .setBody("{\"message\": \"No more results available!\"}")); + + ListRoleTemplateVersionsOptions listRoleTemplateVersionsOptions = new ListRoleTemplateVersionsOptions.Builder() + .roleTemplateId("testString") + .state("active") + .limit(Long.valueOf("10")) + .build(); + + RoleTemplateVersionsPager pager = new RoleTemplateVersionsPager(iamPolicyManagementService, listRoleTemplateVersionsOptions); + List allResults = pager.getAll(); + assertNotNull(allResults); + assertEquals(allResults.size(), 2); + } + + // Test the replaceRoleTemplate operation with a valid options model parameter + @Test + public void testReplaceRoleTemplateWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = "{\"name\": \"name\", \"description\": \"description\", \"account_id\": \"accountId\", \"committed\": false, \"role\": {\"name\": \"name\", \"display_name\": \"displayName\", \"service_name\": \"serviceName\", \"description\": \"description\", \"actions\": [\"actions\"]}, \"id\": \"id\", \"href\": \"href\", \"created_at\": \"2019-01-01T12:00:00.000Z\", \"created_by_id\": \"createdById\", \"last_modified_at\": \"2019-01-01T12:00:00.000Z\", \"last_modified_by_id\": \"lastModifiedById\", \"version\": \"version\", \"state\": \"active\"}"; + String replaceRoleTemplatePath = "/v1/role_templates/testString/versions/testString"; + server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the TemplateRole model + TemplateRole templateRoleModel = new TemplateRole.Builder() + .name("testString") + .displayName("testString") + .serviceName("testString") + .description("testString") + .actions(java.util.Arrays.asList("testString")) + .build(); + + // Construct an instance of the ReplaceRoleTemplateOptions model + ReplaceRoleTemplateOptions replaceRoleTemplateOptionsModel = new ReplaceRoleTemplateOptions.Builder() + .roleTemplateId("testString") + .version("testString") + .ifMatch("testString") + .role(templateRoleModel) + .name("testString") + .description("testString") + .committed(true) + .build(); + + // Invoke replaceRoleTemplate() with a valid options model and verify the result + Response response = iamPolicyManagementService.replaceRoleTemplate(replaceRoleTemplateOptionsModel).execute(); + assertNotNull(response); + RoleTemplate responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "PUT"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, replaceRoleTemplatePath); + // Verify header parameters + assertEquals(request.getHeader("If-Match"), "testString"); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } + + // Test the replaceRoleTemplate operation with and without retries enabled + @Test + public void testReplaceRoleTemplateWRetries() throws Throwable { + iamPolicyManagementService.enableRetries(4, 30); + testReplaceRoleTemplateWOptions(); + + iamPolicyManagementService.disableRetries(); + testReplaceRoleTemplateWOptions(); + } + + // Test the replaceRoleTemplate operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testReplaceRoleTemplateNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + iamPolicyManagementService.replaceRoleTemplate(null).execute(); + } + + // Test the deleteRoleTemplateVersion operation with a valid options model parameter + @Test + public void testDeleteRoleTemplateVersionWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = ""; + String deleteRoleTemplateVersionPath = "/v1/role_templates/testString/versions/testString"; + server.enqueue(new MockResponse() + .setResponseCode(204) + .setBody(mockResponseBody)); + + // Construct an instance of the DeleteRoleTemplateVersionOptions model + DeleteRoleTemplateVersionOptions deleteRoleTemplateVersionOptionsModel = new DeleteRoleTemplateVersionOptions.Builder() + .roleTemplateId("testString") + .version("testString") + .build(); + + // Invoke deleteRoleTemplateVersion() with a valid options model and verify the result + Response response = iamPolicyManagementService.deleteRoleTemplateVersion(deleteRoleTemplateVersionOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + assertNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteRoleTemplateVersionPath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } + + // Test the deleteRoleTemplateVersion operation with and without retries enabled + @Test + public void testDeleteRoleTemplateVersionWRetries() throws Throwable { + iamPolicyManagementService.enableRetries(4, 30); + testDeleteRoleTemplateVersionWOptions(); + + iamPolicyManagementService.disableRetries(); + testDeleteRoleTemplateVersionWOptions(); + } + + // Test the deleteRoleTemplateVersion operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteRoleTemplateVersionNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + iamPolicyManagementService.deleteRoleTemplateVersion(null).execute(); + } + + // Test the getRoleTemplateVersion operation with a valid options model parameter + @Test + public void testGetRoleTemplateVersionWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = "{\"name\": \"name\", \"description\": \"description\", \"account_id\": \"accountId\", \"committed\": false, \"role\": {\"name\": \"name\", \"display_name\": \"displayName\", \"service_name\": \"serviceName\", \"description\": \"description\", \"actions\": [\"actions\"]}, \"id\": \"id\", \"href\": \"href\", \"created_at\": \"2019-01-01T12:00:00.000Z\", \"created_by_id\": \"createdById\", \"last_modified_at\": \"2019-01-01T12:00:00.000Z\", \"last_modified_by_id\": \"lastModifiedById\", \"version\": \"version\", \"state\": \"active\"}"; + String getRoleTemplateVersionPath = "/v1/role_templates/testString/versions/testString"; + server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the GetRoleTemplateVersionOptions model + GetRoleTemplateVersionOptions getRoleTemplateVersionOptionsModel = new GetRoleTemplateVersionOptions.Builder() + .roleTemplateId("testString") + .version("testString") + .build(); + + // Invoke getRoleTemplateVersion() with a valid options model and verify the result + Response response = iamPolicyManagementService.getRoleTemplateVersion(getRoleTemplateVersionOptionsModel).execute(); + assertNotNull(response); + RoleTemplate responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getRoleTemplateVersionPath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } + + // Test the getRoleTemplateVersion operation with and without retries enabled + @Test + public void testGetRoleTemplateVersionWRetries() throws Throwable { + iamPolicyManagementService.enableRetries(4, 30); + testGetRoleTemplateVersionWOptions(); + + iamPolicyManagementService.disableRetries(); + testGetRoleTemplateVersionWOptions(); + } + + // Test the getRoleTemplateVersion operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetRoleTemplateVersionNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + iamPolicyManagementService.getRoleTemplateVersion(null).execute(); + } + + // Test the commitRoleTemplate operation with a valid options model parameter + @Test + public void testCommitRoleTemplateWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = ""; + String commitRoleTemplatePath = "/v1/role_templates/testString/versions/testString/commit"; + server.enqueue(new MockResponse() + .setResponseCode(204) + .setBody(mockResponseBody)); + + // Construct an instance of the CommitRoleTemplateOptions model + CommitRoleTemplateOptions commitRoleTemplateOptionsModel = new CommitRoleTemplateOptions.Builder() + .roleTemplateId("testString") + .version("testString") + .build(); + + // Invoke commitRoleTemplate() with a valid options model and verify the result + Response response = iamPolicyManagementService.commitRoleTemplate(commitRoleTemplateOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + assertNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, commitRoleTemplatePath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } + + // Test the commitRoleTemplate operation with and without retries enabled + @Test + public void testCommitRoleTemplateWRetries() throws Throwable { + iamPolicyManagementService.enableRetries(4, 30); + testCommitRoleTemplateWOptions(); + + iamPolicyManagementService.disableRetries(); + testCommitRoleTemplateWOptions(); + } + + // Test the commitRoleTemplate operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCommitRoleTemplateNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + iamPolicyManagementService.commitRoleTemplate(null).execute(); + } + + // Test the listRoleAssignments operation with a valid options model parameter + @Test + public void testListRoleAssignmentsWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = "{\"limit\": 1, \"first\": {\"href\": \"href\"}, \"next\": {\"href\": \"href\", \"start\": \"start\"}, \"previous\": {\"href\": \"href\", \"start\": \"start\"}, \"assignments\": [{\"id\": \"id\", \"account_id\": \"accountId\", \"href\": \"href\", \"created_at\": \"2019-01-01T12:00:00.000Z\", \"created_by_id\": \"createdById\", \"last_modified_at\": \"2019-01-01T12:00:00.000Z\", \"last_modified_by_id\": \"lastModifiedById\", \"operation\": \"create\", \"resources\": [{\"target\": {\"type\": \"Account\", \"id\": \"id\"}, \"role\": {\"resource_created\": {\"id\": \"id\"}, \"error_message\": {\"name\": \"name\", \"errorCode\": \"errorCode\", \"message\": \"message\", \"code\": \"code\", \"errors\": [{\"code\": \"insufficent_permissions\", \"message\": \"message\", \"details\": {\"conflicts_with\": {\"etag\": \"etag\", \"role\": \"role\", \"policy\": \"policy\"}}, \"more_info\": \"moreInfo\"}]}}}], \"template\": {\"id\": \"id\", \"version\": \"version\"}, \"target\": {\"type\": \"Account\", \"id\": \"id\"}, \"status\": \"accepted\"}]}"; + String listRoleAssignmentsPath = "/v1/role_assignments"; + server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the ListRoleAssignmentsOptions model + ListRoleAssignmentsOptions listRoleAssignmentsOptionsModel = new ListRoleAssignmentsOptions.Builder() + .accountId("testString") + .acceptLanguage("default") + .templateId("testString") + .templateVersion("testString") + .limit(Long.valueOf("10")) + .start("testString") + .build(); + + // Invoke listRoleAssignments() with a valid options model and verify the result + Response response = iamPolicyManagementService.listRoleAssignments(listRoleAssignmentsOptionsModel).execute(); + assertNotNull(response); + RoleAssignmentCollection responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, listRoleAssignmentsPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("account_id"), "testString"); + assertEquals(query.get("template_id"), "testString"); + assertEquals(query.get("template_version"), "testString"); + assertEquals(Long.valueOf(query.get("limit")), Long.valueOf("10")); + assertEquals(query.get("start"), "testString"); + } + + // Test the listRoleAssignments operation with and without retries enabled + @Test + public void testListRoleAssignmentsWRetries() throws Throwable { + iamPolicyManagementService.enableRetries(4, 30); + testListRoleAssignmentsWOptions(); + + iamPolicyManagementService.disableRetries(); + testListRoleAssignmentsWOptions(); + } + + // Test the listRoleAssignments operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListRoleAssignmentsNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + iamPolicyManagementService.listRoleAssignments(null).execute(); + } + + // Test the listRoleAssignments operation using the RoleAssignmentsPager.getNext() method + @Test + public void testListRoleAssignmentsWithPagerGetNext() throws Throwable { + // Set up the two-page mock response. + String mockResponsePage1 = "{\"next\":{\"start\":\"1\"},\"assignments\":[{\"id\":\"id\",\"account_id\":\"accountId\",\"href\":\"href\",\"created_at\":\"2019-01-01T12:00:00.000Z\",\"created_by_id\":\"createdById\",\"last_modified_at\":\"2019-01-01T12:00:00.000Z\",\"last_modified_by_id\":\"lastModifiedById\",\"operation\":\"create\",\"resources\":[{\"target\":{\"type\":\"Account\",\"id\":\"id\"},\"role\":{\"resource_created\":{\"id\":\"id\"},\"error_message\":{\"name\":\"name\",\"errorCode\":\"errorCode\",\"message\":\"message\",\"code\":\"code\",\"errors\":[{\"code\":\"insufficent_permissions\",\"message\":\"message\",\"details\":{\"conflicts_with\":{\"etag\":\"etag\",\"role\":\"role\",\"policy\":\"policy\"}},\"more_info\":\"moreInfo\"}]}}}],\"template\":{\"id\":\"id\",\"version\":\"version\"},\"target\":{\"type\":\"Account\",\"id\":\"id\"},\"status\":\"accepted\"}],\"total_count\":2,\"limit\":1}"; + String mockResponsePage2 = "{\"assignments\":[{\"id\":\"id\",\"account_id\":\"accountId\",\"href\":\"href\",\"created_at\":\"2019-01-01T12:00:00.000Z\",\"created_by_id\":\"createdById\",\"last_modified_at\":\"2019-01-01T12:00:00.000Z\",\"last_modified_by_id\":\"lastModifiedById\",\"operation\":\"create\",\"resources\":[{\"target\":{\"type\":\"Account\",\"id\":\"id\"},\"role\":{\"resource_created\":{\"id\":\"id\"},\"error_message\":{\"name\":\"name\",\"errorCode\":\"errorCode\",\"message\":\"message\",\"code\":\"code\",\"errors\":[{\"code\":\"insufficent_permissions\",\"message\":\"message\",\"details\":{\"conflicts_with\":{\"etag\":\"etag\",\"role\":\"role\",\"policy\":\"policy\"}},\"more_info\":\"moreInfo\"}]}}}],\"template\":{\"id\":\"id\",\"version\":\"version\"},\"target\":{\"type\":\"Account\",\"id\":\"id\"},\"status\":\"accepted\"}],\"total_count\":2,\"limit\":1}"; + server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponsePage1)); + server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponsePage2)); + server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(400) + .setBody("{\"message\": \"No more results available!\"}")); + + ListRoleAssignmentsOptions listRoleAssignmentsOptions = new ListRoleAssignmentsOptions.Builder() + .accountId("testString") + .acceptLanguage("default") + .templateId("testString") + .templateVersion("testString") + .limit(Long.valueOf("10")) + .build(); + + List allResults = new ArrayList<>(); + RoleAssignmentsPager pager = new RoleAssignmentsPager(iamPolicyManagementService, listRoleAssignmentsOptions); + while (pager.hasNext()) { + List nextPage = pager.getNext(); + assertNotNull(nextPage); + allResults.addAll(nextPage); + } + assertEquals(allResults.size(), 2); + } + + // Test the listRoleAssignments operation using the RoleAssignmentsPager.getAll() method + @Test + public void testListRoleAssignmentsWithPagerGetAll() throws Throwable { + // Set up the two-page mock response. + String mockResponsePage1 = "{\"next\":{\"start\":\"1\"},\"assignments\":[{\"id\":\"id\",\"account_id\":\"accountId\",\"href\":\"href\",\"created_at\":\"2019-01-01T12:00:00.000Z\",\"created_by_id\":\"createdById\",\"last_modified_at\":\"2019-01-01T12:00:00.000Z\",\"last_modified_by_id\":\"lastModifiedById\",\"operation\":\"create\",\"resources\":[{\"target\":{\"type\":\"Account\",\"id\":\"id\"},\"role\":{\"resource_created\":{\"id\":\"id\"},\"error_message\":{\"name\":\"name\",\"errorCode\":\"errorCode\",\"message\":\"message\",\"code\":\"code\",\"errors\":[{\"code\":\"insufficent_permissions\",\"message\":\"message\",\"details\":{\"conflicts_with\":{\"etag\":\"etag\",\"role\":\"role\",\"policy\":\"policy\"}},\"more_info\":\"moreInfo\"}]}}}],\"template\":{\"id\":\"id\",\"version\":\"version\"},\"target\":{\"type\":\"Account\",\"id\":\"id\"},\"status\":\"accepted\"}],\"total_count\":2,\"limit\":1}"; + String mockResponsePage2 = "{\"assignments\":[{\"id\":\"id\",\"account_id\":\"accountId\",\"href\":\"href\",\"created_at\":\"2019-01-01T12:00:00.000Z\",\"created_by_id\":\"createdById\",\"last_modified_at\":\"2019-01-01T12:00:00.000Z\",\"last_modified_by_id\":\"lastModifiedById\",\"operation\":\"create\",\"resources\":[{\"target\":{\"type\":\"Account\",\"id\":\"id\"},\"role\":{\"resource_created\":{\"id\":\"id\"},\"error_message\":{\"name\":\"name\",\"errorCode\":\"errorCode\",\"message\":\"message\",\"code\":\"code\",\"errors\":[{\"code\":\"insufficent_permissions\",\"message\":\"message\",\"details\":{\"conflicts_with\":{\"etag\":\"etag\",\"role\":\"role\",\"policy\":\"policy\"}},\"more_info\":\"moreInfo\"}]}}}],\"template\":{\"id\":\"id\",\"version\":\"version\"},\"target\":{\"type\":\"Account\",\"id\":\"id\"},\"status\":\"accepted\"}],\"total_count\":2,\"limit\":1}"; + server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponsePage1)); + server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponsePage2)); + server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(400) + .setBody("{\"message\": \"No more results available!\"}")); + + ListRoleAssignmentsOptions listRoleAssignmentsOptions = new ListRoleAssignmentsOptions.Builder() + .accountId("testString") + .acceptLanguage("default") + .templateId("testString") + .templateVersion("testString") + .limit(Long.valueOf("10")) + .build(); + + RoleAssignmentsPager pager = new RoleAssignmentsPager(iamPolicyManagementService, listRoleAssignmentsOptions); + List allResults = pager.getAll(); + assertNotNull(allResults); + assertEquals(allResults.size(), 2); + } + + // Test the createRoleTemplateAssignment operation with a valid options model parameter + @Test + public void testCreateRoleTemplateAssignmentWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = "{\"limit\": 1, \"first\": {\"href\": \"href\"}, \"next\": {\"href\": \"href\", \"start\": \"start\"}, \"previous\": {\"href\": \"href\", \"start\": \"start\"}, \"assignments\": [{\"id\": \"id\", \"account_id\": \"accountId\", \"href\": \"href\", \"created_at\": \"2019-01-01T12:00:00.000Z\", \"created_by_id\": \"createdById\", \"last_modified_at\": \"2019-01-01T12:00:00.000Z\", \"last_modified_by_id\": \"lastModifiedById\", \"operation\": \"create\", \"resources\": [{\"target\": {\"type\": \"Account\", \"id\": \"id\"}, \"role\": {\"resource_created\": {\"id\": \"id\"}, \"error_message\": {\"name\": \"name\", \"errorCode\": \"errorCode\", \"message\": \"message\", \"code\": \"code\", \"errors\": [{\"code\": \"insufficent_permissions\", \"message\": \"message\", \"details\": {\"conflicts_with\": {\"etag\": \"etag\", \"role\": \"role\", \"policy\": \"policy\"}}, \"more_info\": \"moreInfo\"}]}}}], \"template\": {\"id\": \"id\", \"version\": \"version\"}, \"target\": {\"type\": \"Account\", \"id\": \"id\"}, \"status\": \"accepted\"}]}"; + String createRoleTemplateAssignmentPath = "/v1/role_assignments"; + server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(201) + .setBody(mockResponseBody)); + + // Construct an instance of the AssignmentTargetDetails model + AssignmentTargetDetails assignmentTargetDetailsModel = new AssignmentTargetDetails.Builder() + .type("Account") + .id("testString") + .build(); + + // Construct an instance of the RoleAssignmentTemplate model + RoleAssignmentTemplate roleAssignmentTemplateModel = new RoleAssignmentTemplate.Builder() + .id("testString") + .version("testString") + .build(); + + // Construct an instance of the CreateRoleTemplateAssignmentOptions model + CreateRoleTemplateAssignmentOptions createRoleTemplateAssignmentOptionsModel = new CreateRoleTemplateAssignmentOptions.Builder() + .target(assignmentTargetDetailsModel) + .templates(java.util.Arrays.asList(roleAssignmentTemplateModel)) + .acceptLanguage("default") + .build(); + + // Invoke createRoleTemplateAssignment() with a valid options model and verify the result + Response response = iamPolicyManagementService.createRoleTemplateAssignment(createRoleTemplateAssignmentOptionsModel).execute(); + assertNotNull(response); + RoleAssignmentCollection responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, createRoleTemplateAssignmentPath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } + + // Test the createRoleTemplateAssignment operation with and without retries enabled + @Test + public void testCreateRoleTemplateAssignmentWRetries() throws Throwable { + iamPolicyManagementService.enableRetries(4, 30); + testCreateRoleTemplateAssignmentWOptions(); + + iamPolicyManagementService.disableRetries(); + testCreateRoleTemplateAssignmentWOptions(); + } + + // Test the createRoleTemplateAssignment operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateRoleTemplateAssignmentNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + iamPolicyManagementService.createRoleTemplateAssignment(null).execute(); + } + + // Test the getRoleAssignment operation with a valid options model parameter + @Test + public void testGetRoleAssignmentWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = "{\"id\": \"id\", \"account_id\": \"accountId\", \"href\": \"href\", \"created_at\": \"2019-01-01T12:00:00.000Z\", \"created_by_id\": \"createdById\", \"last_modified_at\": \"2019-01-01T12:00:00.000Z\", \"last_modified_by_id\": \"lastModifiedById\", \"operation\": \"create\", \"resources\": [{\"target\": {\"type\": \"Account\", \"id\": \"id\"}, \"role\": {\"resource_created\": {\"id\": \"id\"}, \"error_message\": {\"name\": \"name\", \"errorCode\": \"errorCode\", \"message\": \"message\", \"code\": \"code\", \"errors\": [{\"code\": \"insufficent_permissions\", \"message\": \"message\", \"details\": {\"conflicts_with\": {\"etag\": \"etag\", \"role\": \"role\", \"policy\": \"policy\"}}, \"more_info\": \"moreInfo\"}]}}}], \"template\": {\"id\": \"id\", \"version\": \"version\"}, \"target\": {\"type\": \"Account\", \"id\": \"id\"}, \"status\": \"accepted\"}"; + String getRoleAssignmentPath = "/v1/role_assignments/testString"; + server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the GetRoleAssignmentOptions model + GetRoleAssignmentOptions getRoleAssignmentOptionsModel = new GetRoleAssignmentOptions.Builder() + .assignmentId("testString") + .build(); + + // Invoke getRoleAssignment() with a valid options model and verify the result + Response response = iamPolicyManagementService.getRoleAssignment(getRoleAssignmentOptionsModel).execute(); + assertNotNull(response); + RoleAssignment responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getRoleAssignmentPath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } + + // Test the getRoleAssignment operation with and without retries enabled + @Test + public void testGetRoleAssignmentWRetries() throws Throwable { + iamPolicyManagementService.enableRetries(4, 30); + testGetRoleAssignmentWOptions(); + + iamPolicyManagementService.disableRetries(); + testGetRoleAssignmentWOptions(); + } + + // Test the getRoleAssignment operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetRoleAssignmentNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + iamPolicyManagementService.getRoleAssignment(null).execute(); + } + + // Test the updateRoleAssignment operation with a valid options model parameter + @Test + public void testUpdateRoleAssignmentWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = "{\"id\": \"id\", \"account_id\": \"accountId\", \"href\": \"href\", \"created_at\": \"2019-01-01T12:00:00.000Z\", \"created_by_id\": \"createdById\", \"last_modified_at\": \"2019-01-01T12:00:00.000Z\", \"last_modified_by_id\": \"lastModifiedById\", \"operation\": \"create\", \"resources\": [{\"target\": {\"type\": \"Account\", \"id\": \"id\"}, \"role\": {\"resource_created\": {\"id\": \"id\"}, \"error_message\": {\"name\": \"name\", \"errorCode\": \"errorCode\", \"message\": \"message\", \"code\": \"code\", \"errors\": [{\"code\": \"insufficent_permissions\", \"message\": \"message\", \"details\": {\"conflicts_with\": {\"etag\": \"etag\", \"role\": \"role\", \"policy\": \"policy\"}}, \"more_info\": \"moreInfo\"}]}}}], \"template\": {\"id\": \"id\", \"version\": \"version\"}, \"target\": {\"type\": \"Account\", \"id\": \"id\"}, \"status\": \"accepted\"}"; + String updateRoleAssignmentPath = "/v1/role_assignments/testString"; + server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the UpdateRoleAssignmentOptions model + UpdateRoleAssignmentOptions updateRoleAssignmentOptionsModel = new UpdateRoleAssignmentOptions.Builder() + .assignmentId("testString") + .ifMatch("testString") + .templateVersion("testString") + .build(); + + // Invoke updateRoleAssignment() with a valid options model and verify the result + Response response = iamPolicyManagementService.updateRoleAssignment(updateRoleAssignmentOptionsModel).execute(); + assertNotNull(response); + RoleAssignment responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "PATCH"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, updateRoleAssignmentPath); + // Verify header parameters + assertEquals(request.getHeader("If-Match"), "testString"); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } + + // Test the updateRoleAssignment operation with and without retries enabled + @Test + public void testUpdateRoleAssignmentWRetries() throws Throwable { + iamPolicyManagementService.enableRetries(4, 30); + testUpdateRoleAssignmentWOptions(); + + iamPolicyManagementService.disableRetries(); + testUpdateRoleAssignmentWOptions(); + } + + // Test the updateRoleAssignment operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateRoleAssignmentNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + iamPolicyManagementService.updateRoleAssignment(null).execute(); + } + + // Test the deleteRoleAssignment operation with a valid options model parameter + @Test + public void testDeleteRoleAssignmentWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = ""; + String deleteRoleAssignmentPath = "/v1/role_assignments/testString"; + server.enqueue(new MockResponse() + .setResponseCode(204) + .setBody(mockResponseBody)); + + // Construct an instance of the DeleteRoleAssignmentOptions model + DeleteRoleAssignmentOptions deleteRoleAssignmentOptionsModel = new DeleteRoleAssignmentOptions.Builder() + .assignmentId("testString") + .build(); + + // Invoke deleteRoleAssignment() with a valid options model and verify the result + Response response = iamPolicyManagementService.deleteRoleAssignment(deleteRoleAssignmentOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + assertNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteRoleAssignmentPath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } + + // Test the deleteRoleAssignment operation with and without retries enabled + @Test + public void testDeleteRoleAssignmentWRetries() throws Throwable { + iamPolicyManagementService.enableRetries(4, 30); + testDeleteRoleAssignmentWOptions(); + + iamPolicyManagementService.disableRetries(); + testDeleteRoleAssignmentWOptions(); + } + + // Test the deleteRoleAssignment operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteRoleAssignmentNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + iamPolicyManagementService.deleteRoleAssignment(null).execute(); + } + // Perform setup needed before each test method @BeforeMethod public void beforeEachTest() { diff --git a/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ActionControlAssignmentResourceActionControlTest.java b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ActionControlAssignmentResourceActionControlTest.java index 08434f06148..cb53bc44d1c 100644 --- a/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ActionControlAssignmentResourceActionControlTest.java +++ b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ActionControlAssignmentResourceActionControlTest.java @@ -15,10 +15,10 @@ import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ActionControlAssignmentResourceActionControl; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ActionControlAssignmentResourceCreated; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.AssignmentResourceError; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ConflictsWith; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ErrorDetails; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ErrorObject; -import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ErrorResponse; import com.ibm.cloud.platform_services.iam_policy_management.v1.utils.TestUtilities; import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; import java.io.InputStream; diff --git a/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ActionControlAssignmentResourceTest.java b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ActionControlAssignmentResourceTest.java index e1c4b47717f..eaa560dce78 100644 --- a/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ActionControlAssignmentResourceTest.java +++ b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ActionControlAssignmentResourceTest.java @@ -16,11 +16,11 @@ import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ActionControlAssignmentResource; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ActionControlAssignmentResourceActionControl; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ActionControlAssignmentResourceCreated; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.AssignmentResourceError; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.AssignmentTargetDetails; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ConflictsWith; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ErrorDetails; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ErrorObject; -import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ErrorResponse; import com.ibm.cloud.platform_services.iam_policy_management.v1.utils.TestUtilities; import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; import java.io.InputStream; diff --git a/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/AssignmentResourceErrorTest.java b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/AssignmentResourceErrorTest.java new file mode 100644 index 00000000000..81e3799a42c --- /dev/null +++ b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/AssignmentResourceErrorTest.java @@ -0,0 +1,44 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.iam_policy_management.v1.model; + +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.AssignmentResourceError; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ConflictsWith; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ErrorDetails; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ErrorObject; +import com.ibm.cloud.platform_services.iam_policy_management.v1.utils.TestUtilities; +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; +import static org.testng.Assert.*; + +/** + * Unit test class for the AssignmentResourceError model. + */ +public class AssignmentResourceErrorTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testAssignmentResourceError() throws Throwable { + AssignmentResourceError assignmentResourceErrorModel = new AssignmentResourceError(); + assertNull(assignmentResourceErrorModel.getName()); + assertNull(assignmentResourceErrorModel.getErrorCode()); + assertNull(assignmentResourceErrorModel.getMessage()); + assertNull(assignmentResourceErrorModel.getCode()); + assertNull(assignmentResourceErrorModel.getErrors()); + } +} \ No newline at end of file diff --git a/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/CommitRoleTemplateOptionsTest.java b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/CommitRoleTemplateOptionsTest.java new file mode 100644 index 00000000000..09c48b8e80e --- /dev/null +++ b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/CommitRoleTemplateOptionsTest.java @@ -0,0 +1,47 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.iam_policy_management.v1.model; + +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.CommitRoleTemplateOptions; +import com.ibm.cloud.platform_services.iam_policy_management.v1.utils.TestUtilities; +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; +import static org.testng.Assert.*; + +/** + * Unit test class for the CommitRoleTemplateOptions model. + */ +public class CommitRoleTemplateOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCommitRoleTemplateOptions() throws Throwable { + CommitRoleTemplateOptions commitRoleTemplateOptionsModel = new CommitRoleTemplateOptions.Builder() + .roleTemplateId("testString") + .version("testString") + .build(); + assertEquals(commitRoleTemplateOptionsModel.roleTemplateId(), "testString"); + assertEquals(commitRoleTemplateOptionsModel.version(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCommitRoleTemplateOptionsError() throws Throwable { + new CommitRoleTemplateOptions.Builder().build(); + } + +} \ No newline at end of file diff --git a/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/CreateRoleTemplateAssignmentOptionsTest.java b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/CreateRoleTemplateAssignmentOptionsTest.java new file mode 100644 index 00000000000..bff414389a5 --- /dev/null +++ b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/CreateRoleTemplateAssignmentOptionsTest.java @@ -0,0 +1,65 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.iam_policy_management.v1.model; + +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.AssignmentTargetDetails; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.CreateRoleTemplateAssignmentOptions; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.RoleAssignmentTemplate; +import com.ibm.cloud.platform_services.iam_policy_management.v1.utils.TestUtilities; +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; +import static org.testng.Assert.*; + +/** + * Unit test class for the CreateRoleTemplateAssignmentOptions model. + */ +public class CreateRoleTemplateAssignmentOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCreateRoleTemplateAssignmentOptions() throws Throwable { + AssignmentTargetDetails assignmentTargetDetailsModel = new AssignmentTargetDetails.Builder() + .type("Account") + .id("testString") + .build(); + assertEquals(assignmentTargetDetailsModel.type(), "Account"); + assertEquals(assignmentTargetDetailsModel.id(), "testString"); + + RoleAssignmentTemplate roleAssignmentTemplateModel = new RoleAssignmentTemplate.Builder() + .id("testString") + .version("testString") + .build(); + assertEquals(roleAssignmentTemplateModel.id(), "testString"); + assertEquals(roleAssignmentTemplateModel.version(), "testString"); + + CreateRoleTemplateAssignmentOptions createRoleTemplateAssignmentOptionsModel = new CreateRoleTemplateAssignmentOptions.Builder() + .target(assignmentTargetDetailsModel) + .templates(java.util.Arrays.asList(roleAssignmentTemplateModel)) + .acceptLanguage("default") + .build(); + assertEquals(createRoleTemplateAssignmentOptionsModel.target(), assignmentTargetDetailsModel); + assertEquals(createRoleTemplateAssignmentOptionsModel.templates(), java.util.Arrays.asList(roleAssignmentTemplateModel)); + assertEquals(createRoleTemplateAssignmentOptionsModel.acceptLanguage(), "default"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateRoleTemplateAssignmentOptionsError() throws Throwable { + new CreateRoleTemplateAssignmentOptions.Builder().build(); + } + +} \ No newline at end of file diff --git a/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/CreateRoleTemplateOptionsTest.java b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/CreateRoleTemplateOptionsTest.java new file mode 100644 index 00000000000..b2d2d02d168 --- /dev/null +++ b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/CreateRoleTemplateOptionsTest.java @@ -0,0 +1,69 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.iam_policy_management.v1.model; + +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.CreateRoleTemplateOptions; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.TemplateRole; +import com.ibm.cloud.platform_services.iam_policy_management.v1.utils.TestUtilities; +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; +import static org.testng.Assert.*; + +/** + * Unit test class for the CreateRoleTemplateOptions model. + */ +public class CreateRoleTemplateOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCreateRoleTemplateOptions() throws Throwable { + TemplateRole templateRoleModel = new TemplateRole.Builder() + .name("testString") + .displayName("testString") + .serviceName("testString") + .description("testString") + .actions(java.util.Arrays.asList("testString")) + .build(); + assertEquals(templateRoleModel.name(), "testString"); + assertEquals(templateRoleModel.displayName(), "testString"); + assertEquals(templateRoleModel.serviceName(), "testString"); + assertEquals(templateRoleModel.description(), "testString"); + assertEquals(templateRoleModel.actions(), java.util.Arrays.asList("testString")); + + CreateRoleTemplateOptions createRoleTemplateOptionsModel = new CreateRoleTemplateOptions.Builder() + .name("testString") + .accountId("testString") + .description("testString") + .committed(true) + .role(templateRoleModel) + .acceptLanguage("default") + .build(); + assertEquals(createRoleTemplateOptionsModel.name(), "testString"); + assertEquals(createRoleTemplateOptionsModel.accountId(), "testString"); + assertEquals(createRoleTemplateOptionsModel.description(), "testString"); + assertEquals(createRoleTemplateOptionsModel.committed(), Boolean.valueOf(true)); + assertEquals(createRoleTemplateOptionsModel.role(), templateRoleModel); + assertEquals(createRoleTemplateOptionsModel.acceptLanguage(), "default"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateRoleTemplateOptionsError() throws Throwable { + new CreateRoleTemplateOptions.Builder().build(); + } + +} \ No newline at end of file diff --git a/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/CreateRoleTemplateVersionOptionsTest.java b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/CreateRoleTemplateVersionOptionsTest.java new file mode 100644 index 00000000000..1f746d295f1 --- /dev/null +++ b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/CreateRoleTemplateVersionOptionsTest.java @@ -0,0 +1,67 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.iam_policy_management.v1.model; + +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.CreateRoleTemplateVersionOptions; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.TemplateRole; +import com.ibm.cloud.platform_services.iam_policy_management.v1.utils.TestUtilities; +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; +import static org.testng.Assert.*; + +/** + * Unit test class for the CreateRoleTemplateVersionOptions model. + */ +public class CreateRoleTemplateVersionOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCreateRoleTemplateVersionOptions() throws Throwable { + TemplateRole templateRoleModel = new TemplateRole.Builder() + .name("testString") + .displayName("testString") + .serviceName("testString") + .description("testString") + .actions(java.util.Arrays.asList("testString")) + .build(); + assertEquals(templateRoleModel.name(), "testString"); + assertEquals(templateRoleModel.displayName(), "testString"); + assertEquals(templateRoleModel.serviceName(), "testString"); + assertEquals(templateRoleModel.description(), "testString"); + assertEquals(templateRoleModel.actions(), java.util.Arrays.asList("testString")); + + CreateRoleTemplateVersionOptions createRoleTemplateVersionOptionsModel = new CreateRoleTemplateVersionOptions.Builder() + .roleTemplateId("testString") + .role(templateRoleModel) + .name("testString") + .description("testString") + .committed(true) + .build(); + assertEquals(createRoleTemplateVersionOptionsModel.roleTemplateId(), "testString"); + assertEquals(createRoleTemplateVersionOptionsModel.role(), templateRoleModel); + assertEquals(createRoleTemplateVersionOptionsModel.name(), "testString"); + assertEquals(createRoleTemplateVersionOptionsModel.description(), "testString"); + assertEquals(createRoleTemplateVersionOptionsModel.committed(), Boolean.valueOf(true)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateRoleTemplateVersionOptionsError() throws Throwable { + new CreateRoleTemplateVersionOptions.Builder().build(); + } + +} \ No newline at end of file diff --git a/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/DeleteRoleAssignmentOptionsTest.java b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/DeleteRoleAssignmentOptionsTest.java new file mode 100644 index 00000000000..7f9b614304f --- /dev/null +++ b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/DeleteRoleAssignmentOptionsTest.java @@ -0,0 +1,45 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.iam_policy_management.v1.model; + +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.DeleteRoleAssignmentOptions; +import com.ibm.cloud.platform_services.iam_policy_management.v1.utils.TestUtilities; +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; +import static org.testng.Assert.*; + +/** + * Unit test class for the DeleteRoleAssignmentOptions model. + */ +public class DeleteRoleAssignmentOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteRoleAssignmentOptions() throws Throwable { + DeleteRoleAssignmentOptions deleteRoleAssignmentOptionsModel = new DeleteRoleAssignmentOptions.Builder() + .assignmentId("testString") + .build(); + assertEquals(deleteRoleAssignmentOptionsModel.assignmentId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteRoleAssignmentOptionsError() throws Throwable { + new DeleteRoleAssignmentOptions.Builder().build(); + } + +} \ No newline at end of file diff --git a/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/DeleteRoleTemplateOptionsTest.java b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/DeleteRoleTemplateOptionsTest.java new file mode 100644 index 00000000000..3fc04286ed3 --- /dev/null +++ b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/DeleteRoleTemplateOptionsTest.java @@ -0,0 +1,45 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.iam_policy_management.v1.model; + +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.DeleteRoleTemplateOptions; +import com.ibm.cloud.platform_services.iam_policy_management.v1.utils.TestUtilities; +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; +import static org.testng.Assert.*; + +/** + * Unit test class for the DeleteRoleTemplateOptions model. + */ +public class DeleteRoleTemplateOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteRoleTemplateOptions() throws Throwable { + DeleteRoleTemplateOptions deleteRoleTemplateOptionsModel = new DeleteRoleTemplateOptions.Builder() + .roleTemplateId("testString") + .build(); + assertEquals(deleteRoleTemplateOptionsModel.roleTemplateId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteRoleTemplateOptionsError() throws Throwable { + new DeleteRoleTemplateOptions.Builder().build(); + } + +} \ No newline at end of file diff --git a/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/DeleteRoleTemplateVersionOptionsTest.java b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/DeleteRoleTemplateVersionOptionsTest.java new file mode 100644 index 00000000000..ff652fa335c --- /dev/null +++ b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/DeleteRoleTemplateVersionOptionsTest.java @@ -0,0 +1,47 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.iam_policy_management.v1.model; + +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.DeleteRoleTemplateVersionOptions; +import com.ibm.cloud.platform_services.iam_policy_management.v1.utils.TestUtilities; +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; +import static org.testng.Assert.*; + +/** + * Unit test class for the DeleteRoleTemplateVersionOptions model. + */ +public class DeleteRoleTemplateVersionOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteRoleTemplateVersionOptions() throws Throwable { + DeleteRoleTemplateVersionOptions deleteRoleTemplateVersionOptionsModel = new DeleteRoleTemplateVersionOptions.Builder() + .roleTemplateId("testString") + .version("testString") + .build(); + assertEquals(deleteRoleTemplateVersionOptionsModel.roleTemplateId(), "testString"); + assertEquals(deleteRoleTemplateVersionOptionsModel.version(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteRoleTemplateVersionOptionsError() throws Throwable { + new DeleteRoleTemplateVersionOptions.Builder().build(); + } + +} \ No newline at end of file diff --git a/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/GetRoleAssignmentOptionsTest.java b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/GetRoleAssignmentOptionsTest.java new file mode 100644 index 00000000000..0c1f6b2bb5a --- /dev/null +++ b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/GetRoleAssignmentOptionsTest.java @@ -0,0 +1,45 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.iam_policy_management.v1.model; + +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.GetRoleAssignmentOptions; +import com.ibm.cloud.platform_services.iam_policy_management.v1.utils.TestUtilities; +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; +import static org.testng.Assert.*; + +/** + * Unit test class for the GetRoleAssignmentOptions model. + */ +public class GetRoleAssignmentOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetRoleAssignmentOptions() throws Throwable { + GetRoleAssignmentOptions getRoleAssignmentOptionsModel = new GetRoleAssignmentOptions.Builder() + .assignmentId("testString") + .build(); + assertEquals(getRoleAssignmentOptionsModel.assignmentId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetRoleAssignmentOptionsError() throws Throwable { + new GetRoleAssignmentOptions.Builder().build(); + } + +} \ No newline at end of file diff --git a/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/GetRoleTemplateOptionsTest.java b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/GetRoleTemplateOptionsTest.java new file mode 100644 index 00000000000..3c10b5207dc --- /dev/null +++ b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/GetRoleTemplateOptionsTest.java @@ -0,0 +1,47 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.iam_policy_management.v1.model; + +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.GetRoleTemplateOptions; +import com.ibm.cloud.platform_services.iam_policy_management.v1.utils.TestUtilities; +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; +import static org.testng.Assert.*; + +/** + * Unit test class for the GetRoleTemplateOptions model. + */ +public class GetRoleTemplateOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetRoleTemplateOptions() throws Throwable { + GetRoleTemplateOptions getRoleTemplateOptionsModel = new GetRoleTemplateOptions.Builder() + .roleTemplateId("testString") + .state("active") + .build(); + assertEquals(getRoleTemplateOptionsModel.roleTemplateId(), "testString"); + assertEquals(getRoleTemplateOptionsModel.state(), "active"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetRoleTemplateOptionsError() throws Throwable { + new GetRoleTemplateOptions.Builder().build(); + } + +} \ No newline at end of file diff --git a/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/GetRoleTemplateVersionOptionsTest.java b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/GetRoleTemplateVersionOptionsTest.java new file mode 100644 index 00000000000..3bd5d278630 --- /dev/null +++ b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/GetRoleTemplateVersionOptionsTest.java @@ -0,0 +1,47 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.iam_policy_management.v1.model; + +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.GetRoleTemplateVersionOptions; +import com.ibm.cloud.platform_services.iam_policy_management.v1.utils.TestUtilities; +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; +import static org.testng.Assert.*; + +/** + * Unit test class for the GetRoleTemplateVersionOptions model. + */ +public class GetRoleTemplateVersionOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetRoleTemplateVersionOptions() throws Throwable { + GetRoleTemplateVersionOptions getRoleTemplateVersionOptionsModel = new GetRoleTemplateVersionOptions.Builder() + .roleTemplateId("testString") + .version("testString") + .build(); + assertEquals(getRoleTemplateVersionOptionsModel.roleTemplateId(), "testString"); + assertEquals(getRoleTemplateVersionOptionsModel.version(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetRoleTemplateVersionOptionsError() throws Throwable { + new GetRoleTemplateVersionOptions.Builder().build(); + } + +} \ No newline at end of file diff --git a/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ListRoleAssignmentsOptionsTest.java b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ListRoleAssignmentsOptionsTest.java new file mode 100644 index 00000000000..bd82df9bfd5 --- /dev/null +++ b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ListRoleAssignmentsOptionsTest.java @@ -0,0 +1,55 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.iam_policy_management.v1.model; + +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ListRoleAssignmentsOptions; +import com.ibm.cloud.platform_services.iam_policy_management.v1.utils.TestUtilities; +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; +import static org.testng.Assert.*; + +/** + * Unit test class for the ListRoleAssignmentsOptions model. + */ +public class ListRoleAssignmentsOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListRoleAssignmentsOptions() throws Throwable { + ListRoleAssignmentsOptions listRoleAssignmentsOptionsModel = new ListRoleAssignmentsOptions.Builder() + .accountId("testString") + .acceptLanguage("default") + .templateId("testString") + .templateVersion("testString") + .limit(Long.valueOf("50")) + .start("testString") + .build(); + assertEquals(listRoleAssignmentsOptionsModel.accountId(), "testString"); + assertEquals(listRoleAssignmentsOptionsModel.acceptLanguage(), "default"); + assertEquals(listRoleAssignmentsOptionsModel.templateId(), "testString"); + assertEquals(listRoleAssignmentsOptionsModel.templateVersion(), "testString"); + assertEquals(listRoleAssignmentsOptionsModel.limit(), Long.valueOf("50")); + assertEquals(listRoleAssignmentsOptionsModel.start(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListRoleAssignmentsOptionsError() throws Throwable { + new ListRoleAssignmentsOptions.Builder().build(); + } + +} \ No newline at end of file diff --git a/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ListRoleTemplateVersionsOptionsTest.java b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ListRoleTemplateVersionsOptionsTest.java new file mode 100644 index 00000000000..2e89527b653 --- /dev/null +++ b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ListRoleTemplateVersionsOptionsTest.java @@ -0,0 +1,51 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.iam_policy_management.v1.model; + +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ListRoleTemplateVersionsOptions; +import com.ibm.cloud.platform_services.iam_policy_management.v1.utils.TestUtilities; +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; +import static org.testng.Assert.*; + +/** + * Unit test class for the ListRoleTemplateVersionsOptions model. + */ +public class ListRoleTemplateVersionsOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListRoleTemplateVersionsOptions() throws Throwable { + ListRoleTemplateVersionsOptions listRoleTemplateVersionsOptionsModel = new ListRoleTemplateVersionsOptions.Builder() + .roleTemplateId("testString") + .state("active") + .limit(Long.valueOf("50")) + .start("testString") + .build(); + assertEquals(listRoleTemplateVersionsOptionsModel.roleTemplateId(), "testString"); + assertEquals(listRoleTemplateVersionsOptionsModel.state(), "active"); + assertEquals(listRoleTemplateVersionsOptionsModel.limit(), Long.valueOf("50")); + assertEquals(listRoleTemplateVersionsOptionsModel.start(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListRoleTemplateVersionsOptionsError() throws Throwable { + new ListRoleTemplateVersionsOptions.Builder().build(); + } + +} \ No newline at end of file diff --git a/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ListRoleTemplatesOptionsTest.java b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ListRoleTemplatesOptionsTest.java new file mode 100644 index 00000000000..21d23a7be0f --- /dev/null +++ b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ListRoleTemplatesOptionsTest.java @@ -0,0 +1,59 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.iam_policy_management.v1.model; + +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ListRoleTemplatesOptions; +import com.ibm.cloud.platform_services.iam_policy_management.v1.utils.TestUtilities; +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; +import static org.testng.Assert.*; + +/** + * Unit test class for the ListRoleTemplatesOptions model. + */ +public class ListRoleTemplatesOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListRoleTemplatesOptions() throws Throwable { + ListRoleTemplatesOptions listRoleTemplatesOptionsModel = new ListRoleTemplatesOptions.Builder() + .accountId("testString") + .acceptLanguage("default") + .name("testString") + .roleName("testString") + .roleServiceName("testString") + .state("active") + .limit(Long.valueOf("50")) + .start("testString") + .build(); + assertEquals(listRoleTemplatesOptionsModel.accountId(), "testString"); + assertEquals(listRoleTemplatesOptionsModel.acceptLanguage(), "default"); + assertEquals(listRoleTemplatesOptionsModel.name(), "testString"); + assertEquals(listRoleTemplatesOptionsModel.roleName(), "testString"); + assertEquals(listRoleTemplatesOptionsModel.roleServiceName(), "testString"); + assertEquals(listRoleTemplatesOptionsModel.state(), "active"); + assertEquals(listRoleTemplatesOptionsModel.limit(), Long.valueOf("50")); + assertEquals(listRoleTemplatesOptionsModel.start(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListRoleTemplatesOptionsError() throws Throwable { + new ListRoleTemplatesOptions.Builder().build(); + } + +} \ No newline at end of file diff --git a/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyAssignmentResourcePolicyTest.java b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyAssignmentResourcePolicyTest.java index fac0f520d53..d5b05ede760 100644 --- a/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyAssignmentResourcePolicyTest.java +++ b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyAssignmentResourcePolicyTest.java @@ -14,10 +14,10 @@ package com.ibm.cloud.platform_services.iam_policy_management.v1.model; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.AssignmentResourceCreated; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.AssignmentResourceError; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ConflictsWith; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ErrorDetails; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ErrorObject; -import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ErrorResponse; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.PolicyAssignmentResourcePolicy; import com.ibm.cloud.platform_services.iam_policy_management.v1.utils.TestUtilities; import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; diff --git a/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyAssignmentResourcesTest.java b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyAssignmentResourcesTest.java index 0683c488336..8b146425617 100644 --- a/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyAssignmentResourcesTest.java +++ b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyAssignmentResourcesTest.java @@ -14,10 +14,10 @@ package com.ibm.cloud.platform_services.iam_policy_management.v1.model; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.AssignmentResourceCreated; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.AssignmentResourceError; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ConflictsWith; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ErrorDetails; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ErrorObject; -import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ErrorResponse; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.PolicyAssignmentResourcePolicy; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.PolicyAssignmentResources; import com.ibm.cloud.platform_services.iam_policy_management.v1.utils.TestUtilities; diff --git a/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyAssignmentV1CollectionTest.java b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyAssignmentV1CollectionTest.java index 5a58b5b7e0a..8a3a6b67703 100644 --- a/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyAssignmentV1CollectionTest.java +++ b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyAssignmentV1CollectionTest.java @@ -14,12 +14,12 @@ package com.ibm.cloud.platform_services.iam_policy_management.v1.model; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.AssignmentResourceCreated; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.AssignmentResourceError; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.AssignmentTargetDetails; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.AssignmentTemplateDetails; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ConflictsWith; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ErrorDetails; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ErrorObject; -import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ErrorResponse; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.First; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.Next; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.PolicyAssignmentResourcePolicy; diff --git a/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyAssignmentV1ResourcesTest.java b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyAssignmentV1ResourcesTest.java index ab53072df60..56c843a232e 100644 --- a/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyAssignmentV1ResourcesTest.java +++ b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyAssignmentV1ResourcesTest.java @@ -14,11 +14,11 @@ package com.ibm.cloud.platform_services.iam_policy_management.v1.model; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.AssignmentResourceCreated; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.AssignmentResourceError; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.AssignmentTargetDetails; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ConflictsWith; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ErrorDetails; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ErrorObject; -import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ErrorResponse; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.PolicyAssignmentResourcePolicy; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.PolicyAssignmentV1Resources; import com.ibm.cloud.platform_services.iam_policy_management.v1.utils.TestUtilities; diff --git a/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyAssignmentV1Test.java b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyAssignmentV1Test.java index 4071b79078a..d9889483421 100644 --- a/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyAssignmentV1Test.java +++ b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyAssignmentV1Test.java @@ -14,12 +14,12 @@ package com.ibm.cloud.platform_services.iam_policy_management.v1.model; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.AssignmentResourceCreated; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.AssignmentResourceError; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.AssignmentTargetDetails; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.AssignmentTemplateDetails; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ConflictsWith; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ErrorDetails; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ErrorObject; -import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ErrorResponse; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.PolicyAssignmentResourcePolicy; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.PolicyAssignmentV1; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.PolicyAssignmentV1Resources; diff --git a/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyTemplateAssignmentCollectionTest.java b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyTemplateAssignmentCollectionTest.java index 43cb2ba1412..8cb98be3d32 100644 --- a/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyTemplateAssignmentCollectionTest.java +++ b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyTemplateAssignmentCollectionTest.java @@ -14,12 +14,12 @@ package com.ibm.cloud.platform_services.iam_policy_management.v1.model; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.AssignmentResourceCreated; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.AssignmentResourceError; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.AssignmentTargetDetails; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.AssignmentTemplateDetails; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ConflictsWith; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ErrorDetails; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ErrorObject; -import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ErrorResponse; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.First; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.Next; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.PolicyAssignmentResourcePolicy; diff --git a/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyTemplateAssignmentItemsPolicyAssignmentTest.java b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyTemplateAssignmentItemsPolicyAssignmentTest.java index 366903ccb02..fded12633d2 100644 --- a/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyTemplateAssignmentItemsPolicyAssignmentTest.java +++ b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyTemplateAssignmentItemsPolicyAssignmentTest.java @@ -14,10 +14,10 @@ package com.ibm.cloud.platform_services.iam_policy_management.v1.model; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.AssignmentResourceCreated; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.AssignmentResourceError; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ConflictsWith; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ErrorDetails; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ErrorObject; -import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ErrorResponse; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.PolicyAssignmentResourcePolicy; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.PolicyAssignmentResources; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.PolicyTemplateAssignmentItemsPolicyAssignment; diff --git a/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyTemplateAssignmentItemsPolicyAssignmentV1Test.java b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyTemplateAssignmentItemsPolicyAssignmentV1Test.java index 91665f00282..6b74125d238 100644 --- a/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyTemplateAssignmentItemsPolicyAssignmentV1Test.java +++ b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyTemplateAssignmentItemsPolicyAssignmentV1Test.java @@ -14,12 +14,12 @@ package com.ibm.cloud.platform_services.iam_policy_management.v1.model; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.AssignmentResourceCreated; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.AssignmentResourceError; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.AssignmentTargetDetails; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.AssignmentTemplateDetails; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ConflictsWith; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ErrorDetails; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ErrorObject; -import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ErrorResponse; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.PolicyAssignmentResourcePolicy; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.PolicyAssignmentV1Resources; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.PolicyAssignmentV1Subject; diff --git a/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyTemplateAssignmentItemsTest.java b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyTemplateAssignmentItemsTest.java index 1bbbebb3b7a..05b400e91c1 100644 --- a/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyTemplateAssignmentItemsTest.java +++ b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyTemplateAssignmentItemsTest.java @@ -14,12 +14,12 @@ package com.ibm.cloud.platform_services.iam_policy_management.v1.model; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.AssignmentResourceCreated; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.AssignmentResourceError; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.AssignmentTargetDetails; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.AssignmentTemplateDetails; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ConflictsWith; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ErrorDetails; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ErrorObject; -import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ErrorResponse; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.PolicyAssignmentResourcePolicy; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.PolicyAssignmentV1Resources; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.PolicyAssignmentV1Subject; diff --git a/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ReplaceRoleTemplateOptionsTest.java b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ReplaceRoleTemplateOptionsTest.java new file mode 100644 index 00000000000..cf277697289 --- /dev/null +++ b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ReplaceRoleTemplateOptionsTest.java @@ -0,0 +1,71 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.iam_policy_management.v1.model; + +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ReplaceRoleTemplateOptions; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.TemplateRole; +import com.ibm.cloud.platform_services.iam_policy_management.v1.utils.TestUtilities; +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; +import static org.testng.Assert.*; + +/** + * Unit test class for the ReplaceRoleTemplateOptions model. + */ +public class ReplaceRoleTemplateOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testReplaceRoleTemplateOptions() throws Throwable { + TemplateRole templateRoleModel = new TemplateRole.Builder() + .name("testString") + .displayName("testString") + .serviceName("testString") + .description("testString") + .actions(java.util.Arrays.asList("testString")) + .build(); + assertEquals(templateRoleModel.name(), "testString"); + assertEquals(templateRoleModel.displayName(), "testString"); + assertEquals(templateRoleModel.serviceName(), "testString"); + assertEquals(templateRoleModel.description(), "testString"); + assertEquals(templateRoleModel.actions(), java.util.Arrays.asList("testString")); + + ReplaceRoleTemplateOptions replaceRoleTemplateOptionsModel = new ReplaceRoleTemplateOptions.Builder() + .roleTemplateId("testString") + .version("testString") + .ifMatch("testString") + .role(templateRoleModel) + .name("testString") + .description("testString") + .committed(true) + .build(); + assertEquals(replaceRoleTemplateOptionsModel.roleTemplateId(), "testString"); + assertEquals(replaceRoleTemplateOptionsModel.version(), "testString"); + assertEquals(replaceRoleTemplateOptionsModel.ifMatch(), "testString"); + assertEquals(replaceRoleTemplateOptionsModel.role(), templateRoleModel); + assertEquals(replaceRoleTemplateOptionsModel.name(), "testString"); + assertEquals(replaceRoleTemplateOptionsModel.description(), "testString"); + assertEquals(replaceRoleTemplateOptionsModel.committed(), Boolean.valueOf(true)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testReplaceRoleTemplateOptionsError() throws Throwable { + new ReplaceRoleTemplateOptions.Builder().build(); + } + +} \ No newline at end of file diff --git a/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/RoleAssignmentCollectionTest.java b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/RoleAssignmentCollectionTest.java new file mode 100644 index 00000000000..42801bc7771 --- /dev/null +++ b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/RoleAssignmentCollectionTest.java @@ -0,0 +1,47 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.iam_policy_management.v1.model; + +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.AssignmentTargetDetails; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.First; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.Next; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.Previous; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.RoleAssignment; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.RoleAssignmentCollection; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.RoleAssignmentTemplate; +import com.ibm.cloud.platform_services.iam_policy_management.v1.utils.TestUtilities; +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; +import static org.testng.Assert.*; + +/** + * Unit test class for the RoleAssignmentCollection model. + */ +public class RoleAssignmentCollectionTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRoleAssignmentCollection() throws Throwable { + RoleAssignmentCollection roleAssignmentCollectionModel = new RoleAssignmentCollection(); + assertNull(roleAssignmentCollectionModel.getLimit()); + assertNull(roleAssignmentCollectionModel.getFirst()); + assertNull(roleAssignmentCollectionModel.getNext()); + assertNull(roleAssignmentCollectionModel.getPrevious()); + assertNull(roleAssignmentCollectionModel.getAssignments()); + } +} \ No newline at end of file diff --git a/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/RoleAssignmentResourceCreatedTest.java b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/RoleAssignmentResourceCreatedTest.java new file mode 100644 index 00000000000..bef8b71b0fa --- /dev/null +++ b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/RoleAssignmentResourceCreatedTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.iam_policy_management.v1.model; + +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.RoleAssignmentResourceCreated; +import com.ibm.cloud.platform_services.iam_policy_management.v1.utils.TestUtilities; +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; +import static org.testng.Assert.*; + +/** + * Unit test class for the RoleAssignmentResourceCreated model. + */ +public class RoleAssignmentResourceCreatedTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRoleAssignmentResourceCreated() throws Throwable { + RoleAssignmentResourceCreated roleAssignmentResourceCreatedModel = new RoleAssignmentResourceCreated(); + assertNull(roleAssignmentResourceCreatedModel.getId()); + } +} \ No newline at end of file diff --git a/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/RoleAssignmentResourceRoleTest.java b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/RoleAssignmentResourceRoleTest.java new file mode 100644 index 00000000000..c346ca0f48f --- /dev/null +++ b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/RoleAssignmentResourceRoleTest.java @@ -0,0 +1,43 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.iam_policy_management.v1.model; + +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.AssignmentResourceError; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ConflictsWith; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ErrorDetails; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ErrorObject; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.RoleAssignmentResourceCreated; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.RoleAssignmentResourceRole; +import com.ibm.cloud.platform_services.iam_policy_management.v1.utils.TestUtilities; +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; +import static org.testng.Assert.*; + +/** + * Unit test class for the RoleAssignmentResourceRole model. + */ +public class RoleAssignmentResourceRoleTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRoleAssignmentResourceRole() throws Throwable { + RoleAssignmentResourceRole roleAssignmentResourceRoleModel = new RoleAssignmentResourceRole(); + assertNull(roleAssignmentResourceRoleModel.getResourceCreated()); + assertNull(roleAssignmentResourceRoleModel.getErrorMessage()); + } +} \ No newline at end of file diff --git a/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/RoleAssignmentResourceTest.java b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/RoleAssignmentResourceTest.java new file mode 100644 index 00000000000..4fca1b25b5b --- /dev/null +++ b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/RoleAssignmentResourceTest.java @@ -0,0 +1,45 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.iam_policy_management.v1.model; + +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.AssignmentResourceError; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.AssignmentTargetDetails; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ConflictsWith; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ErrorDetails; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ErrorObject; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.RoleAssignmentResource; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.RoleAssignmentResourceCreated; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.RoleAssignmentResourceRole; +import com.ibm.cloud.platform_services.iam_policy_management.v1.utils.TestUtilities; +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; +import static org.testng.Assert.*; + +/** + * Unit test class for the RoleAssignmentResource model. + */ +public class RoleAssignmentResourceTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRoleAssignmentResource() throws Throwable { + RoleAssignmentResource roleAssignmentResourceModel = new RoleAssignmentResource(); + assertNull(roleAssignmentResourceModel.getTarget()); + assertNull(roleAssignmentResourceModel.getRole()); + } +} \ No newline at end of file diff --git a/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/RoleAssignmentTemplateTest.java b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/RoleAssignmentTemplateTest.java new file mode 100644 index 00000000000..4f2e3a37200 --- /dev/null +++ b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/RoleAssignmentTemplateTest.java @@ -0,0 +1,54 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.iam_policy_management.v1.model; + +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.RoleAssignmentTemplate; +import com.ibm.cloud.platform_services.iam_policy_management.v1.utils.TestUtilities; +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; +import static org.testng.Assert.*; + +/** + * Unit test class for the RoleAssignmentTemplate model. + */ +public class RoleAssignmentTemplateTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRoleAssignmentTemplate() throws Throwable { + RoleAssignmentTemplate roleAssignmentTemplateModel = new RoleAssignmentTemplate.Builder() + .id("testString") + .version("testString") + .build(); + assertEquals(roleAssignmentTemplateModel.id(), "testString"); + assertEquals(roleAssignmentTemplateModel.version(), "testString"); + + String json = TestUtilities.serialize(roleAssignmentTemplateModel); + + RoleAssignmentTemplate roleAssignmentTemplateModelNew = TestUtilities.deserialize(json, RoleAssignmentTemplate.class); + assertTrue(roleAssignmentTemplateModelNew instanceof RoleAssignmentTemplate); + assertEquals(roleAssignmentTemplateModelNew.id(), "testString"); + assertEquals(roleAssignmentTemplateModelNew.version(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testRoleAssignmentTemplateError() throws Throwable { + new RoleAssignmentTemplate.Builder().build(); + } + +} \ No newline at end of file diff --git a/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ErrorResponseTest.java b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/RoleAssignmentTest.java similarity index 73% rename from modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ErrorResponseTest.java rename to modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/RoleAssignmentTest.java index 768f9fb1d50..bd3bda7ce24 100644 --- a/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ErrorResponseTest.java +++ b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/RoleAssignmentTest.java @@ -13,10 +13,9 @@ package com.ibm.cloud.platform_services.iam_policy_management.v1.model; -import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ConflictsWith; -import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ErrorDetails; -import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ErrorObject; -import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ErrorResponse; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.AssignmentTargetDetails; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.RoleAssignment; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.RoleAssignmentTemplate; import com.ibm.cloud.platform_services.iam_policy_management.v1.utils.TestUtilities; import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; import java.io.InputStream; @@ -26,17 +25,16 @@ import static org.testng.Assert.*; /** - * Unit test class for the ErrorResponse model. + * Unit test class for the RoleAssignment model. */ -public class ErrorResponseTest { +public class RoleAssignmentTest { final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); @Test - public void testErrorResponse() throws Throwable { - ErrorResponse errorResponseModel = new ErrorResponse(); - assertNull(errorResponseModel.getTrace()); - assertNull(errorResponseModel.getErrors()); - assertNull(errorResponseModel.getStatusCode()); + public void testRoleAssignment() throws Throwable { + RoleAssignment roleAssignmentModel = new RoleAssignment(); + assertNull(roleAssignmentModel.getTemplate()); + assertNull(roleAssignmentModel.getTarget()); } } \ No newline at end of file diff --git a/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/RoleTemplateCollectionTest.java b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/RoleTemplateCollectionTest.java new file mode 100644 index 00000000000..cf3028a2536 --- /dev/null +++ b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/RoleTemplateCollectionTest.java @@ -0,0 +1,46 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.iam_policy_management.v1.model; + +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.First; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.Next; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.Previous; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.RoleTemplate; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.RoleTemplateCollection; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.TemplateRole; +import com.ibm.cloud.platform_services.iam_policy_management.v1.utils.TestUtilities; +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; +import static org.testng.Assert.*; + +/** + * Unit test class for the RoleTemplateCollection model. + */ +public class RoleTemplateCollectionTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRoleTemplateCollection() throws Throwable { + RoleTemplateCollection roleTemplateCollectionModel = new RoleTemplateCollection(); + assertNull(roleTemplateCollectionModel.getLimit()); + assertNull(roleTemplateCollectionModel.getFirst()); + assertNull(roleTemplateCollectionModel.getNext()); + assertNull(roleTemplateCollectionModel.getPrevious()); + assertNull(roleTemplateCollectionModel.getRoleTemplates()); + } +} \ No newline at end of file diff --git a/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/RoleTemplateTest.java b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/RoleTemplateTest.java new file mode 100644 index 00000000000..0c539f477db --- /dev/null +++ b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/RoleTemplateTest.java @@ -0,0 +1,44 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.iam_policy_management.v1.model; + +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.RoleTemplate; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.TemplateRole; +import com.ibm.cloud.platform_services.iam_policy_management.v1.utils.TestUtilities; +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; +import static org.testng.Assert.*; + +/** + * Unit test class for the RoleTemplate model. + */ +public class RoleTemplateTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRoleTemplate() throws Throwable { + RoleTemplate roleTemplateModel = new RoleTemplate(); + assertNull(roleTemplateModel.getName()); + assertNull(roleTemplateModel.getDescription()); + assertNull(roleTemplateModel.getAccountId()); + assertNull(roleTemplateModel.isCommitted()); + assertNull(roleTemplateModel.getRole()); + assertNull(roleTemplateModel.getVersion()); + assertNull(roleTemplateModel.getState()); + } +} \ No newline at end of file diff --git a/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/RoleTemplateVersionsCollectionTest.java b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/RoleTemplateVersionsCollectionTest.java new file mode 100644 index 00000000000..ceddec39ba8 --- /dev/null +++ b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/RoleTemplateVersionsCollectionTest.java @@ -0,0 +1,46 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.iam_policy_management.v1.model; + +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.First; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.Next; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.Previous; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.RoleTemplate; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.RoleTemplateVersionsCollection; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.TemplateRole; +import com.ibm.cloud.platform_services.iam_policy_management.v1.utils.TestUtilities; +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; +import static org.testng.Assert.*; + +/** + * Unit test class for the RoleTemplateVersionsCollection model. + */ +public class RoleTemplateVersionsCollectionTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRoleTemplateVersionsCollection() throws Throwable { + RoleTemplateVersionsCollection roleTemplateVersionsCollectionModel = new RoleTemplateVersionsCollection(); + assertNull(roleTemplateVersionsCollectionModel.getLimit()); + assertNull(roleTemplateVersionsCollectionModel.getFirst()); + assertNull(roleTemplateVersionsCollectionModel.getNext()); + assertNull(roleTemplateVersionsCollectionModel.getPrevious()); + assertNull(roleTemplateVersionsCollectionModel.getVersions()); + } +} \ No newline at end of file diff --git a/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/TemplateRoleTest.java b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/TemplateRoleTest.java new file mode 100644 index 00000000000..8e5d3425491 --- /dev/null +++ b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/TemplateRoleTest.java @@ -0,0 +1,62 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.iam_policy_management.v1.model; + +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.TemplateRole; +import com.ibm.cloud.platform_services.iam_policy_management.v1.utils.TestUtilities; +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; +import static org.testng.Assert.*; + +/** + * Unit test class for the TemplateRole model. + */ +public class TemplateRoleTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTemplateRole() throws Throwable { + TemplateRole templateRoleModel = new TemplateRole.Builder() + .name("testString") + .displayName("testString") + .serviceName("testString") + .description("testString") + .actions(java.util.Arrays.asList("testString")) + .build(); + assertEquals(templateRoleModel.name(), "testString"); + assertEquals(templateRoleModel.displayName(), "testString"); + assertEquals(templateRoleModel.serviceName(), "testString"); + assertEquals(templateRoleModel.description(), "testString"); + assertEquals(templateRoleModel.actions(), java.util.Arrays.asList("testString")); + + String json = TestUtilities.serialize(templateRoleModel); + + TemplateRole templateRoleModelNew = TestUtilities.deserialize(json, TemplateRole.class); + assertTrue(templateRoleModelNew instanceof TemplateRole); + assertEquals(templateRoleModelNew.name(), "testString"); + assertEquals(templateRoleModelNew.displayName(), "testString"); + assertEquals(templateRoleModelNew.serviceName(), "testString"); + assertEquals(templateRoleModelNew.description(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testTemplateRoleError() throws Throwable { + new TemplateRole.Builder().build(); + } + +} \ No newline at end of file diff --git a/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/UpdateRoleAssignmentOptionsTest.java b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/UpdateRoleAssignmentOptionsTest.java new file mode 100644 index 00000000000..879c3d5f456 --- /dev/null +++ b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/UpdateRoleAssignmentOptionsTest.java @@ -0,0 +1,49 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.iam_policy_management.v1.model; + +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.UpdateRoleAssignmentOptions; +import com.ibm.cloud.platform_services.iam_policy_management.v1.utils.TestUtilities; +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; +import static org.testng.Assert.*; + +/** + * Unit test class for the UpdateRoleAssignmentOptions model. + */ +public class UpdateRoleAssignmentOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testUpdateRoleAssignmentOptions() throws Throwable { + UpdateRoleAssignmentOptions updateRoleAssignmentOptionsModel = new UpdateRoleAssignmentOptions.Builder() + .assignmentId("testString") + .ifMatch("testString") + .templateVersion("testString") + .build(); + assertEquals(updateRoleAssignmentOptionsModel.assignmentId(), "testString"); + assertEquals(updateRoleAssignmentOptionsModel.ifMatch(), "testString"); + assertEquals(updateRoleAssignmentOptionsModel.templateVersion(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateRoleAssignmentOptionsError() throws Throwable { + new UpdateRoleAssignmentOptions.Builder().build(); + } + +} \ No newline at end of file