From 6f752c23fdb6535e4bb5abd109a12dfb587adaf2 Mon Sep 17 00:00:00 2001 From: Shaun Colley <80714407+swcolley@users.noreply.github.com> Date: Tue, 5 Sep 2023 12:44:06 -0400 Subject: [PATCH] feat(IAM Policy Management): add support for policy templates (#194) Signed-off-by: Shaun Colley --- .../v1/IamPolicyManagementExamples.java | 319 ++++++- .../v1/IamPolicyManagement.java | 390 +++++++- .../v1/model/AssignmentResourceCreated.java | 37 + .../v1/model/CommitPolicyTemplateOptions.java | 165 ++++ .../v1/model/ConflictsWith.java | 61 ++ .../v1/model/CreatePolicyTemplateOptions.java | 254 ++++++ .../CreatePolicyTemplateVersionOptions.java | 186 ++++ .../v1/model/CreateV2PolicyOptions.java | 2 +- .../model/DeletePolicyAssignmentOptions.java | 103 +++ .../v1/model/DeletePolicyTemplateOptions.java | 103 +++ .../DeletePolicyTemplateVersionOptions.java | 133 +++ .../v1/model/ErrorDetails.java | 39 + .../v1/model/ErrorObject.java | 115 +++ .../v1/model/ErrorResponse.java | 65 ++ .../v1/model/GetPolicyAssignmentOptions.java | 103 +++ .../v1/model/GetPolicyTemplateOptions.java | 103 +++ .../GetPolicyTemplateVersionOptions.java | 133 +++ .../model/ListPolicyAssignmentsOptions.java | 192 ++++ .../ListPolicyTemplateVersionsOptions.java | 103 +++ .../ListPolicyTemplateVerssionsOptions.java | 103 +++ .../v1/model/ListPolicyTemplatesOptions.java | 140 +++ .../model/PatchPolicyAssignmentOptions.java | 133 +++ .../PolcyTemplateAssignmentCollection.java | 41 + .../v1/model/Policy.java | 12 + .../v1/model/PolicyAssignment.java | 240 +++++ .../v1/model/PolicyAssignmentOptions.java | 101 +++ .../v1/model/PolicyAssignmentRecord.java | 240 +++++ .../PolicyAssignmentRequestOptionsItem.java | 101 +++ .../v1/model/PolicyAssignmentResources.java | 49 + .../PolicyAssignmentResourcesPolicy.java | 52 ++ .../v1/model/PolicyCollection.java | 39 + .../v1/model/PolicyTemplate.java | 179 ++++ .../PolicyTemplateAssignmentCollection.java | 39 + .../v1/model/PolicyTemplateCollection.java | 41 + .../PolicyTemplateVersionsCollection.java | 39 + .../model/ReplacePolicyTemplateOptions.java | 248 +++++ .../v1/model/ReplaceV2PolicyOptions.java | 2 +- .../v1/model/RoleCollection.java | 67 ++ .../v1/model/TemplateMetada.java | 49 + .../v1/model/TemplateMetadata.java | 49 + .../v1/model/TemplatePolicy.java | 253 ++++++ .../v1/model/V2Policy.java | 14 +- .../v1/IamPolicyManagementIT.java | 430 ++++++++- .../v1/IamPolicyManagementTest.java | 851 +++++++++++++++++- .../model/AssignmentResourceCreatedTest.java | 37 + .../CommitPolicyTemplateOptionsTest.java | 49 + .../v1/model/ConflictsWithTest.java | 39 + .../CreatePolicyTemplateOptionsTest.java | 127 +++ ...reatePolicyTemplateVersionOptionsTest.java | 123 +++ .../DeletePolicyAssignmentOptionsTest.java | 45 + .../DeletePolicyTemplateOptionsTest.java | 45 + ...eletePolicyTemplateVersionOptionsTest.java | 47 + .../v1/model/ErrorDetailsTest.java | 38 + .../v1/model/ErrorObjectTest.java | 42 + .../v1/model/ErrorResponseTest.java | 42 + .../model/GetPolicyAssignmentOptionsTest.java | 45 + .../model/GetPolicyTemplateOptionsTest.java | 45 + .../GetPolicyTemplateVersionOptionsTest.java | 47 + .../ListPolicyAssignmentsOptionsTest.java | 51 ++ ...ListPolicyTemplateVersionsOptionsTest.java | 45 + ...istPolicyTemplateVerssionsOptionsTest.java | 45 + .../model/ListPolicyTemplatesOptionsTest.java | 47 + .../PatchPolicyAssignmentOptionsTest.java | 47 + ...PolcyTemplateAssignmentCollectionTest.java | 46 + .../v1/model/PolicyAssignmentOptionsTest.java | 41 + .../v1/model/PolicyAssignmentRecordTest.java | 52 ++ ...olicyAssignmentRequestOptionsItemTest.java | 41 + .../PolicyAssignmentResourcesPolicyTest.java | 43 + .../model/PolicyAssignmentResourcesTest.java | 44 + .../v1/model/PolicyAssignmentTest.java | 52 ++ .../v1/model/PolicyCollectionTest.java | 45 + .../v1/model/PolicyListTest.java | 1 + ...olicyTemplateAssignmentCollectionTest.java | 46 + .../model/PolicyTemplateCollectionTest.java | 46 + .../v1/model/PolicyTemplateTest.java | 50 + .../PolicyTemplateVersionsCollectionTest.java | 46 + .../v1/model/PolicyTest.java | 2 + .../ReplacePolicyTemplateOptionsTest.java | 127 +++ .../v1/model/RoleCollectionTest.java | 41 + .../v1/model/TemplateMetadaTest.java | 38 + .../v1/model/TemplateMetadataTest.java | 38 + .../v1/model/TemplatePolicyTest.java | 122 +++ .../v1/model/V2PolicyCollectionTest.java | 1 + .../v1/model/V2PolicyTest.java | 2 + 84 files changed, 7996 insertions(+), 52 deletions(-) create mode 100644 modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/AssignmentResourceCreated.java create mode 100644 modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/CommitPolicyTemplateOptions.java create mode 100644 modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ConflictsWith.java create mode 100644 modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/CreatePolicyTemplateOptions.java create mode 100644 modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/CreatePolicyTemplateVersionOptions.java create mode 100644 modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/DeletePolicyAssignmentOptions.java create mode 100644 modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/DeletePolicyTemplateOptions.java create mode 100644 modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/DeletePolicyTemplateVersionOptions.java create mode 100644 modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ErrorDetails.java create mode 100644 modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ErrorObject.java create mode 100644 modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ErrorResponse.java create mode 100644 modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/GetPolicyAssignmentOptions.java create mode 100644 modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/GetPolicyTemplateOptions.java create mode 100644 modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/GetPolicyTemplateVersionOptions.java create mode 100644 modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ListPolicyAssignmentsOptions.java create mode 100644 modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ListPolicyTemplateVersionsOptions.java create mode 100644 modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ListPolicyTemplateVerssionsOptions.java create mode 100644 modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ListPolicyTemplatesOptions.java create mode 100644 modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PatchPolicyAssignmentOptions.java create mode 100644 modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolcyTemplateAssignmentCollection.java create mode 100644 modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyAssignment.java create mode 100644 modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyAssignmentOptions.java create mode 100644 modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyAssignmentRecord.java create mode 100644 modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyAssignmentRequestOptionsItem.java create mode 100644 modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyAssignmentResources.java create mode 100644 modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyAssignmentResourcesPolicy.java create mode 100644 modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyCollection.java create mode 100644 modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyTemplate.java create mode 100644 modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyTemplateAssignmentCollection.java create mode 100644 modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyTemplateCollection.java create mode 100644 modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyTemplateVersionsCollection.java create mode 100644 modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ReplacePolicyTemplateOptions.java create mode 100644 modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/RoleCollection.java create mode 100644 modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/TemplateMetada.java create mode 100644 modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/TemplateMetadata.java create mode 100644 modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/TemplatePolicy.java create mode 100644 modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/AssignmentResourceCreatedTest.java create mode 100644 modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/CommitPolicyTemplateOptionsTest.java create mode 100644 modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ConflictsWithTest.java create mode 100644 modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/CreatePolicyTemplateOptionsTest.java create mode 100644 modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/CreatePolicyTemplateVersionOptionsTest.java create mode 100644 modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/DeletePolicyAssignmentOptionsTest.java create mode 100644 modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/DeletePolicyTemplateOptionsTest.java create mode 100644 modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/DeletePolicyTemplateVersionOptionsTest.java create mode 100644 modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ErrorDetailsTest.java create mode 100644 modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ErrorObjectTest.java create mode 100644 modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ErrorResponseTest.java create mode 100644 modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/GetPolicyAssignmentOptionsTest.java create mode 100644 modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/GetPolicyTemplateOptionsTest.java create mode 100644 modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/GetPolicyTemplateVersionOptionsTest.java create mode 100644 modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ListPolicyAssignmentsOptionsTest.java create mode 100644 modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ListPolicyTemplateVersionsOptionsTest.java create mode 100644 modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ListPolicyTemplateVerssionsOptionsTest.java create mode 100644 modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ListPolicyTemplatesOptionsTest.java create mode 100644 modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PatchPolicyAssignmentOptionsTest.java create mode 100644 modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolcyTemplateAssignmentCollectionTest.java create mode 100644 modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyAssignmentOptionsTest.java create mode 100644 modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyAssignmentRecordTest.java create mode 100644 modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyAssignmentRequestOptionsItemTest.java create mode 100644 modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyAssignmentResourcesPolicyTest.java create mode 100644 modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyAssignmentResourcesTest.java create mode 100644 modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyAssignmentTest.java create mode 100644 modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyCollectionTest.java create mode 100644 modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyTemplateAssignmentCollectionTest.java create mode 100644 modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyTemplateCollectionTest.java create mode 100644 modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyTemplateTest.java create mode 100644 modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyTemplateVersionsCollectionTest.java create mode 100644 modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ReplacePolicyTemplateOptionsTest.java create mode 100644 modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/RoleCollectionTest.java create mode 100644 modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/TemplateMetadaTest.java create mode 100644 modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/TemplateMetadataTest.java create mode 100644 modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/TemplatePolicyTest.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 062756d0ca..766ac23d1a 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 @@ -24,11 +24,11 @@ import com.ibm.cloud.platform_services.iam_policy_management.v1.model.UpdatePolicyStateOptions; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ListRolesOptions; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.Policy; -import com.ibm.cloud.platform_services.iam_policy_management.v1.model.PolicyList; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.PolicyCollection; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.PolicyResource; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.PolicyRole; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.PolicySubject; -import com.ibm.cloud.platform_services.iam_policy_management.v1.model.RoleList; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.RoleCollection; 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.SubjectAttribute; @@ -51,6 +51,24 @@ import com.ibm.cloud.platform_services.iam_policy_management.v1.model.V2PolicyCollection; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ReplaceV2PolicyOptions; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.Roles; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.PolicyAssignment; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.PolicyTemplate; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.PolicyTemplateCollection; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.PolicyTemplateVersionsCollection; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.TemplatePolicy; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.CreatePolicyTemplateOptions; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.DeletePolicyTemplateOptions; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.GetPolicyTemplateOptions; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ListPolicyTemplatesOptions; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ReplacePolicyTemplateOptions; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.CreatePolicyTemplateVersionOptions; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.DeletePolicyTemplateVersionOptions; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.GetPolicyTemplateVersionOptions; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ListPolicyTemplateVersionsOptions; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.CommitPolicyTemplateOptions; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.PolicyTemplateAssignmentCollection; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.GetPolicyAssignmentOptions; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ListPolicyAssignmentsOptions; 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; @@ -90,6 +108,10 @@ protected IamPolicyManagementExamples() { } private static String exampleV2PolicyEtag = null; private static String exampleCustomRoleId = null; private static String exampleCustomRoleEtag = null; + private static String exampleTemplateId = null; + private static String exampleTemplateEtag = null; + private static String exampleTemplateVersion = null; + private static String exampleAssignmentId = null; static { System.setProperty("IBM_CREDENTIALS_FILE", "../../iam_policy_management.env"); @@ -285,10 +307,10 @@ public static void main(String[] args) throws Exception { .format("include_last_permit") .build(); - Response response = service.listPolicies(options).execute(); - PolicyList policyList = response.getResult(); + Response response = service.listPolicies(options).execute(); + PolicyCollection policyCollection = response.getResult(); - System.out.println(policyList); + System.out.println(policyCollection); // end-list_policies @@ -650,10 +672,10 @@ public static void main(String[] args) throws Exception { .accountId(exampleAccountId) .build(); - Response response = service.listRoles(options).execute(); - RoleList roleList = response.getResult(); + Response response = service.listRoles(options).execute(); + RoleCollection roleCollection = response.getResult(); - System.out.println(roleList); + System.out.println(roleCollection); // end-list_roles @@ -678,5 +700,286 @@ 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("createPolicyTemplate() result:"); + // begin-create_policy_template + V2PolicyResourceAttribute v2PolicyResourceAttributeModel = new V2PolicyResourceAttribute.Builder() + .key("serviceType") + .operator("stringEquals") + .value("service") + .build(); + V2PolicyResource v2PolicyResourceModel = new V2PolicyResource.Builder() + .attributes(java.util.Arrays.asList(v2PolicyResourceAttributeModel)) + .build(); + Roles rolesModel = new Roles.Builder() + .roleId("crn:v1:bluemix:public:iam::::role:Viewer") + .build(); + Grant grantModel = new Grant.Builder() + .roles(java.util.Arrays.asList(rolesModel)) + .build(); + Control controlModel = new Control.Builder() + .grant(grantModel) + .build(); + TemplatePolicy templatePolicyModel = new TemplatePolicy.Builder() + .type("access") + .resource(v2PolicyResourceModel) + .control(controlModel) + .build(); + CreatePolicyTemplateOptions createPolicyTemplateOptions = new CreatePolicyTemplateOptions.Builder() + .name("SDKExamplesTest") + .accountId(exampleAccountId) + .policy(templatePolicyModel) + .build(); + + Response response = service.createPolicyTemplate(createPolicyTemplateOptions).execute(); + PolicyTemplate policyTemplate = response.getResult(); + + System.out.println(policyTemplate); + // end-create_policy_template + + exampleTemplateId = policyTemplate.getId(); + exampleTemplateVersion = policyTemplate.getVersion(); + } 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("getPolicyTemplate() result:"); + // begin-get_policy_template + GetPolicyTemplateOptions getPolicyTemplateOptions = new GetPolicyTemplateOptions.Builder() + .policyTemplateId(exampleTemplateId) + .build(); + + Response response = service.getPolicyTemplate(getPolicyTemplateOptions).execute(); + PolicyTemplate policyTemplate = response.getResult(); + + System.out.println(policyTemplate); + // end-get_policy_template + + exampleTemplateEtag = response.getHeaders().values("Etag").get(0); + } 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("replacePolicyTemplate() result:"); + // begin-replace_policy_template + V2PolicyResourceAttribute v2PolicyResourceAttributeModel = new V2PolicyResourceAttribute.Builder() + .key("serviceType") + .operator("stringEquals") + .value("service") + .build(); + V2PolicyResource v2PolicyResourceModel = new V2PolicyResource.Builder() + .attributes(java.util.Arrays.asList(v2PolicyResourceAttributeModel)) + .build(); + Roles rolesModel = new Roles.Builder() + .roleId("crn:v1:bluemix:public:iam::::role:Editor") + .build(); + Grant grantModel = new Grant.Builder() + .roles(java.util.Arrays.asList(rolesModel)) + .build(); + Control controlModel = new Control.Builder() + .grant(grantModel) + .build(); + TemplatePolicy templatePolicyModel = new TemplatePolicy.Builder() + .type("access") + .resource(v2PolicyResourceModel) + .control(controlModel) + .build(); + ReplacePolicyTemplateOptions replacePolicyTemplateOptions = new ReplacePolicyTemplateOptions.Builder() + .policyTemplateId(exampleTemplateId) + .version(exampleTemplateVersion) + .ifMatch(exampleTemplateEtag) + .policy(templatePolicyModel) + .build(); + + Response response = service.replacePolicyTemplate(replacePolicyTemplateOptions).execute(); + PolicyTemplate policyTemplate = response.getResult(); + + System.out.println(policyTemplate); + // end-replace_policy_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("listPolicyTemplates() result:"); + // begin-list_policy_templates + ListPolicyTemplatesOptions listPolicyTemplatesOptions = new ListPolicyTemplatesOptions.Builder() + .accountId(exampleAccountId) + .build(); + + Response response = service.listPolicyTemplates(listPolicyTemplatesOptions).execute(); + PolicyTemplateCollection policyTemplateCollection = response.getResult(); + + System.out.println(policyTemplateCollection); + // end-list_policy_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("createPolicyTemplateVersion() result:"); + // begin-create_policy_template_version + V2PolicyResourceAttribute v2PolicyResourceAttributeModel = new V2PolicyResourceAttribute.Builder() + .key("serviceType") + .operator("stringEquals") + .value("service") + .build(); + V2PolicyResource v2PolicyResourceModel = new V2PolicyResource.Builder() + .attributes(java.util.Arrays.asList(v2PolicyResourceAttributeModel)) + .build(); + Roles rolesModel = new Roles.Builder() + .roleId("crn:v1:bluemix:public:iam::::role:Viewer") + .build(); + Grant grantModel = new Grant.Builder() + .roles(java.util.Arrays.asList(rolesModel)) + .build(); + Control controlModel = new Control.Builder() + .grant(grantModel) + .build(); + TemplatePolicy templatePolicyModel = new TemplatePolicy.Builder() + .type("access") + .resource(v2PolicyResourceModel) + .control(controlModel) + .build(); + CreatePolicyTemplateVersionOptions createPolicyTemplateVersionOptions = new CreatePolicyTemplateVersionOptions.Builder() + .policyTemplateId(exampleTemplateId) + .policy(templatePolicyModel) + .build(); + + Response response = service.createPolicyTemplateVersion(createPolicyTemplateVersionOptions).execute(); + PolicyTemplate policyTemplate = response.getResult(); + + System.out.println(policyTemplate); + // end-create_policy_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("listPolicyTemplateVersions() result:"); + // begin-list_policy_template_versions + ListPolicyTemplateVersionsOptions listPolicyTemplateVersionsOptions = new ListPolicyTemplateVersionsOptions.Builder() + .policyTemplateId(exampleAccountId) + .build(); + + Response response = service.listPolicyTemplateVersions(listPolicyTemplateVersionsOptions).execute(); + PolicyTemplateVersionsCollection policyTemplateVersionsCollection = response.getResult(); + + System.out.println(policyTemplateVersionsCollection); + // end-list_policy_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("getPolicyTemplateVersion() result:"); + // begin-get_policy_template_version + GetPolicyTemplateVersionOptions getPolicyTemplateVersionOptions = new GetPolicyTemplateVersionOptions.Builder() + .policyTemplateId(exampleTemplateId) + .version(exampleTemplateVersion) + .build(); + + Response response = service.getPolicyTemplateVersion(getPolicyTemplateVersionOptions).execute(); + PolicyTemplate policyTemplate = response.getResult(); + + System.out.println(policyTemplate); + // end-get_policy_template_version + + exampleTemplateEtag = response.getHeaders().values("Etag").get(0); + } 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_policy_template + CommitPolicyTemplateOptions commitPolicyTemplateOptions = new CommitPolicyTemplateOptions.Builder() + .policyTemplateId(exampleTemplateId) + .version(exampleTemplateVersion) + .ifMatch(exampleTemplateEtag) + .build(); + + Response response = service.commitPolicyTemplate(commitPolicyTemplateOptions).execute(); + // end-commit_policy_template + System.out.printf("commitPolicyTemplate() 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("listPolicyAssignments() result:"); + // begin-list_Policy Assignments + ListPolicyAssignmentsOptions listPolicyAssignmentsOptions = new ListPolicyAssignmentsOptions.Builder() + .accountId(exampleAccountId) + .build(); + + Response response = service.listPolicyAssignments(listPolicyAssignmentsOptions).execute(); + PolicyTemplateAssignmentCollection polcyTemplateAssignmentCollection = response.getResult(); + + System.out.println(polcyTemplateAssignmentCollection); + // end-list_Policy Assignments + + exampleAssignmentId = polcyTemplateAssignmentCollection.getAssignments().get(0).getId(); + } 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("getPolicyAssignment() result:"); + // begin-get_policy_assignment + GetPolicyAssignmentOptions getPolicyAssignmentOptions = new GetPolicyAssignmentOptions.Builder() + .assignmentId(exampleAssignmentId) + .build(); + + Response response = service.getPolicyAssignment(getPolicyAssignmentOptions).execute(); + PolicyAssignment policyAssignmentRecord = response.getResult(); + + System.out.println(policyAssignmentRecord); + // end-get_policy_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_policy_template_version + DeletePolicyTemplateVersionOptions deletePolicyTemplateVersionOptions = new DeletePolicyTemplateVersionOptions.Builder() + .policyTemplateId(exampleTemplateId) + .version(exampleTemplateVersion) + .build(); + + Response response = service.deletePolicyTemplateVersion(deletePolicyTemplateVersionOptions).execute(); + // end-delete_policy_template_version + System.out.printf("deletePolicyTemplateVersion() 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_policy_template + DeletePolicyTemplateOptions deletePolicyTemplateOptions = new DeletePolicyTemplateOptions.Builder() + .policyTemplateId(exampleTemplateId) + .build(); + + Response response = service.deletePolicyTemplate(deletePolicyTemplateOptions).execute(); + // end-delete_policy_template + System.out.printf("deletePolicyTemplate() 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 7b29d2009c..4100127bfc 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,32 +12,49 @@ */ /* - * IBM OpenAPI SDK Code Generator Version: 3.68.2-ac7def68-20230310-195410 + * IBM OpenAPI SDK Code Generator Version: 3.65.0-79fc0b8f-20230209-215651 */ package com.ibm.cloud.platform_services.iam_policy_management.v1; import com.google.gson.JsonObject; import com.ibm.cloud.platform_services.common.SdkCommon; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.CommitPolicyTemplateOptions; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.CreatePolicyOptions; +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.CreateV2PolicyOptions; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.CustomRole; 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.DeleteRoleOptions; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.DeleteV2PolicyOptions; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.GetPolicyAssignmentOptions; 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.GetRoleOptions; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.GetV2PolicyOptions; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ListPoliciesOptions; +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.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; -import com.ibm.cloud.platform_services.iam_policy_management.v1.model.PolicyList; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.PolicyAssignment; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.PolicyCollection; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.PolicyTemplate; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.PolicyTemplateAssignmentCollection; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.PolicyTemplateCollection; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.PolicyTemplateVersionsCollection; 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.ReplaceV2PolicyOptions; -import com.ibm.cloud.platform_services.iam_policy_management.v1.model.RoleList; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.RoleCollection; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.UpdatePolicyStateOptions; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.V2Policy; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.V2PolicyCollection; @@ -115,9 +132,9 @@ public IamPolicyManagement(String serviceName, Authenticator authenticator) { * the caller does not have read access to any policies an empty array is returned. * * @param listPoliciesOptions the {@link ListPoliciesOptions} containing the options for the call - * @return a {@link ServiceCall} with a result of type {@link PolicyList} + * @return a {@link ServiceCall} with a result of type {@link PolicyCollection} */ - public ServiceCall listPolicies(ListPoliciesOptions listPoliciesOptions) { + public ServiceCall listPolicies(ListPoliciesOptions listPoliciesOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull(listPoliciesOptions, "listPoliciesOptions cannot be null"); RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/policies")); @@ -157,8 +174,8 @@ public ServiceCall listPolicies(ListPoliciesOptions listPoliciesOpti if (listPoliciesOptions.state() != null) { builder.query("state", String.valueOf(listPoliciesOptions.state())); } - ResponseConverter responseConverter = - ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); return createServiceCall(builder.build(), responseConverter); } @@ -395,9 +412,9 @@ public ServiceCall updatePolicyState(UpdatePolicyStateOptions updatePoli * caller does not have read access to any roles an empty array is returned. * * @param listRolesOptions the {@link ListRolesOptions} containing the options for the call - * @return a {@link ServiceCall} with a result of type {@link RoleList} + * @return a {@link ServiceCall} with a result of type {@link RoleCollection} */ - public ServiceCall listRoles(ListRolesOptions listRolesOptions) { + public ServiceCall listRoles(ListRolesOptions listRolesOptions) { if (listRolesOptions == null) { listRolesOptions = new ListRolesOptions.Builder().build(); } @@ -425,8 +442,8 @@ public ServiceCall listRoles(ListRolesOptions listRolesOptions) { if (listRolesOptions.serviceGroupId() != null) { builder.query("service_group_id", String.valueOf(listRolesOptions.serviceGroupId())); } - ResponseConverter responseConverter = - ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); return createServiceCall(builder.build(), responseConverter); } @@ -439,9 +456,9 @@ public ServiceCall listRoles(ListRolesOptions listRolesOptions) { * mutually exclusive. Only roles that match the filter and that the caller has read access to are returned. If the * caller does not have read access to any roles an empty array is returned. * - * @return a {@link ServiceCall} with a result of type {@link RoleList} + * @return a {@link ServiceCall} with a result of type {@link RoleCollection} */ - public ServiceCall listRoles() { + public ServiceCall listRoles() { return listRoles(null); } @@ -637,7 +654,7 @@ public ServiceCall listV2Policies(ListV2PoliciesOptions list * The policy resource must include either the **`serviceType`**, **`serviceName`**, **`resourceGroupId`** or * **`service_group_id`** attribute and the **`accountId`** attribute. In the rule field, you can specify a single * condition by using **`key`**, **`value`**, and condition **`operator`**, or a set of **`conditions`** with a - * combination **`operator`**. The possible combination operators are **`and`** and **`or`**. Combine conditions to + * combination **`operator`**. The possible combination operators are **`and`** and **`or`**. Combine conditions to * specify a time-based restriction (e.g., access only during business hours, during the Monday-Friday work week). For * example, a policy can grant access Monday-Friday, 9:00am-5:00pm using the following rule: * ```json @@ -740,7 +757,7 @@ public ServiceCall createV2Policy(CreateV2PolicyOptions createV2Policy * The policy resource must include either the **`serviceType`**, **`serviceName`**, **`resourceGroupId`** or * **`service_group_id`** attribute and the **`accountId`** attribute. In the rule field, you can specify a single * condition by using **`key`**, **`value`**, and condition **`operator`**, or a set of **`conditions`** with a - * combination **`operator`**. The possible combination operators are **`and`** and **`or`**. Combine conditions to + * combination **`operator`**. The possible combination operators are **`and`** and **`or`**. Combine conditions to * specify a time-based restriction (e.g., access only during business hours, during the Monday-Friday work week). For * example, a policy can grant access Monday-Friday, 9:00am-5:00pm using the following rule: * ```json @@ -872,4 +889,347 @@ public ServiceCall deleteV2Policy(DeleteV2PolicyOptions deleteV2PolicyOpti return createServiceCall(builder.build(), responseConverter); } + /** + * List policy templates by attributes. + * + * List policy templates and filter by attributes by using query parameters. The following attributes are supported: + * `account_id`. + * `account_id` is a required query parameter. Only policy 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 policy templates an empty + * array is returned. + * + * @param listPolicyTemplatesOptions the {@link ListPolicyTemplatesOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link PolicyTemplateCollection} + */ + public ServiceCall listPolicyTemplates(ListPolicyTemplatesOptions listPolicyTemplatesOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(listPolicyTemplatesOptions, + "listPolicyTemplatesOptions cannot be null"); + RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/policy_templates")); + Map sdkHeaders = SdkCommon.getSdkHeaders("iam_policy_management", "v1", "listPolicyTemplates"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + if (listPolicyTemplatesOptions.acceptLanguage() != null) { + builder.header("Accept-Language", listPolicyTemplatesOptions.acceptLanguage()); + } + builder.query("account_id", String.valueOf(listPolicyTemplatesOptions.accountId())); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Create a policy template. + * + * Create a policy template. Policy templates define a policy without requiring a subject, and you can use them to + * grant access to multiple subjects. + * + * @param createPolicyTemplateOptions the {@link CreatePolicyTemplateOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link PolicyTemplate} + */ + public ServiceCall createPolicyTemplate(CreatePolicyTemplateOptions createPolicyTemplateOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(createPolicyTemplateOptions, + "createPolicyTemplateOptions cannot be null"); + RequestBuilder builder = RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/policy_templates")); + Map sdkHeaders = SdkCommon.getSdkHeaders("iam_policy_management", "v1", "createPolicyTemplate"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + if (createPolicyTemplateOptions.acceptLanguage() != null) { + builder.header("Accept-Language", createPolicyTemplateOptions.acceptLanguage()); + } + final JsonObject contentJson = new JsonObject(); + contentJson.addProperty("name", createPolicyTemplateOptions.name()); + contentJson.addProperty("account_id", createPolicyTemplateOptions.accountId()); + contentJson.add("policy", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(createPolicyTemplateOptions.policy())); + if (createPolicyTemplateOptions.description() != null) { + contentJson.addProperty("description", createPolicyTemplateOptions.description()); + } + if (createPolicyTemplateOptions.committed() != null) { + contentJson.addProperty("committed", createPolicyTemplateOptions.committed()); + } + builder.bodyJson(contentJson); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Retrieve latest version of a policy template. + * + * Retrieve the latest version of a policy template by providing a policy template ID. + * + * @param getPolicyTemplateOptions the {@link GetPolicyTemplateOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link PolicyTemplate} + */ + public ServiceCall getPolicyTemplate(GetPolicyTemplateOptions getPolicyTemplateOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(getPolicyTemplateOptions, + "getPolicyTemplateOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("policy_template_id", getPolicyTemplateOptions.policyTemplateId()); + RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/policy_templates/{policy_template_id}", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("iam_policy_management", "v1", "getPolicyTemplate"); + 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); + } + + /** + * Delete a policy template. + * + * Delete a policy template by providing the policy template ID. This deletes all versions of this template. A policy + * template can't be deleted if any version of the template is assigned to one or more child accounts. You must remove + * the policy assignments first. + * + * @param deletePolicyTemplateOptions the {@link DeletePolicyTemplateOptions} containing the options for the call + * @return a {@link ServiceCall} with a void result + */ + public ServiceCall deletePolicyTemplate(DeletePolicyTemplateOptions deletePolicyTemplateOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(deletePolicyTemplateOptions, + "deletePolicyTemplateOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("policy_template_id", deletePolicyTemplateOptions.policyTemplateId()); + RequestBuilder builder = RequestBuilder.delete(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/policy_templates/{policy_template_id}", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("iam_policy_management", "v1", "deletePolicyTemplate"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Create a new policy template version. + * + * Create a new version of a policy template. Use this if you need to make updates to a policy template that is + * committed. + * + * @param createPolicyTemplateVersionOptions the {@link CreatePolicyTemplateVersionOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link PolicyTemplate} + */ + public ServiceCall createPolicyTemplateVersion(CreatePolicyTemplateVersionOptions createPolicyTemplateVersionOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(createPolicyTemplateVersionOptions, + "createPolicyTemplateVersionOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("policy_template_id", createPolicyTemplateVersionOptions.policyTemplateId()); + RequestBuilder builder = RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/policy_templates/{policy_template_id}/versions", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("iam_policy_management", "v1", "createPolicyTemplateVersion"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + final JsonObject contentJson = new JsonObject(); + contentJson.add("policy", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(createPolicyTemplateVersionOptions.policy())); + if (createPolicyTemplateVersionOptions.description() != null) { + contentJson.addProperty("description", createPolicyTemplateVersionOptions.description()); + } + if (createPolicyTemplateVersionOptions.committed() != null) { + contentJson.addProperty("committed", createPolicyTemplateVersionOptions.committed()); + } + builder.bodyJson(contentJson); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Retrieve policy template versions. + * + * Retrieve the versions of a policy template by providing a policy template ID. + * + * @param listPolicyTemplateVersionsOptions the {@link ListPolicyTemplateVersionsOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link PolicyTemplateVersionsCollection} + */ + public ServiceCall listPolicyTemplateVersions(ListPolicyTemplateVersionsOptions listPolicyTemplateVersionsOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(listPolicyTemplateVersionsOptions, + "listPolicyTemplateVersionsOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("policy_template_id", listPolicyTemplateVersionsOptions.policyTemplateId()); + RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/policy_templates/{policy_template_id}/versions", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("iam_policy_management", "v1", "listPolicyTemplateVersions"); + 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 policy template version. + * + * Update a specific version of a policy template. You can use this only if the version isn't committed. + * + * @param replacePolicyTemplateOptions the {@link ReplacePolicyTemplateOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link PolicyTemplate} + */ + public ServiceCall replacePolicyTemplate(ReplacePolicyTemplateOptions replacePolicyTemplateOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(replacePolicyTemplateOptions, + "replacePolicyTemplateOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("policy_template_id", replacePolicyTemplateOptions.policyTemplateId()); + pathParamsMap.put("version", replacePolicyTemplateOptions.version()); + RequestBuilder builder = RequestBuilder.put(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/policy_templates/{policy_template_id}/versions/{version}", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("iam_policy_management", "v1", "replacePolicyTemplate"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + builder.header("If-Match", replacePolicyTemplateOptions.ifMatch()); + final JsonObject contentJson = new JsonObject(); + contentJson.add("policy", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(replacePolicyTemplateOptions.policy())); + if (replacePolicyTemplateOptions.description() != null) { + contentJson.addProperty("description", replacePolicyTemplateOptions.description()); + } + if (replacePolicyTemplateOptions.committed() != null) { + contentJson.addProperty("committed", replacePolicyTemplateOptions.committed()); + } + builder.bodyJson(contentJson); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Delete a policy template version. + * + * Delete a specific version of a policy template by providing a policy template ID and version number. You can't + * delete a policy template version that is assigned to one or more child accounts. You must remove the policy + * assignments first. + * + * @param deletePolicyTemplateVersionOptions the {@link DeletePolicyTemplateVersionOptions} containing the options for the call + * @return a {@link ServiceCall} with a void result + */ + public ServiceCall deletePolicyTemplateVersion(DeletePolicyTemplateVersionOptions deletePolicyTemplateVersionOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(deletePolicyTemplateVersionOptions, + "deletePolicyTemplateVersionOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("policy_template_id", deletePolicyTemplateVersionOptions.policyTemplateId()); + pathParamsMap.put("version", deletePolicyTemplateVersionOptions.version()); + RequestBuilder builder = RequestBuilder.delete(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/policy_templates/{policy_template_id}/versions/{version}", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("iam_policy_management", "v1", "deletePolicyTemplateVersion"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Retrieve a policy template version. + * + * Retrieve a policy template by providing a policy template ID and version number. + * + * @param getPolicyTemplateVersionOptions the {@link GetPolicyTemplateVersionOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link PolicyTemplate} + */ + public ServiceCall getPolicyTemplateVersion(GetPolicyTemplateVersionOptions getPolicyTemplateVersionOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(getPolicyTemplateVersionOptions, + "getPolicyTemplateVersionOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("policy_template_id", getPolicyTemplateVersionOptions.policyTemplateId()); + pathParamsMap.put("version", getPolicyTemplateVersionOptions.version()); + RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/policy_templates/{policy_template_id}/versions/{version}", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("iam_policy_management", "v1", "getPolicyTemplateVersion"); + 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 policy template version. + * + * Commit a policy template version. You can make no further changes to the policy template once it's committed. If + * you need to make updates after committing a version, create a new version. + * + * @param commitPolicyTemplateOptions the {@link CommitPolicyTemplateOptions} containing the options for the call + * @return a {@link ServiceCall} with a void result + */ + public ServiceCall commitPolicyTemplate(CommitPolicyTemplateOptions commitPolicyTemplateOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(commitPolicyTemplateOptions, + "commitPolicyTemplateOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("policy_template_id", commitPolicyTemplateOptions.policyTemplateId()); + pathParamsMap.put("version", commitPolicyTemplateOptions.version()); + RequestBuilder builder = RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/policy_templates/{policy_template_id}/versions/{version}/commit", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("iam_policy_management", "v1", "commitPolicyTemplate"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("If-Match", commitPolicyTemplateOptions.ifMatch()); + ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Get policy template assignments. + * + * Get policy template assignments by attributes. The following attributes are supported: + * `account_id`, `template_id`, `template_version`, `sort`. + * `account_id` is a required query parameter. Only policy template assignments 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 policy template + * assignments an empty array is returned. + * + * @param listPolicyAssignmentsOptions the {@link ListPolicyAssignmentsOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link PolicyTemplateAssignmentCollection} + */ + public ServiceCall listPolicyAssignments(ListPolicyAssignmentsOptions listPolicyAssignmentsOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(listPolicyAssignmentsOptions, + "listPolicyAssignmentsOptions cannot be null"); + RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/policy_assignments")); + Map sdkHeaders = SdkCommon.getSdkHeaders("iam_policy_management", "v1", "listPolicyAssignments"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + if (listPolicyAssignmentsOptions.acceptLanguage() != null) { + builder.header("Accept-Language", listPolicyAssignmentsOptions.acceptLanguage()); + } + builder.query("account_id", String.valueOf(listPolicyAssignmentsOptions.accountId())); + if (listPolicyAssignmentsOptions.templateId() != null) { + builder.query("template_id", String.valueOf(listPolicyAssignmentsOptions.templateId())); + } + if (listPolicyAssignmentsOptions.templateVersion() != null) { + builder.query("template_version", String.valueOf(listPolicyAssignmentsOptions.templateVersion())); + } + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Retrieve a policy assignment. + * + * Retrieve a policy template assignment by providing a policy assignment ID. + * + * @param getPolicyAssignmentOptions the {@link GetPolicyAssignmentOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link PolicyAssignment} + */ + public ServiceCall getPolicyAssignment(GetPolicyAssignmentOptions getPolicyAssignmentOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(getPolicyAssignmentOptions, + "getPolicyAssignmentOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("assignment_id", getPolicyAssignmentOptions.assignmentId()); + RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/policy_assignments/{assignment_id}", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("iam_policy_management", "v1", "getPolicyAssignment"); + 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); + } + } diff --git a/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/AssignmentResourceCreated.java b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/AssignmentResourceCreated.java new file mode 100644 index 0000000000..b42e65136d --- /dev/null +++ b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/AssignmentResourceCreated.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2023. + * + * 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, includes the policy assigned. + */ +public class AssignmentResourceCreated extends GenericModel { + + protected String id; + + protected AssignmentResourceCreated() { } + + /** + * Gets the id. + * + * policy 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/CommitPolicyTemplateOptions.java b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/CommitPolicyTemplateOptions.java new file mode 100644 index 0000000000..3784a83350 --- /dev/null +++ b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/CommitPolicyTemplateOptions.java @@ -0,0 +1,165 @@ +/* + * (C) Copyright IBM Corp. 2023. + * + * 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 commitPolicyTemplate options. + */ +public class CommitPolicyTemplateOptions extends GenericModel { + + protected String policyTemplateId; + protected String version; + protected String ifMatch; + + /** + * Builder. + */ + public static class Builder { + private String policyTemplateId; + private String version; + private String ifMatch; + + /** + * Instantiates a new Builder from an existing CommitPolicyTemplateOptions instance. + * + * @param commitPolicyTemplateOptions the instance to initialize the Builder with + */ + private Builder(CommitPolicyTemplateOptions commitPolicyTemplateOptions) { + this.policyTemplateId = commitPolicyTemplateOptions.policyTemplateId; + this.version = commitPolicyTemplateOptions.version; + this.ifMatch = commitPolicyTemplateOptions.ifMatch; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Instantiates a new builder with required properties. + * + * @param policyTemplateId the policyTemplateId + * @param version the version + * @param ifMatch the ifMatch + */ + public Builder(String policyTemplateId, String version, String ifMatch) { + this.policyTemplateId = policyTemplateId; + this.version = version; + this.ifMatch = ifMatch; + } + + /** + * Builds a CommitPolicyTemplateOptions. + * + * @return the new CommitPolicyTemplateOptions instance + */ + public CommitPolicyTemplateOptions build() { + return new CommitPolicyTemplateOptions(this); + } + + /** + * Set the policyTemplateId. + * + * @param policyTemplateId the policyTemplateId + * @return the CommitPolicyTemplateOptions builder + */ + public Builder policyTemplateId(String policyTemplateId) { + this.policyTemplateId = policyTemplateId; + return this; + } + + /** + * Set the version. + * + * @param version the version + * @return the CommitPolicyTemplateOptions builder + */ + public Builder version(String version) { + this.version = version; + return this; + } + + /** + * Set the ifMatch. + * + * @param ifMatch the ifMatch + * @return the CommitPolicyTemplateOptions builder + */ + public Builder ifMatch(String ifMatch) { + this.ifMatch = ifMatch; + return this; + } + } + + protected CommitPolicyTemplateOptions() { } + + protected CommitPolicyTemplateOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.policyTemplateId, + "policyTemplateId 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"); + policyTemplateId = builder.policyTemplateId; + version = builder.version; + ifMatch = builder.ifMatch; + } + + /** + * New builder. + * + * @return a CommitPolicyTemplateOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the policyTemplateId. + * + * The policy template ID. + * + * @return the policyTemplateId + */ + public String policyTemplateId() { + return policyTemplateId; + } + + /** + * Gets the version. + * + * The policy template version. + * + * @return the version + */ + public String version() { + return version; + } + + /** + * Gets the ifMatch. + * + * The revision number for updating a policy template version and must match the ETag value of the existing policy + * template version. The Etag can be retrieved using the GET + * /v1/policy_templates/{policy_template_id}/versions/{version} API and looking at the ETag response header. + * + * @return the ifMatch + */ + public String ifMatch() { + return ifMatch; + } +} + diff --git a/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ConflictsWith.java b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ConflictsWith.java new file mode 100644 index 0000000000..99b86fe774 --- /dev/null +++ b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ConflictsWith.java @@ -0,0 +1,61 @@ +/* + * (C) Copyright IBM Corp. 2023. + * + * 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; + +/** + * Details of conflicting resource. + */ +public class ConflictsWith extends GenericModel { + + protected String etag; + protected String role; + protected String policy; + + protected ConflictsWith() { } + + /** + * Gets the etag. + * + * The revision number of the resource. + * + * @return the etag + */ + public String getEtag() { + return etag; + } + + /** + * Gets the role. + * + * The conflicting role id. + * + * @return the role + */ + public String getRole() { + return role; + } + + /** + * Gets the policy. + * + * The conflicting policy id. + * + * @return the policy + */ + public String getPolicy() { + return policy; + } +} + diff --git a/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/CreatePolicyTemplateOptions.java b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/CreatePolicyTemplateOptions.java new file mode 100644 index 0000000000..e24c7431ff --- /dev/null +++ b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/CreatePolicyTemplateOptions.java @@ -0,0 +1,254 @@ +/* + * (C) Copyright IBM Corp. 2023. + * + * 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 createPolicyTemplate options. + */ +public class CreatePolicyTemplateOptions extends GenericModel { + + protected String name; + protected String accountId; + protected TemplatePolicy policy; + protected String description; + protected Boolean committed; + protected String acceptLanguage; + + /** + * Builder. + */ + public static class Builder { + private String name; + private String accountId; + private TemplatePolicy policy; + private String description; + private Boolean committed; + private String acceptLanguage; + + /** + * Instantiates a new Builder from an existing CreatePolicyTemplateOptions instance. + * + * @param createPolicyTemplateOptions the instance to initialize the Builder with + */ + private Builder(CreatePolicyTemplateOptions createPolicyTemplateOptions) { + this.name = createPolicyTemplateOptions.name; + this.accountId = createPolicyTemplateOptions.accountId; + this.policy = createPolicyTemplateOptions.policy; + this.description = createPolicyTemplateOptions.description; + this.committed = createPolicyTemplateOptions.committed; + this.acceptLanguage = createPolicyTemplateOptions.acceptLanguage; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Instantiates a new builder with required properties. + * + * @param name the name + * @param accountId the accountId + * @param policy the policy + */ + public Builder(String name, String accountId, TemplatePolicy policy) { + this.name = name; + this.accountId = accountId; + this.policy = policy; + } + + /** + * Builds a CreatePolicyTemplateOptions. + * + * @return the new CreatePolicyTemplateOptions instance + */ + public CreatePolicyTemplateOptions build() { + return new CreatePolicyTemplateOptions(this); + } + + /** + * Set the name. + * + * @param name the name + * @return the CreatePolicyTemplateOptions builder + */ + public Builder name(String name) { + this.name = name; + return this; + } + + /** + * Set the accountId. + * + * @param accountId the accountId + * @return the CreatePolicyTemplateOptions builder + */ + public Builder accountId(String accountId) { + this.accountId = accountId; + return this; + } + + /** + * Set the policy. + * + * @param policy the policy + * @return the CreatePolicyTemplateOptions builder + */ + public Builder policy(TemplatePolicy policy) { + this.policy = policy; + return this; + } + + /** + * Set the description. + * + * @param description the description + * @return the CreatePolicyTemplateOptions builder + */ + public Builder description(String description) { + this.description = description; + return this; + } + + /** + * Set the committed. + * + * @param committed the committed + * @return the CreatePolicyTemplateOptions builder + */ + public Builder committed(Boolean committed) { + this.committed = committed; + return this; + } + + /** + * Set the acceptLanguage. + * + * @param acceptLanguage the acceptLanguage + * @return the CreatePolicyTemplateOptions builder + */ + public Builder acceptLanguage(String acceptLanguage) { + this.acceptLanguage = acceptLanguage; + return this; + } + } + + protected CreatePolicyTemplateOptions() { } + + protected CreatePolicyTemplateOptions(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"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.policy, + "policy cannot be null"); + name = builder.name; + accountId = builder.accountId; + policy = builder.policy; + description = builder.description; + committed = builder.committed; + acceptLanguage = builder.acceptLanguage; + } + + /** + * New builder. + * + * @return a CreatePolicyTemplateOptions 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 will + * change 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 will be created. + * + * @return the accountId + */ + public String accountId() { + return accountId; + } + + /** + * Gets the policy. + * + * The core set of properties associated with the template's policy objet. + * + * @return the policy + */ + public TemplatePolicy policy() { + return policy; + } + + /** + * Gets the description. + * + * Description of the policy template. This is shown to users in the enterprise account. Use this to describe the + * purpose or context of the policy for enterprise users managing IAM templates. + * + * @return the description + */ + public String description() { + return description; + } + + /** + * Gets the committed. + * + * Committed status of the template. + * + * @return the committed + */ + public Boolean committed() { + return committed; + } + + /** + * 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/CreatePolicyTemplateVersionOptions.java b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/CreatePolicyTemplateVersionOptions.java new file mode 100644 index 0000000000..575809e91c --- /dev/null +++ b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/CreatePolicyTemplateVersionOptions.java @@ -0,0 +1,186 @@ +/* + * (C) Copyright IBM Corp. 2023. + * + * 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 createPolicyTemplateVersion options. + */ +public class CreatePolicyTemplateVersionOptions extends GenericModel { + + protected String policyTemplateId; + protected TemplatePolicy policy; + protected String description; + protected Boolean committed; + + /** + * Builder. + */ + public static class Builder { + private String policyTemplateId; + private TemplatePolicy policy; + private String description; + private Boolean committed; + + /** + * Instantiates a new Builder from an existing CreatePolicyTemplateVersionOptions instance. + * + * @param createPolicyTemplateVersionOptions the instance to initialize the Builder with + */ + private Builder(CreatePolicyTemplateVersionOptions createPolicyTemplateVersionOptions) { + this.policyTemplateId = createPolicyTemplateVersionOptions.policyTemplateId; + this.policy = createPolicyTemplateVersionOptions.policy; + this.description = createPolicyTemplateVersionOptions.description; + this.committed = createPolicyTemplateVersionOptions.committed; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Instantiates a new builder with required properties. + * + * @param policyTemplateId the policyTemplateId + * @param policy the policy + */ + public Builder(String policyTemplateId, TemplatePolicy policy) { + this.policyTemplateId = policyTemplateId; + this.policy = policy; + } + + /** + * Builds a CreatePolicyTemplateVersionOptions. + * + * @return the new CreatePolicyTemplateVersionOptions instance + */ + public CreatePolicyTemplateVersionOptions build() { + return new CreatePolicyTemplateVersionOptions(this); + } + + /** + * Set the policyTemplateId. + * + * @param policyTemplateId the policyTemplateId + * @return the CreatePolicyTemplateVersionOptions builder + */ + public Builder policyTemplateId(String policyTemplateId) { + this.policyTemplateId = policyTemplateId; + return this; + } + + /** + * Set the policy. + * + * @param policy the policy + * @return the CreatePolicyTemplateVersionOptions builder + */ + public Builder policy(TemplatePolicy policy) { + this.policy = policy; + return this; + } + + /** + * Set the description. + * + * @param description the description + * @return the CreatePolicyTemplateVersionOptions builder + */ + public Builder description(String description) { + this.description = description; + return this; + } + + /** + * Set the committed. + * + * @param committed the committed + * @return the CreatePolicyTemplateVersionOptions builder + */ + public Builder committed(Boolean committed) { + this.committed = committed; + return this; + } + } + + protected CreatePolicyTemplateVersionOptions() { } + + protected CreatePolicyTemplateVersionOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.policyTemplateId, + "policyTemplateId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.policy, + "policy cannot be null"); + policyTemplateId = builder.policyTemplateId; + policy = builder.policy; + description = builder.description; + committed = builder.committed; + } + + /** + * New builder. + * + * @return a CreatePolicyTemplateVersionOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the policyTemplateId. + * + * The policy template ID. + * + * @return the policyTemplateId + */ + public String policyTemplateId() { + return policyTemplateId; + } + + /** + * Gets the policy. + * + * The core set of properties associated with the template's policy objet. + * + * @return the policy + */ + public TemplatePolicy policy() { + return policy; + } + + /** + * Gets the description. + * + * Description of the policy template. This is shown to users in the enterprise account. Use this to describe the + * purpose or context of the policy for enterprise users managing IAM templates. + * + * @return the description + */ + public String description() { + return description; + } + + /** + * Gets the committed. + * + * Committed status of the template version. + * + * @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/CreateV2PolicyOptions.java b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/CreateV2PolicyOptions.java index 05deb2d80b..cdaeb9c6ef 100644 --- a/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/CreateV2PolicyOptions.java +++ b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/CreateV2PolicyOptions.java @@ -233,7 +233,7 @@ public String type() { /** * Gets the description. * - * Allows the customer to use their own words to record the purpose/context related to a policy. + * Description of the policy. * * @return the description */ diff --git a/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/DeletePolicyAssignmentOptions.java b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/DeletePolicyAssignmentOptions.java new file mode 100644 index 0000000000..b32c64c9b5 --- /dev/null +++ b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/DeletePolicyAssignmentOptions.java @@ -0,0 +1,103 @@ +/* + * (C) Copyright IBM Corp. 2023. + * + * 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 deletePolicyAssignment options. + */ +public class DeletePolicyAssignmentOptions extends GenericModel { + + protected String assignmentId; + + /** + * Builder. + */ + public static class Builder { + private String assignmentId; + + /** + * Instantiates a new Builder from an existing DeletePolicyAssignmentOptions instance. + * + * @param deletePolicyAssignmentOptions the instance to initialize the Builder with + */ + private Builder(DeletePolicyAssignmentOptions deletePolicyAssignmentOptions) { + this.assignmentId = deletePolicyAssignmentOptions.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 DeletePolicyAssignmentOptions. + * + * @return the new DeletePolicyAssignmentOptions instance + */ + public DeletePolicyAssignmentOptions build() { + return new DeletePolicyAssignmentOptions(this); + } + + /** + * Set the assignmentId. + * + * @param assignmentId the assignmentId + * @return the DeletePolicyAssignmentOptions builder + */ + public Builder assignmentId(String assignmentId) { + this.assignmentId = assignmentId; + return this; + } + } + + protected DeletePolicyAssignmentOptions() { } + + protected DeletePolicyAssignmentOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.assignmentId, + "assignmentId cannot be empty"); + assignmentId = builder.assignmentId; + } + + /** + * New builder. + * + * @return a DeletePolicyAssignmentOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the assignmentId. + * + * The policy 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/DeletePolicyTemplateOptions.java b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/DeletePolicyTemplateOptions.java new file mode 100644 index 0000000000..b1d0accd55 --- /dev/null +++ b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/DeletePolicyTemplateOptions.java @@ -0,0 +1,103 @@ +/* + * (C) Copyright IBM Corp. 2023. + * + * 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 deletePolicyTemplate options. + */ +public class DeletePolicyTemplateOptions extends GenericModel { + + protected String policyTemplateId; + + /** + * Builder. + */ + public static class Builder { + private String policyTemplateId; + + /** + * Instantiates a new Builder from an existing DeletePolicyTemplateOptions instance. + * + * @param deletePolicyTemplateOptions the instance to initialize the Builder with + */ + private Builder(DeletePolicyTemplateOptions deletePolicyTemplateOptions) { + this.policyTemplateId = deletePolicyTemplateOptions.policyTemplateId; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Instantiates a new builder with required properties. + * + * @param policyTemplateId the policyTemplateId + */ + public Builder(String policyTemplateId) { + this.policyTemplateId = policyTemplateId; + } + + /** + * Builds a DeletePolicyTemplateOptions. + * + * @return the new DeletePolicyTemplateOptions instance + */ + public DeletePolicyTemplateOptions build() { + return new DeletePolicyTemplateOptions(this); + } + + /** + * Set the policyTemplateId. + * + * @param policyTemplateId the policyTemplateId + * @return the DeletePolicyTemplateOptions builder + */ + public Builder policyTemplateId(String policyTemplateId) { + this.policyTemplateId = policyTemplateId; + return this; + } + } + + protected DeletePolicyTemplateOptions() { } + + protected DeletePolicyTemplateOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.policyTemplateId, + "policyTemplateId cannot be empty"); + policyTemplateId = builder.policyTemplateId; + } + + /** + * New builder. + * + * @return a DeletePolicyTemplateOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the policyTemplateId. + * + * The policy template ID. + * + * @return the policyTemplateId + */ + public String policyTemplateId() { + return policyTemplateId; + } +} + diff --git a/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/DeletePolicyTemplateVersionOptions.java b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/DeletePolicyTemplateVersionOptions.java new file mode 100644 index 0000000000..ba77dda584 --- /dev/null +++ b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/DeletePolicyTemplateVersionOptions.java @@ -0,0 +1,133 @@ +/* + * (C) Copyright IBM Corp. 2023. + * + * 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 deletePolicyTemplateVersion options. + */ +public class DeletePolicyTemplateVersionOptions extends GenericModel { + + protected String policyTemplateId; + protected String version; + + /** + * Builder. + */ + public static class Builder { + private String policyTemplateId; + private String version; + + /** + * Instantiates a new Builder from an existing DeletePolicyTemplateVersionOptions instance. + * + * @param deletePolicyTemplateVersionOptions the instance to initialize the Builder with + */ + private Builder(DeletePolicyTemplateVersionOptions deletePolicyTemplateVersionOptions) { + this.policyTemplateId = deletePolicyTemplateVersionOptions.policyTemplateId; + this.version = deletePolicyTemplateVersionOptions.version; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Instantiates a new builder with required properties. + * + * @param policyTemplateId the policyTemplateId + * @param version the version + */ + public Builder(String policyTemplateId, String version) { + this.policyTemplateId = policyTemplateId; + this.version = version; + } + + /** + * Builds a DeletePolicyTemplateVersionOptions. + * + * @return the new DeletePolicyTemplateVersionOptions instance + */ + public DeletePolicyTemplateVersionOptions build() { + return new DeletePolicyTemplateVersionOptions(this); + } + + /** + * Set the policyTemplateId. + * + * @param policyTemplateId the policyTemplateId + * @return the DeletePolicyTemplateVersionOptions builder + */ + public Builder policyTemplateId(String policyTemplateId) { + this.policyTemplateId = policyTemplateId; + return this; + } + + /** + * Set the version. + * + * @param version the version + * @return the DeletePolicyTemplateVersionOptions builder + */ + public Builder version(String version) { + this.version = version; + return this; + } + } + + protected DeletePolicyTemplateVersionOptions() { } + + protected DeletePolicyTemplateVersionOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.policyTemplateId, + "policyTemplateId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.version, + "version cannot be empty"); + policyTemplateId = builder.policyTemplateId; + version = builder.version; + } + + /** + * New builder. + * + * @return a DeletePolicyTemplateVersionOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the policyTemplateId. + * + * The policy template ID. + * + * @return the policyTemplateId + */ + public String policyTemplateId() { + return policyTemplateId; + } + + /** + * Gets the version. + * + * The policy 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/ErrorDetails.java b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ErrorDetails.java new file mode 100644 index 0000000000..435a506002 --- /dev/null +++ b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ErrorDetails.java @@ -0,0 +1,39 @@ +/* + * (C) Copyright IBM Corp. 2023. + * + * 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; + +/** + * Additional error details. + */ +public class ErrorDetails extends GenericModel { + + @SerializedName("conflicts_with") + protected ConflictsWith conflictsWith; + + protected ErrorDetails() { } + + /** + * Gets the conflictsWith. + * + * Details of conflicting resource. + * + * @return the conflictsWith + */ + public ConflictsWith getConflictsWith() { + return conflictsWith; + } +} + 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 new file mode 100644 index 0000000000..bcba4a61fe --- /dev/null +++ b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ErrorObject.java @@ -0,0 +1,115 @@ +/* + * (C) Copyright IBM Corp. 2023. + * + * 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; + +/** + * ErrorObject. + */ +public class ErrorObject extends GenericModel { + + /** + * The API error code for the error. + */ + public interface Code { + /** insufficent_permissions. */ + String INSUFFICENT_PERMISSIONS = "insufficent_permissions"; + /** invalid_body. */ + String INVALID_BODY = "invalid_body"; + /** invalid_token. */ + String INVALID_TOKEN = "invalid_token"; + /** missing_required_query_parameter. */ + String MISSING_REQUIRED_QUERY_PARAMETER = "missing_required_query_parameter"; + /** not_found. */ + String NOT_FOUND = "not_found"; + /** policy_conflict_error. */ + String POLICY_CONFLICT_ERROR = "policy_conflict_error"; + /** policy_not_found. */ + String POLICY_NOT_FOUND = "policy_not_found"; + /** request_not_processed. */ + String REQUEST_NOT_PROCESSED = "request_not_processed"; + /** role_conflict_error. */ + String ROLE_CONFLICT_ERROR = "role_conflict_error"; + /** role_not_found. */ + String ROLE_NOT_FOUND = "role_not_found"; + /** too_many_requests. */ + String TOO_MANY_REQUESTS = "too_many_requests"; + /** unable_to_process. */ + String UNABLE_TO_PROCESS = "unable_to_process"; + /** unsupported_content_type. */ + String UNSUPPORTED_CONTENT_TYPE = "unsupported_content_type"; + /** policy_template_conflict_error. */ + String POLICY_TEMPLATE_CONFLICT_ERROR = "policy_template_conflict_error"; + /** policy_template_not_found. */ + String POLICY_TEMPLATE_NOT_FOUND = "policy_template_not_found"; + /** policy_assignment_not_found. */ + String POLICY_ASSIGNMENT_NOT_FOUND = "policy_assignment_not_found"; + /** policy_assignment_conflict_error. */ + String POLICY_ASSIGNMENT_CONFLICT_ERROR = "policy_assignment_conflict_error"; + } + + protected String code; + protected String message; + protected ErrorDetails details; + @SerializedName("more_info") + protected String moreInfo; + + protected ErrorObject() { } + + /** + * Gets the code. + * + * The API error code for the error. + * + * @return the code + */ + public String getCode() { + return code; + } + + /** + * Gets the message. + * + * The error message returned by the API. + * + * @return the message + */ + public String getMessage() { + return message; + } + + /** + * Gets the details. + * + * Additional error details. + * + * @return the details + */ + public ErrorDetails getDetails() { + return details; + } + + /** + * Gets the moreInfo. + * + * Additional info for error. + * + * @return the moreInfo + */ + public String getMoreInfo() { + return moreInfo; + } +} + diff --git a/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ErrorResponse.java b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ErrorResponse.java new file mode 100644 index 0000000000..8c1b85e6cc --- /dev/null +++ b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ErrorResponse.java @@ -0,0 +1,65 @@ +/* + * (C) Copyright IBM Corp. 2023. + * + * 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; + +/** + * The error response from API. + */ +public class ErrorResponse extends GenericModel { + + protected String trace; + protected List errors; + @SerializedName("status_code") + protected Long statusCode; + + protected ErrorResponse() { } + + /** + * Gets the trace. + * + * The unique transaction id for the request. + * + * @return the trace + */ + public String getTrace() { + return trace; + } + + /** + * Gets the errors. + * + * The errors encountered during the response. + * + * @return the errors + */ + public List getErrors() { + return errors; + } + + /** + * Gets the statusCode. + * + * The http error code of the response. + * + * @return the statusCode + */ + public Long getStatusCode() { + return statusCode; + } +} + diff --git a/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/GetPolicyAssignmentOptions.java b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/GetPolicyAssignmentOptions.java new file mode 100644 index 0000000000..152f6c0dba --- /dev/null +++ b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/GetPolicyAssignmentOptions.java @@ -0,0 +1,103 @@ +/* + * (C) Copyright IBM Corp. 2023. + * + * 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 getPolicyAssignment options. + */ +public class GetPolicyAssignmentOptions extends GenericModel { + + protected String assignmentId; + + /** + * Builder. + */ + public static class Builder { + private String assignmentId; + + /** + * Instantiates a new Builder from an existing GetPolicyAssignmentOptions instance. + * + * @param getPolicyAssignmentOptions the instance to initialize the Builder with + */ + private Builder(GetPolicyAssignmentOptions getPolicyAssignmentOptions) { + this.assignmentId = getPolicyAssignmentOptions.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 GetPolicyAssignmentOptions. + * + * @return the new GetPolicyAssignmentOptions instance + */ + public GetPolicyAssignmentOptions build() { + return new GetPolicyAssignmentOptions(this); + } + + /** + * Set the assignmentId. + * + * @param assignmentId the assignmentId + * @return the GetPolicyAssignmentOptions builder + */ + public Builder assignmentId(String assignmentId) { + this.assignmentId = assignmentId; + return this; + } + } + + protected GetPolicyAssignmentOptions() { } + + protected GetPolicyAssignmentOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.assignmentId, + "assignmentId cannot be empty"); + assignmentId = builder.assignmentId; + } + + /** + * New builder. + * + * @return a GetPolicyAssignmentOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the assignmentId. + * + * The policy 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/GetPolicyTemplateOptions.java b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/GetPolicyTemplateOptions.java new file mode 100644 index 0000000000..a4278c1e79 --- /dev/null +++ b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/GetPolicyTemplateOptions.java @@ -0,0 +1,103 @@ +/* + * (C) Copyright IBM Corp. 2023. + * + * 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 getPolicyTemplate options. + */ +public class GetPolicyTemplateOptions extends GenericModel { + + protected String policyTemplateId; + + /** + * Builder. + */ + public static class Builder { + private String policyTemplateId; + + /** + * Instantiates a new Builder from an existing GetPolicyTemplateOptions instance. + * + * @param getPolicyTemplateOptions the instance to initialize the Builder with + */ + private Builder(GetPolicyTemplateOptions getPolicyTemplateOptions) { + this.policyTemplateId = getPolicyTemplateOptions.policyTemplateId; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Instantiates a new builder with required properties. + * + * @param policyTemplateId the policyTemplateId + */ + public Builder(String policyTemplateId) { + this.policyTemplateId = policyTemplateId; + } + + /** + * Builds a GetPolicyTemplateOptions. + * + * @return the new GetPolicyTemplateOptions instance + */ + public GetPolicyTemplateOptions build() { + return new GetPolicyTemplateOptions(this); + } + + /** + * Set the policyTemplateId. + * + * @param policyTemplateId the policyTemplateId + * @return the GetPolicyTemplateOptions builder + */ + public Builder policyTemplateId(String policyTemplateId) { + this.policyTemplateId = policyTemplateId; + return this; + } + } + + protected GetPolicyTemplateOptions() { } + + protected GetPolicyTemplateOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.policyTemplateId, + "policyTemplateId cannot be empty"); + policyTemplateId = builder.policyTemplateId; + } + + /** + * New builder. + * + * @return a GetPolicyTemplateOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the policyTemplateId. + * + * The policy template ID. + * + * @return the policyTemplateId + */ + public String policyTemplateId() { + return policyTemplateId; + } +} + diff --git a/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/GetPolicyTemplateVersionOptions.java b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/GetPolicyTemplateVersionOptions.java new file mode 100644 index 0000000000..f2a5857f45 --- /dev/null +++ b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/GetPolicyTemplateVersionOptions.java @@ -0,0 +1,133 @@ +/* + * (C) Copyright IBM Corp. 2023. + * + * 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 getPolicyTemplateVersion options. + */ +public class GetPolicyTemplateVersionOptions extends GenericModel { + + protected String policyTemplateId; + protected String version; + + /** + * Builder. + */ + public static class Builder { + private String policyTemplateId; + private String version; + + /** + * Instantiates a new Builder from an existing GetPolicyTemplateVersionOptions instance. + * + * @param getPolicyTemplateVersionOptions the instance to initialize the Builder with + */ + private Builder(GetPolicyTemplateVersionOptions getPolicyTemplateVersionOptions) { + this.policyTemplateId = getPolicyTemplateVersionOptions.policyTemplateId; + this.version = getPolicyTemplateVersionOptions.version; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Instantiates a new builder with required properties. + * + * @param policyTemplateId the policyTemplateId + * @param version the version + */ + public Builder(String policyTemplateId, String version) { + this.policyTemplateId = policyTemplateId; + this.version = version; + } + + /** + * Builds a GetPolicyTemplateVersionOptions. + * + * @return the new GetPolicyTemplateVersionOptions instance + */ + public GetPolicyTemplateVersionOptions build() { + return new GetPolicyTemplateVersionOptions(this); + } + + /** + * Set the policyTemplateId. + * + * @param policyTemplateId the policyTemplateId + * @return the GetPolicyTemplateVersionOptions builder + */ + public Builder policyTemplateId(String policyTemplateId) { + this.policyTemplateId = policyTemplateId; + return this; + } + + /** + * Set the version. + * + * @param version the version + * @return the GetPolicyTemplateVersionOptions builder + */ + public Builder version(String version) { + this.version = version; + return this; + } + } + + protected GetPolicyTemplateVersionOptions() { } + + protected GetPolicyTemplateVersionOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.policyTemplateId, + "policyTemplateId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.version, + "version cannot be empty"); + policyTemplateId = builder.policyTemplateId; + version = builder.version; + } + + /** + * New builder. + * + * @return a GetPolicyTemplateVersionOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the policyTemplateId. + * + * The policy template ID. + * + * @return the policyTemplateId + */ + public String policyTemplateId() { + return policyTemplateId; + } + + /** + * Gets the version. + * + * The policy 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/ListPolicyAssignmentsOptions.java b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ListPolicyAssignmentsOptions.java new file mode 100644 index 0000000000..78524d12d4 --- /dev/null +++ b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ListPolicyAssignmentsOptions.java @@ -0,0 +1,192 @@ +/* + * (C) Copyright IBM Corp. 2023. + * + * 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 listPolicyAssignments options. + */ +public class ListPolicyAssignmentsOptions extends GenericModel { + + protected String accountId; + protected String acceptLanguage; + protected String templateId; + protected String templateVersion; + + /** + * Builder. + */ + public static class Builder { + private String accountId; + private String acceptLanguage; + private String templateId; + private String templateVersion; + + /** + * Instantiates a new Builder from an existing ListPolicyAssignmentsOptions instance. + * + * @param listPolicyAssignmentsOptions the instance to initialize the Builder with + */ + private Builder(ListPolicyAssignmentsOptions listPolicyAssignmentsOptions) { + this.accountId = listPolicyAssignmentsOptions.accountId; + this.acceptLanguage = listPolicyAssignmentsOptions.acceptLanguage; + this.templateId = listPolicyAssignmentsOptions.templateId; + this.templateVersion = listPolicyAssignmentsOptions.templateVersion; + } + + /** + * 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 ListPolicyAssignmentsOptions. + * + * @return the new ListPolicyAssignmentsOptions instance + */ + public ListPolicyAssignmentsOptions build() { + return new ListPolicyAssignmentsOptions(this); + } + + /** + * Set the accountId. + * + * @param accountId the accountId + * @return the ListPolicyAssignmentsOptions builder + */ + public Builder accountId(String accountId) { + this.accountId = accountId; + return this; + } + + /** + * Set the acceptLanguage. + * + * @param acceptLanguage the acceptLanguage + * @return the ListPolicyAssignmentsOptions builder + */ + public Builder acceptLanguage(String acceptLanguage) { + this.acceptLanguage = acceptLanguage; + return this; + } + + /** + * Set the templateId. + * + * @param templateId the templateId + * @return the ListPolicyAssignmentsOptions builder + */ + public Builder templateId(String templateId) { + this.templateId = templateId; + return this; + } + + /** + * Set the templateVersion. + * + * @param templateVersion the templateVersion + * @return the ListPolicyAssignmentsOptions builder + */ + public Builder templateVersion(String templateVersion) { + this.templateVersion = templateVersion; + return this; + } + } + + protected ListPolicyAssignmentsOptions() { } + + protected ListPolicyAssignmentsOptions(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; + } + + /** + * New builder. + * + * @return a ListPolicyAssignmentsOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the accountId. + * + * The account GUID in which the policies 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 templateId. + * + * Optional template id. + * + * @return the templateId + */ + public String templateId() { + return templateId; + } + + /** + * Gets the templateVersion. + * + * Optional policy template version. + * + * @return the templateVersion + */ + public String templateVersion() { + return templateVersion; + } +} + diff --git a/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ListPolicyTemplateVersionsOptions.java b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ListPolicyTemplateVersionsOptions.java new file mode 100644 index 0000000000..b0b65efe41 --- /dev/null +++ b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ListPolicyTemplateVersionsOptions.java @@ -0,0 +1,103 @@ +/* + * (C) Copyright IBM Corp. 2023. + * + * 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 listPolicyTemplateVersions options. + */ +public class ListPolicyTemplateVersionsOptions extends GenericModel { + + protected String policyTemplateId; + + /** + * Builder. + */ + public static class Builder { + private String policyTemplateId; + + /** + * Instantiates a new Builder from an existing ListPolicyTemplateVersionsOptions instance. + * + * @param listPolicyTemplateVersionsOptions the instance to initialize the Builder with + */ + private Builder(ListPolicyTemplateVersionsOptions listPolicyTemplateVersionsOptions) { + this.policyTemplateId = listPolicyTemplateVersionsOptions.policyTemplateId; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Instantiates a new builder with required properties. + * + * @param policyTemplateId the policyTemplateId + */ + public Builder(String policyTemplateId) { + this.policyTemplateId = policyTemplateId; + } + + /** + * Builds a ListPolicyTemplateVersionsOptions. + * + * @return the new ListPolicyTemplateVersionsOptions instance + */ + public ListPolicyTemplateVersionsOptions build() { + return new ListPolicyTemplateVersionsOptions(this); + } + + /** + * Set the policyTemplateId. + * + * @param policyTemplateId the policyTemplateId + * @return the ListPolicyTemplateVersionsOptions builder + */ + public Builder policyTemplateId(String policyTemplateId) { + this.policyTemplateId = policyTemplateId; + return this; + } + } + + protected ListPolicyTemplateVersionsOptions() { } + + protected ListPolicyTemplateVersionsOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.policyTemplateId, + "policyTemplateId cannot be empty"); + policyTemplateId = builder.policyTemplateId; + } + + /** + * New builder. + * + * @return a ListPolicyTemplateVersionsOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the policyTemplateId. + * + * The policy template ID. + * + * @return the policyTemplateId + */ + public String policyTemplateId() { + return policyTemplateId; + } +} + diff --git a/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ListPolicyTemplateVerssionsOptions.java b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ListPolicyTemplateVerssionsOptions.java new file mode 100644 index 0000000000..5492d5315b --- /dev/null +++ b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ListPolicyTemplateVerssionsOptions.java @@ -0,0 +1,103 @@ +/* + * (C) Copyright IBM Corp. 2023. + * + * 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 listPolicyTemplateVerssions options. + */ +public class ListPolicyTemplateVerssionsOptions extends GenericModel { + + protected String policyTemplateId; + + /** + * Builder. + */ + public static class Builder { + private String policyTemplateId; + + /** + * Instantiates a new Builder from an existing ListPolicyTemplateVerssionsOptions instance. + * + * @param listPolicyTemplateVerssionsOptions the instance to initialize the Builder with + */ + private Builder(ListPolicyTemplateVerssionsOptions listPolicyTemplateVerssionsOptions) { + this.policyTemplateId = listPolicyTemplateVerssionsOptions.policyTemplateId; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Instantiates a new builder with required properties. + * + * @param policyTemplateId the policyTemplateId + */ + public Builder(String policyTemplateId) { + this.policyTemplateId = policyTemplateId; + } + + /** + * Builds a ListPolicyTemplateVerssionsOptions. + * + * @return the new ListPolicyTemplateVerssionsOptions instance + */ + public ListPolicyTemplateVerssionsOptions build() { + return new ListPolicyTemplateVerssionsOptions(this); + } + + /** + * Set the policyTemplateId. + * + * @param policyTemplateId the policyTemplateId + * @return the ListPolicyTemplateVerssionsOptions builder + */ + public Builder policyTemplateId(String policyTemplateId) { + this.policyTemplateId = policyTemplateId; + return this; + } + } + + protected ListPolicyTemplateVerssionsOptions() { } + + protected ListPolicyTemplateVerssionsOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.policyTemplateId, + "policyTemplateId cannot be empty"); + policyTemplateId = builder.policyTemplateId; + } + + /** + * New builder. + * + * @return a ListPolicyTemplateVerssionsOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the policyTemplateId. + * + * The policy template ID. + * + * @return the policyTemplateId + */ + public String policyTemplateId() { + return policyTemplateId; + } +} + diff --git a/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ListPolicyTemplatesOptions.java b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ListPolicyTemplatesOptions.java new file mode 100644 index 0000000000..f9ae7ae23a --- /dev/null +++ b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ListPolicyTemplatesOptions.java @@ -0,0 +1,140 @@ +/* + * (C) Copyright IBM Corp. 2023. + * + * 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 listPolicyTemplates options. + */ +public class ListPolicyTemplatesOptions extends GenericModel { + + protected String accountId; + protected String acceptLanguage; + + /** + * Builder. + */ + public static class Builder { + private String accountId; + private String acceptLanguage; + + /** + * Instantiates a new Builder from an existing ListPolicyTemplatesOptions instance. + * + * @param listPolicyTemplatesOptions the instance to initialize the Builder with + */ + private Builder(ListPolicyTemplatesOptions listPolicyTemplatesOptions) { + this.accountId = listPolicyTemplatesOptions.accountId; + this.acceptLanguage = listPolicyTemplatesOptions.acceptLanguage; + } + + /** + * 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 ListPolicyTemplatesOptions. + * + * @return the new ListPolicyTemplatesOptions instance + */ + public ListPolicyTemplatesOptions build() { + return new ListPolicyTemplatesOptions(this); + } + + /** + * Set the accountId. + * + * @param accountId the accountId + * @return the ListPolicyTemplatesOptions builder + */ + public Builder accountId(String accountId) { + this.accountId = accountId; + return this; + } + + /** + * Set the acceptLanguage. + * + * @param acceptLanguage the acceptLanguage + * @return the ListPolicyTemplatesOptions builder + */ + public Builder acceptLanguage(String acceptLanguage) { + this.acceptLanguage = acceptLanguage; + return this; + } + } + + protected ListPolicyTemplatesOptions() { } + + protected ListPolicyTemplatesOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.accountId, + "accountId cannot be null"); + accountId = builder.accountId; + acceptLanguage = builder.acceptLanguage; + } + + /** + * New builder. + * + * @return a ListPolicyTemplatesOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the accountId. + * + * The account GUID that the policy 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; + } +} + diff --git a/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PatchPolicyAssignmentOptions.java b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PatchPolicyAssignmentOptions.java new file mode 100644 index 0000000000..17afbfb59b --- /dev/null +++ b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PatchPolicyAssignmentOptions.java @@ -0,0 +1,133 @@ +/* + * (C) Copyright IBM Corp. 2023. + * + * 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 patchPolicyAssignment options. + */ +public class PatchPolicyAssignmentOptions extends GenericModel { + + protected String assignmentId; + protected String version; + + /** + * Builder. + */ + public static class Builder { + private String assignmentId; + private String version; + + /** + * Instantiates a new Builder from an existing PatchPolicyAssignmentOptions instance. + * + * @param patchPolicyAssignmentOptions the instance to initialize the Builder with + */ + private Builder(PatchPolicyAssignmentOptions patchPolicyAssignmentOptions) { + this.assignmentId = patchPolicyAssignmentOptions.assignmentId; + this.version = patchPolicyAssignmentOptions.version; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Instantiates a new builder with required properties. + * + * @param assignmentId the assignmentId + * @param version the version + */ + public Builder(String assignmentId, String version) { + this.assignmentId = assignmentId; + this.version = version; + } + + /** + * Builds a PatchPolicyAssignmentOptions. + * + * @return the new PatchPolicyAssignmentOptions instance + */ + public PatchPolicyAssignmentOptions build() { + return new PatchPolicyAssignmentOptions(this); + } + + /** + * Set the assignmentId. + * + * @param assignmentId the assignmentId + * @return the PatchPolicyAssignmentOptions builder + */ + public Builder assignmentId(String assignmentId) { + this.assignmentId = assignmentId; + return this; + } + + /** + * Set the version. + * + * @param version the version + * @return the PatchPolicyAssignmentOptions builder + */ + public Builder version(String version) { + this.version = version; + return this; + } + } + + protected PatchPolicyAssignmentOptions() { } + + protected PatchPolicyAssignmentOptions(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.version, + "version cannot be null"); + assignmentId = builder.assignmentId; + version = builder.version; + } + + /** + * New builder. + * + * @return a PatchPolicyAssignmentOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the assignmentId. + * + * The policy template assignment ID. + * + * @return the assignmentId + */ + public String assignmentId() { + return assignmentId; + } + + /** + * Gets the version. + * + * The policy template version to update to. + * + * @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/PolcyTemplateAssignmentCollection.java b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolcyTemplateAssignmentCollection.java new file mode 100644 index 0000000000..9369052b94 --- /dev/null +++ b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolcyTemplateAssignmentCollection.java @@ -0,0 +1,41 @@ +/* + * (C) Copyright IBM Corp. 2023. + * + * 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 policies assignments. + */ +public class PolcyTemplateAssignmentCollection extends GenericModel { + + @SerializedName("policy_assignments") + protected List policyAssignments; + + protected PolcyTemplateAssignmentCollection() { } + + /** + * Gets the policyAssignments. + * + * List of policy assignments. + * + * @return the policyAssignments + */ + public List getPolicyAssignments() { + return policyAssignments; + } +} + diff --git a/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/Policy.java b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/Policy.java index ffb50c739c..addb6d338f 100644 --- a/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/Policy.java +++ b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/Policy.java @@ -49,6 +49,7 @@ public interface State { @SerializedName("last_modified_by_id") protected String lastModifiedById; protected String state; + protected TemplateMetadata template; protected Policy() { } @@ -183,5 +184,16 @@ public String getLastModifiedById() { public String getState() { return state; } + + /** + * Gets the template. + * + * Origin Template information. + * + * @return the template + */ + public TemplateMetadata getTemplate() { + return template; + } } diff --git a/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyAssignment.java b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyAssignment.java new file mode 100644 index 0000000000..91a6a98cdc --- /dev/null +++ b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyAssignment.java @@ -0,0 +1,240 @@ +/* + * (C) Copyright IBM Corp. 2023. + * + * 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 policy template assignment. + */ +public class PolicyAssignment extends GenericModel { + + /** + * Assignment target type. + */ + public interface TargetType { + /** Account. */ + String ACCOUNT = "Account"; + } + + /** + * The policy assignment status. + */ + public interface Status { + /** in_progress. */ + String IN_PROGRESS = "in_progress"; + /** succeeded. */ + String SUCCEEDED = "succeeded"; + /** succeed_with_errors. */ + String SUCCEED_WITH_ERRORS = "succeed_with_errors"; + /** failed. */ + String FAILED = "failed"; + } + + @SerializedName("template_id") + protected String templateId; + @SerializedName("template_version") + protected String templateVersion; + @SerializedName("assignment_id") + protected String assignmentId; + @SerializedName("target_type") + protected String targetType; + protected String target; + protected List options; + 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 List resources; + protected String status; + + protected PolicyAssignment() { } + + /** + * Gets the templateId. + * + * policy template id. + * + * @return the templateId + */ + public String getTemplateId() { + return templateId; + } + + /** + * Gets the templateVersion. + * + * policy template version. + * + * @return the templateVersion + */ + public String getTemplateVersion() { + return templateVersion; + } + + /** + * Gets the assignmentId. + * + * Passed in value to correlate with other assignments. + * + * @return the assignmentId + */ + public String getAssignmentId() { + return assignmentId; + } + + /** + * Gets the targetType. + * + * Assignment target type. + * + * @return the targetType + */ + public String getTargetType() { + return targetType; + } + + /** + * Gets the target. + * + * ID of the target account. + * + * @return the target + */ + public String getTarget() { + return target; + } + + /** + * Gets the options. + * + * List of objects with required properties for a policy assignment. + * + * @return the options + */ + public List getOptions() { + return options; + } + + /** + * Gets the id. + * + * Policy assignment ID. + * + * @return the id + */ + public String getId() { + return id; + } + + /** + * Gets the accountId. + * + * The account GUID that the policies assignments belong to.. + * + * @return the accountId + */ + public String getAccountId() { + return accountId; + } + + /** + * Gets the href. + * + * The href URL that links to the policies assignments API by policy assignment ID. + * + * @return the href + */ + public String getHref() { + return href; + } + + /** + * Gets the createdAt. + * + * The UTC timestamp when the policy assignment was created. + * + * @return the createdAt + */ + public Date getCreatedAt() { + return createdAt; + } + + /** + * Gets the createdById. + * + * The iam ID of the entity that created the policy assignment. + * + * @return the createdById + */ + public String getCreatedById() { + return createdById; + } + + /** + * Gets the lastModifiedAt. + * + * The UTC timestamp when the policy 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 policy assignment. + * + * @return the lastModifiedById + */ + public String getLastModifiedById() { + return lastModifiedById; + } + + /** + * Gets the resources. + * + * Object for each account assigned. + * + * @return the resources + */ + public List getResources() { + return resources; + } + + /** + * Gets the status. + * + * The policy 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/PolicyAssignmentOptions.java b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyAssignmentOptions.java new file mode 100644 index 0000000000..c537e43cd9 --- /dev/null +++ b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyAssignmentOptions.java @@ -0,0 +1,101 @@ +/* + * (C) Copyright IBM Corp. 2023. + * + * 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; + +/** + * The set of properties required for a policy assignment. + */ +public class PolicyAssignmentOptions extends GenericModel { + + /** + * The policy subject type; either 'iam_id' or 'access_group_id'. + */ + public interface SubjectType { + /** iam_id. */ + String IAM_ID = "iam_id"; + /** access_group_id. */ + String ACCESS_GROUP_ID = "access_group_id"; + } + + @SerializedName("subject_type") + protected String subjectType; + @SerializedName("subject_id") + protected String subjectId; + @SerializedName("root_requester_id") + protected String rootRequesterId; + @SerializedName("root_template_id") + protected String rootTemplateId; + @SerializedName("root_template_version") + protected String rootTemplateVersion; + + protected PolicyAssignmentOptions() { } + + /** + * Gets the subjectType. + * + * The policy subject type; either 'iam_id' or 'access_group_id'. + * + * @return the subjectType + */ + public String getSubjectType() { + return subjectType; + } + + /** + * Gets the subjectId. + * + * The policy subject id. + * + * @return the subjectId + */ + public String getSubjectId() { + return subjectId; + } + + /** + * Gets the rootRequesterId. + * + * The policy assignment requester id. + * + * @return the rootRequesterId + */ + public String getRootRequesterId() { + return rootRequesterId; + } + + /** + * Gets the rootTemplateId. + * + * The template id where this policy is being assigned from. + * + * @return the rootTemplateId + */ + public String getRootTemplateId() { + return rootTemplateId; + } + + /** + * Gets the rootTemplateVersion. + * + * The template version where this policy is being assigned from. + * + * @return the rootTemplateVersion + */ + public String getRootTemplateVersion() { + return rootTemplateVersion; + } +} + diff --git a/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyAssignmentRecord.java b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyAssignmentRecord.java new file mode 100644 index 0000000000..0754c12fbe --- /dev/null +++ b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyAssignmentRecord.java @@ -0,0 +1,240 @@ +/* + * (C) Copyright IBM Corp. 2023. + * + * 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 policy template assignment. + */ +public class PolicyAssignmentRecord extends GenericModel { + + /** + * Assignment target type. + */ + public interface TargetType { + /** Account. */ + String ACCOUNT = "Account"; + } + + /** + * The policy assignment status. + */ + public interface Status { + /** in_progress. */ + String IN_PROGRESS = "in_progress"; + /** succeeded. */ + String SUCCEEDED = "succeeded"; + /** succeed_with_errors. */ + String SUCCEED_WITH_ERRORS = "succeed_with_errors"; + /** failed. */ + String FAILED = "failed"; + } + + @SerializedName("template_id") + protected String templateId; + @SerializedName("template_version") + protected String templateVersion; + @SerializedName("assignment_id") + protected String assignmentId; + @SerializedName("target_type") + protected String targetType; + protected String target; + 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 List options; + protected List resources; + protected String status; + + protected PolicyAssignmentRecord() { } + + /** + * Gets the templateId. + * + * policy template id. + * + * @return the templateId + */ + public String getTemplateId() { + return templateId; + } + + /** + * Gets the templateVersion. + * + * policy template version. + * + * @return the templateVersion + */ + public String getTemplateVersion() { + return templateVersion; + } + + /** + * Gets the assignmentId. + * + * Passed in value to correlate with other assignments. + * + * @return the assignmentId + */ + public String getAssignmentId() { + return assignmentId; + } + + /** + * Gets the targetType. + * + * Assignment target type. + * + * @return the targetType + */ + public String getTargetType() { + return targetType; + } + + /** + * Gets the target. + * + * assignment target id. + * + * @return the target + */ + public String getTarget() { + return target; + } + + /** + * Gets the id. + * + * Policy assignment ID. + * + * @return the id + */ + public String getId() { + return id; + } + + /** + * Gets the accountId. + * + * The account GUID that the policies assignments belong to.. + * + * @return the accountId + */ + public String getAccountId() { + return accountId; + } + + /** + * Gets the href. + * + * The href URL that links to the policies assignments API by policy assignment ID. + * + * @return the href + */ + public String getHref() { + return href; + } + + /** + * Gets the createdAt. + * + * The UTC timestamp when the policy assignment was created. + * + * @return the createdAt + */ + public Date getCreatedAt() { + return createdAt; + } + + /** + * Gets the createdById. + * + * The iam ID of the entity that created the policy assignment. + * + * @return the createdById + */ + public String getCreatedById() { + return createdById; + } + + /** + * Gets the lastModifiedAt. + * + * The UTC timestamp when the policy 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 policy assignment. + * + * @return the lastModifiedById + */ + public String getLastModifiedById() { + return lastModifiedById; + } + + /** + * Gets the options. + * + * Object for each properties for a policy assignment. + * + * @return the options + */ + public List getOptions() { + return options; + } + + /** + * Gets the resources. + * + * Object for each account assigned. + * + * @return the resources + */ + public List getResources() { + return resources; + } + + /** + * Gets the status. + * + * The policy 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/PolicyAssignmentRequestOptionsItem.java b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyAssignmentRequestOptionsItem.java new file mode 100644 index 0000000000..219f1e84da --- /dev/null +++ b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyAssignmentRequestOptionsItem.java @@ -0,0 +1,101 @@ +/* + * (C) Copyright IBM Corp. 2023. + * + * 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; + +/** + * The set of properties required for a policy assignment. + */ +public class PolicyAssignmentRequestOptionsItem extends GenericModel { + + /** + * The policy subject type; either 'iam_id' or 'access_group_id'. + */ + public interface SubjectType { + /** iam_id. */ + String IAM_ID = "iam_id"; + /** access_group_id. */ + String ACCESS_GROUP_ID = "access_group_id"; + } + + @SerializedName("subject_type") + protected String subjectType; + @SerializedName("subject_id") + protected String subjectId; + @SerializedName("root_requester_id") + protected String rootRequesterId; + @SerializedName("root_template_id") + protected String rootTemplateId; + @SerializedName("root_template_version") + protected String rootTemplateVersion; + + protected PolicyAssignmentRequestOptionsItem() { } + + /** + * Gets the subjectType. + * + * The policy subject type; either 'iam_id' or 'access_group_id'. + * + * @return the subjectType + */ + public String getSubjectType() { + return subjectType; + } + + /** + * Gets the subjectId. + * + * The policy subject id. + * + * @return the subjectId + */ + public String getSubjectId() { + return subjectId; + } + + /** + * Gets the rootRequesterId. + * + * The policy assignment requester id. + * + * @return the rootRequesterId + */ + public String getRootRequesterId() { + return rootRequesterId; + } + + /** + * Gets the rootTemplateId. + * + * The template id where this policy is being assigned from. + * + * @return the rootTemplateId + */ + public String getRootTemplateId() { + return rootTemplateId; + } + + /** + * Gets the rootTemplateVersion. + * + * The template version where this policy is being assigned from. + * + * @return the rootTemplateVersion + */ + public String getRootTemplateVersion() { + return rootTemplateVersion; + } +} + diff --git a/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyAssignmentResources.java b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyAssignmentResources.java new file mode 100644 index 0000000000..482c91982f --- /dev/null +++ b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyAssignmentResources.java @@ -0,0 +1,49 @@ +/* + * (C) Copyright IBM Corp. 2023. + * + * 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 policy assignment resources. + */ +public class PolicyAssignmentResources extends GenericModel { + + protected String target; + protected PolicyAssignmentResourcesPolicy policy; + + protected PolicyAssignmentResources() { } + + /** + * Gets the target. + * + * Account ID where resources are assigned. + * + * @return the target + */ + public String getTarget() { + return target; + } + + /** + * Gets the policy. + * + * Set of properties for the assigned resource. + * + * @return the policy + */ + public PolicyAssignmentResourcesPolicy getPolicy() { + return policy; + } +} + diff --git a/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyAssignmentResourcesPolicy.java b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyAssignmentResourcesPolicy.java new file mode 100644 index 0000000000..d9a1216f5e --- /dev/null +++ b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyAssignmentResourcesPolicy.java @@ -0,0 +1,52 @@ +/* + * (C) Copyright IBM Corp. 2023. + * + * 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 for the assigned resource. + */ +public class PolicyAssignmentResourcesPolicy extends GenericModel { + + @SerializedName("resource_created") + protected AssignmentResourceCreated resourceCreated; + @SerializedName("error_message") + protected ErrorResponse errorMessage; + + protected PolicyAssignmentResourcesPolicy() { } + + /** + * Gets the resourceCreated. + * + * On success, includes the policy assigned. + * + * @return the resourceCreated + */ + public AssignmentResourceCreated getResourceCreated() { + return resourceCreated; + } + + /** + * Gets the errorMessage. + * + * The error response from API. + * + * @return the errorMessage + */ + public ErrorResponse getErrorMessage() { + return errorMessage; + } +} + diff --git a/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyCollection.java b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyCollection.java new file mode 100644 index 0000000000..29a7b8a29d --- /dev/null +++ b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyCollection.java @@ -0,0 +1,39 @@ +/* + * (C) Copyright IBM Corp. 2023. + * + * 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 policies. + */ +public class PolicyCollection extends GenericModel { + + protected List policies; + + protected PolicyCollection() { } + + /** + * Gets the policies. + * + * List of policies. + * + * @return the policies + */ + public List getPolicies() { + return policies; + } +} + diff --git a/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyTemplate.java b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyTemplate.java new file mode 100644 index 0000000000..21045f69cf --- /dev/null +++ b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyTemplate.java @@ -0,0 +1,179 @@ +/* + * (C) Copyright IBM Corp. 2023. + * + * 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 core set of properties associated with the policy template. + */ +public class PolicyTemplate extends GenericModel { + + protected String name; + protected String description; + @SerializedName("account_id") + protected String accountId; + protected String version; + protected Boolean committed; + protected TemplatePolicy policy; + 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 PolicyTemplate() { } + + /** + * 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 getName() { + return name; + } + + /** + * Gets the description. + * + * Description of the policy template. This is shown to users in the enterprise account. Use this to describe the + * purpose or context of the policy for enterprise users managing IAM templates. + * + * @return the description + */ + public String getDescription() { + return description; + } + + /** + * Gets the accountId. + * + * Enterprise account ID where this template will be created. + * + * @return the accountId + */ + public String getAccountId() { + return accountId; + } + + /** + * Gets the version. + * + * Template version. + * + * @return the version + */ + public String getVersion() { + return version; + } + + /** + * Gets the committed. + * + * Committed status of the template version. + * + * @return the committed + */ + public Boolean isCommitted() { + return committed; + } + + /** + * Gets the policy. + * + * The core set of properties associated with the template's policy objet. + * + * @return the policy + */ + public TemplatePolicy getPolicy() { + return policy; + } + + /** + * Gets the id. + * + * The policy template ID. + * + * @return the id + */ + public String getId() { + return id; + } + + /** + * Gets the href. + * + * The href URL that links to the policy templates API by policy template ID. + * + * @return the href + */ + public String getHref() { + return href; + } + + /** + * Gets the createdAt. + * + * The UTC timestamp when the policy template was created. + * + * @return the createdAt + */ + public Date getCreatedAt() { + return createdAt; + } + + /** + * Gets the createdById. + * + * The iam ID of the entity that created the policy template. + * + * @return the createdById + */ + public String getCreatedById() { + return createdById; + } + + /** + * Gets the lastModifiedAt. + * + * The UTC timestamp when the policy 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 policy template. + * + * @return the lastModifiedById + */ + public String getLastModifiedById() { + return lastModifiedById; + } +} + diff --git a/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyTemplateAssignmentCollection.java b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyTemplateAssignmentCollection.java new file mode 100644 index 0000000000..ed592da815 --- /dev/null +++ b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyTemplateAssignmentCollection.java @@ -0,0 +1,39 @@ +/* + * (C) Copyright IBM Corp. 2023. + * + * 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 policies assignments. + */ +public class PolicyTemplateAssignmentCollection extends GenericModel { + + protected List assignments; + + protected PolicyTemplateAssignmentCollection() { } + + /** + * Gets the assignments. + * + * List of policy 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/PolicyTemplateCollection.java b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyTemplateCollection.java new file mode 100644 index 0000000000..0504f980be --- /dev/null +++ b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyTemplateCollection.java @@ -0,0 +1,41 @@ +/* + * (C) Copyright IBM Corp. 2023. + * + * 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 policy Templates. + */ +public class PolicyTemplateCollection extends GenericModel { + + @SerializedName("policy_templates") + protected List policyTemplates; + + protected PolicyTemplateCollection() { } + + /** + * Gets the policyTemplates. + * + * List of policy templates. + * + * @return the policyTemplates + */ + public List getPolicyTemplates() { + return policyTemplates; + } +} + diff --git a/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyTemplateVersionsCollection.java b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyTemplateVersionsCollection.java new file mode 100644 index 0000000000..508d27e9c5 --- /dev/null +++ b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyTemplateVersionsCollection.java @@ -0,0 +1,39 @@ +/* + * (C) Copyright IBM Corp. 2023. + * + * 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 policy template. + */ +public class PolicyTemplateVersionsCollection extends GenericModel { + + protected List versions; + + protected PolicyTemplateVersionsCollection() { } + + /** + * Gets the versions. + * + * List of policy 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/ReplacePolicyTemplateOptions.java b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ReplacePolicyTemplateOptions.java new file mode 100644 index 0000000000..eb7d551415 --- /dev/null +++ b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ReplacePolicyTemplateOptions.java @@ -0,0 +1,248 @@ +/* + * (C) Copyright IBM Corp. 2023. + * + * 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 replacePolicyTemplate options. + */ +public class ReplacePolicyTemplateOptions extends GenericModel { + + protected String policyTemplateId; + protected String version; + protected String ifMatch; + protected TemplatePolicy policy; + protected String description; + protected Boolean committed; + + /** + * Builder. + */ + public static class Builder { + private String policyTemplateId; + private String version; + private String ifMatch; + private TemplatePolicy policy; + private String description; + private Boolean committed; + + /** + * Instantiates a new Builder from an existing ReplacePolicyTemplateOptions instance. + * + * @param replacePolicyTemplateOptions the instance to initialize the Builder with + */ + private Builder(ReplacePolicyTemplateOptions replacePolicyTemplateOptions) { + this.policyTemplateId = replacePolicyTemplateOptions.policyTemplateId; + this.version = replacePolicyTemplateOptions.version; + this.ifMatch = replacePolicyTemplateOptions.ifMatch; + this.policy = replacePolicyTemplateOptions.policy; + this.description = replacePolicyTemplateOptions.description; + this.committed = replacePolicyTemplateOptions.committed; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Instantiates a new builder with required properties. + * + * @param policyTemplateId the policyTemplateId + * @param version the version + * @param ifMatch the ifMatch + * @param policy the policy + */ + public Builder(String policyTemplateId, String version, String ifMatch, TemplatePolicy policy) { + this.policyTemplateId = policyTemplateId; + this.version = version; + this.ifMatch = ifMatch; + this.policy = policy; + } + + /** + * Builds a ReplacePolicyTemplateOptions. + * + * @return the new ReplacePolicyTemplateOptions instance + */ + public ReplacePolicyTemplateOptions build() { + return new ReplacePolicyTemplateOptions(this); + } + + /** + * Set the policyTemplateId. + * + * @param policyTemplateId the policyTemplateId + * @return the ReplacePolicyTemplateOptions builder + */ + public Builder policyTemplateId(String policyTemplateId) { + this.policyTemplateId = policyTemplateId; + return this; + } + + /** + * Set the version. + * + * @param version the version + * @return the ReplacePolicyTemplateOptions builder + */ + public Builder version(String version) { + this.version = version; + return this; + } + + /** + * Set the ifMatch. + * + * @param ifMatch the ifMatch + * @return the ReplacePolicyTemplateOptions builder + */ + public Builder ifMatch(String ifMatch) { + this.ifMatch = ifMatch; + return this; + } + + /** + * Set the policy. + * + * @param policy the policy + * @return the ReplacePolicyTemplateOptions builder + */ + public Builder policy(TemplatePolicy policy) { + this.policy = policy; + return this; + } + + /** + * Set the description. + * + * @param description the description + * @return the ReplacePolicyTemplateOptions builder + */ + public Builder description(String description) { + this.description = description; + return this; + } + + /** + * Set the committed. + * + * @param committed the committed + * @return the ReplacePolicyTemplateOptions builder + */ + public Builder committed(Boolean committed) { + this.committed = committed; + return this; + } + } + + protected ReplacePolicyTemplateOptions() { } + + protected ReplacePolicyTemplateOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.policyTemplateId, + "policyTemplateId 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.policy, + "policy cannot be null"); + policyTemplateId = builder.policyTemplateId; + version = builder.version; + ifMatch = builder.ifMatch; + policy = builder.policy; + description = builder.description; + committed = builder.committed; + } + + /** + * New builder. + * + * @return a ReplacePolicyTemplateOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the policyTemplateId. + * + * The policy template ID. + * + * @return the policyTemplateId + */ + public String policyTemplateId() { + return policyTemplateId; + } + + /** + * Gets the version. + * + * The policy template version. + * + * @return the version + */ + public String version() { + return version; + } + + /** + * Gets the ifMatch. + * + * The revision number for updating a policy template version and must match the ETag value of the existing policy + * template version. The Etag can be retrieved using the GET + * /v1/policy_templates/{policy_template_id}/versions/{version} API and looking at the ETag response header. + * + * @return the ifMatch + */ + public String ifMatch() { + return ifMatch; + } + + /** + * Gets the policy. + * + * The core set of properties associated with the template's policy objet. + * + * @return the policy + */ + public TemplatePolicy policy() { + return policy; + } + + /** + * Gets the description. + * + * Description of the policy template. This is shown to users in the enterprise account. Use this to describe the + * purpose or context of the policy for enterprise users managing IAM templates. + * + * @return the description + */ + public String description() { + return description; + } + + /** + * Gets the committed. + * + * Committed status of the template version. + * + * @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/ReplaceV2PolicyOptions.java b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ReplaceV2PolicyOptions.java index 7252361cb2..d005c0c2dc 100644 --- a/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ReplaceV2PolicyOptions.java +++ b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ReplaceV2PolicyOptions.java @@ -279,7 +279,7 @@ public String type() { /** * Gets the description. * - * Allows the customer to use their own words to record the purpose/context related to a policy. + * Description of the policy. * * @return the description */ diff --git a/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/RoleCollection.java b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/RoleCollection.java new file mode 100644 index 0000000000..786e84d3a1 --- /dev/null +++ b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/RoleCollection.java @@ -0,0 +1,67 @@ +/* + * (C) Copyright IBM Corp. 2023. + * + * 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 roles returned by the 'list roles' operation. + */ +public class RoleCollection extends GenericModel { + + @SerializedName("custom_roles") + protected List customRoles; + @SerializedName("service_roles") + protected List serviceRoles; + @SerializedName("system_roles") + protected List systemRoles; + + protected RoleCollection() { } + + /** + * Gets the customRoles. + * + * List of custom roles. + * + * @return the customRoles + */ + public List getCustomRoles() { + return customRoles; + } + + /** + * Gets the serviceRoles. + * + * List of service roles. + * + * @return the serviceRoles + */ + public List getServiceRoles() { + return serviceRoles; + } + + /** + * Gets the systemRoles. + * + * List of system roles. + * + * @return the systemRoles + */ + public List getSystemRoles() { + return systemRoles; + } +} + diff --git a/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/TemplateMetada.java b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/TemplateMetada.java new file mode 100644 index 0000000000..4daa6ad1ae --- /dev/null +++ b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/TemplateMetada.java @@ -0,0 +1,49 @@ +/* + * (C) Copyright IBM Corp. 2023. + * + * 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; + +/** + * Origin Template information. + */ +public class TemplateMetada extends GenericModel { + + protected String crn; + protected String version; + + protected TemplateMetada() { } + + /** + * Gets the crn. + * + * Origin Template CRN. + * + * @return the crn + */ + public String getCrn() { + return crn; + } + + /** + * Gets the version. + * + * Template version. + * + * @return the version + */ + public String getVersion() { + return version; + } +} + diff --git a/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/TemplateMetadata.java b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/TemplateMetadata.java new file mode 100644 index 0000000000..25e5a63421 --- /dev/null +++ b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/TemplateMetadata.java @@ -0,0 +1,49 @@ +/* + * (C) Copyright IBM Corp. 2023. + * + * 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; + +/** + * Origin Template information. + */ +public class TemplateMetadata extends GenericModel { + + protected String crn; + protected String version; + + protected TemplateMetadata() { } + + /** + * Gets the crn. + * + * Origin Template CRN. + * + * @return the crn + */ + public String getCrn() { + return crn; + } + + /** + * Gets the version. + * + * Template version. + * + * @return the version + */ + public String getVersion() { + return version; + } +} + diff --git a/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/TemplatePolicy.java b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/TemplatePolicy.java new file mode 100644 index 0000000000..75782add63 --- /dev/null +++ b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/TemplatePolicy.java @@ -0,0 +1,253 @@ +/* + * (C) Copyright IBM Corp. 2023. + * + * 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 core set of properties associated with the template's policy objet. + */ +public class TemplatePolicy extends GenericModel { + + /** + * The policy type; either 'access' or 'authorization'. + */ + public interface Type { + /** access. */ + String ACCESS = "access"; + /** authorization. */ + String AUTHORIZATION = "authorization"; + } + + protected String type; + protected String description; + protected V2PolicyResource resource; + protected String pattern; + protected V2PolicyRule rule; + protected Control control; + + /** + * Builder. + */ + public static class Builder { + private String type; + private String description; + private V2PolicyResource resource; + private String pattern; + private V2PolicyRule rule; + private Control control; + + /** + * Instantiates a new Builder from an existing TemplatePolicy instance. + * + * @param templatePolicy the instance to initialize the Builder with + */ + private Builder(TemplatePolicy templatePolicy) { + this.type = templatePolicy.type; + this.description = templatePolicy.description; + this.resource = templatePolicy.resource; + this.pattern = templatePolicy.pattern; + this.rule = templatePolicy.rule; + this.control = templatePolicy.control; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Instantiates a new builder with required properties. + * + * @param type the type + * @param resource the resource + * @param control the control + */ + public Builder(String type, V2PolicyResource resource, Control control) { + this.type = type; + this.resource = resource; + this.control = control; + } + + /** + * Builds a TemplatePolicy. + * + * @return the new TemplatePolicy instance + */ + public TemplatePolicy build() { + return new TemplatePolicy(this); + } + + /** + * Set the type. + * + * @param type the type + * @return the TemplatePolicy builder + */ + public Builder type(String type) { + this.type = type; + return this; + } + + /** + * Set the description. + * + * @param description the description + * @return the TemplatePolicy builder + */ + public Builder description(String description) { + this.description = description; + return this; + } + + /** + * Set the resource. + * + * @param resource the resource + * @return the TemplatePolicy builder + */ + public Builder resource(V2PolicyResource resource) { + this.resource = resource; + return this; + } + + /** + * Set the pattern. + * + * @param pattern the pattern + * @return the TemplatePolicy builder + */ + public Builder pattern(String pattern) { + this.pattern = pattern; + return this; + } + + /** + * Set the rule. + * + * @param rule the rule + * @return the TemplatePolicy builder + */ + public Builder rule(V2PolicyRule rule) { + this.rule = rule; + return this; + } + + /** + * Set the control. + * + * @param control the control + * @return the TemplatePolicy builder + */ + public Builder control(Control control) { + this.control = control; + return this; + } + } + + protected TemplatePolicy() { } + + protected TemplatePolicy(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.type, + "type cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.resource, + "resource cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.control, + "control cannot be null"); + type = builder.type; + description = builder.description; + resource = builder.resource; + pattern = builder.pattern; + rule = builder.rule; + control = builder.control; + } + + /** + * New builder. + * + * @return a TemplatePolicy builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the type. + * + * The policy type; either 'access' or 'authorization'. + * + * @return the type + */ + public String type() { + return type; + } + + /** + * Gets the description. + * + * Description of the policy. This is shown in child accounts when an access group or trusted profile template uses + * the policy template to assign access. + * + * @return the description + */ + public String description() { + return description; + } + + /** + * Gets the resource. + * + * The resource attributes to which the policy grants access. + * + * @return the resource + */ + public V2PolicyResource resource() { + return resource; + } + + /** + * Gets the pattern. + * + * Indicates pattern of rule, either 'time-based-conditions:once', 'time-based-conditions:weekly:all-day', or + * 'time-based-conditions:weekly:custom-hours'. + * + * @return the pattern + */ + public String pattern() { + return pattern; + } + + /** + * Gets the rule. + * + * Additional access conditions associated with the policy. + * + * @return the rule + */ + public V2PolicyRule rule() { + return rule; + } + + /** + * Gets the control. + * + * Specifies the type of access granted by the policy. + * + * @return the control + */ + public Control control() { + return control; + } +} + diff --git a/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/V2Policy.java b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/V2Policy.java index 1508935d34..249a6cfd78 100644 --- a/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/V2Policy.java +++ b/modules/iam-policy-management/src/main/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/V2Policy.java @@ -64,6 +64,7 @@ public interface State { protected String lastPermitAt; @SerializedName("last_permit_frequency") protected Long lastPermitFrequency; + protected TemplateMetadata template; protected V2Policy() { } @@ -81,7 +82,7 @@ public String getType() { /** * Gets the description. * - * Allows the customer to use their own words to record the purpose/context related to a policy. + * Description of the policy. * * @return the description */ @@ -242,5 +243,16 @@ public String getLastPermitAt() { public Long getLastPermitFrequency() { return lastPermitFrequency; } + + /** + * Gets the template. + * + * Origin Template information. + * + * @return the template + */ + public TemplateMetadata getTemplate() { + return template; + } } 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 07b181ddcd..650a4ca2e4 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 @@ -33,6 +33,7 @@ import com.ibm.cloud.platform_services.test.SdkIntegrationTestBase; 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; /** @@ -69,6 +70,15 @@ public class IamPolicyManagementIT extends SdkIntegrationTestBase { String testCustomRoleId = null; String testCustomRoleEtag = null; + private static final String TEST_TEMPLATE_PREFIX = "SDKJava"; + private final String TEST_TEMPLATE_NAME = TEST_TEMPLATE_PREFIX + TEST_UNIQUE_ID; + + String testTemplateId = null; + String testTemplateVersion = null; + String testTemplateEtag = null; + String testNewTemplateVersion = null; + String testAssignmentId = null; + @Override public String getConfigFilename() { return "../../iam_policy_management.env"; @@ -281,11 +291,11 @@ public void testListAccessPolicies() throws Exception, InterruptedException { .accountId(testAccountId) .build(); - Response response = service.listPolicies(options).execute(); + Response response = service.listPolicies(options).execute(); assertNotNull(response); assertEquals(response.getStatusCode(), 200); - PolicyList result = response.getResult(); + PolicyCollection result = response.getResult(); assertNotNull(result); // Confirm the test policy is present @@ -636,11 +646,11 @@ public void testListRoles() throws Exception, InterruptedException { .accountId(testAccountId) .build(); - Response response = service.listRoles(options).execute(); + Response response = service.listRoles(options).execute(); assertNotNull(response); assertEquals(response.getStatusCode(), 200); - RoleList result = response.getResult(); + RoleCollection result = response.getResult(); assertNotNull(result); // Confirm the test role is present @@ -661,11 +671,11 @@ public void testListV2Roles() { .serviceGroupId("IAM") .build(); - Response response = service.listRoles(options).execute(); + Response response = service.listRoles(options).execute(); assertNotNull(response); assertEquals(response.getStatusCode(), 200); - RoleList result = response.getResult(); + RoleCollection result = response.getResult(); assertNotNull(result); // Confirm the test role is present @@ -687,9 +697,379 @@ public void testListV2Roles() { assertTrue(foundServiceRole); } + @Test + public void testCreatePolicyTemplate() throws Exception { + V2PolicyResourceAttribute resourceAttributeService = new V2PolicyResourceAttribute.Builder() + .key("serviceType") + .value("service") + .operator("stringEquals") + .build(); + + Roles rolesModel = new Roles.Builder() + .roleId(TEST_VIEW_ROLE_CRN) + .build(); + + Grant policyGrantModel = new Grant.Builder() + .roles(Arrays.asList(rolesModel)) + .build(); + + Control controlModel = new Control.Builder() + .grant(policyGrantModel) + .build(); + + V2PolicyResource policyResourceModel = new V2PolicyResource.Builder() + .attributes(new ArrayList(Arrays.asList(resourceAttributeService))) + .build(); + + TemplatePolicy templatePolicyModel = new TemplatePolicy.Builder() + .type(POLICY_TYPE) + .description("SDK Test Policy") + .resource(policyResourceModel) + .control(controlModel) + .build(); + + CreatePolicyTemplateOptions createPolicyTemplateOptions = new CreatePolicyTemplateOptions.Builder() + .name(TEST_TEMPLATE_NAME) + .accountId(testAccountId) + .policy(templatePolicyModel) + .description("SDK Test template with viewer role") + .build(); + + Response response = service.createPolicyTemplate(createPolicyTemplateOptions).execute(); + assertNotNull(response); + assertEquals(response.getStatusCode(), 201); + + PolicyTemplate result = response.getResult(); + + assertNotNull(result); + assertEquals(result.getPolicy(), templatePolicyModel); + testTemplateId = result.getId(); + } + + @Test(dependsOnMethods = {"testCreatePolicyTemplate"}) + public void testGetPolicyTemplate() { + assertNotNull(testTemplateId); + GetPolicyTemplateOptions getPolicyTemplateOptions = new GetPolicyTemplateOptions.Builder() + .policyTemplateId(testTemplateId) + .build(); + + Response response = service.getPolicyTemplate(getPolicyTemplateOptions).execute(); + assertNotNull(response); + assertEquals(response.getStatusCode(), 200); + + PolicyTemplate result = response.getResult(); + + assertNotNull(result); + assertEquals(result.getId(), testTemplateId); + testTemplateVersion = result.getVersion(); + List values = response.getHeaders().values(HEADER_ETAG); + assertNotNull(values); + testTemplateEtag = values.get(0); + } + + @Test(dependsOnMethods = {"testGetPolicyTemplate"}) + public void testReplacePolicyTemplate() { + assertNotNull(testTemplateId); + assertNotNull(testTemplateEtag); + V2PolicyResourceAttribute resourceAttributeService = new V2PolicyResourceAttribute.Builder() + .key("serviceType") + .value("service") + .operator("stringEquals") + .build(); + + Roles rolesModel = new Roles.Builder() + .roleId(TEST_EDITOR_ROLE_CRN) + .build(); + + Grant policyGrantModel = new Grant.Builder() + .roles(Arrays.asList(rolesModel)) + .build(); + + Control controlModel = new Control.Builder() + .grant(policyGrantModel) + .build(); + + V2PolicyResource policyResourceModel = new V2PolicyResource.Builder() + .attributes(new ArrayList(Arrays.asList(resourceAttributeService))) + .build(); + + TemplatePolicy templatePolicyModel = new TemplatePolicy.Builder() + .type(POLICY_TYPE) + .description("SDK test Template") + .resource(policyResourceModel) + .control(controlModel) + .build(); + + ReplacePolicyTemplateOptions replacePolicyTemplateOptions = new ReplacePolicyTemplateOptions.Builder() + .policyTemplateId(testTemplateId) + .version(testTemplateVersion) + .ifMatch(testTemplateEtag) + .policy(templatePolicyModel) + .description("Updated SDK test template with editor role") + .build(); + + Response response = service.replacePolicyTemplate(replacePolicyTemplateOptions).execute(); + assertNotNull(response); + assertEquals(response.getStatusCode(), 200); + + PolicyTemplate result = response.getResult(); + assertEquals(result.getPolicy(), templatePolicyModel); + assertEquals(result.getDescription(), "Updated SDK test template with editor role"); + } + + @Test(dependsOnMethods = {"testReplacePolicyTemplate"}) + public void testListPolicyTemplates() throws Exception, InterruptedException { + assertNotNull(testTemplateId); + + ListPolicyTemplatesOptions listPolicyTemplatesOptions = new ListPolicyTemplatesOptions.Builder() + .accountId(testAccountId) + .acceptLanguage("default") + .build(); + + + Response response = service.listPolicyTemplates(listPolicyTemplatesOptions).execute(); + + assertNotNull(response); + assertEquals(response.getStatusCode(), 200); + + PolicyTemplateCollection result = response.getResult(); + + assertNotNull(result); + // Confirm the test policy is present + boolean foundTestPolicyTemplate = false; + for (PolicyTemplate policyTemplate : result.getPolicyTemplates()) { + if (testTemplateId.equals(policyTemplate.getId())) { + foundTestPolicyTemplate = true; + break; + } + } + assertTrue(foundTestPolicyTemplate); + } + + @Test(dependsOnMethods = {"testListPolicyTemplates"}) + public void testCreatePolicyTemplateVersion() { + assertNotNull(testTemplateId); + + V2PolicyResourceAttribute resourceAttributeService = new V2PolicyResourceAttribute.Builder() + .key("serviceType") + .value("service") + .operator("stringEquals") + .build(); + + Roles rolesModel = new Roles.Builder() + .roleId(TEST_VIEW_ROLE_CRN) + .build(); + + Grant policyGrantModel = new Grant.Builder() + .roles(Arrays.asList(rolesModel)) + .build(); + + Control controlModel = new Control.Builder() + .grant(policyGrantModel) + .build(); + + V2PolicyResource policyResourceModel = new V2PolicyResource.Builder() + .attributes(new ArrayList(Arrays.asList(resourceAttributeService))) + .build(); + + TemplatePolicy templatePolicyModel = new TemplatePolicy.Builder() + .type(POLICY_TYPE) + .description("SDK Test Policy") + .resource(policyResourceModel) + .control(controlModel) + .build(); + + CreatePolicyTemplateVersionOptions createPolicyTemplateVersionOptions = new CreatePolicyTemplateVersionOptions.Builder() + .policyTemplateId(testTemplateId) + .policy(templatePolicyModel) + .description("SDK Test template with viewer role") + .build(); + + // Invoke operation + Response response = service.createPolicyTemplateVersion(createPolicyTemplateVersionOptions).execute(); + + assertNotNull(response); + assertEquals(response.getStatusCode(), 201); + + PolicyTemplate result = response.getResult(); + + assertNotNull(result); + testNewTemplateVersion = result.getVersion(); + assertEquals(result.getPolicy(), templatePolicyModel); + assertTrue(Integer.parseInt(testNewTemplateVersion) > Integer.parseInt(testTemplateVersion)); + } + + @Test(dependsOnMethods = {"testCreatePolicyTemplateVersion"}) + public void testGetPolicyTemplateVersion() { + assertNotNull(testTemplateId); + assertNotNull(testNewTemplateVersion); + + GetPolicyTemplateVersionOptions getPolicyTemplateVersionOptions = new GetPolicyTemplateVersionOptions.Builder() + .policyTemplateId(testTemplateId) + .version(testNewTemplateVersion) + .build(); + + Response response = service.getPolicyTemplateVersion(getPolicyTemplateVersionOptions).execute(); + assertNotNull(response); + assertEquals(response.getStatusCode(), 200); + + PolicyTemplate result = response.getResult(); + assertNotNull(result); + } + + @Test(dependsOnMethods = { "testGetPolicyTemplateVersion" }) + public void testCommitPolicyTemplate() { + assertNotNull(testTemplateId); + assertNotNull(testTemplateEtag); + CommitPolicyTemplateOptions commitPolicyTemplateOptions = new CommitPolicyTemplateOptions.Builder() + .policyTemplateId(testTemplateId) + .version(testTemplateVersion) + .ifMatch(testTemplateEtag) + .build(); + + Response response = service.commitPolicyTemplate(commitPolicyTemplateOptions).execute(); + + assertNotNull(response); + assertEquals(response.getStatusCode(), 204); + + GetPolicyTemplateVersionOptions getPolicyTemplateVersionOptions = new GetPolicyTemplateVersionOptions.Builder() + .policyTemplateId(testTemplateId) + .version(testTemplateVersion) + .build(); + + Response getResponse = service.getPolicyTemplateVersion(getPolicyTemplateVersionOptions).execute(); + assertNotNull(getResponse); + assertEquals(getResponse.getStatusCode(), 200); + + List values = getResponse.getHeaders().values(HEADER_ETAG); + assertNotNull(values); + testTemplateEtag = values.get(0); + + // Once template is committed, it cannot be updated. Check that update template for first version fails + try { + V2PolicyResourceAttribute resourceAttributeService = new V2PolicyResourceAttribute.Builder() + .key("serviceType") + .value("service") + .operator("stringEquals") + .build(); + + Roles rolesModel = new Roles.Builder() + .roleId(TEST_EDITOR_ROLE_CRN) + .build(); + + Grant policyGrantModel = new Grant.Builder() + .roles(Arrays.asList(rolesModel)) + .build(); + + Control controlModel = new Control.Builder() + .grant(policyGrantModel) + .build(); + + V2PolicyResource policyResourceModel = new V2PolicyResource.Builder() + .attributes(new ArrayList(Arrays.asList(resourceAttributeService))) + .build(); + + TemplatePolicy templatePolicyModel = new TemplatePolicy.Builder() + .type(POLICY_TYPE) + .description("SDK test Template") + .resource(policyResourceModel) + .control(controlModel) + .build(); + + ReplacePolicyTemplateOptions replacePolicyTemplateOptions = new ReplacePolicyTemplateOptions.Builder() + .policyTemplateId(testTemplateId) + .version(testTemplateVersion) + .ifMatch(testTemplateEtag) + .policy(templatePolicyModel) + .description("Updated SDK test template with editor role") + .build(); + + Response updateResponse = service.replacePolicyTemplate(replacePolicyTemplateOptions).execute(); + } catch (ServiceResponseException e) { + assertEquals(e.getMessage(), "Policy template id '" + testTemplateId + "' and version '" + testTemplateVersion + "' is committed and cannot be updated"); + assertEquals(e.getStatusCode(), 400); + } + } + + @Test(dependsOnMethods = {"testCommitPolicyTemplate"}) + public void testDeletePolicyTemplateVersion() { + DeletePolicyTemplateVersionOptions deletePolicyTemplateVersionOptions = new DeletePolicyTemplateVersionOptions.Builder() + .policyTemplateId(testTemplateId) + .version(testTemplateVersion) + .build(); + + Response response = service.deletePolicyTemplateVersion(deletePolicyTemplateVersionOptions).execute(); + assertNotNull(response); + assertEquals(response.getStatusCode(), 204); + } + + @Test(dependsOnMethods = {"testDeletePolicyTemplateVersion"}) + public void testListPolicyTemplateVersions() { + ListPolicyTemplateVersionsOptions listPolicyTemplateVersionsOptions = new ListPolicyTemplateVersionsOptions.Builder() + .policyTemplateId(testTemplateId) + .build(); + + Response response = service.listPolicyTemplateVersions(listPolicyTemplateVersionsOptions).execute(); + assertNotNull(response); + assertEquals(response.getStatusCode(), 200); + + PolicyTemplateVersionsCollection result = response.getResult(); + assertNotNull(result); + assertTrue(result.getVersions().size() == 1); + // Confirm new test policy template version is present + // and old version is not present + boolean foundTestPolicyTemplateVersion = true; + boolean foundNewTestPolicyTemplateVersion = false; + for (PolicyTemplate policyTemplate : result.getVersions()) { + if (testTemplateVersion.equals(policyTemplate.getVersion())) { + foundTestPolicyTemplateVersion = false; + break; + } + if (testNewTemplateVersion.equals(policyTemplate.getVersion())) { + foundNewTestPolicyTemplateVersion = true; + } + } + assertTrue(foundTestPolicyTemplateVersion); + assertTrue(foundNewTestPolicyTemplateVersion); + } + + @Test(dependsOnMethods = {"testListPolicyTemplateVersions"}) + public void testListPolicyAssignments() throws Exception { + ListPolicyAssignmentsOptions listPolicyAssignmentsOptions = new ListPolicyAssignmentsOptions.Builder() + .accountId(testAccountId) + .build(); + + Response response = service.listPolicyAssignments(listPolicyAssignmentsOptions).execute(); + assertNotNull(response); + assertEquals(response.getStatusCode(), 200); + PolicyTemplateAssignmentCollection result = response.getResult(); + assertNotNull(result); + assertNotNull(result.getAssignments()); + List assignments = result.getAssignments(); + // As long there is one assignment in test account, then there should be one assignment to run next test. + testAssignmentId = assignments.get(assignments.size() - 1).getId(); + } + + @Test(dependsOnMethods = { "testListPolicyAssignments" }) + public void testGetPolicyAssignment() throws Exception { + assertNotNull(testAssignmentId); + GetPolicyAssignmentOptions getPolicyAssignmentOptions = new GetPolicyAssignmentOptions.Builder() + .assignmentId(testAssignmentId) + .build(); + + Response response = service.getPolicyAssignment(getPolicyAssignmentOptions).execute(); + assertNotNull(response); + assertEquals(response.getStatusCode(), 200); + + PolicyAssignment result = response.getResult(); + + assertNotNull(result); + assertEquals(result.getId(), testAssignmentId); + } + @AfterClass public void tearDown() { - // Delete all the access policies and roles created during the test. + // Delete all the access policies, roles, templates, and template assingments created during the test. SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); @@ -702,12 +1082,12 @@ public void tearDown() { .accountId(testAccountId) .build(); - Response policyResponse = service.listPolicies(policyOptions).execute(); + Response policyResponse = service.listPolicies(policyOptions).execute(); assertNotNull(policyResponse); assertEquals(policyResponse.getStatusCode(), 200); // Iterate across the policies - PolicyList policyList = policyResponse.getResult(); + PolicyCollection policyList = policyResponse.getResult(); assertNotNull(policyList); for (Policy policy : policyList.getPolicies()) { @@ -743,11 +1123,11 @@ public void tearDown() { .accountId(testAccountId) .build(); - Response roleResponse = service.listRoles(roleOptions).execute(); + Response roleResponse = service.listRoles(roleOptions).execute(); assertNotNull(roleResponse); assertEquals(roleResponse.getStatusCode(), 200); - RoleList rolesList = roleResponse.getResult(); + RoleCollection rolesList = roleResponse.getResult(); assertNotNull(rolesList); // Iterate across the list of custom roles @@ -767,5 +1147,33 @@ public void tearDown() { } } } + + // Delete policy template + ListPolicyTemplatesOptions listPolicyTemplatesOptions = new ListPolicyTemplatesOptions.Builder() + .accountId(testAccountId) + .build(); + + Response templateResponse = service.listPolicyTemplates(listPolicyTemplatesOptions).execute(); + assertNotNull(templateResponse); + assertEquals(templateResponse.getStatusCode(), 200); + + PolicyTemplateCollection policyTemplateCollectionResult = templateResponse.getResult(); + for (PolicyTemplate policyTemplate : policyTemplateCollectionResult.getPolicyTemplates()) { + // Delete the test policy template or any test templates older than 5 minutes + if (policyTemplate.getName().contains(TEST_TEMPLATE_PREFIX)) { + long createdAt = policyTemplate.getCreatedAt().getTime(); + + if ((testTemplateId != null || testTemplateId.equals(policyTemplate.getId())) || createdAt < fiveMinutesAgo) { + DeletePolicyTemplateOptions deletePolicyTemplateOptions = new DeletePolicyTemplateOptions.Builder() + .policyTemplateId(policyTemplate.getId()) + .build(); + + Response response = service.deletePolicyTemplate(deletePolicyTemplateOptions).execute(); + assertNotNull(response); + assertEquals(response.getStatusCode(), 204); + log("Cleanup test template id: " + policyTemplate.getId()); + } + } + } } } 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 0dcd06c254..42b602c576 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 @@ -13,42 +13,69 @@ package com.ibm.cloud.platform_services.iam_policy_management.v1; import com.ibm.cloud.platform_services.iam_policy_management.v1.IamPolicyManagement; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.AssignmentResourceCreated; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.CommitPolicyTemplateOptions; +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; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ControlResponseControl; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ControlResponseControlWithEnrichedRoles; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.CreatePolicyOptions; +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.CreateV2PolicyOptions; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.CustomRole; 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.DeleteRoleOptions; 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.GetPolicyAssignmentOptions; 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.GetRoleOptions; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.GetV2PolicyOptions; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.Grant; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.GrantWithEnrichedRoles; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ListPoliciesOptions; +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.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; -import com.ibm.cloud.platform_services.iam_policy_management.v1.model.PolicyList; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.PolicyAssignment; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.PolicyAssignmentRequestOptionsItem; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.PolicyAssignmentResources; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.PolicyAssignmentResourcesPolicy; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.PolicyCollection; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.PolicyResource; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.PolicyRole; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.PolicySubject; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.PolicyTemplate; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.PolicyTemplateAssignmentCollection; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.PolicyTemplateCollection; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.PolicyTemplateVersionsCollection; 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.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.RoleList; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.RoleCollection; 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; +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.UpdatePolicyStateOptions; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.V2Policy; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.V2PolicyCollection; @@ -100,7 +127,7 @@ public void testConstructorWithNullAuthenticator() throws Throwable { @Test public void testListPoliciesWOptions() throws Throwable { // Register a mock response - String mockResponseBody = "{\"policies\": [{\"id\": \"id\", \"type\": \"type\", \"description\": \"description\", \"subjects\": [{\"attributes\": [{\"name\": \"name\", \"value\": \"value\"}]}], \"roles\": [{\"role_id\": \"roleId\", \"display_name\": \"displayName\", \"description\": \"description\"}], \"resources\": [{\"attributes\": [{\"name\": \"name\", \"value\": \"value\", \"operator\": \"operator\"}], \"tags\": [{\"name\": \"name\", \"value\": \"value\", \"operator\": \"operator\"}]}], \"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\", \"state\": \"active\"}]}"; + String mockResponseBody = "{\"policies\": [{\"id\": \"id\", \"type\": \"type\", \"description\": \"description\", \"subjects\": [{\"attributes\": [{\"name\": \"name\", \"value\": \"value\"}]}], \"roles\": [{\"role_id\": \"roleId\", \"display_name\": \"displayName\", \"description\": \"description\"}], \"resources\": [{\"attributes\": [{\"name\": \"name\", \"value\": \"value\", \"operator\": \"operator\"}], \"tags\": [{\"name\": \"name\", \"value\": \"value\", \"operator\": \"operator\"}]}], \"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\", \"state\": \"active\", \"template\": {\"crn\": \"crn\", \"version\": \"version\"}}]}"; String listPoliciesPath = "/v1/policies"; server.enqueue(new MockResponse() .setHeader("Content-type", "application/json") @@ -123,9 +150,9 @@ public void testListPoliciesWOptions() throws Throwable { .build(); // Invoke listPolicies() with a valid options model and verify the result - Response response = iamPolicyManagementService.listPolicies(listPoliciesOptionsModel).execute(); + Response response = iamPolicyManagementService.listPolicies(listPoliciesOptionsModel).execute(); assertNotNull(response); - PolicyList responseObj = response.getResult(); + PolicyCollection responseObj = response.getResult(); assertNotNull(responseObj); // Verify the contents of the request sent to the mock server @@ -171,7 +198,7 @@ public void testListPoliciesNoOptions() throws Throwable { @Test public void testCreatePolicyWOptions() throws Throwable { // Register a mock response - String mockResponseBody = "{\"id\": \"id\", \"type\": \"type\", \"description\": \"description\", \"subjects\": [{\"attributes\": [{\"name\": \"name\", \"value\": \"value\"}]}], \"roles\": [{\"role_id\": \"roleId\", \"display_name\": \"displayName\", \"description\": \"description\"}], \"resources\": [{\"attributes\": [{\"name\": \"name\", \"value\": \"value\", \"operator\": \"operator\"}], \"tags\": [{\"name\": \"name\", \"value\": \"value\", \"operator\": \"operator\"}]}], \"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\", \"state\": \"active\"}"; + String mockResponseBody = "{\"id\": \"id\", \"type\": \"type\", \"description\": \"description\", \"subjects\": [{\"attributes\": [{\"name\": \"name\", \"value\": \"value\"}]}], \"roles\": [{\"role_id\": \"roleId\", \"display_name\": \"displayName\", \"description\": \"description\"}], \"resources\": [{\"attributes\": [{\"name\": \"name\", \"value\": \"value\", \"operator\": \"operator\"}], \"tags\": [{\"name\": \"name\", \"value\": \"value\", \"operator\": \"operator\"}]}], \"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\", \"state\": \"active\", \"template\": {\"crn\": \"crn\", \"version\": \"version\"}}"; String createPolicyPath = "/v1/policies"; server.enqueue(new MockResponse() .setHeader("Content-type", "application/json") @@ -263,7 +290,7 @@ public void testCreatePolicyNoOptions() throws Throwable { @Test public void testReplacePolicyWOptions() throws Throwable { // Register a mock response - String mockResponseBody = "{\"id\": \"id\", \"type\": \"type\", \"description\": \"description\", \"subjects\": [{\"attributes\": [{\"name\": \"name\", \"value\": \"value\"}]}], \"roles\": [{\"role_id\": \"roleId\", \"display_name\": \"displayName\", \"description\": \"description\"}], \"resources\": [{\"attributes\": [{\"name\": \"name\", \"value\": \"value\", \"operator\": \"operator\"}], \"tags\": [{\"name\": \"name\", \"value\": \"value\", \"operator\": \"operator\"}]}], \"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\", \"state\": \"active\"}"; + String mockResponseBody = "{\"id\": \"id\", \"type\": \"type\", \"description\": \"description\", \"subjects\": [{\"attributes\": [{\"name\": \"name\", \"value\": \"value\"}]}], \"roles\": [{\"role_id\": \"roleId\", \"display_name\": \"displayName\", \"description\": \"description\"}], \"resources\": [{\"attributes\": [{\"name\": \"name\", \"value\": \"value\", \"operator\": \"operator\"}], \"tags\": [{\"name\": \"name\", \"value\": \"value\", \"operator\": \"operator\"}]}], \"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\", \"state\": \"active\", \"template\": {\"crn\": \"crn\", \"version\": \"version\"}}"; String replacePolicyPath = "/v1/policies/testString"; server.enqueue(new MockResponse() .setHeader("Content-type", "application/json") @@ -358,7 +385,7 @@ public void testReplacePolicyNoOptions() throws Throwable { @Test public void testGetPolicyWOptions() throws Throwable { // Register a mock response - String mockResponseBody = "{\"id\": \"id\", \"type\": \"type\", \"description\": \"description\", \"subjects\": [{\"attributes\": [{\"name\": \"name\", \"value\": \"value\"}]}], \"roles\": [{\"role_id\": \"roleId\", \"display_name\": \"displayName\", \"description\": \"description\"}], \"resources\": [{\"attributes\": [{\"name\": \"name\", \"value\": \"value\", \"operator\": \"operator\"}], \"tags\": [{\"name\": \"name\", \"value\": \"value\", \"operator\": \"operator\"}]}], \"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\", \"state\": \"active\"}"; + String mockResponseBody = "{\"id\": \"id\", \"type\": \"type\", \"description\": \"description\", \"subjects\": [{\"attributes\": [{\"name\": \"name\", \"value\": \"value\"}]}], \"roles\": [{\"role_id\": \"roleId\", \"display_name\": \"displayName\", \"description\": \"description\"}], \"resources\": [{\"attributes\": [{\"name\": \"name\", \"value\": \"value\", \"operator\": \"operator\"}], \"tags\": [{\"name\": \"name\", \"value\": \"value\", \"operator\": \"operator\"}]}], \"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\", \"state\": \"active\", \"template\": {\"crn\": \"crn\", \"version\": \"version\"}}"; String getPolicyPath = "/v1/policies/testString"; server.enqueue(new MockResponse() .setHeader("Content-type", "application/json") @@ -459,7 +486,7 @@ public void testDeletePolicyNoOptions() throws Throwable { @Test public void testUpdatePolicyStateWOptions() throws Throwable { // Register a mock response - String mockResponseBody = "{\"id\": \"id\", \"type\": \"type\", \"description\": \"description\", \"subjects\": [{\"attributes\": [{\"name\": \"name\", \"value\": \"value\"}]}], \"roles\": [{\"role_id\": \"roleId\", \"display_name\": \"displayName\", \"description\": \"description\"}], \"resources\": [{\"attributes\": [{\"name\": \"name\", \"value\": \"value\", \"operator\": \"operator\"}], \"tags\": [{\"name\": \"name\", \"value\": \"value\", \"operator\": \"operator\"}]}], \"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\", \"state\": \"active\"}"; + String mockResponseBody = "{\"id\": \"id\", \"type\": \"type\", \"description\": \"description\", \"subjects\": [{\"attributes\": [{\"name\": \"name\", \"value\": \"value\"}]}], \"roles\": [{\"role_id\": \"roleId\", \"display_name\": \"displayName\", \"description\": \"description\"}], \"resources\": [{\"attributes\": [{\"name\": \"name\", \"value\": \"value\", \"operator\": \"operator\"}], \"tags\": [{\"name\": \"name\", \"value\": \"value\", \"operator\": \"operator\"}]}], \"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\", \"state\": \"active\", \"template\": {\"crn\": \"crn\", \"version\": \"version\"}}"; String updatePolicyStatePath = "/v1/policies/testString"; server.enqueue(new MockResponse() .setHeader("Content-type", "application/json") @@ -532,9 +559,9 @@ public void testListRolesWOptions() throws Throwable { .build(); // Invoke listRoles() with a valid options model and verify the result - Response response = iamPolicyManagementService.listRoles(listRolesOptionsModel).execute(); + Response response = iamPolicyManagementService.listRoles(listRolesOptionsModel).execute(); assertNotNull(response); - RoleList responseObj = response.getResult(); + RoleCollection responseObj = response.getResult(); assertNotNull(responseObj); // Verify the contents of the request sent to the mock server @@ -783,7 +810,7 @@ public void testDeleteRoleNoOptions() throws Throwable { @Test public void testListV2PoliciesWOptions() throws Throwable { // Register a mock response - String mockResponseBody = "{\"policies\": [{\"type\": \"access\", \"description\": \"description\", \"subject\": {\"attributes\": [{\"key\": \"key\", \"operator\": \"stringEquals\", \"value\": \"value\"}]}, \"resource\": {\"attributes\": [{\"key\": \"key\", \"operator\": \"stringEquals\", \"value\": \"anyValue\"}], \"tags\": [{\"key\": \"key\", \"value\": \"value\", \"operator\": \"stringEquals\"}]}, \"pattern\": \"pattern\", \"rule\": {\"key\": \"key\", \"operator\": \"timeLessThan\", \"value\": \"anyValue\"}, \"id\": \"id\", \"href\": \"href\", \"control\": {\"grant\": {\"roles\": [{\"role_id\": \"roleId\"}]}}, \"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\", \"state\": \"active\", \"last_permit_at\": \"lastPermitAt\", \"last_permit_frequency\": 19}]}"; + String mockResponseBody = "{\"policies\": [{\"type\": \"access\", \"description\": \"description\", \"subject\": {\"attributes\": [{\"key\": \"key\", \"operator\": \"stringEquals\", \"value\": \"value\"}]}, \"resource\": {\"attributes\": [{\"key\": \"key\", \"operator\": \"stringEquals\", \"value\": \"anyValue\"}], \"tags\": [{\"key\": \"key\", \"value\": \"value\", \"operator\": \"stringEquals\"}]}, \"pattern\": \"pattern\", \"rule\": {\"key\": \"key\", \"operator\": \"timeLessThan\", \"value\": \"anyValue\"}, \"id\": \"id\", \"href\": \"href\", \"control\": {\"grant\": {\"roles\": [{\"role_id\": \"roleId\"}]}}, \"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\", \"state\": \"active\", \"last_permit_at\": \"lastPermitAt\", \"last_permit_frequency\": 19, \"template\": {\"crn\": \"crn\", \"version\": \"version\"}}]}"; String listV2PoliciesPath = "/v2/policies"; server.enqueue(new MockResponse() .setHeader("Content-type", "application/json") @@ -854,7 +881,7 @@ public void testListV2PoliciesNoOptions() throws Throwable { @Test public void testCreateV2PolicyWOptions() throws Throwable { // Register a mock response - String mockResponseBody = "{\"type\": \"access\", \"description\": \"description\", \"subject\": {\"attributes\": [{\"key\": \"key\", \"operator\": \"stringEquals\", \"value\": \"value\"}]}, \"resource\": {\"attributes\": [{\"key\": \"key\", \"operator\": \"stringEquals\", \"value\": \"anyValue\"}], \"tags\": [{\"key\": \"key\", \"value\": \"value\", \"operator\": \"stringEquals\"}]}, \"pattern\": \"pattern\", \"rule\": {\"key\": \"key\", \"operator\": \"timeLessThan\", \"value\": \"anyValue\"}, \"id\": \"id\", \"href\": \"href\", \"control\": {\"grant\": {\"roles\": [{\"role_id\": \"roleId\"}]}}, \"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\", \"state\": \"active\", \"last_permit_at\": \"lastPermitAt\", \"last_permit_frequency\": 19}"; + String mockResponseBody = "{\"type\": \"access\", \"description\": \"description\", \"subject\": {\"attributes\": [{\"key\": \"key\", \"operator\": \"stringEquals\", \"value\": \"value\"}]}, \"resource\": {\"attributes\": [{\"key\": \"key\", \"operator\": \"stringEquals\", \"value\": \"anyValue\"}], \"tags\": [{\"key\": \"key\", \"value\": \"value\", \"operator\": \"stringEquals\"}]}, \"pattern\": \"pattern\", \"rule\": {\"key\": \"key\", \"operator\": \"timeLessThan\", \"value\": \"anyValue\"}, \"id\": \"id\", \"href\": \"href\", \"control\": {\"grant\": {\"roles\": [{\"role_id\": \"roleId\"}]}}, \"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\", \"state\": \"active\", \"last_permit_at\": \"lastPermitAt\", \"last_permit_frequency\": 19, \"template\": {\"crn\": \"crn\", \"version\": \"version\"}}"; String createV2PolicyPath = "/v2/policies"; server.enqueue(new MockResponse() .setHeader("Content-type", "application/json") @@ -966,7 +993,7 @@ public void testCreateV2PolicyNoOptions() throws Throwable { @Test public void testReplaceV2PolicyWOptions() throws Throwable { // Register a mock response - String mockResponseBody = "{\"type\": \"access\", \"description\": \"description\", \"subject\": {\"attributes\": [{\"key\": \"key\", \"operator\": \"stringEquals\", \"value\": \"value\"}]}, \"resource\": {\"attributes\": [{\"key\": \"key\", \"operator\": \"stringEquals\", \"value\": \"anyValue\"}], \"tags\": [{\"key\": \"key\", \"value\": \"value\", \"operator\": \"stringEquals\"}]}, \"pattern\": \"pattern\", \"rule\": {\"key\": \"key\", \"operator\": \"timeLessThan\", \"value\": \"anyValue\"}, \"id\": \"id\", \"href\": \"href\", \"control\": {\"grant\": {\"roles\": [{\"role_id\": \"roleId\"}]}}, \"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\", \"state\": \"active\", \"last_permit_at\": \"lastPermitAt\", \"last_permit_frequency\": 19}"; + String mockResponseBody = "{\"type\": \"access\", \"description\": \"description\", \"subject\": {\"attributes\": [{\"key\": \"key\", \"operator\": \"stringEquals\", \"value\": \"value\"}]}, \"resource\": {\"attributes\": [{\"key\": \"key\", \"operator\": \"stringEquals\", \"value\": \"anyValue\"}], \"tags\": [{\"key\": \"key\", \"value\": \"value\", \"operator\": \"stringEquals\"}]}, \"pattern\": \"pattern\", \"rule\": {\"key\": \"key\", \"operator\": \"timeLessThan\", \"value\": \"anyValue\"}, \"id\": \"id\", \"href\": \"href\", \"control\": {\"grant\": {\"roles\": [{\"role_id\": \"roleId\"}]}}, \"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\", \"state\": \"active\", \"last_permit_at\": \"lastPermitAt\", \"last_permit_frequency\": 19, \"template\": {\"crn\": \"crn\", \"version\": \"version\"}}"; String replaceV2PolicyPath = "/v2/policies/testString"; server.enqueue(new MockResponse() .setHeader("Content-type", "application/json") @@ -1081,7 +1108,7 @@ public void testReplaceV2PolicyNoOptions() throws Throwable { @Test public void testGetV2PolicyWOptions() throws Throwable { // Register a mock response - String mockResponseBody = "{\"type\": \"access\", \"description\": \"description\", \"subject\": {\"attributes\": [{\"key\": \"key\", \"operator\": \"stringEquals\", \"value\": \"value\"}]}, \"resource\": {\"attributes\": [{\"key\": \"key\", \"operator\": \"stringEquals\", \"value\": \"anyValue\"}], \"tags\": [{\"key\": \"key\", \"value\": \"value\", \"operator\": \"stringEquals\"}]}, \"pattern\": \"pattern\", \"rule\": {\"key\": \"key\", \"operator\": \"timeLessThan\", \"value\": \"anyValue\"}, \"id\": \"id\", \"href\": \"href\", \"control\": {\"grant\": {\"roles\": [{\"role_id\": \"roleId\"}]}}, \"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\", \"state\": \"active\", \"last_permit_at\": \"lastPermitAt\", \"last_permit_frequency\": 19}"; + String mockResponseBody = "{\"type\": \"access\", \"description\": \"description\", \"subject\": {\"attributes\": [{\"key\": \"key\", \"operator\": \"stringEquals\", \"value\": \"value\"}]}, \"resource\": {\"attributes\": [{\"key\": \"key\", \"operator\": \"stringEquals\", \"value\": \"anyValue\"}], \"tags\": [{\"key\": \"key\", \"value\": \"value\", \"operator\": \"stringEquals\"}]}, \"pattern\": \"pattern\", \"rule\": {\"key\": \"key\", \"operator\": \"timeLessThan\", \"value\": \"anyValue\"}, \"id\": \"id\", \"href\": \"href\", \"control\": {\"grant\": {\"roles\": [{\"role_id\": \"roleId\"}]}}, \"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\", \"state\": \"active\", \"last_permit_at\": \"lastPermitAt\", \"last_permit_frequency\": 19, \"template\": {\"crn\": \"crn\", \"version\": \"version\"}}"; String getV2PolicyPath = "/v2/policies/testString"; server.enqueue(new MockResponse() .setHeader("Content-type", "application/json") @@ -1180,6 +1207,800 @@ public void testDeleteV2PolicyNoOptions() throws Throwable { iamPolicyManagementService.deleteV2Policy(null).execute(); } + // Test the listPolicyTemplates operation with a valid options model parameter + @Test + public void testListPolicyTemplatesWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = "{\"policy_templates\": [{\"name\": \"name\", \"description\": \"description\", \"account_id\": \"accountId\", \"version\": \"version\", \"committed\": false, \"policy\": {\"type\": \"access\", \"description\": \"description\", \"resource\": {\"attributes\": [{\"key\": \"key\", \"operator\": \"stringEquals\", \"value\": \"anyValue\"}], \"tags\": [{\"key\": \"key\", \"value\": \"value\", \"operator\": \"stringEquals\"}]}, \"pattern\": \"pattern\", \"rule\": {\"key\": \"key\", \"operator\": \"timeLessThan\", \"value\": \"anyValue\"}, \"control\": {\"grant\": {\"roles\": [{\"role_id\": \"roleId\"}]}}}, \"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\"}]}"; + String listPolicyTemplatesPath = "/v1/policy_templates"; + server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the ListPolicyTemplatesOptions model + ListPolicyTemplatesOptions listPolicyTemplatesOptionsModel = new ListPolicyTemplatesOptions.Builder() + .accountId("testString") + .acceptLanguage("default") + .build(); + + // Invoke listPolicyTemplates() with a valid options model and verify the result + Response response = iamPolicyManagementService.listPolicyTemplates(listPolicyTemplatesOptionsModel).execute(); + assertNotNull(response); + PolicyTemplateCollection 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, listPolicyTemplatesPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("account_id"), "testString"); + } + + // Test the listPolicyTemplates operation with and without retries enabled + @Test + public void testListPolicyTemplatesWRetries() throws Throwable { + iamPolicyManagementService.enableRetries(4, 30); + testListPolicyTemplatesWOptions(); + + iamPolicyManagementService.disableRetries(); + testListPolicyTemplatesWOptions(); + } + + // Test the listPolicyTemplates operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListPolicyTemplatesNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + iamPolicyManagementService.listPolicyTemplates(null).execute(); + } + + // Test the createPolicyTemplate operation with a valid options model parameter + @Test + public void testCreatePolicyTemplateWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = "{\"name\": \"name\", \"description\": \"description\", \"account_id\": \"accountId\", \"version\": \"version\", \"committed\": false, \"policy\": {\"type\": \"access\", \"description\": \"description\", \"resource\": {\"attributes\": [{\"key\": \"key\", \"operator\": \"stringEquals\", \"value\": \"anyValue\"}], \"tags\": [{\"key\": \"key\", \"value\": \"value\", \"operator\": \"stringEquals\"}]}, \"pattern\": \"pattern\", \"rule\": {\"key\": \"key\", \"operator\": \"timeLessThan\", \"value\": \"anyValue\"}, \"control\": {\"grant\": {\"roles\": [{\"role_id\": \"roleId\"}]}}}, \"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\"}"; + String createPolicyTemplatePath = "/v1/policy_templates"; + server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(201) + .setBody(mockResponseBody)); + + // Construct an instance of the V2PolicyResourceAttribute model + V2PolicyResourceAttribute v2PolicyResourceAttributeModel = new V2PolicyResourceAttribute.Builder() + .key("testString") + .operator("stringEquals") + .value("testString") + .build(); + + // Construct an instance of the V2PolicyResourceTag model + V2PolicyResourceTag v2PolicyResourceTagModel = new V2PolicyResourceTag.Builder() + .key("testString") + .value("testString") + .operator("stringEquals") + .build(); + + // Construct an instance of the V2PolicyResource model + V2PolicyResource v2PolicyResourceModel = new V2PolicyResource.Builder() + .attributes(java.util.Arrays.asList(v2PolicyResourceAttributeModel)) + .tags(java.util.Arrays.asList(v2PolicyResourceTagModel)) + .build(); + + // Construct an instance of the V2PolicyRuleRuleAttribute model + V2PolicyRuleRuleAttribute v2PolicyRuleModel = new V2PolicyRuleRuleAttribute.Builder() + .key("testString") + .operator("timeLessThan") + .value("testString") + .build(); + + // Construct an instance of the Roles model + Roles rolesModel = new Roles.Builder() + .roleId("testString") + .build(); + + // Construct an instance of the Grant model + Grant grantModel = new Grant.Builder() + .roles(java.util.Arrays.asList(rolesModel)) + .build(); + + // Construct an instance of the Control model + Control controlModel = new Control.Builder() + .grant(grantModel) + .build(); + + // Construct an instance of the TemplatePolicy model + TemplatePolicy templatePolicyModel = new TemplatePolicy.Builder() + .type("access") + .description("testString") + .resource(v2PolicyResourceModel) + .pattern("testString") + .rule(v2PolicyRuleModel) + .control(controlModel) + .build(); + + // Construct an instance of the CreatePolicyTemplateOptions model + CreatePolicyTemplateOptions createPolicyTemplateOptionsModel = new CreatePolicyTemplateOptions.Builder() + .name("testString") + .accountId("testString") + .policy(templatePolicyModel) + .description("testString") + .committed(true) + .acceptLanguage("default") + .build(); + + // Invoke createPolicyTemplate() with a valid options model and verify the result + Response response = iamPolicyManagementService.createPolicyTemplate(createPolicyTemplateOptionsModel).execute(); + assertNotNull(response); + PolicyTemplate 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, createPolicyTemplatePath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } + + // Test the createPolicyTemplate operation with and without retries enabled + @Test + public void testCreatePolicyTemplateWRetries() throws Throwable { + iamPolicyManagementService.enableRetries(4, 30); + testCreatePolicyTemplateWOptions(); + + iamPolicyManagementService.disableRetries(); + testCreatePolicyTemplateWOptions(); + } + + // Test the createPolicyTemplate operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreatePolicyTemplateNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + iamPolicyManagementService.createPolicyTemplate(null).execute(); + } + + // Test the getPolicyTemplate operation with a valid options model parameter + @Test + public void testGetPolicyTemplateWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = "{\"name\": \"name\", \"description\": \"description\", \"account_id\": \"accountId\", \"version\": \"version\", \"committed\": false, \"policy\": {\"type\": \"access\", \"description\": \"description\", \"resource\": {\"attributes\": [{\"key\": \"key\", \"operator\": \"stringEquals\", \"value\": \"anyValue\"}], \"tags\": [{\"key\": \"key\", \"value\": \"value\", \"operator\": \"stringEquals\"}]}, \"pattern\": \"pattern\", \"rule\": {\"key\": \"key\", \"operator\": \"timeLessThan\", \"value\": \"anyValue\"}, \"control\": {\"grant\": {\"roles\": [{\"role_id\": \"roleId\"}]}}}, \"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\"}"; + String getPolicyTemplatePath = "/v1/policy_templates/testString"; + server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the GetPolicyTemplateOptions model + GetPolicyTemplateOptions getPolicyTemplateOptionsModel = new GetPolicyTemplateOptions.Builder() + .policyTemplateId("testString") + .build(); + + // Invoke getPolicyTemplate() with a valid options model and verify the result + Response response = iamPolicyManagementService.getPolicyTemplate(getPolicyTemplateOptionsModel).execute(); + assertNotNull(response); + PolicyTemplate 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, getPolicyTemplatePath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } + + // Test the getPolicyTemplate operation with and without retries enabled + @Test + public void testGetPolicyTemplateWRetries() throws Throwable { + iamPolicyManagementService.enableRetries(4, 30); + testGetPolicyTemplateWOptions(); + + iamPolicyManagementService.disableRetries(); + testGetPolicyTemplateWOptions(); + } + + // Test the getPolicyTemplate operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetPolicyTemplateNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + iamPolicyManagementService.getPolicyTemplate(null).execute(); + } + + // Test the deletePolicyTemplate operation with a valid options model parameter + @Test + public void testDeletePolicyTemplateWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = ""; + String deletePolicyTemplatePath = "/v1/policy_templates/testString"; + server.enqueue(new MockResponse() + .setResponseCode(204) + .setBody(mockResponseBody)); + + // Construct an instance of the DeletePolicyTemplateOptions model + DeletePolicyTemplateOptions deletePolicyTemplateOptionsModel = new DeletePolicyTemplateOptions.Builder() + .policyTemplateId("testString") + .build(); + + // Invoke deletePolicyTemplate() with a valid options model and verify the result + Response response = iamPolicyManagementService.deletePolicyTemplate(deletePolicyTemplateOptionsModel).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, deletePolicyTemplatePath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } + + // Test the deletePolicyTemplate operation with and without retries enabled + @Test + public void testDeletePolicyTemplateWRetries() throws Throwable { + iamPolicyManagementService.enableRetries(4, 30); + testDeletePolicyTemplateWOptions(); + + iamPolicyManagementService.disableRetries(); + testDeletePolicyTemplateWOptions(); + } + + // Test the deletePolicyTemplate operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeletePolicyTemplateNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + iamPolicyManagementService.deletePolicyTemplate(null).execute(); + } + + // Test the createPolicyTemplateVersion operation with a valid options model parameter + @Test + public void testCreatePolicyTemplateVersionWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = "{\"name\": \"name\", \"description\": \"description\", \"account_id\": \"accountId\", \"version\": \"version\", \"committed\": false, \"policy\": {\"type\": \"access\", \"description\": \"description\", \"resource\": {\"attributes\": [{\"key\": \"key\", \"operator\": \"stringEquals\", \"value\": \"anyValue\"}], \"tags\": [{\"key\": \"key\", \"value\": \"value\", \"operator\": \"stringEquals\"}]}, \"pattern\": \"pattern\", \"rule\": {\"key\": \"key\", \"operator\": \"timeLessThan\", \"value\": \"anyValue\"}, \"control\": {\"grant\": {\"roles\": [{\"role_id\": \"roleId\"}]}}}, \"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\"}"; + String createPolicyTemplateVersionPath = "/v1/policy_templates/testString/versions"; + server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(201) + .setBody(mockResponseBody)); + + // Construct an instance of the V2PolicyResourceAttribute model + V2PolicyResourceAttribute v2PolicyResourceAttributeModel = new V2PolicyResourceAttribute.Builder() + .key("testString") + .operator("stringEquals") + .value("testString") + .build(); + + // Construct an instance of the V2PolicyResourceTag model + V2PolicyResourceTag v2PolicyResourceTagModel = new V2PolicyResourceTag.Builder() + .key("testString") + .value("testString") + .operator("stringEquals") + .build(); + + // Construct an instance of the V2PolicyResource model + V2PolicyResource v2PolicyResourceModel = new V2PolicyResource.Builder() + .attributes(java.util.Arrays.asList(v2PolicyResourceAttributeModel)) + .tags(java.util.Arrays.asList(v2PolicyResourceTagModel)) + .build(); + + // Construct an instance of the V2PolicyRuleRuleAttribute model + V2PolicyRuleRuleAttribute v2PolicyRuleModel = new V2PolicyRuleRuleAttribute.Builder() + .key("testString") + .operator("timeLessThan") + .value("testString") + .build(); + + // Construct an instance of the Roles model + Roles rolesModel = new Roles.Builder() + .roleId("testString") + .build(); + + // Construct an instance of the Grant model + Grant grantModel = new Grant.Builder() + .roles(java.util.Arrays.asList(rolesModel)) + .build(); + + // Construct an instance of the Control model + Control controlModel = new Control.Builder() + .grant(grantModel) + .build(); + + // Construct an instance of the TemplatePolicy model + TemplatePolicy templatePolicyModel = new TemplatePolicy.Builder() + .type("access") + .description("testString") + .resource(v2PolicyResourceModel) + .pattern("testString") + .rule(v2PolicyRuleModel) + .control(controlModel) + .build(); + + // Construct an instance of the CreatePolicyTemplateVersionOptions model + CreatePolicyTemplateVersionOptions createPolicyTemplateVersionOptionsModel = new CreatePolicyTemplateVersionOptions.Builder() + .policyTemplateId("testString") + .policy(templatePolicyModel) + .description("testString") + .committed(true) + .build(); + + // Invoke createPolicyTemplateVersion() with a valid options model and verify the result + Response response = iamPolicyManagementService.createPolicyTemplateVersion(createPolicyTemplateVersionOptionsModel).execute(); + assertNotNull(response); + PolicyTemplate 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, createPolicyTemplateVersionPath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } + + // Test the createPolicyTemplateVersion operation with and without retries enabled + @Test + public void testCreatePolicyTemplateVersionWRetries() throws Throwable { + iamPolicyManagementService.enableRetries(4, 30); + testCreatePolicyTemplateVersionWOptions(); + + iamPolicyManagementService.disableRetries(); + testCreatePolicyTemplateVersionWOptions(); + } + + // Test the createPolicyTemplateVersion operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreatePolicyTemplateVersionNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + iamPolicyManagementService.createPolicyTemplateVersion(null).execute(); + } + + // Test the listPolicyTemplateVersions operation with a valid options model parameter + @Test + public void testListPolicyTemplateVersionsWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = "{\"versions\": [{\"name\": \"name\", \"description\": \"description\", \"account_id\": \"accountId\", \"version\": \"version\", \"committed\": false, \"policy\": {\"type\": \"access\", \"description\": \"description\", \"resource\": {\"attributes\": [{\"key\": \"key\", \"operator\": \"stringEquals\", \"value\": \"anyValue\"}], \"tags\": [{\"key\": \"key\", \"value\": \"value\", \"operator\": \"stringEquals\"}]}, \"pattern\": \"pattern\", \"rule\": {\"key\": \"key\", \"operator\": \"timeLessThan\", \"value\": \"anyValue\"}, \"control\": {\"grant\": {\"roles\": [{\"role_id\": \"roleId\"}]}}}, \"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\"}]}"; + String listPolicyTemplateVersionsPath = "/v1/policy_templates/testString/versions"; + server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the ListPolicyTemplateVersionsOptions model + ListPolicyTemplateVersionsOptions listPolicyTemplateVersionsOptionsModel = new ListPolicyTemplateVersionsOptions.Builder() + .policyTemplateId("testString") + .build(); + + // Invoke listPolicyTemplateVersions() with a valid options model and verify the result + Response response = iamPolicyManagementService.listPolicyTemplateVersions(listPolicyTemplateVersionsOptionsModel).execute(); + assertNotNull(response); + PolicyTemplateVersionsCollection 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, listPolicyTemplateVersionsPath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } + + // Test the listPolicyTemplateVersions operation with and without retries enabled + @Test + public void testListPolicyTemplateVersionsWRetries() throws Throwable { + iamPolicyManagementService.enableRetries(4, 30); + testListPolicyTemplateVersionsWOptions(); + + iamPolicyManagementService.disableRetries(); + testListPolicyTemplateVersionsWOptions(); + } + + // Test the listPolicyTemplateVersions operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListPolicyTemplateVersionsNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + iamPolicyManagementService.listPolicyTemplateVersions(null).execute(); + } + + // Test the replacePolicyTemplate operation with a valid options model parameter + @Test + public void testReplacePolicyTemplateWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = "{\"name\": \"name\", \"description\": \"description\", \"account_id\": \"accountId\", \"version\": \"version\", \"committed\": false, \"policy\": {\"type\": \"access\", \"description\": \"description\", \"resource\": {\"attributes\": [{\"key\": \"key\", \"operator\": \"stringEquals\", \"value\": \"anyValue\"}], \"tags\": [{\"key\": \"key\", \"value\": \"value\", \"operator\": \"stringEquals\"}]}, \"pattern\": \"pattern\", \"rule\": {\"key\": \"key\", \"operator\": \"timeLessThan\", \"value\": \"anyValue\"}, \"control\": {\"grant\": {\"roles\": [{\"role_id\": \"roleId\"}]}}}, \"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\"}"; + String replacePolicyTemplatePath = "/v1/policy_templates/testString/versions/testString"; + server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the V2PolicyResourceAttribute model + V2PolicyResourceAttribute v2PolicyResourceAttributeModel = new V2PolicyResourceAttribute.Builder() + .key("testString") + .operator("stringEquals") + .value("testString") + .build(); + + // Construct an instance of the V2PolicyResourceTag model + V2PolicyResourceTag v2PolicyResourceTagModel = new V2PolicyResourceTag.Builder() + .key("testString") + .value("testString") + .operator("stringEquals") + .build(); + + // Construct an instance of the V2PolicyResource model + V2PolicyResource v2PolicyResourceModel = new V2PolicyResource.Builder() + .attributes(java.util.Arrays.asList(v2PolicyResourceAttributeModel)) + .tags(java.util.Arrays.asList(v2PolicyResourceTagModel)) + .build(); + + // Construct an instance of the V2PolicyRuleRuleAttribute model + V2PolicyRuleRuleAttribute v2PolicyRuleModel = new V2PolicyRuleRuleAttribute.Builder() + .key("testString") + .operator("timeLessThan") + .value("testString") + .build(); + + // Construct an instance of the Roles model + Roles rolesModel = new Roles.Builder() + .roleId("testString") + .build(); + + // Construct an instance of the Grant model + Grant grantModel = new Grant.Builder() + .roles(java.util.Arrays.asList(rolesModel)) + .build(); + + // Construct an instance of the Control model + Control controlModel = new Control.Builder() + .grant(grantModel) + .build(); + + // Construct an instance of the TemplatePolicy model + TemplatePolicy templatePolicyModel = new TemplatePolicy.Builder() + .type("access") + .description("testString") + .resource(v2PolicyResourceModel) + .pattern("testString") + .rule(v2PolicyRuleModel) + .control(controlModel) + .build(); + + // Construct an instance of the ReplacePolicyTemplateOptions model + ReplacePolicyTemplateOptions replacePolicyTemplateOptionsModel = new ReplacePolicyTemplateOptions.Builder() + .policyTemplateId("testString") + .version("testString") + .ifMatch("testString") + .policy(templatePolicyModel) + .description("testString") + .committed(true) + .build(); + + // Invoke replacePolicyTemplate() with a valid options model and verify the result + Response response = iamPolicyManagementService.replacePolicyTemplate(replacePolicyTemplateOptionsModel).execute(); + assertNotNull(response); + PolicyTemplate 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, replacePolicyTemplatePath); + // 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 replacePolicyTemplate operation with and without retries enabled + @Test + public void testReplacePolicyTemplateWRetries() throws Throwable { + iamPolicyManagementService.enableRetries(4, 30); + testReplacePolicyTemplateWOptions(); + + iamPolicyManagementService.disableRetries(); + testReplacePolicyTemplateWOptions(); + } + + // Test the replacePolicyTemplate operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testReplacePolicyTemplateNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + iamPolicyManagementService.replacePolicyTemplate(null).execute(); + } + + // Test the deletePolicyTemplateVersion operation with a valid options model parameter + @Test + public void testDeletePolicyTemplateVersionWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = ""; + String deletePolicyTemplateVersionPath = "/v1/policy_templates/testString/versions/testString"; + server.enqueue(new MockResponse() + .setResponseCode(204) + .setBody(mockResponseBody)); + + // Construct an instance of the DeletePolicyTemplateVersionOptions model + DeletePolicyTemplateVersionOptions deletePolicyTemplateVersionOptionsModel = new DeletePolicyTemplateVersionOptions.Builder() + .policyTemplateId("testString") + .version("testString") + .build(); + + // Invoke deletePolicyTemplateVersion() with a valid options model and verify the result + Response response = iamPolicyManagementService.deletePolicyTemplateVersion(deletePolicyTemplateVersionOptionsModel).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, deletePolicyTemplateVersionPath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } + + // Test the deletePolicyTemplateVersion operation with and without retries enabled + @Test + public void testDeletePolicyTemplateVersionWRetries() throws Throwable { + iamPolicyManagementService.enableRetries(4, 30); + testDeletePolicyTemplateVersionWOptions(); + + iamPolicyManagementService.disableRetries(); + testDeletePolicyTemplateVersionWOptions(); + } + + // Test the deletePolicyTemplateVersion operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeletePolicyTemplateVersionNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + iamPolicyManagementService.deletePolicyTemplateVersion(null).execute(); + } + + // Test the getPolicyTemplateVersion operation with a valid options model parameter + @Test + public void testGetPolicyTemplateVersionWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = "{\"name\": \"name\", \"description\": \"description\", \"account_id\": \"accountId\", \"version\": \"version\", \"committed\": false, \"policy\": {\"type\": \"access\", \"description\": \"description\", \"resource\": {\"attributes\": [{\"key\": \"key\", \"operator\": \"stringEquals\", \"value\": \"anyValue\"}], \"tags\": [{\"key\": \"key\", \"value\": \"value\", \"operator\": \"stringEquals\"}]}, \"pattern\": \"pattern\", \"rule\": {\"key\": \"key\", \"operator\": \"timeLessThan\", \"value\": \"anyValue\"}, \"control\": {\"grant\": {\"roles\": [{\"role_id\": \"roleId\"}]}}}, \"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\"}"; + String getPolicyTemplateVersionPath = "/v1/policy_templates/testString/versions/testString"; + server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the GetPolicyTemplateVersionOptions model + GetPolicyTemplateVersionOptions getPolicyTemplateVersionOptionsModel = new GetPolicyTemplateVersionOptions.Builder() + .policyTemplateId("testString") + .version("testString") + .build(); + + // Invoke getPolicyTemplateVersion() with a valid options model and verify the result + Response response = iamPolicyManagementService.getPolicyTemplateVersion(getPolicyTemplateVersionOptionsModel).execute(); + assertNotNull(response); + PolicyTemplate 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, getPolicyTemplateVersionPath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } + + // Test the getPolicyTemplateVersion operation with and without retries enabled + @Test + public void testGetPolicyTemplateVersionWRetries() throws Throwable { + iamPolicyManagementService.enableRetries(4, 30); + testGetPolicyTemplateVersionWOptions(); + + iamPolicyManagementService.disableRetries(); + testGetPolicyTemplateVersionWOptions(); + } + + // Test the getPolicyTemplateVersion operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetPolicyTemplateVersionNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + iamPolicyManagementService.getPolicyTemplateVersion(null).execute(); + } + + // Test the commitPolicyTemplate operation with a valid options model parameter + @Test + public void testCommitPolicyTemplateWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = ""; + String commitPolicyTemplatePath = "/v1/policy_templates/testString/versions/testString/commit"; + server.enqueue(new MockResponse() + .setResponseCode(204) + .setBody(mockResponseBody)); + + // Construct an instance of the CommitPolicyTemplateOptions model + CommitPolicyTemplateOptions commitPolicyTemplateOptionsModel = new CommitPolicyTemplateOptions.Builder() + .policyTemplateId("testString") + .version("testString") + .ifMatch("testString") + .build(); + + // Invoke commitPolicyTemplate() with a valid options model and verify the result + Response response = iamPolicyManagementService.commitPolicyTemplate(commitPolicyTemplateOptionsModel).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, commitPolicyTemplatePath); + // 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 commitPolicyTemplate operation with and without retries enabled + @Test + public void testCommitPolicyTemplateWRetries() throws Throwable { + iamPolicyManagementService.enableRetries(4, 30); + testCommitPolicyTemplateWOptions(); + + iamPolicyManagementService.disableRetries(); + testCommitPolicyTemplateWOptions(); + } + + // Test the commitPolicyTemplate operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCommitPolicyTemplateNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + iamPolicyManagementService.commitPolicyTemplate(null).execute(); + } + + // Test the listPolicyAssignments operation with a valid options model parameter + @Test + public void testListPolicyAssignmentsWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = "{\"assignments\": [{\"template_id\": \"templateId\", \"template_version\": \"templateVersion\", \"assignment_id\": \"assignmentId\", \"target_type\": \"Account\", \"target\": \"target\", \"options\": [{\"subject_type\": \"iam_id\", \"subject_id\": \"subjectId\", \"root_requester_id\": \"rootRequesterId\", \"root_template_id\": \"rootTemplateId\", \"root_template_version\": \"rootTemplateVersion\"}], \"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\": \"target\", \"policy\": {\"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\": 10}}}], \"status\": \"in_progress\"}]}"; + String listPolicyAssignmentsPath = "/v1/policy_assignments"; + server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the ListPolicyAssignmentsOptions model + ListPolicyAssignmentsOptions listPolicyAssignmentsOptionsModel = new ListPolicyAssignmentsOptions.Builder() + .accountId("testString") + .acceptLanguage("default") + .templateId("testString") + .templateVersion("testString") + .build(); + + // Invoke listPolicyAssignments() with a valid options model and verify the result + Response response = iamPolicyManagementService.listPolicyAssignments(listPolicyAssignmentsOptionsModel).execute(); + assertNotNull(response); + PolicyTemplateAssignmentCollection 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, listPolicyAssignmentsPath); + // 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"); + } + + // Test the listPolicyAssignments operation with and without retries enabled + @Test + public void testListPolicyAssignmentsWRetries() throws Throwable { + iamPolicyManagementService.enableRetries(4, 30); + testListPolicyAssignmentsWOptions(); + + iamPolicyManagementService.disableRetries(); + testListPolicyAssignmentsWOptions(); + } + + // Test the listPolicyAssignments operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListPolicyAssignmentsNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + iamPolicyManagementService.listPolicyAssignments(null).execute(); + } + + // Test the getPolicyAssignment operation with a valid options model parameter + @Test + public void testGetPolicyAssignmentWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = "{\"template_id\": \"templateId\", \"template_version\": \"templateVersion\", \"assignment_id\": \"assignmentId\", \"target_type\": \"Account\", \"target\": \"target\", \"options\": [{\"subject_type\": \"iam_id\", \"subject_id\": \"subjectId\", \"root_requester_id\": \"rootRequesterId\", \"root_template_id\": \"rootTemplateId\", \"root_template_version\": \"rootTemplateVersion\"}], \"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\": \"target\", \"policy\": {\"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\": 10}}}], \"status\": \"in_progress\"}"; + String getPolicyAssignmentPath = "/v1/policy_assignments/testString"; + server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the GetPolicyAssignmentOptions model + GetPolicyAssignmentOptions getPolicyAssignmentOptionsModel = new GetPolicyAssignmentOptions.Builder() + .assignmentId("testString") + .build(); + + // Invoke getPolicyAssignment() with a valid options model and verify the result + Response response = iamPolicyManagementService.getPolicyAssignment(getPolicyAssignmentOptionsModel).execute(); + assertNotNull(response); + PolicyAssignment 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, getPolicyAssignmentPath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } + + // Test the getPolicyAssignment operation with and without retries enabled + @Test + public void testGetPolicyAssignmentWRetries() throws Throwable { + iamPolicyManagementService.enableRetries(4, 30); + testGetPolicyAssignmentWOptions(); + + iamPolicyManagementService.disableRetries(); + testGetPolicyAssignmentWOptions(); + } + + // Test the getPolicyAssignment operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetPolicyAssignmentNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + iamPolicyManagementService.getPolicyAssignment(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/AssignmentResourceCreatedTest.java b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/AssignmentResourceCreatedTest.java new file mode 100644 index 0000000000..ad2efd43c4 --- /dev/null +++ b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/AssignmentResourceCreatedTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2023. + * + * 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.AssignmentResourceCreated; +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 AssignmentResourceCreated model. + */ +public class AssignmentResourceCreatedTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testAssignmentResourceCreated() throws Throwable { + AssignmentResourceCreated assignmentResourceCreatedModel = new AssignmentResourceCreated(); + assertNull(assignmentResourceCreatedModel.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/CommitPolicyTemplateOptionsTest.java b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/CommitPolicyTemplateOptionsTest.java new file mode 100644 index 0000000000..a5e87cf0d3 --- /dev/null +++ b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/CommitPolicyTemplateOptionsTest.java @@ -0,0 +1,49 @@ +/* + * (C) Copyright IBM Corp. 2023. + * + * 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.CommitPolicyTemplateOptions; +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 CommitPolicyTemplateOptions model. + */ +public class CommitPolicyTemplateOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCommitPolicyTemplateOptions() throws Throwable { + CommitPolicyTemplateOptions commitPolicyTemplateOptionsModel = new CommitPolicyTemplateOptions.Builder() + .policyTemplateId("testString") + .version("testString") + .ifMatch("testString") + .build(); + assertEquals(commitPolicyTemplateOptionsModel.policyTemplateId(), "testString"); + assertEquals(commitPolicyTemplateOptionsModel.version(), "testString"); + assertEquals(commitPolicyTemplateOptionsModel.ifMatch(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCommitPolicyTemplateOptionsError() throws Throwable { + new CommitPolicyTemplateOptions.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/ConflictsWithTest.java b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ConflictsWithTest.java new file mode 100644 index 0000000000..853375c7ee --- /dev/null +++ b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ConflictsWithTest.java @@ -0,0 +1,39 @@ +/* + * (C) Copyright IBM Corp. 2023. + * + * 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.ConflictsWith; +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 ConflictsWith model. + */ +public class ConflictsWithTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testConflictsWith() throws Throwable { + ConflictsWith conflictsWithModel = new ConflictsWith(); + assertNull(conflictsWithModel.getEtag()); + assertNull(conflictsWithModel.getRole()); + assertNull(conflictsWithModel.getPolicy()); + } +} \ 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/CreatePolicyTemplateOptionsTest.java b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/CreatePolicyTemplateOptionsTest.java new file mode 100644 index 0000000000..9907e08048 --- /dev/null +++ b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/CreatePolicyTemplateOptionsTest.java @@ -0,0 +1,127 @@ +/* + * (C) Copyright IBM Corp. 2023. + * + * 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.Control; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.CreatePolicyTemplateOptions; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.Grant; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.Roles; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.TemplatePolicy; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.V2PolicyResource; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.V2PolicyResourceAttribute; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.V2PolicyResourceTag; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.V2PolicyRuleRuleAttribute; +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 CreatePolicyTemplateOptions model. + */ +public class CreatePolicyTemplateOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCreatePolicyTemplateOptions() throws Throwable { + V2PolicyResourceAttribute v2PolicyResourceAttributeModel = new V2PolicyResourceAttribute.Builder() + .key("testString") + .operator("stringEquals") + .value("testString") + .build(); + assertEquals(v2PolicyResourceAttributeModel.key(), "testString"); + assertEquals(v2PolicyResourceAttributeModel.operator(), "stringEquals"); + assertEquals(v2PolicyResourceAttributeModel.value(), "testString"); + + V2PolicyResourceTag v2PolicyResourceTagModel = new V2PolicyResourceTag.Builder() + .key("testString") + .value("testString") + .operator("stringEquals") + .build(); + assertEquals(v2PolicyResourceTagModel.key(), "testString"); + assertEquals(v2PolicyResourceTagModel.value(), "testString"); + assertEquals(v2PolicyResourceTagModel.operator(), "stringEquals"); + + V2PolicyResource v2PolicyResourceModel = new V2PolicyResource.Builder() + .attributes(java.util.Arrays.asList(v2PolicyResourceAttributeModel)) + .tags(java.util.Arrays.asList(v2PolicyResourceTagModel)) + .build(); + assertEquals(v2PolicyResourceModel.attributes(), java.util.Arrays.asList(v2PolicyResourceAttributeModel)); + assertEquals(v2PolicyResourceModel.tags(), java.util.Arrays.asList(v2PolicyResourceTagModel)); + + V2PolicyRuleRuleAttribute v2PolicyRuleModel = new V2PolicyRuleRuleAttribute.Builder() + .key("testString") + .operator("timeLessThan") + .value("testString") + .build(); + assertEquals(v2PolicyRuleModel.key(), "testString"); + assertEquals(v2PolicyRuleModel.operator(), "timeLessThan"); + assertEquals(v2PolicyRuleModel.value(), "testString"); + + Roles rolesModel = new Roles.Builder() + .roleId("testString") + .build(); + assertEquals(rolesModel.roleId(), "testString"); + + Grant grantModel = new Grant.Builder() + .roles(java.util.Arrays.asList(rolesModel)) + .build(); + assertEquals(grantModel.roles(), java.util.Arrays.asList(rolesModel)); + + Control controlModel = new Control.Builder() + .grant(grantModel) + .build(); + assertEquals(controlModel.grant(), grantModel); + + TemplatePolicy templatePolicyModel = new TemplatePolicy.Builder() + .type("access") + .description("testString") + .resource(v2PolicyResourceModel) + .pattern("testString") + .rule(v2PolicyRuleModel) + .control(controlModel) + .build(); + assertEquals(templatePolicyModel.type(), "access"); + assertEquals(templatePolicyModel.description(), "testString"); + assertEquals(templatePolicyModel.resource(), v2PolicyResourceModel); + assertEquals(templatePolicyModel.pattern(), "testString"); + assertEquals(templatePolicyModel.rule(), v2PolicyRuleModel); + assertEquals(templatePolicyModel.control(), controlModel); + + CreatePolicyTemplateOptions createPolicyTemplateOptionsModel = new CreatePolicyTemplateOptions.Builder() + .name("testString") + .accountId("testString") + .policy(templatePolicyModel) + .description("testString") + .committed(true) + .acceptLanguage("default") + .build(); + assertEquals(createPolicyTemplateOptionsModel.name(), "testString"); + assertEquals(createPolicyTemplateOptionsModel.accountId(), "testString"); + assertEquals(createPolicyTemplateOptionsModel.policy(), templatePolicyModel); + assertEquals(createPolicyTemplateOptionsModel.description(), "testString"); + assertEquals(createPolicyTemplateOptionsModel.committed(), Boolean.valueOf(true)); + assertEquals(createPolicyTemplateOptionsModel.acceptLanguage(), "default"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreatePolicyTemplateOptionsError() throws Throwable { + new CreatePolicyTemplateOptions.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/CreatePolicyTemplateVersionOptionsTest.java b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/CreatePolicyTemplateVersionOptionsTest.java new file mode 100644 index 0000000000..923ea62028 --- /dev/null +++ b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/CreatePolicyTemplateVersionOptionsTest.java @@ -0,0 +1,123 @@ +/* + * (C) Copyright IBM Corp. 2023. + * + * 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.Control; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.CreatePolicyTemplateVersionOptions; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.Grant; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.Roles; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.TemplatePolicy; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.V2PolicyResource; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.V2PolicyResourceAttribute; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.V2PolicyResourceTag; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.V2PolicyRuleRuleAttribute; +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 CreatePolicyTemplateVersionOptions model. + */ +public class CreatePolicyTemplateVersionOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCreatePolicyTemplateVersionOptions() throws Throwable { + V2PolicyResourceAttribute v2PolicyResourceAttributeModel = new V2PolicyResourceAttribute.Builder() + .key("testString") + .operator("stringEquals") + .value("testString") + .build(); + assertEquals(v2PolicyResourceAttributeModel.key(), "testString"); + assertEquals(v2PolicyResourceAttributeModel.operator(), "stringEquals"); + assertEquals(v2PolicyResourceAttributeModel.value(), "testString"); + + V2PolicyResourceTag v2PolicyResourceTagModel = new V2PolicyResourceTag.Builder() + .key("testString") + .value("testString") + .operator("stringEquals") + .build(); + assertEquals(v2PolicyResourceTagModel.key(), "testString"); + assertEquals(v2PolicyResourceTagModel.value(), "testString"); + assertEquals(v2PolicyResourceTagModel.operator(), "stringEquals"); + + V2PolicyResource v2PolicyResourceModel = new V2PolicyResource.Builder() + .attributes(java.util.Arrays.asList(v2PolicyResourceAttributeModel)) + .tags(java.util.Arrays.asList(v2PolicyResourceTagModel)) + .build(); + assertEquals(v2PolicyResourceModel.attributes(), java.util.Arrays.asList(v2PolicyResourceAttributeModel)); + assertEquals(v2PolicyResourceModel.tags(), java.util.Arrays.asList(v2PolicyResourceTagModel)); + + V2PolicyRuleRuleAttribute v2PolicyRuleModel = new V2PolicyRuleRuleAttribute.Builder() + .key("testString") + .operator("timeLessThan") + .value("testString") + .build(); + assertEquals(v2PolicyRuleModel.key(), "testString"); + assertEquals(v2PolicyRuleModel.operator(), "timeLessThan"); + assertEquals(v2PolicyRuleModel.value(), "testString"); + + Roles rolesModel = new Roles.Builder() + .roleId("testString") + .build(); + assertEquals(rolesModel.roleId(), "testString"); + + Grant grantModel = new Grant.Builder() + .roles(java.util.Arrays.asList(rolesModel)) + .build(); + assertEquals(grantModel.roles(), java.util.Arrays.asList(rolesModel)); + + Control controlModel = new Control.Builder() + .grant(grantModel) + .build(); + assertEquals(controlModel.grant(), grantModel); + + TemplatePolicy templatePolicyModel = new TemplatePolicy.Builder() + .type("access") + .description("testString") + .resource(v2PolicyResourceModel) + .pattern("testString") + .rule(v2PolicyRuleModel) + .control(controlModel) + .build(); + assertEquals(templatePolicyModel.type(), "access"); + assertEquals(templatePolicyModel.description(), "testString"); + assertEquals(templatePolicyModel.resource(), v2PolicyResourceModel); + assertEquals(templatePolicyModel.pattern(), "testString"); + assertEquals(templatePolicyModel.rule(), v2PolicyRuleModel); + assertEquals(templatePolicyModel.control(), controlModel); + + CreatePolicyTemplateVersionOptions createPolicyTemplateVersionOptionsModel = new CreatePolicyTemplateVersionOptions.Builder() + .policyTemplateId("testString") + .policy(templatePolicyModel) + .description("testString") + .committed(true) + .build(); + assertEquals(createPolicyTemplateVersionOptionsModel.policyTemplateId(), "testString"); + assertEquals(createPolicyTemplateVersionOptionsModel.policy(), templatePolicyModel); + assertEquals(createPolicyTemplateVersionOptionsModel.description(), "testString"); + assertEquals(createPolicyTemplateVersionOptionsModel.committed(), Boolean.valueOf(true)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreatePolicyTemplateVersionOptionsError() throws Throwable { + new CreatePolicyTemplateVersionOptions.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/DeletePolicyAssignmentOptionsTest.java b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/DeletePolicyAssignmentOptionsTest.java new file mode 100644 index 0000000000..40f6ce21e7 --- /dev/null +++ b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/DeletePolicyAssignmentOptionsTest.java @@ -0,0 +1,45 @@ +/* + * (C) Copyright IBM Corp. 2023. + * + * 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.DeletePolicyAssignmentOptions; +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 DeletePolicyAssignmentOptions model. + */ +public class DeletePolicyAssignmentOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeletePolicyAssignmentOptions() throws Throwable { + DeletePolicyAssignmentOptions deletePolicyAssignmentOptionsModel = new DeletePolicyAssignmentOptions.Builder() + .assignmentId("testString") + .build(); + assertEquals(deletePolicyAssignmentOptionsModel.assignmentId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeletePolicyAssignmentOptionsError() throws Throwable { + new DeletePolicyAssignmentOptions.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/DeletePolicyTemplateOptionsTest.java b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/DeletePolicyTemplateOptionsTest.java new file mode 100644 index 0000000000..ca3eb0c3aa --- /dev/null +++ b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/DeletePolicyTemplateOptionsTest.java @@ -0,0 +1,45 @@ +/* + * (C) Copyright IBM Corp. 2023. + * + * 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.DeletePolicyTemplateOptions; +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 DeletePolicyTemplateOptions model. + */ +public class DeletePolicyTemplateOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeletePolicyTemplateOptions() throws Throwable { + DeletePolicyTemplateOptions deletePolicyTemplateOptionsModel = new DeletePolicyTemplateOptions.Builder() + .policyTemplateId("testString") + .build(); + assertEquals(deletePolicyTemplateOptionsModel.policyTemplateId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeletePolicyTemplateOptionsError() throws Throwable { + new DeletePolicyTemplateOptions.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/DeletePolicyTemplateVersionOptionsTest.java b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/DeletePolicyTemplateVersionOptionsTest.java new file mode 100644 index 0000000000..0c0d905dee --- /dev/null +++ b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/DeletePolicyTemplateVersionOptionsTest.java @@ -0,0 +1,47 @@ +/* + * (C) Copyright IBM Corp. 2023. + * + * 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.DeletePolicyTemplateVersionOptions; +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 DeletePolicyTemplateVersionOptions model. + */ +public class DeletePolicyTemplateVersionOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeletePolicyTemplateVersionOptions() throws Throwable { + DeletePolicyTemplateVersionOptions deletePolicyTemplateVersionOptionsModel = new DeletePolicyTemplateVersionOptions.Builder() + .policyTemplateId("testString") + .version("testString") + .build(); + assertEquals(deletePolicyTemplateVersionOptionsModel.policyTemplateId(), "testString"); + assertEquals(deletePolicyTemplateVersionOptionsModel.version(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeletePolicyTemplateVersionOptionsError() throws Throwable { + new DeletePolicyTemplateVersionOptions.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/ErrorDetailsTest.java b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ErrorDetailsTest.java new file mode 100644 index 0000000000..e4cf38d290 --- /dev/null +++ b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ErrorDetailsTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2023. + * + * 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.ConflictsWith; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ErrorDetails; +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 ErrorDetails model. + */ +public class ErrorDetailsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testErrorDetails() throws Throwable { + ErrorDetails errorDetailsModel = new ErrorDetails(); + assertNull(errorDetailsModel.getConflictsWith()); + } +} \ 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/ErrorObjectTest.java b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ErrorObjectTest.java new file mode 100644 index 0000000000..88ae416442 --- /dev/null +++ b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ErrorObjectTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2023. + * + * 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.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 ErrorObject model. + */ +public class ErrorObjectTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testErrorObject() throws Throwable { + ErrorObject errorObjectModel = new ErrorObject(); + assertNull(errorObjectModel.getCode()); + assertNull(errorObjectModel.getMessage()); + assertNull(errorObjectModel.getDetails()); + assertNull(errorObjectModel.getMoreInfo()); + } +} \ 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/ErrorResponseTest.java new file mode 100644 index 0000000000..21f4e6ff37 --- /dev/null +++ b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ErrorResponseTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2023. + * + * 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.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; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; +import static org.testng.Assert.*; + +/** + * Unit test class for the ErrorResponse model. + */ +public class ErrorResponseTest { + 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()); + } +} \ 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/GetPolicyAssignmentOptionsTest.java b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/GetPolicyAssignmentOptionsTest.java new file mode 100644 index 0000000000..f3650f5245 --- /dev/null +++ b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/GetPolicyAssignmentOptionsTest.java @@ -0,0 +1,45 @@ +/* + * (C) Copyright IBM Corp. 2023. + * + * 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.GetPolicyAssignmentOptions; +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 GetPolicyAssignmentOptions model. + */ +public class GetPolicyAssignmentOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetPolicyAssignmentOptions() throws Throwable { + GetPolicyAssignmentOptions getPolicyAssignmentOptionsModel = new GetPolicyAssignmentOptions.Builder() + .assignmentId("testString") + .build(); + assertEquals(getPolicyAssignmentOptionsModel.assignmentId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetPolicyAssignmentOptionsError() throws Throwable { + new GetPolicyAssignmentOptions.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/GetPolicyTemplateOptionsTest.java b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/GetPolicyTemplateOptionsTest.java new file mode 100644 index 0000000000..41bb4a571f --- /dev/null +++ b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/GetPolicyTemplateOptionsTest.java @@ -0,0 +1,45 @@ +/* + * (C) Copyright IBM Corp. 2023. + * + * 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.GetPolicyTemplateOptions; +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 GetPolicyTemplateOptions model. + */ +public class GetPolicyTemplateOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetPolicyTemplateOptions() throws Throwable { + GetPolicyTemplateOptions getPolicyTemplateOptionsModel = new GetPolicyTemplateOptions.Builder() + .policyTemplateId("testString") + .build(); + assertEquals(getPolicyTemplateOptionsModel.policyTemplateId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetPolicyTemplateOptionsError() throws Throwable { + new GetPolicyTemplateOptions.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/GetPolicyTemplateVersionOptionsTest.java b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/GetPolicyTemplateVersionOptionsTest.java new file mode 100644 index 0000000000..50395ae127 --- /dev/null +++ b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/GetPolicyTemplateVersionOptionsTest.java @@ -0,0 +1,47 @@ +/* + * (C) Copyright IBM Corp. 2023. + * + * 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.GetPolicyTemplateVersionOptions; +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 GetPolicyTemplateVersionOptions model. + */ +public class GetPolicyTemplateVersionOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetPolicyTemplateVersionOptions() throws Throwable { + GetPolicyTemplateVersionOptions getPolicyTemplateVersionOptionsModel = new GetPolicyTemplateVersionOptions.Builder() + .policyTemplateId("testString") + .version("testString") + .build(); + assertEquals(getPolicyTemplateVersionOptionsModel.policyTemplateId(), "testString"); + assertEquals(getPolicyTemplateVersionOptionsModel.version(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetPolicyTemplateVersionOptionsError() throws Throwable { + new GetPolicyTemplateVersionOptions.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/ListPolicyAssignmentsOptionsTest.java b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ListPolicyAssignmentsOptionsTest.java new file mode 100644 index 0000000000..61afefbe1a --- /dev/null +++ b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ListPolicyAssignmentsOptionsTest.java @@ -0,0 +1,51 @@ +/* + * (C) Copyright IBM Corp. 2023. + * + * 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.ListPolicyAssignmentsOptions; +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 ListPolicyAssignmentsOptions model. + */ +public class ListPolicyAssignmentsOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListPolicyAssignmentsOptions() throws Throwable { + ListPolicyAssignmentsOptions listPolicyAssignmentsOptionsModel = new ListPolicyAssignmentsOptions.Builder() + .accountId("testString") + .acceptLanguage("default") + .templateId("testString") + .templateVersion("testString") + .build(); + assertEquals(listPolicyAssignmentsOptionsModel.accountId(), "testString"); + assertEquals(listPolicyAssignmentsOptionsModel.acceptLanguage(), "default"); + assertEquals(listPolicyAssignmentsOptionsModel.templateId(), "testString"); + assertEquals(listPolicyAssignmentsOptionsModel.templateVersion(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListPolicyAssignmentsOptionsError() throws Throwable { + new ListPolicyAssignmentsOptions.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/ListPolicyTemplateVersionsOptionsTest.java b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ListPolicyTemplateVersionsOptionsTest.java new file mode 100644 index 0000000000..e633967e39 --- /dev/null +++ b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ListPolicyTemplateVersionsOptionsTest.java @@ -0,0 +1,45 @@ +/* + * (C) Copyright IBM Corp. 2023. + * + * 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.ListPolicyTemplateVersionsOptions; +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 ListPolicyTemplateVersionsOptions model. + */ +public class ListPolicyTemplateVersionsOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListPolicyTemplateVersionsOptions() throws Throwable { + ListPolicyTemplateVersionsOptions listPolicyTemplateVersionsOptionsModel = new ListPolicyTemplateVersionsOptions.Builder() + .policyTemplateId("testString") + .build(); + assertEquals(listPolicyTemplateVersionsOptionsModel.policyTemplateId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListPolicyTemplateVersionsOptionsError() throws Throwable { + new ListPolicyTemplateVersionsOptions.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/ListPolicyTemplateVerssionsOptionsTest.java b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ListPolicyTemplateVerssionsOptionsTest.java new file mode 100644 index 0000000000..546c9d04b0 --- /dev/null +++ b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ListPolicyTemplateVerssionsOptionsTest.java @@ -0,0 +1,45 @@ +/* + * (C) Copyright IBM Corp. 2023. + * + * 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.ListPolicyTemplateVerssionsOptions; +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 ListPolicyTemplateVerssionsOptions model. + */ +public class ListPolicyTemplateVerssionsOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListPolicyTemplateVerssionsOptions() throws Throwable { + ListPolicyTemplateVerssionsOptions listPolicyTemplateVerssionsOptionsModel = new ListPolicyTemplateVerssionsOptions.Builder() + .policyTemplateId("testString") + .build(); + assertEquals(listPolicyTemplateVerssionsOptionsModel.policyTemplateId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListPolicyTemplateVerssionsOptionsError() throws Throwable { + new ListPolicyTemplateVerssionsOptions.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/ListPolicyTemplatesOptionsTest.java b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ListPolicyTemplatesOptionsTest.java new file mode 100644 index 0000000000..e0ba7886de --- /dev/null +++ b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ListPolicyTemplatesOptionsTest.java @@ -0,0 +1,47 @@ +/* + * (C) Copyright IBM Corp. 2023. + * + * 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.ListPolicyTemplatesOptions; +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 ListPolicyTemplatesOptions model. + */ +public class ListPolicyTemplatesOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListPolicyTemplatesOptions() throws Throwable { + ListPolicyTemplatesOptions listPolicyTemplatesOptionsModel = new ListPolicyTemplatesOptions.Builder() + .accountId("testString") + .acceptLanguage("default") + .build(); + assertEquals(listPolicyTemplatesOptionsModel.accountId(), "testString"); + assertEquals(listPolicyTemplatesOptionsModel.acceptLanguage(), "default"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListPolicyTemplatesOptionsError() throws Throwable { + new ListPolicyTemplatesOptions.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/PatchPolicyAssignmentOptionsTest.java b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PatchPolicyAssignmentOptionsTest.java new file mode 100644 index 0000000000..a5a920ba88 --- /dev/null +++ b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PatchPolicyAssignmentOptionsTest.java @@ -0,0 +1,47 @@ +/* + * (C) Copyright IBM Corp. 2023. + * + * 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.PatchPolicyAssignmentOptions; +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 PatchPolicyAssignmentOptions model. + */ +public class PatchPolicyAssignmentOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testPatchPolicyAssignmentOptions() throws Throwable { + PatchPolicyAssignmentOptions patchPolicyAssignmentOptionsModel = new PatchPolicyAssignmentOptions.Builder() + .assignmentId("testString") + .version("testString") + .build(); + assertEquals(patchPolicyAssignmentOptionsModel.assignmentId(), "testString"); + assertEquals(patchPolicyAssignmentOptionsModel.version(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testPatchPolicyAssignmentOptionsError() throws Throwable { + new PatchPolicyAssignmentOptions.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/PolcyTemplateAssignmentCollectionTest.java b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolcyTemplateAssignmentCollectionTest.java new file mode 100644 index 0000000000..4b96cc7a36 --- /dev/null +++ b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolcyTemplateAssignmentCollectionTest.java @@ -0,0 +1,46 @@ +/* + * (C) Copyright IBM Corp. 2023. + * + * 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.AssignmentResourceCreated; +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.PolcyTemplateAssignmentCollection; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.PolicyAssignmentOptions; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.PolicyAssignmentRecord; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.PolicyAssignmentResources; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.PolicyAssignmentResourcesPolicy; +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 PolcyTemplateAssignmentCollection model. + */ +public class PolcyTemplateAssignmentCollectionTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testPolcyTemplateAssignmentCollection() throws Throwable { + PolcyTemplateAssignmentCollection polcyTemplateAssignmentCollectionModel = new PolcyTemplateAssignmentCollection(); + assertNull(polcyTemplateAssignmentCollectionModel.getPolicyAssignments()); + } +} \ 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/PolicyAssignmentOptionsTest.java b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyAssignmentOptionsTest.java new file mode 100644 index 0000000000..983946bc1c --- /dev/null +++ b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyAssignmentOptionsTest.java @@ -0,0 +1,41 @@ +/* + * (C) Copyright IBM Corp. 2023. + * + * 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.PolicyAssignmentOptions; +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 PolicyAssignmentOptions model. + */ +public class PolicyAssignmentOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testPolicyAssignmentOptions() throws Throwable { + PolicyAssignmentOptions policyAssignmentOptionsModel = new PolicyAssignmentOptions(); + assertNull(policyAssignmentOptionsModel.getSubjectType()); + assertNull(policyAssignmentOptionsModel.getSubjectId()); + assertNull(policyAssignmentOptionsModel.getRootRequesterId()); + assertNull(policyAssignmentOptionsModel.getRootTemplateId()); + assertNull(policyAssignmentOptionsModel.getRootTemplateVersion()); + } +} \ 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/PolicyAssignmentRecordTest.java b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyAssignmentRecordTest.java new file mode 100644 index 0000000000..91198f6b4f --- /dev/null +++ b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyAssignmentRecordTest.java @@ -0,0 +1,52 @@ +/* + * (C) Copyright IBM Corp. 2023. + * + * 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.AssignmentResourceCreated; +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.PolicyAssignmentOptions; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.PolicyAssignmentRecord; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.PolicyAssignmentResources; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.PolicyAssignmentResourcesPolicy; +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 PolicyAssignmentRecord model. + */ +public class PolicyAssignmentRecordTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testPolicyAssignmentRecord() throws Throwable { + PolicyAssignmentRecord policyAssignmentRecordModel = new PolicyAssignmentRecord(); + assertNull(policyAssignmentRecordModel.getTemplateId()); + assertNull(policyAssignmentRecordModel.getTemplateVersion()); + assertNull(policyAssignmentRecordModel.getAssignmentId()); + assertNull(policyAssignmentRecordModel.getTargetType()); + assertNull(policyAssignmentRecordModel.getTarget()); + assertNull(policyAssignmentRecordModel.getOptions()); + assertNull(policyAssignmentRecordModel.getResources()); + assertNull(policyAssignmentRecordModel.getStatus()); + } +} \ 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/PolicyAssignmentRequestOptionsItemTest.java b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyAssignmentRequestOptionsItemTest.java new file mode 100644 index 0000000000..55ab562bf0 --- /dev/null +++ b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyAssignmentRequestOptionsItemTest.java @@ -0,0 +1,41 @@ +/* + * (C) Copyright IBM Corp. 2023. + * + * 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.PolicyAssignmentRequestOptionsItem; +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 PolicyAssignmentRequestOptionsItem model. + */ +public class PolicyAssignmentRequestOptionsItemTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testPolicyAssignmentRequestOptionsItem() throws Throwable { + PolicyAssignmentRequestOptionsItem policyAssignmentRequestOptionsItemModel = new PolicyAssignmentRequestOptionsItem(); + assertNull(policyAssignmentRequestOptionsItemModel.getSubjectType()); + assertNull(policyAssignmentRequestOptionsItemModel.getSubjectId()); + assertNull(policyAssignmentRequestOptionsItemModel.getRootRequesterId()); + assertNull(policyAssignmentRequestOptionsItemModel.getRootTemplateId()); + assertNull(policyAssignmentRequestOptionsItemModel.getRootTemplateVersion()); + } +} \ 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/PolicyAssignmentResourcesPolicyTest.java b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyAssignmentResourcesPolicyTest.java new file mode 100644 index 0000000000..e1c63efb48 --- /dev/null +++ b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyAssignmentResourcesPolicyTest.java @@ -0,0 +1,43 @@ +/* + * (C) Copyright IBM Corp. 2023. + * + * 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.AssignmentResourceCreated; +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.PolicyAssignmentResourcesPolicy; +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 PolicyAssignmentResourcesPolicy model. + */ +public class PolicyAssignmentResourcesPolicyTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testPolicyAssignmentResourcesPolicy() throws Throwable { + PolicyAssignmentResourcesPolicy policyAssignmentResourcesPolicyModel = new PolicyAssignmentResourcesPolicy(); + assertNull(policyAssignmentResourcesPolicyModel.getResourceCreated()); + assertNull(policyAssignmentResourcesPolicyModel.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/PolicyAssignmentResourcesTest.java b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyAssignmentResourcesTest.java new file mode 100644 index 0000000000..ea4aca577c --- /dev/null +++ b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyAssignmentResourcesTest.java @@ -0,0 +1,44 @@ +/* + * (C) Copyright IBM Corp. 2023. + * + * 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.AssignmentResourceCreated; +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.PolicyAssignmentResources; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.PolicyAssignmentResourcesPolicy; +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 PolicyAssignmentResources model. + */ +public class PolicyAssignmentResourcesTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testPolicyAssignmentResources() throws Throwable { + PolicyAssignmentResources policyAssignmentResourcesModel = new PolicyAssignmentResources(); + assertNull(policyAssignmentResourcesModel.getTarget()); + assertNull(policyAssignmentResourcesModel.getPolicy()); + } +} \ 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/PolicyAssignmentTest.java b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyAssignmentTest.java new file mode 100644 index 0000000000..d4187ccfc0 --- /dev/null +++ b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyAssignmentTest.java @@ -0,0 +1,52 @@ +/* + * (C) Copyright IBM Corp. 2023. + * + * 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.AssignmentResourceCreated; +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.PolicyAssignment; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.PolicyAssignmentRequestOptionsItem; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.PolicyAssignmentResources; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.PolicyAssignmentResourcesPolicy; +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 PolicyAssignment model. + */ +public class PolicyAssignmentTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testPolicyAssignment() throws Throwable { + PolicyAssignment policyAssignmentModel = new PolicyAssignment(); + assertNull(policyAssignmentModel.getTemplateId()); + assertNull(policyAssignmentModel.getTemplateVersion()); + assertNull(policyAssignmentModel.getAssignmentId()); + assertNull(policyAssignmentModel.getTargetType()); + assertNull(policyAssignmentModel.getTarget()); + assertNull(policyAssignmentModel.getOptions()); + assertNull(policyAssignmentModel.getResources()); + assertNull(policyAssignmentModel.getStatus()); + } +} \ 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/PolicyCollectionTest.java b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyCollectionTest.java new file mode 100644 index 0000000000..3d91e0d66a --- /dev/null +++ b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyCollectionTest.java @@ -0,0 +1,45 @@ +/* + * (C) Copyright IBM Corp. 2023. + * + * 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.Policy; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.PolicyCollection; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.PolicyResource; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.PolicyRole; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.PolicySubject; +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.SubjectAttribute; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.TemplateMetadata; +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 PolicyCollection model. + */ +public class PolicyCollectionTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testPolicyCollection() throws Throwable { + PolicyCollection policyCollectionModel = new PolicyCollection(); + assertNull(policyCollectionModel.getPolicies()); + } +} \ 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/PolicyListTest.java b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyListTest.java index 5677900237..e84ee69c99 100644 --- a/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyListTest.java +++ b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyListTest.java @@ -21,6 +21,7 @@ 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.SubjectAttribute; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.TemplateMetada; 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/PolicyTemplateAssignmentCollectionTest.java b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyTemplateAssignmentCollectionTest.java new file mode 100644 index 0000000000..54eaf0ee19 --- /dev/null +++ b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyTemplateAssignmentCollectionTest.java @@ -0,0 +1,46 @@ +/* + * (C) Copyright IBM Corp. 2023. + * + * 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.AssignmentResourceCreated; +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.PolicyAssignment; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.PolicyAssignmentRequestOptionsItem; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.PolicyAssignmentResources; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.PolicyAssignmentResourcesPolicy; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.PolicyTemplateAssignmentCollection; +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 PolicyTemplateAssignmentCollection model. + */ +public class PolicyTemplateAssignmentCollectionTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testPolicyTemplateAssignmentCollection() throws Throwable { + PolicyTemplateAssignmentCollection policyTemplateAssignmentCollectionModel = new PolicyTemplateAssignmentCollection(); + assertNull(policyTemplateAssignmentCollectionModel.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/PolicyTemplateCollectionTest.java b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyTemplateCollectionTest.java new file mode 100644 index 0000000000..3f7ffa99f6 --- /dev/null +++ b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyTemplateCollectionTest.java @@ -0,0 +1,46 @@ +/* + * (C) Copyright IBM Corp. 2023. + * + * 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.Control; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.Grant; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.PolicyTemplate; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.PolicyTemplateCollection; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.Roles; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.TemplatePolicy; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.V2PolicyResource; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.V2PolicyResourceAttribute; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.V2PolicyResourceTag; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.V2PolicyRuleRuleAttribute; +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 PolicyTemplateCollection model. + */ +public class PolicyTemplateCollectionTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testPolicyTemplateCollection() throws Throwable { + PolicyTemplateCollection policyTemplateCollectionModel = new PolicyTemplateCollection(); + assertNull(policyTemplateCollectionModel.getPolicyTemplates()); + } +} \ 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/PolicyTemplateTest.java b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyTemplateTest.java new file mode 100644 index 0000000000..30639eff0f --- /dev/null +++ b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyTemplateTest.java @@ -0,0 +1,50 @@ +/* + * (C) Copyright IBM Corp. 2023. + * + * 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.Control; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.Grant; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.PolicyTemplate; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.Roles; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.TemplatePolicy; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.V2PolicyResource; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.V2PolicyResourceAttribute; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.V2PolicyResourceTag; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.V2PolicyRuleRuleAttribute; +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 PolicyTemplate model. + */ +public class PolicyTemplateTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testPolicyTemplate() throws Throwable { + PolicyTemplate policyTemplateModel = new PolicyTemplate(); + assertNull(policyTemplateModel.getName()); + assertNull(policyTemplateModel.getDescription()); + assertNull(policyTemplateModel.getAccountId()); + assertNull(policyTemplateModel.getVersion()); + assertNull(policyTemplateModel.isCommitted()); + assertNull(policyTemplateModel.getPolicy()); + } +} \ 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/PolicyTemplateVersionsCollectionTest.java b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyTemplateVersionsCollectionTest.java new file mode 100644 index 0000000000..7566a698b4 --- /dev/null +++ b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyTemplateVersionsCollectionTest.java @@ -0,0 +1,46 @@ +/* + * (C) Copyright IBM Corp. 2023. + * + * 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.Control; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.Grant; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.PolicyTemplate; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.PolicyTemplateVersionsCollection; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.Roles; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.TemplatePolicy; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.V2PolicyResource; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.V2PolicyResourceAttribute; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.V2PolicyResourceTag; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.V2PolicyRuleRuleAttribute; +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 PolicyTemplateVersionsCollection model. + */ +public class PolicyTemplateVersionsCollectionTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testPolicyTemplateVersionsCollection() throws Throwable { + PolicyTemplateVersionsCollection policyTemplateVersionsCollectionModel = new PolicyTemplateVersionsCollection(); + assertNull(policyTemplateVersionsCollectionModel.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/PolicyTest.java b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyTest.java index 854b3da88b..ec5fcd25d0 100644 --- a/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyTest.java +++ b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/PolicyTest.java @@ -20,6 +20,7 @@ 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.SubjectAttribute; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.TemplateMetadata; 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; @@ -44,5 +45,6 @@ public void testPolicy() throws Throwable { assertNull(policyModel.getRoles()); assertNull(policyModel.getResources()); assertNull(policyModel.getState()); + assertNull(policyModel.getTemplate()); } } \ 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/ReplacePolicyTemplateOptionsTest.java b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ReplacePolicyTemplateOptionsTest.java new file mode 100644 index 0000000000..0d81a9205a --- /dev/null +++ b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/ReplacePolicyTemplateOptionsTest.java @@ -0,0 +1,127 @@ +/* + * (C) Copyright IBM Corp. 2023. + * + * 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.Control; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.Grant; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ReplacePolicyTemplateOptions; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.Roles; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.TemplatePolicy; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.V2PolicyResource; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.V2PolicyResourceAttribute; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.V2PolicyResourceTag; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.V2PolicyRuleRuleAttribute; +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 ReplacePolicyTemplateOptions model. + */ +public class ReplacePolicyTemplateOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testReplacePolicyTemplateOptions() throws Throwable { + V2PolicyResourceAttribute v2PolicyResourceAttributeModel = new V2PolicyResourceAttribute.Builder() + .key("testString") + .operator("stringEquals") + .value("testString") + .build(); + assertEquals(v2PolicyResourceAttributeModel.key(), "testString"); + assertEquals(v2PolicyResourceAttributeModel.operator(), "stringEquals"); + assertEquals(v2PolicyResourceAttributeModel.value(), "testString"); + + V2PolicyResourceTag v2PolicyResourceTagModel = new V2PolicyResourceTag.Builder() + .key("testString") + .value("testString") + .operator("stringEquals") + .build(); + assertEquals(v2PolicyResourceTagModel.key(), "testString"); + assertEquals(v2PolicyResourceTagModel.value(), "testString"); + assertEquals(v2PolicyResourceTagModel.operator(), "stringEquals"); + + V2PolicyResource v2PolicyResourceModel = new V2PolicyResource.Builder() + .attributes(java.util.Arrays.asList(v2PolicyResourceAttributeModel)) + .tags(java.util.Arrays.asList(v2PolicyResourceTagModel)) + .build(); + assertEquals(v2PolicyResourceModel.attributes(), java.util.Arrays.asList(v2PolicyResourceAttributeModel)); + assertEquals(v2PolicyResourceModel.tags(), java.util.Arrays.asList(v2PolicyResourceTagModel)); + + V2PolicyRuleRuleAttribute v2PolicyRuleModel = new V2PolicyRuleRuleAttribute.Builder() + .key("testString") + .operator("timeLessThan") + .value("testString") + .build(); + assertEquals(v2PolicyRuleModel.key(), "testString"); + assertEquals(v2PolicyRuleModel.operator(), "timeLessThan"); + assertEquals(v2PolicyRuleModel.value(), "testString"); + + Roles rolesModel = new Roles.Builder() + .roleId("testString") + .build(); + assertEquals(rolesModel.roleId(), "testString"); + + Grant grantModel = new Grant.Builder() + .roles(java.util.Arrays.asList(rolesModel)) + .build(); + assertEquals(grantModel.roles(), java.util.Arrays.asList(rolesModel)); + + Control controlModel = new Control.Builder() + .grant(grantModel) + .build(); + assertEquals(controlModel.grant(), grantModel); + + TemplatePolicy templatePolicyModel = new TemplatePolicy.Builder() + .type("access") + .description("testString") + .resource(v2PolicyResourceModel) + .pattern("testString") + .rule(v2PolicyRuleModel) + .control(controlModel) + .build(); + assertEquals(templatePolicyModel.type(), "access"); + assertEquals(templatePolicyModel.description(), "testString"); + assertEquals(templatePolicyModel.resource(), v2PolicyResourceModel); + assertEquals(templatePolicyModel.pattern(), "testString"); + assertEquals(templatePolicyModel.rule(), v2PolicyRuleModel); + assertEquals(templatePolicyModel.control(), controlModel); + + ReplacePolicyTemplateOptions replacePolicyTemplateOptionsModel = new ReplacePolicyTemplateOptions.Builder() + .policyTemplateId("testString") + .version("testString") + .ifMatch("testString") + .policy(templatePolicyModel) + .description("testString") + .committed(true) + .build(); + assertEquals(replacePolicyTemplateOptionsModel.policyTemplateId(), "testString"); + assertEquals(replacePolicyTemplateOptionsModel.version(), "testString"); + assertEquals(replacePolicyTemplateOptionsModel.ifMatch(), "testString"); + assertEquals(replacePolicyTemplateOptionsModel.policy(), templatePolicyModel); + assertEquals(replacePolicyTemplateOptionsModel.description(), "testString"); + assertEquals(replacePolicyTemplateOptionsModel.committed(), Boolean.valueOf(true)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testReplacePolicyTemplateOptionsError() throws Throwable { + new ReplacePolicyTemplateOptions.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/RoleCollectionTest.java b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/RoleCollectionTest.java new file mode 100644 index 0000000000..f9785c6570 --- /dev/null +++ b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/RoleCollectionTest.java @@ -0,0 +1,41 @@ +/* + * (C) Copyright IBM Corp. 2023. + * + * 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.CustomRole; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.Role; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.RoleCollection; +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 RoleCollection model. + */ +public class RoleCollectionTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRoleCollection() throws Throwable { + RoleCollection roleCollectionModel = new RoleCollection(); + assertNull(roleCollectionModel.getCustomRoles()); + assertNull(roleCollectionModel.getServiceRoles()); + assertNull(roleCollectionModel.getSystemRoles()); + } +} \ 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/TemplateMetadaTest.java b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/TemplateMetadaTest.java new file mode 100644 index 0000000000..50bcb719d6 --- /dev/null +++ b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/TemplateMetadaTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2023. + * + * 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.TemplateMetada; +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 TemplateMetada model. + */ +public class TemplateMetadaTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTemplateMetada() throws Throwable { + TemplateMetada templateMetadaModel = new TemplateMetada(); + assertNull(templateMetadaModel.getCrn()); + assertNull(templateMetadaModel.getVersion()); + } +} \ 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/TemplateMetadataTest.java b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/TemplateMetadataTest.java new file mode 100644 index 0000000000..2b3e86f322 --- /dev/null +++ b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/TemplateMetadataTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2023. + * + * 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.TemplateMetadata; +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 TemplateMetadata model. + */ +public class TemplateMetadataTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTemplateMetadata() throws Throwable { + TemplateMetadata templateMetadataModel = new TemplateMetadata(); + assertNull(templateMetadataModel.getCrn()); + assertNull(templateMetadataModel.getVersion()); + } +} \ 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/TemplatePolicyTest.java b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/TemplatePolicyTest.java new file mode 100644 index 0000000000..388b9b8dca --- /dev/null +++ b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/TemplatePolicyTest.java @@ -0,0 +1,122 @@ +/* + * (C) Copyright IBM Corp. 2023. + * + * 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.Control; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.Grant; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.Roles; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.TemplatePolicy; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.V2PolicyResource; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.V2PolicyResourceAttribute; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.V2PolicyResourceTag; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.V2PolicyRuleRuleAttribute; +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 TemplatePolicy model. + */ +public class TemplatePolicyTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTemplatePolicy() throws Throwable { + V2PolicyResourceAttribute v2PolicyResourceAttributeModel = new V2PolicyResourceAttribute.Builder() + .key("testString") + .operator("stringEquals") + .value("testString") + .build(); + assertEquals(v2PolicyResourceAttributeModel.key(), "testString"); + assertEquals(v2PolicyResourceAttributeModel.operator(), "stringEquals"); + assertEquals(v2PolicyResourceAttributeModel.value(), "testString"); + + V2PolicyResourceTag v2PolicyResourceTagModel = new V2PolicyResourceTag.Builder() + .key("testString") + .value("testString") + .operator("stringEquals") + .build(); + assertEquals(v2PolicyResourceTagModel.key(), "testString"); + assertEquals(v2PolicyResourceTagModel.value(), "testString"); + assertEquals(v2PolicyResourceTagModel.operator(), "stringEquals"); + + V2PolicyResource v2PolicyResourceModel = new V2PolicyResource.Builder() + .attributes(java.util.Arrays.asList(v2PolicyResourceAttributeModel)) + .tags(java.util.Arrays.asList(v2PolicyResourceTagModel)) + .build(); + assertEquals(v2PolicyResourceModel.attributes(), java.util.Arrays.asList(v2PolicyResourceAttributeModel)); + assertEquals(v2PolicyResourceModel.tags(), java.util.Arrays.asList(v2PolicyResourceTagModel)); + + V2PolicyRuleRuleAttribute v2PolicyRuleModel = new V2PolicyRuleRuleAttribute.Builder() + .key("testString") + .operator("timeLessThan") + .value("testString") + .build(); + assertEquals(v2PolicyRuleModel.key(), "testString"); + assertEquals(v2PolicyRuleModel.operator(), "timeLessThan"); + assertEquals(v2PolicyRuleModel.value(), "testString"); + + Roles rolesModel = new Roles.Builder() + .roleId("testString") + .build(); + assertEquals(rolesModel.roleId(), "testString"); + + Grant grantModel = new Grant.Builder() + .roles(java.util.Arrays.asList(rolesModel)) + .build(); + assertEquals(grantModel.roles(), java.util.Arrays.asList(rolesModel)); + + Control controlModel = new Control.Builder() + .grant(grantModel) + .build(); + assertEquals(controlModel.grant(), grantModel); + + TemplatePolicy templatePolicyModel = new TemplatePolicy.Builder() + .type("access") + .description("testString") + .resource(v2PolicyResourceModel) + .pattern("testString") + .rule(v2PolicyRuleModel) + .control(controlModel) + .build(); + assertEquals(templatePolicyModel.type(), "access"); + assertEquals(templatePolicyModel.description(), "testString"); + assertEquals(templatePolicyModel.resource(), v2PolicyResourceModel); + assertEquals(templatePolicyModel.pattern(), "testString"); + assertEquals(templatePolicyModel.rule(), v2PolicyRuleModel); + assertEquals(templatePolicyModel.control(), controlModel); + + String json = TestUtilities.serialize(templatePolicyModel); + + TemplatePolicy templatePolicyModelNew = TestUtilities.deserialize(json, TemplatePolicy.class); + assertTrue(templatePolicyModelNew instanceof TemplatePolicy); + assertEquals(templatePolicyModelNew.type(), "access"); + assertEquals(templatePolicyModelNew.description(), "testString"); + assertEquals(templatePolicyModelNew.resource().toString(), v2PolicyResourceModel.toString()); + assertEquals(templatePolicyModelNew.pattern(), "testString"); + assertEquals(templatePolicyModelNew.rule().toString(), v2PolicyRuleModel.toString()); + assertEquals(templatePolicyModelNew.control().toString(), controlModel.toString()); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testTemplatePolicyError() throws Throwable { + new TemplatePolicy.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/V2PolicyCollectionTest.java b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/V2PolicyCollectionTest.java index 52e66d90b6..b835375761 100644 --- a/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/V2PolicyCollectionTest.java +++ b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/V2PolicyCollectionTest.java @@ -16,6 +16,7 @@ import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ControlResponseControl; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.Grant; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.Roles; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.TemplateMetadata; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.V2Policy; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.V2PolicyCollection; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.V2PolicyResource; diff --git a/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/V2PolicyTest.java b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/V2PolicyTest.java index 906a56758f..4c0cc55f0f 100644 --- a/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/V2PolicyTest.java +++ b/modules/iam-policy-management/src/test/java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/V2PolicyTest.java @@ -16,6 +16,7 @@ import com.ibm.cloud.platform_services.iam_policy_management.v1.model.ControlResponseControl; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.Grant; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.Roles; +import com.ibm.cloud.platform_services.iam_policy_management.v1.model.TemplateMetadata; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.V2Policy; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.V2PolicyResource; import com.ibm.cloud.platform_services.iam_policy_management.v1.model.V2PolicyResourceAttribute; @@ -51,5 +52,6 @@ public void testV2Policy() throws Throwable { assertNull(v2PolicyModel.getState()); assertNull(v2PolicyModel.getLastPermitAt()); assertNull(v2PolicyModel.getLastPermitFrequency()); + assertNull(v2PolicyModel.getTemplate()); } } \ No newline at end of file