From 57cdfca36ded0397208926d2b9d413d233cd0856 Mon Sep 17 00:00:00 2001 From: Marinov Avgustin Date: Wed, 4 Oct 2023 16:00:43 +0300 Subject: [PATCH] Remove spring REST doc Since now hawkBit support Swagger and OpenAPI the documentation is built using redoc based on OpenAPI definitions. Spring REST documentation is not needed anymore. Since this Spring REST doc is not needed and it duplicates API documentation (no single source of truth and hard to maintain) with this commit it is removed. Some tests from the Spring REST doc that seems are not covered by the JUnit of the resource modules are moved in the resource JUnit tests. Signed-off-by: Marinov Avgustin --- .../rest/resource/MgmtActionResourceTest.java | 23 +- .../MgmtDistributionSetResourceTest.java | 104 +- .../MgmtDistributionSetTagResourceTest.java | 14 +- .../MgmtDistributionSetTypeResourceTest.java | 25 + .../resource/MgmtRolloutResourceTest.java | 89 ++ .../MgmtSoftwareModuleResourceTest.java | 150 +- .../MgmtSoftwareModuleTypeResourceTest.java | 14 + .../MgmtTargetFilterQueryResourceTest.java | 84 +- .../rest/resource/MgmtTargetResourceTest.java | 87 +- .../resource/MgmtTargetTagResourceTest.java | 12 +- .../resource/MgmtTargetTypeResourceTest.java | 1 - .../MgmtTenantManagementResourceTest.java | 42 + hawkbit-rest/hawkbit-rest-docs/README.md | 17 - hawkbit-rest/hawkbit-rest-docs/pom.xml | 146 -- .../src/main/asciidoc/actions-api-guide.adoc | 111 -- .../asciidoc/distributionsets-api-guide.adoc | 892 ------------ .../distributionsettag-api-guide.adoc | 438 ------ .../distributionsettypes-api-guide.adoc | 636 --------- .../src/main/asciidoc/rollout-api-guide.adoc | 585 -------- .../asciidoc/rootcontroller-api-guide.adoc | 688 ---------- .../asciidoc/softwaremodules-api-guide.adoc | 756 ---------- .../softwaremoduletypes-api-guide.adoc | 255 ---- .../asciidoc/targetfilters-api-guide.adoc | 392 ------ .../src/main/asciidoc/targets-api-guide.adoc | 1212 ----------------- .../main/asciidoc/targettag-api-guide.adoc | 431 ------ .../main/asciidoc/targettypes-api-guide.adoc | 396 ------ .../src/main/asciidoc/tenant-api-guide.adoc | 194 --- .../src/main/errors/400.adoc | 3 - .../src/main/errors/400_multiassignment.adoc | 3 - .../src/main/errors/401.adoc | 3 - .../src/main/errors/403.adoc | 3 - .../src/main/errors/403_quota.adoc | 3 - .../src/main/errors/404.adoc | 3 - .../src/main/errors/404_target_action.adoc | 3 - .../src/main/errors/405.adoc | 3 - .../src/main/errors/406.adoc | 3 - .../src/main/errors/409.adoc | 3 - .../src/main/errors/410.adoc | 2 - .../src/main/errors/415.adoc | 3 - .../src/main/errors/429.adoc | 3 - .../src/main/errors/error-response-body.adoc | 27 - .../src/main/template/template.adoc | 64 - .../documentation/DdiApiModelProperties.java | 168 --- .../RootControllerDocumentationTest.java | 815 ----------- .../AbstractApiRestDocumentation.java | 381 ------ .../ApiModelPropertiesGeneric.java | 54 - .../DocumenationResponseFieldsSnippet.java | 25 - .../documentation/MgmtApiModelProperties.java | 285 ---- .../ActionResourceDocumentationTest.java | 165 --- ...butionSetTagResourceDocumentationTest.java | 308 ----- ...DistributionSetTypesDocumentationTest.java | 449 ------ .../DistributionSetsDocumentationTest.java | 699 ---------- .../RolloutResourceDocumentationTest.java | 712 ---------- .../SoftwaremoduleTypesDocumentationTest.java | 221 --- .../SoftwaremodulesDocumentationTest.java | 638 --------- ...ilterQueriesResourceDocumentationTest.java | 276 ---- .../TargetResourceDocumentationTest.java | 1042 -------------- .../TargetTagResourceDocumentationTest.java | 314 ----- .../TargetTypesDocumentationTest.java | 274 ---- .../TenantResourceDocumentationTest.java | 189 --- .../templates/path-parameters.snippet | 9 - .../restdocs/templates/request-fields.snippet | 12 - .../templates/response-fields.snippet | 11 - ...teserver-restdocumentation-test.properties | 38 - hawkbit-rest/pom.xml | 1 - hawkbit-test-report/pom.xml | 5 - 66 files changed, 580 insertions(+), 14434 deletions(-) delete mode 100644 hawkbit-rest/hawkbit-rest-docs/README.md delete mode 100644 hawkbit-rest/hawkbit-rest-docs/pom.xml delete mode 100644 hawkbit-rest/hawkbit-rest-docs/src/main/asciidoc/actions-api-guide.adoc delete mode 100644 hawkbit-rest/hawkbit-rest-docs/src/main/asciidoc/distributionsets-api-guide.adoc delete mode 100644 hawkbit-rest/hawkbit-rest-docs/src/main/asciidoc/distributionsettag-api-guide.adoc delete mode 100644 hawkbit-rest/hawkbit-rest-docs/src/main/asciidoc/distributionsettypes-api-guide.adoc delete mode 100644 hawkbit-rest/hawkbit-rest-docs/src/main/asciidoc/rollout-api-guide.adoc delete mode 100644 hawkbit-rest/hawkbit-rest-docs/src/main/asciidoc/rootcontroller-api-guide.adoc delete mode 100644 hawkbit-rest/hawkbit-rest-docs/src/main/asciidoc/softwaremodules-api-guide.adoc delete mode 100644 hawkbit-rest/hawkbit-rest-docs/src/main/asciidoc/softwaremoduletypes-api-guide.adoc delete mode 100644 hawkbit-rest/hawkbit-rest-docs/src/main/asciidoc/targetfilters-api-guide.adoc delete mode 100644 hawkbit-rest/hawkbit-rest-docs/src/main/asciidoc/targets-api-guide.adoc delete mode 100644 hawkbit-rest/hawkbit-rest-docs/src/main/asciidoc/targettag-api-guide.adoc delete mode 100644 hawkbit-rest/hawkbit-rest-docs/src/main/asciidoc/targettypes-api-guide.adoc delete mode 100644 hawkbit-rest/hawkbit-rest-docs/src/main/asciidoc/tenant-api-guide.adoc delete mode 100644 hawkbit-rest/hawkbit-rest-docs/src/main/errors/400.adoc delete mode 100644 hawkbit-rest/hawkbit-rest-docs/src/main/errors/400_multiassignment.adoc delete mode 100644 hawkbit-rest/hawkbit-rest-docs/src/main/errors/401.adoc delete mode 100644 hawkbit-rest/hawkbit-rest-docs/src/main/errors/403.adoc delete mode 100644 hawkbit-rest/hawkbit-rest-docs/src/main/errors/403_quota.adoc delete mode 100644 hawkbit-rest/hawkbit-rest-docs/src/main/errors/404.adoc delete mode 100644 hawkbit-rest/hawkbit-rest-docs/src/main/errors/404_target_action.adoc delete mode 100644 hawkbit-rest/hawkbit-rest-docs/src/main/errors/405.adoc delete mode 100644 hawkbit-rest/hawkbit-rest-docs/src/main/errors/406.adoc delete mode 100644 hawkbit-rest/hawkbit-rest-docs/src/main/errors/409.adoc delete mode 100644 hawkbit-rest/hawkbit-rest-docs/src/main/errors/410.adoc delete mode 100644 hawkbit-rest/hawkbit-rest-docs/src/main/errors/415.adoc delete mode 100644 hawkbit-rest/hawkbit-rest-docs/src/main/errors/429.adoc delete mode 100644 hawkbit-rest/hawkbit-rest-docs/src/main/errors/error-response-body.adoc delete mode 100644 hawkbit-rest/hawkbit-rest-docs/src/main/template/template.adoc delete mode 100644 hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/ddi/documentation/DdiApiModelProperties.java delete mode 100644 hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/ddi/documentation/RootControllerDocumentationTest.java delete mode 100644 hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/documentation/AbstractApiRestDocumentation.java delete mode 100644 hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/documentation/ApiModelPropertiesGeneric.java delete mode 100644 hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/documentation/DocumenationResponseFieldsSnippet.java delete mode 100644 hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/documentation/MgmtApiModelProperties.java delete mode 100644 hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/mgmt/documentation/ActionResourceDocumentationTest.java delete mode 100644 hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/mgmt/documentation/DistributionSetTagResourceDocumentationTest.java delete mode 100644 hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/mgmt/documentation/DistributionSetTypesDocumentationTest.java delete mode 100644 hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/mgmt/documentation/DistributionSetsDocumentationTest.java delete mode 100644 hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/mgmt/documentation/RolloutResourceDocumentationTest.java delete mode 100644 hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/mgmt/documentation/SoftwaremoduleTypesDocumentationTest.java delete mode 100644 hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/mgmt/documentation/SoftwaremodulesDocumentationTest.java delete mode 100644 hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/mgmt/documentation/TargetFilterQueriesResourceDocumentationTest.java delete mode 100644 hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/mgmt/documentation/TargetResourceDocumentationTest.java delete mode 100644 hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/mgmt/documentation/TargetTagResourceDocumentationTest.java delete mode 100644 hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/mgmt/documentation/TargetTypesDocumentationTest.java delete mode 100644 hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/mgmt/documentation/TenantResourceDocumentationTest.java delete mode 100644 hawkbit-rest/hawkbit-rest-docs/src/test/resources/org/springframework/restdocs/templates/path-parameters.snippet delete mode 100644 hawkbit-rest/hawkbit-rest-docs/src/test/resources/org/springframework/restdocs/templates/request-fields.snippet delete mode 100644 hawkbit-rest/hawkbit-rest-docs/src/test/resources/org/springframework/restdocs/templates/response-fields.snippet delete mode 100644 hawkbit-rest/hawkbit-rest-docs/src/test/resources/updateserver-restdocumentation-test.properties diff --git a/hawkbit-rest/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtActionResourceTest.java b/hawkbit-rest/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtActionResourceTest.java index dcfcd60d40..a8629328bf 100644 --- a/hawkbit-rest/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtActionResourceTest.java +++ b/hawkbit-rest/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtActionResourceTest.java @@ -342,6 +342,28 @@ void getActionsWithEmptyResult() throws Exception { .andExpect(jsonPath("content", hasSize(0))).andExpect(jsonPath("total", equalTo(0))); } + @Test + @Description("Handles the GET request of retrieving a specific action.") + public void getAction() throws Exception { + final String knownTargetId = "targetId"; + // prepare ds + final DistributionSet ds = testdataFactory.createDistributionSet(); + // rollout + final Target target = testdataFactory.createTarget(knownTargetId); + final Rollout rollout = testdataFactory.createRolloutByVariables("TestRollout", "TestDesc", 1, + "name==" + target.getName(), ds, "50", "5"); + rolloutManagement.start(rollout.getId()); + rolloutHandler.handleAll(); + + final List actions = deploymentManagement.findActionsByTarget(target.getControllerId(), PAGE) + .getContent(); + assertThat(actions).hasSize(1); + + mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING + "/{actionId}", actions.get(0).getId())) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()); + } + @Test @Description("Verifies paging is respected as expected.") void getMultipleActionsWithPagingLimitRequestParameter() throws Exception { @@ -484,5 +506,4 @@ private static String generateDistributionSetLink(final Action action) { return "http://localhost" + MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + action.getDistributionSet().getId(); } - } diff --git a/hawkbit-rest/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetResourceTest.java b/hawkbit-rest/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetResourceTest.java index 5638d6d5f4..bac4cbdcf8 100644 --- a/hawkbit-rest/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetResourceTest.java +++ b/hawkbit-rest/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetResourceTest.java @@ -65,6 +65,7 @@ import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; import org.springframework.data.domain.PageRequest; +import org.springframework.hateoas.MediaTypes; import org.springframework.http.MediaType; import org.springframework.test.web.servlet.MvcResult; @@ -84,8 +85,8 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTest { @Test - @Description("This test verifies the call of all Software Modules that are assiged to a Distribution Set through the RESTful API.") - public void getSoftwaremodules() throws Exception { + @Description("This test verifies the call of all Software Modules that are assigned to a Distribution Set through the RESTful API.") + public void getSoftwareModules() throws Exception { // Create DistributionSet with three software modules final DistributionSet set = testdataFactory.createDistributionSet("SMTest"); mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + set.getId() + "/assignedSM")) @@ -93,6 +94,18 @@ public void getSoftwaremodules() throws Exception { .andExpect(jsonPath("$.size", equalTo(set.getModules().size()))); } + @Test + @Description("Handles the GET request of retrieving assigned software modules of a single distribution set within SP with given page size and offset including sorting by version descending and filter down to all sets which name starts with 'one'.") + public void getSoftwareModulesWithParameters() throws Exception { + final DistributionSet set = testdataFactory.createUpdatedDistributionSet(); + + // post assignment + mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + set.getId() + "/assignedSM") + .param("offset", "1").param("limit", "2").param("sort", "version:DESC").param("q", "name==one*") + .accept(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON)); + } + @Test @Description("This test verifies the deletion of a assigned Software Module of a Distribution Set can not be achieved when that Distribution Set has been assigned or installed to a target.") public void deleteFailureWhenDistributionSetInUse() throws Exception { @@ -179,7 +192,7 @@ public void assignmentFailureWhenAssigningToUsedDistributionSet() throws Excepti @Test @Description("This test verifies the assignment of Software Modules to a Distribution Set through the RESTful API.") - public void assignSoftwaremoduleToDistributionSet() throws Exception { + public void assignSoftwareModuleToDistributionSet() throws Exception { // create DisSet final DistributionSet disSet = testdataFactory.createDistributionSetWithNoSoftwareModules("Jupiter", "398,88"); @@ -242,7 +255,7 @@ public void assignSoftwaremoduleToDistributionSet() throws Exception { @Test @Description("This test verifies the removal of Software Modules of a Distribution Set through the RESTful API.") - public void unassignSoftwaremoduleFromDistributionSet() throws Exception { + public void unassignSoftwareModuleFromDistributionSet() throws Exception { // Create DistributionSet with three software modules final DistributionSet set = testdataFactory.createDistributionSet("Venus"); @@ -578,12 +591,28 @@ public void getAssignedTargetsOfDistributionSet() throws Exception { testdataFactory.createTarget(knownTargetId); assignDistributionSet(createdDs.getId(), knownTargetId); - mvc.perform(get( - MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + createdDs.getId() + "/assignedTargets")) + mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + createdDs.getId() + "/assignedTargets")) .andExpect(status().isOk()).andExpect(jsonPath("$.size", equalTo(1))) .andExpect(jsonPath("$.content[0].controllerId", equalTo(knownTargetId))); } + @Test + @Description("Handles the GET request for retrieving assigned targets of a single distribution set with a defined page size and offset, sorted by name in descending order and filtered down to all targets which controllerID starts with 'target'.") + public void getAssignedTargetsOfDistributionSetWithParameters() throws Exception { + final DistributionSet set = testdataFactory.createUpdatedDistributionSet(); + + assignDistributionSet(set, testdataFactory.createTargets(5, "targetMisc", "Test targets for query")) + .getAssignedEntity(); + + mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + set.getId() + "/assignedTargets") + .param("offset", "1").param("limit", "2").param("sort", "name:DESC") + .param("q", "controllerId==target*").accept(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON)); + + } + @Test @Description("Ensures that assigned targets of DS are returned as persisted in the repository.") public void getAssignedTargetsOfDistributionSetIsEmpty() throws Exception { @@ -616,6 +645,24 @@ public void getInstalledTargetsOfDistributionSet() throws Exception { .andExpect(jsonPath("$.content[0].controllerId", equalTo(knownTargetId))); } + @Test + @Description("Handles the GET request for retrieving installed targets of a single distribution set with a defined page size and offset, sortet by name in descending order and filtered down to all targets which controllerID starts with 'target'.") + public void getInstalledTargetsOfDistributionSetWithParameters() throws Exception { + final DistributionSet set = testdataFactory.createUpdatedDistributionSet(); + + final List targets = assignDistributionSet(set, + testdataFactory.createTargets(5, "targetMisc", "Test targets for query")).getAssignedEntity().stream() + .map(Action::getTarget).collect(Collectors.toList()); + testdataFactory.sendUpdateActionStatusToTargets(targets, Status.FINISHED, "some message"); + + mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + set.getId() + "/installedTargets") + .param("offset", "1").param("limit", "2").param("sort", "name:DESC") + .param("q", "controllerId==target*").accept(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON)); + } + @Test @Description("Ensures that target filters with auto assign DS are returned as persisted in the repository.") public void getAutoAssignTargetFiltersOfDistributionSet() throws Exception { @@ -635,6 +682,22 @@ public void getAutoAssignTargetFiltersOfDistributionSet() throws Exception { .andExpect(jsonPath("$.content[0].name", equalTo(knownFilterName))); } + @Test + @Description("Handles the GET request for retrieving assigned target filter queries of a single distribution set with a defined page size and offset, sorted by name in descending order and filtered down to all targets with a name that ends with '1'.") + public void ggetAutoAssignTargetFiltersOfDistributionSetWithParameters() throws Exception { + final DistributionSet set = testdataFactory.createUpdatedDistributionSet(); + targetFilterQueryManagement.create(entityFactory.targetFilterQuery().create().name("filter1").query("name==a") + .autoAssignDistributionSet(set)); + + mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + set.getId() + "/autoAssignTargetFilters") + .param("offset", "1").param("limit", "2").param("sort", "name:DESC").param("q", "name==*1") + .accept(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON)); + + } + @Test @Description("Ensures that an error is returned when the query is invalid.") public void getAutoAssignTargetFiltersOfDSWithInvalidFilter() throws Exception { @@ -692,7 +755,7 @@ private void prepareTestFilters(final String filterNamePrefix, final Distributio @Test @Description("Ensures that DS in repository are listed with proper paging properties.") - public void getDistributionSetsWithoutAddtionalRequestParameters() throws Exception { + public void getDistributionSetsWithoutAdditionalRequestParameters() throws Exception { final int sets = 5; createDistributionSetsAlphabetical(sets); mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING)).andDo(MockMvcResultPrinter.print()) @@ -1184,8 +1247,8 @@ public void deleteMetadataThatDoesNotExistLeadsToNotFound() throws Exception { } @Test - @Description("Ensures that a metadata entry selection through API reflectes the repository content.") - public void getSingleMetadata() throws Exception { + @Description("Ensures that a metadata entry selection through API reflects the repository content.") + public void geteMetadataKey() throws Exception { // prepare and create metadata final String knownKey = "knownKey"; final String knownValue = "knownValue"; @@ -1197,9 +1260,28 @@ public void getSingleMetadata() throws Exception { .andExpect(jsonPath("key", equalTo(knownKey))).andExpect(jsonPath("value", equalTo(knownValue))); } + @Test + @Description("Get a paged list of meta data for a distribution set with standard page size.") + public void getMetadata() throws Exception { + final int totalMetadata = 4; + final String knownKeyPrefix = "knownKey"; + final String knownValuePrefix = "knownValue"; + final DistributionSet testDS = testdataFactory.createDistributionSet("one"); + for (int index = 0; index < totalMetadata; index++) { + distributionSetManagement.createMetaData(testDS.getId(), Lists + .newArrayList(entityFactory.generateDsMetadata(knownKeyPrefix + index, knownValuePrefix + index))); + } + + mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/{distributionSetId}/metadata", + testDS.getId())) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaTypes.HAL_JSON)); + } + @Test @Description("Ensures that a metadata entry paged list selection through API reflectes the repository content.") - public void getPagedListofMetadata() throws Exception { + public void getPagedListOfMetadata() throws Exception { final int totalMetadata = 10; final int limitParam = 5; @@ -1366,7 +1448,7 @@ private static Stream confirmationOptions() { @Test @Description("A request for assigning a target multiple times results in a Bad Request when multiassignment is disabled.") - public void multiassignmentRequestNotAllowedIfDisabled() throws Exception { + public void multiAssignmentRequestNotAllowedIfDisabled() throws Exception { final String targetId = testdataFactory.createTarget().getControllerId(); final Long dsId = testdataFactory.createDistributionSet().getId(); diff --git a/hawkbit-rest/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetTagResourceTest.java b/hawkbit-rest/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetTagResourceTest.java index 2d383ea298..9aed802683 100644 --- a/hawkbit-rest/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetTagResourceTest.java +++ b/hawkbit-rest/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetTagResourceTest.java @@ -75,7 +75,19 @@ public void getDistributionSetTags() throws Exception { } @Test - @Description("Verfies that a paged result list of DS tags reflects the content on the repository side when filtered by distribution set id.") + @Description("Handles the GET request of retrieving all distribution set tags based by parameter") + public void getDistributionSetTagsWithParameters() throws Exception { + final List tags = testdataFactory.createDistributionSetTags(2); + final DistributionSetTag assigned = tags.get(0); + final DistributionSetTag unassigned = tags.get(1); + mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING + + "?limit=10&sort=name:ASC&offset=0&q=name==DsTag")) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()); + } + + @Test + @Description("Verifies that a paged result list of DS tags reflects the content on the repository side when filtered by distribution set id.") public void getDistributionSetTagsByDistributionSetId() throws Exception { final List tags = testdataFactory.createDistributionSetTags(2); final DistributionSetTag tag1 = tags.get(0); diff --git a/hawkbit-rest/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetTypeResourceTest.java b/hawkbit-rest/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetTypeResourceTest.java index 54a7141288..b9302a36c2 100644 --- a/hawkbit-rest/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetTypeResourceTest.java +++ b/hawkbit-rest/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetTypeResourceTest.java @@ -432,6 +432,15 @@ public void getDistributionSetType() throws Exception { .andExpect(jsonPath("$.deleted", equalTo(testType.isDeleted()))); } + @Test + @Description("Handles the GET request of retrieving all distribution set types within SP based on parameter.") + public void getDistributionSetTypesWithParameter() throws Exception { + mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING + + "?limit=10&sort=name:ASC&offset=0&q=name==a")) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()); + } + @Test @WithUser(principal = "uploadTester", allSpPermissions = true) @Description("Checks the correct behaviour of /rest/v1/DistributionSetTypes/{ID} DELETE requests (hard delete scenario).") @@ -498,6 +507,22 @@ public void updateDistributionSetTypeColourDescriptionAndNameUntouched() throws .andExpect(jsonPath("$.name", equalTo("TestName123"))).andReturn(); } + @Test + @Description("Handles the PUT request for a single distribution set type within SP.") + public void updateDistributionSetTypeDescriptionAndColor() throws Exception { + final DistributionSetType testType = distributionSetTypeManagement.update(entityFactory.distributionSetType() + .update(testdataFactory.createDistributionSet().getType().getId()).description("Desc1234")); + final String body = new JSONObject() + .put("description", "an updated description") + .put("colour", "rgb(106,178,83)").toString(); + + mvc + .perform(put(MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING + "/{distributionSetTypeId}", + testType.getId()).content(body).contentType(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()); + + } + @Test @Description("Tests the update of the deletion flag. It is verfied that the distribution set type can't be marked as deleted through update operation.") public void updateDistributionSetTypeDeletedFlag() throws Exception { diff --git a/hawkbit-rest/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtRolloutResourceTest.java b/hawkbit-rest/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtRolloutResourceTest.java index 47a813f069..addf0f1ed0 100644 --- a/hawkbit-rest/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtRolloutResourceTest.java +++ b/hawkbit-rest/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtRolloutResourceTest.java @@ -34,6 +34,7 @@ import org.awaitility.Awaitility; import org.eclipse.hawkbit.exception.SpServerError; +import org.eclipse.hawkbit.im.authentication.SpPermission; import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants; import org.eclipse.hawkbit.repository.RolloutGroupManagement; import org.eclipse.hawkbit.repository.RolloutManagement; @@ -62,6 +63,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Sort.Direction; +import org.springframework.hateoas.MediaTypes; import org.springframework.http.MediaType; import org.springframework.test.web.servlet.ResultMatcher; @@ -379,6 +381,41 @@ void retrieveRolloutListFullRepresentationWithFilter() throws Exception { .andExpect(jsonPath("content[0]._links.self.href", startsWith(HREF_ROLLOUT_PREFIX))); } + @Test + @Description("Handles the GET request of retrieving a single rollout.") + public void getRollout() throws Exception { + enableMultiAssignments(); + approvalStrategy.setApprovalNeeded(true); + try { + approvalStrategy.setApproveDecidedBy("exampleUsername"); + + testdataFactory.createTargets(4, "rollout", "description"); + final DistributionSet dsA = testdataFactory.createDistributionSet(""); + // create a running rollout for the created targets + final Rollout rollout = rolloutManagement.create( + entityFactory + .rollout() + .create() + .name("rollout1") + .set(dsA.getId()) + .targetFilterQuery("controllerId==rollout*"), + 4, false, new RolloutGroupConditionBuilder().withDefaults() + .successCondition(RolloutGroupSuccessCondition.THRESHOLD, "100").build()); + + rolloutHandler.handleAll(); + + rolloutManagement.approveOrDeny(rollout.getId(), Rollout.ApprovalDecision.APPROVED, "Approved remark."); + + mvc.perform(get(MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING + "/{rolloutId}", rollout.getId()) + .accept(MediaTypes.HAL_JSON_VALUE)) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaTypes.HAL_JSON)); + } finally { + approvalStrategy.setApprovalNeeded(false); + } + } + @ParameterizedTest @ValueSource(booleans = { true, false }) @Description("Verify the confirmation required flag is not part of the rollout parent entity") @@ -1071,6 +1108,24 @@ void retrieveTargetsFromRolloutGroup() throws Exception { .andExpect(jsonPath("$.content", hasSize(5))).andExpect(jsonPath("$.total", equalTo(5))); } + @Test + @Description("Handles the GET request of retrieving a all targets of a specific deploy group of a rollout.") + public void getRolloutDeployGroupTargetsWithParameters() throws Exception { + testdataFactory.createTargets(4, "rollout", "description"); + final DistributionSet dsA = testdataFactory.createDistributionSet(""); + final Rollout rollout = createRollout("rollout1", 2, dsA.getId(), "controllerId==rollout*"); + final RolloutGroup firstRolloutGroup = rolloutGroupManagement + .findByRollout(PageRequest.of(0, 1), rollout.getId()).getContent().get(0); + + mvc.perform(get(MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING + "/{rolloutId}/deploygroups/{deployGroupId}/targets", + rollout.getId(), firstRolloutGroup.getId()).param("offset", "0").param("limit", "2") + .param("sort", "name:ASC").param("q", "controllerId==exampleTarget0") + .accept(MediaTypes.HAL_JSON_VALUE)) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaTypes.HAL_JSON)); + } + @Test @Description("Testing that the targets of rollout group can be retrieved with rsql query param") void retrieveTargetsFromRolloutGroupWithQuery() throws Exception { @@ -1337,6 +1392,40 @@ void weightValidation() throws Exception { assertThat(rollouts.get(0).getWeight()).get().isEqualTo(weight); } + @Test + @Description("Handles the POST request of approving a rollout.") + public void approveRollout() throws Exception { + approvalStrategy.setApprovalNeeded(true); + try { + testdataFactory.createTargets(4, "rollout", "description"); + final DistributionSet dsA = testdataFactory.createDistributionSet(""); + final Rollout rollout = createRollout("rollout1", 3, dsA.getId(), "controllerId==rollout*", false); + mvc.perform(post(MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING + "/{rolloutId}/approve", rollout.getId()) + .accept(MediaTypes.HAL_JSON_VALUE)) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()); + } finally { + approvalStrategy.setApprovalNeeded(false); + } + } + + @Test + @Description("Handles the POST request of denying a rollout. Required Permission: " + SpPermission.APPROVE_ROLLOUT) + public void denyRollout() throws Exception { + approvalStrategy.setApprovalNeeded(true); + try { + testdataFactory.createTargets(4, "rollout", "description"); + final DistributionSet dsA = testdataFactory.createDistributionSet(""); + final Rollout rollout = createRollout("rollout1", 3, dsA.getId(), "controllerId==rollout*", false); + mvc.perform(post(MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING + "/{rolloutId}/deny", rollout.getId()) + .accept(MediaTypes.HAL_JSON_VALUE)) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()); + } finally { + approvalStrategy.setApprovalNeeded(false); + } + } + @Test @Description("Check if approvalDecidedBy and approvalRemark are present when rollout is approved") public void validateIfApprovalFieldsArePresentAfterApproval() throws Exception { diff --git a/hawkbit-rest/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleResourceTest.java b/hawkbit-rest/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleResourceTest.java index ab1352fcb7..b0ab7ddd7e 100644 --- a/hawkbit-rest/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleResourceTest.java +++ b/hawkbit-rest/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleResourceTest.java @@ -690,6 +690,24 @@ void getArtifacts() throws Exception { "http://localhost/rest/v1/softwaremodules/" + sm.getId() + "/artifacts/" + artifact2.getId()))); } + @Test + @Description("Handles the GET request of retrieving all meta data of artifacts assigned to a software module (in full representation mode including a download URL by the artifact provider).") + public void getArtifactsWithParameters() throws Exception { + final SoftwareModule sm = testdataFactory.createSoftwareModuleOs(); + + final byte[] random = RandomStringUtils.random(5).getBytes(); + + artifactManagement.create(new ArtifactUpload(new ByteArrayInputStream(random), sm.getId(), "file1", false, 0)); + + mvc.perform( + get(MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING + "/{softwareModuleId}/artifacts", sm.getId()) + .param("representation", MgmtRepresentationMode.FULL.toString()) + .param("useartifacturlhandler", Boolean.TRUE.toString())) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaTypes.HAL_JSON)); + } + @ParameterizedTest @ValueSource(booleans = { true, false }) @Description("Verifies the listing of all artifacts assigned to a software module. That includes the artifact metadata and download links.") @@ -783,9 +801,43 @@ void invalidRequestsOnArtifactResource() throws Exception { artifactSoftDeleted.getId())).andDo(MockMvcResultPrinter.print()).andExpect(status().isGone()); } + @Test + @Description("Tests the deletion of an artifact including verification that the artifact is actually erased in the repository and removed from the software module.") + void deleteArtifact() throws Exception { + // Create 1 SM + final SoftwareModule sm = testdataFactory.createSoftwareModuleOs(); + + final int artifactSize = 5 * 1024; + final byte random[] = RandomStringUtils.random(artifactSize).getBytes(); + + // Create 2 artifacts + final Artifact artifact = artifactManagement.create( + new ArtifactUpload(new ByteArrayInputStream(random), sm.getId(), "file1", false, artifactSize)); + artifactManagement.create( + new ArtifactUpload(new ByteArrayInputStream(random), sm.getId(), "file2", false, artifactSize)); + + // check repo before delete + assertThat(softwareModuleManagement.findAll(PAGE)).hasSize(1); + + assertThat(softwareModuleManagement.get(sm.getId()).get().getArtifacts()).hasSize(2); + assertThat(artifactManagement.count()).isEqualTo(2); + + // delete + mvc.perform(delete("/rest/v1/softwaremodules/{smId}/artifacts/{artId}", sm.getId(), artifact.getId())) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()); + + // check that only one artifact is still alive and still assigned + assertThat(softwareModuleManagement.findAll(PAGE)).as("After the sm should be marked as deleted").hasSize(1); + assertThat(artifactManagement.count()).isEqualTo(1); + assertThat(softwareModuleManagement.get(sm.getId()).get().getArtifacts()) + .as("After delete artifact should available for marked as deleted sm's").hasSize(1); + + } + @Test @Description("Verifies that the system refuses unsupported request types and answers as defined to them, e.g. NOT FOUND on a non existing resource. Or a HTTP POST for updating a resource results in METHOD NOT ALLOWED etc.") - void invalidRequestsOnSoftwaremodulesResource() throws Exception { + void invalidRequestsOnSoftwareModulesResource() throws Exception { final SoftwareModule sm = testdataFactory.createSoftwareModuleOs(); final List modules = Arrays.asList(sm); @@ -844,7 +896,7 @@ void invalidRequestsOnSoftwaremodulesResource() throws Exception { @Test @Description("Test of modules retrieval without any parameters. Will return all modules in the system as defined by standard page size.") - void getSoftwareModulesWithoutAddtionalRequestParameters() throws Exception { + void getSoftwareModulesWithoutAdditionalRequestParameters() throws Exception { final int modules = 5; createSoftwareModulesAlphabetical(modules); mvc.perform(get(MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING)) @@ -1154,40 +1206,6 @@ void deleteAssignedSoftwareModule() throws Exception { assertThat(artifactManagement.count()).isEqualTo(1); } - @Test - @Description("Tests the deletion of an artifact including verification that the artifact is actually erased in the repository and removed from the software module.") - void deleteArtifact() throws Exception { - // Create 1 SM - final SoftwareModule sm = testdataFactory.createSoftwareModuleOs(); - - final int artifactSize = 5 * 1024; - final byte random[] = RandomStringUtils.random(artifactSize).getBytes(); - - // Create 2 artifacts - final Artifact artifact = artifactManagement.create( - new ArtifactUpload(new ByteArrayInputStream(random), sm.getId(), "file1", false, artifactSize)); - artifactManagement.create( - new ArtifactUpload(new ByteArrayInputStream(random), sm.getId(), "file2", false, artifactSize)); - - // check repo before delete - assertThat(softwareModuleManagement.findAll(PAGE)).hasSize(1); - - assertThat(softwareModuleManagement.get(sm.getId()).get().getArtifacts()).hasSize(2); - assertThat(artifactManagement.count()).isEqualTo(2); - - // delete - mvc.perform(delete("/rest/v1/softwaremodules/{smId}/artifacts/{artId}", sm.getId(), artifact.getId())) - .andDo(MockMvcResultPrinter.print()) - .andExpect(status().isOk()); - - // check that only one artifact is still alive and still assigned - assertThat(softwareModuleManagement.findAll(PAGE)).as("After the sm should be marked as deleted").hasSize(1); - assertThat(artifactManagement.count()).isEqualTo(1); - assertThat(softwareModuleManagement.get(sm.getId()).get().getArtifacts()) - .as("After delete artifact should available for marked as deleted sm's").hasSize(1); - - } - @Test @Description("Verifies the successful creation of metadata and the enforcement of the meta data quota.") void createMetadata() throws Exception { @@ -1239,9 +1257,67 @@ void createMetadata() throws Exception { } + @Test + @Description(" Get a paged list of meta data for a software module.") + public void getMetadata() throws Exception { + final int totalMetadata = 4; + final String knownKeyPrefix = "knownKey"; + final String knownValuePrefix = "knownValue"; + final SoftwareModule module = testdataFactory.createDistributionSet("one").findFirstModuleByType(osType).get(); + + for (int index = 0; index < totalMetadata; index++) { + softwareModuleManagement.createMetaData(entityFactory.softwareModuleMetadata().create(module.getId()) + .key(knownKeyPrefix + index).value(knownValuePrefix + index)); + } + + mvc.perform(get(MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING + "/{softwareModuleId}/metadata", + module.getId())).andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaTypes.HAL_JSON)); + } + + @Test + @Description(" Get a paged list of meta data for a software module with defined page size and sorting by name descending and key starting with 'known'.") + public void getMetadataWithParameters() throws Exception { + final int totalMetadata = 4; + final String knownKeyPrefix = "knownKey"; + final String knownValuePrefix = "knownValue"; + final SoftwareModule module = testdataFactory.createDistributionSet("one").findFirstModuleByType(osType).get(); + + for (int index = 0; index < totalMetadata; index++) { + softwareModuleManagement.createMetaData(entityFactory.softwareModuleMetadata().create(module.getId()) + .key(knownKeyPrefix + index).value(knownValuePrefix + index)); + } + + mvc.perform(get(MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING + "/{softwareModuleId}/metadata", + module.getId()).param("offset", "1").param("limit", "2").param("sort", "key:DESC").param("q", + "key==known*")) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaTypes.HAL_JSON)); + } + + @Test + @Description(" Get a single meta data value for a meta data key." ) + public void getMetadataValue() throws Exception { + + // prepare and create metadata + final String knownKey = "knownKey"; + final String knownValue = "knownValue"; + final SoftwareModule module = testdataFactory.createDistributionSet("one").findFirstModuleByType(osType).get(); + softwareModuleManagement.createMetaData( + entityFactory.softwareModuleMetadata().create(module.getId()).key(knownKey).value(knownValue)); + + mvc.perform( + get(MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING + "/{softwareModuleId}/metadata/{metadataKey}", + module.getId(), knownKey)) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()); + } + @Test @Description("Verifies the successful update of metadata based on given key.") - void updateMetadata() throws Exception { + void updateMetadataKey() throws Exception { // prepare and create metadata for update final String knownKey = "knownKey"; final String knownValue = "knownValue"; diff --git a/hawkbit-rest/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleTypeResourceTest.java b/hawkbit-rest/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleTypeResourceTest.java index b9ee495ec6..3781687ed9 100644 --- a/hawkbit-rest/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleTypeResourceTest.java +++ b/hawkbit-rest/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleTypeResourceTest.java @@ -95,6 +95,20 @@ public void getSoftwareModuleTypes() throws Exception { .andExpect(jsonPath("$.total", equalTo(4))); } + @Test + @WithUser(principal = "uploadTester", allSpPermissions = true) + @Description("Handles the GET request of retrieving all software module types within SP with parameters. In this case the first 10 result in ascending order by name where the name starts with 'a'.") + public void getSoftwareModuleTypesWithParameters() throws Exception { + final SoftwareModuleType testType = testdataFactory.findOrCreateSoftwareModuleType("test123"); + softwareModuleTypeManagement + .update(entityFactory.softwareModuleType().update(testType.getId()).description("Desc1234").colour("rgb(106,178,83)")); + + mvc.perform(get(MgmtRestConstants.SOFTWAREMODULETYPE_V1_REQUEST_MAPPING + "?limit=10&sort=name:ASC&offset=0&q=name==a") + .accept(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()); + } + private SoftwareModuleType createTestType() { SoftwareModuleType testType = softwareModuleTypeManagement.create(entityFactory.softwareModuleType().create() .key("test123").name("TestName123").description("Desc123").colour("colour").maxAssignments(5)); diff --git a/hawkbit-rest/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetFilterQueryResourceTest.java b/hawkbit-rest/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetFilterQueryResourceTest.java index 9d2e1b7d35..1226b1638a 100644 --- a/hawkbit-rest/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetFilterQueryResourceTest.java +++ b/hawkbit-rest/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetFilterQueryResourceTest.java @@ -39,6 +39,7 @@ import org.eclipse.hawkbit.repository.model.TargetFilterQuery; import org.eclipse.hawkbit.rest.exception.MessageNotReadableException; import org.eclipse.hawkbit.rest.json.model.ExceptionInfo; +import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter; import org.json.JSONObject; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; @@ -61,7 +62,7 @@ */ @Feature("Component Tests - Management API") @Story("Target Filter Query Resource") -public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiIntegrationTest { +public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiIntegrationTest { private static final String JSON_PATH_ROOT = "$"; @@ -95,6 +96,39 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte private static final String JSON_PATH_EXCEPTION_CLASS = JSON_PATH_ROOT + JSON_PATH_FIELD_EXCEPTION_CLASS; private static final String JSON_PATH_ERROR_CODE = JSON_PATH_ROOT + JSON_PATH_FIELD_ERROR_CODE; + @Test + @Description("Handles the GET request of retrieving all target filter queries within SP.") + public void getTargetFilterQueries() throws Exception { + final String filterName = "filter_01"; + final TargetFilterQuery filterQuery = createSingleTargetFilterQuery(filterName, "name==test_01"); + + mvc.perform(get(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING)) + .andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()); + } + + @Test + @Description("Handles the GET request of retrieving all target filter queries within SP based by parameter. Required Permission: READ_TARGET.") + public void getTargetFilterQueriesWithParameters() throws Exception { + mvc.perform(get(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "?limit=10&sort=name:ASC&offset=0&q=name==*1")) + .andExpect(status().isOk()).andDo(MockMvcResultPrinter.print()); + } + + @Test + @Description("Handles the POST request of creating a new target filter query within SP.") + public void createTargetFilterQuery() throws Exception { + final String name = "test_02"; + final String filterQuery = "name==test_02"; + final String body = new JSONObject() + .put("name", name) + .put("query", filterQuery).toString(); + + mvc.perform(post(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING) + .contentType(MediaType.APPLICATION_JSON).content(body)) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isCreated()); + } + @Test @Description("Ensures that deletion is executed if permitted.") public void deleteTargetFilterQueryReturnsOK() throws Exception { @@ -593,6 +627,53 @@ private void verifyAutoAssignmentWithSoftDeletedDs(final TargetFilterQuery tfq) .andExpect(jsonPath(JSON_PATH_ERROR_CODE, equalTo(SpServerError.SP_REPO_ENTITY_NOT_EXISTS.getKey()))); } + @Test + @Description("Handles the GET request of retrieving a the auto assign distribution set of a target filter query within SP.") + public void getAssignDS() throws Exception { + final TargetFilterQuery filterQuery = createSingleTargetFilterQuery("filter_01", "name==test_01"); + final DistributionSet ds = testdataFactory.createDistributionSet("ds"); + targetFilterQueryManagement + .updateAutoAssignDS(entityFactory.targetFilterQuery() + .updateAutoAssign(filterQuery.getId()).ds(ds.getId())); + + mvc.perform(get(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/{targetFilterQueryId}/autoAssignDS", + filterQuery.getId())) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()); + } + + @Test + @Description("Handles the POST request of setting a distribution set for auto assignment within SP.") + public void createAutoAssignDS() throws Exception { + enableMultiAssignments(); + enableConfirmationFlow(); + + final String filterName = "filter_01"; + final TargetFilterQuery filterQuery = createSingleTargetFilterQuery(filterName, "name==test_01"); + final DistributionSet distributionSet = testdataFactory.createDistributionSet("ds"); + final String autoAssignBody = new JSONObject().put("id", distributionSet.getId()) + .put("type", MgmtActionType.SOFT.getName()).put("weight", 200).toString(); + + mvc + .perform(post(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/{targetFilterQueryId}/autoAssignDS", + filterQuery.getId()).contentType(MediaType.APPLICATION_JSON).content(autoAssignBody.toString())) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()); + } + + @Test + @Description("Handles the DELETE request of deleting the auto assign distribution set from a target filter query within SP.") + public void deleteAutoAssignDS() throws Exception { + final String filterName = "filter_01"; + final TargetFilterQuery filterQuery = createSingleTargetFilterQuery(filterName, "name==test_01"); + mvc + .perform(delete( + MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/{targetFilterQueryId}/autoAssignDS", + filterQuery.getId())) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isNoContent()); + } + @Test @Description("Ensures that the deletion of auto-assignment distribution set works as intended, deleting the auto-assignment action type as well") public void deleteAutoAssignDistributionSetOfTargetFilterQuery() throws Exception { @@ -658,5 +739,4 @@ public void weightValidation() throws Exception { private TargetFilterQuery createSingleTargetFilterQuery(final String name, final String query) { return targetFilterQueryManagement.create(entityFactory.targetFilterQuery().create().name(name).query(query)); } - } diff --git a/hawkbit-rest/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetResourceTest.java b/hawkbit-rest/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetResourceTest.java index be2835523b..bf88de0b36 100644 --- a/hawkbit-rest/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetResourceTest.java +++ b/hawkbit-rest/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetResourceTest.java @@ -10,7 +10,7 @@ package org.eclipse.hawkbit.mgmt.rest.resource; import static org.assertj.core.api.Assertions.assertThat; -import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.TARGET_V1_AUTO_CONFIRM; +import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.*; import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.not; @@ -43,11 +43,14 @@ import javax.validation.ConstraintViolationException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.google.common.collect.Lists; import org.apache.commons.lang3.RandomStringUtils; import org.awaitility.Awaitility; import org.eclipse.hawkbit.exception.SpServerError; import org.eclipse.hawkbit.im.authentication.SpPermission; import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtActionType; +import org.eclipse.hawkbit.mgmt.json.model.target.MgmtTargetAutoConfirmUpdate; import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants; import org.eclipse.hawkbit.repository.ActionFields; import org.eclipse.hawkbit.repository.Identifiable; @@ -134,6 +137,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { private static final String JSON_PATH_LAST_REQUEST_AT = JSON_PATH_ROOT + JSON_PATH_FIELD_LAST_REQUEST_AT; private static final String JSON_PATH_TYPE = JSON_PATH_ROOT + JSON_PATH_FIELD_TARGET_TYPE; + @Autowired + private ObjectMapper objectMapper; @Autowired private JpaProperties jpaProperties; @@ -1081,8 +1086,8 @@ void getCancelActionWithMaintenanceWindow() throws Exception { } @Test - @Description("Ensures that the expected response of geting actions of a target is returned.") - void getMultipleActions() throws Exception { + @Description("Ensures that the expected response of getting actions of a target is returned.") + void getActions() throws Exception { final String knownTargetId = "targetId"; final List actions = generateTargetWithTwoUpdatesWithOneOverride(knownTargetId); @@ -1106,7 +1111,7 @@ void getMultipleActions() throws Exception { @Test @Description("Ensures that the expected response of getting actions with maintenance window of a target is returned.") - void getMultipleActionsWithMaintenanceWindow() throws Exception { + void getActionsWithMaintenanceWindow() throws Exception { final String knownTargetId = "targetId"; final String schedule = getTestSchedule(10); final String duration = getTestDuration(10); @@ -1144,7 +1149,7 @@ void getMultipleActionsWithMaintenanceWindow() throws Exception { @Test @Description("Verifies that the API returns the status list with expected content.") - void getMultipleActionStatus() throws Exception { + void getActionsStatus() throws Exception { final String knownTargetId = "targetId"; final Action action = generateTargetWithTwoUpdatesWithOneOverride(knownTargetId).get(0); // retrieve list in default descending order for actionstaus entries @@ -1172,7 +1177,7 @@ void getMultipleActionStatus() throws Exception { @Test @Description("Verifies that the API returns the status list with expected content sorted by reportedAt field.") - void getMultipleActionStatusSortedByReportedAt() throws Exception { + void getActionsStatusSortedByReportedAt() throws Exception { final String knownTargetId = "targetId"; final Action action = generateTargetWithTwoUpdatesWithOneOverride(knownTargetId).get(0); final List actionStatus = deploymentManagement.findActionStatusByAction(PAGE, action.getId()) @@ -1218,7 +1223,7 @@ void getMultipleActionStatusSortedByReportedAt() throws Exception { @Test @Description("Verifies that the API returns the status list with expected content split into two pages.") - void getMultipleActionStatusWithPagingLimitRequestParameter() throws Exception { + void getActionsStatusWithPagingLimitRequestParameter() throws Exception { final String knownTargetId = "targetId"; final Action action = generateTargetWithTwoUpdatesWithOneOverride(knownTargetId).get(0); @@ -1258,7 +1263,7 @@ void getMultipleActionStatusWithPagingLimitRequestParameter() throws Exception { @Test @Description("Verifies getting multiple actions with the paging request parameter.") - void getMultipleActionsWithPagingLimitRequestParameter() throws Exception { + void getActionsWithPagingLimitRequestParameter() throws Exception { final String knownTargetId = "targetId"; final List actions = generateTargetWithTwoUpdatesWithOneOverride(knownTargetId); @@ -1708,7 +1713,7 @@ void invalidRequestsOnActionStatusResource() throws Exception { } @Test - void getControllerAttributesViaTargetResourceReturnsAttributesWithOk() throws Exception { + void getControllerAttributesReturnsAttributesWithOk() throws Exception { // create target with attributes final String knownTargetId = "targetIdWithAttributes"; final Map knownControllerAttrs = new HashMap<>(); @@ -1784,6 +1789,21 @@ private void verifyResettingRequestAttributesIsNotAllowed(final String knownTarg assertThat(targetManagement.isControllerAttributesRequested(knownTargetId)).isTrue(); } + @Test + @Description("Handles the GET request of retrieving all targets within SP..") + public void getTargets() throws Exception { + enableConfirmationFlow(); + mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING)).andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()); + } + + @Test + @Description("Handles the GET request of retrieving all targets within SP based by parameter.") + public void getTargetsWithParameters() throws Exception { + mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "?limit=10&sort=name:ASC&offset=0&q=name==a")) + .andExpect(status().isOk()).andDo(MockMvcResultPrinter.print()); + } + @Test void searchTargetsUsingRsqlQuery() throws Exception { final int amountTargets = 10; @@ -1964,8 +1984,8 @@ void deleteMetadataThatDoesNotExistLeadsToNotFound() throws Exception { } @Test - @Description("Ensures that a metadata entry selection through API reflectes the repository content.") - void getSingleMetadata() throws Exception { + @Description("Ensures that a metadata entry selection through API reflects the repository content.") + void getMetadataKey() throws Exception { final String knownControllerId = "targetIdWithMetadata"; // prepare and create metadata for deletion @@ -1979,6 +1999,24 @@ void getSingleMetadata() throws Exception { .andExpect(jsonPath("key", equalTo(knownKey))).andExpect(jsonPath("value", equalTo(knownValue))); } + @Test + @Description("Get a paged list of meta data for a target with standard page size.") + public void getMetadata() throws Exception { + final int totalMetadata = 4; + final String knownKeyPrefix = "knownKey"; + final String knownValuePrefix = "knownValue"; + final Target testTarget = testdataFactory.createTarget("targetId"); + for (int index = 0; index < totalMetadata; index++) { + targetManagement.createMetaData(testTarget.getControllerId(), Lists.newArrayList( + entityFactory.generateTargetMetadata(knownKeyPrefix + index, knownValuePrefix + index))); + } + + mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/metadata", testTarget.getControllerId())) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaTypes.HAL_JSON)); + } + @Test @Description("Ensures that a metadata entry paged list selection through API reflectes the repository content.") void getPagedListOfMetadata() throws Exception { @@ -2526,6 +2564,33 @@ void autoConfirmStateReferenceOnTarget() throws Exception { .andExpect(jsonPath("autoConfirmActive").exists()).andExpect(jsonPath("_links.autoConfirm").exists()); } + @Test + @Description("Handles the POST request to activate auto-confirm on a target. Payload can be provided to specify more details about the operation.") + public void postActivateAutoConfirm() throws Exception { + final Target testTarget = testdataFactory.createTarget("targetId"); + + final MgmtTargetAutoConfirmUpdate body = new MgmtTargetAutoConfirmUpdate("custom_initiator_value", + "custom_remark_value"); + + mvc.perform(post(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/" + TARGET_V1_AUTO_CONFIRM + "/" + + TARGET_V1_ACTIVATE_AUTO_CONFIRM, testTarget.getControllerId()) + .content(objectMapper.writeValueAsString(body)).contentType(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()); + } + + @Test + @Description("Handles the POST request to deactivate auto-confirm on a target.") + public void postDeactivateAutoConfirm() throws Exception { + final Target testTarget = testdataFactory.createTarget("targetId"); + confirmationManagement.activateAutoConfirmation(testTarget.getControllerId(), null, null); + + mvc.perform(post(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/" + TARGET_V1_AUTO_CONFIRM + "/" + + TARGET_V1_DEACTIVATE_AUTO_CONFIRM, testTarget.getControllerId())) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()); + } + @Test @Description("Verifies that the status code that was reported in the last action status update is correctly exposed via the action.") void lastActionStatusCode() throws Exception { diff --git a/hawkbit-rest/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetTagResourceTest.java b/hawkbit-rest/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetTagResourceTest.java index 70b4bc0f4e..e9b275c0ea 100644 --- a/hawkbit-rest/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetTagResourceTest.java +++ b/hawkbit-rest/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetTagResourceTest.java @@ -77,7 +77,17 @@ public void getTargetTags() throws Exception { } @Test - @Description("Verfies that a paged result list of target tags reflects on the content of assigned tags for specific controller/target ID") + @Description("Handles the GET request of retrieving all targets tags within SP based by parameter") + public void getTargetTagsWithParameters() throws Exception { + final List tags = testdataFactory.createTargetTags(2, ""); + final TargetTag assigned = tags.get(0); + final TargetTag unassigned = tags.get(1); + mvc.perform(get(MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING + "?limit=10&sort=name:ASC&offset=0&q=name==targetTag")) + .andExpect(status().isOk()).andDo(MockMvcResultPrinter.print()); + } + + @Test + @Description("Verifies that a paged result list of target tags reflects on the content of assigned tags for specific controller/target ID") public void getTargetTagsByTargetId() throws Exception { final String controllerId1 = "controllerTestId1"; final String controllerId2 = "controllerTestId2"; diff --git a/hawkbit-rest/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetTypeResourceTest.java b/hawkbit-rest/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetTypeResourceTest.java index ff72ed3f21..b6740b30d7 100644 --- a/hawkbit-rest/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetTypeResourceTest.java +++ b/hawkbit-rest/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetTypeResourceTest.java @@ -24,7 +24,6 @@ import org.eclipse.hawkbit.exception.SpServerError; import org.eclipse.hawkbit.im.authentication.SpPermission; import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants; -import org.eclipse.hawkbit.repository.builder.DistributionSetTypeCreate; import org.eclipse.hawkbit.repository.builder.TargetTypeCreate; import org.eclipse.hawkbit.repository.exception.AssignmentQuotaExceededException; import org.eclipse.hawkbit.repository.model.DistributionSetType; diff --git a/hawkbit-rest/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTenantManagementResourceTest.java b/hawkbit-rest/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTenantManagementResourceTest.java index dd945bcf03..c691540a8a 100644 --- a/hawkbit-rest/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTenantManagementResourceTest.java +++ b/hawkbit-rest/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTenantManagementResourceTest.java @@ -9,11 +9,16 @@ */ package org.eclipse.hawkbit.mgmt.rest.resource; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.put; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.eclipse.hawkbit.mgmt.json.model.system.MgmtSystemTenantConfigurationValueRequest; import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants; import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter; +import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationProperties; import org.json.JSONObject; import org.junit.jupiter.api.Test; import org.springframework.http.MediaType; @@ -39,8 +44,37 @@ public class MgmtTenantManagementResourceTest extends AbstractManagementApiInteg private static final String AUTHENTICATION_GATEWAYTOKEN_KEY = "authentication.gatewaytoken.key"; + @Test + @Description("Handles GET request for receiving all tenant specific configurations.") + public void getTenantConfigurations() throws Exception { + mvc.perform(get(MgmtRestConstants.SYSTEM_V1_REQUEST_MAPPING + "/configs/")) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()); + } + @Test + @Description("Handles GET request for receiving a tenant specific configuration.") + public void getTenantConfiguration() throws Exception { + mvc.perform(get(MgmtRestConstants.SYSTEM_V1_REQUEST_MAPPING + "/configs/{keyName}/", + TenantConfigurationProperties.TenantConfigurationKey.AUTHENTICATION_MODE_GATEWAY_SECURITY_TOKEN_KEY)) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()); + } + @Test + @Description("Handles PUT request for settings values in tenant specific configuration.") + public void putTenantConfiguration() throws Exception { + final MgmtSystemTenantConfigurationValueRequest bodyPut = new MgmtSystemTenantConfigurationValueRequest(); + bodyPut.setValue("exampleToken"); + final ObjectMapper mapper = new ObjectMapper(); + final String json = mapper.writeValueAsString(bodyPut); + + mvc.perform(put(MgmtRestConstants.SYSTEM_V1_REQUEST_MAPPING + "/configs/{keyName}/", + TenantConfigurationProperties.TenantConfigurationKey.AUTHENTICATION_MODE_GATEWAY_SECURITY_TOKEN_KEY).content(json) + .contentType(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()); + } @Test @Description("The 'multi.assignments.enabled' property must not be changed to false.") @@ -109,4 +143,12 @@ public void autoCloseCannotBeModifiedIfMultiAssignmentIsEnabled() throws Excepti .andExpect(status().isForbidden()); } + @Test + @Description("Handles DELETE request deleting a tenant specific configuration.") + public void deleteTenantConfiguration() throws Exception { + mvc.perform(delete(MgmtRestConstants.SYSTEM_V1_REQUEST_MAPPING + "/configs/{keyName}/", + TenantConfigurationProperties.TenantConfigurationKey.AUTHENTICATION_MODE_GATEWAY_SECURITY_TOKEN_KEY)) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()); + } } diff --git a/hawkbit-rest/hawkbit-rest-docs/README.md b/hawkbit-rest/hawkbit-rest-docs/README.md deleted file mode 100644 index 1a9f74b280..0000000000 --- a/hawkbit-rest/hawkbit-rest-docs/README.md +++ /dev/null @@ -1,17 +0,0 @@ -# hawkBit Rest Documentation tests - -The hawkBit Rest Documentation tests are based on [Rest Docs](https://projects.spring.io/spring-restdocs/). These tests generate documentation for our RESTful services. - -## Run and create snippets - -Run the test with maven - -```bash -mvn clean package -``` - -Every rest test will create snippets (e.g. curl-request.adoc, http-request.adoc) in the target\generated-snippets\ directory. - -## Use the snippets - -The snippets get included using Asciidoc within our API documents in src\main\asciidoc. Those documents in turn are used to generate HTML documents in the target\classes directory when building with maven. diff --git a/hawkbit-rest/hawkbit-rest-docs/pom.xml b/hawkbit-rest/hawkbit-rest-docs/pom.xml deleted file mode 100644 index 01ea1c229b..0000000000 --- a/hawkbit-rest/hawkbit-rest-docs/pom.xml +++ /dev/null @@ -1,146 +0,0 @@ - - - 4.0.0 - - org.eclipse.hawkbit - hawkbit-rest-parent - 0.3.0-SNAPSHOT - - hawkbit-rest-docs - hawkbit :: REST :: Documentation - - - ${maven.build.timestamp} - - - - - - org.eclipse.hawkbit - hawkbit-repository-api - ${project.version} - test - - - org.eclipse.hawkbit - hawkbit-repository-jpa - ${project.version} - test - - - org.springframework.restdocs - spring-restdocs-mockmvc - test - - - org.springframework.security - spring-security-config - test - - - org.eclipse.hawkbit - hawkbit-rest-core - ${project.version} - tests - test - - - org.eclipse.hawkbit - hawkbit-ddi-resource - ${project.version} - test - - - org.eclipse.hawkbit - hawkbit-mgmt-resource - ${project.version} - test - - - org.eclipse.hawkbit - hawkbit-repository-test - ${project.version} - test - - - org.eclipse.hawkbit - hawkbit-http-security - ${project.version} - test - - - org.springframework.boot - spring-boot-starter-json - test - - - org.springframework.boot - spring-boot-starter-test - test - - - org.springframework.security - spring-security-aspects - test - - - io.qameta.allure - allure-junit5 - test - - - org.springframework - spring-context-support - test - - - - - - org.asciidoctor - asciidoctor-maven-plugin - 1.5.8 - - - generate-docs - prepare-package - - process-asciidoc - - - html - book - - ${project.build.directory}/generated-snippets - - ${project.build.directory}/classes/rest-api - - - - - - org.apache.maven.plugins - maven-jar-plugin - - - - test-jar - - - - - - - diff --git a/hawkbit-rest/hawkbit-rest-docs/src/main/asciidoc/actions-api-guide.adoc b/hawkbit-rest/hawkbit-rest-docs/src/main/asciidoc/actions-api-guide.adoc deleted file mode 100644 index 1c19c5a5cb..0000000000 --- a/hawkbit-rest/hawkbit-rest-docs/src/main/asciidoc/actions-api-guide.adoc +++ /dev/null @@ -1,111 +0,0 @@ -:doctype: book -:icons: font -:source-highlighter: highlightjs -:toc: macro -:toclevels: 1 -:sectlinks: -:linkattrs: - -[[actions]] -= Actions - -toc::[] - -== GET /rest/v1/actions - -=== Implementation notes - -Handles the GET request of retrieving all actions within Hawkbit. Required permission: READ_TARGET - -=== Get paged list of actions - -==== CURL - -include::{snippets}/actions/get-actions/curl-request.adoc[] - -==== Request URL - -A `GET` request is used to access the actions - -include::{snippets}/actions/get-actions/http-request.adoc[] - -==== Request query parameter - -include::{snippets}/actions/get-actions-with-parameters/request-parameters.adoc[] - -==== Request parameter example - -include::{snippets}/actions/get-actions-with-parameters/http-request.adoc[] - -=== Response (Status 200) - -==== Response fields - -include::{snippets}/actions/get-actions/response-fields.adoc[] - -==== Response example - -include::{snippets}/actions/get-actions/http-response.adoc[] - -==== Response example for representation mode 'full' - -include::{snippets}/actions/get-actions-with-parameters/http-response.adoc[] - - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/429.adoc[] -|=== - -== GET /rest/v1/actions/{actionId} - -=== Implementation notes - -Handles the GET request of retrieving a single action within Hawkbit by actionId. - -=== Get single action - -==== CURL - -include::{snippets}/actions/get-action/curl-request.adoc[] - -==== Request URL - -A `GET` request is used to access a single action - -include::{snippets}/actions/get-action/http-request.adoc[] - -=== Response (Status 200) - -==== Response fields - -include::{snippets}/actions/get-action/response-fields.adoc[] - -==== Response example - -include::{snippets}/actions/get-action/http-response.adoc[] - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/404.adoc[] -include::../errors/406.adoc[] -include::../errors/429.adoc[] -|=== - -== Additional content - -[[error-body]] -=== Error body - -include::../errors/error-response-body.adoc[] diff --git a/hawkbit-rest/hawkbit-rest-docs/src/main/asciidoc/distributionsets-api-guide.adoc b/hawkbit-rest/hawkbit-rest-docs/src/main/asciidoc/distributionsets-api-guide.adoc deleted file mode 100644 index b0c39c6da6..0000000000 --- a/hawkbit-rest/hawkbit-rest-docs/src/main/asciidoc/distributionsets-api-guide.adoc +++ /dev/null @@ -1,892 +0,0 @@ -:doctype: book -:icons: font -:source-highlighter: highlightjs -:toc: macro -:toclevels: 1 -:sectlinks: -:linkattrs: - -[[distributionsets]] -= Distributionsets - -toc::[] - -== GET /rest/v1/distributionsets - -=== Implementation notes - -Handles the GET request of retrieving all distribution sets within Hawkbit. Required permission: READ_REPOSITORY - -=== Get paged list of Distribution Sets - -==== Curl - -include::{snippets}/distributionsets/get-distribution-sets/curl-request.adoc[] - -==== Request URL - -include::{snippets}/distributionsets/get-distribution-sets/http-request.adoc[] - -==== Request query parameter - -include::{snippets}/distributionsets/get-distribution-sets-with-parameters/request-parameters.adoc[] - -==== Request query parameter example - -include::{snippets}/distributionsets/get-distribution-sets-with-parameters/http-request.adoc[] - -=== Response (Status 200) - -==== Response fields - -include::{snippets}/distributionsets/get-distribution-sets/response-fields.adoc[] - -==== Response example - -include::{snippets}/distributionsets/get-distribution-sets/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/429.adoc[] -|=== - - -== POST /rest/v1/distributionsets - -=== Implementation Notes -Handles the POST request of creating new distribution sets within Hawkbit. The request body must always be a list of sets. Required permission: CREATE_REPOSITORY - -=== Create Distribution Sets - - -==== CURL - -include::{snippets}/distributionsets/create-distribution-sets/curl-request.adoc[] - - -==== Request URL - -include::{snippets}/distributionsets/create-distribution-sets/http-request.adoc[] - -==== Request fields - -include::{snippets}/distributionsets/create-distribution-sets/request-fields.adoc[] - -=== Response (Status 200) - -==== Response fields - -include::{snippets}/distributionsets/create-distribution-sets/response-fields.adoc[] - -==== Response example - -include::{snippets}/distributionsets/create-distribution-sets/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/409.adoc[] -include::../errors/415.adoc[] -include::../errors/429.adoc[] -|=== - - -== DELETE /rest/v1/distributionsets/{distributionSetId} - - -=== Implementation Notes - -Handles the DELETE request for a single Distribution Set within Hawkbit. Required permission: DELETE_REPOSITORY - -=== Delete Distribution Set - -==== CURL - -include::{snippets}/distributionsets/delete-distribution-set/curl-request.adoc[] - -==== Request URL - -include::{snippets}/distributionsets/delete-distribution-set/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/distributionsets/delete-distribution-set/path-parameters.adoc[] - -=== Response (Status 200) - -==== Response example - -include::{snippets}/distributionsets/delete-distribution-set/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/404.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/429.adoc[] -|=== - -== GET /rest/v1/distributionsets/{distributionSetId} - -=== Implementation Notes - -Handles the GET request of retrieving a single distribution set within Hawkbit. Required permission: READ_REPOSITORY - -=== Get Distribution Set - -==== CURL - -include::{snippets}/distributionsets/get-distribution-set/curl-request.adoc[] - -==== Request URL - -include::{snippets}/distributionsets/get-distribution-set/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/distributionsets/get-distribution-set/path-parameters.adoc[] - -=== Response (Status 200) - -==== Response fields - -include::{snippets}/distributionsets/get-distribution-set/response-fields.adoc[] - -==== Response example - -include::{snippets}/distributionsets/get-distribution-set/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/404.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/429.adoc[] -|=== - - -== PUT /rest/v1/distributionsets/{distributionSetId} - -=== Implementation Notes - -Handles the UPDATE request for a single Distribution Set within Hawkbit. Required permission: UPDATE_REPOSITORY - -=== Updating a Distribution Set - -==== Curl - -include::{snippets}/distributionsets/update-distribution-set/curl-request.adoc[] - -==== Request URL - -include::{snippets}/distributionsets/update-distribution-set/http-request.adoc[] - - -==== Request path parameter - -include::{snippets}/distributionsets/update-distribution-set/path-parameters.adoc[] - -==== Request fields - -include::{snippets}/distributionsets/update-distribution-set/request-fields.adoc[] - -=== Response (Status 200) - -==== Response fields - -include::{snippets}/distributionsets/update-distribution-set/response-fields.adoc[] - -==== Response example - -include::{snippets}/distributionsets/update-distribution-set/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/404.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/409.adoc[] -include::../errors/415.adoc[] -include::../errors/429.adoc[] -|=== - -== GET /rest/v1/distributionsets/{distributionSetId}/assignedSM - -=== Implementation Notes -Handles the GET request of retrieving a single distribution set within Hawkbit. Required permission: READ_REPOSITORY - -=== Get assigned Software Modules - -==== Curl - -include::{snippets}/distributionsets/get-assigned-software-modules/curl-request.adoc[] - -==== Request URL - -include::{snippets}/distributionsets/get-assigned-software-modules/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/distributionsets/get-assigned-software-modules/path-parameters.adoc[] - -==== Request query parameter - -include::{snippets}/distributionsets/get-assigned-software-modules-with-parameters/request-parameters.adoc[] - -==== Request parameter example - -include::{snippets}/distributionsets/get-assigned-software-modules-with-parameters/http-request.adoc[] - -=== Response (Status 200) - -==== Response fields - -include::{snippets}/distributionsets/get-assigned-software-modules/response-fields.adoc[] - -==== Response example - -include::{snippets}/distributionsets/get-assigned-software-modules/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/429.adoc[] -|=== - - -== POST /rest/v1/distributionsets/{distributionSetId}/assignedSM - -=== Implementation Notes - -Handles the POST request for assigning multiple software modules to a distribution set.The request body must always be a list of software module IDs. Required permissions: READ_REPOSITORY and UPDATE_REPOSITORY - -=== Assign Software Modules to Distribution Set - - -==== CURL - -include::{snippets}/distributionsets/assign-software-modules/curl-request.adoc[] - -==== Request URL - -include::{snippets}/distributionsets/assign-software-modules/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/distributionsets/assign-software-modules/path-parameters.adoc[] - -==== Request fields - -include::{snippets}/distributionsets/assign-software-modules/request-fields.adoc[] - -=== Response (Status 200) - -==== Response example - -include::{snippets}/distributionsets/assign-software-modules/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/404.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/409.adoc[] -include::../errors/415.adoc[] -include::../errors/429.adoc[] -|=== - -== DELETE /rest/v1/distributionsets/{distributionSetId}/assignedSM/{softwareModuleId} - - -=== Implementation Notes - -Delete a assignment. Required permission: UPDATE_REPOSITORY - -=== Delete assignment of Software Module - -==== CURL - -include::{snippets}/distributionsets/delete-assign-software-modules/curl-request.adoc[] - -==== Request URL - -include::{snippets}/distributionsets/delete-assign-software-modules/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/distributionsets/delete-assign-software-modules/path-parameters.adoc[] - -=== Response (Status 200) - -==== Response example - -include::{snippets}/distributionsets/delete-assign-software-modules/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/404.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/429.adoc[] -|=== - - -== GET /rest/v1/distributionsets/{distributionSetId}/assignedTargets - - -=== Implementation Notes -Handles the GET request for retrieving assigned targets of a single distribution set. Required permissions: READ_REPOSITORY and READ_TARGET - -=== Get assigned targets - -==== Curl - -include::{snippets}/distributionsets/get-assigned-targets/curl-request.adoc[] - -==== Request URL - -include::{snippets}/distributionsets/get-assigned-targets/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/distributionsets/get-assigned-targets/path-parameters.adoc[] - -==== Request query parameter - -include::{snippets}/distributionsets/get-assigned-targets-with-parameters/request-parameters.adoc[] - -==== Request parameter example - -include::{snippets}/distributionsets/get-assigned-targets-with-parameters/http-request.adoc[] - -=== Response (Status 200) - -==== Response fields - -include::{snippets}/distributionsets/get-assigned-targets/response-fields.adoc[] - -==== Response example - -include::{snippets}/distributionsets/get-assigned-targets/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/429.adoc[] -|=== - - -== POST /rest/v1/distributionsets/{distributionSetId}/assignedTargets - - -=== Implementation Notes - -Handles the POST request for assigning multiple targets to a distribution set.The request body must always be a list of target IDs. Non-existing targets are silently ignored resulting in a valid response. Required permissions: READ_REPOSITORY and UPDATE_TARGET - -=== Assign targets to a distribution set - -==== CURL - -include::{snippets}/distributionsets/create-assigned-target/curl-request.adoc[] - -==== Request URL - -include::{snippets}/distributionsets/create-assigned-target/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/distributionsets/create-assigned-target/path-parameters.adoc[] - -==== Request query parameter - -include::{snippets}/distributionsets/create-assigned-target/request-parameters.adoc[] - -==== Request fields - -include::{snippets}/distributionsets/create-assigned-target/request-fields.adoc[] - -=== Response (Status 200) - -==== Response fields - -include::{snippets}/distributionsets/create-assigned-target/response-fields.adoc[] - -==== Response example - -include::{snippets}/distributionsets/create-assigned-target/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/409.adoc[] -include::../errors/415.adoc[] -include::../errors/429.adoc[] -|=== - -== GET /rest/v1/distributionsets/{distributionSetId}/installedTargets - -=== Implementation Notes - -Handles the GET request for retrieving installed targets of a single distribution set. Required permissions: READ_REPOSITORY and READ_TARGET - -=== Get installed targets - -==== Curl - -include::{snippets}/distributionsets/get-installed-targets/curl-request.adoc[] - -==== Request URL - -include::{snippets}/distributionsets/get-installed-targets/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/distributionsets/get-installed-targets/path-parameters.adoc[] - -==== Request query parameter - -include::{snippets}/distributionsets/get-installed-targets-with-parameters/request-parameters.adoc[] - -==== Request parameter example - -include::{snippets}/distributionsets/get-installed-targets-with-parameters/http-request.adoc[] - -=== Response (Status 200) - -==== Response fields - -include::{snippets}/distributionsets/get-installed-targets/response-fields.adoc[] - -==== Response example - -include::{snippets}/distributionsets/get-installed-targets/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/429.adoc[] -|=== - - -== GET /rest/v1/distributionsets/{distributionSetId}/autoAssignTargetFilters - -=== Implementation Notes - -Handles the GET request for retrieving assigned target filter queries of a single distribution set. Required permissions: READ_REPOSITORY and READ_TARGET - -=== Get installed targets - -==== Curl - -include::{snippets}/distributionsets/get-auto-assign-target-filter-queries/curl-request.adoc[] - -==== Request URL - -include::{snippets}/distributionsets/get-auto-assign-target-filter-queries/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/distributionsets/get-auto-assign-target-filter-queries/path-parameters.adoc[] - -==== Request query parameter - -include::{snippets}/distributionsets/get-auto-assign-target-filter-queries-with-parameters/request-parameters.adoc[] - -==== Request parameter example - -include::{snippets}/distributionsets/get-auto-assign-target-filter-queries-with-parameters/http-request.adoc[] - -=== Response (Status 200) - -==== Response fields - -include::{snippets}/distributionsets/get-auto-assign-target-filter-queries/response-fields.adoc[] - -==== Response example - -include::{snippets}/distributionsets/get-auto-assign-target-filter-queries/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/429.adoc[] -|=== - - -== GET /rest/v1/distributionsets/{distributionSetId}/metadata - -=== Implementation Notes - -Get a paged list of meta data for a distribution set. Required permission: READ_REPOSITORY - -=== Get a paged list of meta data - -==== Curl - -include::{snippets}/distributionsets/get-metadata/curl-request.adoc[] - -==== Request URL - -include::{snippets}/distributionsets/get-metadata/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/distributionsets/get-metadata/path-parameters.adoc[] - -==== Request query parameter - -include::{snippets}/distributionsets/get-metadata-with-parameters/request-parameters.adoc[] - -==== Request parameter example - -include::{snippets}/distributionsets/get-metadata-with-parameters/http-request.adoc[] - -=== Response (Status 200) - -==== Response fields - -include::{snippets}/distributionsets/get-metadata/response-fields.adoc[] - -==== Response example - -include::{snippets}/distributionsets/get-metadata/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/429.adoc[] -|=== - -== POST /rest/v1/distributionsets/{distributionSetId}/metadata - -=== Implementation Notes - -Create a list of meta data entries Required permissions: READ_REPOSITORY and UPDATE_TARGET - -=== Create a list of meta data entries - - -==== CURL - -include::{snippets}/distributionsets/create-metadata/curl-request.adoc[] - -==== Request URL - -include::{snippets}/distributionsets/create-metadata/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/distributionsets/create-metadata/path-parameters.adoc[] - -==== Request fields - -include::{snippets}/distributionsets/create-metadata/request-fields.adoc[] - -=== Response (Status 200) - -==== Response example - -include::{snippets}/distributionsets/create-metadata/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/404.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/409.adoc[] -include::../errors/415.adoc[] -include::../errors/429.adoc[] -|=== - - -== DELETE /rest/v1/distributionsets/{distributionSetId}/metadata/{metadataKey} - - -=== Implementation Notes - -Delete a single meta data. Required permission: UPDATE_REPOSITORY - -=== Delete a single meta data - -==== CURL - -include::{snippets}/distributionsets/delete-metadata/curl-request.adoc[] - -==== Request URL - -include::{snippets}/distributionsets/delete-metadata/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/distributionsets/delete-metadata/path-parameters.adoc[] - -=== Response (Status 200) - -==== Response example - -include::{snippets}/distributionsets/delete-metadata/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/404.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/429.adoc[] -|=== - - -== GET /rest/v1/distributionsets/{distributionSetId}/metadata/{metadataKey} - - -=== Implementation Notes - -Get a single meta data value for a meta data key. Required permission: READ_REPOSITORY - -=== Get a single meta data value - -==== Curl - -include::{snippets}/distributionsets/get-metadata-value/curl-request.adoc[] - -==== Request URL - -include::{snippets}/distributionsets/get-metadata-value/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/distributionsets/get-metadata-value/path-parameters.adoc[] - -=== Response (Status 200) - -==== Response fields - -include::{snippets}/distributionsets/get-metadata-value/response-fields.adoc[] - -==== Response example - -include::{snippets}/distributionsets/get-metadata-value/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/429.adoc[] -|=== - -== PUT /rest/v1/distributionsets/{distributionSetId}/metadata/{metadataKey} - - -=== Implementation Notes - -Update a single meta data value for speficic key. Required permission: UPDATE_REPOSITORY - -=== Update a single meta data value - -==== Curl - -include::{snippets}/distributionsets/update-metadata/curl-request.adoc[] - -==== Request URL - -include::{snippets}/distributionsets/update-metadata/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/distributionsets/update-metadata/path-parameters.adoc[] - -==== Request fields - -include::{snippets}/distributionsets/update-metadata/request-fields.adoc[] - -=== Response (Status 200) - -==== Response fields - -include::{snippets}/distributionsets/update-metadata/response-fields.adoc[] - -==== Response example - -include::{snippets}/distributionsets/update-metadata/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/404.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/409.adoc[] -include::../errors/415.adoc[] -include::../errors/429.adoc[] -|=== - - -== POST /rest/v1/distributionsets/{distributionSetId}/invalidate - - -=== Implementation Notes - -Invalidate a distribution set. -Once a distribution set is invalidated, it can not be valid again. -An invalidated distribution set cannot be assigned to targets anymore. -The distribution set that is going to be invalidated will be removed from all auto assignments. -Furthermore, the user can choose to cancel all rollouts and (force) cancel all actions connected to this distribution set. -Required permission: UPDATE_REPOSITORY, UPDATE_TARGET - -=== Invalidate a distribution set - -==== Curl - -include::{snippets}/distributionsets/invalidate/curl-request.adoc[] - -==== Request URL - -include::{snippets}/distributionsets/invalidate/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/distributionsets/invalidate/path-parameters.adoc[] - -==== Request fields - -include::{snippets}/distributionsets/invalidate/request-fields.adoc[] - -=== Response (Status 200) - -==== Response example - -include::{snippets}/distributionsets/invalidate/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/404.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/409.adoc[] -include::../errors/415.adoc[] -include::../errors/429.adoc[] -|=== - - -== Additional content - -[[error-body]] -=== Error body - -include::../errors/error-response-body.adoc[] - diff --git a/hawkbit-rest/hawkbit-rest-docs/src/main/asciidoc/distributionsettag-api-guide.adoc b/hawkbit-rest/hawkbit-rest-docs/src/main/asciidoc/distributionsettag-api-guide.adoc deleted file mode 100644 index 75a387900c..0000000000 --- a/hawkbit-rest/hawkbit-rest-docs/src/main/asciidoc/distributionsettag-api-guide.adoc +++ /dev/null @@ -1,438 +0,0 @@ -:doctype: book -:icons: font -:source-highlighter: highlightjs -:toc: macro -:toclevels: 1 -:sectlinks: -:linkattrs: - -[[distributionsettag]] -= Distribution set Tag - -toc::[] - - -== GET /rest/v1/distributionsettags - -=== Implementation notes - -Handles the GET request of retrieving all distribution set tags. - -=== Get paged list of distribution set tags - -==== CURL - -include::{snippets}/distributionsettag/get-distribution-set-tags/curl-request.adoc[] - -==== Request URL - -A `GET` request is used to access the distribution set tags. - -include::{snippets}/distributionsettag/get-distribution-set-tags/http-request.adoc[] - -==== Request query parameter - -include::{snippets}/distributionsettag/get-distribution-set-tags-with-parameters/request-parameters.adoc[] - -==== Request parameter example - -include::{snippets}/distributionsettag/get-distribution-set-tags-with-parameters/http-request.adoc[] - -=== Response (Status 200) - -==== Response fields - -include::{snippets}/distributionsettag/get-distribution-set-tags/response-fields.adoc[] - -==== Response example - -include::{snippets}/distributionsettag/get-distribution-set-tags/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/429.adoc[] -|=== - - -== GET /rest/v1/distributionsettags/{distributionsetTagId} - -=== Implementation notes - -Handles the GET request of retrieving a single distribution set tag. - -=== Get a single distribution set tag - -==== CURL - -include::{snippets}/distributionsettag/get-distribution-set-tag/curl-request.adoc[] - -==== Request URL - -A `GET` request is used to access the distribution set tag. - -include::{snippets}/distributionsettag/get-distribution-set-tag/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/distributionsettag/get-distribution-set-tag/path-parameters.adoc[] - -=== Response (Status 200) - -==== Response fields - -include::{snippets}/distributionsettag/get-distribution-set-tag/response-fields.adoc[] - -==== Response example - -include::{snippets}/distributionsettag/get-distribution-set-tag/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/429.adoc[] -|=== - - -== POST /rest/v1/distributionsettags - -=== Implementation Notes - -Handles the POST request of creating new distribution set tag. The request body must always be a list of distribution set tags. - -=== Create list of distribution set tags - -==== CURL - -include::{snippets}/distributionsettag/create-distribution-set-tags/curl-request.adoc[] - -==== Request URL - -include::{snippets}/distributionsettag/create-distribution-set-tags/http-request.adoc[] - -==== Request fields - -include::{snippets}/distributionsettag/create-distribution-set-tags/request-fields.adoc[] - -=== Response (Status 201) - -==== Response fields - -include::{snippets}/distributionsettag/create-distribution-set-tags/response-fields.adoc[] - -==== Response example - -include::{snippets}/distributionsettag/create-distribution-set-tags/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/409.adoc[] -include::../errors/415.adoc[] -include::../errors/429.adoc[] -|=== - - -== PUT /rest/v1/distributionsettags/{distributionsetTagId} - -=== Implementation Notes - -Handles the PUT request of updating a distribution set tag. - -=== Update a distribution set tag - -==== Curl - -include::{snippets}/distributionsettag/update-distribution-set-tag/curl-request.adoc[] - -==== Request URL - -include::{snippets}/distributionsettag/update-distribution-set-tag/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/distributionsettag/update-distribution-set-tag/path-parameters.adoc[] - -==== Request fields - -include::{snippets}/distributionsettag/update-distribution-set-tag/request-fields.adoc[] - -=== Response (Status 200) - -==== Response fields - -include::{snippets}/distributionsettag/update-distribution-set-tag/response-fields.adoc[] - -==== Response example - -include::{snippets}/distributionsettag/update-distribution-set-tag/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/404.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/409.adoc[] -include::../errors/415.adoc[] -include::../errors/429.adoc[] -|=== - - -== DELETE /rest/v1/distributionsettags/{distributionsetTagId} - -=== Implementation Notes - -Handles the DELETE request of deleting a single distribution set tag. - -=== Deleting a distribution set tag - -==== CURL - -include::{snippets}/distributionsettag/delete-distribution-set-tag/curl-request.adoc[] - -==== Request URL - -include::{snippets}/distributionsettag/delete-distribution-set-tag/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/distributionsettag/delete-distribution-set-tag/path-parameters.adoc[] - -=== Response (Status 200) - -==== Response example - -include::{snippets}/distributionsettag/delete-distribution-set-tag/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/404.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/409.adoc[] -include::../errors/415.adoc[] -include::../errors/429.adoc[] -|=== - - -== GET /rest/v1/distributionsettags/{distributionsetTagId}/assigned - -=== Implementation Notes - -Handles the GET request of retrieving a list of assigned distributions. - -=== Get a list of assigned distributions - -==== CURL - -include::{snippets}/distributionsettag/get-assigned-distribution-sets/curl-request.adoc[] - -==== Request URL - -include::{snippets}/distributionsettag/get-assigned-distribution-sets/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/distributionsettag/get-assigned-distribution-sets/path-parameters.adoc[] - -=== Response (Status 200) - -==== Response fields - -include::{snippets}/distributionsettag/get-assigned-distribution-sets/response-fields.adoc[] - -==== Response example - -include::{snippets}/distributionsettag/get-assigned-distribution-sets/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/404.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/429.adoc[] -|=== - - -== POST /rest/v1/distributionsettags/{distributionsetTagId}/assigned/toggleTagAssignment - -=== Implementation Notes - -Handles the POST request of toggle distribution assignment. -The request body must always be a list of distribution set ids. - -=== Toggle distribution assignment - -==== CURL - -include::{snippets}/distributionsettag/toggle-tag-assignment/curl-request.adoc[] - -==== Request URL - -include::{snippets}/distributionsettag/toggle-tag-assignment/http-request.adoc[] - -==== Request fields - -include::{snippets}/distributionsettag/toggle-tag-assignment/request-fields.adoc[] - -=== Response (Status 200) - -==== Response fields - -include::{snippets}/distributionsettag/toggle-tag-assignment/response-fields.adoc[] - -==== Response example - -include::{snippets}/distributionsettag/toggle-tag-assignment/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/409.adoc[] -include::../errors/415.adoc[] -include::../errors/429.adoc[] -|=== - - -== POST /rest/v1/distributionsettags/{distributionsetTagId}/assigned - -=== Implementation Notes - -Handles the POST request of distribution assignment. Already assigned distribution will be ignored. - -=== Distribution assignment - -==== CURL - -include::{snippets}/distributionsettag/assign-distribution-sets/curl-request.adoc[] - -==== Request URL - -include::{snippets}/distributionsettag/assign-distribution-sets/http-request.adoc[] - -==== Request fields - -include::{snippets}/distributionsettag/assign-distribution-sets/request-fields.adoc[] - -=== Response (Status 200) - -==== Response fields - -include::{snippets}/distributionsettag/assign-distribution-sets/response-fields.adoc[] - -==== Response example - -include::{snippets}/distributionsettag/assign-distribution-sets/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/409.adoc[] -include::../errors/415.adoc[] -include::../errors/429.adoc[] -|=== - - -== DELETE /rest/v1/distributionsettags/{distributionsetTagId}/assigned/{distributionsetId} - -=== Implementation Notes - -Handles the DELETE request of unassign the given distribution. - -=== Unassign a distribution - -==== CURL - -include::{snippets}/distributionsettag/unassign-distribution-set/curl-request.adoc[] - -==== Request URL - -include::{snippets}/distributionsettag/unassign-distribution-set/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/distributionsettag/unassign-distribution-set/path-parameters.adoc[] - -=== Response (Status 200) - -==== Response example - -include::{snippets}/distributionsettag/unassign-distribution-set/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/404.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/429.adoc[] -|=== - - -== Additional content - -[[error-body]] -=== Error body - -include::../errors/error-response-body.adoc[] - - - diff --git a/hawkbit-rest/hawkbit-rest-docs/src/main/asciidoc/distributionsettypes-api-guide.adoc b/hawkbit-rest/hawkbit-rest-docs/src/main/asciidoc/distributionsettypes-api-guide.adoc deleted file mode 100644 index 26a45f2ec3..0000000000 --- a/hawkbit-rest/hawkbit-rest-docs/src/main/asciidoc/distributionsettypes-api-guide.adoc +++ /dev/null @@ -1,636 +0,0 @@ -:doctype: book -:icons: font -:source-highlighter: highlightjs -:toc: macro -:toclevels: 1 -:sectlinks: -:linkattrs: - -[[distributionset-types]] -= Distribution Set Types - -toc::[] - -== GET /rest/v1/distributionsettypes - -=== Implementation notes - -Handles the GET request of retrieving all distribution set types within Hawkbit. Required Permission: READ_REPOSITORY - -=== Get distribution set types - -==== CURL - -include::{snippets}/distributionsettypes/get-distribution-set-types/curl-request.adoc[] - -==== Request URL - -include::{snippets}/distributionsettypes/get-distribution-set-types/http-request.adoc[] - -==== Request query parameter - -include::{snippets}/distributionsettypes/get-distribution-set-types-with-parameters/request-parameters.adoc[] - -==== Request parameter example - -include::{snippets}/distributionsettypes/get-distribution-set-types-with-parameters/http-request.adoc[] - -=== Response (Status 200) - -==== Response fields - -include::{snippets}/distributionsettypes/get-distribution-set-types/response-fields.adoc[] - -==== Response example - -include::{snippets}/distributionsettypes/get-distribution-set-types/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/429.adoc[] -|=== - - -== POST /rest/v1/distributionsettypes - -=== Implementation notes - -Handles the POST request for creating new distribution set types within Hawkbit. The request body must always be a list of types. Required Permission: CREATE_REPOSITORY - -=== Create distribution set types - -==== CURL - -include::{snippets}/distributionsettypes/post-distribution-set-types/curl-request.adoc[] - -==== Request URL - -include::{snippets}/distributionsettypes/post-distribution-set-types/http-request.adoc[] - -==== Request fields - -include::{snippets}/distributionsettypes/post-distribution-set-types/request-fields.adoc[] - -=== Response (Status 201) - -==== Response fields - -include::{snippets}/distributionsettypes/post-distribution-set-types/response-fields.adoc[] - -==== Response example - -include::{snippets}/distributionsettypes/post-distribution-set-types/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -| `404 Not Found` -| Distribution set type was not found. -| See <> -include::../errors/405.adoc[] -include::../errors/406.adoc[] -| `409 Conflict` -| Distribution set type already exists -| See <> -include::../errors/415.adoc[] -include::../errors/429.adoc[] -|=== - - -== DELETE /rest/v1/distributionsettypes/{distributionSetTypeId} - -=== Implementation Notes - -Handles the DELETE request for a single distribution set type within Hawkbit. Required Permission: DELETE_REPOSITORY - -=== Delete distribution set type - -==== CURL - -include::{snippets}/distributionsettypes/delete-distribution-set-type/curl-request.adoc[] - -==== Request URL - -include::{snippets}/distributionsettypes/delete-distribution-set-type/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/distributionsettypes/delete-distribution-set-type/path-parameters.adoc[] - -=== Response (Status 200) - -==== Response example - -include::{snippets}/distributionsettypes/delete-distribution-set-type/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -| `404 Not Found` -| Distribution set type was not found. -| See <> -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/429.adoc[] -|=== - - -== GET /rest/v1/distributionsettypes/{distributionSetTypeId} - -=== Implementation notes - -Handles the GET request of retrieving a single distribution set type within Hawkbit. Required Permission: READ_REPOSITORY - -=== Get distribution set type - -==== CURL - -include::{snippets}/distributionsettypes/get-distribution-set-type/curl-request.adoc[] - -==== Request URL - -include::{snippets}/distributionsettypes/get-distribution-set-type/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/distributionsettypes/get-distribution-set-type/path-parameters.adoc[] - -=== Response (Status 200) - -==== Response fields - -include::{snippets}/distributionsettypes/get-distribution-set-type/response-fields.adoc[] - -==== Response example - -include::{snippets}/distributionsettypes/get-distribution-set-type/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -| `404 Not Found` -| Distribution set type was not found. -| See <> -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/429.adoc[] -|=== - -== PUT /rest/v1/distributionsettypes/{distributionSetTypeId} - -=== Implementation notes - -Handles the PUT request for a single distribution set type within Hawkbit. Required Permission: UPDATE_REPOSITORY - -=== Update distribution set type - -==== CURL - -include::{snippets}/distributionsettypes/put-distribution-set-type/curl-request.adoc[] - -==== Request URL - -include::{snippets}/distributionsettypes/put-distribution-set-type/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/distributionsettypes/put-distribution-set-type/path-parameters.adoc[] - -==== Request fields - -include::{snippets}/distributionsettypes/put-distribution-set-type/request-fields.adoc[] - -=== Response (Status 200) - -==== Response fields - -include::{snippets}/distributionsettypes/put-distribution-set-type/response-fields.adoc[] - -==== Response example - -include::{snippets}/distributionsettypes/put-distribution-set-type/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -| `404 Not Found` -| Distribution set type was not found. -| See <> -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/409.adoc[] -include::../errors/415.adoc[] -include::../errors/429.adoc[] -|=== - - -== GET /rest/v1/distributionsettypes/{distributionSetTypeId}/mandatorymoduletypes - -=== Implementation notes - -Handles the GET request of retrieving the list of mandatory software module types in that distribution set type. Required Permission: READ_REPOSITORY - -=== Lists all mandatory software module types - -==== CURL - -include::{snippets}/distributionsettypes/get-mandatory-modules/curl-request.adoc[] - -==== Request URL - -include::{snippets}/distributionsettypes/get-mandatory-modules/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/distributionsettypes/get-mandatory-modules/path-parameters.adoc[] - -=== Response (Status 200) - -==== Response fields - -include::{snippets}/distributionsettypes/get-mandatory-modules/response-fields.adoc[] - -==== Response example - -include::{snippets}/distributionsettypes/get-mandatory-modules/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -| `404 Not Found` -| Distribution set type was not found. -| See <> -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/429.adoc[] -|=== - - -== POST /rest/v1/distributionsettypes/{distributionSetTypeId}/mandatorymoduletypes - -=== Implementation notes - -Handles the POST request for adding a mandatory software module type to a distribution set type.Note that a DS type cannot be changed after it has been used by a DS. Required Permission: UPDATE_REPOSITORY and READ_REPOSITORY - -=== Add mandatory software module type - -==== CURL - -include::{snippets}/distributionsettypes/post-mandatory-module/curl-request.adoc[] - -==== Request URL - -include::{snippets}/distributionsettypes/post-mandatory-module/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/distributionsettypes/post-mandatory-module/path-parameters.adoc[] - -==== Request fields - -include::{snippets}/distributionsettypes/post-mandatory-module/request-fields.adoc[] - -=== Response (Status 201) - -==== Response example - -include::{snippets}/distributionsettypes/post-mandatory-module/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -| `404 Not Found` -| Distribution set type was not found. -| See <> -include::../errors/405.adoc[] -include::../errors/406.adoc[] -| `409 Conflict` -| Distribution set type already exists -| See <> -include::../errors/415.adoc[] -include::../errors/429.adoc[] -|=== - - -== DELETE /rest/v1/distributionsettypes/{distributionSetTypeId}/mandatorymoduletypes/{softwareModuleTypeId} - -=== Implementation Notes - -Handles the DELETE request for removing a software module type from a single distribution set type within Hawkbit. Required Permission: DELETE_REPOSITORY - -Delete mandatory software module type. - -=== Remove mandatory module from distribution set type - -==== CURL - -include::{snippets}/distributionsettypes/delete-mandatory-module/curl-request.adoc[] - -==== Request URL - -include::{snippets}/distributionsettypes/delete-mandatory-module/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/distributionsettypes/delete-mandatory-module/path-parameters.adoc[] - -=== Response (Status 200) - -==== Response example - -include::{snippets}/distributionsettypes/delete-mandatory-module/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -| `404 Not Found` -| Distribution set type was not found. -| See <> -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/429.adoc[] -|=== - - -== GET /rest/v1/distributionsettypes/{distributionSetTypeId}/mandatorymoduletypes/{softwareModuleTypeId} - -=== Implementation notes - -Handles the GET request of retrieving the single mandatory software module type in that distribution set type. Required Permission: READ_REPOSITORY - -=== Retrieve mandatory software module type - -==== CURL - -include::{snippets}/distributionsettypes/get-mandatory-module/curl-request.adoc[] - -==== Request URL - -include::{snippets}/distributionsettypes/get-mandatory-module/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/distributionsettypes/get-mandatory-module/path-parameters.adoc[] - -=== Response (Status 200) - -==== Response fields - -include::{snippets}/distributionsettypes/get-mandatory-module/response-fields.adoc[] - -==== Response example - -include::{snippets}/distributionsettypes/get-mandatory-module/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -| `404 Not Found` -| Distribution set type was not found. -| See <> -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/429.adoc[] -|=== - - -== GET /rest/v1/distributionsettypes/{distributionSetTypeId}/optionalmoduletypes - -=== Implementation notes - -Handles the GET request of retrieving the list of optional software module types in that distribution set type. Required Permission: READ_REPOSITORY - -=== Lists all optional software module types - -==== CURL - -include::{snippets}/distributionsettypes/get-optional-modules/curl-request.adoc[] - -==== Request URL - -include::{snippets}/distributionsettypes/get-optional-modules/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/distributionsettypes/get-optional-modules/path-parameters.adoc[] - -=== Response (Status 200) - -==== Response fields - -include::{snippets}/distributionsettypes/get-optional-modules/response-fields.adoc[] - -==== Response example - -include::{snippets}/distributionsettypes/get-optional-modules/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -| `404 Not Found` -| Distribution set type was not found. -| See <> -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/429.adoc[] -|=== - -== POST /rest/v1/distributionsettypes/{distributionSetTypeId}/optionalmoduletypes - -=== Implementation notes - -Handles the POST request for adding an optional software module type to a distribution set type.Note that a DS type cannot be changed after it has been used by a DS. Required Permission: UPDATE_REPOSITORY and READ_REPOSITORY - -=== Add optional software module type - -==== CURL - -include::{snippets}/distributionsettypes/post-optional-module/curl-request.adoc[] - -==== Request URL - -include::{snippets}/distributionsettypes/post-optional-module/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/distributionsettypes/post-optional-module/path-parameters.adoc[] - -==== Request fields - -include::{snippets}/distributionsettypes/post-optional-module/request-fields.adoc[] - -=== Response (Status 201) - -==== Response example - -include::{snippets}/distributionsettypes/post-optional-module/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -| `404 Not Found` -| Distribution set type was not found. -| See <> -include::../errors/405.adoc[] -include::../errors/406.adoc[] -| `409 Conflict` -| Distribution set type already exists -| See <> -include::../errors/415.adoc[] -include::../errors/429.adoc[] -|=== - - -== DELETE /rest/v1/distributionsettypes/{distributionSetTypeId}/optionalmoduletypes/{softwareModuleTypeId} - -=== Implementation Notes - -Handles DELETE request for removing an optional module from the distribution set type.Note that a DS type cannot be changed after it has been used by a DS. Required Permission: UPDATE_REPOSITORY and READ_REPOSITORY - -=== Remove optional module from distribution set type - -==== CURL - -include::{snippets}/distributionsettypes/delete-optional-module/curl-request.adoc[] - -==== Request URL - -include::{snippets}/distributionsettypes/delete-optional-module/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/distributionsettypes/delete-optional-module/path-parameters.adoc[] - -=== Response (Status 200) - -==== Response example - -include::{snippets}/distributionsettypes/delete-optional-module/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -| `404 Not Found` -| Distribution set type was not found. -| See <> -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/429.adoc[] -|=== - - -== GET /rest/v1/distributionsettypes/{distributionSetTypeId}/optionalmoduletypes/{softwareModuleTypeId} - -=== Implementation notes - -Handles the GET request of retrieving the single optional software module type in that distribution set type. Required Permission: READ_REPOSITORY - -=== Retrieve optional software module type - -==== CURL - -include::{snippets}/distributionsettypes/get-optional-module/curl-request.adoc[] - -==== Request URL - -include::{snippets}/distributionsettypes/get-optional-module/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/distributionsettypes/post-optional-module/path-parameters.adoc[] - -=== Response (Status 200) - -==== Response fields - -include::{snippets}/distributionsettypes/get-optional-module/response-fields.adoc[] - -==== Response example - -include::{snippets}/distributionsettypes/get-optional-module/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -| `404 Not Found` -| Distribution set type was not found. -| See <> -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/429.adoc[] -|=== - -== Additional content - -[[error-body]] -=== Error body - -include::../errors/error-response-body.adoc[] \ No newline at end of file diff --git a/hawkbit-rest/hawkbit-rest-docs/src/main/asciidoc/rollout-api-guide.adoc b/hawkbit-rest/hawkbit-rest-docs/src/main/asciidoc/rollout-api-guide.adoc deleted file mode 100644 index ad91778d7e..0000000000 --- a/hawkbit-rest/hawkbit-rest-docs/src/main/asciidoc/rollout-api-guide.adoc +++ /dev/null @@ -1,585 +0,0 @@ -:doctype: book -:icons: font -:source-highlighter: highlightjs -:toc: macro -:toclevels: 1 -:sectlinks: -:linkattrs: - - - -[[rollouts]] -= Rollouts - -toc::[] - - -== GET /rest/v1/rollouts - -=== Implementation notes - -Handles the GET request of retrieving all rollouts within Hawkbit. Required Permission: READ_ROLLOUT - -=== Get paged list of Rollouts - -==== Curl - -include::{snippets}/rollouts/get-rollouts/curl-request.adoc[] - -==== Request URL - -include::{snippets}/rollouts/get-rollouts/http-request.adoc[] - -==== Request query parameter - -include::{snippets}/rollouts/get-rollouts-with-parameters/request-parameters.adoc[] - -==== Request query parameter example - -include::{snippets}/rollouts/get-rollouts-with-parameters/http-request.adoc[] - -=== Response (Status 200) - -==== Response fields - -include::{snippets}/rollouts/get-rollouts/response-fields.adoc[] - -==== Response example - -include::{snippets}/rollouts/get-rollouts/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/429.adoc[] -|=== - -== GET /rest/v1/rollouts/{rolloutId} - -=== Implementation Notes - -Handles the GET request of retrieving a single rollout within Hawkbit. Required Permission: READ_ROLLOUT - -=== Get Rollout - -==== CURL - -include::{snippets}/rollouts/get-rollout/curl-request.adoc[] - -==== Request URL - -include::{snippets}/rollouts/get-rollout/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/rollouts/get-rollout/path-parameters.adoc[] - -=== Response (Status 200) - -==== Response fields - -include::{snippets}/rollouts/get-rollout/response-fields.adoc[] - -==== Response example - -include::{snippets}/rollouts/get-rollout/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/404.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/429.adoc[] -|=== - -== POST /rest/v1/rollouts - -=== Implementation Notes -Handles the POST request of creating new rollout within Hawkbit. Required Permission: CREATE_ROLLOUT - -=== Create Rollout with defined amount of groups - - -==== CURL - -include::{snippets}/rollouts/create-rollout/curl-request.adoc[] - - -==== Request URL - -include::{snippets}/rollouts/create-rollout/http-request.adoc[] - -==== Request fields - -include::{snippets}/rollouts/create-rollout/request-fields.adoc[] - -=== Response (Status 201) - -==== Response fields - -include::{snippets}/rollouts/create-rollout/response-fields.adoc[] - -==== Response example - -include::{snippets}/rollouts/create-rollout/http-response.adoc[] - - -=== Create Rollout with groups definition - - -==== CURL - -include::{snippets}/rollouts/create-rollout-with-groups-definition/curl-request.adoc[] - - -==== Request URL - -include::{snippets}/rollouts/create-rollout-with-groups-definition/http-request.adoc[] - -==== Request fields - -include::{snippets}/rollouts/create-rollout-with-groups-definition/request-fields.adoc[] - -=== Response (Status 201) - -==== Response fields - -include::{snippets}/rollouts/create-rollout-with-groups-definition/response-fields.adoc[] - -==== Response example - -include::{snippets}/rollouts/create-rollout-with-groups-definition/http-response.adoc[] - - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/409.adoc[] -include::../errors/415.adoc[] -include::../errors/429.adoc[] -|=== - -== POST /rest/v1/rollouts/{rolloutId}/approve - -=== Implementation Notes -Handles the POST request of approving a created rollout within Hawkbit. -Only possible if approval workflow is enabled in system configuration and rollout is in state WAITING_FOR_APPROVAL. -Required Permission: APPROVE_ROLLOUT - -=== Approve Rollout - -==== CURL - -include::{snippets}/rollouts/approve-rollout/curl-request.adoc[] - - -==== Request URL - -include::{snippets}/rollouts/approve-rollout/http-request.adoc[] - - -=== Response (Status 200) - -==== Response example - -include::{snippets}/rollouts/approve-rollout/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/429.adoc[] -|=== - -== POST /rest/v1/rollouts/{rolloutId}/deny - -=== Implementation Notes -Handles the POST request of denying a created rollout within Hawkbit. -Only possible if approval workflow is enabled in system configuration and rollout is in state WAITING_FOR_APPROVAL. -Required Permission: APPROVE_ROLLOUT - -=== Deny Rollout - - -==== CURL - -include::{snippets}/rollouts/deny-rollout/curl-request.adoc[] - - -==== Request URL - -include::{snippets}/rollouts/deny-rollout/http-request.adoc[] - - -=== Response (Status 200) - -==== Response example - -include::{snippets}/rollouts/deny-rollout/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/429.adoc[] -|=== - -== POST /rest/v1/rollouts/{rolloutId}/start - -=== Implementation Notes -Handles the POST request of starting a created rollout within Hawkbit. Required Permission: HANDLE_ROLLOUT - -=== Start Rollout - - -==== CURL - -include::{snippets}/rollouts/start-rollout/curl-request.adoc[] - - -==== Request URL - -include::{snippets}/rollouts/start-rollout/http-request.adoc[] - - -=== Response (Status 200) - -==== Response example - -include::{snippets}/rollouts/start-rollout/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/429.adoc[] -|=== - -== POST /rest/v1/rollouts/{rolloutId}/pause - -=== Implementation Notes -Handles the POST request of pausing a running rollout within Hawkbit. Required Permission: HANDLE_ROLLOUT - -=== Pause Rollout - - -==== CURL - -include::{snippets}/rollouts/pause-rollout/curl-request.adoc[] - - -==== Request URL - -include::{snippets}/rollouts/pause-rollout/http-request.adoc[] - -==== Response example - -include::{snippets}/rollouts/pause-rollout/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/429.adoc[] -|=== - -== POST /rest/v1/rollouts/{rolloutId}/resume - -=== Implementation Notes -Handles the POST request of resuming a paused rollout within Hawkbit. Required Permission: HANDLE_ROLLOUT - -=== Resume Rollout - - -==== CURL - -include::{snippets}/rollouts/resume-rollout/curl-request.adoc[] - - -==== Request URL - -include::{snippets}/rollouts/resume-rollout/http-request.adoc[] - -==== Response example - -include::{snippets}/rollouts/resume-rollout/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/429.adoc[] -|=== - -== POST /rest/v1/rollouts/{rolloutId}/triggerNextGroup - -=== Implementation Notes -Handles the POST request of triggering the next group of a rollout within Hawkbit. Required Permission: UPDATE_ROLLOUT - -=== Trigger next group - - -==== CURL - -include::{snippets}/rollouts/trigger-next-group/curl-request.adoc[] - - -==== Request URL - -include::{snippets}/rollouts/trigger-next-group/http-request.adoc[] - -==== Response example - -include::{snippets}/rollouts/trigger-next-group/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/429.adoc[] -|=== - -== DELETE /rest/v1/rollouts/{rolloutId} - -=== Implementation Notes - -Handles the DELETE request of deleting a rollout within Hawkbit. Required Permission: DELETE_ROLLOUT - -=== Deleting a rollout - -==== CURL - -include::{snippets}/rollouts/delete-rollout/curl-request.adoc[] - -==== Request URL - -include::{snippets}/rollouts/delete-rollout/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/rollouts/delete-rollout/path-parameters.adoc[] - -=== Response (Status 200) - -==== Response example - -include::{snippets}/rollouts/delete-rollout/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/404.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/429.adoc[] -|=== - -== GET /rest/v1/rollouts/{rolloutId}/deploygroups - -=== Implementation Notes - -Handles the GET request of retrieving all deploy groups of a specific rollout within Hawkbit. Required Permission: READ_ROLLOUT - -=== Get Deploy Groups - -==== CURL - -include::{snippets}/rollouts/get-rollout-deploy-groups/curl-request.adoc[] - -==== Request URL - -include::{snippets}/rollouts/get-rollout-deploy-groups/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/rollouts/get-rollout-deploy-groups/path-parameters.adoc[] - -==== Request query parameter - -include::{snippets}/rollouts/get-rollouts-with-parameters/request-parameters.adoc[] - -==== Request query parameter example - -include::{snippets}/rollouts/get-rollouts-with-parameters/http-request.adoc[] - -=== Response (Status 200) - -==== Response fields - -include::{snippets}/rollouts/get-rollout-deploy-groups/response-fields.adoc[] - -==== Response example - -include::{snippets}/rollouts/get-rollout-deploy-groups/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/404.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/429.adoc[] -|=== - -== GET /rest/v1/rollouts/{rolloutId}/deploygroups/{deployGroupId} - -=== Implementation Notes - -Handles the GET request of a single deploy group of a specific rollout within Hawkbit. Required Permission: READ_ROLLOUT - -=== Get Deploy Groups - -==== CURL - -include::{snippets}/rollouts/get-rollout-deploy-group/curl-request.adoc[] - -==== Request URL - -include::{snippets}/rollouts/get-rollout-deploy-group/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/rollouts/get-rollout-deploy-group/path-parameters.adoc[] - -=== Response (Status 200) - -==== Response fields - -include::{snippets}/rollouts/get-rollout-deploy-group/response-fields.adoc[] - -==== Response example - -include::{snippets}/rollouts/get-rollout-deploy-group/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/404.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/429.adoc[] -|=== - -== GET /rest/v1/rollouts/{rolloutId}/deploygroups/{deployGroupId}/targets - -=== Implementation Notes - -Handles the GET request of retrieving all targets of a single deploy group of a specific rollout within Hawkbit. Required Permissions: READ_ROLLOUT, READ_TARGET. - -=== Get Deploy Group Targets - -==== CURL - -include::{snippets}/rollouts/get-rollout-deploy-group-targets/curl-request.adoc[] - -==== Request URL - -include::{snippets}/rollouts/get-rollout-deploy-group-targets/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/rollouts/get-rollout-deploy-group-targets/path-parameters.adoc[] - -==== Request query parameter - -include::{snippets}/rollouts/get-rollout-deploy-group-targets-with-parameters/request-parameters.adoc[] - -==== Request query parameter example - -include::{snippets}/rollouts/get-rollout-deploy-group-targets-with-parameters/http-request.adoc[] - -=== Response (Status 200) - -==== Response fields - -include::{snippets}/rollouts/get-rollout-deploy-group-targets/response-fields.adoc[] - -==== Response example - -include::{snippets}/rollouts/get-rollout-deploy-group-targets/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/404.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/429.adoc[] -|=== - -== Additional content - -[[error-body]] -=== Error body - -include::../errors/error-response-body.adoc[] \ No newline at end of file diff --git a/hawkbit-rest/hawkbit-rest-docs/src/main/asciidoc/rootcontroller-api-guide.adoc b/hawkbit-rest/hawkbit-rest-docs/src/main/asciidoc/rootcontroller-api-guide.adoc deleted file mode 100644 index 724d3c8d70..0000000000 --- a/hawkbit-rest/hawkbit-rest-docs/src/main/asciidoc/rootcontroller-api-guide.adoc +++ /dev/null @@ -1,688 +0,0 @@ -:doctype: book -:icons: font -:source-highlighter: highlightjs -:toc: macro -:toclevels: 1 -:sectlinks: -:linkattrs: - -[[root-controller]] -= Root Controller - -toc::[] - -== GET /{tenant}/controller/v1/{controllerid} - -=== Implementation notes - -This base resource can be regularly polled by the controller on the provisioning target or device in order to retrieve actions that need to be executed. -Those are provided as a list of links to give more detailed information about the action. -Links are only available for initial configuration, open actions, or the latest installed action, respectively. -The resource supports Etag based modification checks in order to save traffic. - -Note: deployments have to be confirmed in order to move on to the next action. -Cancellations have to be confirmed or rejected. - -=== Controller base poll resource - -==== Curl - -include::{snippets}/rootcontroller/get-controller-base-with-open-deplyoment/curl-request.adoc[] - -==== Request URL - -include::{snippets}/rootcontroller/get-controller-base-with-open-deplyoment/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/rootcontroller/get-controller-base-with-open-deplyoment/path-parameters.adoc[] - -=== Response (Status 200) with an active deployment - -==== Response fields - -include::{snippets}/rootcontroller/get-controller-base-with-open-deplyoment/response-fields.adoc[] - -==== Response example - -include::{snippets}/rootcontroller/get-controller-base-with-open-deplyoment/http-response.adoc[] - -=== Response (Status 200) with an active cancellation - -==== Response fields - -include::{snippets}/rootcontroller/get-controller-base-with-open-deployment-cancellation/response-fields.adoc[] - -==== Response example - -include::{snippets}/rootcontroller/get-controller-base-with-open-deployment-cancellation/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403_quota.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/429.adoc[] -|=== - - -== GET /{tenant}/controller/v1/{controllerid}/cancelAction/{actionId} - -=== Implementation notes - -The Hawkbit server might cancel an operation, e.g. an unfinished update has a successor. It is up to the provisioning target to decide to accept the cancelation or reject it. - -=== Cancel an action - -==== Curl - -include::{snippets}/rootcontroller/get-controller-cancel-action/curl-request.adoc[] - -==== Request URL - -include::{snippets}/rootcontroller/get-controller-cancel-action/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/rootcontroller/get-controller-cancel-action/path-parameters.adoc[] - -=== Response (Status 200) - -==== Response fields - -include::{snippets}/rootcontroller/get-controller-cancel-action/response-fields.adoc[] - -==== Response example - -include::{snippets}/rootcontroller/get-controller-cancel-action/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/429.adoc[] -|=== - - -== POST /{tenant}/controller/v1/{controllerid}/cancelAction/{actionId}/feedback - -=== Implementation notes - -It is up to the device how much intermediate feedback is provided. However, the action will be kept open until the controller on the device reports a finished (either successful or error) or rejects the action, e.g. the canceled actions have been started already. - -=== Feedback channel for cancel actions - -==== Curl - -include::{snippets}/rootcontroller/post-cancel-action-feedback/curl-request.adoc[] - -==== Request URL - -include::{snippets}/rootcontroller/post-cancel-action-feedback/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/rootcontroller/post-cancel-action-feedback/path-parameters.adoc[] - -==== Request fields - -include::{snippets}/rootcontroller/post-cancel-action-feedback/request-fields.adoc[] - -=== Response (Status 200) - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/409.adoc[] -include::../errors/415.adoc[] -include::../errors/429.adoc[] -|=== - - -== PUT /{tenant}/controller/v1/{controllerid}/configData - -=== Implementation notes - -The usual behaviour is that when a new device registers at the server it is requested to provide the meta information that will allow the server to identify the device on a hardware level (e.g. hardware revision, mac address, serial number etc.). - -=== Response to a requested metadata pull from the provisioning target device. - -==== Curl - -include::{snippets}/rootcontroller/put-config-data/curl-request.adoc[] - -==== Request URL - -include::{snippets}/rootcontroller/put-config-data/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/rootcontroller/put-config-data/path-parameters.adoc[] - -==== Request fields - -include::{snippets}/rootcontroller/put-config-data/request-fields.adoc[] - -=== Response (Status 200) - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/409.adoc[] -include::../errors/415.adoc[] -include::../errors/429.adoc[] -|=== - - -== GET /{tenant}/controller/v1/{controllerid}/deploymentBase/{actionId} - -=== Implementation notes - -Core resource for deployment operations. Contains all information necessary in order to execute the operation. - -Keep in mind that the provided download links for the artifacts are generated dynamically by the update server. Host, port and path and not guaranteed to be similar to the provided examples below but will be defined at runtime. - -=== Deployment or update action - -==== Curl - -include::{snippets}/rootcontroller/get-controller-basedeployment-action/curl-request.adoc[] - -==== Request URL - -include::{snippets}/rootcontroller/get-controller-basedeployment-action/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/rootcontroller/get-controller-basedeployment-action/path-parameters.adoc[] - -==== Request query parameter - -include::{snippets}/rootcontroller/get-controller-basedeployment-action/request-parameters.adoc[] - -=== Response (Status 200) - -==== Response fields - -include::{snippets}/rootcontroller/get-controller-basedeployment-action/response-fields.adoc[] - -==== Response example - -In this case the (optional) query for the last 10 messages, previously provided by the device, are included. Useful if the devices provide state information previously on the feedback channel and won't store it locally. - -include::{snippets}/rootcontroller/get-controller-basedeployment-action/http-response.adoc[] - - -=== Response (Status 200) with a maintenance window defined but not active yet - -In addition to the straight forward approach to inform the device to download and install the software in one transaction hawkBit supports the separation of download and installation into separate steps. - -This feature is called Maintenance Window where the device is informed to download the software first and then when it enters a defined (maintenance) window the installation triggers follows as in the example above. - -==== Response example - -Note: artifact details not shown in this example. - -include::{snippets}/rootcontroller/get-controller-basedeployment-action-with-maintenance-window/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/429.adoc[] -|=== - - -== POST /{tenant}/controller/v1/{controllerid}/deploymentBase/{actionId}/feedback - - -=== Implementation notes - -Feedback channel. It is up to the device how much intermediate feedback is provided. However, the action will be kept open until the controller on the device reports a finished (either successful or error). - -=== Feedback channel for update action - -==== Curl - -include::{snippets}/rootcontroller/post-basedeployment-action-feedback/curl-request.adoc[] - -==== Request URL - -include::{snippets}/rootcontroller/post-basedeployment-action-feedback/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/rootcontroller/post-basedeployment-action-feedback/path-parameters.adoc[] - -==== Request fields - -include::{snippets}/rootcontroller/post-basedeployment-action-feedback/request-fields.adoc[] - -=== Response (Status 200) - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/404.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/409.adoc[] -include::../errors/410.adoc[] -include::../errors/415.adoc[] -include::../errors/429.adoc[] -|=== - -== GET /{tenant}/controller/v1/{controllerid}/confirmationBase - -=== Implementation notes - -Core resource for confirmation related operations. While active actions awaiting confirmation will be referenced, the current auto-confirmation status will be shown. In case auto-confirmation is active, details like the initiator, remark and date of activation (as unix timestamp) will be provided. Reference links to switch the auto-confirmation state are exposed as well. - -=== Resource to request confirmation specific information for the controller - -==== Curl - -include::{snippets}/rootcontroller/get-confirmation-base-with-auto-confirm-active/curl-request.adoc[] - -==== Request URL - -include::{snippets}/rootcontroller/get-confirmation-base-with-auto-confirm-active/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/rootcontroller/get-confirmation-base-with-auto-confirm-active/path-parameters.adoc[] - -==== Response example (auto-confirmation is active) - -The response body in case auto-confirmation is active. - -include::{snippets}/rootcontroller/get-confirmation-base-with-auto-confirm-active/http-response.adoc[] - -==== Response example (auto-confirmation is not active) - -The response body references a link to activate auto-confirmation as well as a link to an open action waiting for confirmation (if present). - -include::{snippets}/rootcontroller/get-confirmation-base-with-auto-confirm-deactivated/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/404.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/409.adoc[] -include::../errors/415.adoc[] -include::../errors/429.adoc[] -|=== - -== POST /{tenant}/controller/v1/{controllerid}/confirmationBase/activateAutoConfirm - -=== Implementation notes - -The device can use this resource to activate auto-confirmation. As a result all current active as well as future actions will automatically be confirmed by mentioning the initiator as triggered person. Actions will be automatically confirmed, as long as auto-confirmation is active. - -=== Interface to activate auto-confirmation for a specific device - -==== Curl - -include::{snippets}/rootcontroller/activate-auto-confirmation/curl-request.adoc[] - -==== Request URL - -include::{snippets}/rootcontroller/activate-auto-confirmation/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/rootcontroller/activate-auto-confirmation/path-parameters.adoc[] - -==== Request fields - -include::{snippets}/rootcontroller/activate-auto-confirmation/request-fields.adoc[] - -=== Response (Status 200) - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/404.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/409.adoc[] -include::../errors/415.adoc[] -include::../errors/429.adoc[] -|=== - -== POST /{tenant}/controller/v1/{controllerid}/confirmationBase/deactivateAutoConfirm - -=== Implementation notes - -The device can use this resource to deactivate auto-confirmation. All active actions will remain unchanged while all future actions need to be confirmed, before processing with the deployment. - -=== Interface to deactivate auto-confirmation for a specific controller - -==== Curl - -include::{snippets}/rootcontroller/deactivate-auto-confirmation/curl-request.adoc[] - -==== Request URL - -include::{snippets}/rootcontroller/deactivate-auto-confirmation/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/rootcontroller/deactivate-auto-confirmation/path-parameters.adoc[] - -=== Response (Status 200) - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/404.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/409.adoc[] -include::../errors/415.adoc[] -include::../errors/429.adoc[] -|=== - -== GET /{tenant}/controller/v1/{controllerid}/confirmationBase/{actionId} - -=== Implementation notes - -Resource to receive information about a pending confirmation. -The response will be of the same format as the deploymentBase operation. -The controller should provide feedback about the confirmation first, before processing the deployment. - -Keep in mind that the provided download links for the artifacts are generated dynamically by the update server. -Host, port and path are not guaranteed to be similar to the provided examples below but will be defined at runtime. - -=== Confirmation status of an action - -==== Curl - -include::{snippets}/rootcontroller/get-confirmation-base-action/curl-request.adoc[] - -==== Request URL - -include::{snippets}/rootcontroller/get-confirmation-base-action/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/rootcontroller/get-confirmation-base-action/path-parameters.adoc[] - -==== Request query parameter - -include::{snippets}/rootcontroller/get-confirmation-base-action/request-parameters.adoc[] - -=== Response (Status 200) - -==== Response fields - -include::{snippets}/rootcontroller/get-confirmation-base-action/response-fields.adoc[] - -==== Response example - -The response body includes the detailed information about the action awaiting confirmation in the same format as for the deploymentBase operation. - -include::{snippets}/rootcontroller/get-confirmation-base-action/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/404_target_action.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/429.adoc[] -|=== - -== POST /{tenant}/controller/v1/{controllerid}/confirmationBase/{actionId}/feedback - -=== Implementation notes - -The device will use this resource to either confirm or deny an action which is waiting for confirmation. The action will be transferred into the RUNNING state in case the device is confirming it. Afterwards it will be exposed by the deploymentBase. - -=== Feedback channel for actions waiting for confirmation - -==== Curl - -include::{snippets}/rootcontroller/post-confirmation-feedback/curl-request.adoc[] - -==== Request URL - -include::{snippets}/rootcontroller/post-confirmation-feedback/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/rootcontroller/post-confirmation-feedback/path-parameters.adoc[] - -==== Request fields - -include::{snippets}/rootcontroller/post-confirmation-feedback/request-fields.adoc[] - -=== Response (Status 200) - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/404_target_action.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/409.adoc[] -include::../errors/410.adoc[] -include::../errors/415.adoc[] -include::../errors/429.adoc[] -|=== - -== GET /{tenant}/controller/v1/{controllerid}/installedBase/{actionId} - -=== Implementation notes - -Resource to receive information of the previous installation. -Can be used to re-retrieve artifacts of the already finished action, for example in case a re-installation is necessary. -The response will be of the same format as the deploymentBase operation, providing the previous action that has been finished successfully. -As the action is already finished, no further feedback is expected. - -Keep in mind that the provided download links for the artifacts are generated dynamically by the update server. -Host, port and path are not guaranteed to be similar to the provided examples below but will be defined at runtime. - -=== Previously installed action - -==== Curl - -include::{snippets}/rootcontroller/get-controller-installed-base-action/curl-request.adoc[] - -==== Request URL - -include::{snippets}/rootcontroller/get-controller-installed-base-action/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/rootcontroller/get-controller-installed-base-action/path-parameters.adoc[] - -==== Request query parameter - -include::{snippets}/rootcontroller/get-controller-installed-base-action/request-parameters.adoc[] - -=== Response (Status 200) - -==== Response fields - -include::{snippets}/rootcontroller/get-controller-installed-base-action/response-fields.adoc[] - -==== Response example - -The response body includes the detailed operation for the already finished action in the same format as for the deploymentBase operation. - -In this case the (optional) query for the last 10 messages, previously provided by the device, are included. - -include::{snippets}/rootcontroller/get-controller-installed-base-action/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/429.adoc[] -|=== - -//// -== GET /{tenant}/controller/v1/{controllerid}/softwaremodules - -=== Implementation notes - -Returns all available software modules for a given target - -=== Returns software modules of given target - -==== Curl - -include::{snippets}/rootcontroller/get-software-modules/curl-request.adoc[] - -==== Request URL - -include::{snippets}/rootcontroller/get-software-modules/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/rootcontroller/get-software-modules/path-parameters.adoc[] - -=== Response (Status 200) - -==== Response fields - -include::{snippets}/rootcontroller/get-software-modules/response-fields.adoc[] - -==== Response example - -include::{snippets}/rootcontroller/get-software-modules/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/429.adoc[] -|=== -//// - -== GET /{tenant}/controller/v1/{controllerid}/softwaremodules/{softwareModuleId}/artifacts - -=== Implementation notes - -Returns all artifacts that are assigned to the software module - -=== Returns artifacts of given software module - -==== Curl - -include::{snippets}/rootcontroller/get-software-modules-artifacts/curl-request.adoc[] - -==== Request URL - -include::{snippets}/rootcontroller/get-software-modules-artifacts/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/rootcontroller/get-software-modules-artifacts/path-parameters.adoc[] - -=== Response (Status 200) - -==== Response fields - -include::{snippets}/rootcontroller/get-software-modules-artifacts/response-fields.adoc[] - -==== Response example - -include::{snippets}/rootcontroller/get-software-modules-artifacts/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/429.adoc[] -|=== - - -== Additional content - -[[error-body]] -=== Error body - -include::../errors/error-response-body.adoc[] \ No newline at end of file diff --git a/hawkbit-rest/hawkbit-rest-docs/src/main/asciidoc/softwaremodules-api-guide.adoc b/hawkbit-rest/hawkbit-rest-docs/src/main/asciidoc/softwaremodules-api-guide.adoc deleted file mode 100644 index 3b6c9368b3..0000000000 --- a/hawkbit-rest/hawkbit-rest-docs/src/main/asciidoc/softwaremodules-api-guide.adoc +++ /dev/null @@ -1,756 +0,0 @@ -:doctype: book -:icons: font -:source-highlighter: highlightjs -:toc: macro -:toclevels: 1 -:sectlinks: -:linkattrs: - -[[software-modules]] -= Software Modules - -toc::[] - -== GET /rest/v1/softwaremodules - -=== Implementation notes - -Handles the GET request of retrieving all softwaremodules within Hawkbit. Required Permission: READ_REPOSITORY - -=== Get software modules - -==== CURL - -include::{snippets}/softwaremodules/get-software-modules/curl-request.adoc[] - -==== Request URL - -include::{snippets}/softwaremodules/get-software-modules/http-request.adoc[] - -==== Request parameter - -include::{snippets}/softwaremodules/get-software-modules-with-parameters/request-parameters.adoc[] - -==== Request parameter example - -include::{snippets}/softwaremodules/get-software-modules-with-parameters/http-request.adoc[] - -=== Response (Status 200) - -==== Response fields - -include::{snippets}/softwaremodules/get-software-modules/response-fields.adoc[] - -==== Response example - -include::{snippets}/softwaremodules/get-software-modules/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/429.adoc[] -|=== - - -== POST /rest/v1/softwaremodules - -=== Implementation notes - -Handles the POST request of creating new software modules within Hawkbit. The request body must always be a list of modules. Required Permission: CREATE_REPOSITORY - -=== Create software modules - -==== CURL - -include::{snippets}/softwaremodules/post-software-modules/curl-request.adoc[] - -==== Request URL - -include::{snippets}/softwaremodules/post-software-modules/http-request.adoc[] - -==== Request fields - -include::{snippets}/softwaremodules/post-software-modules/request-fields.adoc[] - -=== Response (Status 201) - -==== Response fields - -include::{snippets}/softwaremodules/post-software-modules/response-fields.adoc[] - -==== Response example - -include::{snippets}/softwaremodules/post-software-modules/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -| `404 Not Found` -| Not Found Software Module. -| See <> -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/409.adoc[] -include::../errors/415.adoc[] -include::../errors/429.adoc[] -|=== - - -== DELETE /rest/v1/softwaremodules/{softwareModuleId} - -=== Implementation Notes - -Handles the DELETE request for a single softwaremodule within Hawkbit. Required Permission: DELETE_REPOSITORY - -=== Delete software module - -==== CURL - -include::{snippets}/softwaremodules/delete-software-module/curl-request.adoc[] - -==== Request URL - -include::{snippets}/softwaremodules/delete-software-module/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/softwaremodules/delete-software-module/path-parameters.adoc[] - -=== Response (Status 200) - -==== Response example - -include::{snippets}/softwaremodules/delete-software-module/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -| `404 Not Found` -| Not Found Software Module. -| See <> -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/429.adoc[] -|=== - - -== GET /rest/v1/softwaremodules/{softwareModuleId} - -=== Implementation notes - -Handles the GET request of retrieving a single softwaremodule within Hawkbit. Required Permission: READ_REPOSITORY - -=== Get software module - -==== CURL - -include::{snippets}/softwaremodules/get-software-module/curl-request.adoc[] - -==== Request URL - -include::{snippets}/softwaremodules/get-software-module/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/softwaremodules/get-software-module/path-parameters.adoc[] - -=== Response (Status 200) - -==== Response fields - -include::{snippets}/softwaremodules/get-software-module/response-fields.adoc[] - -==== Response example - -include::{snippets}/softwaremodules/get-software-module/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -| `404 Not Found` -| Not Found Software Module. -| See <> -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/429.adoc[] -|=== - - -== PUT /rest/v1/softwaremodules/{softwareModuleId} - -=== Implementation notes - -Handles the PUT request for a single softwaremodule within Hawkbit. Required Permission: UPDATE_REPOSITORY - -=== Update software module - -==== CURL - -include::{snippets}/softwaremodules/put-software-module/curl-request.adoc[] - -==== Request URL - -include::{snippets}/softwaremodules/put-software-module/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/softwaremodules/put-software-module/path-parameters.adoc[] - -==== Request fields - -include::{snippets}/softwaremodules/put-software-module/request-fields.adoc[] - -=== Response (Status 200) - -==== Response fields - -include::{snippets}/softwaremodules/put-software-module/response-fields.adoc[] - -==== Response example - -include::{snippets}/softwaremodules/put-software-module/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -| `404 Not Found` -| Not Found Software Module. -| See <> -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/409.adoc[] -include::../errors/415.adoc[] -include::../errors/429.adoc[] -|=== - - -== GET /rest/v1/softwaremodules/{softwareModuleId}/artifacts - -=== Implementation notes - -Handles the GET request of retrieving all meta data of artifacts assigned to a software module. Required Permission: READ_REPOSITORY - -=== List artifacts metadata - -==== CURL - -include::{snippets}/softwaremodules/get-artifacts/curl-request.adoc[] - -==== Request URL - -include::{snippets}/softwaremodules/get-artifacts/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/softwaremodules/get-artifacts/path-parameters.adoc[] - -==== Request query parameter - -include::{snippets}/softwaremodules/get-artifacts-with-parameters/request-parameters.adoc[] - -=== Response (Status 200) - -==== Response fields - -include::{snippets}/softwaremodules/get-artifacts/response-fields.adoc[] - -==== Response example - -include::{snippets}/softwaremodules/get-artifacts/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -| `404 Not Found` -| Not Found Software Module. -| See <> -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/429.adoc[] -|=== - - -== POST /rest/v1/softwaremodules/{softwareModuleId}/artifacts - -=== Implementation notes - -Handles POST request for artifact upload. Required Permission: CREATE_REPOSITORY - -=== Upload artifact - -==== CURL - -include::{snippets}/softwaremodules/post-artifact/curl-request.adoc[] - -==== Request URL - -include::{snippets}/softwaremodules/post-artifact/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/softwaremodules/post-artifact/path-parameters.adoc[] - -==== Request query parameter - -include::{snippets}/softwaremodules/post-artifact-with-parameters/request-parameters.adoc[] - -==== Request parameter example - -include::{snippets}/softwaremodules/post-artifact-with-parameters/http-request.adoc[] - -=== Response (Status 201) - -==== Response fields - -include::{snippets}/softwaremodules/post-artifact/response-fields.adoc[] - -==== Response example - -include::{snippets}/softwaremodules/post-artifact/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -| `404 Not Found` -| Not Found Software Module. -| See <> -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/415.adoc[] -include::../errors/429.adoc[] -|=== - - -== DELETE /rest/v1/softwaremodules/{softwareModuleId}/artifacts/{artifactId} - -=== Implementation Notes - -Handles the DELETE request for a single SoftwareModule within Hawkbit. Required Permission: DELETE_REPOSITORY - -=== Delete arifact - -==== CURL - -include::{snippets}/softwaremodules/delete-artifact/curl-request.adoc[] - -==== Request URL - -include::{snippets}/softwaremodules/delete-artifact/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/softwaremodules/delete-artifact/path-parameters.adoc[] - -=== Response (Status 200) - -==== Response example - -include::{snippets}/softwaremodules/delete-artifact/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -| `404 Not Found` -| Not Found Software Module. -| See <> -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/429.adoc[] -|=== - - -== GET /rest/v1/softwaremodules/{softwareModuleId}/artifacts/{artifactId} - -=== Implementation notes - -Handles the GET request of retrieving a single Artifact meta data request. Required Permission: READ_REPOSITORY - -=== Get artifact metadata - -==== CURL - -include::{snippets}/softwaremodules/get-artifact/curl-request.adoc[] - -==== Request URL - -include::{snippets}/softwaremodules/get-artifact/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/softwaremodules/get-artifact/path-parameters.adoc[] - -==== Request query parameter - -include::{snippets}/softwaremodules/get-artifact-with-parameters/request-parameters.adoc[] - -=== Response (Status 200) - -==== Response fields - -include::{snippets}/softwaremodules/get-artifact/response-fields.adoc[] - -==== Response example - -include::{snippets}/softwaremodules/get-artifact/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -| `404 Not Found` -| Not Found Software Module. -| See <> -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/429.adoc[] -|=== - - -== GET /rest/v1/softwaremodules/{softwareModuleId}/artifacts/{artifactId}/download - -=== Implementation notes - -Handles the GET request for downloading an artifact. Required Permission: READ_REPOSITORY - -=== Download artifact - -==== CURL - -include::{snippets}/softwaremodules/get-download-artifact/curl-request.adoc[] - -==== Request URL - -include::{snippets}/softwaremodules/get-download-artifact/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/softwaremodules/get-download-artifact/path-parameters.adoc[] - -=== Response (Status 200) - -==== Response example - -include::{snippets}/softwaremodules/get-download-artifact/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -| `404 Not Found` -| Not Found Software Module. -| See <> -include::../errors/405.adoc[] -include::../errors/406.adoc[] -| `410 Gone` -| The resource does not exist anymore. The software module might be soft deleted. -| -include::../errors/429.adoc[] -|=== - - -== GET /rest/v1/softwaremodules/{softwareModuleId}/metadata - -=== Implementation notes - -Get a paged list of meta data for a software module. Required Permission: READ_REPOSITORY - -=== Get a paged list of metadata - -==== CURL - -include::{snippets}/softwaremodules/get-metadata/curl-request.adoc[] - -==== Request URL - -include::{snippets}/softwaremodules/get-metadata/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/softwaremodules/get-metadata/path-parameters.adoc[] - -==== Request query parameter - -include::{snippets}/softwaremodules/get-metadata-with-parameters/request-parameters.adoc[] - -==== Request parameter example - -include::{snippets}/softwaremodules/get-metadata-with-parameters/http-request.adoc[] - -=== Response (Status 200) - -==== Response fields - -include::{snippets}/softwaremodules/get-metadata/response-fields.adoc[] - -==== Response example - -include::{snippets}/softwaremodules/get-metadata/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -| `404 Not Found` -| Not Found Software Module. -| See <> -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/429.adoc[] -|=== - - -== POST /rest/v1/softwaremodules/{softwareModuleId}/metadata - -=== Implementation notes - -Create a list of meta data entries Required Permission: UPDATE_REPOSITORY - -=== Create a list of metadata entries - -==== CURL - -include::{snippets}/softwaremodules/post-metadata/curl-request.adoc[] - -==== Request URL - -include::{snippets}/softwaremodules/post-metadata/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/softwaremodules/post-metadata/path-parameters.adoc[] - -==== Request fields - -include::{snippets}/softwaremodules/post-metadata/request-fields.adoc[] - -=== Response (Status 201) - -==== Response fields - -include::{snippets}/softwaremodules/post-metadata/response-fields.adoc[] - -==== Response example - -include::{snippets}/softwaremodules/post-metadata/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -| `404 Not Found` -| Not Found Software Module. -| See <> -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/409.adoc[] -include::../errors/415.adoc[] -include::../errors/429.adoc[] -|=== - -== DELETE /rest/v1/softwaremodules/{softwareModuleId}/metadata/{metadataKey} - -=== Implementation Notes - -Delete a single meta data. Required Permission: UPDATE_REPOSITORY - -=== Deleting a single metadata - -==== CURL - -include::{snippets}/softwaremodules/delete-metadata/curl-request.adoc[] - -==== Request URL - -include::{snippets}/softwaremodules/delete-metadata/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/softwaremodules/delete-metadata/path-parameters.adoc[] - -=== Response (Status 200) - -==== Response example - -include::{snippets}/softwaremodules/delete-metadata/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -| `404 Not Found` -| Not Found Software Module. -| See <> -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/429.adoc[] -|=== - - -== GET /rest/v1/softwaremodules/{softwareModuleId}/metadata/{metadataKey} - -=== Implementation notes - -Get a single meta data value for a meta data key. Required Permission: READ_REPOSITORY - -=== Get a single metadata value - -==== CURL - -include::{snippets}/softwaremodules/get-metadata-value/curl-request.adoc[] - -==== Request URL - -include::{snippets}/softwaremodules/get-metadata-value/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/softwaremodules/get-metadata-value/path-parameters.adoc[] - -=== Response (Status 200) - -==== Response fields - -include::{snippets}/softwaremodules/get-metadata-value/response-fields.adoc[] - -==== Response example - -include::{snippets}/softwaremodules/get-metadata-value/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -| `404 Not Found` -| Not Found Software Module. -| See <> -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/429.adoc[] -|=== - - -== PUT /rest/v1/softwaremodules/{softwareModuleId}/metadata/{metadataKey} - -=== Implementation notes - -Update a single meta data value for speficic key. Required Permission: UPDATE_REPOSITORY - -=== Updating a single metadata value - -==== CURL - -include::{snippets}/softwaremodules/put-metadata/curl-request.adoc[] - -==== Request URL - -include::{snippets}/softwaremodules/put-metadata/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/softwaremodules/put-metadata/path-parameters.adoc[] - -==== Request fields - -include::{snippets}/softwaremodules/put-metadata/request-fields.adoc[] - -=== Response (Status 200) - -==== Response fields - -include::{snippets}/softwaremodules/put-metadata/response-fields.adoc[] - -==== Response example - -include::{snippets}/softwaremodules/put-software-module/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -| `404 Not Found` -| Not Found Software Module. -| See <> -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/429.adoc[] -|=== - - -== Additional content - -[[error-body]] -=== Error body - -include::../errors/error-response-body.adoc[] - - diff --git a/hawkbit-rest/hawkbit-rest-docs/src/main/asciidoc/softwaremoduletypes-api-guide.adoc b/hawkbit-rest/hawkbit-rest-docs/src/main/asciidoc/softwaremoduletypes-api-guide.adoc deleted file mode 100644 index 97249b5a3b..0000000000 --- a/hawkbit-rest/hawkbit-rest-docs/src/main/asciidoc/softwaremoduletypes-api-guide.adoc +++ /dev/null @@ -1,255 +0,0 @@ -:doctype: book -:icons: font -:source-highlighter: highlightjs -:toc: macro -:toclevels: 1 -:sectlinks: -:linkattrs: - -[[software-module-types]] -= Software Module Types - -toc::[] - -== GET /rest/v1/softwaremoduletypes - -=== Implementation notes - -Handles the GET request of retrieving all software module types within Hawkbit. Required Permission: READ_REPOSITORY - -=== Get software module types - -==== CURL - -include::{snippets}/softwaremoduletypes/get-software-module-types/curl-request.adoc[] - -==== Request URL - -include::{snippets}/softwaremoduletypes/get-software-module-types/http-request.adoc[] - -==== Request query parameter - -include::{snippets}/softwaremoduletypes/get-software-module-types-with-parameters/request-parameters.adoc[] - -==== Request parameter example - -include::{snippets}/softwaremoduletypes/get-software-module-types-with-parameters/http-request.adoc[] - -=== Response (Status 200) - -==== Response fields - -include::{snippets}/softwaremoduletypes/get-software-module-types/response-fields.adoc[] - -==== Response example - -include::{snippets}/softwaremoduletypes/get-software-module-types/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/429.adoc[] -|=== - - -== POST /rest/v1/softwaremoduletypes - -=== Implementation notes - -Handles the POST request of creating new software module types within Hawkbit. The request body must always be a list of module types. Required Permission: CREATE_REPOSITORY - -=== Creating software module types - -==== CURL - -include::{snippets}/softwaremoduletypes/post-software-module-types/curl-request.adoc[] - -==== Request URL - -include::{snippets}/softwaremoduletypes/post-software-module-types/http-request.adoc[] - -==== Request fields - -include::{snippets}/softwaremoduletypes/post-software-module-types/request-fields.adoc[] - -=== Response (Status 201) - -==== Response fields - -include::{snippets}/softwaremoduletypes/post-software-module-types/response-fields.adoc[] - -==== Response example - -include::{snippets}/softwaremoduletypes/post-software-module-types/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -| `404 Not Found` -| Not Found Software Module Type. -| See <> -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/409.adoc[] -include::../errors/415.adoc[] -include::../errors/429.adoc[] -|=== - - -== DELETE /rest/v1/softwaremoduletypes/{softwareModuleTypeId} - -=== Implementation Notes - -Handles the DELETE request for a single software module type within Hawkbit. Required Permission: DELETE_REPOSITORY - -=== Delete software module type - -==== CURL - -include::{snippets}/softwaremoduletypes/delete-software-module-type/curl-request.adoc[] - -==== Request URL - -include::{snippets}/softwaremoduletypes/delete-software-module-type/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/softwaremoduletypes/delete-software-module-type/path-parameters.adoc[] - -=== Response (Status 200) - -==== Response example - -include::{snippets}/softwaremoduletypes/delete-software-module-type/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/404.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/429.adoc[] -|=== - - -== GET /rest/v1/softwaremoduletypes/{softwareModuleTypeId} - -=== Implementation notes - -Handles the GET request of retrieving a single software module type within Hawkbit. Required Permission: READ_REPOSITORY - -=== Accessing a software module type - -==== CURL - -include::{snippets}/softwaremoduletypes/get-software-module-type/curl-request.adoc[] - -==== Request URL - -include::{snippets}/softwaremoduletypes/get-software-module-type/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/softwaremoduletypes/get-software-module-type/path-parameters.adoc[] - -=== Response (Status 200) - -==== Response fields - -include::{snippets}/softwaremoduletypes/get-software-module-type/response-fields.adoc[] - -==== Response example - -include::{snippets}/softwaremoduletypes/get-software-module-type/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/429.adoc[] -|=== - - -== PUT /rest/v1/softwaremoduletypes/{softwareModuleTypeId} - -=== Implementation notes - -Handles the PUT request for a single software module type within Hawkbit. Required Permission: UPDATE_REPOSITORY - -=== Updating a software module types - -==== CURL - -include::{snippets}/softwaremoduletypes/put-software-module-type/curl-request.adoc[] - -==== Request URL - -include::{snippets}/softwaremoduletypes/put-software-module-type/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/softwaremoduletypes/put-software-module-type/path-parameters.adoc[] - -==== Request fields - -include::{snippets}/softwaremoduletypes/put-software-module-type/request-fields.adoc[] - -=== Response (Status 200) - -==== Response fields - -include::{snippets}/softwaremoduletypes/put-software-module-type/response-fields.adoc[] - -==== Response example - -include::{snippets}/softwaremoduletypes/put-software-module-type/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -| `404 Not Found` -| Not Found Software Module Type. -| See <> -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/409.adoc[] -include::../errors/415.adoc[] -include::../errors/429.adoc[] -|=== - - -== Additional content - -[[error-body]] -=== Error body - -include::../errors/error-response-body.adoc[] - diff --git a/hawkbit-rest/hawkbit-rest-docs/src/main/asciidoc/targetfilters-api-guide.adoc b/hawkbit-rest/hawkbit-rest-docs/src/main/asciidoc/targetfilters-api-guide.adoc deleted file mode 100644 index 2c4d48f140..0000000000 --- a/hawkbit-rest/hawkbit-rest-docs/src/main/asciidoc/targetfilters-api-guide.adoc +++ /dev/null @@ -1,392 +0,0 @@ -:doctype: book -:icons: font -:source-highlighter: highlightjs -:toc: macro -:toclevels: 1 -:sectlinks: -:linkattrs: - -[[targetfilters]] -= Target filter queries - -toc::[] - - -== GET /rest/v1/targetfilters - -=== Implementation notes - -Handles the GET request of retrieving all target filter queries within Hawkbit. Required permission: READ_TARGET - -=== Get paged list of target filter queries - -==== CURL - -include::{snippets}/targetfilters/get-target-filter-queries/curl-request.adoc[] - -==== Request URL - -A `GET` request is used to access the target filter queries - -include::{snippets}/targetfilters/get-target-filter-queries/http-request.adoc[] - -==== Request query parameter - -include::{snippets}/targetfilters/get-target-filter-queries-with-parameters/request-parameters.adoc[] - -==== Request parameter example - -include::{snippets}/targetfilters/get-target-filter-queries-with-parameters/http-request.adoc[] - -=== Response (Status 200) - -==== Response fields - -include::{snippets}/targetfilters/get-target-filter-queries/response-fields.adoc[] - -==== Response example - -include::{snippets}/targetfilters/get-target-filter-queries/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/429.adoc[] -|=== - - -== POST /rest/v1/targetfilters - -=== Implementation Notes - -Handles the POST request to create a new target filter query within Hawkbit. Required permission: CREATE_TARGET - -=== Create a target filter query - -==== CURL - -include::{snippets}/targetfilters/post-target-filter-query/curl-request.adoc[] - -==== Request URL - -include::{snippets}/targetfilters/post-target-filter-query/http-request.adoc[] - -==== Request fields - -include::{snippets}/targetfilters/post-target-filter-query/request-fields.adoc[] - -=== Response (Status 201) - -==== Response fields - -include::{snippets}/targetfilters/post-target-filter-query/response-fields.adoc[] - -==== Response example - -include::{snippets}/targetfilters/post-target-filter-query/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403_quota.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/409.adoc[] -include::../errors/415.adoc[] -include::../errors/429.adoc[] -|=== - - -== DELETE /rest/v1/targetfilters/{targetFilterQueryId} - -=== Implementation Notes - -Handles the DELETE request of deleting a target filter query within Hawkbit. Required permission: DELETE_TARGET - -=== Deleting a target - -==== CURL - -include::{snippets}/targetfilters/delete-target-filter-query/curl-request.adoc[] - -==== Request URL - -include::{snippets}/targetfilters/delete-target-filter-query/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/targetfilters/delete-target-filter-query/path-parameters.adoc[] - -=== Response (Status 200) - -==== Response example - -include::{snippets}/targetfilters/delete-target-filter-query/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/404.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/429.adoc[] -|=== - - -== GET /rest/v1/targetfilters/{targetFilterQueryId} - -=== Implementation Notes - -Handles the GET request of retrieving a single target filter query within Hawkbit. Required permission: READ_TARGET - -=== Get single target - -==== CURL - -include::{snippets}/targetfilters/get-target-filter-query/curl-request.adoc[] - -==== Request URL - -include::{snippets}/targetfilters/get-target-filter-query/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/targetfilters/get-target-filter-query/path-parameters.adoc[] - -=== Response (Status 200) - -==== Response fields - -include::{snippets}/targetfilters/get-target-filter-query/response-fields.adoc[] - -==== Response example - -include::{snippets}/targetfilters/get-target-filter-query/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/404.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/429.adoc[] -|=== - - -== PUT /rest/v1/targetfilters/{targetFilterQueryId} - -=== Implementation Notes - -Handles the PUT request of updating a target filter query within Hawkbit. Required permission: UPDATE_TARGET - -=== Update a target - -==== Curl - -include::{snippets}/targetfilters/put-target-filter-query/curl-request.adoc[] - -==== Request URL - -include::{snippets}/targetfilters/put-target-filter-query/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/targetfilters/put-target-filter-query/path-parameters.adoc[] - -==== Request fields - -include::{snippets}/targetfilters/put-target-filter-query/request-fields.adoc[] - -=== Response (Status 200) - -==== Response fields - -include::{snippets}/targetfilters/put-target-filter-query/response-fields.adoc[] - -==== Response example - -include::{snippets}/targetfilters/put-target-filter-query/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/404.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/409.adoc[] -include::../errors/415.adoc[] -include::../errors/429.adoc[] -|=== - - -== GET /rest/v1/targetfilters/{targetFilterQueryId}/autoAssignDS - -=== Implementation Notes - -Handles the GET request of retrieving the auto assign distribution set. Required permission: READ_TARGET - -=== Get auto assign distribution set - -==== Curl - -include::{snippets}/targetfilters/get-assign-ds/curl-request.adoc[] - -==== Request URL - -include::{snippets}/targetfilters/get-assign-ds/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/targetfilters/get-assign-ds/path-parameters.adoc[] - -=== Response (Status 200) - -==== Response fields - -include::{snippets}/targetfilters/get-assign-ds/response-fields.adoc[] - -==== Response example - -include::{snippets}/targetfilters/get-assign-ds/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/429.adoc[] -|=== - - -== POST /rest/v1/targetfilters/{targetFilterQueryId}/autoAssignDS - -=== Implementation Notes - -Handles the POST request of setting the auto assign distribution set for a target filter query. -Required permissions: UPDATE_TARGET and READ_REPOSITORY - -=== Set auto assign distribution set - -==== Curl - -include::{snippets}/targetfilters/post-auto-assign-ds/curl-request.adoc[] - -==== Request URL - -include::{snippets}/targetfilters/post-auto-assign-ds/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/targetfilters/post-auto-assign-ds/path-parameters.adoc[] - -==== Request fields - -include::{snippets}/targetfilters/post-auto-assign-ds/request-fields.adoc[] - -=== Response (Status 200) - -==== Response fields - -include::{snippets}/targetfilters/post-auto-assign-ds/response-fields.adoc[] - -==== Response example - -include::{snippets}/targetfilters/post-auto-assign-ds/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/404.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/415.adoc[] -include::../errors/429.adoc[] -|=== - - -== DELETE /rest/v1/targetfilters/{targetFilterQueryId}/autoAssignDS - -=== Implementation Notes - -Removes the auto assign distribution set from the target filter query. Required permission: UPDATE_TARGET - -=== Removing the auto assign distribution set - -==== Curl - -include::{snippets}/targetfilters/delete-auto-assign-ds/curl-request.adoc[] - -==== Request URL - -include::{snippets}/targetfilters/delete-auto-assign-ds/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/targetfilters/delete-auto-assign-ds/path-parameters.adoc[] - -=== Response (Status 204) - -==== Response example - -include::{snippets}/targetfilters/delete-auto-assign-ds/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/404.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/429.adoc[] -|=== - - - -== Additional content - -[[error-body]] -=== Error body - -include::../errors/error-response-body.adoc[] - - diff --git a/hawkbit-rest/hawkbit-rest-docs/src/main/asciidoc/targets-api-guide.adoc b/hawkbit-rest/hawkbit-rest-docs/src/main/asciidoc/targets-api-guide.adoc deleted file mode 100644 index 571a1ed4b2..0000000000 --- a/hawkbit-rest/hawkbit-rest-docs/src/main/asciidoc/targets-api-guide.adoc +++ /dev/null @@ -1,1212 +0,0 @@ -:doctype: book -:icons: font -:source-highlighter: highlightjs -:toc: macro -:toclevels: 1 -:sectlinks: -:linkattrs: - -[[targets]] -= Targets - -toc::[] - - -== GET /rest/v1/targets - -=== Implementation notes - -Handles the GET request of retrieving all targets within Hawkbit. Required permission: READ_TARGET - -=== Get paged list of targets - -==== CURL - -include::{snippets}/targets/get-targets/curl-request.adoc[] - -==== Request URL - -A `GET` request is used to access the targets - -include::{snippets}/targets/get-targets/http-request.adoc[] - -==== Request query parameter - -include::{snippets}/targets/get-targets-with-parameters/request-parameters.adoc[] - -==== Request parameter example - -include::{snippets}/targets/get-targets-with-parameters/http-request.adoc[] - -=== Response (Status 200) - -==== Response fields - -include::{snippets}/targets/get-targets/response-fields.adoc[] - -==== Response example - -include::{snippets}/targets/get-targets/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/429.adoc[] -|=== - - -== POST /rest/v1/targets - -=== Implementation Notes - -Handles the POST request of creating new targets within Hawkbit. The request body must always be a list of targets. Required Permission: CREATE_TARGET - -=== Create list of targets - -==== CURL - -include::{snippets}/targets/post-targets/curl-request.adoc[] - -==== Request URL - -include::{snippets}/targets/post-targets/http-request.adoc[] - -==== Request fields - -include::{snippets}/targets/post-targets/request-fields.adoc[] - -=== Response (Status 201) - -==== Response fields - -include::{snippets}/targets/post-targets/response-fields.adoc[] - -==== Response example - -include::{snippets}/targets/post-targets/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403_quota.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/409.adoc[] -include::../errors/415.adoc[] -include::../errors/429.adoc[] -|=== - - -== DELETE /rest/v1/targets/{targetId} - -=== Implementation Notes - -Handles the DELETE request of deleting a single target within Hawkbit. Required Permission: DELETE_TARGET - -=== Deleting a target - -==== CURL - -include::{snippets}/targets/delete-target/curl-request.adoc[] - -==== Request URL - -include::{snippets}/targets/delete-target/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/targets/delete-target/path-parameters.adoc[] - -=== Response (Status 200) - -==== Response example - -include::{snippets}/targets/delete-target/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/404.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/429.adoc[] -|=== - - -== GET /rest/v1/targets/{targetId} - -=== Implementation Notes - -Handles the GET request of retrieving a single target within Hawkbit. Required Permission: READ_TARGET - -=== Get single target - -==== CURL - -include::{snippets}/targets/get-target/curl-request.adoc[] - -==== Request URL - -include::{snippets}/targets/get-target/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/targets/get-target/path-parameters.adoc[] - -=== Response (Status 200) - -==== Response fields - -include::{snippets}/targets/get-target/response-fields.adoc[] - -==== Response example - -include::{snippets}/targets/get-target/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/404.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/429.adoc[] -|=== - - -== PUT /rest/v1/targets/{targetId} - -=== Implementation Notes - -Handles the PUT request of updating a target within Hawkbit. Required Permission: UPDATE_TARGET - -=== Update a target - -==== Curl - -include::{snippets}/targets/put-target/curl-request.adoc[] - -==== Request URL - -include::{snippets}/targets/put-target/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/targets/put-target/path-parameters.adoc[] - -==== Request fields - -include::{snippets}/targets/put-target/request-fields.adoc[] - -=== Response (Status 200) - -==== Response fields - -include::{snippets}/targets/put-target/response-fields.adoc[] - -==== Response example - -include::{snippets}/targets/put-target/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/404.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/409.adoc[] -include::../errors/415.adoc[] -include::../errors/429.adoc[] -|=== - - -== GET /rest/v1/targets/{targetId}/autoConfirm - -=== Implementation Notes - -Handles the GET request to check the current auto-confirmation state of a target. Required Permission: READ_TARGET - -=== Request auto-confirmation state for a specific target - -==== Curl - -include::{snippets}/targets/get-target-auto-confirm-state-active/curl-request.adoc[] - -==== Request URL - -include::{snippets}/targets/get-target-auto-confirm-state-active/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/targets/get-target-auto-confirm-state-active/path-parameters.adoc[] - -=== Response in case auto-confirmation is active (Status 200) - -In case auto-confirmation is active, details like the initiator, remark and date of activation (as unix timestamp) will be provided. Reference links to switch the auto-confirmation state are exposed as well. - -==== Response fields - -include::{snippets}/targets/get-target-auto-confirm-state-active/response-fields.adoc[] - -==== Response example - -include::{snippets}/targets/get-target-auto-confirm-state-active/http-response.adoc[] - -=== Response in case auto-confirmation is not active (Status 200) - -The response body references a link to activate auto-confirmation. - -==== Response fields - -include::{snippets}/targets/get-target-auto-confirm-state-not-active/response-fields.adoc[] - -==== Response example - -include::{snippets}/targets/get-target-auto-confirm-state-not-active/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/404.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/429.adoc[] -|=== - - -== POST /rest/v1/targets/{targetId}/autoConfirm/activate - -=== Implementation Notes - -Handles the POST request to activate auto-confirmation for a specific target. -As a result all current active as well as future actions will automatically be confirmed by mentioning the initiator as triggered person. -Actions will be automatically confirmed, as long as auto-confirmation is active. -Required Permission: UPDATE_TARGET - -=== Activate auto-confirmation for a target - -==== Curl - -include::{snippets}/targets/post-activate-auto-confirm/curl-request.adoc[] - -==== Request URL - -include::{snippets}/targets/post-activate-auto-confirm/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/targets/post-activate-auto-confirm/path-parameters.adoc[] - -==== Request fields - -include::{snippets}/targets/post-activate-auto-confirm/request-fields.adoc[] - -=== Response (Status 200) - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/404.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/409.adoc[] -include::../errors/415.adoc[] -include::../errors/429.adoc[] -|=== - - -== POST /rest/v1/targets/{targetId}/autoConfirm/deactivate - -=== Implementation Notes - -Handles the POST request to deactivate auto-confirmation for a specific target. -All active actions will remain unchanged while all future actions need to be confirmed, before processing with the deployment. -Required Permission: UPDATE_TARGET - -=== Deactivate auto-confirmation for a target - -==== Curl - -include::{snippets}/targets/post-deactivate-auto-confirm/curl-request.adoc[] - -==== Request URL - -include::{snippets}/targets/post-deactivate-auto-confirm/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/targets/post-deactivate-auto-confirm/path-parameters.adoc[] - -=== Response (Status 200) - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/404.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/409.adoc[] -include::../errors/415.adoc[] -include::../errors/429.adoc[] -|=== - - -== GET /rest/v1/targets/{targetId}/actions - -=== Implementation Notes - -Handles the GET request of retrieving the full action history of a specific target. Required Permission: READ_TARGET - -=== List all actions of Target - -==== Curl - -include::{snippets}/targets/get-actions-from-target/curl-request.adoc[] - -==== Request URL - -include::{snippets}/targets/get-actions-from-target/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/targets/get-actions-from-target/path-parameters.adoc[] - -==== Request query parameter - -include::{snippets}/targets/get-actions-from-target-with-parameters/request-parameters.adoc[] - -==== Request parameter example - -include::{snippets}/targets/get-actions-from-target-with-parameters/http-request.adoc[] - -=== Response (Status 200) - -==== Response fields - -include::{snippets}/targets/get-actions-from-target-with-maintenance-window/response-fields.adoc[] - -==== Response example - -include::{snippets}/targets/get-actions-from-target/http-response.adoc[] - -==== Response example with Maintenance Window - -include::{snippets}/targets/get-actions-from-target-with-maintenance-window/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/429.adoc[] -|=== - - -== PUT /rest/v1/targets/{targetId}/actions/{actionId} - -=== Implementation Notes - -Handles the PUT request to switch an action from soft to forced. Required Permission: UPDATE_TARGET. - -=== Update a target - -==== Curl - -include::{snippets}/targets/switch-action-to-forced/curl-request.adoc[] - -==== Request URL - -include::{snippets}/targets/switch-action-to-forced/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/targets/switch-action-to-forced/path-parameters.adoc[] - -==== Request fields - -include::{snippets}/targets/switch-action-to-forced/request-fields.adoc[] - -=== Response (Status 200) - -==== Response fields - -include::{snippets}/targets/switch-action-to-forced/response-fields.adoc[] - -==== Response example - -include::{snippets}/targets/switch-action-to-forced/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/404.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/409.adoc[] -include::../errors/415.adoc[] -include::../errors/429.adoc[] -|=== - -== DELETE /rest/v1/targets/{targetId}/actions/{actionId} - -=== Implementation Notes - -Cancels an active action, only active actions can be deleted. Required Permission: UPDATE_TARGET - -=== Canceling an active action - -==== Curl - -include::{snippets}/targets/delete-action-from-target/curl-request.adoc[] - -==== Request URL - -include::{snippets}/targets/delete-action-from-target/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/targets/delete-action-from-target/path-parameters.adoc[] - -==== Request query parameter - -include::{snippets}/targets/delete-action-from-target-with-parameters/request-parameters.adoc[] - -==== Request parameter example - -include::{snippets}/targets/delete-action-from-target-with-parameters/http-request.adoc[] - -=== Response (Status 204) - -==== Response example - -include::{snippets}/targets/delete-action-from-target/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/404.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/429.adoc[] -|=== - - -== GET /rest/v1/targets/{targetId}/actions/{actionId} - -=== Implementation Notes - -Handles the GET request of retrieving a specific action on a specific target. Required Permission: READ_TARGET - -=== Get assigned action of target - -==== Curl - -include::{snippets}/targets/get-action-from-target/curl-request.adoc[] - -==== Request URL - -include::{snippets}/targets/get-action-from-target/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/targets/get-action-from-target/path-parameters.adoc[] - -=== Response (Status 200) - -==== Response fields - -include::{snippets}/targets/get-action-from-target-with-maintenance-window/response-fields.adoc[] - -==== Response example - -include::{snippets}/targets/get-action-from-target/http-response.adoc[] - -==== Response example with Maintenance Window - -include::{snippets}/targets/get-action-from-target-with-maintenance-window/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/404.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/429.adoc[] -|=== - - -== GET /rest/v1/targets/{targetId}/actions/{actionId}/status - -=== Implementation Notes - -Handles the GET request of retrieving a specific action on a specific target. Required Permission: READ_TARGET - -=== Get statuses of assigned action - -==== Curl - -include::{snippets}/targets/get-status-from-action/curl-request.adoc[] - -==== Request URL - -include::{snippets}/targets/get-status-from-action/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/targets/get-status-from-action/path-parameters.adoc[] - -==== Request parameter - -include::{snippets}/targets/get-status-from-action-with-parameters/request-parameters.adoc[] - -==== Request parameter example - -include::{snippets}/targets/get-status-from-action-with-parameters/http-request.adoc[] - -=== Response (Status 200) - -==== Response fields - -include::{snippets}/targets/get-status-from-action/response-fields.adoc[] - -==== Response example - -include::{snippets}/targets/get-status-from-action/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/404.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/429.adoc[] -|=== - - -== GET /rest/v1/targets/{targetId}/assignedDS - -=== Implementation Notes - -Handles the GET request of retrieving the assigned distribution set of an specific target. Required Permission: READ_TARGET - -=== Get assigned distribution set of target - -==== Curl - -include::{snippets}/targets/get-assigned-distribution-set-from-action/curl-request.adoc[] - -==== Request URL - -include::{snippets}/targets/get-assigned-distribution-set-from-action/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/targets/get-assigned-distribution-set-from-action/path-parameters.adoc[] - -=== Response (Status 200) - -==== Response fields - -include::{snippets}/targets/get-assigned-distribution-set-from-action/response-fields.adoc[] - -==== Response example - -include::{snippets}/targets/get-assigned-distribution-set-from-action/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/404.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/429.adoc[] -|=== - - -== POST /rest/v1/targets/{targetId}/assignedDS (assign single distribution set) - -=== Implementation Notes - -Handles the POST request for assigning a distribution set to a specific target. Required Permission: READ_REPOSITORY and UPDATE_TARGET - -=== Assign distribution set to target - -==== Curl - -include::{snippets}/targets/post-assign-distribution-set-to-target/curl-request.adoc[] - -==== Request path parameter - -include::{snippets}/targets/post-assign-distribution-set-to-target/path-parameters.adoc[] - -==== Request query parameter - -include::{snippets}/targets/post-assign-distribution-set-to-target/request-parameters.adoc[] - -==== Request fields - -include::{snippets}/targets/post-assign-distribution-set-to-target/request-fields.adoc[] - -==== Request URL - -include::{snippets}/targets/post-assign-distribution-set-to-target/http-request.adoc[] - -=== Response (Status 200) - -==== Response fields -include::{snippets}/targets/post-assign-distribution-set-to-target/response-fields.adoc[] - -==== Response example - -include::{snippets}/targets/post-assign-distribution-set-to-target/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/404.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/409.adoc[] -include::../errors/415.adoc[] -include::../errors/429.adoc[] -|=== - - -== POST /rest/v1/targets/{targetId}/assignedDS (assign multiple distribution sets) - -=== Implementation Notes - -Handles the POST request for assigning multiple distribution sets to a specific target (only allowed id 'multi assignments' is enabled). Required Permission: READ_REPOSITORY and UPDATE_TARGET - -=== Assign distribution sets to target - -==== Curl - -include::{snippets}/targets/post-assign-distribution-sets-to-target/curl-request.adoc[] - -==== Request path parameter - -include::{snippets}/targets/post-assign-distribution-sets-to-target/path-parameters.adoc[] - -==== Request query parameter - -include::{snippets}/targets/post-assign-distribution-sets-to-target/request-parameters.adoc[] - -==== Request fields - -include::{snippets}/targets/post-assign-distribution-sets-to-target/request-fields.adoc[] - -==== Request URL - -include::{snippets}/targets/post-assign-distribution-sets-to-target/http-request.adoc[] - -=== Response (Status 200) - -==== Response fields -include::{snippets}/targets/post-assign-distribution-sets-to-target/response-fields.adoc[] - -==== Response example - -include::{snippets}/targets/post-assign-distribution-sets-to-target/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400_multiassignment.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/404.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/409.adoc[] -include::../errors/415.adoc[] -include::../errors/429.adoc[] -|=== - - -== GET /rest/v1/targets/{targetId}/attributes - -=== Implementation Notes - -Handles the GET request of retrieving the attributes of a specific target. Reponse is a key/value list. Required Permission: READ_TARGET - -=== Get attributes of target - -==== Curl - -include::{snippets}/targets/get-controller-attributes/curl-request.adoc[] - -==== Request URL - -include::{snippets}/targets/get-controller-attributes/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/targets/get-controller-attributes/path-parameters.adoc[] - -=== Response (Status 200) - -==== Response example - -include::{snippets}/targets/get-controller-attributes/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/404.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/429.adoc[] -|=== - - -== GET /rest/v1/targets/{targetId}/installedDS - -=== Implementation Notes - -Handles the GET request of retrieving the installed distribution set of an specific target. Required Permission: READ_TARGET - -=== Get installed distribution set of target - -==== Curl - -include::{snippets}/targets/get-installed-distribution-set-from-target/curl-request.adoc[] - -==== Request URL - -include::{snippets}/targets/get-installed-distribution-set-from-target/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/targets/get-installed-distribution-set-from-target/path-parameters.adoc[] - -=== Response (Status 200) - -==== Response fields - -include::{snippets}/targets/get-installed-distribution-set-from-target/response-fields.adoc[] - -==== Response example - -include::{snippets}/targets/get-installed-distribution-set-from-target/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/404.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/429.adoc[] -|=== - -== GET /rest/v1/targets/{targetId}/metadata - -=== Implementation Notes - -Get a paged list of meta data for a target. Required permission: READ_REPOSITORY - -=== Get a paged list of meta data - -==== Curl - -include::{snippets}/targets/get-metadata/curl-request.adoc[] - -==== Request URL - -include::{snippets}/targets/get-metadata/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/targets/get-metadata/path-parameters.adoc[] - -==== Request query parameter - -include::{snippets}/targets/get-metadata-with-parameters/request-parameters.adoc[] - -==== Request parameter example - -include::{snippets}/targets/get-metadata-with-parameters/http-request.adoc[] - -=== Response (Status 200) - -==== Response fields - -include::{snippets}/targets/get-metadata/response-fields.adoc[] - -==== Response example - -include::{snippets}/targets/get-metadata/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/429.adoc[] -|=== - -== POST /rest/v1/targets/{targetId}/metadata - -=== Implementation Notes - -Create a list of meta data entries Required permissions: READ_REPOSITORY and UPDATE_TARGET - -=== Create a list of meta data entries - - -==== CURL - -include::{snippets}/targets/create-metadata/curl-request.adoc[] - -==== Request URL - -include::{snippets}/targets/create-metadata/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/targets/create-metadata/path-parameters.adoc[] - -==== Request fields - -include::{snippets}/targets/create-metadata/request-fields.adoc[] - -=== Response (Status 200) - -==== Response example - -include::{snippets}/targets/create-metadata/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/404.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/409.adoc[] -include::../errors/415.adoc[] -include::../errors/429.adoc[] -|=== - - -== DELETE /rest/v1/targets/{targetId}/metadata/{metadataKey} - - -=== Implementation Notes - -Delete a single meta data. Required permission: UPDATE_REPOSITORY - -=== Delete a single meta data - -==== CURL - -include::{snippets}/targets/delete-metadata/curl-request.adoc[] - -==== Request URL - -include::{snippets}/targets/delete-metadata/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/targets/delete-metadata/path-parameters.adoc[] - -=== Response (Status 200) - -==== Response example - -include::{snippets}/targets/delete-metadata/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/404.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/429.adoc[] -|=== - - -== GET /rest/v1/targets/{targetId}/metadata/{metadataKey} - - -=== Implementation Notes - -Get a single meta data value for a meta data key. Required permission: READ_REPOSITORY - -=== Get a single meta data value - -==== Curl - -include::{snippets}/targets/get-metadata-value/curl-request.adoc[] - -==== Request URL - -include::{snippets}/targets/get-metadata-value/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/targets/get-metadata-value/path-parameters.adoc[] - -=== Response (Status 200) - -==== Response fields - -include::{snippets}/targets/get-metadata-value/response-fields.adoc[] - -==== Response example - -include::{snippets}/targets/get-metadata-value/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/429.adoc[] -|=== - -== PUT /rest/v1/targets/{targetId}/metadata/{metadataKey} - - -=== Implementation Notes - -Update a single meta data value for speficic key. Required permission: UPDATE_REPOSITORY - -=== Update a single meta data value - -==== Curl - -include::{snippets}/targets/update-metadata/curl-request.adoc[] - -==== Request URL - -include::{snippets}/targets/update-metadata/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/targets/update-metadata/path-parameters.adoc[] - -==== Request fields - -include::{snippets}/targets/update-metadata/request-fields.adoc[] - -=== Response (Status 200) - -==== Response fields - -include::{snippets}/targets/update-metadata/response-fields.adoc[] - -==== Response example - -include::{snippets}/targets/update-metadata/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/404.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/409.adoc[] -include::../errors/415.adoc[] -include::../errors/429.adoc[] -|=== - -== POST /rest/v1/targets/{targetId}/targettype - -=== Implementation Notes - -Assign or update the target type of a target. Required permission: UPDATE_TARGET - -=== Assign a target type to a target - -==== Curl - -include::{snippets}/targets/post-assign-target-type/curl-request.adoc[] - -==== Request URL - -include::{snippets}/targets/post-assign-target-type/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/targets/post-assign-target-type/path-parameters.adoc[] - -==== Request fields - -include::{snippets}/targets/post-assign-target-type/request-fields.adoc[] - -=== Response (Status 200) - -==== Response example - -include::{snippets}/targets/post-assign-target-type/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/405.adoc[] -include::../errors/429.adoc[] -|=== - -== DELETE /rest/v1/targets/{targetId}/targettype - -=== Implementation Notes - -Remove the target type from a target. The target type will be set to null. Required permission: UPDATE_TARGET - -=== Remove a target type from a target - -==== Curl - -include::{snippets}/targets/delete-unassign-target-type/curl-request.adoc[] - -==== Request URL - -include::{snippets}/targets/delete-unassign-target-type/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/targets/delete-unassign-target-type/path-parameters.adoc[] - -=== Response (Status 200) - -==== Response example - -include::{snippets}/targets/delete-unassign-target-type/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/405.adoc[] -include::../errors/429.adoc[] -|=== - -== Additional content - -[[error-body]] -=== Error body - -include::../errors/error-response-body.adoc[] - - diff --git a/hawkbit-rest/hawkbit-rest-docs/src/main/asciidoc/targettag-api-guide.adoc b/hawkbit-rest/hawkbit-rest-docs/src/main/asciidoc/targettag-api-guide.adoc deleted file mode 100644 index a1a9cfccb7..0000000000 --- a/hawkbit-rest/hawkbit-rest-docs/src/main/asciidoc/targettag-api-guide.adoc +++ /dev/null @@ -1,431 +0,0 @@ -:doctype: book -:icons: font -:source-highlighter: highlightjs -:toc: macro -:toclevels: 1 -:sectlinks: -:linkattrs: - -[[targettag]] -= Target Tag - -toc::[] - - -== GET /rest/v1/targettags - -=== Implementation notes - -Handles the GET request of retrieving all target tags. - -=== Get paged list of target tags - -==== CURL - -include::{snippets}/targettag/get-target-tags/curl-request.adoc[] - -==== Request URL - -A `GET` request is used to access the target tags - -include::{snippets}/targettag/get-target-tags/http-request.adoc[] - -==== Request query parameter - -include::{snippets}/targettag/get-target-tags-with-parameters/request-parameters.adoc[] - -==== Request parameter example - -include::{snippets}/targettag/get-target-tags-with-parameters/http-request.adoc[] - -=== Response (Status 200) - -==== Response fields - -include::{snippets}/targettag/get-target-tags/response-fields.adoc[] - -==== Response example - -include::{snippets}/targettag/get-target-tags/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/429.adoc[] -|=== - - -== GET /rest/v1/targettags/{targetTagId} - -=== Implementation notes - -Handles the GET request of retrieving a single target tag. - -=== Get a single target tag - -==== CURL - -include::{snippets}/targettag/get-target-tag/curl-request.adoc[] - -==== Request URL - -A `GET` request is used to access the target tag - -include::{snippets}/targettag/get-target-tag/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/targettag/get-target-tag/path-parameters.adoc[] - -=== Response (Status 200) - -==== Response fields - -include::{snippets}/targettag/get-target-tag/response-fields.adoc[] - -==== Response example - -include::{snippets}/targettag/get-target-tag/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/429.adoc[] -|=== - - -== POST /rest/v1/targettags - -=== Implementation Notes - -Handles the POST request of creating new target tag. The request body must always be a list of target tags. - -=== Create list of target tags - -==== CURL - -include::{snippets}/targettag/create-target-tags/curl-request.adoc[] - -==== Request URL - -include::{snippets}/targettag/create-target-tags/http-request.adoc[] - -==== Request fields - -include::{snippets}/targettag/create-target-tags/request-fields.adoc[] - -=== Response (Status 201) - -==== Response fields - -include::{snippets}/targettag/create-target-tags/response-fields.adoc[] - -==== Response example - -include::{snippets}/targettag/create-target-tags/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/409.adoc[] -include::../errors/415.adoc[] -include::../errors/429.adoc[] -|=== - -== PUT /rest/v1/targettags/{targetTagId} - -=== Implementation Notes - -Handles the PUT request of updating a target tag. - -=== Update a target tag - -==== Curl - -include::{snippets}/targettag/update-tagret-tag/curl-request.adoc[] - -==== Request URL - -include::{snippets}/targettag/update-tagret-tag/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/targettag/update-tagret-tag/path-parameters.adoc[] - -==== Request fields - -include::{snippets}/targettag/update-tagret-tag/request-fields.adoc[] - -=== Response (Status 200) - -==== Response fields - -include::{snippets}/targettag/update-tagret-tag/response-fields.adoc[] - -==== Response example - -include::{snippets}/targettag/update-tagret-tag/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/404.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/409.adoc[] -include::../errors/415.adoc[] -include::../errors/429.adoc[] -|=== - - -== DELETE /rest/v1/targettags/{targetTagId} - -=== Implementation Notes - -Handles the DELETE request of deleting a single target tag. - -=== Deleting a target tag - -==== CURL - -include::{snippets}/targettag/delete-target-tag/curl-request.adoc[] - -==== Request URL - -include::{snippets}/targettag/delete-target-tag/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/targettag/delete-target-tag/path-parameters.adoc[] - -=== Response (Status 200) - -==== Response example - -include::{snippets}/targettag/delete-target-tag/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/404.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/429.adoc[] -|=== - - -== GET /rest/v1/targettags/{targetTagId}/assigned - -=== Implementation Notes - -Handles the GET request of retrieving a list of assigned targets. - -=== Get a list of assigned targets - -==== CURL - -include::{snippets}/targettag/get-assigned-targets/curl-request.adoc[] - -==== Request URL - -include::{snippets}/targettag/get-assigned-targets/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/targettag/get-assigned-targets/path-parameters.adoc[] - -=== Response (Status 200) - -==== Response fields - -include::{snippets}/targettag/get-assigned-targets/response-fields.adoc[] - -==== Response example - -include::{snippets}/targettag/get-assigned-targets/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/404.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/429.adoc[] -|=== - - -== POST /rest/v1/targettags/{targetTagId}/assigned/toggleTagAssignment - -=== Implementation Notes - -Handles the POST request of toogle target assignment. The request body must always be a list of controller ids. - -=== Toogle target assignment - -==== CURL - -include::{snippets}/targettag/toggle-tag-assignment/curl-request.adoc[] - -==== Request URL - -include::{snippets}/targettag/toggle-tag-assignment/http-request.adoc[] - -==== Request fields - -include::{snippets}/targettag/toggle-tag-assignment/request-fields.adoc[] - -=== Response (Status 200) - -==== Response fields - -include::{snippets}/targettag/toggle-tag-assignment/response-fields.adoc[] - -==== Response example - -include::{snippets}/targettag/toggle-tag-assignment/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/409.adoc[] -include::../errors/415.adoc[] -include::../errors/429.adoc[] -|=== - -== POST /rest/v1/targettags/{targetTagId}/assigned - -=== Implementation Notes - -Handles the POST request of target assignment. Already assigned target will be ignored. - -=== Target assignment - -==== CURL - -include::{snippets}/targettag/assign-targets/curl-request.adoc[] - -==== Request URL - -include::{snippets}/targettag/assign-targets/http-request.adoc[] - -==== Request fields - -include::{snippets}/targettag/assign-targets/request-fields.adoc[] - -=== Response (Status 200) - -==== Response fields - -include::{snippets}/targettag/assign-targets/response-fields.adoc[] - -==== Response example - -include::{snippets}/targettag/assign-targets/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/409.adoc[] -include::../errors/415.adoc[] -include::../errors/429.adoc[] -|=== - -== DELETE /rest/v1/targettags/{targetTagId}/assigned/{controllerId} - -=== Implementation Notes - -Handles the DELETE request to unassign the given target. - -=== Unassign a target - -==== CURL - -include::{snippets}/targettag/unassign-target/curl-request.adoc[] - -==== Request URL - -include::{snippets}/targettag/unassign-target/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/targettag/unassign-target/path-parameters.adoc[] - -=== Response (Status 200) - -==== Response example - -include::{snippets}/targettag/unassign-target/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/404.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/429.adoc[] -|=== - -== Additional content - -[[error-body]] -=== Error body - -include::../errors/error-response-body.adoc[] - - - diff --git a/hawkbit-rest/hawkbit-rest-docs/src/main/asciidoc/targettypes-api-guide.adoc b/hawkbit-rest/hawkbit-rest-docs/src/main/asciidoc/targettypes-api-guide.adoc deleted file mode 100644 index 9534c8fde5..0000000000 --- a/hawkbit-rest/hawkbit-rest-docs/src/main/asciidoc/targettypes-api-guide.adoc +++ /dev/null @@ -1,396 +0,0 @@ -:doctype: book -:icons: font -:source-highlighter: highlightjs -:toc: macro -:toclevels: 1 -:sectlinks: -:linkattrs: - -[[target-types]] -= Target Types - -toc::[] - - -== GET /rest/v1/targettypes - -=== Implementation notes - -Handles the GET request of retrieving all target types within Hawkbit. Required Permission: READ_TARGET - -=== Get target types - -==== CURL - -include::{snippets}/targettypes/get-target-types/curl-request.adoc[] - -==== Request URL - -include::{snippets}/targettypes/get-target-types/http-request.adoc[] - -==== Request query parameter - -include::{snippets}/targettypes/get-target-types-with-parameters/request-parameters.adoc[] - -==== Request parameter example - -include::{snippets}/targettypes/get-target-types-with-parameters/http-request.adoc[] - -=== Response (Status 200) - -==== Response fields - -include::{snippets}/targettypes/get-target-types/response-fields.adoc[] - -==== Response example - -include::{snippets}/targettypes/get-target-types/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/429.adoc[] -|=== - - -== POST /rest/v1/targettypes - -=== Implementation notes - -Handles the POST request for creating new target types within Hawkbit. The request body must always be a list of types. Required Permission: CREATE_TARGET - -=== Create target types - -==== CURL - -include::{snippets}/targettypes/post-target-types/curl-request.adoc[] - -==== Request URL - -include::{snippets}/targettypes/post-target-types/http-request.adoc[] - -==== Request fields - -include::{snippets}/targettypes/post-target-types/request-fields.adoc[] - -=== Response (Status 201) - -==== Response fields - -include::{snippets}/targettypes/post-target-types/response-fields.adoc[] - -==== Response example - -include::{snippets}/targettypes/post-target-types/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -| `404 Not Found` -| Target type was not found. -| See <> -include::../errors/405.adoc[] -include::../errors/406.adoc[] -| `409 Conflict` -| Target type already exists -| See <> -include::../errors/415.adoc[] -include::../errors/429.adoc[] -|=== - - -== DELETE /rest/v1/targettypes/{targetTypeId} - -=== Implementation Notes - -Handles the DELETE request for a single target type within Hawkbit. Required Permission: DELETE_TARGET - -=== Delete target type - -==== CURL - -include::{snippets}/targettypes/delete-target-type/curl-request.adoc[] - -==== Request URL - -include::{snippets}/targettypes/delete-target-type/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/targettypes/delete-target-type/path-parameters.adoc[] - -=== Response (Status 200) - -==== Response example - -include::{snippets}/targettypes/delete-target-type/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -| `404 Not Found` -| Target type was not found. -| See <> -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/429.adoc[] -|=== - - -== GET /rest/v1/targettypes/{targetTypeId} - -=== Implementation notes - -Handles the GET request of retrieving a single target type within Hawkbit. Required Permission: READ_TARGET - -=== Get target type - -==== CURL - -include::{snippets}/targettypes/get-target-type/curl-request.adoc[] - -==== Request URL - -include::{snippets}/targettypes/get-target-type/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/targettypes/get-target-type/path-parameters.adoc[] - -=== Response (Status 200) - -==== Response fields - -include::{snippets}/targettypes/get-target-type/response-fields.adoc[] - -==== Response example - -include::{snippets}/targettypes/get-target-type/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -| `404 Not Found` -| Target type was not found. -| See <> -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/429.adoc[] -|=== - - -== PUT /rest/v1/targettypes/{targetTypeId} - -=== Implementation notes - -Handles the PUT request for a single target type within Hawkbit. Required Permission: UPDATE_TARGET - -=== Update target type - -==== CURL - -include::{snippets}/targettypes/put-target-type/curl-request.adoc[] - -==== Request URL - -include::{snippets}/targettypes/put-target-type/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/targettypes/put-target-type/path-parameters.adoc[] - -==== Request fields - -include::{snippets}/targettypes/put-target-type/request-fields.adoc[] - -=== Response (Status 200) - -==== Response fields - -include::{snippets}/targettypes/put-target-type/response-fields.adoc[] - -==== Response example - -include::{snippets}/targettypes/put-target-type/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -| `404 Not Found` -| Target type was not found. -| See <> -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/409.adoc[] -include::../errors/415.adoc[] -include::../errors/429.adoc[] -|=== - - -== GET /rest/v1/targettypes/{targetTypeId}/compatibledistributionsettypes - -=== Implementation notes - -Handles the GET request of retrieving the list of compatible distribution set types in that target type. Required Permission: READ_TARGET, READ_REPOSITORY - -=== Lists all compatible distribution set types - -==== CURL - -include::{snippets}/targettypes/get-compatible-distribution-set-types/curl-request.adoc[] - -==== Request URL - -include::{snippets}/targettypes/get-compatible-distribution-set-types/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/targettypes/get-compatible-distribution-set-types/path-parameters.adoc[] - -=== Response (Status 200) - -==== Response fields - -include::{snippets}/targettypes/get-compatible-distribution-set-types/response-fields.adoc[] - -==== Response example - -include::{snippets}/targettypes/get-compatible-distribution-set-types/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -| `404 Not Found` -| Distribution set type was not found. -| See <> -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/429.adoc[] -|=== - - -== POST /rest/v1/targettypes/{targetTypeId}/compatibledistributionsettypes - -=== Implementation notes - -Handles the POST request for adding compatible distribution set types to a target type. Required Permission: UPDATE_TARGET and READ_REPOSITORY - -=== Add compatible distribution set type - -==== CURL - -include::{snippets}/targettypes/post-compatible-distribution-set-types/curl-request.adoc[] - -==== Request URL - -include::{snippets}/targettypes/post-compatible-distribution-set-types/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/targettypes/post-compatible-distribution-set-types/path-parameters.adoc[] - -==== Request fields - -include::{snippets}/targettypes/post-compatible-distribution-set-types/request-fields.adoc[] - -=== Response (Status 201) - -==== Response example - -include::{snippets}/targettypes/post-compatible-distribution-set-types/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -| `404 Not Found` -| Distribution set type was not found. -| See <> -include::../errors/405.adoc[] -include::../errors/406.adoc[] -| `409 Conflict` -| Distribution set type already exists -| See <> -include::../errors/415.adoc[] -include::../errors/429.adoc[] -|=== - - -== DELETE /rest/v1/targettypes/{targetTypeId}/compatibledistributionsettypes/{distributionSetTypeId} - -=== Implementation Notes - -Handles the DELETE request for removing a distribution set type from a single target type. Required Permission: UPDATE_TARGET and READ_REPOSITORY - -=== Remove compatible distribution set type from target type - -==== CURL - -include::{snippets}/targettypes/delete-compatible-distribution-set-type/curl-request.adoc[] - -==== Request URL - -include::{snippets}/targettypes/delete-compatible-distribution-set-type/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/targettypes/delete-compatible-distribution-set-type/path-parameters.adoc[] - -=== Response (Status 200) - -==== Response example - -include::{snippets}/targettypes/delete-compatible-distribution-set-type/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -| `404 Not Found` -| Distribution set type was not found. -| See <> -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/429.adoc[] -|=== - diff --git a/hawkbit-rest/hawkbit-rest-docs/src/main/asciidoc/tenant-api-guide.adoc b/hawkbit-rest/hawkbit-rest-docs/src/main/asciidoc/tenant-api-guide.adoc deleted file mode 100644 index 6bc35a9484..0000000000 --- a/hawkbit-rest/hawkbit-rest-docs/src/main/asciidoc/tenant-api-guide.adoc +++ /dev/null @@ -1,194 +0,0 @@ -:doctype: book -:icons: font -:source-highlighter: highlightjs -:toc: macro -:toclevels: 1 -:sectlinks: -:linkattrs: - -[[tenant]] -= System Configuration - -toc::[] - - -== GET /rest/v1/system/configs - -=== Implementation notes - -The GET request returns a list of all possible configuration keys for the tenant. Required Permission: TENANT_CONFIGURATION - -=== Get all configuration parameters - -==== CURL - -include::{snippets}/tenant/get-tenant-configrations/curl-request.adoc[] - -==== Request URL - -include::{snippets}/tenant/get-tenant-configrations/http-request.adoc[] - -=== Response (Status 200) - -==== Response fields - -include::{snippets}/tenant/get-tenant-configrations/response-fields.adoc[] - -==== Response example - -include::{snippets}/tenant/get-tenant-configrations/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/404.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/429.adoc[] -|=== - -== GET /rest/v1/system/configs/{keyName} - -=== Implementation notes - -The GET request returns the configuration value of a specific configuration key for the tenant. Required Permission: TENANT_CONFIGURATION - -=== Read a configuration parameter - -==== CURL - -include::{snippets}/tenant/get-tenant-configration/curl-request.adoc[] - -==== Request URL - -include::{snippets}/tenant/get-tenant-configration/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/tenant/get-tenant-configration/path-parameters.adoc[] - -=== Response (Status 200) - -==== Response fields - -include::{snippets}/tenant/get-tenant-configration/response-fields.adoc[] - -==== Response example - -include::{snippets}/tenant/get-tenant-configration/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/404.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/429.adoc[] -|=== - -== PUT /rest/v1/system/configs/{keyName} - -=== Implementation notes - -The PUT request changes a configuration value of a specific configuration key for the tenant. Required Permission: TENANT_CONFIGURATION - -=== Change a configuration parameter - -==== CURL - -include::{snippets}/tenant/put-tenant-configration/curl-request.adoc[] - -==== Request URL - -include::{snippets}/tenant/put-tenant-configration/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/tenant/put-tenant-configration/path-parameters.adoc[] - -==== Request fields - -include::{snippets}/tenant/put-tenant-configration/request-fields.adoc[] - -=== Response (Status 200) - -==== Response fields - -include::{snippets}/tenant/put-tenant-configration/response-fields.adoc[] - -==== Response example - -include::{snippets}/tenant/put-tenant-configration/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/404.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/409.adoc[] -include::../errors/415.adoc[] -include::../errors/429.adoc[] -|=== - -== DELETE /rest/v1/system/configs/{keyName} - -=== Implementation notes - -The DELETE request removes a tenant specific configuration value for the tenant. Afterwards the global default value is used. Required Permission: TENANT_CONFIGURATION - -=== Removes a configuration parameter - -==== CURL - -include::{snippets}/tenant/delete-tenant-configration/curl-request.adoc[] - -==== Request URL - -include::{snippets}/tenant/delete-tenant-configration/http-request.adoc[] - -==== Request path parameter - -include::{snippets}/tenant/delete-tenant-configration/path-parameters.adoc[] - -=== Response (Status 204) - -==== Response example - -include::{snippets}/tenant/delete-tenant-configration/http-response.adoc[] - -=== Error responses - -|=== -| HTTP Status Code | Reason | Response Model - -include::../errors/400.adoc[] -include::../errors/401.adoc[] -include::../errors/403.adoc[] -include::../errors/404.adoc[] -include::../errors/405.adoc[] -include::../errors/406.adoc[] -include::../errors/429.adoc[] -|=== - -== Additional content - -[[error-body]] -=== Error body - -include::../errors/error-response-body.adoc[] diff --git a/hawkbit-rest/hawkbit-rest-docs/src/main/errors/400.adoc b/hawkbit-rest/hawkbit-rest-docs/src/main/errors/400.adoc deleted file mode 100644 index 18af7627b2..0000000000 --- a/hawkbit-rest/hawkbit-rest-docs/src/main/errors/400.adoc +++ /dev/null @@ -1,3 +0,0 @@ -| `400 Bad Request` -| Bad Request - e.g. invalid parameters -| diff --git a/hawkbit-rest/hawkbit-rest-docs/src/main/errors/400_multiassignment.adoc b/hawkbit-rest/hawkbit-rest-docs/src/main/errors/400_multiassignment.adoc deleted file mode 100644 index e502b8fbea..0000000000 --- a/hawkbit-rest/hawkbit-rest-docs/src/main/errors/400_multiassignment.adoc +++ /dev/null @@ -1,3 +0,0 @@ -| `400 Bad Request` -| Bad Request - e.g. invalid parameters or 'multi assignments' is disabled -| diff --git a/hawkbit-rest/hawkbit-rest-docs/src/main/errors/401.adoc b/hawkbit-rest/hawkbit-rest-docs/src/main/errors/401.adoc deleted file mode 100644 index bfe5050c9b..0000000000 --- a/hawkbit-rest/hawkbit-rest-docs/src/main/errors/401.adoc +++ /dev/null @@ -1,3 +0,0 @@ -| `401 Unauthorized` -| The request requires user authentication. -| diff --git a/hawkbit-rest/hawkbit-rest-docs/src/main/errors/403.adoc b/hawkbit-rest/hawkbit-rest-docs/src/main/errors/403.adoc deleted file mode 100644 index 492f5a7226..0000000000 --- a/hawkbit-rest/hawkbit-rest-docs/src/main/errors/403.adoc +++ /dev/null @@ -1,3 +0,0 @@ -| `403 Forbidden` -| Insufficient permissions, entity is not allowed to be changed (i.e. read-only) or data volume restriction applies. -| See <> diff --git a/hawkbit-rest/hawkbit-rest-docs/src/main/errors/403_quota.adoc b/hawkbit-rest/hawkbit-rest-docs/src/main/errors/403_quota.adoc deleted file mode 100644 index 1a817026b9..0000000000 --- a/hawkbit-rest/hawkbit-rest-docs/src/main/errors/403_quota.adoc +++ /dev/null @@ -1,3 +0,0 @@ -| `403 Forbidden` -| Insufficient permissions, data volume restriction applies or quota limit exceeded. -| See <> diff --git a/hawkbit-rest/hawkbit-rest-docs/src/main/errors/404.adoc b/hawkbit-rest/hawkbit-rest-docs/src/main/errors/404.adoc deleted file mode 100644 index 85bf3f9b77..0000000000 --- a/hawkbit-rest/hawkbit-rest-docs/src/main/errors/404.adoc +++ /dev/null @@ -1,3 +0,0 @@ -| `404 Not Found` -| Target not found. -| See <> diff --git a/hawkbit-rest/hawkbit-rest-docs/src/main/errors/404_target_action.adoc b/hawkbit-rest/hawkbit-rest-docs/src/main/errors/404_target_action.adoc deleted file mode 100644 index 29f11470fa..0000000000 --- a/hawkbit-rest/hawkbit-rest-docs/src/main/errors/404_target_action.adoc +++ /dev/null @@ -1,3 +0,0 @@ -| `404 Not Found` -| Target or Action not found. -| See <> diff --git a/hawkbit-rest/hawkbit-rest-docs/src/main/errors/405.adoc b/hawkbit-rest/hawkbit-rest-docs/src/main/errors/405.adoc deleted file mode 100644 index 01159992be..0000000000 --- a/hawkbit-rest/hawkbit-rest-docs/src/main/errors/405.adoc +++ /dev/null @@ -1,3 +0,0 @@ -| `405 Method Not Allowed` -| The http request method is not allowed on the resource. -| diff --git a/hawkbit-rest/hawkbit-rest-docs/src/main/errors/406.adoc b/hawkbit-rest/hawkbit-rest-docs/src/main/errors/406.adoc deleted file mode 100644 index 8a3dc60b7b..0000000000 --- a/hawkbit-rest/hawkbit-rest-docs/src/main/errors/406.adoc +++ /dev/null @@ -1,3 +0,0 @@ -| `406 Not Acceptable` -| In case accept header is specified and not application/json. -| diff --git a/hawkbit-rest/hawkbit-rest-docs/src/main/errors/409.adoc b/hawkbit-rest/hawkbit-rest-docs/src/main/errors/409.adoc deleted file mode 100644 index 363b0e04de..0000000000 --- a/hawkbit-rest/hawkbit-rest-docs/src/main/errors/409.adoc +++ /dev/null @@ -1,3 +0,0 @@ -| `409 Conflict` -| E.g. in case an entity is created or modified by another user in another request at the same time. You may retry your modification request. -| See <> diff --git a/hawkbit-rest/hawkbit-rest-docs/src/main/errors/410.adoc b/hawkbit-rest/hawkbit-rest-docs/src/main/errors/410.adoc deleted file mode 100644 index e32d136798..0000000000 --- a/hawkbit-rest/hawkbit-rest-docs/src/main/errors/410.adoc +++ /dev/null @@ -1,2 +0,0 @@ -| `410 Gone` -| Action is not active anymore. diff --git a/hawkbit-rest/hawkbit-rest-docs/src/main/errors/415.adoc b/hawkbit-rest/hawkbit-rest-docs/src/main/errors/415.adoc deleted file mode 100644 index 5a993596d6..0000000000 --- a/hawkbit-rest/hawkbit-rest-docs/src/main/errors/415.adoc +++ /dev/null @@ -1,3 +0,0 @@ -| `415 Unsupported Media Type` -| The request was attempt with a media-type which is not supported by the server for this resource. -| diff --git a/hawkbit-rest/hawkbit-rest-docs/src/main/errors/429.adoc b/hawkbit-rest/hawkbit-rest-docs/src/main/errors/429.adoc deleted file mode 100644 index c215b43deb..0000000000 --- a/hawkbit-rest/hawkbit-rest-docs/src/main/errors/429.adoc +++ /dev/null @@ -1,3 +0,0 @@ -| `429 Too Many Request` -| Too many requests. The server will refuse further attempts and the client has to wait another second. -| diff --git a/hawkbit-rest/hawkbit-rest-docs/src/main/errors/error-response-body.adoc b/hawkbit-rest/hawkbit-rest-docs/src/main/errors/error-response-body.adoc deleted file mode 100644 index a842b56fb4..0000000000 --- a/hawkbit-rest/hawkbit-rest-docs/src/main/errors/error-response-body.adoc +++ /dev/null @@ -1,27 +0,0 @@ -[source,http] ----- - -{ - "errorCode": "string", - "exceptionClass": "string", - "message": "string", - "parameters": [ - "string" - ] -} - ----- - -=== Field description - -|=== -|**Field** |**Description** -| errorCode -| A error code/key set by server -| exceptionClass -| The involved exceptionClass -| message -| An error message set by the server -| parameters -| A list of parameters -|=== diff --git a/hawkbit-rest/hawkbit-rest-docs/src/main/template/template.adoc b/hawkbit-rest/hawkbit-rest-docs/src/main/template/template.adoc deleted file mode 100644 index 13d600c0f0..0000000000 --- a/hawkbit-rest/hawkbit-rest-docs/src/main/template/template.adoc +++ /dev/null @@ -1,64 +0,0 @@ -= Management API -Eclipse hawkBit; -:doctype: book -:icons: font -:source-highlighter: highlightjs -:toc: macro -:toclevels: 1 -:sectlinks: -:linkattrs: - -[[resource-name]] -= Resource name - -toc::[] - - -== The request: Example: GET /rest/v1/targets - -=== Implementation notes - -..... Implementation notes ..... -..... Implementation notes ..... - -=== Describe the request: Example: Get paged list of targets - -==== CURL - -include::{snippets}/ ... ...curl-request.adoc[] - -==== Request URL - -include::{snippets}/... ...http-request.adoc[] - -==== Request path parameter - -include::{snippets}/ ... ...path-parameters.adoc[] - -==== Request fields - -include::{snippets}/ ... ...request-fields.adoc[] - -==== Request query parameter - -include::{snippets}/ ... ...with-parameters/request-parameters.adoc[] - -==== Request parameter example - -include::{snippets}/ ... ...with-parameters/http-request.adoc[] - -=== Response (Status 200) - -==== Response fields - -include::{snippets}/ ... ...response-fields.adoc[] - -==== Response example - -include::{snippets}/ ... ...http-response.adoc[] - -=== Error responses - -include::../errors/... -include::../errors/... -... \ No newline at end of file diff --git a/hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/ddi/documentation/DdiApiModelProperties.java b/hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/ddi/documentation/DdiApiModelProperties.java deleted file mode 100644 index 291b44563d..0000000000 --- a/hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/ddi/documentation/DdiApiModelProperties.java +++ /dev/null @@ -1,168 +0,0 @@ -/** - * Copyright (c) 2018 Bosch Software Innovations GmbH and others - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - */ -package org.eclipse.hawkbit.rest.ddi.documentation; - -/** - * Model properties for the DDI API documentation. - */ -final class DdiApiModelProperties { - - // Direct Device Integration API - static final String CONTROLLER_ID = "id of the controller"; - - static final String TARGET_STATUS = "target action status"; - - static final String TARGET_EXEC_STATUS = "status of the action execution"; - - static final String TARGET_EXEC_STATUS_CODE = "optional individual status code"; - - static final String TARGET_RESULT_VALUE = "result of the action execution"; - - static final String TARGET_RESULT_DETAILS = "List of details message information"; - - static final String TARGET_RESULT_FINISHED = "defined status of the result"; - - static final String TARGET_RESULT_PROGRESS = "progress assumption of the device (currently not supported)."; - - static final String TARGET_PROGRESS_CNT = "current progress level"; - - static final String TARGET_PROGRESS_OF = "assumption concerning max progress level"; - - static final String ACTION_ID = "id of the action"; - - static final String FEEDBACK_ACTION_ID = "(@deprecated) id of the action"; - - static final String FEEDBACK_ACTION_TIME = "timestamp of the action"; - - static final String CANCEL_ACTION = "action that needs to be canceled"; - - static final String ACTION_ID_CANCELED = "id of the action that needs to be canceled (typically identical to id field on the cancel action itself)"; - - static final String ARTIFACT_HTTPS_HASHES_MD5SUM_LINK = "HTTPs Download resource for MD5SUM file is an optional auto generated artifact that is especially useful for " - + "Linux based devices on order to check artifact consistency after download by using the md5sum " - + "command line tool. The MD5 and SHA1 are in addition available as metadata in the deployment command itself."; - - static final String ARTIFACT_HTTP_HASHES_MD5SUM_LINK = "HTTP Download resource for MD5SUM file is an optional auto generated artifact that is especially useful for " - + "Linux based devices on order to check artifact consistency after download by using the md5sum " - + "command line tool. The MD5 and SHA1 are in addition available as metadata in the deployment command itself. " - + "(note: anonymous download needs to be enabled on the service account for non-TLS access)"; - - static final String ARTIFACT_HTTPS_DOWNLOAD_LINK_BY_CONTROLLER = "HTTPs Download resource for artifacts. The resource supports partial download " - + "as specified by RFC7233 (range requests). Keep in mind that the target " - + "needs to have the artifact assigned in order to be granted permission to download."; - - static final String ARTIFACT_HTTP_DOWNLOAD_LINK_BY_CONTROLLER = "HTTP Download resource for artifacts. The resource supports partial download " - + "as specified by RFC7233 (range requests). Keep in mind that the target " - + "needs to have the artifact assigned in order to be granted permission to download. " - + "(note: anonymous download needs to be enabled on the service account for non-TLS access)"; - - static final String CHUNK_TYPE = "Type of the chunk, e.g. firmware, bundle, app. In update server mapped to Software Module Type."; - - static final String SOFTWARE_MODULE_TYPE = "type of the software module, e.g. firmware, bundle, app"; - - static final String SOFTWARE_MODULE_VERSION = "version of the software module"; - - static final String SOFTWARE_MODULE_NAME = "name of the software module"; - - static final String SOFTWARE_MODULE_ARTIFACT_LINKS = "artifact links of the software module"; - - static final String SOFTWARE_MODULE_ID = "id of the software module"; - - static final String CHUNK_VERSION = "software version of the chunk"; - - static final String CHUNK_NAME = "name of the chunk"; - - static final String CHUNK_META_DATA = "meta data of the respective software module that has been marked with 'target visible'"; - - static final String CHUNK_META_DATA_KEY = "key of meta data entry"; - - static final String CHUNK_META_DATA_VALUE = "value of meta data entry"; - - static final String ARTIFACTS = "list of artifacts"; - - static final String TARGET_CONFIGURATION = "target configuration setup by the server"; - - static final String TARGET_POLL_TIME = "suggested sleep time between polls"; - - static final String TARGET_OPEN_ACTIONS = "Open Actions that the server has for the target"; - - static final String TARGET_SLEEP = "sleep time in HH:MM:SS notation"; - - static final String DEPLOYMENT = "Detailed deployment operation"; - - static final String CONFIRMATION = "Deployment confirmation operation"; - - static final String CANCEL = "Detailed cancel operation of a deployment"; - - static final String INSTALLED = "Detailed operation of last successfully finished action"; - - static final String HANDLING_DOWNLOAD = "handling for the download part of the provisioning process ('skip': do not download yet, 'attempt': server asks to download, 'forced': server requests immediate download)"; - - static final String HANDLING_UPDATE = "handling for the update part of the provisioning process ('skip': do not update yet, 'attempt': server asks to update, 'forced': server requests immediate update)"; - - static final String MAINTENANCE_WINDOW = "separation of download and installation by defining a maintenance window for the installation. Status shows if currently in a window."; - - static final String CHUNK = "Software chunks of an update. In server mapped by Software Module."; - - static final String SOFTWARE_MODULE = "software modules of an update"; - - static final String ARTIFACT = "artifact modules of an update"; - - static final String FILENAME = "file name of artifact"; - - static final String TARGET_CONFIG_DATA = "Link which is provided whenever the provisioning target or device is supposed " - + "to push its configuration data (aka. \"controller attributes\") to the server. Only shown for the initial " - + "configuration, after a successful update action, or if requested explicitly (e.g. via the management UI)."; - - static final String ARTIFACT_HASHES_SHA1 = "SHA1 hash of the artifact in Base 16 format"; - static final String ARTIFACT_HASHES_MD5 = "MD5 hash of the artifact"; - static final String ARTIFACT_HASHES_SHA256 = "SHA-256 hash of the artifact in Base 16 format"; - - static final String ARTIFACT_SIZE = "size of the artifact"; - - static final String ACTION_HISTORY = "Optional GET parameter to retrieve a given number of messages which are previously provided by the device. " - + "Useful if the devices sent state information to the feedback channel and never stored them locally."; - - static final String ACTION_HISTORY_RESP = "Current deployment state."; - - static final String ACTION_HISTORY_RESP_STATUS = "Status of the deployment based on previous feedback by the device."; - - static final String ACTION_HISTORY_RESP_MESSAGES = "Messages are previously sent to the feedback channel in LIFO order by the device. " - + "Note: The first status message is set by the system and describes the trigger of the deployment"; - - static final String UPDATE_MODE = "Optional parameter to specify the update mode that should be applied when updating target attributes. " - + "Valid values are 'merge', 'replace', and 'remove'. Defaults to 'merge'."; - - static final String TARGET_CONFIRMATION_STATE = "action confirmation state"; - - static final String TARGET_CONFIRMATION_CODE = "optional individual status code"; - - static final String TARGET_CONFIRMATION_DETAILS = "List of detailed message information"; - - static final String TARGET_AUTO_CONFIRM = "id of the action"; - - static final String TARGET_AUTO_CONFIRM_STATE = "flag if auto confirm is active"; - - static final String TARGET_AUTO_CONFIRM_INITIATOR_RESPONSE = "(optional) initiator set on activation"; - - static final String TARGET_AUTO_CONFIRM_REMARK_RESPONSE = "(optional) remark set on activation"; - - static final String TARGET_AUTO_CONFIRM_ACTIVATED_AT = "timestamp of the activation"; - - static final String TARGET_AUTO_CONFIRM_REFERENCE_ACTIVATE_AUTO_CONFIRM = "reference link to activate auto confirm"; - - static final String TARGET_AUTO_CONFIRM_REFERENCE_DEACTIVATE_AUTO_CONFIRM = "reference link to deactivate auto confirm"; - - static final String TARGET_AUTO_CONFIRM_REFERENCE_CONFIRMATION_BASE_ACTION = "reference link in case an action with open confirmation is present"; - - static final String TARGET_AUTO_CONFIRM_ACTIVATE_INITIATOR = "individual value (e.g. username) stored as initiator and automatically used as confirmed user in future actions"; - static final String TARGET_AUTO_CONFIRM_ACTIVATE_REMARK = "individual value to attach a remark which will be persisted when automatically confirming future actions"; - -} diff --git a/hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/ddi/documentation/RootControllerDocumentationTest.java b/hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/ddi/documentation/RootControllerDocumentationTest.java deleted file mode 100644 index 49ca8f569f..0000000000 --- a/hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/ddi/documentation/RootControllerDocumentationTest.java +++ /dev/null @@ -1,815 +0,0 @@ -/** - * Copyright (c) 2018 Bosch Software Innovations GmbH and others - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - */ -package org.eclipse.hawkbit.rest.ddi.documentation; - -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.post; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.put; -import static org.springframework.restdocs.payload.PayloadDocumentation.requestFields; -import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields; -import static org.springframework.restdocs.request.RequestDocumentation.parameterWithName; -import static org.springframework.restdocs.request.RequestDocumentation.pathParameters; -import static org.springframework.restdocs.request.RequestDocumentation.requestParameters; -import static org.springframework.restdocs.snippet.Attributes.key; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - -import java.io.ByteArrayInputStream; -import java.time.Instant; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.apache.commons.lang3.RandomStringUtils; -import org.eclipse.hawkbit.ddi.json.model.DdiActionFeedback; -import org.eclipse.hawkbit.ddi.json.model.DdiActivateAutoConfirmation; -import org.eclipse.hawkbit.ddi.json.model.DdiConfirmationFeedback; -import org.eclipse.hawkbit.ddi.json.model.DdiProgress; -import org.eclipse.hawkbit.ddi.json.model.DdiResult; -import org.eclipse.hawkbit.ddi.json.model.DdiStatus; -import org.eclipse.hawkbit.ddi.rest.api.DdiRestConstants; -import org.eclipse.hawkbit.repository.model.Action; -import org.eclipse.hawkbit.repository.model.Action.Status; -import org.eclipse.hawkbit.repository.model.ArtifactUpload; -import org.eclipse.hawkbit.repository.model.DistributionSet; -import org.eclipse.hawkbit.repository.model.SoftwareModule; -import org.eclipse.hawkbit.repository.model.Target; -import org.eclipse.hawkbit.repository.test.util.WithUser; -import org.eclipse.hawkbit.rest.documentation.AbstractApiRestDocumentation; -import org.eclipse.hawkbit.rest.documentation.ApiModelPropertiesGeneric; -import org.eclipse.hawkbit.rest.util.JsonBuilder; -import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.springframework.hateoas.MediaTypes; -import org.springframework.http.MediaType; -import org.springframework.restdocs.payload.JsonFieldType; - -import io.qameta.allure.Description; -import io.qameta.allure.Feature; -import io.qameta.allure.Story; - -/** - * Documentation generation for Direct Device Integration API. - * - */ -@Feature("Documentation Verification - Direct Device Integration API") -@Story("Root Resource") -public class RootControllerDocumentationTest extends AbstractApiRestDocumentation { - private static final String CONTROLLER_ID = "CONTROLLER_ID"; - - @Override - public String getResourceName() { - return "rootcontroller"; - } - - @BeforeEach - public void setUp() { - host = "ddi-api.host"; - } - - @Test - @Description("This base resource can be regularly polled by the controller on the provisioning target or device " - + "in order to retrieve actions that need to be executed. In this case including a config pull request and a deployment. " - + "The resource supports Etag based modification checks in order to save traffic.") - @WithUser(tenantId = "TENANT_ID", authorities = "ROLE_CONTROLLER", allSpPermissions = true) - public void getControllerBaseWithOpenDeplyoment() throws Exception { - final Action actionZero = prepareFinishedUpdate(CONTROLLER_ID, "zero", false); - final String controllerId = actionZero.getTarget().getControllerId(); - - final DistributionSet set = testdataFactory.createDistributionSet("one"); - assignDistributionSet(set.getId(), controllerId); - - mockMvc.perform(get(DdiRestConstants.BASE_V1_REQUEST_MAPPING + "/{controllerId}", - tenantAware.getCurrentTenant(), controllerId).accept(MediaTypes.HAL_JSON_VALUE)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaTypes.HAL_JSON)) - .andDo(this.document.document( - pathParameters(parameterWithName("tenant").description(ApiModelPropertiesGeneric.TENANT), - parameterWithName("controllerId").description(DdiApiModelProperties.CONTROLLER_ID)), - responseFields( - fieldWithPath("config.polling").description(DdiApiModelProperties.TARGET_POLL_TIME), - fieldWithPath("config.polling.sleep").description(DdiApiModelProperties.TARGET_SLEEP), - fieldWithPath("_links").description(DdiApiModelProperties.TARGET_OPEN_ACTIONS), - fieldWithPath("_links.deploymentBase").description(DdiApiModelProperties.DEPLOYMENT), - fieldWithPath("_links.installedBase").description(DdiApiModelProperties.INSTALLED), - fieldWithPath("_links.configData") - .description(DdiApiModelProperties.TARGET_CONFIG_DATA)))); - } - - @Test - @Description("This base resource can be regularly polled by the controller on the provisioning target or device " - + "in order to retrieve actions that need to be executed. In this case including a config pull request and a cancellation. " - + "Note: as with deployments the cancel action has to be confirmed or rejected in order to move on to the next action.") - @WithUser(tenantId = "TENANT_ID", authorities = "ROLE_CONTROLLER", allSpPermissions = true) - public void getControllerBaseWithOpenDeploymentCancellation() throws Exception { - final Action actionZero = prepareFinishedUpdate(CONTROLLER_ID, "zero", false); - final String controllerId = actionZero.getTarget().getControllerId(); - - final DistributionSet set = testdataFactory.createDistributionSet("one"); - final DistributionSet setTwo = testdataFactory.createDistributionSet("two"); - - assignDistributionSet(set.getId(), controllerId); - assignDistributionSet(setTwo.getId(), controllerId); - - mockMvc.perform(get(DdiRestConstants.BASE_V1_REQUEST_MAPPING + "/{controllerId}", - tenantAware.getCurrentTenant(), controllerId).accept(MediaTypes.HAL_JSON_VALUE)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaTypes.HAL_JSON)) - .andDo(this.document.document( - pathParameters(parameterWithName("tenant").description(ApiModelPropertiesGeneric.TENANT), - parameterWithName("controllerId").description(DdiApiModelProperties.CONTROLLER_ID)), - responseFields( - fieldWithPath("config.polling").description(DdiApiModelProperties.TARGET_POLL_TIME), - fieldWithPath("config.polling.sleep").description(DdiApiModelProperties.TARGET_SLEEP), - fieldWithPath("_links").description(DdiApiModelProperties.TARGET_OPEN_ACTIONS), - fieldWithPath("_links.cancelAction").description(DdiApiModelProperties.CANCEL), - fieldWithPath("_links.installedBase").description(DdiApiModelProperties.INSTALLED), - fieldWithPath("_links.configData") - .description(DdiApiModelProperties.TARGET_CONFIG_DATA)))); - } - - @Test - @Description("The SP server might cancel an operation, e.g. an unfinished update has a successor. " - + "It is up to the provisioning target to decide either to accept the cancellation or reject it.") - @WithUser(tenantId = "TENANT_ID", authorities = "ROLE_CONTROLLER", allSpPermissions = true) - public void getControllerCancelAction() throws Exception { - final DistributionSet set = testdataFactory.createDistributionSet("one"); - - set.getModules().forEach(module -> { - final byte[] random = RandomStringUtils.random(5).getBytes(); - - artifactManagement.create( - new ArtifactUpload(new ByteArrayInputStream(random), module.getId(), "binary.tgz", false, 0)); - artifactManagement.create( - new ArtifactUpload(new ByteArrayInputStream(random), module.getId(), "file.signature", false, 0)); - }); - - final Target target = targetManagement.create(entityFactory.target().create().controllerId(CONTROLLER_ID)); - final Long actionId = getFirstAssignedActionId(assignDistributionSet(set.getId(), target.getControllerId())); - final Action cancelAction = deploymentManagement.cancelAction(actionId); - - mockMvc.perform( - get(DdiRestConstants.BASE_V1_REQUEST_MAPPING + "/{controllerId}/" + DdiRestConstants.CANCEL_ACTION - + "/{actionId}", tenantAware.getCurrentTenant(), target.getControllerId(), cancelAction.getId()) - .accept(MediaTypes.HAL_JSON_VALUE)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaTypes.HAL_JSON)) - .andDo(this.document.document( - pathParameters(parameterWithName("tenant").description(ApiModelPropertiesGeneric.TENANT), - parameterWithName("controllerId").description(DdiApiModelProperties.CONTROLLER_ID), - parameterWithName("actionId").description(DdiApiModelProperties.ACTION_ID_CANCELED)), - - responseFields(fieldWithPath("id").description(DdiApiModelProperties.ACTION_ID), - fieldWithPath("cancelAction").description(DdiApiModelProperties.CANCEL_ACTION), - fieldWithPath("cancelAction.stopId") - .description(DdiApiModelProperties.ACTION_ID_CANCELED) - - ))); - } - - @Test - @Description("It is up to the device to decided how much intermediate feedback is " - + "provided. However, the action will be kept open until the controller on the device reports a " - + "finished (either successful or error) or rejects the operation, e.g. the canceled actions have been started already.") - @WithUser(tenantId = "TENANT_ID", authorities = "ROLE_CONTROLLER", allSpPermissions = true) - public void postCancelActionFeedback() throws Exception { - final DistributionSet set = testdataFactory.createDistributionSet("one"); - - final Target target = targetManagement.create(entityFactory.target().create().controllerId(CONTROLLER_ID)); - final Long actionId = getFirstAssignedActionId(assignDistributionSet(set.getId(), target.getControllerId())); - final Action cancelAction = deploymentManagement.cancelAction(actionId); - - final DdiStatus ddiStatus = new DdiStatus(DdiStatus.ExecutionStatus.CLOSED, - new DdiResult(DdiResult.FinalResult.SUCCESS, new DdiProgress(2, 5)), null, List.of("Some feedback")); - final DdiActionFeedback feedback = new DdiActionFeedback(Instant.now().toString(), ddiStatus); - - mockMvc.perform(post( - DdiRestConstants.BASE_V1_REQUEST_MAPPING + "/{controllerId}/" + DdiRestConstants.CANCEL_ACTION - + "/{actionId}/feedback", - tenantAware.getCurrentTenant(), target.getControllerId(), cancelAction.getId()) - .content(objectMapper.writeValueAsString(feedback)) - .contentType(MediaType.APPLICATION_JSON_UTF8)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andDo(this.document.document( - pathParameters(parameterWithName("tenant").description(ApiModelPropertiesGeneric.TENANT), - parameterWithName("controllerId").description(DdiApiModelProperties.CONTROLLER_ID), - parameterWithName("actionId").description(DdiApiModelProperties.ACTION_ID_CANCELED)), - requestFields( - optionalRequestFieldWithPath("id").description(DdiApiModelProperties.FEEDBACK_ACTION_ID) - .type(JsonFieldType.NUMBER), - optionalRequestFieldWithPath("time") - .description(DdiApiModelProperties.FEEDBACK_ACTION_TIME), - requestFieldWithPath("status").description(DdiApiModelProperties.TARGET_STATUS), - requestFieldWithPath("status.code") - .description(DdiApiModelProperties.TARGET_EXEC_STATUS_CODE), - requestFieldWithPath("status.execution") - .description(DdiApiModelProperties.TARGET_EXEC_STATUS).type("enum") - .attributes(key("value").value( - "['closed', 'proceeding', 'download', 'downloaded', 'canceled','scheduled', 'rejected', 'resumed']")), - requestFieldWithPath("status.result") - .description(DdiApiModelProperties.TARGET_RESULT_VALUE), - requestFieldWithPath("status.result.finished") - .description(DdiApiModelProperties.TARGET_RESULT_FINISHED).type("enum") - .attributes(key("value").value("['success', 'failure', 'none']")), - optionalRequestFieldWithPath("status.details") - .description(DdiApiModelProperties.TARGET_RESULT_DETAILS)))); - } - - @Test - @Description("The usual behaviour is that when a new device registers at the server it is " - + "requested to provide the meta information that will allow the server to identify the device on a " - + "hardware level (e.g. hardware revision, mac address, serial number etc.).") - @WithUser(tenantId = "TENANT_ID", authorities = "ROLE_CONTROLLER", allSpPermissions = true) - public void putConfigData() throws Exception { - final Target target = targetManagement.create(entityFactory.target().create().controllerId(CONTROLLER_ID)); - - final Map attributes = new HashMap<>(); - attributes.put("hwRevision", "2"); - attributes.put("VIN", "JH4TB2H26CC000000"); - - mockMvc.perform( - put(DdiRestConstants.BASE_V1_REQUEST_MAPPING + "/{controllerId}/" + DdiRestConstants.CONFIG_DATA_ACTION, - tenantAware.getCurrentTenant(), target.getControllerId()) - .content(JsonBuilder.configData(attributes, "merge").toString()) - .contentType(MediaType.APPLICATION_JSON_UTF8)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andDo(this.document.document( - pathParameters(parameterWithName("tenant").description(ApiModelPropertiesGeneric.TENANT), - parameterWithName("controllerId").description(DdiApiModelProperties.CONTROLLER_ID)), - requestFields( - requestFieldWithPath("data").description(DdiApiModelProperties.TARGET_CONFIG_DATA), - optionalRequestFieldWithPath("mode").description(DdiApiModelProperties.UPDATE_MODE) - .type("enum") - .attributes(key("value").value("['merge', 'replace', 'remove']"))))); - - } - - @Test - @Description("Core resource for deployment operations. Contains all information necessary in order to execute the operation.") - @WithUser(tenantId = "TENANT_ID", authorities = "ROLE_CONTROLLER", allSpPermissions = true) - public void getControllerBasedeploymentAction() throws Exception { - final DistributionSet set = testdataFactory.createDistributionSet("one"); - - set.getModules().forEach(module -> { - final byte[] random = RandomStringUtils.random(5).getBytes(); - - artifactManagement.create( - new ArtifactUpload(new ByteArrayInputStream(random), module.getId(), "binary.tgz", false, 0)); - artifactManagement.create( - new ArtifactUpload(new ByteArrayInputStream(random), module.getId(), "file.signature", false, 0)); - }); - - softwareModuleManagement.createMetaData( - entityFactory.softwareModuleMetadata().create(set.getModules().iterator().next().getId()) - .key("aMetadataKey").value("Metadata value as defined in software module").targetVisible(true)); - - final Target target = targetManagement.create(entityFactory.target().create().controllerId(CONTROLLER_ID)); - final Long actionId = getFirstAssignedActionId(assignDistributionSetWithMaintenanceWindow(set.getId(), - target.getControllerId(), getTestSchedule(-5), getTestDuration(10), getTestTimeZone())); - - controllerManagement.addInformationalActionStatus( - entityFactory.actionStatus().create(actionId).message("Started download").status(Status.DOWNLOAD)); - controllerManagement.addInformationalActionStatus(entityFactory.actionStatus().create(actionId) - .message("Download failed. ErrorCode #5876745. Retry").status(Status.WARNING)); - controllerManagement.addInformationalActionStatus( - entityFactory.actionStatus().create(actionId).message("Download done").status(Status.DOWNLOADED)); - controllerManagement.addInformationalActionStatus( - entityFactory.actionStatus().create(actionId).message("Write firmware").status(Status.RUNNING)); - controllerManagement.addInformationalActionStatus( - entityFactory.actionStatus().create(actionId).message("Reboot").status(Status.RUNNING)); - - mockMvc.perform(get( - DdiRestConstants.BASE_V1_REQUEST_MAPPING + "/{controllerId}/" + DdiRestConstants.DEPLOYMENT_BASE_ACTION - + "/{actionId}?actionHistory=10", - tenantAware.getCurrentTenant(), target.getControllerId(), actionId).accept(MediaTypes.HAL_JSON_VALUE)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaTypes.HAL_JSON)) - .andDo(this.document.document( - pathParameters(parameterWithName("tenant").description(ApiModelPropertiesGeneric.TENANT), - parameterWithName("controllerId").description(DdiApiModelProperties.CONTROLLER_ID), - parameterWithName("actionId").description(DdiApiModelProperties.ACTION_ID)), - requestParameters( - parameterWithName("actionHistory").description(DdiApiModelProperties.ACTION_HISTORY)), - responseFields(fieldWithPath("id").description(DdiApiModelProperties.ACTION_ID), - fieldWithPath("deployment").description(DdiApiModelProperties.DEPLOYMENT), - fieldWithPath("deployment.download") - .description(DdiApiModelProperties.HANDLING_DOWNLOAD).type("enum") - .attributes(key("value").value("['skip', 'attempt', 'forced']")), - fieldWithPath("deployment.update").description(DdiApiModelProperties.HANDLING_UPDATE) - .type("enum").attributes(key("value").value("['skip', 'attempt', 'forced']")), - fieldWithPath("deployment.maintenanceWindow") - .description(DdiApiModelProperties.MAINTENANCE_WINDOW).type("enum") - .attributes(key("value").value("['available', 'unavailable']")), - fieldWithPath("deployment.chunks").description(DdiApiModelProperties.CHUNK), - fieldWithPath("deployment.chunks[].metadata") - .description(DdiApiModelProperties.CHUNK_META_DATA).optional(), - fieldWithPath("deployment.chunks[].metadata[].key") - .description(DdiApiModelProperties.CHUNK_META_DATA_KEY).optional(), - fieldWithPath("deployment.chunks[].metadata[].value") - .description(DdiApiModelProperties.CHUNK_META_DATA_VALUE).optional(), - fieldWithPath("deployment.chunks[].part").description(DdiApiModelProperties.CHUNK_TYPE), - fieldWithPath("deployment.chunks[].name").description(DdiApiModelProperties.CHUNK_NAME), - fieldWithPath("deployment.chunks[].version") - .description(DdiApiModelProperties.CHUNK_VERSION), - fieldWithPath("deployment.chunks[].artifacts") - .description(DdiApiModelProperties.ARTIFACTS), - fieldWithPath("deployment.chunks[].artifacts[].filename") - .description(DdiApiModelProperties.ARTIFACTS), - fieldWithPath("deployment.chunks[].artifacts[].hashes") - .description(DdiApiModelProperties.ARTIFACTS), - fieldWithPath("deployment.chunks[].artifacts[].hashes.sha1") - .description(DdiApiModelProperties.ARTIFACT_HASHES_SHA1), - fieldWithPath("deployment.chunks[].artifacts[].hashes.md5") - .description(DdiApiModelProperties.ARTIFACT_HASHES_MD5), - fieldWithPath("deployment.chunks[].artifacts[].hashes.sha256") - .description(DdiApiModelProperties.ARTIFACT_HASHES_SHA256), - fieldWithPath("deployment.chunks[].artifacts[].size") - .description(DdiApiModelProperties.ARTIFACT_SIZE), - fieldWithPath("deployment.chunks[].artifacts[]._links.download") - .description(DdiApiModelProperties.ARTIFACT_HTTPS_DOWNLOAD_LINK_BY_CONTROLLER), - fieldWithPath("deployment.chunks[].artifacts[]._links.md5sum") - .description(DdiApiModelProperties.ARTIFACT_HTTPS_HASHES_MD5SUM_LINK), - fieldWithPath("deployment.chunks[].artifacts[]._links.download-http") - .description(DdiApiModelProperties.ARTIFACT_HTTP_DOWNLOAD_LINK_BY_CONTROLLER), - fieldWithPath("deployment.chunks[].artifacts[]._links.md5sum-http") - .description(DdiApiModelProperties.ARTIFACT_HTTP_HASHES_MD5SUM_LINK), - fieldWithPath("actionHistory").description(DdiApiModelProperties.ACTION_HISTORY_RESP), - fieldWithPath("actionHistory.status") - .description(DdiApiModelProperties.ACTION_HISTORY_RESP_STATUS), - fieldWithPath("actionHistory.messages") - .description(DdiApiModelProperties.ACTION_HISTORY_RESP_MESSAGES)))); - - } - - @Test - @Description("Core resource for deployment operations. Contains all information necessary in order to execute the operation. Example with maintenance window where the device is requested to download only as it is not in the maintenance window yet.") - @WithUser(tenantId = "TENANT_ID", authorities = "ROLE_CONTROLLER", allSpPermissions = true) - public void getControllerBasedeploymentActionWithMaintenanceWindow() throws Exception { - final DistributionSet set = testdataFactory.createDistributionSet("one"); - - final Target target = targetManagement.create(entityFactory.target().create().controllerId(CONTROLLER_ID)); - final Long actionId = getFirstAssignedActionId(assignDistributionSetWithMaintenanceWindow(set.getId(), - target.getControllerId(), getTestSchedule(2), getTestDuration(1), getTestTimeZone())); - - mockMvc.perform(get( - DdiRestConstants.BASE_V1_REQUEST_MAPPING + "/{controllerId}/" + DdiRestConstants.DEPLOYMENT_BASE_ACTION - + "/{actionId}?actionHistory=10", - tenantAware.getCurrentTenant(), target.getControllerId(), actionId).accept(MediaTypes.HAL_JSON_VALUE)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaTypes.HAL_JSON)) - .andDo(this.document.document( - pathParameters(parameterWithName("tenant").description(ApiModelPropertiesGeneric.TENANT), - parameterWithName("controllerId").description(DdiApiModelProperties.CONTROLLER_ID), - parameterWithName("actionId").description(DdiApiModelProperties.ACTION_ID)), - requestParameters( - parameterWithName("actionHistory").description(DdiApiModelProperties.ACTION_HISTORY)), - responseFields(fieldWithPath("id").description(DdiApiModelProperties.ACTION_ID), - fieldWithPath("deployment").description(DdiApiModelProperties.DEPLOYMENT), - fieldWithPath("deployment.download") - .description(DdiApiModelProperties.HANDLING_DOWNLOAD), - fieldWithPath("deployment.update").description(DdiApiModelProperties.HANDLING_UPDATE) - .type("enum").attributes(key("value").value("['attempt', 'forced']")), - fieldWithPath("deployment.maintenanceWindow") - .description(DdiApiModelProperties.MAINTENANCE_WINDOW).type("enum") - .attributes(key("value").value("['available', 'unavailable']")), - fieldWithPath("deployment.chunks").description(DdiApiModelProperties.CHUNK), - fieldWithPath("deployment.chunks[].part").description(DdiApiModelProperties.CHUNK_TYPE), - fieldWithPath("deployment.chunks[].name").description(DdiApiModelProperties.CHUNK_NAME), - fieldWithPath("deployment.chunks[].version") - .description(DdiApiModelProperties.CHUNK_VERSION), - fieldWithPath("actionHistory.status") - .description(DdiApiModelProperties.ACTION_HISTORY_RESP_STATUS), - fieldWithPath("actionHistory.messages") - .description(DdiApiModelProperties.ACTION_HISTORY_RESP_MESSAGES)))); - - } - - @Test - @Description("Feedback channel. It is up to the device to decided how much intermediate feedback is " - + "provided. However, the action will be kept open until the controller on the device reports a " - + "finished (either successful or error).") - @WithUser(tenantId = "TENANT_ID", authorities = "ROLE_CONTROLLER", allSpPermissions = true) - public void postBasedeploymentActionFeedback() throws Exception { - final DistributionSet set = testdataFactory.createDistributionSet("one"); - - final Target target = targetManagement.create(entityFactory.target().create().controllerId(CONTROLLER_ID)); - final Long actionId = getFirstAssignedActionId(assignDistributionSet(set.getId(), target.getControllerId())); - - final DdiStatus ddiStatus = new DdiStatus(DdiStatus.ExecutionStatus.CLOSED, - new DdiResult(DdiResult.FinalResult.SUCCESS, new DdiProgress(2, 5)), 200, List.of("Feedback message")); - final DdiActionFeedback feedback = new DdiActionFeedback(Instant.now().toString(), ddiStatus); - - mockMvc.perform(post(DdiRestConstants.BASE_V1_REQUEST_MAPPING + "/{controllerId}/" - + DdiRestConstants.DEPLOYMENT_BASE_ACTION + "/{actionId}/feedback", tenantAware.getCurrentTenant(), - target.getControllerId(), actionId).content(objectMapper.writeValueAsString(feedback)) - .contentType(MediaType.APPLICATION_JSON_UTF8).accept(MediaTypes.HAL_JSON_VALUE)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andDo(this.document.document( - pathParameters(parameterWithName("tenant").description(ApiModelPropertiesGeneric.TENANT), - parameterWithName("controllerId").description(DdiApiModelProperties.CONTROLLER_ID), - parameterWithName("actionId").description(DdiApiModelProperties.ACTION_ID)), - - requestFields( - optionalRequestFieldWithPath("id").description(DdiApiModelProperties.FEEDBACK_ACTION_ID) - .type(JsonFieldType.NUMBER), - optionalRequestFieldWithPath("time") - .description(DdiApiModelProperties.FEEDBACK_ACTION_TIME), - requestFieldWithPath("status").description(DdiApiModelProperties.TARGET_STATUS), - requestFieldWithPath("status.code") - .description(DdiApiModelProperties.TARGET_EXEC_STATUS_CODE), - requestFieldWithPath("status.execution") - .description(DdiApiModelProperties.TARGET_EXEC_STATUS).type("enum") - .attributes(key("value").value( - "['closed', 'proceeding', 'download', 'downloaded', 'canceled','scheduled', 'rejected', 'resumed']")), - requestFieldWithPath("status.result") - .description(DdiApiModelProperties.TARGET_RESULT_VALUE), - requestFieldWithPath("status.result.finished") - .description(DdiApiModelProperties.TARGET_RESULT_FINISHED).type("enum") - .attributes(key("value").value("['success', 'failure', 'none']")), - optionalRequestFieldWithPath("status.result.progress") - .description(DdiApiModelProperties.TARGET_RESULT_PROGRESS), - optionalRequestFieldWithPath("status.details") - .description(DdiApiModelProperties.TARGET_RESULT_DETAILS)))); - } - - @Test - @Description("Returns all artifacts that are assigned to the software module." - + "Can be useful for the target to double check that its current state matches with the targeted state.") - @WithUser(tenantId = "TENANT_ID", authorities = "ROLE_CONTROLLER", allSpPermissions = true) - public void getSoftwareModulesArtifacts() throws Exception { - final DistributionSet set = testdataFactory.createDistributionSet(""); - - final SoftwareModule module = (SoftwareModule) set.getModules().toArray()[0]; - - final byte[] random = RandomStringUtils.random(5).getBytes(); - artifactManagement - .create(new ArtifactUpload(new ByteArrayInputStream(random), module.getId(), "binaryFile", false, 0)); - - final Target target = targetManagement.create(entityFactory.target().create().controllerId(CONTROLLER_ID)); - assignDistributionSet(set.getId(), target.getControllerId()); - - mockMvc.perform( - get(DdiRestConstants.BASE_V1_REQUEST_MAPPING + "/{controllerId}/softwaremodules/{moduleId}/artifacts", - tenantAware.getCurrentTenant(), target.getControllerId(), module.getId()) - .accept(MediaTypes.HAL_JSON_VALUE)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaTypes.HAL_JSON)) - .andDo(this.document.document( - pathParameters(parameterWithName("tenant").description(ApiModelPropertiesGeneric.TENANT), - parameterWithName("controllerId").description(DdiApiModelProperties.CONTROLLER_ID), - parameterWithName("moduleId").description(DdiApiModelProperties.SOFTWARE_MODULE_ID)), - responseFields(fieldWithPath("[]filename").description(DdiApiModelProperties.ARTIFACTS), - fieldWithPath("[]hashes").description(DdiApiModelProperties.ARTIFACTS), - fieldWithPath("[]hashes.sha1").description(DdiApiModelProperties.ARTIFACT_HASHES_SHA1), - fieldWithPath("[]hashes.md5").description(DdiApiModelProperties.ARTIFACT_HASHES_MD5), - fieldWithPath("[]hashes.sha256") - .description(DdiApiModelProperties.ARTIFACT_HASHES_SHA256), - fieldWithPath("[]size").description(DdiApiModelProperties.ARTIFACT_SIZE), - fieldWithPath("[]_links.download") - .description(DdiApiModelProperties.ARTIFACT_HTTPS_DOWNLOAD_LINK_BY_CONTROLLER), - fieldWithPath("[]_links.md5sum") - .description(DdiApiModelProperties.ARTIFACT_HTTPS_HASHES_MD5SUM_LINK), - fieldWithPath("[]_links.download-http") - .description(DdiApiModelProperties.ARTIFACT_HTTP_DOWNLOAD_LINK_BY_CONTROLLER), - fieldWithPath("[]_links.md5sum-http") - .description(DdiApiModelProperties.ARTIFACT_HTTP_HASHES_MD5SUM_LINK)))); - } - - @Test - @Description("Resource to receive information of the previous installation. The response will be of same format as " - + "the deploymentBase operation.") - @WithUser(tenantId = "TENANT_ID", authorities = "ROLE_CONTROLLER", allSpPermissions = true) - public void getControllerInstalledBaseAction() throws Exception { - final DistributionSet set = testdataFactory.createDistributionSet("zero"); - - set.getModules().forEach(module -> { - final byte[] random = RandomStringUtils.random(5).getBytes(); - artifactManagement.create( - new ArtifactUpload(new ByteArrayInputStream(random), module.getId(), "binary.tgz", false, 0)); - artifactManagement.create( - new ArtifactUpload(new ByteArrayInputStream(random), module.getId(), "file.signature", false, 0)); - }); - - softwareModuleManagement.createMetaData( - entityFactory.softwareModuleMetadata().create(set.getModules().iterator().next().getId()) - .key("aMetadataKey").value("Metadata value as defined in software module").targetVisible(true)); - - final Target target = targetManagement.create(entityFactory.target().create().controllerId(CONTROLLER_ID)); - final Long actionId = getFirstAssignedActionId(assignDistributionSetWithMaintenanceWindow(set.getId(), - target.getControllerId(), getTestSchedule(-5), getTestDuration(10), getTestTimeZone())); - - controllerManagement.addInformationalActionStatus( - entityFactory.actionStatus().create(actionId).message("Started download").status(Status.DOWNLOAD)); - controllerManagement.addInformationalActionStatus(entityFactory.actionStatus().create(actionId) - .message("Download failed. ErrorCode #5876745. Retry").status(Status.WARNING)); - controllerManagement.addInformationalActionStatus( - entityFactory.actionStatus().create(actionId).message("Download done").status(Status.DOWNLOADED)); - controllerManagement.addInformationalActionStatus( - entityFactory.actionStatus().create(actionId).message("Write firmware").status(Status.RUNNING)); - controllerManagement.addInformationalActionStatus( - entityFactory.actionStatus().create(actionId).message("Reboot").status(Status.RUNNING)); - controllerManagement.addUpdateActionStatus( - entityFactory.actionStatus().create(actionId).message("Installed").status(Status.FINISHED)); - - mockMvc.perform(get( - DdiRestConstants.BASE_V1_REQUEST_MAPPING + "/{controllerId}/" + DdiRestConstants.INSTALLED_BASE_ACTION - + "/{actionId}?actionHistory=10", - tenantAware.getCurrentTenant(), target.getControllerId(), actionId).accept(MediaTypes.HAL_JSON_VALUE)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaTypes.HAL_JSON)) - .andDo(this.document.document( - pathParameters(parameterWithName("tenant").description(ApiModelPropertiesGeneric.TENANT), - parameterWithName("controllerId").description(DdiApiModelProperties.CONTROLLER_ID), - parameterWithName("actionId").description(DdiApiModelProperties.ACTION_ID)), - requestParameters( - parameterWithName("actionHistory").description(DdiApiModelProperties.ACTION_HISTORY)), - responseFields(fieldWithPath("id").description(DdiApiModelProperties.ACTION_ID), - fieldWithPath("deployment").description(DdiApiModelProperties.DEPLOYMENT), - fieldWithPath("deployment.download") - .description(DdiApiModelProperties.HANDLING_DOWNLOAD).type("enum") - .attributes(key("value").value("['skip', 'attempt', 'forced']")), - fieldWithPath("deployment.update").description(DdiApiModelProperties.HANDLING_UPDATE) - .type("enum").attributes(key("value").value("['skip', 'attempt', 'forced']")), - fieldWithPath("deployment.maintenanceWindow") - .description(DdiApiModelProperties.MAINTENANCE_WINDOW).type("enum") - .attributes(key("value").value("['available', 'unavailable']")), - fieldWithPath("deployment.chunks").description(DdiApiModelProperties.CHUNK), - fieldWithPath("deployment.chunks[].metadata") - .description(DdiApiModelProperties.CHUNK_META_DATA).optional(), - fieldWithPath("deployment.chunks[].metadata[].key") - .description(DdiApiModelProperties.CHUNK_META_DATA_KEY).optional(), - fieldWithPath("deployment.chunks[].metadata[].value") - .description(DdiApiModelProperties.CHUNK_META_DATA_VALUE).optional(), - fieldWithPath("deployment.chunks[].part").description(DdiApiModelProperties.CHUNK_TYPE), - fieldWithPath("deployment.chunks[].name").description(DdiApiModelProperties.CHUNK_NAME), - fieldWithPath("deployment.chunks[].version") - .description(DdiApiModelProperties.CHUNK_VERSION), - fieldWithPath("deployment.chunks[].artifacts") - .description(DdiApiModelProperties.ARTIFACTS), - fieldWithPath("deployment.chunks[].artifacts[].filename") - .description(DdiApiModelProperties.ARTIFACTS), - fieldWithPath("deployment.chunks[].artifacts[].hashes") - .description(DdiApiModelProperties.ARTIFACTS), - fieldWithPath("deployment.chunks[].artifacts[].hashes.sha1") - .description(DdiApiModelProperties.ARTIFACT_HASHES_SHA1), - fieldWithPath("deployment.chunks[].artifacts[].hashes.md5") - .description(DdiApiModelProperties.ARTIFACT_HASHES_MD5), - fieldWithPath("deployment.chunks[].artifacts[].hashes.sha256") - .description(DdiApiModelProperties.ARTIFACT_HASHES_SHA256), - fieldWithPath("deployment.chunks[].artifacts[].size") - .description(DdiApiModelProperties.ARTIFACT_SIZE), - fieldWithPath("deployment.chunks[].artifacts[]._links.download") - .description(DdiApiModelProperties.ARTIFACT_HTTPS_DOWNLOAD_LINK_BY_CONTROLLER), - fieldWithPath("deployment.chunks[].artifacts[]._links.md5sum") - .description(DdiApiModelProperties.ARTIFACT_HTTPS_HASHES_MD5SUM_LINK), - fieldWithPath("deployment.chunks[].artifacts[]._links.download-http") - .description(DdiApiModelProperties.ARTIFACT_HTTP_DOWNLOAD_LINK_BY_CONTROLLER), - fieldWithPath("deployment.chunks[].artifacts[]._links.md5sum-http") - .description(DdiApiModelProperties.ARTIFACT_HTTP_HASHES_MD5SUM_LINK), - fieldWithPath("actionHistory").description(DdiApiModelProperties.ACTION_HISTORY_RESP), - fieldWithPath("actionHistory.status") - .description(DdiApiModelProperties.ACTION_HISTORY_RESP_STATUS), - fieldWithPath("actionHistory.messages") - .description(DdiApiModelProperties.ACTION_HISTORY_RESP_MESSAGES)))); - - } - - @Test - @Description("Resource to retrieve the current state of auto confirmation. In case auto-confirm is active a reference to disable it will be provided.") - @WithUser(tenantId = "TENANT_ID", authorities = "ROLE_CONTROLLER", allSpPermissions = true) - public void getConfirmationBaseWithAutoConfirmActive() throws Exception { - enableConfirmationFlow(); - - final DistributionSet set = testdataFactory.createDistributionSet("one"); - final Target target = targetManagement.create(entityFactory.target().create().controllerId(CONTROLLER_ID)); - confirmationManagement.activateAutoConfirmation(target.getControllerId(), "exampleUserId", "exampleRemark"); - assignDistributionSetWithMaintenanceWindow(set.getId(), target.getControllerId(), getTestSchedule(-5), - getTestDuration(10), getTestTimeZone()); - - mockMvc.perform( - get(DdiRestConstants.BASE_V1_REQUEST_MAPPING + "/{controllerId}/" + DdiRestConstants.CONFIRMATION_BASE, - tenantAware.getCurrentTenant(), target.getControllerId()).accept(MediaTypes.HAL_JSON_VALUE)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaTypes.HAL_JSON)) - .andDo(this.document.document( - pathParameters(parameterWithName("tenant").description(ApiModelPropertiesGeneric.TENANT), - parameterWithName("controllerId").description(DdiApiModelProperties.CONTROLLER_ID)), - responseFields( - fieldWithPath("autoConfirm").description(DdiApiModelProperties.TARGET_AUTO_CONFIRM), - fieldWithPath("autoConfirm.active") - .description(DdiApiModelProperties.TARGET_AUTO_CONFIRM_STATE), - fieldWithPath("autoConfirm.initiator") - .description(DdiApiModelProperties.TARGET_AUTO_CONFIRM_INITIATOR_RESPONSE), - fieldWithPath("autoConfirm.remark") - .description(DdiApiModelProperties.TARGET_AUTO_CONFIRM_REMARK_RESPONSE), - fieldWithPath("autoConfirm.activatedAt") - .description(DdiApiModelProperties.TARGET_AUTO_CONFIRM_ACTIVATED_AT), - fieldWithPath("_links.deactivateAutoConfirm").description( - DdiApiModelProperties.TARGET_AUTO_CONFIRM_REFERENCE_DEACTIVATE_AUTO_CONFIRM)))); - } - - @Test - @Description("Resource to retrieve the current state of auto confirmation. In case actions are waiting for a confirmation, they will be referenced.") - @WithUser(tenantId = "TENANT_ID", authorities = "ROLE_CONTROLLER", allSpPermissions = true) - public void getConfirmationBaseWithAutoConfirmDeactivated() throws Exception { - enableConfirmationFlow(); - - final DistributionSet set = testdataFactory.createDistributionSet("one"); - final Target target = targetManagement.create(entityFactory.target().create().controllerId(CONTROLLER_ID)); - assignDistributionSetWithMaintenanceWindow(set.getId(), target.getControllerId(), getTestSchedule(-5), - getTestDuration(10), getTestTimeZone()); - - mockMvc.perform( - get(DdiRestConstants.BASE_V1_REQUEST_MAPPING + "/{controllerId}/" + DdiRestConstants.CONFIRMATION_BASE, - tenantAware.getCurrentTenant(), target.getControllerId()).accept(MediaTypes.HAL_JSON_VALUE)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaTypes.HAL_JSON)) - .andDo(this.document.document( - pathParameters(parameterWithName("tenant").description(ApiModelPropertiesGeneric.TENANT), - parameterWithName("controllerId").description(DdiApiModelProperties.CONTROLLER_ID)), - responseFields( - fieldWithPath("autoConfirm").description(DdiApiModelProperties.TARGET_AUTO_CONFIRM), - fieldWithPath("autoConfirm.active") - .description(DdiApiModelProperties.TARGET_AUTO_CONFIRM_STATE), - fieldWithPath("_links.activateAutoConfirm").description( - DdiApiModelProperties.TARGET_AUTO_CONFIRM_REFERENCE_ACTIVATE_AUTO_CONFIRM), - fieldWithPath("_links.confirmationBase").description( - DdiApiModelProperties.TARGET_AUTO_CONFIRM_REFERENCE_CONFIRMATION_BASE_ACTION)))); - } - - @Test - @Description("Core resource for confirmation of actions. Contains all necessary information for confirmation.") - @WithUser(tenantId = "TENANT_ID", authorities = "ROLE_CONTROLLER", allSpPermissions = true) - public void getConfirmationBaseAction() throws Exception { - enableConfirmationFlow(); - - final DistributionSet set = testdataFactory.createDistributionSet("one"); - - set.getModules().forEach(module -> { - final byte[] random = RandomStringUtils.random(5).getBytes(); - - artifactManagement.create( - new ArtifactUpload(new ByteArrayInputStream(random), module.getId(), "binary.tgz", false, 0)); - artifactManagement.create( - new ArtifactUpload(new ByteArrayInputStream(random), module.getId(), "file.signature", false, 0)); - }); - - softwareModuleManagement.createMetaData( - entityFactory.softwareModuleMetadata().create(set.getModules().iterator().next().getId()) - .key("aMetadataKey").value("Metadata value as defined in software module").targetVisible(true)); - - final Target target = targetManagement.create(entityFactory.target().create().controllerId(CONTROLLER_ID)); - final Long actionId = getFirstAssignedActionId(assignDistributionSetWithMaintenanceWindow(set.getId(), - target.getControllerId(), getTestSchedule(-5), getTestDuration(10), getTestTimeZone())); - - mockMvc.perform(get( - DdiRestConstants.BASE_V1_REQUEST_MAPPING + "/{controllerId}/" + DdiRestConstants.CONFIRMATION_BASE - + "/{actionId}?actionHistory=10", - tenantAware.getCurrentTenant(), target.getControllerId(), actionId).accept(MediaTypes.HAL_JSON_VALUE)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaTypes.HAL_JSON)) - .andDo(this.document.document( - pathParameters(parameterWithName("tenant").description(ApiModelPropertiesGeneric.TENANT), - parameterWithName("controllerId").description(DdiApiModelProperties.CONTROLLER_ID), - parameterWithName("actionId").description(DdiApiModelProperties.ACTION_ID)), - requestParameters( - parameterWithName("actionHistory").description(DdiApiModelProperties.ACTION_HISTORY)), - responseFields(fieldWithPath("id").description(DdiApiModelProperties.ACTION_ID), - fieldWithPath("confirmation").description(DdiApiModelProperties.CONFIRMATION), - fieldWithPath("confirmation.download") - .description(DdiApiModelProperties.HANDLING_DOWNLOAD).type("enum") - .attributes(key("value").value("['skip', 'attempt', 'forced']")), - fieldWithPath("confirmation.update").description(DdiApiModelProperties.HANDLING_UPDATE) - .type("enum").attributes(key("value").value("['skip', 'attempt', 'forced']")), - fieldWithPath("confirmation.maintenanceWindow") - .description(DdiApiModelProperties.MAINTENANCE_WINDOW).type("enum") - .attributes(key("value").value("['available', 'unavailable']")), - fieldWithPath("confirmation.chunks").description(DdiApiModelProperties.CHUNK), - fieldWithPath("confirmation.chunks[].metadata") - .description(DdiApiModelProperties.CHUNK_META_DATA).optional(), - fieldWithPath("confirmation.chunks[].metadata[].key") - .description(DdiApiModelProperties.CHUNK_META_DATA_KEY).optional(), - fieldWithPath("confirmation.chunks[].metadata[].value") - .description(DdiApiModelProperties.CHUNK_META_DATA_VALUE).optional(), - fieldWithPath("confirmation.chunks[].part") - .description(DdiApiModelProperties.CHUNK_TYPE), - fieldWithPath("confirmation.chunks[].name") - .description(DdiApiModelProperties.CHUNK_NAME), - fieldWithPath("confirmation.chunks[].version") - .description(DdiApiModelProperties.CHUNK_VERSION), - fieldWithPath("confirmation.chunks[].artifacts") - .description(DdiApiModelProperties.ARTIFACTS), - fieldWithPath("confirmation.chunks[].artifacts[].filename") - .description(DdiApiModelProperties.ARTIFACTS), - fieldWithPath("confirmation.chunks[].artifacts[].hashes") - .description(DdiApiModelProperties.ARTIFACTS), - fieldWithPath("confirmation.chunks[].artifacts[].hashes.sha1") - .description(DdiApiModelProperties.ARTIFACT_HASHES_SHA1), - fieldWithPath("confirmation.chunks[].artifacts[].hashes.md5") - .description(DdiApiModelProperties.ARTIFACT_HASHES_MD5), - fieldWithPath("confirmation.chunks[].artifacts[].hashes.sha256") - .description(DdiApiModelProperties.ARTIFACT_HASHES_SHA256), - fieldWithPath("confirmation.chunks[].artifacts[].size") - .description(DdiApiModelProperties.ARTIFACT_SIZE), - fieldWithPath("confirmation.chunks[].artifacts[]._links.download") - .description(DdiApiModelProperties.ARTIFACT_HTTPS_DOWNLOAD_LINK_BY_CONTROLLER), - fieldWithPath("confirmation.chunks[].artifacts[]._links.md5sum") - .description(DdiApiModelProperties.ARTIFACT_HTTPS_HASHES_MD5SUM_LINK), - fieldWithPath("confirmation.chunks[].artifacts[]._links.download-http") - .description(DdiApiModelProperties.ARTIFACT_HTTP_DOWNLOAD_LINK_BY_CONTROLLER), - fieldWithPath("confirmation.chunks[].artifacts[]._links.md5sum-http") - .description(DdiApiModelProperties.ARTIFACT_HTTP_HASHES_MD5SUM_LINK), - fieldWithPath("actionHistory").description(DdiApiModelProperties.ACTION_HISTORY_RESP), - fieldWithPath("actionHistory.status") - .description(DdiApiModelProperties.ACTION_HISTORY_RESP_STATUS), - fieldWithPath("actionHistory.messages") - .description(DdiApiModelProperties.ACTION_HISTORY_RESP_MESSAGES)))); - } - - @Test - @Description("Feedback channel for confirming an action") - @WithUser(tenantId = "TENANT_ID", authorities = "ROLE_CONTROLLER", allSpPermissions = true) - public void postConfirmationFeedback() throws Exception { - enableConfirmationFlow(); - - final DistributionSet set = testdataFactory.createDistributionSet("one"); - - final Target target = targetManagement.create(entityFactory.target().create().controllerId(CONTROLLER_ID)); - final Long actionId = getFirstAssignedActionId(assignDistributionSet(set.getId(), target.getControllerId())); - - final DdiConfirmationFeedback feedback = new DdiConfirmationFeedback( - DdiConfirmationFeedback.Confirmation.CONFIRMED, 33, List.of("Feedback message")); - - mockMvc.perform( - post(DdiRestConstants.BASE_V1_REQUEST_MAPPING + "/{controllerId}/" + DdiRestConstants.CONFIRMATION_BASE - + "/{actionId}/feedback", tenantAware.getCurrentTenant(), target.getControllerId(), actionId) - .content(objectMapper.writeValueAsString(feedback)) - .contentType(MediaType.APPLICATION_JSON_UTF8).accept(MediaTypes.HAL_JSON_VALUE)) - .andDo(MockMvcResultPrinter.print()).andExpect( - status().isOk()) - .andDo(this.document.document( - pathParameters(parameterWithName("tenant").description(ApiModelPropertiesGeneric.TENANT), - parameterWithName("controllerId").description(DdiApiModelProperties.CONTROLLER_ID), - parameterWithName("actionId").description(DdiApiModelProperties.ACTION_ID)), - - requestFields( - requestFieldWithPath("confirmation") - .description(DdiApiModelProperties.TARGET_CONFIRMATION_STATE).type("enum") - .attributes(key("value").value("['confirmed', 'denied']")), - - optionalRequestFieldWithPath("code") - .description(DdiApiModelProperties.TARGET_CONFIRMATION_CODE), - - optionalRequestFieldWithPath("details") - .description(DdiApiModelProperties.TARGET_CONFIRMATION_DETAILS)))); - } - - @Test - @Description("Resource to activate auto-confirmation on a target.") - @WithUser(tenantId = "TENANT_ID", authorities = "ROLE_CONTROLLER", allSpPermissions = true) - public void activateAutoConfirmation() throws Exception { - final Target target = targetManagement.create(entityFactory.target().create().controllerId(CONTROLLER_ID)); - - final DdiActivateAutoConfirmation body = new DdiActivateAutoConfirmation("exampleUser", "exampleRemark"); - - mockMvc.perform(post( - DdiRestConstants.BASE_V1_REQUEST_MAPPING + "/{controllerId}/" + DdiRestConstants.CONFIRMATION_BASE + "/" - + DdiRestConstants.AUTO_CONFIRM_ACTIVATE, - tenantAware.getCurrentTenant(), target.getControllerId()).content(objectMapper.writeValueAsString(body)) - .contentType(MediaType.APPLICATION_JSON_UTF8)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andDo(this.document.document( - pathParameters(parameterWithName("tenant").description(ApiModelPropertiesGeneric.TENANT), - parameterWithName("controllerId").description(DdiApiModelProperties.CONTROLLER_ID)), - requestFields( - optionalRequestFieldWithPath("initiator") - .description(DdiApiModelProperties.TARGET_AUTO_CONFIRM_ACTIVATE_INITIATOR), - optionalRequestFieldWithPath("remark") - .description(DdiApiModelProperties.TARGET_AUTO_CONFIRM_ACTIVATE_REMARK)))); - } - - @Test - @Description("Resource to deactivate auto-confirmation on a target.") - @WithUser(tenantId = "TENANT_ID", authorities = "ROLE_CONTROLLER", allSpPermissions = true) - public void deactivateAutoConfirmation() throws Exception { - final Target target = targetManagement.create(entityFactory.target().create().controllerId(CONTROLLER_ID)); - - mockMvc.perform(post( - DdiRestConstants.BASE_V1_REQUEST_MAPPING + "/{controllerId}/" + DdiRestConstants.CONFIRMATION_BASE + "/" - + DdiRestConstants.AUTO_CONFIRM_DEACTIVATE, - tenantAware.getCurrentTenant(), target.getControllerId())).andDo(MockMvcResultPrinter.print()) - .andExpect(status().isOk()) - .andDo(this.document.document( - pathParameters(parameterWithName("tenant").description(ApiModelPropertiesGeneric.TENANT), - parameterWithName("controllerId").description(DdiApiModelProperties.CONTROLLER_ID)))); - } - -} diff --git a/hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/documentation/AbstractApiRestDocumentation.java b/hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/documentation/AbstractApiRestDocumentation.java deleted file mode 100644 index ed3010e057..0000000000 --- a/hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/documentation/AbstractApiRestDocumentation.java +++ /dev/null @@ -1,381 +0,0 @@ -/** - * Copyright (c) 2018 Bosch Software Innovations GmbH and others - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - */ -package org.eclipse.hawkbit.rest.documentation; - -import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document; -import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessRequest; -import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessResponse; -import static org.springframework.restdocs.operation.preprocess.Preprocessors.prettyPrint; -import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields; -import static org.springframework.restdocs.request.RequestDocumentation.parameterWithName; -import static org.springframework.restdocs.request.RequestDocumentation.requestParameters; -import static org.springframework.restdocs.snippet.Attributes.key; - -import java.io.ByteArrayInputStream; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.stream.Collectors; - -import org.apache.commons.lang3.RandomStringUtils; -import org.eclipse.hawkbit.ddi.rest.resource.DdiApiConfiguration; -import org.eclipse.hawkbit.mgmt.rest.resource.MgmtApiConfiguration; -import org.eclipse.hawkbit.repository.DeploymentManagement; -import org.eclipse.hawkbit.repository.jpa.RepositoryApplicationConfiguration; -import org.eclipse.hawkbit.repository.model.Action; -import org.eclipse.hawkbit.repository.model.Action.ActionType; -import org.eclipse.hawkbit.repository.model.Action.Status; -import org.eclipse.hawkbit.repository.model.ArtifactUpload; -import org.eclipse.hawkbit.repository.model.DeploymentRequestBuilder; -import org.eclipse.hawkbit.repository.model.DistributionSet; -import org.eclipse.hawkbit.repository.model.Rollout; -import org.eclipse.hawkbit.repository.model.Target; -import org.eclipse.hawkbit.repository.model.TargetType; -import org.eclipse.hawkbit.repository.model.TargetUpdateStatus; -import org.eclipse.hawkbit.repository.test.TestConfiguration; -import org.eclipse.hawkbit.rest.AbstractRestIntegrationTest; -import org.eclipse.hawkbit.rest.RestConfiguration; -import org.eclipse.hawkbit.rest.util.FilterHttpResponse; -import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationProperties.TenantConfigurationKey; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.extension.ExtendWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.cloud.stream.test.binder.TestSupportBinderAutoConfiguration; -import org.springframework.restdocs.RestDocumentationContextProvider; -import org.springframework.restdocs.RestDocumentationExtension; -import org.springframework.restdocs.mockmvc.MockMvcRestDocumentation; -import org.springframework.restdocs.mockmvc.RestDocumentationResultHandler; -import org.springframework.restdocs.payload.FieldDescriptor; -import org.springframework.restdocs.payload.SubsectionDescriptor; -import org.springframework.restdocs.snippet.Snippet; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.TestPropertySource; -import org.springframework.test.web.servlet.MockMvc; -import org.springframework.test.web.servlet.setup.MockMvcBuilders; - -import com.fasterxml.jackson.databind.ObjectMapper; -import com.google.common.collect.Lists; - -import io.qameta.allure.Feature; - -/** - * Parent class for all Management API rest documentation classes. - * - */ -@Feature("Documentation Verification - API") -@ExtendWith(RestDocumentationExtension.class) -@ContextConfiguration(classes = { DdiApiConfiguration.class, MgmtApiConfiguration.class, RestConfiguration.class, - RepositoryApplicationConfiguration.class, TestConfiguration.class, - TestSupportBinderAutoConfiguration.class }) -@TestPropertySource(locations = { "classpath:/updateserver-restdocumentation-test.properties" }) -public abstract class AbstractApiRestDocumentation extends AbstractRestIntegrationTest { - - @Autowired - protected ObjectMapper objectMapper; - - @Autowired - private FilterHttpResponse filterHttpResponse; - - protected MockMvc mockMvc; - - protected RestDocumentationResultHandler document; - - protected String arrayPrefix; - - protected String host = "management-api.host"; - - /** - * The generated REST docs snippets will be outputted to an own resource - * folder. The child class has to specify the name of that output folder - * where to put its corresponding snippets. - * - * @return the name of the resource folder - */ - public abstract String getResourceName(); - - @BeforeEach - protected void setupMvc(final RestDocumentationContextProvider restDocContext) { - this.document = document(getResourceName() + "/{method-name}", preprocessRequest(prettyPrint()), - preprocessResponse(prettyPrint())); - this.mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext) - .apply(MockMvcRestDocumentation.documentationConfiguration(restDocContext).uris().withScheme("https") - .withHost(host + ".com").withPort(443)) - .alwaysDo(this.document).addFilter(filterHttpResponse).build(); - arrayPrefix = "[]"; - } - - public static MyFieldFieldDesc requestFieldWithPath(final String path, final boolean mandatory) { - return requestFieldWithPath(path, mandatory, mandatory ? "X" : ""); - } - - private static MyFieldFieldDesc requestFieldWithPath(final String path, final boolean mandatory, - final String mandatoryMessage) { - final MyFieldFieldDesc myFieldDesc = new MyFieldFieldDesc(path); - myFieldDesc.attributes(key("mandatory").value(mandatoryMessage)); - // defaults - myFieldDesc.attributes(key("value").value("")); - - if (!mandatory) { - myFieldDesc.optional(); - } - - return myFieldDesc; - } - - public static MyFieldFieldDesc requestFieldWithPath(final String path) { - return requestFieldWithPath(path, true); - } - - protected static MyFieldFieldDesc optionalRequestFieldWithPath(final String path) { - return requestFieldWithPath(path, false); - } - - public static MyFieldFieldDesc requestFieldWithPathMandatoryInMultiAssignMode(final String path) { - return requestFieldWithPath(path, false, "when multi-assignment is enabled"); - } - - public static class MyFieldFieldDesc extends SubsectionDescriptor { - - /** - * @param path - */ - protected MyFieldFieldDesc(final String path) { - super(path); - } - } - - /** - * Wrapper for FieldDescriptor adding attribute with a key named value if - * not set. - * - * @param path - * @return FieldDescriptor with value key - */ - public static FieldDescriptor fieldWithPath(final String path) { - final MyFieldFieldDesc myFieldDesc = new MyFieldFieldDesc(path); - // defaults - myFieldDesc.attributes(key("value").value("")); - return myFieldDesc; - } - - protected Target createTargetByGivenNameWithAttributes(final String name, final boolean inSync, - final boolean timeforced, final DistributionSet distributionSet) { - return createTargetByGivenNameWithAttributes(name, inSync, timeforced, distributionSet, null, null, null, - false); - } - - protected Target createTargetByGivenNameWithAttributes(final String name, final boolean inSync, - final boolean timeforced, final DistributionSet distributionSet, final boolean createRollout) { - return createTargetByGivenNameWithAttributes(name, inSync, timeforced, distributionSet, null, null, null, - createRollout); - } - - protected Target createTargetByGivenNameWithAttributes(final String name, final boolean inSync, - final boolean timeforced, final DistributionSet distributionSet, final String maintenanceWindowSchedule, - final String maintenanceWindowDuration, final String maintenanceWindowTimeZone, - final boolean createRollout) { - - final TargetType targetType = testdataFactory.findOrCreateTargetType("defaultType"); - targetTypeManagement.assignCompatibleDistributionSetTypes(targetType.getId(), - Collections.singletonList(distributionSet.getType().getId())); - final Target savedTarget = targetManagement.create(entityFactory.target().create().controllerId(name) - .status(TargetUpdateStatus.UNKNOWN).address("http://192.168.0.1").description("My name is " + name) - .targetType(targetType.getId()).lastTargetQuery(System.currentTimeMillis())); - - final List updatedTargets; - if (createRollout) { - - final Rollout rollout = testdataFactory.createRolloutByVariables("rollout", "rollout desc", 1, - "name==" + name, distributionSet, "50", "5", timeforced ? ActionType.TIMEFORCED : ActionType.FORCED, - isMultiAssignmentsEnabled() ? 600 : null, isConfirmationFlowActive()); - - // start the rollout and handle it - rolloutManagement.start(rollout.getId()); - rolloutHandler.handleAll(); - - updatedTargets = Collections.singletonList(savedTarget); - - } else { - final DeploymentRequestBuilder deploymentRequestBuilder = DeploymentManagement - .deploymentRequest(savedTarget.getControllerId(), distributionSet.getId()) - .setMaintenance(maintenanceWindowSchedule, maintenanceWindowDuration, maintenanceWindowTimeZone); - - if (timeforced) { - deploymentRequestBuilder.setActionType(ActionType.TIMEFORCED); - } - - if (isMultiAssignmentsEnabled()) { - deploymentRequestBuilder.setWeight(600); - } - - updatedTargets = makeAssignment(deploymentRequestBuilder.build()).getAssignedEntity().stream() - .map(Action::getTarget).collect(Collectors.toList()); - } - - if (inSync) { - feedbackToByInSync(distributionSet); - } - - return updatedTargets.get(0); - } - - protected DistributionSet createDistributionSet() { - DistributionSet distributionSet = testdataFactory.createDistributionSet(""); - distributionSet = distributionSetManagement.update(entityFactory.distributionSet() - .update(distributionSet.getId()).description("The descption of the distribution set.")); - - distributionSet.getModules().forEach(module -> { - final byte[] random = RandomStringUtils.random(5).getBytes(); - artifactManagement - .create(new ArtifactUpload(new ByteArrayInputStream(random), module.getId(), "file1", false, 0)); - softwareModuleManagement.update(entityFactory.softwareModule().update(module.getId()) - .description("Description of the software module")); - }); - - return distributionSet; - } - - /* - * helper method to give feedback mark an target IN_SNCY * - */ - private void feedbackToByInSync(final DistributionSet savedSet) { - final Action action = deploymentManagement.findActionsByDistributionSet(PAGE, savedSet.getId()).getContent() - .get(0); - - controllerManagement - .addUpdateActionStatus(entityFactory.actionStatus().create(action.getId()).status(Status.FINISHED)); - } - - protected void provideCodeFeedback(final Action action, final int code) { - controllerManagement.addUpdateActionStatus( - entityFactory.actionStatus().create(action.getId()).code(code).status(Status.RUNNING)); - } - - protected Target createTargetByGivenNameWithAttributes(final String name, final DistributionSet distributionSet) { - return createTargetByGivenNameWithAttributes(name, true, false, distributionSet); - } - - protected String getArrayPrefix(final boolean isArray) { - return isArray ? arrayPrefix : ""; - } - - protected Snippet getResponseFieldTarget(final boolean isArray, final FieldDescriptor... descriptors) { - final String fieldArrayPrefix = getArrayPrefix(isArray); - - final List fields = Lists.newArrayList( - fieldWithPath(fieldArrayPrefix + "createdBy").description(ApiModelPropertiesGeneric.CREATED_BY), - fieldWithPath(fieldArrayPrefix + "address").description(MgmtApiModelProperties.ADDRESS), - fieldWithPath(fieldArrayPrefix + "createdAt").description(ApiModelPropertiesGeneric.CREATED_AT), - fieldWithPath(fieldArrayPrefix + "name").description(ApiModelPropertiesGeneric.NAME), - fieldWithPath(fieldArrayPrefix + "description").description(ApiModelPropertiesGeneric.DESCRPTION), - fieldWithPath(fieldArrayPrefix + "controllerId").description(ApiModelPropertiesGeneric.ITEM_ID), - fieldWithPath(fieldArrayPrefix + "updateStatus").description(MgmtApiModelProperties.UPDATE_STATUS) - .type("enum") - .attributes(key("value").value("['error', 'in_sync', 'pending', 'registered', 'unknown']")), - fieldWithPath(fieldArrayPrefix + "securityToken").description(MgmtApiModelProperties.SECURITY_TOKEN), - fieldWithPath(fieldArrayPrefix + "requestAttributes") - .description(MgmtApiModelProperties.REQUEST_ATTRIBUTES), - fieldWithPath(fieldArrayPrefix + "autoConfirmActive") - .description(MgmtApiModelProperties.AUTO_CONFIRM_ACTIVE), - fieldWithPath(fieldArrayPrefix + "installedAt").description(MgmtApiModelProperties.INSTALLED_AT), - fieldWithPath(fieldArrayPrefix + "lastModifiedAt") - .description(ApiModelPropertiesGeneric.LAST_MODIFIED_AT).type("Number"), - fieldWithPath(fieldArrayPrefix + "lastModifiedBy") - .description(ApiModelPropertiesGeneric.LAST_MODIFIED_BY).type("String"), - fieldWithPath(fieldArrayPrefix + "ipAddress").description(MgmtApiModelProperties.IP_ADDRESS) - .type("String"), - fieldWithPath(fieldArrayPrefix + "lastControllerRequestAt") - .description(MgmtApiModelProperties.LAST_REQUEST_AT).type("Number"), - fieldWithPath(fieldArrayPrefix + "targetType").description(MgmtApiModelProperties.TARGETTYPE_ID) - .type("Number"), - fieldWithPath(fieldArrayPrefix + "targetTypeName").description(MgmtApiModelProperties.TARGETTYPE_NAME) - .type("String"), - fieldWithPath(fieldArrayPrefix + "_links.self").ignored()); - - if (!isArray) { - fields.addAll(Arrays.asList( - fieldWithPath(fieldArrayPrefix + "pollStatus").description(MgmtApiModelProperties.POLL_STATUS), - fieldWithPath(fieldArrayPrefix + "pollStatus.lastRequestAt") - .description(MgmtApiModelProperties.POLL_LAST_REQUEST_AT), - fieldWithPath(fieldArrayPrefix + "pollStatus.nextExpectedRequestAt") - .description(MgmtApiModelProperties.POLL_NEXT_EXPECTED_REQUEST_AT), - fieldWithPath(fieldArrayPrefix + "pollStatus.overdue") - .description(MgmtApiModelProperties.POLL_OVERDUE), - fieldWithPath(fieldArrayPrefix + "_links.assignedDS") - .description(MgmtApiModelProperties.LINKS_ASSIGNED_DS), - fieldWithPath(fieldArrayPrefix + "_links.installedDS") - .description(MgmtApiModelProperties.LINKS_INSTALLED_DS), - fieldWithPath(fieldArrayPrefix + "_links.attributes") - .description(MgmtApiModelProperties.LINKS_ATTRIBUTES), - fieldWithPath(fieldArrayPrefix + "_links.actions") - .description(MgmtApiModelProperties.LINKS_ACTIONS), - fieldWithPath(fieldArrayPrefix + "_links.metadata").description(MgmtApiModelProperties.META_DATA), - fieldWithPath(fieldArrayPrefix + "_links.targetType") - .description(MgmtApiModelProperties.LINK_TO_TARGET_TYPE), - fieldWithPath(fieldArrayPrefix + "_links.autoConfirm") - .description(MgmtApiModelProperties.LINK_TO_AUTO_CONFIRM))); - - } - fields.addAll(Arrays.asList(descriptors)); - - return responseFields(fields); - } - - protected Snippet getResponseFieldsDistributionSet(final boolean isArray, final FieldDescriptor... descriptors) { - final String arrayPrefix = getArrayPrefix(isArray); - final List fields = Lists.newArrayList( - fieldWithPath(arrayPrefix + "id").description(ApiModelPropertiesGeneric.ITEM_ID), - fieldWithPath(arrayPrefix + "name").description(ApiModelPropertiesGeneric.NAME), - fieldWithPath(arrayPrefix + "description").description(ApiModelPropertiesGeneric.DESCRPTION), - fieldWithPath(arrayPrefix + "createdBy").description(ApiModelPropertiesGeneric.CREATED_BY), - fieldWithPath(arrayPrefix + "createdAt").description(ApiModelPropertiesGeneric.CREATED_AT), - fieldWithPath(arrayPrefix + "lastModifiedBy").description(ApiModelPropertiesGeneric.LAST_MODIFIED_BY), - fieldWithPath(arrayPrefix + "lastModifiedAt").description(ApiModelPropertiesGeneric.LAST_MODIFIED_AT), - fieldWithPath(arrayPrefix + "type").description(MgmtApiModelProperties.DS_TYPE), - fieldWithPath(arrayPrefix + "typeName").description(MgmtApiModelProperties.DS_TYPE_NAME), - fieldWithPath(arrayPrefix + "requiredMigrationStep") - .description(MgmtApiModelProperties.DS_REQUIRED_STEP), - fieldWithPath(arrayPrefix + "complete").description(MgmtApiModelProperties.DS_COMPLETE), - fieldWithPath(arrayPrefix + "deleted").description(ApiModelPropertiesGeneric.DELETED), - fieldWithPath(arrayPrefix + "valid").description(MgmtApiModelProperties.DS_VALID), - fieldWithPath(arrayPrefix + "version").description(MgmtApiModelProperties.VERSION), - fieldWithPath(arrayPrefix + "_links.self").ignored(), fieldWithPath(arrayPrefix + "modules").ignored()); - - fields.addAll(Arrays.asList(descriptors)); - - if (!isArray) { - fields.add(fieldWithPath(arrayPrefix + "_links.type").description(MgmtApiModelProperties.DS_TYPE)); - fields.add(fieldWithPath(arrayPrefix + "_links.metadata").description(MgmtApiModelProperties.META_DATA)); - fields.add(fieldWithPath(arrayPrefix + "_links.modules").description(MgmtApiModelProperties.SM_LIST)); - } - - return responseFields(fields); - } - - protected Snippet getFilterRequestParamter() { - return requestParameters( - parameterWithName("limit").attributes(key("type").value("query")) - .description(ApiModelPropertiesGeneric.LIMIT), - parameterWithName("sort").description(ApiModelPropertiesGeneric.SORT), - parameterWithName("offset").description(ApiModelPropertiesGeneric.OFFSET), - parameterWithName("q").description(ApiModelPropertiesGeneric.FIQL)); - } - - protected boolean isMultiAssignmentsEnabled() { - return Boolean.TRUE.equals(tenantConfigurationManagement - .getConfigurationValue(TenantConfigurationKey.MULTI_ASSIGNMENTS_ENABLED, Boolean.class).getValue()); - } - - protected boolean isConfirmationFlowActive() { - return Boolean.TRUE.equals(tenantConfigurationManagement - .getConfigurationValue(TenantConfigurationKey.USER_CONFIRMATION_ENABLED, Boolean.class).getValue()); - } - -} diff --git a/hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/documentation/ApiModelPropertiesGeneric.java b/hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/documentation/ApiModelPropertiesGeneric.java deleted file mode 100644 index 88b447be09..0000000000 --- a/hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/documentation/ApiModelPropertiesGeneric.java +++ /dev/null @@ -1,54 +0,0 @@ -/** - * Copyright (c) 2018 Bosch Software Innovations GmbH and others - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - */ -package org.eclipse.hawkbit.rest.documentation; - -/** - * Constants for API documentation. - */ -public final class ApiModelPropertiesGeneric { - public static final String ENDING = " of the entity"; - - // generic - public static final String TENANT = "The tenant"; - public static final String ITEM_ID = "The technical identifier " + ENDING; - public static final String NAME = "The name" + ENDING; - public static final String DESCRPTION = "The description" + ENDING; - public static final String COLOUR = "The colour" + ENDING; - public static final String DELETED = "Deleted flag, used for soft deleted entities"; - - public static final String CREATED_BY = "Entity was originally created by (User, AMQP-Controller, anonymous etc.)"; - public static final String CREATED_AT = "Entity was originally created at (timestamp UTC in milliseconds)"; - public static final String LAST_MODIFIED_BY = "Entity was last modified by (User, AMQP-Controller, anonymous etc.)"; - public static final String LAST_MODIFIED_AT = "Entity was last modified at (timestamp UTC in milliseconds)"; - - // Paging elements - public static final String SIZE = "Current page size"; - public static final String TOTAL_ELEMENTS = "Total number of elements"; - public static final String SELF_LINKS_TO_RESOURCE = "Links to the given resource itself"; - - private ApiModelPropertiesGeneric() { - // utility class - } - - // parameters - public static final String OFFSET = "The paging offset (default is 0)."; - public static final String LIMIT = "The maximum number of entries in a page (default is 50)."; - public static final String SORT = "The query parameter sort allows to define the sort order for the result of a query. " - + "A sort criteria consists of the name of a field and the sort direction (ASC for ascending and DESC descending). " - + "The sequence of the sort criteria (multiple can be used) defines the sort order of the entities in the result."; - public static final String FIQL = "Query fields based on the Feed Item Query Language (FIQL). See Entity Definitions for available fields."; - - // Error/exception handling - public static final String EXCEPTION_CLASS = "The exception class name."; - public static final String ERROR_CODE = "The exception error code."; - public static final String ERROR_MESSAGE = "The exception human readable message."; - public static final String ERROR_PARAMETERS = "The exception message parameters."; - -} diff --git a/hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/documentation/DocumenationResponseFieldsSnippet.java b/hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/documentation/DocumenationResponseFieldsSnippet.java deleted file mode 100644 index 081c389fe9..0000000000 --- a/hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/documentation/DocumenationResponseFieldsSnippet.java +++ /dev/null @@ -1,25 +0,0 @@ -/** - * Copyright (c) 2018 Bosch Software Innovations GmbH and others - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - */ -package org.eclipse.hawkbit.rest.documentation; - -import java.util.List; - -import org.springframework.restdocs.payload.FieldDescriptor; -import org.springframework.restdocs.payload.ResponseFieldsSnippet; - -/** - * {@link ResponseFieldsSnippet} with public constructor - */ -public class DocumenationResponseFieldsSnippet extends ResponseFieldsSnippet { - public DocumenationResponseFieldsSnippet(final List descriptors) { - super(descriptors); - } - -} diff --git a/hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/documentation/MgmtApiModelProperties.java b/hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/documentation/MgmtApiModelProperties.java deleted file mode 100644 index e4f0a90090..0000000000 --- a/hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/documentation/MgmtApiModelProperties.java +++ /dev/null @@ -1,285 +0,0 @@ -/** - * Copyright (c) 2018 Bosch Software Innovations GmbH and others - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - */ -package org.eclipse.hawkbit.rest.documentation; - -/** - * Model properties for the Management API documentation. - */ -public final class MgmtApiModelProperties { - - // Versioned entity - public static final String VERSION = "Package version."; - public static final String VENDOR = "The software vendor."; - - public static final String ACTION_ID = "ID of the action."; - - public static final String LINKS_ASSIGNED_DS = "Links to assigned distribution sets."; - public static final String LINKS_INSTALLED_DS = "Links to installed distribution sets."; - public static final String LINKS_ATTRIBUTES = "Links to attributes of the target."; - public static final String LINKS_ACTIONS = "Links to actions of the target."; - public static final String LINK_TO_ACTION = "The link to the action."; - public static final String LINK_TO_DS = "The link to the distribution set."; - public static final String LINKS_ACTION_STATUSES = "The link to all statuses of the action."; - public static final String LINK_TO_ARTIFACTS = "The link to all artifact of a software module."; - public static final String LINK_TO_SM_TYPE = "The link to the software module type."; - public static final String LINK_TO_METADATA = "The link to the metadata."; - public static final String LINK_TO_MANDATORY_SMT = "Link to mandatory software modules types in this distribution set type."; - public static final String LINK_TO_OPTIONAL_SMT = "Link to optional software modules types in this distribution set type."; - public static final String LINK_TO_ROLLOUT = "The link to the rollout."; - public static final String LINK_TO_TARGET_TYPE = "The link to the target type."; - public static final String LINK_TO_TARGET = "The link to the target."; - - public static final String LINK_TO_AUTO_CONFIRM = "The link to the detailed auto confirm state."; - - // software module types - public static final String SMT_TYPE = "The type of the software module identified by its key."; - public static final String SMT_VENDOR = "The software vendor of the entity."; - public static final String SMT_VERSION = "The version of the software module type."; - public static final String SMT_KEY = "The key of the software module type."; - public static final String SMT_MAX_ASSIGNMENTS = "Software modules of that type can be assigned at this maximum number (e.g. operating system only once)."; - - // software module - public static final String SM_TYPE = "The software module type " + ApiModelPropertiesGeneric.ENDING; - public static final String SM_TYPE_NAME = "The software module type name " + ApiModelPropertiesGeneric.ENDING; - public static final String ENCRYPTED = "Encryption flag, used to identify that artifacts should be encrypted upon upload."; - public static final String ARTIFACT_HASHES = "Hashes of the artifact."; - public static final String ARTIFACT_SIZE = "Size of the artifact."; - public static final String ARTIFACT_PROVIDED_FILE = "Binary of file."; - public static final String ARTIFACT_PROVIDED_FILENAME = "Filename of the artifact."; - public static final String ARTIFACT_HASHES_SHA1 = "SHA1 hash of the artifact."; - public static final String ARTIFACT_HASHES_MD5 = "MD5 hash of the artifact."; - public static final String ARTIFACT_HASHES_SHA256 = "SHA256 hash of the artifact."; - public static final String ARTIFACT_DOWNLOAD_LINK = "Download link of the artifact based on the chosen download url type parameter."; - public static final String ARTIFACT_LIST = "List of artifacts of given software module."; - public static final String ARTIFACT_DOWNLOAD_USE_URL_HANDLER = "Indicates if the artifact URL handler should be used e.g. for external links."; - - // Distribution Set - public static final String DS_OS = "Operating system or firmware software module - DEPRECATED (use modules)."; - public static final String DS_RUNTIME = "Runtime software module (e.g. JVM) - DEPRECATED (use modules)."; - public static final String DS_APPLICATION = "Application software module (e.g. OSGi container) - DEPRECATED (use modules)."; - public static final String DS_MODULES = "Software modules (e.g. OSGi bundles, runtimes)."; - public static final String DS_REQUIRED_STEP = "True if DS is a required migration step for another DS. As a result the DS's assignment will not be cancelled when another DS is assigned (note: updatable only if DS is not yet assigned to a target)"; - public static final String DS_ASSIGNED_TARGETS = "Targets that have this distribution set assigned."; - public static final String DS_INSTALLED_TARGETS = "Targets that have this distribution set installed."; - public static final String DS_LIST = "List of distribution sets."; - public static final String DS_TAG_LIST = "List of distribution set tags"; - public static final String DS_NEW_ASSIGNED_TARGETS = "Targets that now have this distribution set assigned."; - public static final String DS_ALREADY_ASSIGNED_TARGETS = "Targets that had this distribution set already assigned (in \"offline\" case this includes targets that have arbitrary updates running)"; - public static final String DS_TOTAL_ASSIGNED_TARGETS = "Overall assigned as part of this request."; - public static final String DS_ID = "Id of the distribution set."; - public static final String DS_INVALIDATION_ACTION_CANCELATION_TYPE = "Type of cancelation for actions referring to the given distribution set."; - public static final String DS_INVALIDATION_CANCEL_ROLLOUTS = "Defines if rollouts referring to this distribution set should be canceled."; - - // Target - public static final String INSTALLED_AT = "Installation time of current installed DistributionSet."; - - public static final String LAST_REQUEST_AT = "Last time where the target polled the server, same as pollStatus.lastRequestAt."; - // poll status - public static final String POLL_LAST_REQUEST_AT = "Last time when the target polled the server."; - public static final String POLL_NEXT_EXPECTED_REQUEST_AT = "Next expected time when the target polls the server."; - public static final String POLL_STATUS = "Poll status of the target. In many scenarios that target will poll the update server on a regular basis to look for potential updates. If that poll does not happen it might imply that the target is offline."; - public static final String POLL_OVERDUE = "Defines if the target poll time is overdue based on the next expected poll time plus the configured overdue poll time threshold."; - - // Target type - public static final String TARGETTYPE_ID = "ID of the target type"; - public static final String TARGETTYPE_NAME = "Name of the target type"; - public static final String COMPATIBLE_DS_TYPES = "Array of distribution set types that are compatible to that target type"; - public static final String LINK_COMPATIBLE_DS_TYPES = "Link to the compatible distribution set types in this target type"; - - // rollout - public static final String ROLLOUT_FILTER_QUERY = "target filter query language expression"; - public static final String ROLLOUT_CONFIRMATION_REQUIRED = "(available with user consent flow active) if the confirmation is required for this rollout. Value will be used if confirmation options are missing in the rollout group definitions. Confirmation is required per default"; - public static final String ROLLOUT_GROUP_CONFIRMATION_REQUIRED = "(available with user consent flow active) if the confirmation is required for this rollout group. Confirmation is required per default."; - public static final String ROLLOUT_GROUP_FILTER_QUERY = "target filter query language expression that selects a subset of targets which match the target filter of the Rollout"; - public static final String ROLLOUT_GROUP_TARGET_PERCENTAGE = "percentage of remaining and matching targets that should be added to this group"; - public static final String ROLLOUT_DS_ID = "the ID of distributionset of this rollout"; - public static final String ROLLOUT_TOTAL_TARGETS = "the total targets of a rollout"; - public static final String ROLLOUT_TOTAL_TARGETS_PER_STATUS = "the total targets per status"; - - public static final String ROLLOUT_TOTAL_GROUPS = "the total number of groups created by this rollout"; - public static final String ROLLOUT_STATUS = "the status of this rollout"; - public static final String ROLLOUT_TYPE = "the type of this rollout"; - public static final String ROLLOUT_GROUP_STATUS = "the status of this rollout group"; - public static final String ROLLOUT_AMOUNT_GROUPS = "the amount of groups the rollout should split targets into"; - public static final String ROLLOUT_GROUPS = "the list of group definitions"; - public static final String ROLLOUT_SUCCESS_CONDITION = "the success condition which takes in place to evaluate if a rollout group is successful and so the next group can be started"; - public static final String ROLLOUT_SUCCESS_CONDITION_CONDITION = "the type of the condition"; - public static final String ROLLOUT_SUCCESS_CONDITION_EXP = "the expression according to the condition, e.g. the value of threshold in percentage"; - public static final String ROLLOUT_SUCCESS_ACTION = "the success action which takes in place to execute in case the success action is fulfilled"; - public static final String ROLLOUT_SUCCESS_ACTION_ACTION = "the success action to execute"; - public static final String ROLLOUT_SUCCESS_ACTION_EXP = "the expression for the success action"; - public static final String ROLLOUT_ERROR_CONDITION = "the error condition which takes in place to evaluate if a rollout group encounter errors"; - public static final String ROLLOUT_ERROR_CONDITION_CONDITION = "the type of the condition"; - public static final String ROLLOUT_ERROR_CONDITION_EXP = "the expression according to the condition, e.g. the value of threshold in percentage"; - public static final String ROLLOUT_ERROR_ACTION = "the error action which is executed if the error condition is fulfilled"; - public static final String ROLLOUT_ERROR_ACTION_ACTION = "the error action to execute"; - public static final String ROLLOUT_ERROR_ACTION_EXP = "the expression for the error action"; - public static final String ROLLOUT_LINKS_START_SYNC = "Link to start the rollout in sync mode"; - public static final String ROLLOUT_LINKS_START_ASYNC = "Link to start the rollout in async mode"; - public static final String ROLLOUT_LINKS_PAUSE = "Link to pause a running rollout"; - public static final String ROLLOUT_LINKS_TRIGGER_NEXT_GROUP = "Link for triggering next rollout group on a running rollout"; - public static final String ROLLOUT_LINKS_RESUME = "Link to resume a paused rollout"; - public static final String ROLLOUT_LINKS_APPROVE = "Link to approve a rollout"; - public static final String ROLLOUT_LINKS_DENY = "Link to deny a rollout"; - public static final String ROLLOUT_LINKS_GROUPS = "Link to retrieve the groups a rollout"; - public static final String ROLLOUT_START_ASYNC = "Start the rollout asynchronous"; - public static final String ROLLOUT_START_AT = "Start at timestamp of Rollout."; - - - public static final String RESULTING_ACTIONS_WEIGHT = "Weight of the resulting Actions"; - - public static final String UPDATE_STATUS = "Current update status of the target."; - public static final String TARGET_ATTRIBUTES = "Target attributes."; - - public static final String TARGET_LIST = "List of provisioning targets."; - - public static final String TARGET_TAG_LIST = "List of target tags"; - - public static final String TARGET_TYPE_LIST = "List of target types"; - - public static final String SM_LIST = "List of software modules."; - - public static final String ROLLOUT_LIST = "list of rollouts"; - - public static final String ACTION_TYPE = "Type of action."; - - public static final String ACTION_FORCE_TYPE = "Force type of the action that provides a hint if the controller should apply the action immediately or whenever possible."; - - public static final String ACTION_CONFIRMATION_REQUIRED = "(Available with user consent flow active) Defines, if the confirmation is required for an action. Confirmation is required per default."; - - public static final String ACTION_FORCE_TIME = "In case of timeforced mode the difference, measured in milliseconds, between the time the action should switch to forced and midnight, January 1, 1970 UTC."; - - public static final String ACTION_FORCED = "Set to forced in order to switch action to forced mode."; - - public static final String ACTION_STATUS_TYPE = "Type of the action status."; - - public static final String ACTION_STATUS_MESSAGES = "Messages related to the status."; - - public static final String ACTION_STATUS_REPORTED_AT = "Time at which the status was reported (server time)."; - - public static final String ACTION_STATUS_CODE = "(Optional) Code provided by the device related to the status."; - - public static final String ACTION_LAST_STATUS_CODE = "(Optional) Code provided as part of the last status update that was sent by the device."; - - public static final String ACTION_STATUS_LIST = "List of action status."; - - public static final String ACTION_EXECUTION_STATUS = "Status of action."; - - public static final String ACTION_DETAIL_STATUS = "Detailed status of action."; - - public static final String ACTION_LIST = "List of actions."; - - public static final String ACTION_WEIGHT = "Weight of the action showing the importance of the update."; - - public static final String ACTION_ROLLOUT = "The ID of the rollout this action was created for."; - - public static final String ACTION_ROLLOUT_NAME = "The name of the rollout this action was created for."; - - public static final String IP_ADDRESS = "Last known IP address of the target. Only presented if IP address of the target itself is known (connected directly through DDI API)."; - - public static final String ADDRESS = "The last known address URI of the target. Includes information of the target is connected either directly (DDI) through HTTP or indirectly (DMF) through amqp."; - - public static final String SECURITY_TOKEN = "Pre-Shared key that allows targets to authenticate at Direct Device Integration API if enabled in the tenant settings."; - - public static final String REQUEST_ATTRIBUTES = "Request re-transmission of target attributes."; - - public static final String AUTO_CONFIRM_ACTIVE = "Present if user consent flow active. Indicates if auto-confirm is active"; - - public static final String META_DATA = "List of metadata."; - - public static final String META_DATA_KEY = "Metadata property key."; - - public static final String META_DATA_VALUE = "Metadata property value."; - - public static final String SM_META_DATA_TARGET_VISIBLE = "Metadata property is visible to targets as part of software update action."; - - public static final String AUTO_CONFIRM_STATE_ACTIVE = "Flag if auto confirm is active"; - - public static final String AUTO_CONFIRM_STATE_INITIATOR = "(Optional) initiator set on activation"; - - public static final String AUTO_CONFIRM_STATE_REMARK = "(Optional) remark set on activation"; - - public static final String AUTO_CONFIRM_STATE_ACTIVATED_AT = "timestamp of the activation"; - - public static final String AUTO_CONFIRM_STATE_REFERENCE_ACTIVATE_AUTO_CONFIRM = "reference link to activate auto confirm (present if not active)"; - - public static final String AUTO_CONFIRM_STATE_REFERENCE_DEACTIVATE_AUTO_CONFIRM = "reference link to deactivate auto confirm (present if active)"; - - public static final String AUTO_CONFIRM_ACTIVATE_INITIATOR = "individual value (e.g. username) stored as initiator and automatically used as confirmed user in future actions"; - public static final String AUTO_CONFIRM_ACTIVATE_REMARK = "individual value to attach a remark which will be persisted when automatically confirming future actions"; - - public static final String SM_TYPE_KEY = "Key that can be interpreted by the target."; - - public static final String SM_MAX_ASSIGNMENTS = "Maximum number of assignments to a distribution set/target, e.g. only one firmware but multiple applications."; - - public static final String SM_TYPE_LIST = "List of software modules types."; - - public static final String DS_TYPE_KEY = "Functional key of the distribution set type."; - - public static final String DS_TYPE_LIST = "List of distribution set types."; - - public static final String DS_TYPE = "The type of the distribution set."; - - public static final String DS_TYPE_NAME = "The type name of the distribution set."; - - public static final String DS_COMPLETE = "True of the distribution set software module setup is complete as defined by the distribution set type."; - - public static final String DS_VALID = "True by default and false after the distribution set is invalidated by the user."; - - public static final String DS_TYPE_MANDATORY_MODULES = "Mandatory module type IDs."; - - public static final String DS_TYPE_OPTIONAL_MODULES = "Optional module type IDs."; - - public static final String MAINTENANCE_WINDOW = "Separation of download and install by defining a maintenance window for the installation."; - public static final String MAINTENANCE_WINDOW_SCHEDULE = "Schedule for the maintenance window start in quartz cron notation, such as '0 15 10 * * ? 2018' for 10:15am every day during the year 2018."; - public static final String MAINTENANCE_WINDOW_DURATION = "Duration of the window, such as '02:00:00' for 2 hours."; - public static final String MAINTENANCE_WINDOW_TIMEZONE = "A time-zone offset from Greenwich/UTC, such as '+02:00'."; - public static final String MAINTENANCE_WINDOW_NEXT_START_AT = "The time (timestamp UTC in milliseconds) of the next maintenance window start"; - - // target filter query - public static final String TARGET_FILTER_QUERY = "target filter query expression"; - public static final String TARGET_FILTER_QUERIES_LIST = "List of target filter queries."; - public static final String TARGET_FILTER_QUERY_AUTO_ASSIGN_DS_ID = "Auto assign distribution set id"; - public static final String TARGET_FILTER_QUERY_LINK_AUTO_ASSIGN_DS = "Link to manage the auto assign distribution set"; - public static final String TARGET_FILTER_QUERY_PARAM_Q = "Name filter"; - - // request parameter - public static final String FORCETIME = "Forcetime in milliseconds."; - public static final String FORCE = "Force as boolean."; - public static final String ASSIGNMENT_WEIGHT = "Importance of the assignment."; - public static final String ASSIGNMENT_CONFIRMATION_REQUIRED = "(Available with user consent flow active) Specifies if the confirmation by the device is required for this action."; - public static final String ASSIGNMENT_TYPE = "The type of the assignment."; - public static final String TARGET_ASSIGNED = "The number of targets that have been assigned as part of this operation."; - public static final String TARGET_ASSIGNED_ALREADY = "The number of targets which already had been the assignment."; - public static final String TARGET_ASSIGNED_TOTAL = "The total number of targets that are part of this operation."; - - public static final String ASSIGNED_TARGETS = "Assigned targets."; - public static final String UN_ASSIGNED_TARGETS = "Unassigned targets."; - public static final String LINKS_ASSIGNED_TARGETS = "Links to assigned targets."; - - public static final String ASSIGNED_DISTRIBUTION_SETS = "Assigned distribution sets."; - public static final String UN_ASSIGNED_DISTRIBUTION_SETS = "Unassigned distribution sets."; - public static final String LINKS_ASSIGNED_DISTRIBUTION_SETS = "Links to assigned distribution sets."; - public static final Object OFFLINE_UPDATE = "Offline update (set param to true) that is only reported but not managed by the service, " - + "e.g. defaults set in factory, manual updates or migrations from other update systems. A completed action is added to the history of the target(s)." - + " Target is set to IN_SYNC state as both assigend and installed DS are set. " - + "Note: only executed if the target has currently no running update."; - - // configuration - public static final String CONFIG_LIST = "List of all available configuration parameter."; - public static final String CONFIG_VALUE = "Current value of of configuration parameter."; - public static final String CONFIG_GLOBAL = "true - if the current value is the global configuration value, false - if there is a tenant specific value configured."; - public static final String CONFIG_PARAM = "The name of the configuration parameter."; - - public static final String DS_NEW_ASSIGNED_ACTIONS = "The newly created actions as a result of this assignment"; - - public static final String REPRESENTATION_MODE = "The representation mode. Can be \"full\" or \"compact\". Defaults to \"compact\""; - -} diff --git a/hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/mgmt/documentation/ActionResourceDocumentationTest.java b/hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/mgmt/documentation/ActionResourceDocumentationTest.java deleted file mode 100644 index a5431f35d2..0000000000 --- a/hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/mgmt/documentation/ActionResourceDocumentationTest.java +++ /dev/null @@ -1,165 +0,0 @@ -/** - * Copyright (c) 2018 Bosch Software Innovations GmbH and others - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - */ -package org.eclipse.hawkbit.rest.mgmt.documentation; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get; -import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields; -import static org.springframework.restdocs.request.RequestDocumentation.*; -import static org.springframework.restdocs.snippet.Attributes.key; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - -import java.util.List; - -import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants; -import org.eclipse.hawkbit.repository.ActionStatusFields; -import org.eclipse.hawkbit.repository.model.Action; -import org.eclipse.hawkbit.rest.documentation.AbstractApiRestDocumentation; -import org.eclipse.hawkbit.rest.documentation.ApiModelPropertiesGeneric; -import org.eclipse.hawkbit.rest.documentation.MgmtApiModelProperties; -import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter; -import org.junit.jupiter.api.Test; -import org.springframework.data.domain.PageRequest; -import org.springframework.data.domain.Sort.Direction; -import org.springframework.restdocs.payload.JsonFieldType; - -import io.qameta.allure.Description; -import io.qameta.allure.Feature; -import io.qameta.allure.Story; - -/** - * Documentation generation for Management API for {@link Action}. - */ -@Feature("Spring Rest Docs Tests - Action") -@Story("Action Resource") -public class ActionResourceDocumentationTest extends AbstractApiRestDocumentation { - - private final String targetId = "target137"; - - @Override - public String getResourceName() { - return "actions"; - } - - @Test - @Description("Handles the GET request of retrieving all actions. Required Permission: READ_TARGET.") - public void getActions() throws Exception { - enableMultiAssignments(); - final Action action = generateRolloutActionForTarget(targetId); - provideCodeFeedback(action, 200); - - mockMvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING)).andExpect(status().isOk()) - .andDo(MockMvcResultPrinter.print()) - .andDo(this.document.document(responseFields( - fieldWithPath("size").type(JsonFieldType.NUMBER).description(ApiModelPropertiesGeneric.SIZE), - fieldWithPath("total").description(ApiModelPropertiesGeneric.TOTAL_ELEMENTS), - fieldWithPath("content[]").description(MgmtApiModelProperties.ACTION_LIST), - fieldWithPath("content[].createdBy").description(ApiModelPropertiesGeneric.CREATED_BY), - fieldWithPath("content[].createdAt").description(ApiModelPropertiesGeneric.CREATED_AT), - fieldWithPath("content[].lastModifiedBy") - .description(ApiModelPropertiesGeneric.LAST_MODIFIED_BY).type("String"), - fieldWithPath("content[].lastModifiedAt") - .description(ApiModelPropertiesGeneric.LAST_MODIFIED_AT).type("String"), - fieldWithPath("content[].type").description(MgmtApiModelProperties.ACTION_TYPE) - .attributes(key("value").value("['update', 'cancel']")), - - fieldWithPath("content[].status").description(MgmtApiModelProperties.ACTION_EXECUTION_STATUS) - .attributes(key("value").value("['finished', 'pending']")), - fieldWithPath("content[].detailStatus").description(MgmtApiModelProperties.ACTION_DETAIL_STATUS) - .attributes(key("value").value( - "['finished', 'error', 'running', 'warning', 'scheduled', 'canceling', 'canceled', 'download', 'downloaded', 'retrieved', 'cancel_rejected']")), - optionalRequestFieldWithPath("content[].lastStatusCode") - .description(MgmtApiModelProperties.ACTION_LAST_STATUS_CODE).type("Integer"), - fieldWithPath("content[]._links").description(MgmtApiModelProperties.LINK_TO_ACTION), - fieldWithPath("content[].id").description(MgmtApiModelProperties.ACTION_ID), - fieldWithPath("content[].weight").description(MgmtApiModelProperties.ACTION_WEIGHT), - fieldWithPath("content[].rollout").description(MgmtApiModelProperties.ACTION_ROLLOUT), - fieldWithPath("content[].rolloutName") - .description(MgmtApiModelProperties.ACTION_ROLLOUT_NAME)))); - } - - @Test - @Description("Handles the GET request of retrieving all actions based on parameters. Required Permission: READ_TARGET.") - public void getActionsWithParameters() throws Exception { - final Action action = generateRolloutActionForTarget(targetId); - - mockMvc.perform( - get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING + "?limit=10&sort=id:ASC&offset=0&q=rollout.id==" - + action.getRollout().getId() + "&representation=full")) - .andExpect(status().isOk()).andDo(MockMvcResultPrinter.print()) - .andDo(this.document.document(requestParameters( - parameterWithName("limit").attributes(key("type").value("query")) - .description(ApiModelPropertiesGeneric.LIMIT), - parameterWithName("sort").description(ApiModelPropertiesGeneric.SORT), - parameterWithName("offset").description(ApiModelPropertiesGeneric.OFFSET), - parameterWithName("q").description(ApiModelPropertiesGeneric.FIQL), - parameterWithName("representation").description(MgmtApiModelProperties.REPRESENTATION_MODE)))); - } - - @Test - @Description("Handles the GET request of retrieving a specific action.") - public void getAction() throws Exception { - final Action action = generateRolloutActionForTarget(targetId); - provideCodeFeedback(action, 200); - - assertThat(deploymentManagement.findAction(action.getId()).get().getActionType()) - .isEqualTo(Action.ActionType.FORCED); - - mockMvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING + "/{actionId}", action.getId())) - .andExpect(status().isOk()).andDo(MockMvcResultPrinter.print()) - .andDo(this.document.document( - pathParameters(parameterWithName("actionId").description(ApiModelPropertiesGeneric.ITEM_ID)), - responseFields(fieldWithPath("createdBy").description(ApiModelPropertiesGeneric.CREATED_BY), - fieldWithPath("createdAt").description(ApiModelPropertiesGeneric.CREATED_AT), - fieldWithPath("id").description(MgmtApiModelProperties.ACTION_ID), - fieldWithPath("lastModifiedBy").description(ApiModelPropertiesGeneric.LAST_MODIFIED_BY) - .type("String"), - fieldWithPath("lastModifiedAt").description(ApiModelPropertiesGeneric.LAST_MODIFIED_AT) - .type("String"), - fieldWithPath("type").description(MgmtApiModelProperties.ACTION_TYPE) - .attributes(key("value").value("['update', 'cancel']")), - fieldWithPath("forceType").description(MgmtApiModelProperties.ACTION_FORCE_TYPE) - .attributes(key("value").value("['forced', 'soft', 'timeforced']")), - fieldWithPath("status").description(MgmtApiModelProperties.ACTION_EXECUTION_STATUS) - .attributes(key("value").value("['finished', 'pending']")), - fieldWithPath("detailStatus").description(MgmtApiModelProperties.ACTION_DETAIL_STATUS) - .attributes(key("value").value( - "['finished', 'error', 'running', 'warning', 'scheduled', 'canceling', 'canceled', 'download', 'downloaded', 'retrieved', 'cancel_rejected']")), - optionalRequestFieldWithPath("lastStatusCode") - .description(MgmtApiModelProperties.ACTION_LAST_STATUS_CODE).type("Integer"), - fieldWithPath("rollout").description(MgmtApiModelProperties.ACTION_ROLLOUT), - fieldWithPath("rolloutName").description(MgmtApiModelProperties.ACTION_ROLLOUT_NAME), - fieldWithPath("_links.self").ignored(), - fieldWithPath("_links.distributionset").description(MgmtApiModelProperties.LINK_TO_DS), - fieldWithPath("_links.status") - .description(MgmtApiModelProperties.LINKS_ACTION_STATUSES), - fieldWithPath("_links.rollout").description(MgmtApiModelProperties.LINK_TO_ROLLOUT), - fieldWithPath("_links.target").description(MgmtApiModelProperties.LINK_TO_TARGET)))); - } - - private Action generateRolloutActionForTarget(final String knownControllerId) throws Exception { - return generateActionForTarget(knownControllerId, true, false, null, null, null, true); - } - - private Action generateActionForTarget(final String knownControllerId, final boolean inSync, - final boolean timeforced, final String maintenanceWindowSchedule, final String maintenanceWindowDuration, - final String maintenanceWindowTimeZone, final boolean createRollout) throws Exception { - final PageRequest pageRequest = PageRequest.of(0, 1, Direction.ASC, ActionStatusFields.ID.getFieldName()); - - createTargetByGivenNameWithAttributes(knownControllerId, inSync, timeforced, createDistributionSet(), - maintenanceWindowSchedule, maintenanceWindowDuration, maintenanceWindowTimeZone, createRollout); - - final List actions = deploymentManagement.findActionsAll(pageRequest).getContent(); - - assertThat(actions).hasSize(1); - return actions.get(0); - } - -} diff --git a/hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/mgmt/documentation/DistributionSetTagResourceDocumentationTest.java b/hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/mgmt/documentation/DistributionSetTagResourceDocumentationTest.java deleted file mode 100644 index d2679568a9..0000000000 --- a/hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/mgmt/documentation/DistributionSetTagResourceDocumentationTest.java +++ /dev/null @@ -1,308 +0,0 @@ -/** - * Copyright (c) 2018 Bosch Software Innovations GmbH and others - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - */ -package org.eclipse.hawkbit.rest.mgmt.documentation; - -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.delete; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.post; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.put; -import static org.springframework.restdocs.payload.PayloadDocumentation.requestFields; -import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields; -import static org.springframework.restdocs.request.RequestDocumentation.parameterWithName; -import static org.springframework.restdocs.request.RequestDocumentation.pathParameters; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import org.eclipse.hawkbit.mgmt.json.model.tag.MgmtAssignedDistributionSetRequestBody; -import org.eclipse.hawkbit.mgmt.json.model.tag.MgmtTagRequestBodyPut; -import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants; -import org.eclipse.hawkbit.repository.model.DistributionSet; -import org.eclipse.hawkbit.repository.model.DistributionSetTag; -import org.eclipse.hawkbit.rest.documentation.AbstractApiRestDocumentation; -import org.eclipse.hawkbit.rest.documentation.ApiModelPropertiesGeneric; -import org.eclipse.hawkbit.rest.documentation.DocumenationResponseFieldsSnippet; -import org.eclipse.hawkbit.rest.documentation.MgmtApiModelProperties; -import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.springframework.http.MediaType; -import org.springframework.restdocs.payload.FieldDescriptor; -import org.springframework.restdocs.payload.JsonFieldType; -import org.springframework.restdocs.snippet.Snippet; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; - -import io.qameta.allure.Description; -import io.qameta.allure.Feature; -import io.qameta.allure.Story; - -/** - * Documentation generation for Management API for {@link DistributionSetTag}. - * - */ -@Feature("Spring Rest Docs Tests - DistributionSetTag") -@Story("DistributionSet Tag Resource") -public class DistributionSetTagResourceDocumentationTest extends AbstractApiRestDocumentation { - - private DistributionSet distributionSet; - - @Override - public String getResourceName() { - return "distributionsettag"; - } - - @BeforeEach - public void setUp() { - distributionSet = createDistributionSet(); - } - - @Test - @Description("Handles the GET request of retrieving all distribution set tags") - public void getDistributionSetTags() throws Exception { - createDistributionSetTag(); - arrayPrefix = "content[]."; - mockMvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING)).andExpect(status().isOk()) - .andDo(MockMvcResultPrinter.print()) - .andDo(this.document.document(getResponseFieldsTag(true, - fieldWithPath("size").type(JsonFieldType.NUMBER).description(ApiModelPropertiesGeneric.SIZE), - fieldWithPath("total").description(ApiModelPropertiesGeneric.TOTAL_ELEMENTS), - fieldWithPath("content").description(MgmtApiModelProperties.DS_TAG_LIST)))); - } - - @Test - @Description("Handles the GET request of retrieving all distribution set tags based by parameter") - public void getDistributionSetTagsWithParameters() throws Exception { - createDistributionSetTag(); - mockMvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING - + "?limit=10&sort=name:ASC&offset=0&q=name==DsTag")).andExpect(status().isOk()) - .andDo(MockMvcResultPrinter.print()).andDo(this.document.document(getFilterRequestParamter())); - } - - @Test - @Description("Handles the GET request of retrieving a single distribution set tag") - public void getDistributionSetTag() throws Exception { - final Long tagId = createDistributionSetTagId(); - - mockMvc.perform( - get(MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING + "/{distributionsetTagId}", tagId)) - .andExpect(status().isOk()).andDo(MockMvcResultPrinter.print()) - .andDo(this.document.document(pathParameters( - parameterWithName("distributionsetTagId").description(ApiModelPropertiesGeneric.ITEM_ID)), - getResponseFieldsTag(false))); - } - - @Test - @Description("Handles the POST request of creating new distribution set tag. The request body must always be a list of tags.") - public void createDistributionSetTags() throws Exception { - final MgmtTagRequestBodyPut bodyPut = createDSBody(); - final ObjectMapper mapper = new ObjectMapper(); - final String json = mapper.writeValueAsString(Arrays.asList(bodyPut)); - this.mockMvc - .perform(post(MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING).content(json) - .contentType(MediaType.APPLICATION_JSON)) - .andExpect(status().isCreated()).andDo(MockMvcResultPrinter.print()) - .andDo(this.document.document(getRequestFieldsTag(true), getResponseFieldsTag(true))); - } - - @Test - @Description("Handles the PUT request of updating a single distribution set tag.") - public void updateDistributionSetTag() throws Exception { - final Long tagId = createDistributionSetTagId(); - final MgmtTagRequestBodyPut bodyPut = createDSBody(); - final ObjectMapper mapper = new ObjectMapper(); - final String json = mapper.writeValueAsString(bodyPut); - - this.mockMvc - .perform( - put(MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING + "/{distributionsetTagId}", tagId) - .content(json).contentType(MediaType.APPLICATION_JSON)) - .andExpect(status().isOk()).andDo(MockMvcResultPrinter.print()) - .andDo(this.document.document( - pathParameters(parameterWithName("distributionsetTagId") - .description(ApiModelPropertiesGeneric.ITEM_ID)), - getRequestFieldsTag(false), getResponseFieldsTag(false))); - - } - - private MgmtTagRequestBodyPut createDSBody() { - final MgmtTagRequestBodyPut bodyPut = new MgmtTagRequestBodyPut(); - bodyPut.setColour("red"); - bodyPut.setDescription("ds tag description"); - bodyPut.setName("ds tag"); - return bodyPut; - } - - @Test - @Description("Handles the DELETE request for a single distribution set tag") - public void deleteDistributionSetTag() throws Exception { - final Long tagId = createDistributionSetTagId(); - this.mockMvc - .perform(delete(MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING + "/{distributionsetTagId}", - tagId).contentType(MediaType.APPLICATION_JSON)) - .andExpect(status().isOk()).andDo(MockMvcResultPrinter.print()) - .andDo(this.document.document(pathParameters( - parameterWithName("distributionsetTagId").description(ApiModelPropertiesGeneric.ITEM_ID)))); - } - - @Test - @Description("Handles the GET request of retrieving all assigned distribution sets by the given tag id.") - public void getAssignedDistributionSets() throws Exception { - final DistributionSetTag tag = createDistributionSetTag(); - distributionSetManagement.assignTag(Arrays.asList(distributionSet.getId()), tag.getId()); - - arrayPrefix = "content[]."; - this.mockMvc - .perform(get(MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING - + MgmtRestConstants.DISTRIBUTIONSET_TAG_DISTRIBUTIONSETS_REQUEST_MAPPING, tag.getId()) - .contentType(MediaType.APPLICATION_JSON)) - .andExpect(status().isOk()).andDo(MockMvcResultPrinter.print()) - .andDo(this.document.document( - pathParameters(parameterWithName("distributionsetTagId") - .description(ApiModelPropertiesGeneric.ITEM_ID)), - getResponseFieldsDistributionSet(true, - fieldWithPath("size").type(JsonFieldType.NUMBER) - .description(ApiModelPropertiesGeneric.SIZE), - fieldWithPath("total").description(ApiModelPropertiesGeneric.TOTAL_ELEMENTS), - fieldWithPath("content").description(MgmtApiModelProperties.DS_TAG_LIST)))); - } - - @Test - @Description("andles the POST request to toggle the assignment of distribution sets by the given tag id.") - public void toggleTagAssignment() throws Exception { - final DistributionSet unassignDS = testdataFactory.createDistributionSet("unassign"); - final Long tagId = createDistributionSetTagId(); - final MgmtAssignedDistributionSetRequestBody body = new MgmtAssignedDistributionSetRequestBody(); - body.setDistributionSetId(distributionSet.getId()); - final ObjectMapper mapper = new ObjectMapper(); - final String json = mapper.writeValueAsString(Arrays.asList(body)); - - this.mockMvc - .perform(post(MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING - + MgmtRestConstants.DISTRIBUTIONSET_TAG_DISTRIBUTIONSETS_REQUEST_MAPPING - + "/toggleTagAssignment", tagId).content(json).contentType(MediaType.APPLICATION_JSON)) - .andExpect(status().isOk()).andDo(MockMvcResultPrinter.print()) - .andDo(this.document.document( - pathParameters(parameterWithName("distributionsetTagId") - .description(ApiModelPropertiesGeneric.ITEM_ID)), - getRequestFieldsDistributionSetAssignment(true), - getResponseAssignmentResult(distributionSet, unassignDS) - - )); - } - - @Test - @Description("Handles the POST request to assign distribution sets to the given tag id.") - public void assignDistributionSets() throws Exception { - final Long tagId = createDistributionSetTagId(); - final MgmtAssignedDistributionSetRequestBody body = new MgmtAssignedDistributionSetRequestBody(); - body.setDistributionSetId(distributionSet.getId()); - final ObjectMapper mapper = new ObjectMapper(); - final String json = mapper.writeValueAsString(Arrays.asList(body)); - - this.mockMvc - .perform(post(MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING - + MgmtRestConstants.DISTRIBUTIONSET_TAG_DISTRIBUTIONSETS_REQUEST_MAPPING, tagId).content(json) - .contentType(MediaType.APPLICATION_JSON)) - .andExpect(status().isOk()).andDo(MockMvcResultPrinter.print()) - .andDo(this.document.document( - pathParameters(parameterWithName("distributionsetTagId") - .description(ApiModelPropertiesGeneric.ITEM_ID)), - getRequestFieldsDistributionSetAssignment(true), getResponseFieldsDistributionSet(true))); - } - - @Test - @Description("Handles the DELETE request to unassign one distribution set from the given tag id.") - public void unassignDistributionSet() throws Exception { - final Long tagId = createDistributionSetTagId(); - - this.mockMvc - .perform(delete(MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING - + MgmtRestConstants.DISTRIBUTIONSET_TAG_DISTRIBUTIONSETS_REQUEST_MAPPING - + "/{distributionsetId}", tagId, distributionSet.getId()) - .contentType(MediaType.APPLICATION_JSON)) - .andExpect(status().isOk()).andDo(MockMvcResultPrinter.print()) - .andDo(this.document.document(pathParameters( - parameterWithName("distributionsetTagId").description(ApiModelPropertiesGeneric.ITEM_ID), - parameterWithName("distributionsetId").description(ApiModelPropertiesGeneric.ITEM_ID)))); - } - - private Snippet getRequestFieldsTag(final boolean isArray) { - final String arrayPrefix = getArrayPrefix(isArray); - - return requestFields(requestFieldWithPath(arrayPrefix + "name").description(ApiModelPropertiesGeneric.NAME), - requestFieldWithPath(arrayPrefix + "description").description(ApiModelPropertiesGeneric.DESCRPTION), - optionalRequestFieldWithPath(arrayPrefix + "colour").description(ApiModelPropertiesGeneric.COLOUR)); - } - - private Snippet getRequestFieldsDistributionSetAssignment(final boolean isArray) { - final String arrayPrefix = getArrayPrefix(isArray); - - return requestFields(requestFieldWithPath(arrayPrefix + "id").description(ApiModelPropertiesGeneric.ITEM_ID)); - } - - private Snippet getResponseFieldsTag(final boolean isArray, final FieldDescriptor... descriptors) - throws JsonProcessingException { - final String arrayPrefix = getArrayPrefix(isArray); - final List allFieldDescriptor = new ArrayList<>(); - allFieldDescriptor.addAll(Arrays.asList(descriptors)); - - allFieldDescriptor.add(fieldWithPath(arrayPrefix + "id").description(ApiModelPropertiesGeneric.ITEM_ID)); - allFieldDescriptor.add(fieldWithPath(arrayPrefix + "name").description(ApiModelPropertiesGeneric.NAME)); - allFieldDescriptor - .add(fieldWithPath(arrayPrefix + "description").description(ApiModelPropertiesGeneric.DESCRPTION)); - allFieldDescriptor - .add(fieldWithPath(arrayPrefix + "createdBy").description(ApiModelPropertiesGeneric.CREATED_BY)); - allFieldDescriptor - .add(fieldWithPath(arrayPrefix + "createdAt").description(ApiModelPropertiesGeneric.CREATED_AT)); - allFieldDescriptor.add( - fieldWithPath(arrayPrefix + "lastModifiedBy").description(ApiModelPropertiesGeneric.LAST_MODIFIED_BY)); - allFieldDescriptor.add( - fieldWithPath(arrayPrefix + "lastModifiedAt").description(ApiModelPropertiesGeneric.LAST_MODIFIED_AT)); - allFieldDescriptor.add(fieldWithPath(arrayPrefix + "colour").description(ApiModelPropertiesGeneric.COLOUR)); - allFieldDescriptor.add(fieldWithPath(arrayPrefix + "_links.self").ignored()); - - if (!isArray) { - allFieldDescriptor.add(fieldWithPath(arrayPrefix + "_links.assignedDistributionSets") - .description(MgmtApiModelProperties.LINKS_ASSIGNED_DISTRIBUTION_SETS)); - } - - return new DocumenationResponseFieldsSnippet(allFieldDescriptor); - } - - private Snippet getResponseFieldsTag(final boolean isArray) throws JsonProcessingException { - return getResponseFieldsTag(isArray, new FieldDescriptor[0]); - } - - private Snippet getResponseAssignmentResult(final DistributionSet assignment, final DistributionSet unassignment) - throws JsonProcessingException { - return responseFields( - fieldWithPath("assignedDistributionSets").description(MgmtApiModelProperties.ASSIGNED_DISTRIBUTION_SETS) - .type("Array[Object]"), - - fieldWithPath("unassignedDistributionSets") - .description(MgmtApiModelProperties.UN_ASSIGNED_DISTRIBUTION_SETS).type("Array[Object]")); - } - - private DistributionSetTag createDistributionSetTag() { - final DistributionSetTag updateTag = distributionSetTagManagement - .create(entityFactory.tag().create().name("DsTag")); - return distributionSetTagManagement.update(entityFactory.tag().update(updateTag.getId()) - .description("My name is " + updateTag.getName()).colour("default")); - } - - private Long createDistributionSetTagId() { - return createDistributionSetTag().getId(); - } - -} diff --git a/hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/mgmt/documentation/DistributionSetTypesDocumentationTest.java b/hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/mgmt/documentation/DistributionSetTypesDocumentationTest.java deleted file mode 100644 index 89b2b3b1c3..0000000000 --- a/hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/mgmt/documentation/DistributionSetTypesDocumentationTest.java +++ /dev/null @@ -1,449 +0,0 @@ -/** - * Copyright (c) 2018 Bosch Software Innovations GmbH and others - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - */ -package org.eclipse.hawkbit.rest.mgmt.documentation; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.hamcrest.CoreMatchers.equalTo; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.delete; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.post; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.put; -import static org.springframework.restdocs.payload.PayloadDocumentation.requestFields; -import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields; -import static org.springframework.restdocs.request.RequestDocumentation.parameterWithName; -import static org.springframework.restdocs.request.RequestDocumentation.pathParameters; -import static org.springframework.restdocs.request.RequestDocumentation.requestParameters; -import static org.springframework.restdocs.snippet.Attributes.key; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.hawkbit.im.authentication.SpPermission; -import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants; -import org.eclipse.hawkbit.repository.model.DistributionSetType; -import org.eclipse.hawkbit.repository.test.util.WithUser; -import org.eclipse.hawkbit.rest.documentation.AbstractApiRestDocumentation; -import org.eclipse.hawkbit.rest.documentation.ApiModelPropertiesGeneric; -import org.eclipse.hawkbit.rest.documentation.MgmtApiModelProperties; -import org.eclipse.hawkbit.rest.util.JsonBuilder; -import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter; -import org.json.JSONObject; -import org.junit.jupiter.api.Test; -import org.springframework.http.MediaType; -import org.springframework.restdocs.payload.JsonFieldType; - -import io.qameta.allure.Description; -import io.qameta.allure.Feature; -import io.qameta.allure.Story; - -/** - * Documentation generation for Management API for {@link DistributionSetType}. - * - */ -@Feature("Spring Rest Docs Tests - DistributionSetType") -@Story("DistributionSetTypes Resource") -public class DistributionSetTypesDocumentationTest extends AbstractApiRestDocumentation { - - @Override - public String getResourceName() { - return "distributionsettypes"; - } - - @Test - @Description("Handles the GET request of retrieving all distribution set types within SP. Required Permission: READ_REPOSITORY.") - public void getDistributionSetTypes() throws Exception { - - distributionSetTypeManagement.update(entityFactory.distributionSetType() - .update(testdataFactory.createDistributionSet().getType().getId()).description("Desc1234")); - - mockMvc.perform( - get(MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING).accept(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON)) - .andExpect(jsonPath("$.total", equalTo(4))) - .andDo(this.document.document(responseFields( - fieldWithPath("size").type(JsonFieldType.NUMBER).description(ApiModelPropertiesGeneric.SIZE), - fieldWithPath("total").description(ApiModelPropertiesGeneric.TOTAL_ELEMENTS), - fieldWithPath("content").description(MgmtApiModelProperties.TARGET_LIST), - fieldWithPath("content[].createdBy").description(ApiModelPropertiesGeneric.CREATED_BY), - fieldWithPath("content[].createdAt").description(ApiModelPropertiesGeneric.CREATED_AT), - fieldWithPath("content[].description").description(ApiModelPropertiesGeneric.DESCRPTION), - fieldWithPath("content[].key").description(MgmtApiModelProperties.DS_TYPE_KEY), - fieldWithPath("content[].id").description(ApiModelPropertiesGeneric.ITEM_ID), - fieldWithPath("content[].lastModifiedAt") - .description(ApiModelPropertiesGeneric.LAST_MODIFIED_AT).type("Number"), - fieldWithPath("content[].lastModifiedBy") - .description(ApiModelPropertiesGeneric.LAST_MODIFIED_BY).type("String"), - fieldWithPath("content[].name").description(ApiModelPropertiesGeneric.NAME), - fieldWithPath("content[].deleted").description(ApiModelPropertiesGeneric.DELETED), - fieldWithPath("content[]._links.self").ignored()))); - } - - @Test - @Description("Handles the GET request of retrieving all distribution set types within SP with a defined page size and offset, sortet by name in descending order and filtered down to all targets which name starts with 'a'. Required Permission: READ_REPOSITORY.") - public void getDistributionSetTypesWithParameters() throws Exception { - - distributionSetTypeManagement.update( - entityFactory.distributionSetType().update(testdataFactory.createDistributionSet().getType().getId()) - .description("Desc1234").colour("rgb(86,37,99)")); - mockMvc.perform(get(MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING).accept(MediaType.APPLICATION_JSON) - .param("offset", "1").param("limit", "2").param("sort", "name:DESC").param("q", "name==a*")) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON)) - .andDo(this.document.document(getFilterRequestParamter())); - } - - @Test - @WithUser(principal = "uploadTester", allSpPermissions = true) - @Description("Handles the POST request for creating new distribution set types within SP. The request body " - + "must always be a list of types. Required Permission: CREATE_REPOSITORY.") - public void postDistributionSetTypes() throws Exception { - - assertThat(distributionSetTypeManagement.count()).isEqualTo(4); - - final List types = new ArrayList<>(); - types.add(entityFactory.distributionSetType().create().key("test1").name("TestName1").description("Desc1") - .colour("rgb(86,37,99)").mandatory(osType).optional(runtimeType).build()); - - mockMvc.perform(post(MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING) - .content(JsonBuilder.distributionSetTypesCreateValidFieldsOnly(types)) - .contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isCreated()).andDo( - this.document.document( - requestFields( - requestFieldWithPath("[]key").description(MgmtApiModelProperties.DS_TYPE_KEY), - requestFieldWithPath("[]name").description(ApiModelPropertiesGeneric.NAME), - optionalRequestFieldWithPath("[]description") - .description(ApiModelPropertiesGeneric.DESCRPTION), - optionalRequestFieldWithPath("[]colour") - .description(ApiModelPropertiesGeneric.COLOUR), - optionalRequestFieldWithPath("[]mandatorymodules") - .description(MgmtApiModelProperties.DS_TYPE_MANDATORY_MODULES), - optionalRequestFieldWithPath("[]optionalmodules") - .description(MgmtApiModelProperties.DS_TYPE_OPTIONAL_MODULES)), - responseFields( - fieldWithPath("[]createdBy").description(ApiModelPropertiesGeneric.CREATED_BY), - fieldWithPath("[]createdAt").description(ApiModelPropertiesGeneric.CREATED_AT), - fieldWithPath("[]description") - .description(ApiModelPropertiesGeneric.DESCRPTION), - fieldWithPath("[]key").description(MgmtApiModelProperties.DS_TYPE_KEY), - fieldWithPath("[]id").description(ApiModelPropertiesGeneric.ITEM_ID), - fieldWithPath("[]lastModifiedAt") - .description(ApiModelPropertiesGeneric.LAST_MODIFIED_AT).type("Number"), - fieldWithPath("[]lastModifiedBy") - .description(ApiModelPropertiesGeneric.LAST_MODIFIED_BY).type("String"), - fieldWithPath("[]name").description(ApiModelPropertiesGeneric.NAME), - fieldWithPath("[]deleted").description(ApiModelPropertiesGeneric.DELETED), - fieldWithPath("[]colour") - .description(ApiModelPropertiesGeneric.COLOUR), - fieldWithPath("[]_links.self").ignored()))); - } - - @Test - @Description("Handles the GET request of retrieving a single distribution set type within SP. Required Permission: READ_REPOSITORY") - public void deleteDistributionSetType() throws Exception { - final DistributionSetType testType = distributionSetTypeManagement.update( - entityFactory.distributionSetType().update(testdataFactory.createDistributionSet().getType().getId()) - .description("Desc1234").colour("rgb(86,37,99)")); - - mockMvc.perform(delete(MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING + "/{distributionSetTypeId}", - testType.getId())).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andDo(this.document.document(pathParameters( - parameterWithName("distributionSetTypeId").description(ApiModelPropertiesGeneric.ITEM_ID)))); - } - - @Test - @Description("Handles the DELETE request for a single distribution set type within SP. Required Permission: DELETE_REPOSITORY.") - public void getDistributionSetType() throws Exception { - - final DistributionSetType testType = distributionSetTypeManagement.update(entityFactory.distributionSetType() - .update(testdataFactory.createDistributionSet().getType().getId()).description("Desc1234").colour("rgb(86,37,99)")); - - mockMvc.perform(get(MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING + "/{distributionSetTypeId}", - testType.getId()).accept(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) - .andExpect(status().isOk()) - .andDo(this.document.document( - pathParameters(parameterWithName("distributionSetTypeId") - .description(ApiModelPropertiesGeneric.ITEM_ID)), - responseFields(fieldWithPath("createdBy").description(ApiModelPropertiesGeneric.CREATED_BY), - fieldWithPath("createdAt").description(ApiModelPropertiesGeneric.CREATED_AT), - fieldWithPath("description").description(ApiModelPropertiesGeneric.DESCRPTION), - fieldWithPath("key").description(MgmtApiModelProperties.DS_TYPE_KEY), - fieldWithPath("id").description(ApiModelPropertiesGeneric.ITEM_ID), - fieldWithPath("lastModifiedAt").description(ApiModelPropertiesGeneric.LAST_MODIFIED_AT) - .type("Number"), - fieldWithPath("lastModifiedBy").description(ApiModelPropertiesGeneric.LAST_MODIFIED_BY) - .type("String"), - fieldWithPath("name").description(ApiModelPropertiesGeneric.NAME), - fieldWithPath("deleted").description(ApiModelPropertiesGeneric.DELETED), - fieldWithPath("colour").description(ApiModelPropertiesGeneric.COLOUR), - fieldWithPath("_links.self").ignored(), - fieldWithPath("_links.mandatorymodules") - .description(MgmtApiModelProperties.LINK_TO_MANDATORY_SMT), - fieldWithPath("_links.optionalmodules") - .description(MgmtApiModelProperties.LINK_TO_OPTIONAL_SMT)))); - } - - @Test - @Description("Handles the GET request of retrieving all distribution set types within SP based on parameter. Required Permission: READ_REPOSITORY.") - public void getDistributionSetTypesWithParameter() throws Exception { - - mockMvc.perform(get(MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING - + "?limit=10&sort=name:ASC&offset=0&q=name==a")).andExpect(status().isOk()) - .andDo(MockMvcResultPrinter.print()) - .andDo(this.document.document(requestParameters( - parameterWithName("limit").attributes(key("type").value("query")) - .description(ApiModelPropertiesGeneric.LIMIT), - parameterWithName("sort").description(ApiModelPropertiesGeneric.SORT), - parameterWithName("offset").description(ApiModelPropertiesGeneric.OFFSET), - parameterWithName("q").description(ApiModelPropertiesGeneric.FIQL)))); - } - - @Test - @Description("Handles the PUT request for a single distribution set type within SP. Required Permission: UPDATE_REPOSITORY.") - public void putDistributionSetType() throws Exception { - final DistributionSetType testType = distributionSetTypeManagement.update(entityFactory.distributionSetType() - .update(testdataFactory.createDistributionSet().getType().getId()).description("Desc1234")); - final String body = new JSONObject().put("description", "an updated description") - .put("colour", "rgb(106,178,83)").toString(); - - this.mockMvc - .perform(put(MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING + "/{distributionSetTypeId}", - testType.getId()).content(body).contentType(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andDo(this.document.document( - pathParameters(parameterWithName("distributionSetTypeId") - .description(ApiModelPropertiesGeneric.ITEM_ID)), - requestFields( - optionalRequestFieldWithPath("description").description(ApiModelPropertiesGeneric.DESCRPTION), - optionalRequestFieldWithPath("colour").description(ApiModelPropertiesGeneric.COLOUR)), - responseFields(fieldWithPath("createdBy").description(ApiModelPropertiesGeneric.CREATED_BY), - fieldWithPath("createdAt").description(ApiModelPropertiesGeneric.CREATED_AT), - fieldWithPath("description").description(ApiModelPropertiesGeneric.DESCRPTION), - fieldWithPath("key").description(MgmtApiModelProperties.DS_TYPE_KEY), - fieldWithPath("id").description(ApiModelPropertiesGeneric.ITEM_ID), - fieldWithPath("lastModifiedAt").description(ApiModelPropertiesGeneric.LAST_MODIFIED_AT) - .type("Number"), - fieldWithPath("lastModifiedBy").description(ApiModelPropertiesGeneric.LAST_MODIFIED_BY) - .type("String"), - fieldWithPath("name").description(ApiModelPropertiesGeneric.NAME), - fieldWithPath("deleted").description(ApiModelPropertiesGeneric.DELETED), - fieldWithPath("colour").description(ApiModelPropertiesGeneric.COLOUR), - fieldWithPath("_links.self").ignored(), - fieldWithPath("_links.mandatorymodules") - .description(MgmtApiModelProperties.LINK_TO_MANDATORY_SMT), - fieldWithPath("_links.optionalmodules") - .description(MgmtApiModelProperties.LINK_TO_OPTIONAL_SMT)))); - - } - - @Test - @WithUser(principal = "uploadTester", allSpPermissions = true) - @Description("Handles the GET request of retrieving the list of mandatory software module types in that distribution set type. Required Permission: READ_REPOSITORY.") - public void getMandatoryModules() throws Exception { - final DistributionSetType testType = distributionSetTypeManagement - .create(entityFactory.distributionSetType().create().key("test1").name("TestName1").description("Desc1") - .colour("rgb(86,37,99)").mandatory(osType).optional(runtimeType)); - - mockMvc.perform(get(MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING - + "/{distributionSetTypeId}/mandatorymoduletypes", testType.getId()).accept(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON)) - - .andDo(this.document.document( - pathParameters(parameterWithName("distributionSetTypeId") - .description(ApiModelPropertiesGeneric.ITEM_ID)), - responseFields(fieldWithPath("[]createdBy").description(ApiModelPropertiesGeneric.CREATED_BY), - fieldWithPath("[]createdAt").description(ApiModelPropertiesGeneric.CREATED_AT), - fieldWithPath("[]description").description(ApiModelPropertiesGeneric.DESCRPTION), - fieldWithPath("[]key").description(MgmtApiModelProperties.SM_TYPE_KEY), - fieldWithPath("[]maxAssignments") - .description(MgmtApiModelProperties.SMT_MAX_ASSIGNMENTS), - fieldWithPath("[]id").description(ApiModelPropertiesGeneric.ITEM_ID), - fieldWithPath("[]lastModifiedAt") - .description(ApiModelPropertiesGeneric.LAST_MODIFIED_AT).type("Number"), - fieldWithPath("[]lastModifiedBy") - .description(ApiModelPropertiesGeneric.LAST_MODIFIED_BY).type("String"), - fieldWithPath("[]name").description(ApiModelPropertiesGeneric.NAME), - fieldWithPath("[]deleted").description(ApiModelPropertiesGeneric.DELETED), - fieldWithPath("[]_links.self").ignored()))); - - } - - @Test - @Description("Handles the POST request for adding a mandatory software module type to a distribution set type." - + "Note that a DS type cannot be changed after it has been used by a DS. Required Permission: " - + SpPermission.UPDATE_REPOSITORY + " and " + SpPermission.READ_REPOSITORY) - public void postMandatoryModule() throws Exception { - final DistributionSetType testType = distributionSetTypeManagement.create(entityFactory.distributionSetType() - .create().key("test1").name("TestName1").description("Desc1").colour("rgb(86,37,99)")); - - mockMvc.perform(post(MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING - + "/{distributionSetTypeId}/mandatorymoduletypes", testType.getId()) - .content("{\"id\":" + osType.getId() + "}").contentType(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andDo(this.document.document( - pathParameters(parameterWithName("distributionSetTypeId") - .description(ApiModelPropertiesGeneric.ITEM_ID)), - requestFields(requestFieldWithPath("id").description(ApiModelPropertiesGeneric.ITEM_ID)))); - } - - @Test - @Description("Handles the GET request of retrieving the list of software module types in that distribution set. " - + "Note that a DS type cannot be changed after it has been used by a DS. Required permissions: " - + SpPermission.UPDATE_REPOSITORY + " and " + SpPermission.READ_REPOSITORY) - public void deleteMandatoryModule() throws Exception { - final DistributionSetType testType = distributionSetTypeManagement - .create(entityFactory.distributionSetType().create().key("test1").name("TestName1").description("Desc1") - .colour("rgb(86,37,99)").mandatory(osType).optional(runtimeType)); - mockMvc.perform(delete( - MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING - + "/{distributionSetTypeId}/mandatorymoduletypes/{softwareModuleTypeId}", - testType.getId(), osType.getId()).contentType(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andDo(this.document.document(pathParameters( - parameterWithName("distributionSetTypeId").description(ApiModelPropertiesGeneric.ITEM_ID), - parameterWithName("softwareModuleTypeId").description(ApiModelPropertiesGeneric.ITEM_ID)))); - - } - - @Test - @Description("Handles the GET request of retrieving the single mandatory software module type in that distribution set type. Required Permission: " - + SpPermission.READ_REPOSITORY) - public void getMandatoryModule() throws Exception { - final DistributionSetType testType = distributionSetTypeManagement - .create(entityFactory.distributionSetType().create().key("test1").name("TestName1").description("Desc1") - .colour("rgb(86,37,99)").mandatory(osType).optional(runtimeType)); - - mockMvc.perform(get( - MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING - + "/{distributionSetTypeId}/mandatorymoduletypes/{softwareModuleTypeId}", - testType.getId(), osType.getId()).contentType(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andDo(this.document.document(pathParameters( - parameterWithName("distributionSetTypeId").description(ApiModelPropertiesGeneric.ITEM_ID), - parameterWithName("softwareModuleTypeId").description(ApiModelPropertiesGeneric.ITEM_ID)), - responseFields(fieldWithPath("createdBy").description(ApiModelPropertiesGeneric.CREATED_BY), - fieldWithPath("createdAt").description(ApiModelPropertiesGeneric.CREATED_AT), - fieldWithPath("description").description(ApiModelPropertiesGeneric.DESCRPTION), - fieldWithPath("key").description(MgmtApiModelProperties.SM_TYPE_KEY), - fieldWithPath("maxAssignments").description(MgmtApiModelProperties.SMT_MAX_ASSIGNMENTS), - fieldWithPath("id").description(ApiModelPropertiesGeneric.ITEM_ID), - fieldWithPath("lastModifiedAt").description(ApiModelPropertiesGeneric.LAST_MODIFIED_AT) - .type("Number"), - fieldWithPath("lastModifiedBy").description(ApiModelPropertiesGeneric.LAST_MODIFIED_BY) - .type("String"), - fieldWithPath("name").description(ApiModelPropertiesGeneric.NAME), - fieldWithPath("deleted").description(ApiModelPropertiesGeneric.DELETED), - fieldWithPath("_links.self").ignored()))); - } - - @Test - @Description("Handles the GET request of retrieving the list of optional software module types in that distribution set type. Required Permission: " - + SpPermission.READ_REPOSITORY) - public void getOptionalModules() throws Exception { - final DistributionSetType testType = distributionSetTypeManagement - .create(entityFactory.distributionSetType().create().key("test1").name("TestName1").description("Desc1") - .colour("rgb(86,37,99)").mandatory(osType).optional(runtimeType)); - mockMvc.perform(get(MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING - + "/{distributionSetTypeId}/optionalmoduletypes", testType.getId()).accept(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON)) - .andDo(this.document.document( - pathParameters(parameterWithName("distributionSetTypeId") - .description(ApiModelPropertiesGeneric.ITEM_ID)), - responseFields(fieldWithPath("[]createdBy").description(ApiModelPropertiesGeneric.CREATED_BY), - fieldWithPath("[]createdAt").description(ApiModelPropertiesGeneric.CREATED_AT), - fieldWithPath("[]description").description(ApiModelPropertiesGeneric.DESCRPTION), - fieldWithPath("[]colour").description(ApiModelPropertiesGeneric.COLOUR), - fieldWithPath("[]key").description(MgmtApiModelProperties.SM_TYPE_KEY), - fieldWithPath("[]maxAssignments") - .description(MgmtApiModelProperties.SMT_MAX_ASSIGNMENTS), - fieldWithPath("[]id").description(ApiModelPropertiesGeneric.ITEM_ID), - fieldWithPath("[]lastModifiedAt") - .description(ApiModelPropertiesGeneric.LAST_MODIFIED_AT), - fieldWithPath("[]lastModifiedBy") - .description(ApiModelPropertiesGeneric.LAST_MODIFIED_BY), - fieldWithPath("[]name").description(ApiModelPropertiesGeneric.NAME), - fieldWithPath("[]deleted").description(ApiModelPropertiesGeneric.DELETED), - fieldWithPath("[]_links.self").ignored()))); - } - - @Test - @Description("Handles the POST request for adding an optional software module type to a distribution set type." - + "Note that a DS type cannot be changed after it has been used by a DS. Required Permission: " - + SpPermission.UPDATE_REPOSITORY + " and " + SpPermission.READ_REPOSITORY) - public void postOptionalModule() throws Exception { - final DistributionSetType testType = distributionSetTypeManagement.create(entityFactory.distributionSetType() - .create().key("test1").name("TestName1").description("Desc1").colour("rgb(86,37,99)")); - mockMvc.perform(post(MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING - + "/{distributionSetTypeId}/optionalmoduletypes", testType.getId()) - .content("{\"id\":" + appType.getId() + "}").contentType(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andDo(this.document.document( - pathParameters(parameterWithName("distributionSetTypeId") - .description(ApiModelPropertiesGeneric.ITEM_ID)), - requestFields(requestFieldWithPath("id").description(ApiModelPropertiesGeneric.ITEM_ID)))); - - } - - @Test - @Description("Handles DELETE request for removing an optional module from the distribution set type." - + "Note that a DS type cannot be changed after it has been used by a DS. Required Permission: " - + SpPermission.UPDATE_REPOSITORY + " and " + SpPermission.READ_REPOSITORY) - public void deleteOptionalModule() throws Exception { - final DistributionSetType testType = distributionSetTypeManagement - .create(entityFactory.distributionSetType().create().key("test1").name("TestName1").description("Desc1") - .colour("rgb(86,37,99)").mandatory(osType).optional(runtimeType)); - mockMvc.perform(delete( - MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING - + "/{distributionSetTypeId}/optionalmoduletypes/{softwareModuleTypeId}", - testType.getId(), appType.getId()).contentType(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andDo(this.document.document(pathParameters( - parameterWithName("distributionSetTypeId").description(ApiModelPropertiesGeneric.ITEM_ID), - parameterWithName("softwareModuleTypeId").description(ApiModelPropertiesGeneric.ITEM_ID)))); - } - - @Test - @Description("Handles the GET request of retrieving the single optional software module type in that distribution set type. Required Permission: " - + SpPermission.READ_REPOSITORY) - public void getOptionalModule() throws Exception { - final DistributionSetType testType = distributionSetTypeManagement - .create(entityFactory.distributionSetType().create().key("test1").name("TestName1").description("Desc1") - .colour("rgb(86,37,99)").mandatory(osType).optional(appType)); - - mockMvc.perform(get( - MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING - + "/{distributionSetTypeId}/optionalmoduletypes/{softwareModuleTypeId}", - testType.getId(), appType.getId()).contentType(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andDo(this.document.document(pathParameters( - parameterWithName("distributionSetTypeId").description(ApiModelPropertiesGeneric.ITEM_ID), - parameterWithName("softwareModuleTypeId").description(ApiModelPropertiesGeneric.ITEM_ID)), - responseFields(fieldWithPath("createdBy").description(ApiModelPropertiesGeneric.CREATED_BY), - fieldWithPath("createdAt").description(ApiModelPropertiesGeneric.CREATED_AT), - fieldWithPath("description").description(ApiModelPropertiesGeneric.DESCRPTION), - fieldWithPath("key").description(MgmtApiModelProperties.SM_TYPE_KEY), - fieldWithPath("maxAssignments").description(MgmtApiModelProperties.SMT_MAX_ASSIGNMENTS), - fieldWithPath("id").description(ApiModelPropertiesGeneric.ITEM_ID), - fieldWithPath("lastModifiedAt").description(ApiModelPropertiesGeneric.LAST_MODIFIED_AT) - .type("Number"), - fieldWithPath("lastModifiedBy").description(ApiModelPropertiesGeneric.LAST_MODIFIED_BY) - .type("String"), - fieldWithPath("name").description(ApiModelPropertiesGeneric.NAME), - fieldWithPath("deleted").description(ApiModelPropertiesGeneric.DELETED), - fieldWithPath("_links.self").ignored()))); - } - -} diff --git a/hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/mgmt/documentation/DistributionSetsDocumentationTest.java b/hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/mgmt/documentation/DistributionSetsDocumentationTest.java deleted file mode 100644 index 393fa2a2bb..0000000000 --- a/hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/mgmt/documentation/DistributionSetsDocumentationTest.java +++ /dev/null @@ -1,699 +0,0 @@ -/** - * Copyright (c) 2018 Bosch Software Innovations GmbH and others - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - */ -package org.eclipse.hawkbit.rest.mgmt.documentation; - -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.delete; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.post; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.put; -import static org.springframework.restdocs.payload.PayloadDocumentation.requestFields; -import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields; -import static org.springframework.restdocs.request.RequestDocumentation.parameterWithName; -import static org.springframework.restdocs.request.RequestDocumentation.pathParameters; -import static org.springframework.restdocs.request.RequestDocumentation.requestParameters; -import static org.springframework.restdocs.snippet.Attributes.key; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - -import java.util.Arrays; -import java.util.List; -import java.util.stream.Collectors; - -import org.eclipse.hawkbit.im.authentication.SpPermission; -import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants; -import org.eclipse.hawkbit.repository.model.Action; -import org.eclipse.hawkbit.repository.model.Action.Status; -import org.eclipse.hawkbit.repository.model.DistributionSet; -import org.eclipse.hawkbit.repository.model.SoftwareModule; -import org.eclipse.hawkbit.repository.model.Target; -import org.eclipse.hawkbit.rest.documentation.AbstractApiRestDocumentation; -import org.eclipse.hawkbit.rest.documentation.ApiModelPropertiesGeneric; -import org.eclipse.hawkbit.rest.documentation.MgmtApiModelProperties; -import org.eclipse.hawkbit.rest.util.JsonBuilder; -import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter; -import org.json.JSONArray; -import org.json.JSONObject; -import org.junit.jupiter.api.Test; -import org.springframework.hateoas.MediaTypes; -import org.springframework.http.MediaType; -import org.springframework.restdocs.payload.JsonFieldType; - -import com.google.common.collect.Lists; - -import io.qameta.allure.Description; -import io.qameta.allure.Feature; -import io.qameta.allure.Story; - -/** - * Documentation generation for Management API for {@link DistributionSet}. - */ -@Feature("Spring Rest Docs Tests - DistributionSet") -@Story("DistributionSet Resource") -public class DistributionSetsDocumentationTest extends AbstractApiRestDocumentation { - - @Override - public String getResourceName() { - return "distributionsets"; - } - - @Test - @Description("Get Distribution Set. Handles the GET request of retrieving a single distribution set within SP. Required Permission: " - + SpPermission.READ_REPOSITORY) - public void getDistributionSet() throws Exception { - final DistributionSet set = testdataFactory.createUpdatedDistributionSet(); - - mockMvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/{distributionSetId}", set.getId()) - .accept(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON)) - .andDo(this.document.document( - pathParameters( - parameterWithName("distributionSetId").description(ApiModelPropertiesGeneric.ITEM_ID)), - getResponseFieldsDistributionSet(false))); - } - - @Test - @Description("Get paged list of Distribution Sets. Required Permission: " + SpPermission.READ_REPOSITORY) - public void getDistributionSets() throws Exception { - testdataFactory.createUpdatedDistributionSet(); - - mockMvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING).accept(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON)) - .andDo(this.document.document(responseFields( - fieldWithPath("total").description(ApiModelPropertiesGeneric.TOTAL_ELEMENTS), - fieldWithPath("size").type(JsonFieldType.NUMBER).description(ApiModelPropertiesGeneric.SIZE), - fieldWithPath("content").description(MgmtApiModelProperties.DS_LIST), - fieldWithPath("content[].id").description(ApiModelPropertiesGeneric.ITEM_ID), - fieldWithPath("content[].name").description(ApiModelPropertiesGeneric.NAME), - fieldWithPath("content[].description").description(ApiModelPropertiesGeneric.DESCRPTION), - fieldWithPath("content[].createdBy").description(ApiModelPropertiesGeneric.CREATED_BY), - fieldWithPath("content[].createdAt").description(ApiModelPropertiesGeneric.CREATED_AT), - fieldWithPath("content[].lastModifiedBy") - .description(ApiModelPropertiesGeneric.LAST_MODIFIED_BY), - fieldWithPath("content[].lastModifiedAt") - .description(ApiModelPropertiesGeneric.LAST_MODIFIED_AT), - fieldWithPath("content[].type").description(MgmtApiModelProperties.DS_TYPE), - fieldWithPath("content[].typeName").description(MgmtApiModelProperties.DS_TYPE_NAME), - fieldWithPath("content[].requiredMigrationStep") - .description(MgmtApiModelProperties.DS_REQUIRED_STEP), - fieldWithPath("content[].complete").description(MgmtApiModelProperties.DS_COMPLETE), - fieldWithPath("content[].deleted").description(ApiModelPropertiesGeneric.DELETED), - fieldWithPath("content[].version").description(MgmtApiModelProperties.VERSION), - fieldWithPath("content[]._links.self").ignored()))); - } - - @Test - @Description("Get paged list of Distribution Sets with given page size and offset including sorting by name descending and filter down to all sets which name starts with 'testDs'. Required Permission: " - + SpPermission.READ_REPOSITORY) - public void getDistributionSetsWithParameters() throws Exception { - - final List sets = testdataFactory.createDistributionSets("testDS", 3); - - sets.forEach(set -> distributionSetManagement - .update(entityFactory.distributionSet().update(set.getId()).description("updated description"))); - - mockMvc.perform( - get(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING).param("offset", "1").param("limit", "2") - .param("sort", "version:DESC").param("q", "name==testDS*").accept(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON)) - .andDo(this.document.document(getFilterRequestParamter())); - - } - - @Test - @Description("Handles the DELETE request for a single Distribution Set within SP. Required Permission: " - + SpPermission.DELETE_REPOSITORY) - public void deleteDistributionSet() throws Exception { - final DistributionSet set = testdataFactory.createUpdatedDistributionSet(); - - this.mockMvc - .perform(delete(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/{distributionSetId}", - set.getId())) - .andExpect(status().isOk()).andDo(MockMvcResultPrinter.print()) - .andDo(this.document.document(pathParameters( - parameterWithName("distributionSetId").description(ApiModelPropertiesGeneric.ITEM_ID)))); - } - - @Test - @Description("Create Distribution Sets. Handles the POST request of creating new distribution sets within SP. The request body must always be a list of sets. Required Permission: " - + SpPermission.CREATE_REPOSITORY) - public void createDistributionSets() throws Exception { - - final SoftwareModule ah = testdataFactory.createSoftwareModuleApp(); - final SoftwareModule os = testdataFactory.createSoftwareModuleOs(); - - final DistributionSet one = testdataFactory.generateDistributionSet("one", "one", standardDsType, - Arrays.asList(os, ah)); - final DistributionSet two = testdataFactory.generateDistributionSet("two", "two", standardDsType, - Arrays.asList(os, ah)); - final DistributionSet three = testdataFactory.generateDistributionSet("three", "three", standardDsType, - Arrays.asList(os, ah), true); - - final List sets = Arrays.asList(one, two, three); - - this.mockMvc - .perform(post(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/") - .content(JsonBuilder.distributionSetsCreateValidFieldsOnly(sets)) - .contentType(MediaType.APPLICATION_JSON)) - .andExpect(status().isCreated()).andDo(MockMvcResultPrinter.print()) - .andDo(this.document.document( - requestFields(requestFieldWithPath("[]name").description(ApiModelPropertiesGeneric.NAME), - requestFieldWithPath("[]description").description(ApiModelPropertiesGeneric.DESCRPTION), - requestFieldWithPath("[]version").description(MgmtApiModelProperties.VERSION), - optionalRequestFieldWithPath("[]requiredMigrationStep") - .description(MgmtApiModelProperties.DS_REQUIRED_STEP), - requestFieldWithPath("[]type").description(MgmtApiModelProperties.DS_TYPE), - optionalRequestFieldWithPath("[]modules").ignored()), - getResponseFieldsDistributionSet(true))); - } - - @Test - @Description("Handles the UPDATE request for a single Distribution Set within SP. Required Permission: " - + SpPermission.UPDATE_REPOSITORY) - public void updateDistributionSet() throws Exception { - final DistributionSet set = testdataFactory.createUpdatedDistributionSet(); - - final DistributionSet update = entityFactory.distributionSet().create().name("another Name") - .version("another Version").description("a new description").requiredMigrationStep(true).build(); - - mockMvc.perform(put(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/{distributionSetId}", set.getId()) - .content(JsonBuilder.distributionSetUpdateValidFieldsOnly(update)) - .contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON)) - .andDo(this.document.document( - pathParameters( - parameterWithName("distributionSetId").description(ApiModelPropertiesGeneric.ITEM_ID)), - requestFields(optionalRequestFieldWithPath("name").description(ApiModelPropertiesGeneric.NAME), - optionalRequestFieldWithPath("version").description(MgmtApiModelProperties.VERSION), - optionalRequestFieldWithPath("description") - .description(ApiModelPropertiesGeneric.DESCRPTION), - optionalRequestFieldWithPath("requiredMigrationStep") - .description(MgmtApiModelProperties.DS_REQUIRED_STEP)), - getResponseFieldsDistributionSet(false))); - } - - @Test - @Description("Handles the GET request for retrieving assigned targets of a single distribution set. Required Permission: " - + SpPermission.READ_REPOSITORY + " and " + SpPermission.READ_TARGET) - public void getAssignedTargets() throws Exception { - final DistributionSet set = testdataFactory.createUpdatedDistributionSet(); - - final Target target = testdataFactory.createTarget(); - // assign knownTargetId to distribution set - assignDistributionSet(set.getId(), target.getControllerId()); - - mockMvc.perform( - get(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/{distributionSetId}/assignedTargets", - set.getId()).accept(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON)) - .andDo(this.document.document( - pathParameters( - parameterWithName("distributionSetId").description(ApiModelPropertiesGeneric.ITEM_ID)), - responseFields(fieldWithPath("total").description(ApiModelPropertiesGeneric.TOTAL_ELEMENTS), - fieldWithPath("size").type(JsonFieldType.NUMBER) - .description(ApiModelPropertiesGeneric.SIZE), - fieldWithPath("content").description(MgmtApiModelProperties.TARGET_LIST) - .type("Array[Object]")))); - - } - - @Test - @Description("Handles the GET request for retrieving assigned target filter queries of a single distribution set. Required Permission: " - + SpPermission.READ_REPOSITORY + " and " + SpPermission.READ_TARGET) - public void getAutoAssignTargetFilterQueries() throws Exception { - final DistributionSet set = testdataFactory.createUpdatedDistributionSet(); - targetFilterQueryManagement.create(entityFactory.targetFilterQuery().create().name("filter1").query("name==a") - .autoAssignDistributionSet(set)); - targetFilterQueryManagement.create(entityFactory.targetFilterQuery().create().name("filter2").query("name==b") - .autoAssignDistributionSet(set)); - - mockMvc.perform(get( - MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/{distributionSetId}/autoAssignTargetFilters", - set.getId()).accept(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) - .andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_JSON)) - .andDo(this.document.document( - pathParameters( - parameterWithName("distributionSetId").description(ApiModelPropertiesGeneric.ITEM_ID)), - responseFields(fieldWithPath("total").description(ApiModelPropertiesGeneric.TOTAL_ELEMENTS), - fieldWithPath("size").type(JsonFieldType.NUMBER) - .description(ApiModelPropertiesGeneric.SIZE), - fieldWithPath("content").description(MgmtApiModelProperties.TARGET_FILTER_QUERIES_LIST) - .type("Array[Object]")))); - - } - - @Test - @Description("Handles the GET request for retrieving assigned target filter queries of a single distribution set with a defined page size and offset, sorted by name in descending order and filtered down to all targets with a name that ends with '1'. Required Permission: " - + SpPermission.READ_REPOSITORY + " and " + SpPermission.READ_TARGET) - public void getAutoAssignTargetFilterQueriesWithParameters() throws Exception { - final DistributionSet set = testdataFactory.createUpdatedDistributionSet(); - targetFilterQueryManagement.create(entityFactory.targetFilterQuery().create().name("filter1").query("name==a") - .autoAssignDistributionSet(set)); - - mockMvc.perform(get( - MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + set.getId() + "/autoAssignTargetFilters") - .param("offset", "1").param("limit", "2").param("sort", "name:DESC").param("q", "name==*1") - .accept(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON)) - .andDo(this.document.document(requestParameters( - parameterWithName("limit").attributes(key("type").value("query")) - .description(ApiModelPropertiesGeneric.LIMIT), - parameterWithName("sort").description(ApiModelPropertiesGeneric.SORT), - parameterWithName("offset").description(ApiModelPropertiesGeneric.OFFSET), - parameterWithName("q").description(ApiModelPropertiesGeneric.FIQL)))); - - } - - @Test - @Description("Handles the GET request for retrieving assigned targets of a single distribution set with a defined page size and offset, sorted by name in descending order and filtered down to all targets which controllerID starts with 'target'. Required Permission: " - + SpPermission.READ_REPOSITORY + " and " + SpPermission.READ_TARGET) - public void getAssignedTargetsWithParameters() throws Exception { - final DistributionSet set = testdataFactory.createUpdatedDistributionSet(); - - assignDistributionSet(set, testdataFactory.createTargets(5, "targetMisc", "Test targets for query")) - .getAssignedEntity(); - - mockMvc.perform( - get(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + set.getId() + "/assignedTargets") - .param("offset", "1").param("limit", "2").param("sort", "name:DESC") - .param("q", "controllerId==target*").accept(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON)) - .andDo(this.document.document(requestParameters( - parameterWithName("limit").attributes(key("type").value("query")) - .description(ApiModelPropertiesGeneric.LIMIT), - parameterWithName("sort").description(ApiModelPropertiesGeneric.SORT), - parameterWithName("offset").description(ApiModelPropertiesGeneric.OFFSET), - parameterWithName("q").description(ApiModelPropertiesGeneric.FIQL)))); - - } - - @Test - @Description("Handles the GET request for retrieving installed targets of a single distribution set with a defined page size and offset, sortet by name in descending order and filtered down to all targets which controllerID starts with 'target'. Required Permission: " - + SpPermission.READ_REPOSITORY + " and " + SpPermission.READ_TARGET) - public void getInstalledTargetsWithParameters() throws Exception { - final DistributionSet set = testdataFactory.createUpdatedDistributionSet(); - - final List targets = assignDistributionSet(set, - testdataFactory.createTargets(5, "targetMisc", "Test targets for query")).getAssignedEntity().stream() - .map(Action::getTarget).collect(Collectors.toList()); - testdataFactory.sendUpdateActionStatusToTargets(targets, Status.FINISHED, "some message"); - - mockMvc.perform( - get(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + set.getId() + "/installedTargets") - .param("offset", "1").param("limit", "2").param("sort", "name:DESC") - .param("q", "controllerId==target*").accept(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON)) - .andDo(this.document.document(requestParameters( - parameterWithName("limit").attributes(key("type").value("query")) - .description(ApiModelPropertiesGeneric.LIMIT), - parameterWithName("sort").description(ApiModelPropertiesGeneric.SORT), - parameterWithName("offset").description(ApiModelPropertiesGeneric.OFFSET), - parameterWithName("q").description(ApiModelPropertiesGeneric.FIQL)))); - } - - @Test - @Description("Handles the GET request for retrieving installed targets of a single distribution set. Required Permission: " - + SpPermission.READ_REPOSITORY + " and " + SpPermission.READ_TARGET) - public void getInstalledTargets() throws Exception { - final DistributionSet set = testdataFactory.createUpdatedDistributionSet(); - - final Target target = testdataFactory.createTarget(); - // assign knownTargetId to distribution set - assignDistributionSet(set.getId(), target.getControllerId()); - // make it in install state - testdataFactory.sendUpdateActionStatusToTargets(Arrays.asList(target), Status.FINISHED, "some message"); - - mockMvc.perform( - get(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/{distributionSetId}/installedTargets", - set.getId()).accept(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON)) - .andDo(this.document.document( - pathParameters( - parameterWithName("distributionSetId").description(ApiModelPropertiesGeneric.ITEM_ID)), - responseFields(fieldWithPath("total").description(ApiModelPropertiesGeneric.TOTAL_ELEMENTS), - fieldWithPath("size").type(JsonFieldType.NUMBER) - .description(ApiModelPropertiesGeneric.SIZE), - fieldWithPath("content").description(MgmtApiModelProperties.TARGET_LIST) - .type("Array[Object]")))); - } - - @Test - @Description("Handles the POST request for assigning multiple targets to a distribution set.The request body must always be a list of target IDs." - + " Required Permission: " + SpPermission.READ_REPOSITORY + " and " + SpPermission.UPDATE_TARGET) - public void createAssignedTarget() throws Exception { - enableConfirmationFlow(); - - final DistributionSet set = testdataFactory.createUpdatedDistributionSet(); - - // prepare targets - final long forceTime = System.currentTimeMillis(); - final String[] knownTargetIds = new String[] { "target1", "target2", "target3", "target4", "target5" }; - final JSONArray list = new JSONArray(); - for (final String targetId : knownTargetIds) { - targetManagement.create(entityFactory.target().create().controllerId(targetId)); - list.put(new JSONObject().put("id", targetId).put("type", "timeforced").put("forcetime", forceTime) - .put("maintenanceWindow", new JSONObject().put("schedule", getTestSchedule(100)) - .put("duration", getTestDuration(10)).put("timezone", getTestTimeZone()))); - } - - // assign already one target to DS - assignDistributionSet(set.getId(), knownTargetIds[0]); - - this.mockMvc - .perform(post( - MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/{distributionSetId}/assignedTargets", - set.getId()).content(list.toString()).contentType(MediaType.APPLICATION_JSON)) - .andExpect(status().isOk()).andDo(MockMvcResultPrinter.print()) - .andDo(this.document.document( - pathParameters( - parameterWithName("distributionSetId").description(ApiModelPropertiesGeneric.ITEM_ID)), - requestParameters(parameterWithName("offline") - .description(MgmtApiModelProperties.OFFLINE_UPDATE).optional()), - requestFields(requestFieldWithPath("[].id").description(ApiModelPropertiesGeneric.ITEM_ID), - requestFieldWithPathMandatoryInMultiAssignMode("[].weight") - .description(MgmtApiModelProperties.ASSIGNMENT_WEIGHT) - .type(JsonFieldType.NUMBER).attributes(key("value").value("0 - 1000")), - optionalRequestFieldWithPath("[].forcetime") - .description(MgmtApiModelProperties.FORCETIME), - optionalRequestFieldWithPath("[].maintenanceWindow") - .description(MgmtApiModelProperties.MAINTENANCE_WINDOW), - optionalRequestFieldWithPath("[].maintenanceWindow.schedule") - .description(MgmtApiModelProperties.MAINTENANCE_WINDOW_SCHEDULE), - optionalRequestFieldWithPath("[].maintenanceWindow.duration") - .description(MgmtApiModelProperties.MAINTENANCE_WINDOW_DURATION), - optionalRequestFieldWithPath("[].maintenanceWindow.timezone") - .description(MgmtApiModelProperties.MAINTENANCE_WINDOW_TIMEZONE), - optionalRequestFieldWithPath("[].type") - .description(MgmtApiModelProperties.ASSIGNMENT_TYPE).attributes( - key("value").value("['soft', 'forced','timeforced', 'downloadonly']")), - optionalRequestFieldWithPath("[].confirmationRequired") - .description(MgmtApiModelProperties.ACTION_CONFIRMATION_REQUIRED) - .type(JsonFieldType.BOOLEAN.toString())), - responseFields( - fieldWithPath("assigned").description(MgmtApiModelProperties.DS_NEW_ASSIGNED_TARGETS), - fieldWithPath("alreadyAssigned").type(JsonFieldType.NUMBER) - .description(MgmtApiModelProperties.DS_ALREADY_ASSIGNED_TARGETS), - fieldWithPath("assignedActions").type(JsonFieldType.ARRAY) - .description(MgmtApiModelProperties.DS_NEW_ASSIGNED_ACTIONS), - fieldWithPath("assignedActions.[].id").type(JsonFieldType.NUMBER) - .description(MgmtApiModelProperties.ACTION_ID), - fieldWithPath("assignedActions.[]._links.self").type(JsonFieldType.OBJECT) - .description(MgmtApiModelProperties.LINK_TO_ACTION), - fieldWithPath("total").type(JsonFieldType.NUMBER) - .description(MgmtApiModelProperties.DS_TOTAL_ASSIGNED_TARGETS)))); - } - - @Test - @Description("Handles the POST request for assigning multiple software modules to a distribution set. The request body must always be a list of software module IDs." - + " Required Permission: " + SpPermission.READ_REPOSITORY + " and " + SpPermission.UPDATE_REPOSITORY) - public void assignSoftwareModules() throws Exception { - // create DisSet - final DistributionSet disSet = testdataFactory.createDistributionSetWithNoSoftwareModules("Jupiter", "398,88"); - - // create Software Modules - final List smIDs = Arrays.asList(testdataFactory.createSoftwareModuleOs().getId(), - testdataFactory.createSoftwareModuleApp().getId()); - final JSONArray list = new JSONArray(); - for (final Long smID : smIDs) { - list.put(new JSONObject().put("id", Long.valueOf(smID))); - } - - // post assignment - mockMvc.perform(post(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/{distributionSetId}/assignedSM", - disSet.getId()).contentType(MediaType.APPLICATION_JSON).content(list.toString())) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andDo(this.document.document( - pathParameters( - parameterWithName("distributionSetId").description(ApiModelPropertiesGeneric.ITEM_ID)), - requestFields(requestFieldWithPath("[]id").description(ApiModelPropertiesGeneric.ITEM_ID)))); - - } - - @Test - @Description("Delete a software module assignment." + " Required Permission: " + SpPermission.UPDATE_REPOSITORY) - public void deleteAssignSoftwareModules() throws Exception { - final DistributionSet set = testdataFactory.createUpdatedDistributionSet(); - - mockMvc.perform(delete( - MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING - + "/{distributionSetId}/assignedSM/{softwareModuleId}", - set.getId(), set.findFirstModuleByType(osType).get().getId()).contentType(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andDo(this.document.document(pathParameters( - parameterWithName("distributionSetId").description(ApiModelPropertiesGeneric.ITEM_ID), - parameterWithName("softwareModuleId").description(ApiModelPropertiesGeneric.ITEM_ID)))); - } - - @Test - @Description("Handles the GET request of retrieving assigned software modules of a single distribution set within SP. Required Permission: " - + SpPermission.READ_REPOSITORY) - public void getAssignedSoftwareModules() throws Exception { - final DistributionSet set = testdataFactory.createUpdatedDistributionSet(); - - // post assignment - mockMvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/{distributionSetId}/assignedSM", - set.getId()).accept(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) - .andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_JSON)) - .andDo(this.document.document( - pathParameters( - parameterWithName("distributionSetId").description(ApiModelPropertiesGeneric.ITEM_ID)), - responseFields(fieldWithPath("total").description(ApiModelPropertiesGeneric.TOTAL_ELEMENTS), - fieldWithPath("size").type(JsonFieldType.NUMBER) - .description(ApiModelPropertiesGeneric.SIZE), - fieldWithPath("content").description(MgmtApiModelProperties.SM_LIST), - fieldWithPath("content[].id").description(ApiModelPropertiesGeneric.ITEM_ID), - fieldWithPath("content[].name").description(ApiModelPropertiesGeneric.NAME), - fieldWithPath("content[].description") - .description(ApiModelPropertiesGeneric.DESCRPTION), - fieldWithPath("content[].vendor").description(MgmtApiModelProperties.VENDOR), - fieldWithPath("content[].createdBy").description(ApiModelPropertiesGeneric.CREATED_BY), - fieldWithPath("content[].createdAt").description(ApiModelPropertiesGeneric.CREATED_AT), - fieldWithPath("content[].lastModifiedBy") - .description(ApiModelPropertiesGeneric.LAST_MODIFIED_BY), - fieldWithPath("content[].lastModifiedAt") - .description(ApiModelPropertiesGeneric.LAST_MODIFIED_AT), - fieldWithPath("content[].type").description(MgmtApiModelProperties.SM_TYPE), - fieldWithPath("content[].version").description(MgmtApiModelProperties.VERSION), - fieldWithPath("content[]._links.self").ignored()))); - } - - @Test - @Description("Handles the GET request of retrieving assigned software modules of a single distribution set within SP with given page size and offset including sorting by version descending and filter down to all sets which name starts with 'one'. Required Permission: " - + SpPermission.READ_REPOSITORY) - public void getAssignedSoftwareModulesWithParameters() throws Exception { - final DistributionSet set = testdataFactory.createUpdatedDistributionSet(); - - // post assignment - mockMvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + set.getId() + "/assignedSM") - .param("offset", "1").param("limit", "2").param("sort", "version:DESC").param("q", "name==one*") - .accept(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON)) - .andDo(this.document.document(requestParameters( - parameterWithName("limit").attributes(key("type").value("query")) - .description(ApiModelPropertiesGeneric.LIMIT), - parameterWithName("sort").description(ApiModelPropertiesGeneric.SORT), - parameterWithName("offset").description(ApiModelPropertiesGeneric.OFFSET), - parameterWithName("q").description(ApiModelPropertiesGeneric.FIQL)))); - } - - @Test - @Description("Get a paged list of meta data for a distribution set with standard page size." - + " Required Permission: " + SpPermission.READ_REPOSITORY) - public void getMetadata() throws Exception { - final int totalMetadata = 4; - final String knownKeyPrefix = "knownKey"; - final String knownValuePrefix = "knownValue"; - final DistributionSet testDS = testdataFactory.createDistributionSet("one"); - for (int index = 0; index < totalMetadata; index++) { - distributionSetManagement.createMetaData(testDS.getId(), Lists - .newArrayList(entityFactory.generateDsMetadata(knownKeyPrefix + index, knownValuePrefix + index))); - } - - mockMvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/{distributionSetId}/metadata", - testDS.getId())).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaTypes.HAL_JSON)) - .andDo(this.document.document( - pathParameters( - parameterWithName("distributionSetId").description(ApiModelPropertiesGeneric.ITEM_ID)), - responseFields(fieldWithPath("total").description(ApiModelPropertiesGeneric.TOTAL_ELEMENTS), - fieldWithPath("size").type(JsonFieldType.NUMBER) - .description(ApiModelPropertiesGeneric.SIZE), - fieldWithPath("content").description(MgmtApiModelProperties.META_DATA), - fieldWithPath("content[].key").description(MgmtApiModelProperties.META_DATA_KEY), - fieldWithPath("content[].value").description(MgmtApiModelProperties.META_DATA_VALUE)))); - } - - @Test - @Description("Get a paged list of meta data for a distribution set with defined page size and sorting by name descending and key starting with 'known'." - + " Required Permission: " + SpPermission.READ_REPOSITORY) - public void getMetadataWithParameters() throws Exception { - final int totalMetadata = 4; - - final String knownKeyPrefix = "knownKey"; - final String knownValuePrefix = "knownValue"; - final DistributionSet testDS = testdataFactory.createDistributionSet("one"); - for (int index = 0; index < totalMetadata; index++) { - distributionSetManagement.createMetaData(testDS.getId(), Lists - .newArrayList(entityFactory.generateDsMetadata(knownKeyPrefix + index, knownValuePrefix + index))); - } - - mockMvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/{dsId}/metadata", testDS.getId()) - .param("offset", "1").param("limit", "2").param("sort", "key:DESC").param("q", "key==known*")) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaTypes.HAL_JSON)) - .andDo(this.document.document( - requestParameters( - parameterWithName("limit").attributes(key("type").value("query")) - .description(ApiModelPropertiesGeneric.LIMIT), - parameterWithName("sort").description(ApiModelPropertiesGeneric.SORT), - parameterWithName("offset").description(ApiModelPropertiesGeneric.OFFSET), - parameterWithName("q").description(ApiModelPropertiesGeneric.FIQL)), - responseFields(fieldWithPath("total").description(ApiModelPropertiesGeneric.TOTAL_ELEMENTS), - fieldWithPath("size").type(JsonFieldType.NUMBER) - .description(ApiModelPropertiesGeneric.SIZE), - fieldWithPath("content").description(MgmtApiModelProperties.META_DATA), - fieldWithPath("content[].key").description(MgmtApiModelProperties.META_DATA_KEY), - fieldWithPath("content[].value").description(MgmtApiModelProperties.META_DATA_VALUE)))); - } - - @Test - @Description("Get a single meta data value for a meta data key." + " Required Permission: " - + SpPermission.READ_REPOSITORY) - public void getMetadataValue() throws Exception { - - // prepare and create metadata - final String knownKey = "knownKey"; - final String knownValue = "knownValue"; - final DistributionSet testDS = testdataFactory.createDistributionSet("one"); - distributionSetManagement.createMetaData(testDS.getId(), - Arrays.asList(entityFactory.generateDsMetadata(knownKey, knownValue))); - - mockMvc.perform(get( - MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/{distributionSetId}/metadata/{metadatakey}", - testDS.getId(), knownKey)).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andDo(this.document.document( - pathParameters( - parameterWithName("distributionSetId").description(ApiModelPropertiesGeneric.ITEM_ID), - parameterWithName("metadatakey").description(ApiModelPropertiesGeneric.ITEM_ID)), - responseFields(fieldWithPath("key").description(MgmtApiModelProperties.META_DATA_KEY), - fieldWithPath("value").description(MgmtApiModelProperties.META_DATA_VALUE)))); - } - - @Test - @Description("Update a single meta data value for specific key." + " Required Permission: " - + SpPermission.UPDATE_REPOSITORY) - public void updateMetadata() throws Exception { - // prepare and create metadata for update - final String knownKey = "knownKey"; - final String knownValue = "knownValue"; - final String updateValue = "valueForUpdate"; - - final DistributionSet testDS = testdataFactory.createDistributionSet("one"); - distributionSetManagement.createMetaData(testDS.getId(), - Arrays.asList(entityFactory.generateDsMetadata(knownKey, knownValue))); - - final JSONObject jsonObject = new JSONObject().put("key", knownKey).put("value", updateValue); - - mockMvc.perform(put( - MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/{distributionSetId}/metadata/{metadatakey}", - testDS.getId(), knownKey).contentType(MediaType.APPLICATION_JSON).content(jsonObject.toString())) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andDo(this.document.document( - pathParameters( - parameterWithName("distributionSetId").description(ApiModelPropertiesGeneric.ITEM_ID), - parameterWithName("metadatakey").description(ApiModelPropertiesGeneric.ITEM_ID)), - requestFields(requestFieldWithPath("key").description(MgmtApiModelProperties.META_DATA_KEY), - requestFieldWithPath("value").description(MgmtApiModelProperties.META_DATA_VALUE)), - responseFields(fieldWithPath("key").description(MgmtApiModelProperties.META_DATA_KEY), - fieldWithPath("value").description(MgmtApiModelProperties.META_DATA_VALUE)))); - - } - - @Test - @Description("Delete a single meta data." + " Required Permission: " + SpPermission.UPDATE_REPOSITORY) - public void deleteMetadata() throws Exception { - // prepare and create metadata for deletion - final String knownKey = "knownKey"; - final String knownValue = "knownValue"; - - final DistributionSet testDS = testdataFactory.createDistributionSet("one"); - distributionSetManagement.createMetaData(testDS.getId(), - Arrays.asList(entityFactory.generateDsMetadata(knownKey, knownValue))); - - mockMvc.perform( - delete(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/{distributionSetId}/metadata/{key}", - testDS.getId(), knownKey)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andDo(this.document.document(pathParameters( - parameterWithName("distributionSetId").description(ApiModelPropertiesGeneric.ITEM_ID), - parameterWithName("key").description(ApiModelPropertiesGeneric.ITEM_ID)))); - - } - - @Test - @Description("Create a list of meta data entries" + " Required Permission: " + SpPermission.READ_REPOSITORY - + " and " + SpPermission.UPDATE_TARGET) - public void createMetadata() throws Exception { - - final DistributionSet testDS = testdataFactory.createDistributionSet("one"); - - final String knownKey1 = "knownKey1"; - final String knownKey2 = "knownKey2"; - - final String knownValue1 = "knownValue1"; - final String knownValue2 = "knownValue2"; - - final JSONArray jsonArray = new JSONArray(); - jsonArray.put(new JSONObject().put("key", knownKey1).put("value", knownValue1)); - jsonArray.put(new JSONObject().put("key", knownKey2).put("value", knownValue2)); - - mockMvc.perform(post(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/{distributionSetId}/metadata", - testDS.getId()).contentType(MediaType.APPLICATION_JSON).content(jsonArray.toString())) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isCreated()) - .andExpect(content().contentType(MediaTypes.HAL_JSON)) - .andDo(this.document.document( - pathParameters( - parameterWithName("distributionSetId").description(ApiModelPropertiesGeneric.ITEM_ID)), - requestFields(requestFieldWithPath("[]key").description(MgmtApiModelProperties.META_DATA_KEY), - optionalRequestFieldWithPath("[]value") - .description(MgmtApiModelProperties.META_DATA_VALUE)))); - } - - @Test - @Description("Invalidates a distribution set. Required Permission: " + SpPermission.UPDATE_REPOSITORY) - public void invalidate() throws Exception { - final DistributionSet testDS = testdataFactory.createDistributionSet(); - - final JSONObject jsonObject = new JSONObject(); - jsonObject.put("actionCancelationType", "soft"); - jsonObject.put("cancelRollouts", true); - - mockMvc.perform(post(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/{distributionSetId}/invalidate", - testDS.getId()).content(jsonObject.toString()).contentType(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()).andDo( - this.document.document( - pathParameters(parameterWithName("distributionSetId") - .description(ApiModelPropertiesGeneric.ITEM_ID)), - requestFields( - requestFieldWithPath("actionCancelationType") - .description( - MgmtApiModelProperties.DS_INVALIDATION_ACTION_CANCELATION_TYPE) - .attributes(key("value").value("['force','soft','none']")), - optionalRequestFieldWithPath("cancelRollouts") - .description(MgmtApiModelProperties.DS_INVALIDATION_CANCEL_ROLLOUTS)))); - } -} diff --git a/hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/mgmt/documentation/RolloutResourceDocumentationTest.java b/hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/mgmt/documentation/RolloutResourceDocumentationTest.java deleted file mode 100644 index e90a0f8d74..0000000000 --- a/hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/mgmt/documentation/RolloutResourceDocumentationTest.java +++ /dev/null @@ -1,712 +0,0 @@ -/** - * Copyright (c) 2018 Bosch Software Innovations GmbH and others - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - */ -package org.eclipse.hawkbit.rest.mgmt.documentation; - -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.delete; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.post; -import static org.springframework.restdocs.payload.PayloadDocumentation.requestFields; -import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields; -import static org.springframework.restdocs.request.RequestDocumentation.parameterWithName; -import static org.springframework.restdocs.request.RequestDocumentation.pathParameters; -import static org.springframework.restdocs.snippet.Attributes.key; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import org.eclipse.hawkbit.im.authentication.SpPermission; -import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants; -import org.eclipse.hawkbit.repository.builder.RolloutCreate; -import org.eclipse.hawkbit.repository.model.Rollout; -import org.eclipse.hawkbit.repository.model.RolloutGroup; -import org.eclipse.hawkbit.repository.model.RolloutGroup.RolloutGroupErrorAction; -import org.eclipse.hawkbit.repository.model.RolloutGroup.RolloutGroupErrorCondition; -import org.eclipse.hawkbit.repository.model.RolloutGroup.RolloutGroupSuccessAction; -import org.eclipse.hawkbit.repository.model.RolloutGroup.RolloutGroupSuccessCondition; -import org.eclipse.hawkbit.repository.model.RolloutGroupConditionBuilder; -import org.eclipse.hawkbit.repository.model.RolloutGroupConditions; -import org.eclipse.hawkbit.repository.test.util.RolloutTestApprovalStrategy; -import org.eclipse.hawkbit.rest.documentation.AbstractApiRestDocumentation; -import org.eclipse.hawkbit.rest.documentation.ApiModelPropertiesGeneric; -import org.eclipse.hawkbit.rest.documentation.DocumenationResponseFieldsSnippet; -import org.eclipse.hawkbit.rest.documentation.MgmtApiModelProperties; -import org.eclipse.hawkbit.rest.util.JsonBuilder; -import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.domain.PageRequest; -import org.springframework.hateoas.MediaTypes; -import org.springframework.http.MediaType; -import org.springframework.restdocs.payload.FieldDescriptor; -import org.springframework.restdocs.payload.JsonFieldType; -import org.springframework.restdocs.snippet.Snippet; - -import io.qameta.allure.Description; -import io.qameta.allure.Feature; -import io.qameta.allure.Story; - -/** - * Documentation generation for Rollout API for {@link Rollout}. - * - */ -@Feature("Spring Rest Docs Tests - Rollout") -@Story("Rollout Resource") -public class RolloutResourceDocumentationTest extends AbstractApiRestDocumentation { - - @Autowired - private RolloutTestApprovalStrategy approvalStrategy; - - @Override - public String getResourceName() { - return "rollouts"; - } - - @BeforeEach - public void setUp() { - arrayPrefix = "content[]."; - approvalStrategy.setApprovalNeeded(false); - } - - @Test - @Description("Handles the GET request of retrieving all rollouts. Required Permission: " - + SpPermission.READ_ROLLOUT) - public void getRollouts() throws Exception { - enableMultiAssignments(); - createRolloutEntity(); - - mockMvc.perform(get(MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING).accept(MediaTypes.HAL_JSON_VALUE)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaTypes.HAL_JSON)) - .andDo(this.document.document(getRolloutResponseFields(true, false, false, - fieldWithPath("total").description(ApiModelPropertiesGeneric.TOTAL_ELEMENTS), - fieldWithPath("size").type(JsonFieldType.NUMBER).description(ApiModelPropertiesGeneric.SIZE), - fieldWithPath("content").description(MgmtApiModelProperties.ROLLOUT_LIST)))); - } - - @Test - @Description("Handles the GET request of retrieving all rollouts. Required Permission: " - + SpPermission.READ_ROLLOUT) - public void getRolloutsWithParameters() throws Exception { - createRolloutEntity(); - - mockMvc.perform(get(MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING).param("offset", "0").param("limit", "2") - .param("sort", "id:DESC").param("q", "name==exampleRollout*").accept(MediaTypes.HAL_JSON_VALUE)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaTypes.HAL_JSON)) - .andDo(this.document.document(getFilterRequestParamter())); - } - - private Snippet getRolloutResponseFields(final boolean isArray, final boolean withDetails, final boolean isApproveRequired, - final FieldDescriptor... descriptors) { - final String arrayPrefix = getArrayPrefix(isArray); - final List allFieldDescriptor = new ArrayList<>(); - allFieldDescriptor.addAll(Arrays.asList(descriptors)); - - allFieldDescriptor.add(fieldWithPath(arrayPrefix + "id").description(ApiModelPropertiesGeneric.ITEM_ID)); - allFieldDescriptor.add(fieldWithPath(arrayPrefix + "name").description(ApiModelPropertiesGeneric.NAME)); - allFieldDescriptor.add(fieldWithPath(arrayPrefix + "weight") - .description(MgmtApiModelProperties.RESULTING_ACTIONS_WEIGHT).type(JsonFieldType.NUMBER).optional()); - allFieldDescriptor.add(fieldWithPath(arrayPrefix + "deleted").description(ApiModelPropertiesGeneric.DELETED)); - allFieldDescriptor - .add(fieldWithPath(arrayPrefix + "description").description(ApiModelPropertiesGeneric.DESCRPTION)); - allFieldDescriptor - .add(fieldWithPath(arrayPrefix + "createdBy").description(ApiModelPropertiesGeneric.CREATED_BY)); - allFieldDescriptor - .add(fieldWithPath(arrayPrefix + "createdAt").description(ApiModelPropertiesGeneric.CREATED_AT)); - allFieldDescriptor.add( - fieldWithPath(arrayPrefix + "lastModifiedBy").description(ApiModelPropertiesGeneric.LAST_MODIFIED_BY)); - allFieldDescriptor.add( - fieldWithPath(arrayPrefix + "lastModifiedAt").description(ApiModelPropertiesGeneric.LAST_MODIFIED_AT)); - allFieldDescriptor.add(fieldWithPath(arrayPrefix + "targetFilterQuery") - .description(MgmtApiModelProperties.ROLLOUT_FILTER_QUERY)); - allFieldDescriptor.add( - fieldWithPath(arrayPrefix + "distributionSetId").description(MgmtApiModelProperties.ROLLOUT_DS_ID)); - allFieldDescriptor.add(fieldWithPath(arrayPrefix + "status").description(MgmtApiModelProperties.ROLLOUT_STATUS) - .attributes(key("value").value("['creating','ready','paused','running','finished']"))); - allFieldDescriptor.add(fieldWithPath(arrayPrefix + "type").description(MgmtApiModelProperties.ROLLOUT_TYPE) - .attributes(key("value").value("['forced','soft','timeforced','downloadonly']"))); - allFieldDescriptor.add( - fieldWithPath(arrayPrefix + "totalTargets").description(MgmtApiModelProperties.ROLLOUT_TOTAL_TARGETS)); - allFieldDescriptor.add(fieldWithPath(arrayPrefix + "forcetime").description(MgmtApiModelProperties.FORCETIME)); - allFieldDescriptor.add(fieldWithPath(arrayPrefix + "_links.self").ignored()); - if (withDetails) { - allFieldDescriptor.add(fieldWithPath(arrayPrefix + "totalTargetsPerStatus") - .description(MgmtApiModelProperties.ROLLOUT_TOTAL_TARGETS_PER_STATUS)); - allFieldDescriptor.add(fieldWithPath(arrayPrefix + "totalGroups") - .description(MgmtApiModelProperties.ROLLOUT_TOTAL_GROUPS)); - allFieldDescriptor.add(fieldWithPath(arrayPrefix + "startAt") - .description(MgmtApiModelProperties.ROLLOUT_START_AT)); - allFieldDescriptor.add(fieldWithPath(arrayPrefix + "_links.start") - .description(MgmtApiModelProperties.ROLLOUT_LINKS_START_SYNC)); - allFieldDescriptor.add(fieldWithPath(arrayPrefix + "_links.pause") - .description(MgmtApiModelProperties.ROLLOUT_LINKS_PAUSE)); - allFieldDescriptor.add(fieldWithPath(arrayPrefix + "_links.triggerNextGroup") - .description(MgmtApiModelProperties.ROLLOUT_LINKS_TRIGGER_NEXT_GROUP)); - allFieldDescriptor.add(fieldWithPath(arrayPrefix + "_links.resume") - .description(MgmtApiModelProperties.ROLLOUT_LINKS_RESUME)); - allFieldDescriptor.add(fieldWithPath(arrayPrefix + "_links.groups") - .description(MgmtApiModelProperties.ROLLOUT_LINKS_GROUPS)); - allFieldDescriptor.add(fieldWithPath(arrayPrefix + "_links.approve") - .description(MgmtApiModelProperties.ROLLOUT_LINKS_APPROVE)); - allFieldDescriptor.add( - fieldWithPath(arrayPrefix + "_links.deny").description(MgmtApiModelProperties.ROLLOUT_LINKS_DENY)); - allFieldDescriptor.add(fieldWithPath(arrayPrefix + "_links.distributionset") - .description(MgmtApiModelProperties.LINK_TO_DS)); - if (isApproveRequired) { - allFieldDescriptor.add(fieldWithPath(arrayPrefix + "approveDecidedBy") - .description("Who Approved/Denied the rollout. Not present if the rollout is missing approval.")); - allFieldDescriptor.add(fieldWithPath(arrayPrefix + "approvalRemark") - .description("A user remark of the approve/denied decision. Not present if the rollout is missing approval.")); - } - } - - return new DocumenationResponseFieldsSnippet(allFieldDescriptor); - } - - @Test - @Description("Handles the GET request of retrieving a single rollout. Required Permission: " - + SpPermission.READ_ROLLOUT) - public void getRollout() throws Exception { - enableMultiAssignments(); - approvalStrategy.setApprovalNeeded(true); - approvalStrategy.setApproveDecidedBy("exampleUsername"); - final Rollout rollout = createRolloutEntity(); - - rolloutManagement.approveOrDeny(rollout.getId(), Rollout.ApprovalDecision.APPROVED, "Approved remark."); - - mockMvc.perform(get(MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING + "/{rolloutId}", rollout.getId()) - .accept(MediaTypes.HAL_JSON_VALUE)).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaTypes.HAL_JSON)) - .andDo(this.document.document(getRolloutResponseFields(false, true, true), - pathParameters(parameterWithName("rolloutId").description(ApiModelPropertiesGeneric.ITEM_ID)))); - } - - @Test - @Description("Handles the POST request of creating a rollout. Required Permission: " + SpPermission.CREATE_ROLLOUT) - public void createRollout() throws Exception { - enableConfirmationFlow(); - - testdataFactory.createTargets(20, "targets-"); - - final String name = "exampleRollout"; - final String type = "forced"; - final String description = "Rollout for all named targets"; - final int groupSize = 5; - final Long dsId = testdataFactory.createDistributionSet().getId(); - final String targetFilter = "id==targets-*"; - - final RolloutGroupConditions rolloutGroupConditions = new RolloutGroupConditionBuilder() - .successCondition(RolloutGroupSuccessCondition.THRESHOLD, "50") - .successAction(RolloutGroupSuccessAction.NEXTGROUP, "") - .errorCondition(RolloutGroupErrorCondition.THRESHOLD, "80") - .errorAction(RolloutGroupErrorAction.PAUSE, "").build(); - - mockMvc.perform( - post(MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING) - .content(JsonBuilder.rollout(name, description, groupSize, dsId, targetFilter, rolloutGroupConditions, null, type, - null, System.currentTimeMillis() + 2000, System.currentTimeMillis() + 3000, false)) - .contentType(MediaTypes.HAL_JSON).accept(MediaTypes.HAL_JSON_VALUE)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isCreated()) - .andExpect(content().contentType(MediaTypes.HAL_JSON)) - .andDo(this.document.document(requestFields( - requestFieldWithPath("name").description(ApiModelPropertiesGeneric.NAME), - requestFieldWithPathMandatoryInMultiAssignMode("weight").type(JsonFieldType.NUMBER) - .description(MgmtApiModelProperties.RESULTING_ACTIONS_WEIGHT) - .attributes(key("value").value("0 - 1000")), - requestFieldWithPath("name").description(ApiModelPropertiesGeneric.NAME), - optionalRequestFieldWithPath("forcetime").description(MgmtApiModelProperties.FORCETIME), - optionalRequestFieldWithPath("type").description(MgmtApiModelProperties.ROLLOUT_TYPE) - .attributes(key("value").value("['soft', 'forced', 'timeforced', 'downloadonly']")), - optionalRequestFieldWithPath("startAt").description(MgmtApiModelProperties.ROLLOUT_START_AT) - .type(JsonFieldType.NUMBER), - optionalRequestFieldWithPath("confirmationRequired") - .description(MgmtApiModelProperties.ROLLOUT_CONFIRMATION_REQUIRED) - .type(JsonFieldType.BOOLEAN.toString()), - requestFieldWithPath("distributionSetId").description(MgmtApiModelProperties.ROLLOUT_DS_ID), - requestFieldWithPath("targetFilterQuery") - .description(MgmtApiModelProperties.ROLLOUT_FILTER_QUERY), - requestFieldWithPath("amountGroups").description(MgmtApiModelProperties.ROLLOUT_AMOUNT_GROUPS), - optionalRequestFieldWithPath("description").description(ApiModelPropertiesGeneric.DESCRPTION), - optionalRequestFieldWithPath("successCondition") - .description(MgmtApiModelProperties.ROLLOUT_SUCCESS_CONDITION), - optionalRequestFieldWithPath("successCondition.condition") - .description(MgmtApiModelProperties.ROLLOUT_SUCCESS_CONDITION_CONDITION) - .attributes(key("value").value("['threshold']")), - optionalRequestFieldWithPath("successCondition.expression") - .description(MgmtApiModelProperties.ROLLOUT_SUCCESS_CONDITION_EXP), - optionalRequestFieldWithPath("successAction") - .description(MgmtApiModelProperties.ROLLOUT_SUCCESS_ACTION), - optionalRequestFieldWithPath("successAction.action") - .description(MgmtApiModelProperties.ROLLOUT_SUCCESS_ACTION_ACTION) - .attributes(key("value").value("['nextgroup']")), - optionalRequestFieldWithPath("successAction.expression") - .description(MgmtApiModelProperties.ROLLOUT_SUCCESS_ACTION_EXP), - optionalRequestFieldWithPath("errorCondition") - .description(MgmtApiModelProperties.ROLLOUT_ERROR_CONDITION), - optionalRequestFieldWithPath("errorCondition.condition") - .description(MgmtApiModelProperties.ROLLOUT_ERROR_CONDITION_CONDITION) - .attributes(key("value").value("['threshold']")), - optionalRequestFieldWithPath("errorCondition.expression") - .description(MgmtApiModelProperties.ROLLOUT_ERROR_CONDITION_EXP), - optionalRequestFieldWithPath("errorAction") - .description(MgmtApiModelProperties.ROLLOUT_ERROR_ACTION), - optionalRequestFieldWithPath("errorAction.action") - .description(MgmtApiModelProperties.ROLLOUT_ERROR_ACTION_ACTION) - .attributes(key("value").value("['pause']")), - optionalRequestFieldWithPath("errorAction.expression") - .description(MgmtApiModelProperties.ROLLOUT_ERROR_ACTION_EXP)), - - getRolloutResponseFields(false, true, false))); - - } - - @Test - @Description("Handles the POST request of creating a rollout with a groups definition. Required Permission: " - + SpPermission.CREATE_ROLLOUT) - public void createRolloutWithGroupsDefinition() throws Exception { - enableConfirmationFlow(); - - final int amountTargets = 10; - testdataFactory.createTargets(amountTargets, "targets-", "rollout"); - - final List rolloutGroups = new ArrayList<>(2); - final float percentTargetsInGroup1 = 20; - final float percentTargetsInGroup2 = 100; - - final RolloutGroup group1 = entityFactory.rolloutGroup().create().name("Group1").description("Group1desc") - .targetFilterQuery("name==targets-1*").targetPercentage(percentTargetsInGroup1) - .conditions(new RolloutGroupConditionBuilder() - .successCondition(RolloutGroupSuccessCondition.THRESHOLD, "90") - .successAction(RolloutGroupSuccessAction.NEXTGROUP, "") - .errorCondition(RolloutGroupErrorCondition.THRESHOLD, "30") - .errorAction(RolloutGroupErrorAction.PAUSE, "").build()) - .build(); - rolloutGroups.add(group1); - - final RolloutGroup group2 = entityFactory.rolloutGroup().create().name("Group2").description("Group2desc") - .targetPercentage(percentTargetsInGroup2).build(); - rolloutGroups.add(group2); - - final String name = "exampleRolloutWithDefinedGroups"; - final String description = "Rollout for all named targets"; - final Long dsId = testdataFactory.createDistributionSet().getId(); - final String targetFilter = "id==targets-*"; - final RolloutGroupConditions rolloutGroupConditions = new RolloutGroupConditionBuilder() - .successCondition(RolloutGroupSuccessCondition.THRESHOLD, "50") - .successAction(RolloutGroupSuccessAction.NEXTGROUP, "") - .errorCondition(RolloutGroupErrorCondition.THRESHOLD, "80") - .errorAction(RolloutGroupErrorAction.PAUSE, "").build(); - mockMvc.perform(post(MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING) - .content(JsonBuilder.rolloutWithGroups(name, description, null, dsId, targetFilter, - rolloutGroupConditions, rolloutGroups, null, null, true)) - .contentType( - MediaType.APPLICATION_JSON).accept(MediaTypes.HAL_JSON_VALUE)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isCreated()) - .andExpect(content().contentType(MediaTypes.HAL_JSON)) - .andDo(this.document.document( - requestFields(requestFieldWithPath("name").description(ApiModelPropertiesGeneric.NAME), - requestFieldWithPathMandatoryInMultiAssignMode("weight") - .type(JsonFieldType.NUMBER) - .description(MgmtApiModelProperties.RESULTING_ACTIONS_WEIGHT) - .attributes(key("value").value("0 - 1000")), - requestFieldWithPath("distributionSetId") - .description(MgmtApiModelProperties.ROLLOUT_DS_ID), - requestFieldWithPath("targetFilterQuery") - .description(MgmtApiModelProperties.ROLLOUT_FILTER_QUERY), - requestFieldWithPath("confirmationRequired") - .description(MgmtApiModelProperties.ROLLOUT_CONFIRMATION_REQUIRED), - optionalRequestFieldWithPath("description") - .description(ApiModelPropertiesGeneric.DESCRPTION), - optionalRequestFieldWithPath("startAt").description(MgmtApiModelProperties.ROLLOUT_START_AT) - .type(JsonFieldType.NUMBER), - optionalRequestFieldWithPath("successCondition") - .description(MgmtApiModelProperties.ROLLOUT_SUCCESS_CONDITION), - optionalRequestFieldWithPath("successCondition.condition") - .description(MgmtApiModelProperties.ROLLOUT_SUCCESS_CONDITION_CONDITION) - .attributes(key("value").value("['threshold']")), - optionalRequestFieldWithPath("successCondition.expression") - .description(MgmtApiModelProperties.ROLLOUT_SUCCESS_CONDITION_EXP), - optionalRequestFieldWithPath("successAction") - .description(MgmtApiModelProperties.ROLLOUT_SUCCESS_ACTION), - optionalRequestFieldWithPath("successAction.action") - .description(MgmtApiModelProperties.ROLLOUT_SUCCESS_ACTION_ACTION) - .attributes(key("value").value("['nextgroup']")), - optionalRequestFieldWithPath("successAction.expression") - .description(MgmtApiModelProperties.ROLLOUT_SUCCESS_ACTION_EXP), - optionalRequestFieldWithPath("errorCondition") - .description(MgmtApiModelProperties.ROLLOUT_ERROR_CONDITION), - optionalRequestFieldWithPath("errorCondition.condition") - .description(MgmtApiModelProperties.ROLLOUT_ERROR_CONDITION_CONDITION) - .attributes(key("value").value("['threshold']")), - optionalRequestFieldWithPath("errorCondition.expression") - .description(MgmtApiModelProperties.ROLLOUT_ERROR_CONDITION_EXP), - optionalRequestFieldWithPath("errorAction") - .description(MgmtApiModelProperties.ROLLOUT_ERROR_ACTION), - optionalRequestFieldWithPath("errorAction.action") - .description(MgmtApiModelProperties.ROLLOUT_ERROR_ACTION_ACTION) - .attributes(key("value").value("['pause']")), - optionalRequestFieldWithPath("errorAction.expression") - .description(MgmtApiModelProperties.ROLLOUT_ERROR_ACTION_EXP), - requestFieldWithPath("groups").description(MgmtApiModelProperties.ROLLOUT_GROUPS), - requestFieldWithPath("groups[].name").description(ApiModelPropertiesGeneric.NAME), - requestFieldWithPath("groups[].description") - .description(ApiModelPropertiesGeneric.DESCRPTION), - optionalRequestFieldWithPath("groups[].targetFilterQuery") - .description(MgmtApiModelProperties.ROLLOUT_GROUP_FILTER_QUERY), - optionalRequestFieldWithPath("groups[].confirmationRequired") - .description(MgmtApiModelProperties.ROLLOUT_GROUP_CONFIRMATION_REQUIRED), - optionalRequestFieldWithPath("groups[].targetPercentage") - .description(MgmtApiModelProperties.ROLLOUT_GROUP_TARGET_PERCENTAGE) - .attributes(key("value").value("0..100")), - optionalRequestFieldWithPath("groups[].successCondition") - .description(MgmtApiModelProperties.ROLLOUT_SUCCESS_CONDITION), - optionalRequestFieldWithPath("groups[].successCondition.condition") - .description(MgmtApiModelProperties.ROLLOUT_SUCCESS_CONDITION_CONDITION) - .attributes(key("value").value("['threshold']")), - optionalRequestFieldWithPath("groups[].successCondition.expression") - .description(MgmtApiModelProperties.ROLLOUT_SUCCESS_CONDITION_EXP), - optionalRequestFieldWithPath("groups[].successAction") - .description(MgmtApiModelProperties.ROLLOUT_SUCCESS_ACTION), - optionalRequestFieldWithPath("groups[].successAction.action") - .description(MgmtApiModelProperties.ROLLOUT_SUCCESS_ACTION_ACTION) - .attributes(key("value").value("['nextgroup']")), - optionalRequestFieldWithPath("groups[].successAction.expression") - .description(MgmtApiModelProperties.ROLLOUT_SUCCESS_ACTION_EXP), - optionalRequestFieldWithPath("groups[].errorCondition") - .description(MgmtApiModelProperties.ROLLOUT_ERROR_CONDITION), - optionalRequestFieldWithPath("groups[].errorCondition.condition") - .description(MgmtApiModelProperties.ROLLOUT_ERROR_CONDITION_CONDITION) - .attributes(key("value").value("['threshold']")), - optionalRequestFieldWithPath("groups[].errorCondition.expression") - .description(MgmtApiModelProperties.ROLLOUT_ERROR_CONDITION_EXP), - optionalRequestFieldWithPath("groups[].errorAction") - .description(MgmtApiModelProperties.ROLLOUT_ERROR_ACTION), - optionalRequestFieldWithPath("groups[].errorAction.action") - .description(MgmtApiModelProperties.ROLLOUT_ERROR_ACTION_ACTION) - .attributes(key("value").value("['pause']")), - optionalRequestFieldWithPath("groups[].errorAction.expression") - .description(MgmtApiModelProperties.ROLLOUT_ERROR_ACTION_EXP)), - getRolloutResponseFields(false, true, false))); - } - - @Test - @Description("Handles the DELETE request of deleting a rollout within SP. Required Permission: " - + SpPermission.DELETE_ROLLOUT) - public void deleteRollout() throws Exception { - final Rollout rollout = createRolloutEntity(); - this.mockMvc.perform(delete(MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING + "/{rolloutId}", rollout.getId())) - .andExpect(status().isOk()).andDo(MockMvcResultPrinter.print()).andDo(this.document.document( - pathParameters(parameterWithName("rolloutId").description(ApiModelPropertiesGeneric.NAME)))); - } - - @Test - @Description("Handles the POST request of starting a rollout. Required Permission: " + SpPermission.HANDLE_ROLLOUT) - public void startRollout() throws Exception { - final Rollout rollout = createRolloutEntity(); - mockMvc.perform(post(MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING + "/{rolloutId}/start", rollout.getId()) - .accept(MediaTypes.HAL_JSON_VALUE)).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andDo(this.document.document( - pathParameters(parameterWithName("rolloutId").description(ApiModelPropertiesGeneric.ITEM_ID)))); - } - - @Test - @Description("Handles the POST request of pausing a rollout. Required Permission: " + SpPermission.HANDLE_ROLLOUT) - public void pauseRollout() throws Exception { - final Rollout rollout = createRolloutEntity(); - rolloutManagement.start(rollout.getId()); - - // Run here, because scheduler is disabled during tests - rolloutHandler.handleAll(); - - mockMvc.perform(post(MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING + "/{rolloutId}/pause", rollout.getId()) - .accept(MediaTypes.HAL_JSON_VALUE)).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andDo(this.document.document( - pathParameters(parameterWithName("rolloutId").description(ApiModelPropertiesGeneric.ITEM_ID)))); - } - - @Test - @Description("Handles the POST request of resuming a rollout. Required Permission: " + SpPermission.HANDLE_ROLLOUT) - public void resumeRollout() throws Exception { - final Rollout rollout = createRolloutEntity(); - rolloutManagement.start(rollout.getId()); - - // Run here, because scheduler is disabled during tests - rolloutHandler.handleAll(); - - rolloutManagement.pauseRollout(rollout.getId()); - mockMvc.perform(post(MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING + "/{rolloutId}/resume", rollout.getId()) - .accept(MediaTypes.HAL_JSON_VALUE)).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andDo(this.document.document( - pathParameters(parameterWithName("rolloutId").description(ApiModelPropertiesGeneric.ITEM_ID)))); - } - - @Test - @Description("Handles the POST request of approving a rollout. Required Permission: " - + SpPermission.APPROVE_ROLLOUT) - public void approveRollout() throws Exception { - approvalStrategy.setApprovalNeeded(true); - final Rollout rollout = createRolloutEntity(); - mockMvc.perform(post(MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING + "/{rolloutId}/approve", rollout.getId()) - .accept(MediaTypes.HAL_JSON_VALUE)).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andDo(this.document.document( - pathParameters(parameterWithName("rolloutId").description(ApiModelPropertiesGeneric.ITEM_ID)))); - } - - @Test - @Description("Handles the POST request of denying a rollout. Required Permission: " + SpPermission.APPROVE_ROLLOUT) - public void denyRollout() throws Exception { - approvalStrategy.setApprovalNeeded(true); - final Rollout rollout = createRolloutEntity(); - mockMvc.perform(post(MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING + "/{rolloutId}/deny", rollout.getId()) - .accept(MediaTypes.HAL_JSON_VALUE)).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andDo(this.document.document( - pathParameters(parameterWithName("rolloutId").description(ApiModelPropertiesGeneric.ITEM_ID)))); - } - - @Test - @Description("Handles the POST request of triggering the next group of a rollout. Required Permission: " - + SpPermission.UPDATE_ROLLOUT) - public void triggerNextGroup() throws Exception { - final Rollout rollout = createRolloutEntity(); - rolloutManagement.start(rollout.getId()); - - // Run here, because scheduler is disabled during tests - rolloutHandler.handleAll(); - - mockMvc.perform( - post(MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING + "/{rolloutId}/triggerNextGroup", rollout.getId()) - .accept(MediaTypes.HAL_JSON_VALUE)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()).andDo(this.document.document( - pathParameters(parameterWithName("rolloutId").description(ApiModelPropertiesGeneric.ITEM_ID)))); - } - - @Test - @Description("Handles the GET request of retrieving the deploy groups of a rollout. Required Permission: " - + SpPermission.READ_ROLLOUT) - public void getRolloutDeployGroups() throws Exception { - enableConfirmationFlow(); - - final Rollout rollout = createRolloutEntity(); - - mockMvc.perform(get(MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING + "/{rolloutId}/deploygroups", rollout.getId()) - .accept(MediaTypes.HAL_JSON_VALUE)).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaTypes.HAL_JSON)) - .andDo(this.document.document( - getRolloutDeployGroupResponseFields(true, false, - fieldWithPath("total").description(ApiModelPropertiesGeneric.TOTAL_ELEMENTS), - fieldWithPath("size").type(JsonFieldType.NUMBER) - .description(ApiModelPropertiesGeneric.SIZE), - fieldWithPath("content").description(MgmtApiModelProperties.ROLLOUT_LIST)), - pathParameters(parameterWithName("rolloutId").description(ApiModelPropertiesGeneric.ITEM_ID)))); - } - - @Test - @Description("Handles the GET request of retrieving a deploy group of a rollout. Required Permission: " - + SpPermission.READ_ROLLOUT) - public void getRolloutDeployGroup() throws Exception { - enableConfirmationFlow(); - - final Rollout rollout = createRolloutEntity(); - final RolloutGroup firstRolloutGroup = rolloutGroupManagement.findByRollout(PAGE, rollout.getId()).getContent() - .get(0); - - mockMvc.perform(get(MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING + "/{rolloutId}/deploygroups/{deployGroupId}", - rollout.getId(), firstRolloutGroup.getId()).accept(MediaTypes.HAL_JSON_VALUE)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaTypes.HAL_JSON)) - .andDo(this.document.document(getRolloutDeployGroupResponseFields(false, true), - pathParameters(parameterWithName("rolloutId").description(ApiModelPropertiesGeneric.ITEM_ID), - parameterWithName("deployGroupId").description(ApiModelPropertiesGeneric.ITEM_ID)))); - } - - private Snippet getRolloutDeployGroupResponseFields(final boolean isArray, final boolean withDetails, - final FieldDescriptor... descriptors) { - final String arrayPrefix = getArrayPrefix(isArray); - final List allFieldDescriptor = new ArrayList<>(); - allFieldDescriptor.addAll(Arrays.asList(descriptors)); - - allFieldDescriptor.add(fieldWithPath(arrayPrefix + "id").description(ApiModelPropertiesGeneric.ITEM_ID)); - allFieldDescriptor.add(fieldWithPath(arrayPrefix + "name").description(ApiModelPropertiesGeneric.NAME)); - allFieldDescriptor.add(fieldWithPath(arrayPrefix + "description").optional() - .description(ApiModelPropertiesGeneric.DESCRPTION)); - allFieldDescriptor - .add(fieldWithPath(arrayPrefix + "createdBy").description(ApiModelPropertiesGeneric.CREATED_BY)); - allFieldDescriptor - .add(fieldWithPath(arrayPrefix + "createdAt").description(ApiModelPropertiesGeneric.CREATED_AT)); - allFieldDescriptor.add(fieldWithPath(arrayPrefix + "lastModifiedBy").optional().type(JsonFieldType.STRING) - .description(ApiModelPropertiesGeneric.LAST_MODIFIED_BY)); - allFieldDescriptor.add(fieldWithPath(arrayPrefix + "lastModifiedAt").optional().type(JsonFieldType.NUMBER) - .description(ApiModelPropertiesGeneric.LAST_MODIFIED_AT)); - allFieldDescriptor - .add(fieldWithPath(arrayPrefix + "status").description(MgmtApiModelProperties.ROLLOUT_GROUP_STATUS) - .attributes(key("value").value("['creating','ready','paused','running','finished']"))); - - allFieldDescriptor.add( - fieldWithPath(arrayPrefix + "totalTargets").description(MgmtApiModelProperties.ROLLOUT_TOTAL_TARGETS)); - - if (withDetails) { - allFieldDescriptor.add(fieldWithPath(arrayPrefix + "totalTargetsPerStatus") - .description(MgmtApiModelProperties.ROLLOUT_TOTAL_TARGETS_PER_STATUS)); - } - - allFieldDescriptor.add(fieldWithPath(arrayPrefix + "targetFilterQuery") - .description(MgmtApiModelProperties.ROLLOUT_GROUP_FILTER_QUERY)); - - allFieldDescriptor.add(fieldWithPath(arrayPrefix + "targetPercentage") - .description(MgmtApiModelProperties.ROLLOUT_GROUP_TARGET_PERCENTAGE)); - - allFieldDescriptor.add(fieldWithPath(arrayPrefix + "confirmationRequired") - .description(MgmtApiModelProperties.ROLLOUT_GROUP_CONFIRMATION_REQUIRED)); - - allFieldDescriptor.add(fieldWithPath(arrayPrefix + "successCondition") - .description(MgmtApiModelProperties.ROLLOUT_SUCCESS_CONDITION)); - allFieldDescriptor.add(fieldWithPath(arrayPrefix + "successCondition.condition") - .description(MgmtApiModelProperties.ROLLOUT_SUCCESS_CONDITION_CONDITION)); - allFieldDescriptor.add(fieldWithPath(arrayPrefix + "successCondition.expression") - .description(MgmtApiModelProperties.ROLLOUT_SUCCESS_CONDITION_EXP)); - - allFieldDescriptor.add(fieldWithPath(arrayPrefix + "successAction") - .description(MgmtApiModelProperties.ROLLOUT_SUCCESS_ACTION)); - allFieldDescriptor.add(fieldWithPath(arrayPrefix + "successAction.action") - .description(MgmtApiModelProperties.ROLLOUT_SUCCESS_ACTION_ACTION)); - allFieldDescriptor.add(fieldWithPath(arrayPrefix + "successAction.expression") - .description(MgmtApiModelProperties.ROLLOUT_SUCCESS_ACTION_EXP)); - - allFieldDescriptor.add(fieldWithPath(arrayPrefix + "errorCondition") - .description(MgmtApiModelProperties.ROLLOUT_ERROR_CONDITION)); - allFieldDescriptor.add(fieldWithPath(arrayPrefix + "errorCondition.condition") - .description(MgmtApiModelProperties.ROLLOUT_ERROR_CONDITION_CONDITION)); - allFieldDescriptor.add(fieldWithPath(arrayPrefix + "errorCondition.expression") - .description(MgmtApiModelProperties.ROLLOUT_ERROR_CONDITION_EXP)); - - allFieldDescriptor.add( - fieldWithPath(arrayPrefix + "errorAction").description(MgmtApiModelProperties.ROLLOUT_ERROR_ACTION)); - allFieldDescriptor.add(fieldWithPath(arrayPrefix + "errorAction.action") - .description(MgmtApiModelProperties.ROLLOUT_ERROR_ACTION_ACTION)); - allFieldDescriptor.add(fieldWithPath(arrayPrefix + "errorAction.expression") - .description(MgmtApiModelProperties.ROLLOUT_ERROR_ACTION_EXP)); - - allFieldDescriptor.add(fieldWithPath(arrayPrefix + "_links.self").ignored()); - - return new DocumenationResponseFieldsSnippet(allFieldDescriptor); - } - - @Test - @Description("Handles the GET request of retrieving a deploy group of a rollout. Required Permission: " - + SpPermission.READ_ROLLOUT) - public void getRolloutDeployGroupWithParameters() throws Exception { - final Rollout rollout = createRolloutEntity(); - final RolloutGroup firstRolloutGroup = rolloutGroupManagement - .findByRollout(PageRequest.of(0, 1), rollout.getId()).getContent().get(0); - - mockMvc.perform(get(MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING + "/{rolloutId}/deploygroups/{deployGroupId}", - rollout.getId(), firstRolloutGroup.getId()).param("offset", "0").param("limit", "2") - .param("sort", "id:DESC").param("q", "id==" + firstRolloutGroup.getId()) - .accept(MediaTypes.HAL_JSON_VALUE)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaTypes.HAL_JSON)) - .andDo(this.document.document( - pathParameters(parameterWithName("rolloutId").description(ApiModelPropertiesGeneric.ITEM_ID), - parameterWithName("deployGroupId").description(ApiModelPropertiesGeneric.ITEM_ID)), - getFilterRequestParamter())); - } - - @Test - @Description("Handles the GET request of retrieving a all targets of a specific deploy group of a rollout. Required Permissions: " - + SpPermission.READ_ROLLOUT + ", " + SpPermission.READ_TARGET) - public void getRolloutDeployGroupTargets() throws Exception { - final Rollout rollout = createRolloutEntity(); - final RolloutGroup firstRolloutGroup = rolloutGroupManagement - .findByRollout(PageRequest.of(0, 1), rollout.getId()).getContent().get(0); - - mockMvc.perform( - get(MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING + "/{rolloutId}/deploygroups/{deployGroupId}/targets", - rollout.getId(), firstRolloutGroup.getId()).accept(MediaTypes.HAL_JSON_VALUE)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaTypes.HAL_JSON)) - .andDo(this.document.document( - pathParameters(parameterWithName("rolloutId").description(ApiModelPropertiesGeneric.ITEM_ID), - parameterWithName("deployGroupId").description(ApiModelPropertiesGeneric.ITEM_ID)), - responseFields( - fieldWithPath("size").type(JsonFieldType.NUMBER) - .description(ApiModelPropertiesGeneric.SIZE), - fieldWithPath("total").description(ApiModelPropertiesGeneric.TOTAL_ELEMENTS), - fieldWithPath("content").description(MgmtApiModelProperties.TARGET_LIST), - fieldWithPath("content[].createdBy").description(ApiModelPropertiesGeneric.CREATED_BY), - fieldWithPath("content[].address").optional().type(String.class) - .description(MgmtApiModelProperties.ADDRESS), - fieldWithPath("content[].createdAt").description(ApiModelPropertiesGeneric.CREATED_AT), - fieldWithPath("content[].name").description(ApiModelPropertiesGeneric.NAME), - fieldWithPath("content[].description").optional().type(String.class) - .description(ApiModelPropertiesGeneric.DESCRPTION), - fieldWithPath("content[].controllerId").description(ApiModelPropertiesGeneric.ITEM_ID), - fieldWithPath("content[].updateStatus") - .description(MgmtApiModelProperties.UPDATE_STATUS).type("enum") - .attributes(key("value") - .value("['error', 'in_sync', 'pending', 'registered', 'unknown']")), - fieldWithPath("content[].securityToken") - .description(MgmtApiModelProperties.SECURITY_TOKEN), - fieldWithPath("content[].installedAt").optional().type(Long.class) - .description(MgmtApiModelProperties.INSTALLED_AT), - fieldWithPath("content[].lastModifiedAt").optional().type(Long.class) - .description(ApiModelPropertiesGeneric.LAST_MODIFIED_AT).type("Number"), - fieldWithPath("content[].lastModifiedBy").optional().type(String.class) - .description(ApiModelPropertiesGeneric.LAST_MODIFIED_BY).type("String"), - fieldWithPath("content[].ipAddress").optional().type(String.class) - .description(MgmtApiModelProperties.IP_ADDRESS).type("String"), - fieldWithPath("content[].lastControllerRequestAt").optional().type(Long.class) - .description(MgmtApiModelProperties.LAST_REQUEST_AT).type("Number"), - fieldWithPath("content[]._links.self").ignored()))); - } - - @Test - @Description("Handles the GET request of retrieving a all targets of a specific deploy group of a rollout. Required Permission: " - + SpPermission.READ_ROLLOUT + ", " + SpPermission.READ_TARGET) - public void getRolloutDeployGroupTargetsWithParameters() throws Exception { - final Rollout rollout = createRolloutEntity(); - final RolloutGroup firstRolloutGroup = rolloutGroupManagement - .findByRollout(PageRequest.of(0, 1), rollout.getId()).getContent().get(0); - - mockMvc.perform( - get(MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING + "/{rolloutId}/deploygroups/{deployGroupId}/targets", - rollout.getId(), firstRolloutGroup.getId()).param("offset", "0").param("limit", "2") - .param("sort", "name:ASC").param("q", "controllerId==exampleTarget0") - .accept(MediaTypes.HAL_JSON_VALUE)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaTypes.HAL_JSON)) - .andDo(this.document.document( - pathParameters(parameterWithName("rolloutId").description(ApiModelPropertiesGeneric.ITEM_ID), - parameterWithName("deployGroupId").description(ApiModelPropertiesGeneric.ITEM_ID)), - getFilterRequestParamter())); - } - - private Rollout createRolloutEntity() { - testdataFactory.createTargets(20, "exampleTarget"); - final RolloutCreate rolloutCreate = entityFactory.rollout().create().name("exampleRollout") - .targetFilterQuery("controllerId==exampleTarget*").set(testdataFactory.createDistributionSet()); - if (isMultiAssignmentsEnabled()) { - rolloutCreate.weight(400); - } - rolloutCreate.forcedTime(System.currentTimeMillis() + 12345); - final Rollout rollout = rolloutManagement.create(rolloutCreate, 5, false, new RolloutGroupConditionBuilder() - .withDefaults().successCondition(RolloutGroupSuccessCondition.THRESHOLD, "10").build()); - - // Run here, because Scheduler is disabled during tests - rolloutHandler.handleAll(); - - return rolloutManagement - .update(entityFactory.rollout().update(rollout.getId()).startAt(System.currentTimeMillis() + 1000).description("exampleDescription")); - } - -} diff --git a/hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/mgmt/documentation/SoftwaremoduleTypesDocumentationTest.java b/hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/mgmt/documentation/SoftwaremoduleTypesDocumentationTest.java deleted file mode 100644 index 1c32071a56..0000000000 --- a/hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/mgmt/documentation/SoftwaremoduleTypesDocumentationTest.java +++ /dev/null @@ -1,221 +0,0 @@ -/** - * Copyright (c) 2018 Bosch Software Innovations GmbH and others - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - */ -package org.eclipse.hawkbit.rest.mgmt.documentation; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.delete; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.post; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.put; -import static org.springframework.restdocs.payload.PayloadDocumentation.requestFields; -import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields; -import static org.springframework.restdocs.request.RequestDocumentation.parameterWithName; -import static org.springframework.restdocs.request.RequestDocumentation.pathParameters; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - -import java.util.Arrays; -import java.util.List; - -import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants; -import org.eclipse.hawkbit.repository.model.SoftwareModuleType; -import org.eclipse.hawkbit.repository.test.util.WithUser; -import org.eclipse.hawkbit.rest.documentation.AbstractApiRestDocumentation; -import org.eclipse.hawkbit.rest.documentation.ApiModelPropertiesGeneric; -import org.eclipse.hawkbit.rest.documentation.MgmtApiModelProperties; -import org.eclipse.hawkbit.rest.util.JsonBuilder; -import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter; -import org.json.JSONObject; -import org.junit.jupiter.api.Test; -import org.springframework.http.MediaType; -import org.springframework.restdocs.payload.JsonFieldType; - -import io.qameta.allure.Description; -import io.qameta.allure.Feature; -import io.qameta.allure.Story; - -/** - * Documentation generation for Management API for {@link SoftwareModuleType}. - */ -@Feature("Spring Rest Docs Tests - SoftwareModuleType") -@Story("Softwaremoduletypes Resource") -public class SoftwaremoduleTypesDocumentationTest extends AbstractApiRestDocumentation { - - @Override - public String getResourceName() { - return "softwaremoduletypes"; - } - - @Test - @WithUser(principal = "uploadTester", allSpPermissions = true) - @Description("Handles the GET request of retrieving all software module types within SP. Required Permission: READ_REPOSITORY.") - public void getSoftwareModuleTypes() throws Exception { - - final SoftwareModuleType testType = testdataFactory.findOrCreateSoftwareModuleType("test123"); - softwareModuleTypeManagement - .update(entityFactory.softwareModuleType().update(testType.getId()).description("Desc1234").colour("rgb(106,178,83)")); - - mockMvc.perform(get(MgmtRestConstants.SOFTWAREMODULETYPE_V1_REQUEST_MAPPING).accept(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andDo(this.document.document(responseFields( - fieldWithPath("size").type(JsonFieldType.NUMBER).description(ApiModelPropertiesGeneric.SIZE), - fieldWithPath("total").description(ApiModelPropertiesGeneric.TOTAL_ELEMENTS), - fieldWithPath("content").description(MgmtApiModelProperties.TARGET_LIST), - fieldWithPath("content[].createdBy").description(ApiModelPropertiesGeneric.CREATED_BY), - fieldWithPath("content[].createdAt").description(ApiModelPropertiesGeneric.CREATED_AT), - fieldWithPath("content[].description").description(ApiModelPropertiesGeneric.DESCRPTION), - fieldWithPath("content[].id").description(ApiModelPropertiesGeneric.ITEM_ID), - fieldWithPath("content[].lastModifiedAt") - .description(ApiModelPropertiesGeneric.LAST_MODIFIED_AT).type("Number"), - fieldWithPath("content[].lastModifiedBy") - .description(ApiModelPropertiesGeneric.LAST_MODIFIED_BY).type("String"), - fieldWithPath("content[].name").description(ApiModelPropertiesGeneric.NAME), - fieldWithPath("content[].deleted").description(ApiModelPropertiesGeneric.DELETED), - fieldWithPath("content[]._links.self").ignored()))); - } - - @Test - @WithUser(principal = "uploadTester", allSpPermissions = true) - @Description("Handles the GET request of retrieving all software module types within SP with parametsrs. In this case the first 10 result in ascending order by name wher the name starts with 'a'. Required Permission: READ_REPOSITORY.") - public void getSoftwareModuleTypesWithParameters() throws Exception { - final SoftwareModuleType testType = testdataFactory.findOrCreateSoftwareModuleType("test123"); - softwareModuleTypeManagement - .update(entityFactory.softwareModuleType().update(testType.getId()).description("Desc1234").colour("rgb(106,178,83)")); - - mockMvc.perform(get( - MgmtRestConstants.SOFTWAREMODULETYPE_V1_REQUEST_MAPPING + "?limit=10&sort=name:ASC&offset=0&q=name==a") - .accept(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andDo(this.document.document(getFilterRequestParamter())); - } - - @Test - @WithUser(principal = "uploadTester", allSpPermissions = true) - @Description("Handles the POST request of creating new software module types within SP. The request body must " - + "always be a list of module types. Required Permission: CREATE_REPOSITORY.") - public void postSoftwareModuleTypes() throws Exception { - - final List types = Arrays.asList(entityFactory.softwareModuleType().create().key("test1") - .name("TestName1").description("Desc1").colour("rgb(106,178,83)").build()); - - this.mockMvc - .perform(post(MgmtRestConstants.SOFTWAREMODULETYPE_V1_REQUEST_MAPPING) - .content(JsonBuilder.softwareModuleTypesCreatableFieldsOnly(types)) - .contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()) - .andDo(this.document.document( - requestFields( - requestFieldWithPath("[]key").description(MgmtApiModelProperties.SMT_KEY), - requestFieldWithPath("[]name").description(ApiModelPropertiesGeneric.NAME), - requestFieldWithPath("[]maxAssignments").description(MgmtApiModelProperties.SM_MAX_ASSIGNMENTS), - optionalRequestFieldWithPath("[]description") - .description(ApiModelPropertiesGeneric.DESCRPTION), - optionalRequestFieldWithPath("[]colour").description(ApiModelPropertiesGeneric.COLOUR)), - responseFields(fieldWithPath("[]key").description(MgmtApiModelProperties.SMT_KEY), - fieldWithPath("[]maxAssignments") - .description(MgmtApiModelProperties.SMT_MAX_ASSIGNMENTS), - fieldWithPath("[]createdBy").description(ApiModelPropertiesGeneric.CREATED_BY), - fieldWithPath("[]createdAt").description(ApiModelPropertiesGeneric.CREATED_AT), - fieldWithPath("[]description").description(ApiModelPropertiesGeneric.DESCRPTION), - fieldWithPath("[]colour").description(ApiModelPropertiesGeneric.COLOUR), - fieldWithPath("[]deleted").description(ApiModelPropertiesGeneric.DELETED), - fieldWithPath("[]id").description(ApiModelPropertiesGeneric.ITEM_ID), - fieldWithPath("[]lastModifiedAt") - .description(ApiModelPropertiesGeneric.LAST_MODIFIED_AT).type("Number"), - fieldWithPath("[]lastModifiedBy") - .description(ApiModelPropertiesGeneric.LAST_MODIFIED_BY).type("String"), - fieldWithPath("[]name").description(ApiModelPropertiesGeneric.NAME), - - fieldWithPath("[]_links.self").ignored()))); - - } - - @Test - @WithUser(principal = "uploadTester", allSpPermissions = true) - @Description("Handles the DELETE request for a single software module Type within SP. Required Permission: DELETE_REPOSITORY.") - public void deleteSoftwareModuleType() throws Exception { - final SoftwareModuleType testType = softwareModuleTypeManagement.create( - entityFactory.softwareModuleType().create().key("test1").name("TestName1").description("Desc1").colour("rgb(106,178,83)")); - assertThat(softwareModuleTypeManagement.count()).isEqualTo(4); - this.mockMvc - .perform(delete(MgmtRestConstants.SOFTWAREMODULETYPE_V1_REQUEST_MAPPING + "/{softwareModuleTypeID}", - testType.getId())) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andDo(this.document.document(pathParameters( - parameterWithName("softwareModuleTypeID").description(ApiModelPropertiesGeneric.ITEM_ID)))); - assertThat(softwareModuleTypeManagement.count()).isEqualTo(3); - } - - @Test - @WithUser(principal = "uploadTester", allSpPermissions = true) - @Description("Handles the GET request of retrieving a single software module type within SP. Required Permission: READ_REPOSITORY.") - public void getSoftwareModuleType() throws Exception { - final SoftwareModuleType testType = testdataFactory.findOrCreateSoftwareModuleType("test123"); - softwareModuleTypeManagement - .update(entityFactory.softwareModuleType().update(testType.getId()).description("Desc1234").colour("rgb(106,178,83)")); - - this.mockMvc - .perform(get(MgmtRestConstants.SOFTWAREMODULETYPE_V1_REQUEST_MAPPING + "/{softwareModuleTypeID}", - testType.getId()).accept(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()) - .andDo(this.document.document( - pathParameters(parameterWithName("softwareModuleTypeID") - .description(ApiModelPropertiesGeneric.ITEM_ID)), - responseFields(fieldWithPath("key").description(MgmtApiModelProperties.SMT_KEY), - fieldWithPath("maxAssignments").description(MgmtApiModelProperties.SMT_MAX_ASSIGNMENTS), - fieldWithPath("createdBy").description(ApiModelPropertiesGeneric.CREATED_BY), - fieldWithPath("createdAt").description(ApiModelPropertiesGeneric.CREATED_AT), - fieldWithPath("description").description(ApiModelPropertiesGeneric.DESCRPTION), - fieldWithPath("colour").description(ApiModelPropertiesGeneric.COLOUR), - fieldWithPath("deleted").description(ApiModelPropertiesGeneric.DELETED), - fieldWithPath("id").description(ApiModelPropertiesGeneric.ITEM_ID), - fieldWithPath("lastModifiedAt").description(ApiModelPropertiesGeneric.LAST_MODIFIED_AT) - .type("Number"), - fieldWithPath("lastModifiedBy").description(ApiModelPropertiesGeneric.LAST_MODIFIED_BY) - .type("String"), - fieldWithPath("name").description(ApiModelPropertiesGeneric.NAME), - - fieldWithPath("_links.self").ignored()))); - } - - @Test - @Description("Handles the PUT request for a single software module type within SP. Required Permission: UPDATE_REPOSITORY.") - public void putSoftwareModuleType() throws Exception { - final SoftwareModuleType testType = testdataFactory.findOrCreateSoftwareModuleType("test123"); - - final String body = new JSONObject().put("description", "a new description").put("colour", "rgb(86,37,99)").toString(); - - this.mockMvc - .perform(put(MgmtRestConstants.SOFTWAREMODULETYPE_V1_REQUEST_MAPPING + "/{softwareModuleTypeID}", - testType.getId()).content(body.toString()).contentType(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andDo(this.document.document( - pathParameters(parameterWithName("softwareModuleTypeID") - .description(ApiModelPropertiesGeneric.ITEM_ID)), - requestFields( - optionalRequestFieldWithPath("description").description(ApiModelPropertiesGeneric.DESCRPTION), - optionalRequestFieldWithPath("colour").description(ApiModelPropertiesGeneric.COLOUR)), - responseFields(fieldWithPath("key").description(MgmtApiModelProperties.SMT_KEY), - fieldWithPath("maxAssignments").description(MgmtApiModelProperties.SMT_MAX_ASSIGNMENTS), - fieldWithPath("createdBy").description(ApiModelPropertiesGeneric.CREATED_BY), - fieldWithPath("createdAt").description(ApiModelPropertiesGeneric.CREATED_AT), - fieldWithPath("description").description(ApiModelPropertiesGeneric.DESCRPTION), - fieldWithPath("colour").description(ApiModelPropertiesGeneric.COLOUR), - fieldWithPath("deleted").description(ApiModelPropertiesGeneric.DELETED), - fieldWithPath("id").description(ApiModelPropertiesGeneric.ITEM_ID), - fieldWithPath("lastModifiedAt").description(ApiModelPropertiesGeneric.LAST_MODIFIED_AT) - .type("Number"), - fieldWithPath("lastModifiedBy").description(ApiModelPropertiesGeneric.LAST_MODIFIED_BY) - .type("String"), - fieldWithPath("name").description(ApiModelPropertiesGeneric.NAME), - fieldWithPath("_links.self").ignored()))); - - } - -} diff --git a/hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/mgmt/documentation/SoftwaremodulesDocumentationTest.java b/hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/mgmt/documentation/SoftwaremodulesDocumentationTest.java deleted file mode 100644 index 879a25d13a..0000000000 --- a/hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/mgmt/documentation/SoftwaremodulesDocumentationTest.java +++ /dev/null @@ -1,638 +0,0 @@ -/** - * Copyright (c) 2018 Bosch Software Innovations GmbH and others - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - */ -package org.eclipse.hawkbit.rest.mgmt.documentation; - -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.delete; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.fileUpload; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.post; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.put; -import static org.springframework.restdocs.payload.PayloadDocumentation.requestFields; -import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields; -import static org.springframework.restdocs.request.RequestDocumentation.parameterWithName; -import static org.springframework.restdocs.request.RequestDocumentation.pathParameters; -import static org.springframework.restdocs.request.RequestDocumentation.requestParameters; -import static org.springframework.restdocs.snippet.Attributes.key; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - -import java.io.ByteArrayInputStream; -import java.util.Arrays; -import java.util.List; - -import org.apache.commons.lang3.RandomStringUtils; -import org.eclipse.hawkbit.im.authentication.SpPermission; -import org.eclipse.hawkbit.mgmt.rest.api.MgmtRepresentationMode; -import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants; -import org.eclipse.hawkbit.repository.Constants; -import org.eclipse.hawkbit.repository.model.Artifact; -import org.eclipse.hawkbit.repository.model.ArtifactUpload; -import org.eclipse.hawkbit.repository.model.SoftwareModule; -import org.eclipse.hawkbit.rest.documentation.AbstractApiRestDocumentation; -import org.eclipse.hawkbit.rest.documentation.ApiModelPropertiesGeneric; -import org.eclipse.hawkbit.rest.documentation.MgmtApiModelProperties; -import org.eclipse.hawkbit.rest.util.JsonBuilder; -import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter; -import org.json.JSONArray; -import org.json.JSONObject; -import org.junit.jupiter.api.Test; -import org.springframework.hateoas.MediaTypes; -import org.springframework.http.MediaType; -import org.springframework.mock.web.MockMultipartFile; -import org.springframework.restdocs.payload.JsonFieldType; - -import io.qameta.allure.Description; -import io.qameta.allure.Feature; -import io.qameta.allure.Story; - -/** - * Documentation generation for Management API for {@link SoftwareModule}. - */ -@Feature("Spring Rest Docs Tests - SoftwareModule") -@Story("Softwaremodule Resource") -public class SoftwaremodulesDocumentationTest extends AbstractApiRestDocumentation { - - @Override - public String getResourceName() { - return "softwaremodules"; - } - - @Test - @Description("Handles the GET request of retrieving all softwaremodules within SP. Required Permission: " - + SpPermission.READ_REPOSITORY) - public void getSoftwareModules() throws Exception { - - final SoftwareModule sm = testdataFactory.createSoftwareModuleOs(); - softwareModuleManagement.update(entityFactory.softwareModule().update(sm.getId()).description("a description")); - - final SoftwareModule sm2 = testdataFactory.createSoftwareModuleApp(); - softwareModuleManagement - .update(entityFactory.softwareModule().update(sm2.getId()).description("a description")); - - mockMvc.perform(get(MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING)).andDo(MockMvcResultPrinter.print()) - .andExpect(status().isOk()).andExpect(content().contentType(MediaTypes.HAL_JSON)) - .andDo(this.document.document(responseFields( - fieldWithPath("total").description(ApiModelPropertiesGeneric.TOTAL_ELEMENTS), - fieldWithPath("size").type(JsonFieldType.NUMBER).description(ApiModelPropertiesGeneric.SIZE), - fieldWithPath("content").description(MgmtApiModelProperties.SM_LIST), - fieldWithPath("content[].id").description(ApiModelPropertiesGeneric.ITEM_ID), - fieldWithPath("content[].name").description(ApiModelPropertiesGeneric.NAME), - fieldWithPath("content[].description").description(ApiModelPropertiesGeneric.DESCRPTION), - fieldWithPath("content[].vendor").description(MgmtApiModelProperties.VENDOR), - fieldWithPath("content[].encrypted").description(MgmtApiModelProperties.ENCRYPTED), - fieldWithPath("content[].createdBy").description(ApiModelPropertiesGeneric.CREATED_BY), - fieldWithPath("content[].createdAt").description(ApiModelPropertiesGeneric.CREATED_AT), - fieldWithPath("content[].lastModifiedBy") - .description(ApiModelPropertiesGeneric.LAST_MODIFIED_BY), - fieldWithPath("content[].lastModifiedAt") - .description(ApiModelPropertiesGeneric.LAST_MODIFIED_AT), - fieldWithPath("content[].type").description(MgmtApiModelProperties.SM_TYPE), - fieldWithPath("content[].typeName").description(MgmtApiModelProperties.SM_TYPE_NAME), - fieldWithPath("content[].version").description(MgmtApiModelProperties.VERSION), - fieldWithPath("content[]._links.self").ignored()))); - } - - @Test - @Description("Handles the GET request of retrieving all softwaremodules within SP with given page size and offset including sorting by version descending and filter down to all sets which name starts with 'SM'. Required Permission: " - + SpPermission.READ_REPOSITORY) - public void getSoftwareModulesWithParameters() throws Exception { - - final SoftwareModule sm = testdataFactory.createSoftwareModuleOs(); - softwareModuleManagement.update(entityFactory.softwareModule().update(sm.getId()).description("a description")); - - final SoftwareModule sm2 = testdataFactory.createSoftwareModuleApp(); - softwareModuleManagement - .update(entityFactory.softwareModule().update(sm2.getId()).description("a description")); - - mockMvc.perform(get(MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING).param("offset", "1") - .param("limit", "2").param("sort", "version:DESC").param("q", "name==SM*")) - - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaTypes.HAL_JSON)) - .andDo(this.document.document(getFilterRequestParamter())); - } - - @Test - @Description("Handles the POST request of creating new software modules within SP. The request body must always be a list of modules. Required Permission: " - + SpPermission.CREATE_REPOSITORY) - public void postSoftwareModules() throws Exception { - final SoftwareModule os = entityFactory.softwareModule().create().type(osType).name("name1").version("version1") - .description("description1").vendor("vendor1").build(); - final SoftwareModule ah = entityFactory.softwareModule().create().type(appType).name("name3") - .version("version1").description("description1").vendor("vendor1").build(); - - final List modules = Arrays.asList(os, ah); - - mockMvc.perform(post(MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING) - .content(JsonBuilder.softwareModulesCreatableFieldsOnly(modules)).contentType(MediaTypes.HAL_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isCreated()) - .andExpect(content().contentType(MediaTypes.HAL_JSON)) - .andDo(this.document.document( - requestFields(requestFieldWithPath("[]name").description(ApiModelPropertiesGeneric.NAME), - optionalRequestFieldWithPath("[]description") - .description(ApiModelPropertiesGeneric.DESCRPTION), - requestFieldWithPath("[]version").description(MgmtApiModelProperties.VERSION), - optionalRequestFieldWithPath("[]vendor").description(MgmtApiModelProperties.VENDOR), - requestFieldWithPath("[]type").description(MgmtApiModelProperties.SMT_TYPE)), - responseFields(fieldWithPath("[].id").description(ApiModelPropertiesGeneric.ITEM_ID), - fieldWithPath("[].name").description(ApiModelPropertiesGeneric.NAME), - fieldWithPath("[].description").description(ApiModelPropertiesGeneric.DESCRPTION), - fieldWithPath("[].vendor").description(MgmtApiModelProperties.VENDOR), - fieldWithPath("[].encrypted").description(MgmtApiModelProperties.ENCRYPTED), - fieldWithPath("[].deleted").description(ApiModelPropertiesGeneric.DELETED), - fieldWithPath("[].createdBy").description(ApiModelPropertiesGeneric.CREATED_BY), - fieldWithPath("[].createdAt").description(ApiModelPropertiesGeneric.CREATED_AT), - fieldWithPath("[].lastModifiedBy") - .description(ApiModelPropertiesGeneric.LAST_MODIFIED_BY), - fieldWithPath("[].lastModifiedAt") - .description(ApiModelPropertiesGeneric.LAST_MODIFIED_AT), - fieldWithPath("[].type").description(MgmtApiModelProperties.SM_TYPE), - fieldWithPath("[].typeName").description(MgmtApiModelProperties.SM_TYPE_NAME), - fieldWithPath("[].version").description(MgmtApiModelProperties.VERSION), - fieldWithPath("[]._links.self").ignored()))); - } - - @Test - @Description("Handles the DELETE request for a single softwaremodule within SP. Required Permission: " - + SpPermission.DELETE_REPOSITORY) - public void deleteSoftwareModule() throws Exception { - final SoftwareModule sm = testdataFactory.createSoftwareModuleOs(); - - this.mockMvc - .perform( - delete(MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING + "/{softwareModuleId}", sm.getId())) - .andExpect(status().isOk()).andDo(MockMvcResultPrinter.print()) - .andDo(this.document.document(pathParameters( - parameterWithName("softwareModuleId").description(ApiModelPropertiesGeneric.ITEM_ID)))); - } - - @Test - @Description("Handles the GET request of retrieving a single softwaremodule within SP. Required Permission: " - + SpPermission.READ_REPOSITORY) - public void getSoftwareModule() throws Exception { - final SoftwareModule sm = testdataFactory.createSoftwareModuleOs(); - softwareModuleManagement.update(entityFactory.softwareModule().update(sm.getId()).description("a description")); - - mockMvc.perform(get(MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING + "/{softwareModuleId}", sm.getId())) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaTypes.HAL_JSON)) - .andDo(this.document.document( - pathParameters( - parameterWithName("softwareModuleId").description(ApiModelPropertiesGeneric.ITEM_ID)), - responseFields(fieldWithPath("id").description(ApiModelPropertiesGeneric.ITEM_ID), - fieldWithPath("name").description(ApiModelPropertiesGeneric.NAME), - fieldWithPath("description").description(ApiModelPropertiesGeneric.DESCRPTION), - fieldWithPath("createdBy").description(ApiModelPropertiesGeneric.CREATED_BY), - fieldWithPath("createdAt").description(ApiModelPropertiesGeneric.CREATED_AT), - fieldWithPath("lastModifiedBy").description(ApiModelPropertiesGeneric.LAST_MODIFIED_BY), - fieldWithPath("lastModifiedAt").description(ApiModelPropertiesGeneric.LAST_MODIFIED_AT), - fieldWithPath("vendor").description(MgmtApiModelProperties.VENDOR), - fieldWithPath("encrypted").description(MgmtApiModelProperties.ENCRYPTED), - fieldWithPath("deleted").description(ApiModelPropertiesGeneric.DELETED), - fieldWithPath("type").description(MgmtApiModelProperties.SM_TYPE), - fieldWithPath("typeName").description(MgmtApiModelProperties.SM_TYPE_NAME), - fieldWithPath("version").description(MgmtApiModelProperties.VERSION), - fieldWithPath("_links.self").ignored(), - fieldWithPath("_links.type").description(MgmtApiModelProperties.SM_TYPE), - fieldWithPath("_links.artifacts").description(MgmtApiModelProperties.ARTIFACT_LIST), - fieldWithPath("_links.metadata").description(MgmtApiModelProperties.META_DATA)))); - } - - @Test - @Description("Handles the PUT request for a single softwaremodule within SP. Required Permission: " - + SpPermission.UPDATE_REPOSITORY) - public void putSoftwareModule() throws Exception { - final SoftwareModule sm = testdataFactory.createSoftwareModuleOs(); - softwareModuleManagement.update(entityFactory.softwareModule().update(sm.getId()).description("a description")); - - final SoftwareModule update = entityFactory.softwareModule().create().name("another name") - .vendor("another Vendor").description("a new description").type(Constants.SMT_DEFAULT_OS_KEY).build(); - - mockMvc.perform(put(MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING + "/{softwareModuleId}", sm.getId()) - .content(JsonBuilder.softwareModuleUpdatableFieldsOnly(update)).contentType(MediaTypes.HAL_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaTypes.HAL_JSON)) - .andDo(this.document.document( - pathParameters( - parameterWithName("softwareModuleId").description(ApiModelPropertiesGeneric.ITEM_ID)), - requestFields(optionalRequestFieldWithPath("vendor").description(MgmtApiModelProperties.VENDOR), - optionalRequestFieldWithPath("description") - .description(ApiModelPropertiesGeneric.DESCRPTION)), - responseFields(fieldWithPath("id").description(ApiModelPropertiesGeneric.ITEM_ID), - fieldWithPath("name").description(ApiModelPropertiesGeneric.NAME), - fieldWithPath("description").description(ApiModelPropertiesGeneric.DESCRPTION), - fieldWithPath("createdBy").description(ApiModelPropertiesGeneric.CREATED_BY), - fieldWithPath("createdAt").description(ApiModelPropertiesGeneric.CREATED_AT), - fieldWithPath("lastModifiedBy").description(ApiModelPropertiesGeneric.LAST_MODIFIED_BY), - fieldWithPath("lastModifiedAt").description(ApiModelPropertiesGeneric.LAST_MODIFIED_AT), - fieldWithPath("type").description(MgmtApiModelProperties.SM_TYPE), - fieldWithPath("typeName").description(MgmtApiModelProperties.SM_TYPE_NAME), - fieldWithPath("version").description(MgmtApiModelProperties.VERSION), - fieldWithPath("vendor").description(MgmtApiModelProperties.VENDOR), - fieldWithPath("encrypted").description(MgmtApiModelProperties.ENCRYPTED), - fieldWithPath("deleted").description(ApiModelPropertiesGeneric.DELETED), - fieldWithPath("_links.self").ignored(), - fieldWithPath("_links.type").description(MgmtApiModelProperties.SM_TYPE), - fieldWithPath("_links.artifacts").description(MgmtApiModelProperties.ARTIFACT_LIST), - fieldWithPath("_links.metadata").description(MgmtApiModelProperties.META_DATA)))); - - } - - @Test - @Description("Handles the GET request of retrieving all meta data of artifacts assigned to a software module. Required Permission: " - + SpPermission.READ_REPOSITORY) - public void getArtifacts() throws Exception { - final SoftwareModule sm = testdataFactory.createSoftwareModuleOs(); - - final byte[] random = RandomStringUtils.random(5).getBytes(); - - artifactManagement.create(new ArtifactUpload(new ByteArrayInputStream(random), sm.getId(), "file1", false, 0)); - - mockMvc.perform( - get(MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING + "/{softwareModuleId}/artifacts", sm.getId())) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaTypes.HAL_JSON)) - .andDo(this.document.document( - pathParameters( - parameterWithName("softwareModuleId").description(ApiModelPropertiesGeneric.ITEM_ID)), - responseFields(fieldWithPath("[].id").description(ApiModelPropertiesGeneric.ITEM_ID), - fieldWithPath("[].size").description(MgmtApiModelProperties.ARTIFACT_SIZE), - fieldWithPath("[].createdBy").description(ApiModelPropertiesGeneric.CREATED_BY), - fieldWithPath("[].createdAt").description(ApiModelPropertiesGeneric.CREATED_AT), - fieldWithPath("[].lastModifiedBy") - .description(ApiModelPropertiesGeneric.LAST_MODIFIED_BY), - fieldWithPath("[].lastModifiedAt") - .description(ApiModelPropertiesGeneric.LAST_MODIFIED_AT), - fieldWithPath("[].hashes.md5").description(MgmtApiModelProperties.ARTIFACT_HASHES_MD5), - fieldWithPath("[].hashes.sha1") - .description(MgmtApiModelProperties.ARTIFACT_HASHES_SHA1), - fieldWithPath("[].hashes.sha256") - .description(MgmtApiModelProperties.ARTIFACT_HASHES_SHA256), - fieldWithPath("[].providedFilename") - .description(MgmtApiModelProperties.ARTIFACT_PROVIDED_FILENAME), - fieldWithPath("[]._links.self").ignored()))); - } - - @Test - @Description("Handles the GET request of retrieving all meta data of artifacts assigned to a software module (in full representation mode including a download URL by the artifact provider). Required Permission: " - + SpPermission.READ_REPOSITORY) - public void getArtifactsWithParameters() throws Exception { - final SoftwareModule sm = testdataFactory.createSoftwareModuleOs(); - - final byte[] random = RandomStringUtils.random(5).getBytes(); - - artifactManagement.create(new ArtifactUpload(new ByteArrayInputStream(random), sm.getId(), "file1", false, 0)); - - mockMvc.perform( - get(MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING + "/{softwareModuleId}/artifacts", sm.getId()) - .param("representation", MgmtRepresentationMode.FULL.toString()) - .param("useartifacturlhandler", Boolean.TRUE.toString())) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaTypes.HAL_JSON)) - .andDo(this.document.document(requestParameters( - parameterWithName("representation").description(MgmtApiModelProperties.REPRESENTATION_MODE) - .optional(), - parameterWithName("useartifacturlhandler") - .description(MgmtApiModelProperties.ARTIFACT_DOWNLOAD_USE_URL_HANDLER).optional()))); - } - - @Test - @Description("Handles POST request for artifact upload. Required Permission: " + SpPermission.CREATE_REPOSITORY) - public void postArtifact() throws Exception { - final SoftwareModule sm = testdataFactory.createSoftwareModuleOs(); - - // create test file - final byte[] random = RandomStringUtils.random(5).getBytes(); - final MockMultipartFile file = new MockMultipartFile("file", "origFilename", null, random); - - mockMvc.perform( - fileUpload(MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING + "/{softwareModuleId}/artifacts", - sm.getId()).file(file)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isCreated()) - .andExpect(content().contentType(MediaTypes.HAL_JSON)) - .andDo(this.document.document( - pathParameters( - parameterWithName("softwareModuleId").description(ApiModelPropertiesGeneric.ITEM_ID)), - responseFields(fieldWithPath("size").description(MgmtApiModelProperties.ARTIFACT_SIZE), - fieldWithPath("id").description(ApiModelPropertiesGeneric.ITEM_ID), - fieldWithPath("createdBy").description(ApiModelPropertiesGeneric.CREATED_BY), - fieldWithPath("createdAt").description(ApiModelPropertiesGeneric.CREATED_AT), - fieldWithPath("lastModifiedBy").description(ApiModelPropertiesGeneric.LAST_MODIFIED_BY), - fieldWithPath("lastModifiedAt").description(ApiModelPropertiesGeneric.LAST_MODIFIED_AT), - fieldWithPath("_links.self").ignored(), - fieldWithPath("_links.download") - .description(MgmtApiModelProperties.ARTIFACT_DOWNLOAD_LINK), - fieldWithPath("hashes.md5").description(MgmtApiModelProperties.ARTIFACT_HASHES_MD5), - fieldWithPath("hashes.sha1").description(MgmtApiModelProperties.ARTIFACT_HASHES_SHA1), - fieldWithPath("hashes.sha256") - .description(MgmtApiModelProperties.ARTIFACT_HASHES_SHA256), - fieldWithPath("providedFilename") - .description(MgmtApiModelProperties.ARTIFACT_PROVIDED_FILENAME))) - - ); - } - - @Test - @Description("Handles POST request for artifact upload. Required Permission: " + SpPermission.CREATE_REPOSITORY) - public void postArtifactWithParameters() throws Exception { - - final SoftwareModule sm = testdataFactory.createSoftwareModuleOs(); - - final byte[] random = RandomStringUtils.random(5).getBytes(); - final MockMultipartFile file = new MockMultipartFile("file", "origFilename", null, random); - - mockMvc.perform( - fileUpload(MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING + "/{softwareModuleId}/artifacts", - sm.getId()).file(file).param("filename", "filename").param("file", "s") - .param("md5sum", "md5sum").param("sha1sum", "sha1sum")) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isBadRequest()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON)) - .andDo(this.document.document(requestParameters( - parameterWithName("filename").description(MgmtApiModelProperties.ARTIFACT_PROVIDED_FILENAME), - parameterWithName("file").description(MgmtApiModelProperties.ARTIFACT_PROVIDED_FILE), - parameterWithName("md5sum").description(MgmtApiModelProperties.ARTIFACT_HASHES_MD5), - parameterWithName("sha1sum").description(MgmtApiModelProperties.ARTIFACT_HASHES_SHA1)))); - } - - @Test - @Description("Handles the DELETE request for a single SoftwareModule within SP. Required Permission: " - + SpPermission.DELETE_REPOSITORY) - public void deleteArtifact() throws Exception { - final SoftwareModule sm = testdataFactory.createSoftwareModuleOs(); - - final byte[] random = RandomStringUtils.random(5).getBytes(); - - final Artifact artifact = artifactManagement - .create(new ArtifactUpload(new ByteArrayInputStream(random), sm.getId(), "file1", false, 0)); - - mockMvc.perform(delete( - MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING + "/{softwareModuleId}/artifacts/{artifactId}", - sm.getId(), artifact.getId())).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andDo(this.document.document(pathParameters( - parameterWithName("softwareModuleId").description(ApiModelPropertiesGeneric.ITEM_ID), - parameterWithName("artifactId").description(ApiModelPropertiesGeneric.ITEM_ID)))); - } - - @Test - @Description("Handles the GET request of retrieving a single Artifact meta data request. Required Permission: " - + SpPermission.READ_REPOSITORY) - public void getArtifact() throws Exception { - final SoftwareModule sm = testdataFactory.createSoftwareModuleOs(); - - final byte[] random = RandomStringUtils.random(5).getBytes(); - - final Artifact artifact = artifactManagement - .create(new ArtifactUpload(new ByteArrayInputStream(random), sm.getId(), "file1", false, 0)); - - mockMvc.perform( - get(MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING + "/{softwareModuleId}/artifacts/{artifactId}", - sm.getId(), artifact.getId())) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaTypes.HAL_JSON)) - .andDo(this.document.document( - pathParameters( - parameterWithName("softwareModuleId").description(ApiModelPropertiesGeneric.ITEM_ID), - parameterWithName("artifactId").description(ApiModelPropertiesGeneric.ITEM_ID)), - responseFields(fieldWithPath("id").description(ApiModelPropertiesGeneric.ITEM_ID), - fieldWithPath("size").description(MgmtApiModelProperties.ARTIFACT_SIZE), - fieldWithPath("createdBy").description(ApiModelPropertiesGeneric.CREATED_BY), - fieldWithPath("createdAt").description(ApiModelPropertiesGeneric.CREATED_AT), - fieldWithPath("lastModifiedBy").description(ApiModelPropertiesGeneric.LAST_MODIFIED_BY), - fieldWithPath("lastModifiedAt").description(ApiModelPropertiesGeneric.LAST_MODIFIED_AT), - fieldWithPath("hashes.md5").description(MgmtApiModelProperties.ARTIFACT_HASHES_MD5), - fieldWithPath("hashes.sha1").description(MgmtApiModelProperties.ARTIFACT_HASHES_SHA1), - fieldWithPath("hashes.sha256") - .description(MgmtApiModelProperties.ARTIFACT_HASHES_SHA256), - fieldWithPath("providedFilename") - .description(MgmtApiModelProperties.ARTIFACT_PROVIDED_FILENAME), - fieldWithPath("_links.self").ignored(), fieldWithPath("_links.download") - .description(MgmtApiModelProperties.ARTIFACT_DOWNLOAD_LINK)))); - } - - @Test - @Description("Handles the GET request of retrieving a single Artifact meta data request. Required Permission: " - + SpPermission.READ_REPOSITORY) - public void getArtifactWithParameters() throws Exception { - final SoftwareModule sm = testdataFactory.createSoftwareModuleOs(); - - final byte[] random = RandomStringUtils.random(5).getBytes(); - - final Artifact artifact = artifactManagement - .create(new ArtifactUpload(new ByteArrayInputStream(random), sm.getId(), "file1", false, 0)); - - mockMvc.perform( - get(MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING + "/{softwareModuleId}/artifacts/{artifactId}", - sm.getId(), artifact.getId()).param("useartifacturlhandler", "true")) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaTypes.HAL_JSON)) - .andDo(this.document.document(requestParameters(parameterWithName("useartifacturlhandler") - .description(MgmtApiModelProperties.ARTIFACT_DOWNLOAD_USE_URL_HANDLER).optional()))); - } - - @Test - @Description("Handles the GET request for downloading an artifact. Required Permission: " - + SpPermission.READ_REPOSITORY) - public void getDownloadArtifact() throws Exception { - - final SoftwareModule sm = testdataFactory.createSoftwareModuleOs(); - - final byte[] random = RandomStringUtils.random(5).getBytes(); - - final Artifact artifact = artifactManagement - .create(new ArtifactUpload(new ByteArrayInputStream(random), sm.getId(), "file1", false, 0)); - - mockMvc.perform(get(MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING - + "/{softwareModuleId}/artifacts/{artifactId}/download", sm.getId(), artifact.getId()) - .accept(MediaType.APPLICATION_OCTET_STREAM)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_OCTET_STREAM)) - .andDo(this.document.document(pathParameters( - parameterWithName("softwareModuleId").description(ApiModelPropertiesGeneric.ITEM_ID), - parameterWithName("artifactId").description(ApiModelPropertiesGeneric.ITEM_ID)))); - } - - @Test - @Description(" Get a paged list of meta data for a software module." + " Required Permission: " - + SpPermission.READ_REPOSITORY) - public void getMetadata() throws Exception { - final int totalMetadata = 4; - final String knownKeyPrefix = "knownKey"; - final String knownValuePrefix = "knownValue"; - final SoftwareModule module = testdataFactory.createDistributionSet("one").findFirstModuleByType(osType).get(); - - for (int index = 0; index < totalMetadata; index++) { - softwareModuleManagement.createMetaData(entityFactory.softwareModuleMetadata().create(module.getId()) - .key(knownKeyPrefix + index).value(knownValuePrefix + index)); - } - - mockMvc.perform(get(MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING + "/{softwareModuleId}/metadata", - module.getId())).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaTypes.HAL_JSON)) - .andDo(this.document.document( - pathParameters( - parameterWithName("softwareModuleId").description(ApiModelPropertiesGeneric.ITEM_ID)), - responseFields(fieldWithPath("total").description(ApiModelPropertiesGeneric.TOTAL_ELEMENTS), - fieldWithPath("size").type(JsonFieldType.NUMBER) - .description(ApiModelPropertiesGeneric.SIZE), - fieldWithPath("content").description(MgmtApiModelProperties.META_DATA), - fieldWithPath("content[].key").description(MgmtApiModelProperties.META_DATA_KEY), - fieldWithPath("content[].value").description(MgmtApiModelProperties.META_DATA_VALUE), - fieldWithPath("content[].targetVisible") - .description(MgmtApiModelProperties.SM_META_DATA_TARGET_VISIBLE)))); - } - - @Test - @Description(" Get a paged list of meta data for a software module with defined page size and sorting by name descending and key starting with 'known'." - + " Required Permission: " + SpPermission.READ_REPOSITORY) - public void getMetadataWithParameters() throws Exception { - final int totalMetadata = 4; - final String knownKeyPrefix = "knownKey"; - final String knownValuePrefix = "knownValue"; - final SoftwareModule module = testdataFactory.createDistributionSet("one").findFirstModuleByType(osType).get(); - - for (int index = 0; index < totalMetadata; index++) { - softwareModuleManagement.createMetaData(entityFactory.softwareModuleMetadata().create(module.getId()) - .key(knownKeyPrefix + index).value(knownValuePrefix + index)); - } - - mockMvc.perform(get(MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING + "/{softwareModuleId}/metadata", - module.getId()).param("offset", "1").param("limit", "2").param("sort", "key:DESC").param("q", - "key==known*")) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaTypes.HAL_JSON)) - .andDo(this.document.document( - pathParameters( - parameterWithName("softwareModuleId").description(ApiModelPropertiesGeneric.ITEM_ID)), - requestParameters( - parameterWithName("limit").attributes(key("type").value("query")) - .description(ApiModelPropertiesGeneric.LIMIT), - parameterWithName("sort").description(ApiModelPropertiesGeneric.SORT), - parameterWithName("offset").description(ApiModelPropertiesGeneric.OFFSET), - parameterWithName("q").description(ApiModelPropertiesGeneric.FIQL)))); - } - - @Test - @Description("Create a list of meta data entries" + " Required Permission: " + SpPermission.UPDATE_REPOSITORY) - public void postMetadata() throws Exception { - - final SoftwareModule module = testdataFactory.createDistributionSet("one").findFirstModuleByType(osType).get(); - - final String knownKey1 = "knownKey1"; - final String knownKey2 = "knownKey2"; - - final String knownValue1 = "knownValue1"; - final String knownValue2 = "knownValue2"; - - final JSONArray jsonArray = new JSONArray(); - jsonArray.put(new JSONObject().put("key", knownKey1).put("value", knownValue1)); - jsonArray.put(new JSONObject().put("key", knownKey2).put("value", knownValue2).put("targetVisible", true)); - - mockMvc.perform(post(MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING + "/{softwareModuleId}/metadata", - module.getId()).contentType(MediaTypes.HAL_JSON).content(jsonArray.toString())) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isCreated()) - .andExpect(content().contentType(MediaTypes.HAL_JSON)) - .andDo(this.document.document( - pathParameters( - parameterWithName("softwareModuleId").description(ApiModelPropertiesGeneric.ITEM_ID)), - requestFields(requestFieldWithPath("[]key").description(MgmtApiModelProperties.META_DATA_KEY), - requestFieldWithPath("[]value").description(MgmtApiModelProperties.META_DATA_VALUE), - requestFieldWithPath("[]targetVisible") - .description(MgmtApiModelProperties.SM_META_DATA_TARGET_VISIBLE).optional()), - - responseFields(fieldWithPath("[]key").description(MgmtApiModelProperties.META_DATA_KEY), - fieldWithPath("[]value").description(MgmtApiModelProperties.META_DATA_VALUE), - fieldWithPath("[]targetVisible") - .description(MgmtApiModelProperties.SM_META_DATA_TARGET_VISIBLE) - - ) - - )); - } - - @Test - @Description(" Delete a single meta data." + " Required Permission: " + SpPermission.UPDATE_REPOSITORY) - public void deleteMetadata() throws Exception { - // prepare and create metadata for deletion - final String knownKey = "knownKey"; - final String knownValue = "knownValue"; - - final SoftwareModule module = testdataFactory.createDistributionSet("one").findFirstModuleByType(osType).get(); - softwareModuleManagement.createMetaData( - entityFactory.softwareModuleMetadata().create(module.getId()).key(knownKey).value(knownValue)); - - mockMvc.perform(delete( - MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING + "/{softwareModuleId}/metadata/{{metadataKey}", - module.getId(), knownKey)).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andDo(this.document.document(pathParameters( - parameterWithName("softwareModuleId").description(ApiModelPropertiesGeneric.ITEM_ID), - parameterWithName("{metadataKey").description(MgmtApiModelProperties.META_DATA_KEY)))); - } - - @Test - @Description(" Get a single meta data value for a meta data key." + " Required Permission: " - + SpPermission.READ_REPOSITORY) - public void getMetadataValue() throws Exception { - - // prepare and create metadata - final String knownKey = "knownKey"; - final String knownValue = "knownValue"; - final SoftwareModule module = testdataFactory.createDistributionSet("one").findFirstModuleByType(osType).get(); - softwareModuleManagement.createMetaData( - entityFactory.softwareModuleMetadata().create(module.getId()).key(knownKey).value(knownValue)); - - mockMvc.perform( - get(MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING + "/{softwareModuleId}/metadata/{metadataKey}", - module.getId(), knownKey)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andDo(this.document.document( - pathParameters( - parameterWithName("softwareModuleId").description(ApiModelPropertiesGeneric.ITEM_ID), - parameterWithName("metadataKey").description(MgmtApiModelProperties.META_DATA_KEY)), - responseFields(fieldWithPath("key").description(MgmtApiModelProperties.META_DATA_KEY), - fieldWithPath("value").description(MgmtApiModelProperties.META_DATA_VALUE), - fieldWithPath("targetVisible") - .description(MgmtApiModelProperties.SM_META_DATA_TARGET_VISIBLE)))); - } - - @Test - @Description(" Update a single meta data value for speficic key." + " Required Permission: " - + SpPermission.UPDATE_REPOSITORY) - public void putMetadata() throws Exception { - // prepare and create metadata for update - final String knownKey = "knownKey"; - final String knownValue = "knownValue"; - final String updateValue = "valueForUpdate"; - - final SoftwareModule module = testdataFactory.createDistributionSet("one").findFirstModuleByType(osType).get(); - softwareModuleManagement.createMetaData( - entityFactory.softwareModuleMetadata().create(module.getId()).key(knownKey).value(knownValue)); - - final JSONObject jsonObject = new JSONObject().put("key", knownKey).put("value", updateValue) - .put("targetVisible", true); - - mockMvc.perform( - put(MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING + "/{softwareModuleId}/metadata/{metadataKey}", - module.getId(), knownKey).contentType(MediaTypes.HAL_JSON).content(jsonObject.toString())) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andDo(this.document.document( - pathParameters(parameterWithName("softwareModuleId") - .description(ApiModelPropertiesGeneric.ITEM_ID), - parameterWithName("metadataKey").description(MgmtApiModelProperties.META_DATA_KEY)), - requestFields(requestFieldWithPath("key").description(MgmtApiModelProperties.META_DATA_KEY), - requestFieldWithPath("value").description(MgmtApiModelProperties.META_DATA_VALUE), - requestFieldWithPath("targetVisible") - .description(MgmtApiModelProperties.SM_META_DATA_TARGET_VISIBLE)), - responseFields(fieldWithPath("key").description(MgmtApiModelProperties.META_DATA_KEY), - fieldWithPath("value").description(MgmtApiModelProperties.META_DATA_VALUE), - fieldWithPath("targetVisible") - .description(MgmtApiModelProperties.SM_META_DATA_TARGET_VISIBLE)))); - } - -} diff --git a/hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/mgmt/documentation/TargetFilterQueriesResourceDocumentationTest.java b/hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/mgmt/documentation/TargetFilterQueriesResourceDocumentationTest.java deleted file mode 100644 index 74ac6c865f..0000000000 --- a/hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/mgmt/documentation/TargetFilterQueriesResourceDocumentationTest.java +++ /dev/null @@ -1,276 +0,0 @@ -/** - * Copyright (c) 2018 Bosch Software Innovations GmbH and others - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - */ -package org.eclipse.hawkbit.rest.mgmt.documentation; - -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.delete; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.post; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.put; -import static org.springframework.restdocs.payload.PayloadDocumentation.requestFields; -import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields; -import static org.springframework.restdocs.request.RequestDocumentation.parameterWithName; -import static org.springframework.restdocs.request.RequestDocumentation.pathParameters; -import static org.springframework.restdocs.request.RequestDocumentation.requestParameters; -import static org.springframework.restdocs.snippet.Attributes.key; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - -import java.util.HashMap; -import java.util.Map; - -import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtActionType; -import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants; -import org.eclipse.hawkbit.repository.model.DistributionSet; -import org.eclipse.hawkbit.repository.model.TargetFilterQuery; -import org.eclipse.hawkbit.rest.documentation.AbstractApiRestDocumentation; -import org.eclipse.hawkbit.rest.documentation.ApiModelPropertiesGeneric; -import org.eclipse.hawkbit.rest.documentation.MgmtApiModelProperties; -import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter; -import org.json.JSONObject; -import org.junit.jupiter.api.Test; -import org.springframework.http.MediaType; -import org.springframework.restdocs.payload.JsonFieldType; -import org.springframework.restdocs.snippet.Snippet; - -import com.fasterxml.jackson.core.JsonProcessingException; - -import io.qameta.allure.Description; -import io.qameta.allure.Feature; -import io.qameta.allure.Story; - -/** - * Documentation generation for Management API for {@link TargetFilterQuery}. - */ -@Feature("Spring Rest Docs Tests - TargetFilterQuery") -@Story("TargetFilterQuery Resource") -public class TargetFilterQueriesResourceDocumentationTest extends AbstractApiRestDocumentation { - - private static final String EXAMPLE_TFQ_NAME = "filter1"; - private static final String EXAMPLE_TFQ_QUERY = "name==*"; - - @Override - public String getResourceName() { - return "targetfilters"; - } - - @Test - @Description("Handles the GET request of retrieving all target filter queries within SP. Required Permission: READ_TARGET.") - public void getTargetFilterQueries() throws Exception { - createTargetFilterQueryWithDS(createDistributionSet()); - - mockMvc.perform(get(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING)).andExpect(status().isOk()) - .andDo(MockMvcResultPrinter.print()) - .andDo(this.document.document(responseFields( - fieldWithPath("size").type(JsonFieldType.NUMBER).description(ApiModelPropertiesGeneric.SIZE), - fieldWithPath("total").description(ApiModelPropertiesGeneric.TOTAL_ELEMENTS), - fieldWithPath("content").description(MgmtApiModelProperties.TARGET_FILTER_QUERIES_LIST), - fieldWithPath("content[].id").description(ApiModelPropertiesGeneric.ITEM_ID), - fieldWithPath("content[].name").description(ApiModelPropertiesGeneric.NAME), - fieldWithPath("content[].query").description(MgmtApiModelProperties.TARGET_FILTER_QUERY), - fieldWithPath("content[].autoAssignDistributionSet") - .description(MgmtApiModelProperties.TARGET_FILTER_QUERY_AUTO_ASSIGN_DS_ID) - .type(JsonFieldType.NUMBER.toString()), - fieldWithPath("content[].autoAssignActionType") - .description(MgmtApiModelProperties.ACTION_FORCE_TYPE) - .type(JsonFieldType.STRING.toString()) - .attributes(key("value").value("['forced', 'soft', 'downloadonly']")), - fieldWithPath("content[].autoAssignWeight") - .description(MgmtApiModelProperties.RESULTING_ACTIONS_WEIGHT) - .type(JsonFieldType.NUMBER.toString()), - fieldWithPath("content[].confirmationRequired") - .description(MgmtApiModelProperties.ACTION_CONFIRMATION_REQUIRED) - .type(JsonFieldType.BOOLEAN.toString()), - fieldWithPath("content[].createdAt").description(ApiModelPropertiesGeneric.CREATED_AT), - fieldWithPath("content[].createdBy").description(ApiModelPropertiesGeneric.CREATED_BY), - fieldWithPath("content[].lastModifiedAt") - .description(ApiModelPropertiesGeneric.LAST_MODIFIED_AT), - fieldWithPath("content[].lastModifiedBy") - .description(ApiModelPropertiesGeneric.LAST_MODIFIED_BY), - fieldWithPath("content[]._links.self").ignored()))); - } - - @Test - @Description("Handles the GET request of retrieving all target filter queries within SP based by parameter. Required Permission: READ_TARGET.") - public void getTargetFilterQueriesWithParameters() throws Exception { - - mockMvc.perform( - get(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "?limit=10&sort=name:ASC&offset=0&q=name==*1")) - .andExpect(status().isOk()).andDo(MockMvcResultPrinter.print()) - .andDo(this.document.document(requestParameters( - parameterWithName("limit").attributes(key("type").value("query")) - .description(ApiModelPropertiesGeneric.LIMIT), - parameterWithName("sort").description(ApiModelPropertiesGeneric.SORT), - parameterWithName("offset").description(ApiModelPropertiesGeneric.OFFSET), - parameterWithName("q").description(ApiModelPropertiesGeneric.FIQL)))); - } - - @Test - @Description("Handles the POST request of creating a new target filter query within SP. Required Permission: CREATE_TARGET.") - public void postTargetFilterQuery() throws Exception { - final String tfqJson = createTargetFilterQueryJson(EXAMPLE_TFQ_NAME, EXAMPLE_TFQ_QUERY); - - this.mockMvc - .perform(post(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING) - .contentType(MediaType.APPLICATION_JSON).content(tfqJson)) - .andExpect(status().isCreated()).andDo(MockMvcResultPrinter.print()).andDo( - this.document.document( - requestFields(requestFieldWithPath("name").description(ApiModelPropertiesGeneric.NAME), - requestFieldWithPath("query") - .description(MgmtApiModelProperties.TARGET_FILTER_QUERY)), - getResponseFieldTargetFilterQuery(false))); - - } - - @Test - @Description("Handles the DELETE request of deleting a single target filter query within SP. Required Permission: DELETE_TARGET.") - public void deleteTargetFilterQuery() throws Exception { - final TargetFilterQuery tfq = createTargetFilterQuery(); - this.mockMvc - .perform(delete(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/{targetFilterQueryId}", - tfq.getId())) - .andExpect(status().isOk()).andDo(MockMvcResultPrinter.print()) - .andDo(this.document.document(pathParameters( - parameterWithName("targetFilterQueryId").description(ApiModelPropertiesGeneric.ITEM_ID)))); - } - - @Test - @Description("Handles the GET request of retrieving a single target filter query within SP. Required Permission: READ_TARGET.") - public void getTargetFilterQuery() throws Exception { - final TargetFilterQuery tfq = createTargetFilterQueryWithDS(createDistributionSet()); - - mockMvc.perform(get(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/{targetFilterQueryId}", tfq.getId())) - .andExpect(status().isOk()).andDo(MockMvcResultPrinter.print()) - .andDo(this.document.document( - pathParameters(parameterWithName("targetFilterQueryId") - .description(ApiModelPropertiesGeneric.ITEM_ID)), - getResponseFieldTargetFilterQuery(false))); - } - - @Test - @Description("Handles the PUT request of updating a target filter query within SP. Required Permission: UPDATE_TARGET.") - public void putTargetFilterQuery() throws Exception { - final TargetFilterQuery tfq = createTargetFilterQuery(); - final String targetAsJson = createTargetFilterQueryJson("newFilterName", "attribute.hwRevision==2"); - this.mockMvc - .perform(put(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/{targetFilterQueryId}", tfq.getId()) - .contentType(MediaType.APPLICATION_JSON).content(targetAsJson)) - .andExpect(status().isOk()).andDo(MockMvcResultPrinter.print()) - .andDo(this.document.document( - pathParameters(parameterWithName("targetFilterQueryId") - .description(ApiModelPropertiesGeneric.ITEM_ID)), - requestFields(optionalRequestFieldWithPath("name").description(ApiModelPropertiesGeneric.NAME), - optionalRequestFieldWithPath("query") - .description(MgmtApiModelProperties.TARGET_FILTER_QUERY)), - getResponseFieldTargetFilterQuery(false))); - - } - - @Test - @Description("Handles the GET request of retrieving a the auto assign distribution set of a target filter query within SP. Required Permission: READ_TARGET.") - public void getAssignDS() throws Exception { - final TargetFilterQuery tfq = createTargetFilterQueryWithDS(createDistributionSet()); - - mockMvc.perform(get(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/{targetFilterQueryId}/autoAssignDS", - tfq.getId())).andExpect(status().isOk()).andDo(MockMvcResultPrinter.print()) - .andDo(this.document.document( - pathParameters(parameterWithName("targetFilterQueryId") - .description(ApiModelPropertiesGeneric.ITEM_ID)), - getResponseFieldsDistributionSet(false))); - } - - @Test - @Description("Handles the POST request of setting a distribution set for auto assignment within SP. Required Permission: CREATE_TARGET.") - public void postAutoAssignDS() throws Exception { - enableMultiAssignments(); - enableConfirmationFlow(); - - final TargetFilterQuery tfq = createTargetFilterQuery(); - final DistributionSet distributionSet = createDistributionSet(); - final String autoAssignBody = new JSONObject().put("id", distributionSet.getId()) - .put("type", MgmtActionType.SOFT.getName()).put("weight", 200).toString(); - - this.mockMvc - .perform( - post(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/{targetFilterQueryId}/autoAssignDS", - tfq.getId()).contentType(MediaType.APPLICATION_JSON).content(autoAssignBody.toString())) - .andExpect(status().isOk()).andDo(MockMvcResultPrinter.print()) - .andDo(this.document.document( - pathParameters(parameterWithName("targetFilterQueryId") - .description(ApiModelPropertiesGeneric.ITEM_ID)), - requestFields(requestFieldWithPath("id").description(MgmtApiModelProperties.DS_ID), - optionalRequestFieldWithPath("type") - .description(MgmtApiModelProperties.ACTION_FORCE_TYPE) - .attributes(key("value").value("['forced', 'soft', 'downloadonly']")), - requestFieldWithPathMandatoryInMultiAssignMode("weight") - .description(MgmtApiModelProperties.RESULTING_ACTIONS_WEIGHT) - .attributes(key("value").value("0 - 1000")), - optionalRequestFieldWithPath("confirmationRequired") - .description(MgmtApiModelProperties.ACTION_CONFIRMATION_REQUIRED) - .type(JsonFieldType.BOOLEAN.toString())), - getResponseFieldTargetFilterQuery(false))); - } - - @Test - @Description("Handles the DELETE request of deleting the auto assign distribution set from a target filter query within SP. Required Permission: DELETE_TARGET.") - public void deleteAutoAssignDS() throws Exception { - final TargetFilterQuery tfq = createTargetFilterQueryWithDS(createDistributionSet()); - this.mockMvc - .perform(delete( - MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/{targetFilterQueryId}/autoAssignDS", - tfq.getId())) - .andExpect(status().isNoContent()).andDo(MockMvcResultPrinter.print()) - .andDo(this.document.document(pathParameters( - parameterWithName("targetFilterQueryId").description(ApiModelPropertiesGeneric.ITEM_ID)))); - } - - private Snippet getResponseFieldTargetFilterQuery(final boolean isArray) { - final String arrayPrefix = getArrayPrefix(isArray); - return responseFields(fieldWithPath(arrayPrefix + "id").description(ApiModelPropertiesGeneric.ITEM_ID), - fieldWithPath(arrayPrefix + "name").description(ApiModelPropertiesGeneric.NAME), - fieldWithPath(arrayPrefix + "query").description(MgmtApiModelProperties.TARGET_FILTER_QUERY), - fieldWithPath(arrayPrefix + "autoAssignDistributionSet") - .description(MgmtApiModelProperties.TARGET_FILTER_QUERY_AUTO_ASSIGN_DS_ID) - .type(JsonFieldType.NUMBER.toString()), - fieldWithPath(arrayPrefix + "autoAssignActionType") - .description(MgmtApiModelProperties.ACTION_FORCE_TYPE).type(JsonFieldType.STRING.toString()) - .attributes(key("value").value("['forced', 'soft', 'downloadonly']")), - fieldWithPath(arrayPrefix + "autoAssignWeight") - .description(MgmtApiModelProperties.RESULTING_ACTIONS_WEIGHT) - .type(JsonFieldType.NUMBER.toString()), - fieldWithPath(arrayPrefix + "confirmationRequired") - .description(MgmtApiModelProperties.ACTION_CONFIRMATION_REQUIRED) - .type(JsonFieldType.BOOLEAN.toString()), - fieldWithPath(arrayPrefix + "createdAt").description(ApiModelPropertiesGeneric.CREATED_AT), - fieldWithPath(arrayPrefix + "createdBy").description(ApiModelPropertiesGeneric.CREATED_BY), - fieldWithPath(arrayPrefix + "lastModifiedAt").description(ApiModelPropertiesGeneric.LAST_MODIFIED_AT), - fieldWithPath(arrayPrefix + "lastModifiedBy").description(ApiModelPropertiesGeneric.LAST_MODIFIED_BY), - fieldWithPath(arrayPrefix + "_links.self").ignored(), fieldWithPath(arrayPrefix + "_links.autoAssignDS") - .description(MgmtApiModelProperties.TARGET_FILTER_QUERY_LINK_AUTO_ASSIGN_DS), - optionalRequestFieldWithPath(arrayPrefix + "_links.DS").ignored()); - } - - private String createTargetFilterQueryJson(final String name, final String query) - throws JsonProcessingException { - final Map target = new HashMap<>(); - target.put("name", name); - target.put("query", query); - return objectMapper.writeValueAsString(target); - } - - private TargetFilterQuery createTargetFilterQuery() { - return targetFilterQueryManagement - .create(entityFactory.targetFilterQuery().create().name(EXAMPLE_TFQ_NAME).query(EXAMPLE_TFQ_QUERY)); - } - - private TargetFilterQuery createTargetFilterQueryWithDS(final DistributionSet distributionSet) { - final TargetFilterQuery targetFilterQuery = createTargetFilterQuery(); - return targetFilterQueryManagement.updateAutoAssignDS(entityFactory.targetFilterQuery() - .updateAutoAssign(targetFilterQuery.getId()).ds(distributionSet.getId())); - } -} diff --git a/hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/mgmt/documentation/TargetResourceDocumentationTest.java b/hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/mgmt/documentation/TargetResourceDocumentationTest.java deleted file mode 100644 index 75766c3149..0000000000 --- a/hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/mgmt/documentation/TargetResourceDocumentationTest.java +++ /dev/null @@ -1,1042 +0,0 @@ -/** - * Copyright (c) 2018 Bosch Software Innovations GmbH and others - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - */ -package org.eclipse.hawkbit.rest.mgmt.documentation; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.TARGET_V1_ACTIVATE_AUTO_CONFIRM; -import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.TARGET_V1_AUTO_CONFIRM; -import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.TARGET_V1_DEACTIVATE_AUTO_CONFIRM; -import static org.hamcrest.CoreMatchers.equalTo; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.delete; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.post; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.put; -import static org.springframework.restdocs.payload.PayloadDocumentation.requestFields; -import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields; -import static org.springframework.restdocs.request.RequestDocumentation.parameterWithName; -import static org.springframework.restdocs.request.RequestDocumentation.pathParameters; -import static org.springframework.restdocs.request.RequestDocumentation.requestParameters; -import static org.springframework.restdocs.snippet.Attributes.key; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.eclipse.hawkbit.im.authentication.SpPermission; -import org.eclipse.hawkbit.mgmt.json.model.target.MgmtTargetAutoConfirmUpdate; -import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants; -import org.eclipse.hawkbit.repository.ActionStatusFields; -import org.eclipse.hawkbit.repository.model.Action; -import org.eclipse.hawkbit.repository.model.Action.ActionType; -import org.eclipse.hawkbit.repository.model.DistributionSet; -import org.eclipse.hawkbit.repository.model.DistributionSetType; -import org.eclipse.hawkbit.repository.model.Target; -import org.eclipse.hawkbit.repository.model.TargetType; -import org.eclipse.hawkbit.rest.documentation.AbstractApiRestDocumentation; -import org.eclipse.hawkbit.rest.documentation.ApiModelPropertiesGeneric; -import org.eclipse.hawkbit.rest.documentation.MgmtApiModelProperties; -import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter; -import org.json.JSONArray; -import org.json.JSONObject; -import org.junit.jupiter.api.Test; -import org.springframework.data.domain.PageRequest; -import org.springframework.data.domain.Sort.Direction; -import org.springframework.hateoas.MediaTypes; -import org.springframework.http.MediaType; -import org.springframework.restdocs.payload.FieldDescriptor; -import org.springframework.restdocs.payload.JsonFieldType; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.google.common.collect.Lists; - -import io.qameta.allure.Description; -import io.qameta.allure.Feature; -import io.qameta.allure.Story; - -/** - * Documentation generation for Management API for {@link Target}. - * - */ -@Feature("Spring Rest Docs Tests - Target") -@Story("Target Resource") -public class TargetResourceDocumentationTest extends AbstractApiRestDocumentation { - - private final String targetId = "137"; - - @Override - public String getResourceName() { - return "targets"; - } - - @Test - @Description("Handles the GET request of retrieving all targets within SP. Required Permission: READ_TARGET.") - public void getTargets() throws Exception { - enableConfirmationFlow(); - - createTargetByGivenNameWithAttributes(targetId, createDistributionSet()); - - mockMvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING)).andExpect(status().isOk()) - .andDo(MockMvcResultPrinter.print()) - .andDo(this.document.document(responseFields( - fieldWithPath("size").type(JsonFieldType.NUMBER).description(ApiModelPropertiesGeneric.SIZE), - fieldWithPath("total").description(ApiModelPropertiesGeneric.TOTAL_ELEMENTS), - fieldWithPath("content").description(MgmtApiModelProperties.TARGET_LIST), - fieldWithPath("content[].createdBy").description(ApiModelPropertiesGeneric.CREATED_BY), - fieldWithPath("content[].address").description(MgmtApiModelProperties.ADDRESS), - fieldWithPath("content[].createdAt").description(ApiModelPropertiesGeneric.CREATED_AT), - fieldWithPath("content[].name").description(ApiModelPropertiesGeneric.NAME), - fieldWithPath("content[].description").description(ApiModelPropertiesGeneric.DESCRPTION), - fieldWithPath("content[].controllerId").description(ApiModelPropertiesGeneric.ITEM_ID), - fieldWithPath("content[].updateStatus").description(MgmtApiModelProperties.UPDATE_STATUS) - .type("enum").attributes( - key("value").value("['error', 'in_sync', 'pending', 'registered', 'unknown']")), - fieldWithPath("content[].securityToken").description(MgmtApiModelProperties.SECURITY_TOKEN), - fieldWithPath("content[].requestAttributes") - .description(MgmtApiModelProperties.REQUEST_ATTRIBUTES), - fieldWithPath("content[].autoConfirmActive") - .description(MgmtApiModelProperties.AUTO_CONFIRM_ACTIVE), - fieldWithPath("content[].installedAt").description(MgmtApiModelProperties.INSTALLED_AT), - fieldWithPath("content[].lastModifiedAt") - .description(ApiModelPropertiesGeneric.LAST_MODIFIED_AT).type("Number"), - fieldWithPath("content[].lastModifiedBy") - .description(ApiModelPropertiesGeneric.LAST_MODIFIED_BY).type("String"), - fieldWithPath("content[].ipAddress").description(MgmtApiModelProperties.IP_ADDRESS) - .type("String"), - fieldWithPath("content[].lastControllerRequestAt") - .description(MgmtApiModelProperties.LAST_REQUEST_AT).type("Number"), - fieldWithPath("content[].targetType").description(MgmtApiModelProperties.TARGETTYPE_ID) - .type("Number"), - fieldWithPath("content[].targetTypeName").description(MgmtApiModelProperties.TARGETTYPE_NAME) - .type("String"), - fieldWithPath("content[]._links.self").ignored()))); - } - - @Test - @Description("Handles the GET request of retrieving all targets within SP based by parameter. Required Permission: READ_TARGET.") - public void getTargetsWithParameters() throws Exception { - mockMvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "?limit=10&sort=name:ASC&offset=0&q=name==a")) - .andExpect(status().isOk()).andDo(MockMvcResultPrinter.print()) - .andDo(this.document.document(getFilterRequestParamter())); - } - - @Test - @Description("Handles the POST request of creating new targets within SP. The request body must always be a list of targets. Required Permission: CREATE_TARGET.") - public void postTargets() throws Exception { - enableConfirmationFlow(); - - final TargetType defaultType = testdataFactory.createTargetType("defaultType", Collections.emptyList()); - final String target = createTargetJsonForPostRequest("123456", "controllerId", "test", defaultType); - - mockMvc.perform(post(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING) - .contentType(MediaType.APPLICATION_JSON).content(target)).andExpect(status().isCreated()) - .andDo(MockMvcResultPrinter.print()) - .andDo(this.document.document(requestFields( - requestFieldWithPath("[]controllerId").description(ApiModelPropertiesGeneric.ITEM_ID), - requestFieldWithPath("[]name").description(ApiModelPropertiesGeneric.NAME), - optionalRequestFieldWithPath("[]description").description(ApiModelPropertiesGeneric.DESCRPTION), - optionalRequestFieldWithPath("[]address").description(MgmtApiModelProperties.ADDRESS), - optionalRequestFieldWithPath("[]securityToken") - .description(MgmtApiModelProperties.SECURITY_TOKEN), - optionalRequestFieldWithPath("[]targetType").description(MgmtApiModelProperties.TARGETTYPE_ID)), - responseFields(fieldWithPath("[]controllerId").description(ApiModelPropertiesGeneric.ITEM_ID), - fieldWithPath("[]name").description(ApiModelPropertiesGeneric.NAME), - fieldWithPath("[]description").description(ApiModelPropertiesGeneric.DESCRPTION), - fieldWithPath("[]address").description(MgmtApiModelProperties.ADDRESS), - fieldWithPath("[]createdBy").description(ApiModelPropertiesGeneric.CREATED_BY), - fieldWithPath("[]lastModifiedBy") - .description(ApiModelPropertiesGeneric.LAST_MODIFIED_BY), - fieldWithPath("[]lastModifiedAt") - .description(ApiModelPropertiesGeneric.LAST_MODIFIED_AT), - fieldWithPath("[]ipAddress").description(MgmtApiModelProperties.IP_ADDRESS), - fieldWithPath("[]createdAt").description(ApiModelPropertiesGeneric.CREATED_AT), - fieldWithPath("[]updateStatus").description(MgmtApiModelProperties.UPDATE_STATUS) - .type("enum") - .attributes(key("value") - .value("['error', 'in_sync', 'pending', 'registered', 'unknown']")), - fieldWithPath("[]securityToken").description(MgmtApiModelProperties.SECURITY_TOKEN), - fieldWithPath("[]requestAttributes") - .description(MgmtApiModelProperties.REQUEST_ATTRIBUTES), - fieldWithPath("[]autoConfirmActive") - .description(MgmtApiModelProperties.AUTO_CONFIRM_ACTIVE), - fieldWithPath("[]targetType").description(MgmtApiModelProperties.TARGETTYPE_ID), - fieldWithPath("[]targetTypeName").description(MgmtApiModelProperties.TARGETTYPE_NAME), - fieldWithPath("[]_links.self").ignored()))); - } - - @Test - @Description("Handles the DELETE request of deleting a single target within SP. Required Permission: DELETE_TARGET.") - public void deleteTarget() throws Exception { - final Target target = testdataFactory.createTarget(targetId); - - mockMvc.perform(delete(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}", target.getControllerId())) - .andExpect(status().isOk()).andDo(MockMvcResultPrinter.print()).andDo(this.document.document( - pathParameters(parameterWithName("targetId").description(ApiModelPropertiesGeneric.ITEM_ID)))); - } - - @Test - @Description("Handles the GET request of retrieving a single target within SP. Required Permission: READ_TARGET.") - public void getTarget() throws Exception { - enableConfirmationFlow(); - - final Target target = createTargetByGivenNameWithAttributes(targetId, createDistributionSet()); - - mockMvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}", target.getControllerId())) - .andExpect(status().isOk()).andDo(MockMvcResultPrinter.print()) - .andDo(this.document.document( - pathParameters(parameterWithName("targetId").description(ApiModelPropertiesGeneric.ITEM_ID)), - getResponseFieldTarget(false))); - } - - @Test - @Description("Handles the PUT request of updating a target within SP. Required Permission: UPDATE_TARGET.") - public void putTarget() throws Exception { - enableConfirmationFlow(); - - final Target target = createTargetByGivenNameWithAttributes(targetId, createDistributionSet()); - final long targetTypeId = target.getTargetType().getId(); - - final String targetAsJson = createJsonTarget(targetId, "newTargetName", "I've been updated", targetTypeId); - - mockMvc.perform(put(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}", target.getControllerId()) - .contentType(MediaType.APPLICATION_JSON).content(targetAsJson)).andExpect(status().isOk()) - .andDo(MockMvcResultPrinter.print()) - .andDo(this.document.document( - pathParameters(parameterWithName("targetId").description(ApiModelPropertiesGeneric.ITEM_ID)), - requestFields(optionalRequestFieldWithPath("name").description(ApiModelPropertiesGeneric.NAME), - optionalRequestFieldWithPath("description") - .description(ApiModelPropertiesGeneric.DESCRPTION), - optionalRequestFieldWithPath("controllerId") - .description(ApiModelPropertiesGeneric.ITEM_ID), - optionalRequestFieldWithPath("address").description(MgmtApiModelProperties.ADDRESS), - optionalRequestFieldWithPath("securityToken") - .description(MgmtApiModelProperties.SECURITY_TOKEN), - optionalRequestFieldWithPath("requestAttributes") - .description(MgmtApiModelProperties.REQUEST_ATTRIBUTES), - optionalRequestFieldWithPath("targetType").description(MgmtApiModelProperties.TARGETTYPE_ID - + ". If value of -1 provided the target type will be unassigned.")), - getResponseFieldTarget(false))); - } - - @Test - @Description("Handles the GET request of retrieving the full action history of a specific target. Required Permission: READ_TARGET.") - public void getActionsFromTarget() throws Exception { - enableMultiAssignments(); - generateRolloutActionForTarget(targetId); - - mockMvc.perform( - get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/" + MgmtRestConstants.TARGET_V1_ACTIONS, - targetId)) - .andExpect(status().isOk()).andDo(MockMvcResultPrinter.print()) - .andDo(this.document.document( - pathParameters(parameterWithName("targetId").description(ApiModelPropertiesGeneric.ITEM_ID)), - responseFields( - fieldWithPath("size").type(JsonFieldType.NUMBER) - .description(ApiModelPropertiesGeneric.SIZE), - fieldWithPath("total").description(ApiModelPropertiesGeneric.TOTAL_ELEMENTS), - fieldWithPath("content[]").description(MgmtApiModelProperties.ACTION_LIST), - fieldWithPath("content[].createdBy").description(ApiModelPropertiesGeneric.CREATED_BY), - fieldWithPath("content[].createdAt").description(ApiModelPropertiesGeneric.CREATED_AT), - fieldWithPath("content[].lastModifiedBy") - .description(ApiModelPropertiesGeneric.LAST_MODIFIED_BY).type("String"), - fieldWithPath("content[].lastModifiedAt") - .description(ApiModelPropertiesGeneric.LAST_MODIFIED_AT).type("String"), - fieldWithPath("content[].type").description(MgmtApiModelProperties.ACTION_TYPE) - .attributes(key("value").value("['update', 'cancel']")), - - fieldWithPath("content[].status") - .description(MgmtApiModelProperties.ACTION_EXECUTION_STATUS) - .attributes(key("value").value("['finished', 'pending']")), - fieldWithPath("content[].detailStatus") - .description(MgmtApiModelProperties.ACTION_DETAIL_STATUS) - .attributes(key("value").value( - "['finished', 'error', 'running', 'warning', 'scheduled', 'canceling', 'canceled', 'download', 'downloaded', 'retrieved', 'cancel_rejected']")), - fieldWithPath("content[]._links").description(MgmtApiModelProperties.LINK_TO_ACTION), - fieldWithPath("content[].id").description(MgmtApiModelProperties.ACTION_ID), - fieldWithPath("content[].weight").description(MgmtApiModelProperties.ACTION_WEIGHT), - fieldWithPath("content[].rollout").description(MgmtApiModelProperties.ACTION_ROLLOUT), - fieldWithPath("content[].rolloutName") - .description(MgmtApiModelProperties.ACTION_ROLLOUT_NAME)))); - } - - @Test - @Description("Handles the GET request of retrieving the full action history of a specific target with maintenance window. Required Permission: READ_TARGET.") - public void getActionsFromTargetWithMaintenanceWindow() throws Exception { - enableMultiAssignments(); - generateActionForTarget(targetId, true, false, getTestSchedule(2), getTestDuration(1), getTestTimeZone()); - - mockMvc.perform( - get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/" + MgmtRestConstants.TARGET_V1_ACTIONS, - targetId)) - .andExpect(status().isOk()).andDo(MockMvcResultPrinter.print()) - .andDo(this.document.document( - pathParameters(parameterWithName("targetId").description(ApiModelPropertiesGeneric.ITEM_ID)), - responseFields( - fieldWithPath("size").type(JsonFieldType.NUMBER) - .description(ApiModelPropertiesGeneric.SIZE), - fieldWithPath("total").description(ApiModelPropertiesGeneric.TOTAL_ELEMENTS), - fieldWithPath("content[]").description(MgmtApiModelProperties.ACTION_LIST), - fieldWithPath("content[].createdBy").description(ApiModelPropertiesGeneric.CREATED_BY), - fieldWithPath("content[].createdAt").description(ApiModelPropertiesGeneric.CREATED_AT), - fieldWithPath("content[].lastModifiedBy") - .description(ApiModelPropertiesGeneric.LAST_MODIFIED_BY).type("String"), - fieldWithPath("content[].lastModifiedAt") - .description(ApiModelPropertiesGeneric.LAST_MODIFIED_AT).type("String"), - fieldWithPath("content[].type").description(MgmtApiModelProperties.ACTION_TYPE) - .attributes(key("value").value("['update', 'cancel']")), - fieldWithPath("content[].status") - .description(MgmtApiModelProperties.ACTION_EXECUTION_STATUS) - .attributes(key("value").value("['finished', 'pending']")), - fieldWithPath("content[].detailStatus") - .description(MgmtApiModelProperties.ACTION_DETAIL_STATUS) - .attributes(key("value").value( - "['finished', 'error', 'running', 'warning', 'scheduled', 'canceling', 'canceled', 'download', 'downloaded', 'retrieved', 'cancel_rejected']")), - fieldWithPath("content[]._links.self") - .description(MgmtApiModelProperties.LINK_TO_ACTION), - fieldWithPath("content[].id").description(MgmtApiModelProperties.ACTION_ID), - fieldWithPath("content[].weight").description(MgmtApiModelProperties.ACTION_WEIGHT), - fieldWithPath("content[].maintenanceWindow") - .description(MgmtApiModelProperties.MAINTENANCE_WINDOW), - fieldWithPath("content[].maintenanceWindow.schedule") - .description(MgmtApiModelProperties.MAINTENANCE_WINDOW_SCHEDULE), - fieldWithPath("content[].maintenanceWindow.duration") - .description(MgmtApiModelProperties.MAINTENANCE_WINDOW_DURATION), - fieldWithPath("content[].maintenanceWindow.timezone") - .description(MgmtApiModelProperties.MAINTENANCE_WINDOW_TIMEZONE), - fieldWithPath("content[].maintenanceWindow.nextStartAt") - .description(MgmtApiModelProperties.MAINTENANCE_WINDOW_NEXT_START_AT)))); - } - - @Test - @Description("Handles the GET request of retrieving all targets within SP based by parameter. Required Permission: READ_TARGET.") - public void getActionsFromTargetWithParameters() throws Exception { - generateActionForTarget(targetId); - - mockMvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + targetId + "/" - + MgmtRestConstants.TARGET_V1_ACTIONS + "?limit=10&sort=id:ASC&offset=0&q=status==pending")) - .andExpect(status().isOk()).andDo(MockMvcResultPrinter.print()) - .andDo(this.document.document(requestParameters( - parameterWithName("limit").attributes(key("type").value("query")) - .description(ApiModelPropertiesGeneric.LIMIT), - parameterWithName("sort").description(ApiModelPropertiesGeneric.SORT), - parameterWithName("offset").description(ApiModelPropertiesGeneric.OFFSET), - parameterWithName("q").description(ApiModelPropertiesGeneric.FIQL)))); - } - - @Test - @Description("Cancels an active action, only active actions can be deleted. Required Permission: UPDATE_TARGET.") - public void deleteActionFromTarget() throws Exception { - final Action actions = generateActionForTarget(targetId, false); - - mockMvc.perform(delete(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/" - + MgmtRestConstants.TARGET_V1_ACTIONS + "/{actionId}", targetId, actions.getId())) - .andExpect(status().isNoContent()).andDo(MockMvcResultPrinter.print()) - .andDo(this.document.document( - pathParameters(parameterWithName("targetId").description(ApiModelPropertiesGeneric.ITEM_ID), - parameterWithName("actionId").description(ApiModelPropertiesGeneric.ITEM_ID)))); - } - - @Test - @Description("Optionally force quits an active action, only active actions can be deleted. Required Permission: UPDATE_TARGET.") - public void deleteActionFromTargetWithParameters() throws Exception { - final Action action = generateActionForTarget(targetId, false); - deploymentManagement.cancelAction(action.getId()); - - mockMvc.perform(delete(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/" - + MgmtRestConstants.TARGET_V1_ACTIONS + "/{actionId}?force=true", targetId, action.getId())) - .andExpect(status().isNoContent()).andDo(MockMvcResultPrinter.print()) - .andDo(this.document.document( - pathParameters(parameterWithName("targetId").description(ApiModelPropertiesGeneric.ITEM_ID), - parameterWithName("actionId").description(ApiModelPropertiesGeneric.ITEM_ID)), - requestParameters(parameterWithName("force").description(MgmtApiModelProperties.FORCE)))); - } - - @Test - @Description("Handles the GET request of retrieving a specific action on a specific target. Required Permission: READ_TARGET.") - public void getActionFromTarget() throws Exception { - enableMultiAssignments(); - final Action action = generateRolloutActionForTarget(targetId, true, true); - provideCodeFeedback(action, 200); - - assertThat(deploymentManagement.findAction(action.getId()).get().getActionType()) - .isEqualTo(ActionType.TIMEFORCED); - - mockMvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/" - + MgmtRestConstants.TARGET_V1_ACTIONS + "/{actionId}", targetId, action.getId())) - .andExpect(status().isOk()).andDo(MockMvcResultPrinter.print()) - .andDo(this.document.document( - pathParameters(parameterWithName("targetId").description(ApiModelPropertiesGeneric.ITEM_ID), - parameterWithName("actionId").description(ApiModelPropertiesGeneric.ITEM_ID)), - responseFields(fieldWithPath("createdBy").description(ApiModelPropertiesGeneric.CREATED_BY), - fieldWithPath("createdAt").description(ApiModelPropertiesGeneric.CREATED_AT), - fieldWithPath("id").description(MgmtApiModelProperties.ACTION_ID), - fieldWithPath("weight").description(MgmtApiModelProperties.ACTION_WEIGHT), - fieldWithPath("lastModifiedBy").description(ApiModelPropertiesGeneric.LAST_MODIFIED_BY) - .type("String"), - fieldWithPath("lastModifiedAt").description(ApiModelPropertiesGeneric.LAST_MODIFIED_AT) - .type("String"), - fieldWithPath("type").description(MgmtApiModelProperties.ACTION_TYPE) - .attributes(key("value").value("['update', 'cancel']")), - fieldWithPath("forceType").description(MgmtApiModelProperties.ACTION_FORCE_TYPE) - .attributes(key("value").value("['forced', 'soft', 'timeforced']")), - fieldWithPath("forceTime").description(MgmtApiModelProperties.ACTION_FORCE_TIME) - .type("String"), - fieldWithPath("status").description(MgmtApiModelProperties.ACTION_EXECUTION_STATUS) - .attributes(key("value").value("['finished', 'pending']")), - fieldWithPath("detailStatus").description(MgmtApiModelProperties.ACTION_DETAIL_STATUS) - .attributes(key("value").value( - "['finished', 'error', 'running', 'warning', 'scheduled', 'canceling', 'canceled', 'download', 'downloaded', 'retrieved', 'cancel_rejected']")), - optionalRequestFieldWithPath("lastStatusCode") - .description(MgmtApiModelProperties.ACTION_LAST_STATUS_CODE).type("Integer"), - fieldWithPath("rollout").description(MgmtApiModelProperties.ACTION_ROLLOUT), - fieldWithPath("rolloutName").description(MgmtApiModelProperties.ACTION_ROLLOUT_NAME), - fieldWithPath("_links.self").ignored(), - fieldWithPath("_links.distributionset").description(MgmtApiModelProperties.LINK_TO_DS), - fieldWithPath("_links.status") - .description(MgmtApiModelProperties.LINKS_ACTION_STATUSES), - fieldWithPath("_links.rollout").description(MgmtApiModelProperties.LINK_TO_ROLLOUT), - fieldWithPath("_links.target").description(MgmtApiModelProperties.LINK_TO_TARGET)))); - } - - @Test - @Description("Handles the GET request of retrieving a specific action on a specific target. Required Permission: READ_TARGET.") - public void getActionFromTargetWithMaintenanceWindow() throws Exception { - enableMultiAssignments(); - final Action action = generateActionForTarget(targetId, true, true, getTestSchedule(2), getTestDuration(1), - getTestTimeZone()); - provideCodeFeedback(action, 200); - - mockMvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/" - + MgmtRestConstants.TARGET_V1_ACTIONS + "/{actionId}", targetId, action.getId())) - .andExpect(status().isOk()).andDo(MockMvcResultPrinter.print()) - .andDo(this.document.document( - pathParameters(parameterWithName("targetId").description(ApiModelPropertiesGeneric.ITEM_ID), - parameterWithName("actionId").description(ApiModelPropertiesGeneric.ITEM_ID)), - responseFields(fieldWithPath("createdBy").description(ApiModelPropertiesGeneric.CREATED_BY), - fieldWithPath("createdAt").description(ApiModelPropertiesGeneric.CREATED_AT), - fieldWithPath("id").description(MgmtApiModelProperties.ACTION_ID), - fieldWithPath("weight").description(MgmtApiModelProperties.ACTION_WEIGHT), - fieldWithPath("lastModifiedBy").description(ApiModelPropertiesGeneric.LAST_MODIFIED_BY) - .type("String"), - fieldWithPath("lastModifiedAt").description(ApiModelPropertiesGeneric.LAST_MODIFIED_AT) - .type("String"), - fieldWithPath("type").description(MgmtApiModelProperties.ACTION_TYPE) - .attributes(key("value").value("['update', 'cancel']")), - fieldWithPath("forceType").description(MgmtApiModelProperties.ACTION_FORCE_TYPE) - .attributes(key("value").value("['forced', 'soft', 'timeforced']")), - fieldWithPath("forceTime").description(MgmtApiModelProperties.ACTION_FORCE_TIME) - .type("String"), - fieldWithPath("status").description(MgmtApiModelProperties.ACTION_EXECUTION_STATUS) - .attributes(key("value").value("['finished', 'pending']")), - fieldWithPath("detailStatus").description(MgmtApiModelProperties.ACTION_DETAIL_STATUS) - .attributes(key("value").value( - "['finished', 'error', 'running', 'warning', 'scheduled', 'canceling', 'canceled', 'download', 'downloaded', 'retrieved', 'cancel_rejected']")), - optionalRequestFieldWithPath("lastStatusCode") - .description(MgmtApiModelProperties.ACTION_LAST_STATUS_CODE).type("Integer"), - fieldWithPath("maintenanceWindow") - .description(MgmtApiModelProperties.MAINTENANCE_WINDOW), - fieldWithPath("maintenanceWindow.schedule") - .description(MgmtApiModelProperties.MAINTENANCE_WINDOW_SCHEDULE), - fieldWithPath("maintenanceWindow.duration") - .description(MgmtApiModelProperties.MAINTENANCE_WINDOW_DURATION), - fieldWithPath("maintenanceWindow.timezone") - .description(MgmtApiModelProperties.MAINTENANCE_WINDOW_TIMEZONE), - fieldWithPath("maintenanceWindow.nextStartAt") - .description(MgmtApiModelProperties.MAINTENANCE_WINDOW_NEXT_START_AT), - fieldWithPath("_links.self").ignored(), - fieldWithPath("_links.distributionset").description(MgmtApiModelProperties.LINK_TO_DS), - fieldWithPath("_links.status") - .description(MgmtApiModelProperties.LINKS_ACTION_STATUSES), - fieldWithPath("_links.target").description(MgmtApiModelProperties.LINK_TO_TARGET)))); - } - - @Test - @Description("Handles the PUT request to switch an action from soft to forced. Required Permission: UPDATE_TARGET.") - public void switchActionToForced() throws Exception { - final Target target = testdataFactory.createTarget(targetId); - final DistributionSet set = testdataFactory.createDistributionSet(); - final Long actionId = getFirstAssignedActionId( - assignDistributionSet(set.getId(), target.getControllerId(), ActionType.SOFT)); - assertThat(deploymentManagement.findAction(actionId).get().getActionType()).isEqualTo(ActionType.SOFT); - - final Map body = new HashMap<>(); - body.put("forceType", "forced"); - - mockMvc.perform(put(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/" - + MgmtRestConstants.TARGET_V1_ACTIONS + "/{actionId}", targetId, actionId) - .content(this.objectMapper.writeValueAsString(body)).contentType(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andDo(this.document.document( - pathParameters(parameterWithName("targetId").description(ApiModelPropertiesGeneric.ITEM_ID), - parameterWithName("actionId").description(ApiModelPropertiesGeneric.ITEM_ID)), - requestFields( - requestFieldWithPath("forceType").description(MgmtApiModelProperties.ACTION_FORCED)), - responseFields(fieldWithPath("createdBy").description(ApiModelPropertiesGeneric.CREATED_BY), - fieldWithPath("createdAt").description(ApiModelPropertiesGeneric.CREATED_AT), - fieldWithPath("id").description(MgmtApiModelProperties.ACTION_ID), - fieldWithPath("lastModifiedBy").description(ApiModelPropertiesGeneric.LAST_MODIFIED_BY) - .type("String"), - fieldWithPath("lastModifiedAt").description(ApiModelPropertiesGeneric.LAST_MODIFIED_AT) - .type("String"), - fieldWithPath("type").description(MgmtApiModelProperties.ACTION_TYPE) - .attributes(key("value").value("['update', 'cancel']")), - fieldWithPath("forceType").description(MgmtApiModelProperties.ACTION_FORCE_TYPE) - .attributes(key("value").value("['forced', 'soft', 'timeforced']")), - fieldWithPath("status").description(MgmtApiModelProperties.ACTION_EXECUTION_STATUS) - .attributes(key("value").value("['finished', 'pending']")), - fieldWithPath("detailStatus").description(MgmtApiModelProperties.ACTION_DETAIL_STATUS) - .attributes(key("value").value( - "['finished', 'error', 'running', 'warning', 'scheduled', 'canceling', 'canceled', 'download', 'downloaded', 'retrieved', 'cancel_rejected']")), - fieldWithPath("_links.self").ignored(), - fieldWithPath("_links.distributionset").description(MgmtApiModelProperties.LINK_TO_DS), - fieldWithPath("_links.status") - .description(MgmtApiModelProperties.LINKS_ACTION_STATUSES), - fieldWithPath("_links.target").description(MgmtApiModelProperties.LINK_TO_TARGET)))); - } - - @Test - @Description("Handles the GET request of retrieving a specific action on a specific target. Required Permission: READ_TARGET.") - public void getStatusFromAction() throws Exception { - final Action action = generateActionForTarget(targetId, false); - provideCodeFeedback(action, 200); - - mockMvc.perform( - get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/" + MgmtRestConstants.TARGET_V1_ACTIONS - + "/{actionId}/" + MgmtRestConstants.TARGET_V1_ACTION_STATUS, targetId, action.getId())) - .andExpect(status().isOk()).andDo(MockMvcResultPrinter.print()) - .andDo(this.document.document( - pathParameters(parameterWithName("targetId").description(ApiModelPropertiesGeneric.ITEM_ID), - parameterWithName("actionId").description(ApiModelPropertiesGeneric.ITEM_ID)), - responseFields( - fieldWithPath("size").type(JsonFieldType.NUMBER) - .description(ApiModelPropertiesGeneric.SIZE), - fieldWithPath("total").description(ApiModelPropertiesGeneric.TOTAL_ELEMENTS), - fieldWithPath("content[]").description(MgmtApiModelProperties.ACTION_STATUS_LIST), - fieldWithPath("content[].id").description(ApiModelPropertiesGeneric.ITEM_ID), - fieldWithPath("content[].messages") - .description(MgmtApiModelProperties.ACTION_STATUS_MESSAGES).type("String"), - fieldWithPath("content[].reportedAt") - .description(MgmtApiModelProperties.ACTION_STATUS_REPORTED_AT).type("String"), - optionalRequestFieldWithPath("content[].code") - .description(MgmtApiModelProperties.ACTION_STATUS_CODE).type("Integer"), - fieldWithPath("content[].type").description(MgmtApiModelProperties.ACTION_STATUS_TYPE) - .attributes(key("value").value( - "['finished', 'error', 'warning', 'running', 'canceled', 'canceling', " // - + "'retrieved', 'download', 'scheduled', 'cancel_rejected', " // - + "'downloaded', 'wait_for_confirmation']"))))); - } - - @Test - @Description("Handles the GET request of retrieving all targets within SP based by parameter. Required Permission: READ_TARGET.") - public void getStatusFromActionWithParameters() throws Exception { - final Action action = generateActionForTarget(targetId); - - mockMvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + targetId + "/" - + MgmtRestConstants.TARGET_V1_ACTIONS + "/" + action.getId() + "/" - + MgmtRestConstants.TARGET_V1_ACTION_STATUS + "?limit=10&sort=id:ASC&offset=0")) - .andExpect(status().isOk()).andDo(MockMvcResultPrinter.print()) - .andDo(this.document.document( - requestParameters(parameterWithName("limit").description(ApiModelPropertiesGeneric.LIMIT), - parameterWithName("sort").description(ApiModelPropertiesGeneric.SORT), - parameterWithName("offset").description(ApiModelPropertiesGeneric.OFFSET)))); - } - - @Test - @Description("Handles the GET request of retrieving the assigned distribution set of an specific target. Required Permission: READ_TARGET.") - public void getAssignedDistributionSetFromAction() throws Exception { - generateActionForTarget(targetId); - - mockMvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/" - + MgmtRestConstants.TARGET_V1_ASSIGNED_DISTRIBUTION_SET, targetId)).andExpect(status().isOk()) - .andDo(MockMvcResultPrinter.print()) - .andDo(this.document.document( - pathParameters(parameterWithName("targetId").description(ApiModelPropertiesGeneric.ITEM_ID)), - getResponseFieldsDistributionSet(false))); - } - - @Test - @Description("Handles the POST request for assigning a distribution set to a specific target. Required Permission: READ_REPOSITORY and UPDATE_TARGET.") - public void postAssignDistributionSetToTarget() throws Exception { - // create target and ds, and assign ds - testdataFactory.createTarget(targetId + "-old"); - final DistributionSet set = testdataFactory.createDistributionSet("one"); - assignDistributionSet(set.getId(), targetId + "-old"); - - testdataFactory.createTarget(targetId); - - final long forceTime = System.currentTimeMillis(); - final String body = new JSONObject().put("id", set.getId()).put("type", "timeforced") - .put("forcetime", forceTime) - .put("maintenanceWindow", new JSONObject().put("schedule", getTestSchedule(100)) - .put("duration", getTestDuration(10)).put("timezone", getTestTimeZone())) - .toString(); - - mockMvc.perform(post(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/" - + MgmtRestConstants.TARGET_V1_ASSIGNED_DISTRIBUTION_SET, targetId).content(body) - .contentType(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andDo(this.document.document( - pathParameters(parameterWithName("targetId").description(ApiModelPropertiesGeneric.ITEM_ID)), - requestParameters(parameterWithName("offline") - .description(MgmtApiModelProperties.OFFLINE_UPDATE).optional()), - requestFields(requestFieldWithPath("id").description(ApiModelPropertiesGeneric.ITEM_ID), - requestFieldWithPathMandatoryInMultiAssignMode("weight") - .description(MgmtApiModelProperties.ASSIGNMENT_WEIGHT) - .type(JsonFieldType.NUMBER).attributes(key("value").value("0 - 1000")), - optionalRequestFieldWithPath("forcetime").description(MgmtApiModelProperties.FORCETIME), - optionalRequestFieldWithPath("[].confirmationRequired") - .description(MgmtApiModelProperties.ASSIGNMENT_CONFIRMATION_REQUIRED) - .type(JsonFieldType.BOOLEAN.toString()), - optionalRequestFieldWithPath("maintenanceWindow") - .description(MgmtApiModelProperties.MAINTENANCE_WINDOW), - optionalRequestFieldWithPath("maintenanceWindow.schedule") - .description(MgmtApiModelProperties.MAINTENANCE_WINDOW_SCHEDULE), - optionalRequestFieldWithPath("maintenanceWindow.duration") - .description(MgmtApiModelProperties.MAINTENANCE_WINDOW_DURATION), - optionalRequestFieldWithPath("maintenanceWindow.timezone") - .description(MgmtApiModelProperties.MAINTENANCE_WINDOW_TIMEZONE), - optionalRequestFieldWithPath("type").description(MgmtApiModelProperties.ASSIGNMENT_TYPE) - .attributes( - key("value").value("['soft', 'forced','timeforced', 'downloadonly']"))), - responseFields(getDsAssignmentResponseFieldDescriptors()))); - } - - @Test - @Description("Handles the POST request for assigning distribution sets to a specific target. Required Permission: READ_REPOSITORY and UPDATE_TARGET.") - public void postAssignDistributionSetsToTarget() throws Exception { - // create target and ds, and assign ds - final List sets = testdataFactory.createDistributionSets(2); - testdataFactory.createTarget(targetId); - - final long forceTime = System.currentTimeMillis(); - final JSONArray body = new JSONArray(); - body.put( - new JSONObject().put("id", sets.get(1).getId()).put("weight", 500).put("type", "timeforced") - .put("forcetime", forceTime).put("maintenanceWindow", - new JSONObject().put("schedule", getTestSchedule(100)) - .put("duration", getTestDuration(10)).put("timezone", getTestTimeZone()))) - .toString(); - body.put(new JSONObject().put("id", sets.get(0).getId()).put("type", "forced").put("weight", 800) - .put("confirmationRequired", true)); - - enableMultiAssignments(); - mockMvc.perform(post(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/" - + MgmtRestConstants.TARGET_V1_ASSIGNED_DISTRIBUTION_SET, targetId).content(body.toString()) - .contentType(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andDo(this.document.document( - pathParameters(parameterWithName("targetId").description(ApiModelPropertiesGeneric.ITEM_ID)), - requestParameters(parameterWithName("offline") - .description(MgmtApiModelProperties.OFFLINE_UPDATE).optional()), - requestFields(requestFieldWithPath("[].id").description(ApiModelPropertiesGeneric.ITEM_ID), - requestFieldWithPathMandatoryInMultiAssignMode("[].weight") - .description(MgmtApiModelProperties.ASSIGNMENT_WEIGHT) - .attributes(key("value").value("0 - 1000")), - optionalRequestFieldWithPath("[].forcetime") - .description(MgmtApiModelProperties.FORCETIME), - optionalRequestFieldWithPath("[].confirmationRequired") - .description(MgmtApiModelProperties.ASSIGNMENT_CONFIRMATION_REQUIRED) - .type(JsonFieldType.BOOLEAN.toString()), - optionalRequestFieldWithPath("[].maintenanceWindow") - .description(MgmtApiModelProperties.MAINTENANCE_WINDOW), - optionalRequestFieldWithPath("[].maintenanceWindow.schedule") - .description(MgmtApiModelProperties.MAINTENANCE_WINDOW_SCHEDULE), - optionalRequestFieldWithPath("[].maintenanceWindow.duration") - .description(MgmtApiModelProperties.MAINTENANCE_WINDOW_DURATION), - optionalRequestFieldWithPath("[].maintenanceWindow.timezone") - .description(MgmtApiModelProperties.MAINTENANCE_WINDOW_TIMEZONE), - optionalRequestFieldWithPath("[].type") - .description(MgmtApiModelProperties.ASSIGNMENT_TYPE) - .attributes(key("[].value") - .value("['soft', 'forced','timeforced', 'downloadonly']"))), - responseFields(getDsAssignmentResponseFieldDescriptors()))); - } - - private static FieldDescriptor[] getDsAssignmentResponseFieldDescriptors() { - final FieldDescriptor[] descriptors = { - fieldWithPath("assigned").description(MgmtApiModelProperties.DS_NEW_ASSIGNED_TARGETS), - fieldWithPath("alreadyAssigned").type(JsonFieldType.NUMBER) - .description(MgmtApiModelProperties.DS_ALREADY_ASSIGNED_TARGETS), - fieldWithPath("assignedActions").type(JsonFieldType.ARRAY) - .description(MgmtApiModelProperties.DS_NEW_ASSIGNED_ACTIONS), - fieldWithPath("assignedActions.[].id").type(JsonFieldType.NUMBER) - .description(MgmtApiModelProperties.ACTION_ID), - fieldWithPath("assignedActions.[]._links.self").type(JsonFieldType.OBJECT) - .description(MgmtApiModelProperties.LINK_TO_ACTION), - fieldWithPath("total").type(JsonFieldType.NUMBER) - .description(MgmtApiModelProperties.DS_TOTAL_ASSIGNED_TARGETS) }; - return descriptors; - } - - @Test - @Description("Handles the GET request of retrieving the attributes of a specific target. Reponse is a key/value list. Required Permission: READ_TARGET.") - public void getControllerAttributes() throws Exception { - // create target with attributes - final Map knownControllerAttrs = new HashMap<>(); - knownControllerAttrs.put("a", "1"); - knownControllerAttrs.put("b", "2"); - final Target target = testdataFactory.createTarget(targetId); - controllerManagement.updateControllerAttributes(targetId, knownControllerAttrs, null); - - // test query target over rest resource - mockMvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/attributes", target.getName())) - .andDo(MockMvcResultPrinter.print()).andExpect(status().is2xxSuccessful()) - .andExpect(jsonPath("$.a", equalTo("1"))).andExpect(jsonPath("$.b", equalTo("2"))) - .andDo(this.document.document( - pathParameters(parameterWithName("targetId").description(ApiModelPropertiesGeneric.ITEM_ID)))); - } - - @Test - @Description("Handles the GET request of retrieving the installed distribution set of an specific target. Required Permission: READ_TARGET.") - public void getInstalledDistributionSetFromTarget() throws Exception { - final Target target = createTargetByGivenNameWithAttributes(targetId, createDistributionSet()); - - mockMvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/" - + MgmtRestConstants.TARGET_V1_INSTALLED_DISTRIBUTION_SET, target.getName())).andExpect(status().isOk()) - .andDo(MockMvcResultPrinter.print()) - .andDo(this.document.document( - pathParameters(parameterWithName("targetId").description(ApiModelPropertiesGeneric.ITEM_ID)), - getResponseFieldsDistributionSet(false))); - } - - @Test - @Description("Get a paged list of meta data for a target with standard page size." + " Required Permission: " - + SpPermission.READ_REPOSITORY) - public void getMetadata() throws Exception { - final int totalMetadata = 4; - final String knownKeyPrefix = "knownKey"; - final String knownValuePrefix = "knownValue"; - final Target testTarget = testdataFactory.createTarget(targetId); - for (int index = 0; index < totalMetadata; index++) { - targetManagement.createMetaData(testTarget.getControllerId(), Lists.newArrayList( - entityFactory.generateTargetMetadata(knownKeyPrefix + index, knownValuePrefix + index))); - } - - mockMvc.perform( - get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/metadata", testTarget.getControllerId())) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaTypes.HAL_JSON)) - .andDo(this.document.document( - pathParameters(parameterWithName("targetId").description(ApiModelPropertiesGeneric.ITEM_ID)), - responseFields(fieldWithPath("total").description(ApiModelPropertiesGeneric.TOTAL_ELEMENTS), - fieldWithPath("size").type(JsonFieldType.NUMBER) - .description(ApiModelPropertiesGeneric.SIZE), - fieldWithPath("content").description(MgmtApiModelProperties.META_DATA), - fieldWithPath("content[].key").description(MgmtApiModelProperties.META_DATA_KEY), - fieldWithPath("content[].value").description(MgmtApiModelProperties.META_DATA_VALUE)))); - } - - @Test - @Description("Get a paged list of meta data for a target with defined page size and sorting by name descending and key starting with 'known'." - + " Required Permission: " + SpPermission.READ_REPOSITORY) - public void getMetadataWithParameters() throws Exception { - final int totalMetadata = 4; - - final String knownKeyPrefix = "knownKey"; - final String knownValuePrefix = "knownValue"; - final Target testTarget = testdataFactory.createTarget(targetId); - for (int index = 0; index < totalMetadata; index++) { - targetManagement.createMetaData(testTarget.getControllerId(), Lists.newArrayList( - entityFactory.generateTargetMetadata(knownKeyPrefix + index, knownValuePrefix + index))); - } - - mockMvc.perform( - get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/metadata", testTarget.getControllerId()) - .param("offset", "1").param("limit", "2").param("sort", "key:DESC").param("q", "key==known*")) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaTypes.HAL_JSON)) - .andDo(this.document.document( - requestParameters( - parameterWithName("limit").attributes(key("type").value("query")) - .description(ApiModelPropertiesGeneric.LIMIT), - parameterWithName("sort").description(ApiModelPropertiesGeneric.SORT), - parameterWithName("offset").description(ApiModelPropertiesGeneric.OFFSET), - parameterWithName("q").description(ApiModelPropertiesGeneric.FIQL)), - responseFields(fieldWithPath("total").description(ApiModelPropertiesGeneric.TOTAL_ELEMENTS), - fieldWithPath("size").type(JsonFieldType.NUMBER) - .description(ApiModelPropertiesGeneric.SIZE), - fieldWithPath("content").description(MgmtApiModelProperties.META_DATA), - fieldWithPath("content[].key").description(MgmtApiModelProperties.META_DATA_KEY), - fieldWithPath("content[].value").description(MgmtApiModelProperties.META_DATA_VALUE)))); - } - - @Test - @Description("Get a single meta data value for a meta data key." + " Required Permission: " - + SpPermission.READ_REPOSITORY) - public void getMetadataValue() throws Exception { - - // prepare and create metadata - final String knownKey = "knownKey"; - final String knownValue = "knownValue"; - final Target testTarget = testdataFactory.createTarget(targetId); - targetManagement.createMetaData(testTarget.getControllerId(), - Collections.singletonList(entityFactory.generateTargetMetadata(knownKey, knownValue))); - - mockMvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/metadata/{metadatakey}", - testTarget.getControllerId(), knownKey)).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andDo(this.document.document( - pathParameters(parameterWithName("targetId").description(ApiModelPropertiesGeneric.ITEM_ID), - parameterWithName("metadatakey").description(ApiModelPropertiesGeneric.ITEM_ID)), - responseFields(fieldWithPath("key").description(MgmtApiModelProperties.META_DATA_KEY), - fieldWithPath("value").description(MgmtApiModelProperties.META_DATA_VALUE)))); - } - - @Test - @Description("Update a single meta data value for specific key." + " Required Permission: " - + SpPermission.UPDATE_REPOSITORY) - public void updateMetadata() throws Exception { - // prepare and create metadata for update - final String knownKey = "knownKey"; - final String knownValue = "knownValue"; - final String updateValue = "valueForUpdate"; - - final Target testTarget = testdataFactory.createTarget(targetId); - targetManagement.createMetaData(testTarget.getControllerId(), - Collections.singletonList(entityFactory.generateTargetMetadata(knownKey, knownValue))); - - final JSONObject jsonObject = new JSONObject().put("key", knownKey).put("value", updateValue); - - mockMvc.perform(put(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/metadata/{metadatakey}", - testTarget.getControllerId(), knownKey) - .contentType(MediaType.APPLICATION_JSON).content(jsonObject.toString())) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andDo(this.document.document( - pathParameters(parameterWithName("targetId").description(ApiModelPropertiesGeneric.ITEM_ID), - parameterWithName("metadatakey").description(ApiModelPropertiesGeneric.ITEM_ID)), - requestFields(requestFieldWithPath("key").description(MgmtApiModelProperties.META_DATA_KEY), - requestFieldWithPath("value").description(MgmtApiModelProperties.META_DATA_VALUE)), - responseFields(fieldWithPath("key").description(MgmtApiModelProperties.META_DATA_KEY), - fieldWithPath("value").description(MgmtApiModelProperties.META_DATA_VALUE)))); - - } - - @Test - @Description("Delete a single meta data." + " Required Permission: " + SpPermission.UPDATE_REPOSITORY) - public void deleteMetadata() throws Exception { - // prepare and create metadata for deletion - final String knownKey = "knownKey"; - final String knownValue = "knownValue"; - - final Target testTarget = testdataFactory.createTarget(targetId); - targetManagement.createMetaData(testTarget.getControllerId(), - Collections.singletonList(entityFactory.generateTargetMetadata(knownKey, knownValue))); - - mockMvc.perform(delete(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/metadata/{key}", - testTarget.getControllerId(), knownKey)).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andDo(this.document.document( - pathParameters(parameterWithName("targetId").description(ApiModelPropertiesGeneric.ITEM_ID), - parameterWithName("key").description(ApiModelPropertiesGeneric.ITEM_ID)))); - - } - - @Test - @Description("Create a list of meta data entries" + " Required Permission: " + SpPermission.READ_REPOSITORY - + " and " + SpPermission.UPDATE_TARGET) - public void createMetadata() throws Exception { - - final Target testTarget = testdataFactory.createTarget(targetId); - - final String knownKey1 = "knownKey1"; - final String knownKey2 = "knownKey2"; - - final String knownValue1 = "knownValue1"; - final String knownValue2 = "knownValue2"; - - final JSONArray jsonArray = new JSONArray(); - jsonArray.put(new JSONObject().put("key", knownKey1).put("value", knownValue1)); - jsonArray.put(new JSONObject().put("key", knownKey2).put("value", knownValue2)); - - mockMvc.perform( - post(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/metadata", testTarget.getControllerId()) - .contentType(MediaType.APPLICATION_JSON).content(jsonArray.toString())) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isCreated()) - .andExpect(content().contentType(MediaTypes.HAL_JSON)) - .andDo(this.document.document( - pathParameters(parameterWithName("targetId").description(ApiModelPropertiesGeneric.ITEM_ID)), - requestFields(requestFieldWithPath("[]key").description(MgmtApiModelProperties.META_DATA_KEY), - optionalRequestFieldWithPath("[]value") - .description(MgmtApiModelProperties.META_DATA_VALUE)))); - } - - @Test - @Description("Update the target type of a target." + " Required Permission: " + SpPermission.UPDATE_TARGET) - public void postAssignTargetType() throws Exception { - final Target testTarget = testdataFactory.createTarget(targetId); - final DistributionSetType distributionSetTypeA = testdataFactory.findOrCreateDistributionSetType("jar", "jar"); - final DistributionSetType distributionSetTypeB = testdataFactory.findOrCreateDistributionSetType("zip", "zip"); - final TargetType targetType = testdataFactory.createTargetType("deviceType-A", - Arrays.asList(distributionSetTypeA, distributionSetTypeB)); - - final JSONObject jsonObject = new JSONObject(); - jsonObject.put("id", targetType.getId()); - - mockMvc.perform(post(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/targettype", - testTarget.getControllerId(), targetType.getId()).content(String.valueOf(jsonObject)) - .contentType(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andDo(this.document.document( - pathParameters(parameterWithName("targetId").description(ApiModelPropertiesGeneric.ITEM_ID)), - requestFields(requestFieldWithPath("id").description(MgmtApiModelProperties.TARGETTYPE_ID)))); - } - - @Test - @Description("Reset the target type of a target." + " Required Permission: " + SpPermission.UPDATE_TARGET) - public void deleteUnassignTargetType() throws Exception { - final Target testTarget = testdataFactory.createTarget(targetId); - final DistributionSetType distributionSetTypeA = testdataFactory.findOrCreateDistributionSetType("jar", "jar"); - final DistributionSetType distributionSetTypeB = testdataFactory.findOrCreateDistributionSetType("zip", "zip"); - final TargetType targetType = testdataFactory.createTargetType("deviceType-A", - Arrays.asList(distributionSetTypeA, distributionSetTypeB)); - targetManagement.assignType(testTarget.getControllerId(), targetType.getId()); - - mockMvc.perform(delete(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/targettype", - testTarget.getControllerId()).contentType(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()).andDo(this.document.document( - pathParameters(parameterWithName("targetId").description(ApiModelPropertiesGeneric.ITEM_ID)))); - } - - @Test - @Description("Handles the GET request of retrieving the auto-confirm state of a target. In this case auto-confirm is active for the requested target. Required Permission: READ_TARGET.") - public void getTargetAutoConfirmStateActive() throws Exception { - final Target testTarget = testdataFactory.createTarget(targetId); - confirmationManagement.activateAutoConfirmation(testTarget.getControllerId(), "custom_initiator_value", - "custom_remark"); - - mockMvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/" + TARGET_V1_AUTO_CONFIRM, - testTarget.getControllerId())).andExpect(status().isOk()).andDo(MockMvcResultPrinter.print()) - .andDo(this.document.document( - pathParameters(parameterWithName("targetId").description(ApiModelPropertiesGeneric.ITEM_ID)), - responseFields( - fieldWithPath("active").description(MgmtApiModelProperties.AUTO_CONFIRM_STATE_ACTIVE), - fieldWithPath("initiator") - .description(MgmtApiModelProperties.AUTO_CONFIRM_STATE_INITIATOR), - fieldWithPath("remark").description(MgmtApiModelProperties.AUTO_CONFIRM_STATE_REMARK), - fieldWithPath("activatedAt") - .description(MgmtApiModelProperties.AUTO_CONFIRM_STATE_ACTIVATED_AT), - fieldWithPath("_links.deactivate").optional().description( - MgmtApiModelProperties.AUTO_CONFIRM_STATE_REFERENCE_DEACTIVATE_AUTO_CONFIRM)))); - } - - @Test - @Description("Handles the GET request of retrieving the auto-confirm state of a target. In this case auto-confirm is not active for the requested target. Required Permission: READ_TARGET.") - public void getTargetAutoConfirmStateNotActive() throws Exception { - final Target testTarget = testdataFactory.createTarget(targetId); - - mockMvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/" + TARGET_V1_AUTO_CONFIRM, - testTarget.getControllerId())).andExpect(status().isOk()).andDo(MockMvcResultPrinter.print()) - .andDo(this.document.document( - pathParameters(parameterWithName("targetId").description(ApiModelPropertiesGeneric.ITEM_ID)), - responseFields( - fieldWithPath("active").description(MgmtApiModelProperties.AUTO_CONFIRM_STATE_ACTIVE), - fieldWithPath("_links.activate").optional().description( - MgmtApiModelProperties.AUTO_CONFIRM_STATE_REFERENCE_ACTIVATE_AUTO_CONFIRM)))); - } - - @Test - @Description("Handles the POST request to activate auto-confirm on a target. Payload can be provided to specify more details about the operation. Required Permission: UPDATE_TARGET.") - public void postActivateAutoConfirm() throws Exception { - final Target testTarget = testdataFactory.createTarget(targetId); - - final MgmtTargetAutoConfirmUpdate body = new MgmtTargetAutoConfirmUpdate("custom_initiator_value", - "custom_remark_value"); - - mockMvc.perform(post(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/" + TARGET_V1_AUTO_CONFIRM + "/" - + TARGET_V1_ACTIVATE_AUTO_CONFIRM, testTarget.getControllerId()) - .content(this.objectMapper.writeValueAsString(body)).contentType(MediaType.APPLICATION_JSON)) - .andExpect(status().isOk()).andDo(MockMvcResultPrinter.print()) - .andDo(this.document.document( - pathParameters(parameterWithName("targetId").description(ApiModelPropertiesGeneric.ITEM_ID)), - requestFields( - optionalRequestFieldWithPath("initiator") - .description(MgmtApiModelProperties.AUTO_CONFIRM_ACTIVATE_INITIATOR), - optionalRequestFieldWithPath("remark") - .description(MgmtApiModelProperties.AUTO_CONFIRM_ACTIVATE_REMARK)))); - } - - @Test - @Description("Handles the POST request to deactivate auto-confirm on a target. Required Permission: UPDATE_TARGET.") - public void postDeactivateAutoConfirm() throws Exception { - final Target testTarget = testdataFactory.createTarget(targetId); - confirmationManagement.activateAutoConfirmation(testTarget.getControllerId(), null, null); - - mockMvc.perform(post(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/" + TARGET_V1_AUTO_CONFIRM + "/" - + TARGET_V1_DEACTIVATE_AUTO_CONFIRM, testTarget.getControllerId())).andExpect(status().isOk()) - .andDo(MockMvcResultPrinter.print()).andDo(this.document.document( - pathParameters(parameterWithName("targetId").description(ApiModelPropertiesGeneric.ITEM_ID)))); - } - - private String createTargetJsonForPostRequest(final String controllerId, final String name, - final String description, final TargetType targetType) throws JsonProcessingException { - final Map target = new HashMap<>(); - target.put("controllerId", controllerId); - target.put("description", description); - target.put("name", name); - target.put("address", "https://192.168.0.1"); - target.put("securityToken", "2345678DGGDGFTDzztgf"); - target.put("targetType", targetType.getId()); - return "[" + this.objectMapper.writeValueAsString(target) + "]"; - } - - private String createJsonTarget(final String controllerId, final String name, final String description, final long targetTypeId) - throws JsonProcessingException { - final Map target = new HashMap<>(); - target.put("controllerId", controllerId); - target.put("description", description); - target.put("name", name); - target.put("address", "https://192.168.0.1"); - target.put("securityToken", "2345678DGGDGFTDzztgf"); - target.put("requestAttributes", true); - target.put("targetType", targetTypeId); - return this.objectMapper.writeValueAsString(target); - } - - private Action generateActionForTarget(final String knownControllerId) throws Exception { - return generateActionForTarget(knownControllerId, true, false, null, null, null); - } - - private Action generateRolloutActionForTarget(final String knownControllerId) throws Exception { - return generateActionForTarget(knownControllerId, true, false, null, null, null, true); - } - - private Action generateActionForTarget(final String knownControllerId, final boolean inSync) throws Exception { - return generateActionForTarget(knownControllerId, inSync, false, null, null, null); - } - - private Action generateRolloutActionForTarget(final String knownControllerId, final boolean inSync, - final boolean timeforced) throws Exception { - return generateActionForTarget(knownControllerId, inSync, timeforced, null, null, null, true); - } - - private Action generateActionForTarget(final String knownControllerId, final boolean inSync, - final boolean timeforced, final String maintenanceWindowSchedule, final String maintenanceWindowDuration, - final String maintenanceWindowTimeZone) throws Exception { - return generateActionForTarget(knownControllerId, inSync, timeforced, maintenanceWindowSchedule, - maintenanceWindowDuration, maintenanceWindowTimeZone, false); - } - - private Action generateActionForTarget(final String knownControllerId, final boolean inSync, - final boolean timeforced, final String maintenanceWindowSchedule, final String maintenanceWindowDuration, - final String maintenanceWindowTimeZone, final boolean createRollout) throws Exception { - final PageRequest pageRequest = PageRequest.of(0, 1, Direction.ASC, ActionStatusFields.ID.getFieldName()); - - createTargetByGivenNameWithAttributes(knownControllerId, inSync, timeforced, createDistributionSet(), - maintenanceWindowSchedule, maintenanceWindowDuration, maintenanceWindowTimeZone, createRollout); - - final List actions = deploymentManagement.findActionsAll(pageRequest).getContent(); - - assertThat(actions).hasSize(1); - return actions.get(0); - } - -} diff --git a/hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/mgmt/documentation/TargetTagResourceDocumentationTest.java b/hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/mgmt/documentation/TargetTagResourceDocumentationTest.java deleted file mode 100644 index cca4b786c7..0000000000 --- a/hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/mgmt/documentation/TargetTagResourceDocumentationTest.java +++ /dev/null @@ -1,314 +0,0 @@ -/** - * Copyright (c) 2018 Bosch Software Innovations GmbH and others - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - */ -package org.eclipse.hawkbit.rest.mgmt.documentation; - -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.delete; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.post; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.put; -import static org.springframework.restdocs.payload.PayloadDocumentation.requestFields; -import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields; -import static org.springframework.restdocs.request.RequestDocumentation.parameterWithName; -import static org.springframework.restdocs.request.RequestDocumentation.pathParameters; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import org.eclipse.hawkbit.mgmt.json.model.tag.MgmtAssignedTargetRequestBody; -import org.eclipse.hawkbit.mgmt.json.model.tag.MgmtTagRequestBodyPut; -import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants; -import org.eclipse.hawkbit.repository.model.DistributionSet; -import org.eclipse.hawkbit.repository.model.Target; -import org.eclipse.hawkbit.repository.model.TargetTag; -import org.eclipse.hawkbit.rest.documentation.AbstractApiRestDocumentation; -import org.eclipse.hawkbit.rest.documentation.ApiModelPropertiesGeneric; -import org.eclipse.hawkbit.rest.documentation.DocumenationResponseFieldsSnippet; -import org.eclipse.hawkbit.rest.documentation.MgmtApiModelProperties; -import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.springframework.http.MediaType; -import org.springframework.restdocs.payload.FieldDescriptor; -import org.springframework.restdocs.payload.JsonFieldType; -import org.springframework.restdocs.snippet.Snippet; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; - -import io.qameta.allure.Description; -import io.qameta.allure.Feature; -import io.qameta.allure.Story; - -/** - * Documentation generation for Management API for {@link TargetTag}. - * - */ -@Feature("Spring Rest Docs Tests - TargetTag") -@Story("TargetTag Resource") -public class TargetTagResourceDocumentationTest extends AbstractApiRestDocumentation { - - private DistributionSet distributionSet; - - @Override - public String getResourceName() { - return "targettag"; - } - - @BeforeEach - public void setUp() { - distributionSet = createDistributionSet(); - } - - @Test - @Description("Handles the GET request of retrieving all target tags") - public void getTargetTags() throws Exception { - createTargetTagEntitiy(); - arrayPrefix = "content[]."; - mockMvc.perform(get(MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING)).andExpect(status().isOk()) - .andDo(MockMvcResultPrinter.print()) - .andDo(this.document.document(getResponseFieldTargetTag(true, - fieldWithPath("size").type(JsonFieldType.NUMBER).description(ApiModelPropertiesGeneric.SIZE), - fieldWithPath("total").description(ApiModelPropertiesGeneric.TOTAL_ELEMENTS), - fieldWithPath("content").description(MgmtApiModelProperties.TARGET_TAG_LIST)))); - } - - @Test - @Description("Handles the GET request of retrieving all targets tags within SP based by parameter") - public void getTargetTagsWithParameters() throws Exception { - createTargetTagEntitiy(); - mockMvc.perform(get( - MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING + "?limit=10&sort=name:ASC&offset=0&q=name==targetTag")) - .andExpect(status().isOk()).andDo(MockMvcResultPrinter.print()) - .andDo(this.document.document(getFilterRequestParamter())); - } - - @Test - @Description("Handles the GET request of retrieving all target tag within SP. Required Permission: READ_TARGET.") - public void getTargetTag() throws Exception { - final Long tagId = createTargetTagId(); - mockMvc.perform(get(MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING + "/{targetTagId}", tagId)) - .andExpect(status().isOk()).andDo(MockMvcResultPrinter.print()) - .andDo(this.document.document( - pathParameters(parameterWithName("targetTagId").description(ApiModelPropertiesGeneric.ITEM_ID)), - getResponseFieldTargetTag(false))); - } - - @Test - @Description(" Handles the POST request of creating new target tags. The request body must always be a list of tags") - public void createTargetTags() throws Exception { - final MgmtTagRequestBodyPut bodyPut = new MgmtTagRequestBodyPut(); - bodyPut.setColour("red"); - bodyPut.setDescription("target tag description"); - bodyPut.setName("target tag"); - final ObjectMapper mapper = new ObjectMapper(); - final String json = mapper.writeValueAsString(Arrays.asList(bodyPut)); - this.mockMvc - .perform(post(MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING).content(json) - .contentType(MediaType.APPLICATION_JSON)) - .andExpect(status().isCreated()).andDo(MockMvcResultPrinter.print()) - .andDo(this.document.document(getRequestFieldsTargetTag(true), getResponseFieldTargetTag(true))); - } - - @Test - @Description("Handles the PUT request of updating a single target tag.") - public void updateTagretTag() throws Exception { - final Long tagId = createTargetTagId(); - final MgmtTagRequestBodyPut bodyPut = new MgmtTagRequestBodyPut(); - bodyPut.setColour("red"); - bodyPut.setDescription("target tag description"); - bodyPut.setName("target tag"); - final ObjectMapper mapper = new ObjectMapper(); - final String json = mapper.writeValueAsString(bodyPut); - - this.mockMvc - .perform(put(MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING + "/{targetTagId}", tagId).content(json) - .contentType(MediaType.APPLICATION_JSON)) - .andExpect(status().isOk()).andDo(MockMvcResultPrinter.print()) - .andDo(this.document.document( - pathParameters(parameterWithName("targetTagId").description(ApiModelPropertiesGeneric.ITEM_ID)), - getRequestFieldsTargetTag(false), getResponseFieldTargetTag(false))); - - } - - @Test - @Description("Handles the DELETE request for a single target tag") - public void deleteTargetTag() throws Exception { - final Long tagId = createTargetTagId(); - this.mockMvc - .perform(delete(MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING + "/{targetTagId}", tagId) - .contentType(MediaType.APPLICATION_JSON)) - .andExpect(status().isOk()).andDo(MockMvcResultPrinter.print()) - .andDo(this.document.document(pathParameters( - parameterWithName("targetTagId").description(ApiModelPropertiesGeneric.ITEM_ID)))); - } - - @Test - @Description("Handles the GET request of retrieving all assigned targets by the given") - public void getAssignedTargets() throws Exception { - enableConfirmationFlow(); - - final TargetTag tag = createTargetTagEntitiy(); - final Target target = createTargetByGivenNameWithAttributes("Target1", distributionSet); - targetManagement.assignTag(Arrays.asList(target.getControllerId()), tag.getId()); - - arrayPrefix = "content[]."; - this.mockMvc - .perform(get(MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING - + MgmtRestConstants.TARGET_TAG_TARGETS_REQUEST_MAPPING, tag.getId()) - .contentType(MediaType.APPLICATION_JSON)) - .andExpect(status().isOk()).andDo(MockMvcResultPrinter.print()) - .andDo(this.document.document( - pathParameters(parameterWithName("targetTagId").description(ApiModelPropertiesGeneric.ITEM_ID)), - getResponseFieldTarget(true, - fieldWithPath("size").type(JsonFieldType.NUMBER) - .description(ApiModelPropertiesGeneric.SIZE), - fieldWithPath("total").description(ApiModelPropertiesGeneric.TOTAL_ELEMENTS), - fieldWithPath("content").description(MgmtApiModelProperties.TARGET_TAG_LIST)))); - } - - @Test - @Description("Handles the POST request to toggle the assignment of targets by the given tag id") - public void toggleTagAssignment() throws Exception { - final Target assignTarget = createTargetByGivenNameWithAttributes("AssignedTarget", distributionSet); - final Target unassignTarget = createTargetByGivenNameWithAttributes("UnassignedTarget", distributionSet); - final Long tagId = createTargetTagId(); - final MgmtAssignedTargetRequestBody assignedTargetRequestBody1 = new MgmtAssignedTargetRequestBody(); - assignedTargetRequestBody1 - .setControllerId(createTargetByGivenNameWithAttributes("Target1", distributionSet).getControllerId()); - final ObjectMapper mapper = new ObjectMapper(); - final String json = mapper.writeValueAsString(Arrays.asList(assignedTargetRequestBody1)); - - this.mockMvc - .perform(post(MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING - + MgmtRestConstants.TARGET_TAG_TARGETS_REQUEST_MAPPING + "/toggleTagAssignment", tagId) - .content(json).contentType(MediaType.APPLICATION_JSON)) - .andExpect(status().isOk()).andDo(MockMvcResultPrinter.print()) - .andDo(this.document.document( - pathParameters(parameterWithName("targetTagId").description(ApiModelPropertiesGeneric.ITEM_ID)), - getRequestFieldsTargetAssignment(true), - getResponseAssignmentResult(assignTarget, unassignTarget) - - )); - } - - @Test - @Description("Handles the POST request to assign targets to the given tag id") - public void assignTargets() throws Exception { - enableConfirmationFlow(); - - final Long tagId = createTargetTagId(); - final MgmtAssignedTargetRequestBody assignedTargetRequestBody1 = new MgmtAssignedTargetRequestBody(); - assignedTargetRequestBody1 - .setControllerId(createTargetByGivenNameWithAttributes("Target1", distributionSet).getControllerId()); - final ObjectMapper mapper = new ObjectMapper(); - final String json = mapper.writeValueAsString(Arrays.asList(assignedTargetRequestBody1)); - - this.mockMvc - .perform(post(MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING - + MgmtRestConstants.TARGET_TAG_TARGETS_REQUEST_MAPPING, tagId).content(json) - .contentType(MediaType.APPLICATION_JSON)) - .andExpect(status().isOk()).andDo(MockMvcResultPrinter.print()) - .andDo(this.document.document( - pathParameters(parameterWithName("targetTagId").description(ApiModelPropertiesGeneric.ITEM_ID)), - getRequestFieldsTargetAssignment(true), getResponseFieldTarget(true))); - } - - @Test - @Description("Handles the DELETE request to unassign one target from the given tag id") - public void unassignTarget() throws Exception { - final Long tagId = createTargetTagId(); - final Target target = testdataFactory.createTarget(); - - this.mockMvc - .perform(delete( - MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING - + MgmtRestConstants.TARGET_TAG_TARGETS_REQUEST_MAPPING + "/{controllerId}", - tagId, target.getControllerId()).contentType(MediaType.APPLICATION_JSON)) - .andExpect(status().isOk()).andDo(MockMvcResultPrinter.print()) - .andDo(this.document.document( - pathParameters(parameterWithName("targetTagId").description(ApiModelPropertiesGeneric.ITEM_ID), - parameterWithName("controllerId").description(ApiModelPropertiesGeneric.ITEM_ID)))); - } - - private Snippet getRequestFieldsTargetTag(final boolean isArray) { - final String arrayPrefix = getArrayPrefix(isArray); - - return requestFields(requestFieldWithPath(arrayPrefix + "name").description(ApiModelPropertiesGeneric.NAME), - requestFieldWithPath(arrayPrefix + "description").description(ApiModelPropertiesGeneric.DESCRPTION), - optionalRequestFieldWithPath(arrayPrefix + "colour").description(ApiModelPropertiesGeneric.COLOUR)); - } - - private Snippet getRequestFieldsTargetAssignment(final boolean isArray) { - final String arrayPrefix = getArrayPrefix(isArray); - - return requestFields( - requestFieldWithPath(arrayPrefix + "controllerId").description(ApiModelPropertiesGeneric.ITEM_ID)); - } - - private Snippet getResponseFieldTargetTag(final boolean isArray) throws JsonProcessingException { - return getResponseFieldTargetTag(isArray, new FieldDescriptor[0]); - } - - private Snippet getResponseFieldTargetTag(final boolean isArray, final FieldDescriptor... descriptors) - throws JsonProcessingException { - final String arrayPrefix = getArrayPrefix(isArray); - final List allFieldDescriptor = new ArrayList<>(); - allFieldDescriptor.addAll(Arrays.asList(descriptors)); - - allFieldDescriptor.add(fieldWithPath(arrayPrefix + "id").description(ApiModelPropertiesGeneric.ITEM_ID)); - allFieldDescriptor.add(fieldWithPath(arrayPrefix + "name").description(ApiModelPropertiesGeneric.NAME)); - allFieldDescriptor - .add(fieldWithPath(arrayPrefix + "description").description(ApiModelPropertiesGeneric.DESCRPTION)); - allFieldDescriptor - .add(fieldWithPath(arrayPrefix + "createdBy").description(ApiModelPropertiesGeneric.CREATED_BY)); - allFieldDescriptor - .add(fieldWithPath(arrayPrefix + "createdAt").description(ApiModelPropertiesGeneric.CREATED_AT)); - allFieldDescriptor.add( - fieldWithPath(arrayPrefix + "lastModifiedBy").description(ApiModelPropertiesGeneric.LAST_MODIFIED_BY)); - allFieldDescriptor.add( - fieldWithPath(arrayPrefix + "lastModifiedAt").description(ApiModelPropertiesGeneric.LAST_MODIFIED_AT)); - allFieldDescriptor.add(fieldWithPath(arrayPrefix + "colour").description(ApiModelPropertiesGeneric.COLOUR)); - allFieldDescriptor.add(fieldWithPath(arrayPrefix + "_links.self").ignored()); - - if (!isArray) { - allFieldDescriptor.add(fieldWithPath(arrayPrefix + "_links.assignedTargets") - .description(MgmtApiModelProperties.LINKS_ASSIGNED_TARGETS)); - } - - return new DocumenationResponseFieldsSnippet(allFieldDescriptor); - } - - private Snippet getResponseAssignmentResult(final Target assignTarget, final Target unAssignTarget) - throws JsonProcessingException { - return responseFields( - fieldWithPath("assignedTargets").description(MgmtApiModelProperties.ASSIGNED_TARGETS) - .type("Array[Object]"), - - fieldWithPath("unassignedTargets").description(MgmtApiModelProperties.UN_ASSIGNED_TARGETS) - .type("Array[Object]")); - } - - private TargetTag createTargetTagEntitiy(final String name) { - final TargetTag updateTargetTag = targetTagManagement.create(entityFactory.tag().create().name(name)); - return targetTagManagement.update(entityFactory.tag().update(updateTargetTag.getId()) - .description("My name is " + name).colour("default")); - } - - private TargetTag createTargetTagEntitiy() { - return createTargetTagEntitiy("targetTag"); - } - - private Long createTargetTagId() { - return createTargetTagEntitiy().getId(); - } - -} diff --git a/hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/mgmt/documentation/TargetTypesDocumentationTest.java b/hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/mgmt/documentation/TargetTypesDocumentationTest.java deleted file mode 100644 index 4d67a09700..0000000000 --- a/hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/mgmt/documentation/TargetTypesDocumentationTest.java +++ /dev/null @@ -1,274 +0,0 @@ -/** - * Copyright (c) 2021 Bosch.IO GmbH and others - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - */ -package org.eclipse.hawkbit.rest.mgmt.documentation; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import io.qameta.allure.Description; -import io.qameta.allure.Feature; -import io.qameta.allure.Story; -import org.eclipse.hawkbit.im.authentication.SpPermission; -import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants; -import org.eclipse.hawkbit.repository.model.DistributionSetType; -import org.eclipse.hawkbit.repository.model.TargetType; -import org.eclipse.hawkbit.rest.documentation.AbstractApiRestDocumentation; -import org.eclipse.hawkbit.rest.documentation.ApiModelPropertiesGeneric; -import org.eclipse.hawkbit.rest.documentation.MgmtApiModelProperties; -import org.eclipse.hawkbit.rest.util.JsonBuilder; -import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter; -import org.json.JSONObject; -import org.junit.jupiter.api.Test; -import org.springframework.http.MediaType; -import org.springframework.restdocs.payload.JsonFieldType; - -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.delete; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.post; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.put; -import static org.springframework.restdocs.payload.PayloadDocumentation.requestFields; -import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields; -import static org.springframework.restdocs.request.RequestDocumentation.parameterWithName; -import static org.springframework.restdocs.request.RequestDocumentation.pathParameters; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - -/** - * Documentation generation for Management API for {@link TargetType}. - * - */ -@Feature("Spring Rest Docs Tests - TargetType") -@Story("TargetTypes Resource") -public class TargetTypesDocumentationTest extends AbstractApiRestDocumentation { - @Override - public String getResourceName() { - return "targettypes"; - } - - @Test - @Description("Handles the GET request of retrieving all target types within Hawkbit. Required Permission: " - + SpPermission.READ_TARGET) - public void getTargetTypes() throws Exception { - testdataFactory.findOrCreateTargetType("targetType1"); - testdataFactory.createTargetType("targetType2", Collections.singletonList(standardDsType)); - - mockMvc.perform(get(MgmtRestConstants.TARGETTYPE_V1_REQUEST_MAPPING).accept(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andDo(this.document.document(responseFields( - fieldWithPath("size").type(JsonFieldType.NUMBER).description(ApiModelPropertiesGeneric.SIZE), - fieldWithPath("total").description(ApiModelPropertiesGeneric.TOTAL_ELEMENTS), - fieldWithPath("content").description(MgmtApiModelProperties.TARGET_TYPE_LIST), - fieldWithPath("content[].id").description(ApiModelPropertiesGeneric.ITEM_ID), - fieldWithPath("content[].name").description(ApiModelPropertiesGeneric.NAME), - fieldWithPath("content[].description").description(ApiModelPropertiesGeneric.DESCRPTION), - fieldWithPath("content[].colour").description(ApiModelPropertiesGeneric.COLOUR), - fieldWithPath("content[].createdAt").description(ApiModelPropertiesGeneric.CREATED_AT), - fieldWithPath("content[].createdBy").description(ApiModelPropertiesGeneric.CREATED_BY), - fieldWithPath("content[].lastModifiedAt") - .description(ApiModelPropertiesGeneric.LAST_MODIFIED_AT).type("Number"), - fieldWithPath("content[].lastModifiedBy") - .description(ApiModelPropertiesGeneric.LAST_MODIFIED_BY).type("String"), - fieldWithPath("content[]._links.self").ignored()))); - } - - @Test - @Description("Handles the GET request of retrieving all target types within Hawkbit with a defined page size and " - + "offset, sorted by name in descending order and filtered down to all targets which name starts with 'targetType'. " - + "Required Permission: " + SpPermission.READ_TARGET) - public void getTargetTypesWithParameters() throws Exception { - testdataFactory.findOrCreateTargetType("targetType1"); - testdataFactory.createTargetType("targetType2", Collections.singletonList(standardDsType)); - - mockMvc.perform(get(MgmtRestConstants.TARGETTYPE_V1_REQUEST_MAPPING).accept(MediaType.APPLICATION_JSON) - .param("offset", "0").param("limit", "2").param("sort", "name:ASC").param("q", "name==targetType*")) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON)) - .andDo(this.document.document(getFilterRequestParamter())); - } - - @Test - @Description("Handles the GET request for a single target type within Hawkbit. Required Permission: " - + SpPermission.READ_TARGET) - public void getTargetType() throws Exception { - TargetType testType = testdataFactory.createTargetType("TargetType", Collections.singletonList(standardDsType)); - - mockMvc.perform(get(MgmtRestConstants.TARGETTYPE_V1_REQUEST_MAPPING + "/{targetTypeId}", testType.getId()) - .accept(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andDo(this.document.document( - pathParameters( - parameterWithName("targetTypeId").description(ApiModelPropertiesGeneric.ITEM_ID)), - responseFields(fieldWithPath("id").description(ApiModelPropertiesGeneric.ITEM_ID), - fieldWithPath("name").description(ApiModelPropertiesGeneric.NAME), - fieldWithPath("description").description(ApiModelPropertiesGeneric.DESCRPTION), - fieldWithPath("colour").description(ApiModelPropertiesGeneric.COLOUR), - fieldWithPath("createdAt").description(ApiModelPropertiesGeneric.CREATED_AT), - fieldWithPath("createdBy").description(ApiModelPropertiesGeneric.CREATED_BY), - fieldWithPath("lastModifiedAt").description(ApiModelPropertiesGeneric.LAST_MODIFIED_AT) - .type("Number"), - fieldWithPath("lastModifiedBy").description(ApiModelPropertiesGeneric.LAST_MODIFIED_BY) - .type("String"), - fieldWithPath("_links.compatibledistributionsettypes.href") - .description(MgmtApiModelProperties.LINK_COMPATIBLE_DS_TYPES), - fieldWithPath("_links.self").ignored()))); - } - - @Test - @Description("Handles the POST request for creating new target types within Hawkbit. The request body " - + "must always be a list of types. Required Permission: " + SpPermission.CREATE_TARGET) - public void postTargetTypes() throws Exception { - final List types = new ArrayList<>(); - types.add(entityFactory.targetType().create().name("targetType1").description("targetType1 description") - .colour("#ffffff").build()); - types.add(entityFactory.targetType().create().name("targetType2").description("targetType2 description") - .colour("#000000").compatible(Collections.singletonList(standardDsType.getId())).build()); - - mockMvc.perform(post(MgmtRestConstants.TARGETTYPE_V1_REQUEST_MAPPING) - .content(JsonBuilder.targetTypesCreatableFieldsOnly(types)).contentType(MediaType.APPLICATION_JSON) - .accept(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()).andExpect(status().isCreated()) - .andDo(this.document.document( - requestFields(requestFieldWithPath("[]name").description(ApiModelPropertiesGeneric.NAME), - optionalRequestFieldWithPath("[]description") - .description(ApiModelPropertiesGeneric.DESCRPTION), - optionalRequestFieldWithPath("[]colour").description(ApiModelPropertiesGeneric.COLOUR), - optionalRequestFieldWithPath("[]compatibledistributionsettypes") - .description(MgmtApiModelProperties.COMPATIBLE_DS_TYPES)), - responseFields(fieldWithPath("[]id").description(ApiModelPropertiesGeneric.ITEM_ID), - fieldWithPath("[]name").description(ApiModelPropertiesGeneric.NAME), - fieldWithPath("[]description").description(ApiModelPropertiesGeneric.DESCRPTION), - fieldWithPath("[]colour").description(ApiModelPropertiesGeneric.COLOUR), - fieldWithPath("[]createdAt").description(ApiModelPropertiesGeneric.CREATED_AT), - fieldWithPath("[]createdBy").description(ApiModelPropertiesGeneric.CREATED_BY), - fieldWithPath("[]lastModifiedAt") - .description(ApiModelPropertiesGeneric.LAST_MODIFIED_AT).type("Number"), - fieldWithPath("[]lastModifiedBy") - .description(ApiModelPropertiesGeneric.LAST_MODIFIED_BY).type("String"), - fieldWithPath("[]_links.self").ignored()))); - } - - @Test - @Description("Handles the DELETE request of retrieving a single target type within Hawkbit. Required Permission: " - + SpPermission.DELETE_TARGET) - public void deleteTargetType() throws Exception { - TargetType testType = testdataFactory.createTargetType("TargetType", Collections.singletonList(standardDsType)); - - mockMvc.perform(delete(MgmtRestConstants.TARGETTYPE_V1_REQUEST_MAPPING + "/{targetTypeId}", testType.getId())) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andDo(this.document.document(pathParameters( - parameterWithName("targetTypeId").description(ApiModelPropertiesGeneric.ITEM_ID)))); - } - - @Test - @Description("Handles the PUT request for a single target type within Hawkbit. " + "Required Permission: " - + SpPermission.UPDATE_TARGET) - public void putTargetType() throws Exception { - TargetType testType = testdataFactory.createTargetType("targetType", Collections.singletonList(standardDsType)); - final String body = new JSONObject().put("description", "an updated description").put("name", "updatedTypeName") - .put("colour", "#aaafff").toString(); - - this.mockMvc - .perform(put(MgmtRestConstants.TARGETTYPE_V1_REQUEST_MAPPING + "/{targetTypeId}", testType.getId()) - .content(body).contentType(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andDo(this.document.document( - pathParameters( - parameterWithName("targetTypeId").description(ApiModelPropertiesGeneric.ITEM_ID)), - requestFields( - optionalRequestFieldWithPath("description") - .description(ApiModelPropertiesGeneric.DESCRPTION), - optionalRequestFieldWithPath("name").description(ApiModelPropertiesGeneric.NAME), - optionalRequestFieldWithPath("colour").description(ApiModelPropertiesGeneric.COLOUR)), - responseFields(fieldWithPath("id").description(ApiModelPropertiesGeneric.ITEM_ID), - fieldWithPath("name").description(ApiModelPropertiesGeneric.NAME), - fieldWithPath("description").description(ApiModelPropertiesGeneric.DESCRPTION), - fieldWithPath("colour").description(ApiModelPropertiesGeneric.COLOUR), - fieldWithPath("createdAt").description(ApiModelPropertiesGeneric.CREATED_AT), - fieldWithPath("createdBy").description(ApiModelPropertiesGeneric.CREATED_BY), - fieldWithPath("lastModifiedAt").description(ApiModelPropertiesGeneric.LAST_MODIFIED_AT) - .type("Number"), - fieldWithPath("lastModifiedBy").description(ApiModelPropertiesGeneric.LAST_MODIFIED_BY) - .type("String"), - fieldWithPath("_links.compatibledistributionsettypes.href") - .description(MgmtApiModelProperties.LINK_COMPATIBLE_DS_TYPES), - fieldWithPath("_links.self").ignored()))); - } - - @Test - @Description("Handles the GET request of retrieving the list of compatible distribution set types in that target type. " - + "Required Permission: " + SpPermission.READ_TARGET + " and " + SpPermission.READ_REPOSITORY) - public void getCompatibleDistributionSetTypes() throws Exception { - TargetType testType = testdataFactory.createTargetType("targetType", Collections.singletonList(standardDsType)); - - mockMvc.perform( - get(MgmtRestConstants.TARGETTYPE_V1_REQUEST_MAPPING + "/{targetTypeId}/compatibledistributionsettypes", - testType.getId()).accept(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON)) - - .andDo(this.document.document( - pathParameters( - parameterWithName("targetTypeId").description(ApiModelPropertiesGeneric.ITEM_ID)), - responseFields(fieldWithPath("[]id").description(ApiModelPropertiesGeneric.ITEM_ID), - fieldWithPath("[]key").description(MgmtApiModelProperties.DS_TYPE_KEY), - fieldWithPath("[]name").description(ApiModelPropertiesGeneric.NAME), - fieldWithPath("[]description").description(ApiModelPropertiesGeneric.DESCRPTION), - fieldWithPath("[]colour").description(ApiModelPropertiesGeneric.COLOUR), - fieldWithPath("[]createdAt").description(ApiModelPropertiesGeneric.CREATED_AT), - fieldWithPath("[]createdBy").description(ApiModelPropertiesGeneric.CREATED_BY), - fieldWithPath("[]lastModifiedAt") - .description(ApiModelPropertiesGeneric.LAST_MODIFIED_AT).type("Number"), - fieldWithPath("[]lastModifiedBy") - .description(ApiModelPropertiesGeneric.LAST_MODIFIED_BY).type("String"), - fieldWithPath("[]deleted").description(ApiModelPropertiesGeneric.DELETED), - fieldWithPath("[]_links.self").ignored()))); - } - - @Test - @Description("Handles the POST request for adding a compatible distribution set type to a target type." - + " Required Permission: " + SpPermission.UPDATE_TARGET + " and " + SpPermission.READ_REPOSITORY) - public void postCompatibleDistributionSetTypes() throws Exception { - final DistributionSetType dsType1 = distributionSetTypeManagement.create( - entityFactory.distributionSetType().create().key("test1").name("TestName1").description("Desc1")); - final DistributionSetType dsType2 = distributionSetTypeManagement.create( - entityFactory.distributionSetType().create().key("test2").name("TestName2").description("Desc2")); - final TargetType targetType = testdataFactory.createTargetType("targetType", - Collections.singletonList(standardDsType)); - - mockMvc.perform( - post(MgmtRestConstants.TARGETTYPE_V1_REQUEST_MAPPING + "/{targetTypeId}/compatibledistributionsettypes", - targetType.getId()) - .content("[{\"id\":" + dsType1.getId() + "},{\"id\":" + dsType2.getId() + "}]") - .contentType(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andDo(this.document.document( - pathParameters( - parameterWithName("targetTypeId").description(ApiModelPropertiesGeneric.ITEM_ID)), - requestFields(requestFieldWithPath("[]id").description(ApiModelPropertiesGeneric.ITEM_ID)))); - } - - @Test - @Description("Handles the DELETE request to unassign the list of compatible distribution set types in that target type. " - + SpPermission.UPDATE_TARGET + " and " + SpPermission.READ_REPOSITORY) - public void deleteCompatibleDistributionSetType() throws Exception { - final DistributionSetType dsType = distributionSetTypeManagement.create( - entityFactory.distributionSetType().create().key("test1").name("TestName1").description("Desc1")); - final TargetType targetType = testdataFactory.createTargetType("targetType", Collections.singletonList(dsType)); - - mockMvc.perform(delete( - MgmtRestConstants.TARGETTYPE_V1_REQUEST_MAPPING - + "/{targetTypeId}/compatibledistributionsettypes/{distributionSetTypeId}", - targetType.getId(), dsType.getId()).contentType(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andDo(this.document.document(pathParameters( - parameterWithName("targetTypeId").description(ApiModelPropertiesGeneric.ITEM_ID), - parameterWithName("distributionSetTypeId").description(ApiModelPropertiesGeneric.ITEM_ID)))); - } - -} diff --git a/hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/mgmt/documentation/TenantResourceDocumentationTest.java b/hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/mgmt/documentation/TenantResourceDocumentationTest.java deleted file mode 100644 index fba8847478..0000000000 --- a/hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/mgmt/documentation/TenantResourceDocumentationTest.java +++ /dev/null @@ -1,189 +0,0 @@ -/** - * Copyright (c) 2018 Bosch Software Innovations GmbH and others - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - */ -package org.eclipse.hawkbit.rest.mgmt.documentation; - -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.delete; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.put; -import static org.springframework.restdocs.payload.PayloadDocumentation.requestFields; -import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields; -import static org.springframework.restdocs.request.RequestDocumentation.parameterWithName; -import static org.springframework.restdocs.request.RequestDocumentation.pathParameters; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.eclipse.hawkbit.im.authentication.SpPermission; -import org.eclipse.hawkbit.mgmt.json.model.system.MgmtSystemTenantConfigurationValueRequest; -import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants; -import org.eclipse.hawkbit.repository.model.TenantConfiguration; -import org.eclipse.hawkbit.rest.documentation.AbstractApiRestDocumentation; -import org.eclipse.hawkbit.rest.documentation.ApiModelPropertiesGeneric; -import org.eclipse.hawkbit.rest.documentation.MgmtApiModelProperties; -import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter; -import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationProperties; -import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationProperties.TenantConfigurationKey; -import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.MediaType; -import org.springframework.restdocs.payload.FieldDescriptor; - -import com.fasterxml.jackson.databind.ObjectMapper; - -import io.qameta.allure.Description; -import io.qameta.allure.Feature; -import io.qameta.allure.Story; - -/** - * Documentation generation for System API for {@link TenantConfiguration}. - */ -@Feature("Spring Rest Docs Tests - TenantConfiguration") -@Story("TenantConfiguration Resource") -public class TenantResourceDocumentationTest extends AbstractApiRestDocumentation { - - protected static final Map CONFIG_ITEM_DESCRIPTIONS = new HashMap<>(); - - static { - CONFIG_ITEM_DESCRIPTIONS.put(TenantConfigurationKey.AUTHENTICATION_MODE_GATEWAY_SECURITY_TOKEN_ENABLED, - "if the authentication mode 'gateway security token' is enabled."); - CONFIG_ITEM_DESCRIPTIONS.put(TenantConfigurationKey.AUTHENTICATION_MODE_GATEWAY_SECURITY_TOKEN_KEY, - "the key of the gateway security token."); - CONFIG_ITEM_DESCRIPTIONS.put(TenantConfigurationKey.AUTHENTICATION_MODE_HEADER_AUTHORITY_NAME, - "the name of the 'authority header'."); - CONFIG_ITEM_DESCRIPTIONS.put(TenantConfigurationKey.AUTHENTICATION_MODE_HEADER_ENABLED, - "if the authentication mode 'authority header' is enabled."); - CONFIG_ITEM_DESCRIPTIONS.put(TenantConfigurationKey.AUTHENTICATION_MODE_TARGET_SECURITY_TOKEN_ENABLED, - "if the authentication mode 'target security token' is enabled."); - CONFIG_ITEM_DESCRIPTIONS.put(TenantConfigurationKey.POLLING_OVERDUE_TIME_INTERVAL, - "the period of time after the SP server will recognize a target, which is not performing pull requests anymore."); - CONFIG_ITEM_DESCRIPTIONS.put(TenantConfigurationKey.POLLING_TIME_INTERVAL, - "the time interval between two poll requests of a target."); - CONFIG_ITEM_DESCRIPTIONS.put(TenantConfigurationKey.MIN_POLLING_TIME_INTERVAL, - "the smallest time interval permitted between two poll requests of a target."); - CONFIG_ITEM_DESCRIPTIONS.put(TenantConfigurationKey.MAINTENANCE_WINDOW_POLL_COUNT, - "the polling interval so that controller tries to poll at least these many times between the last " - + "polling and before start of maintenance window. The polling interval is" - + " bounded by configured pollingTime and minPollingTime. The polling" - + " interval is modified as per following scheme: pollingTime(@time=t) =" - + " (maintenanceWindowStartTime - t)/maintenanceWindowPollCount."); - CONFIG_ITEM_DESCRIPTIONS.put(TenantConfigurationKey.ANONYMOUS_DOWNLOAD_MODE_ENABLED, - "if the anonymous download mode is enabled."); - CONFIG_ITEM_DESCRIPTIONS.put(TenantConfigurationKey.REPOSITORY_ACTIONS_AUTOCLOSE_ENABLED, - "if autoclose running actions with new Distribution Set assignment is enabled."); - CONFIG_ITEM_DESCRIPTIONS.put(TenantConfigurationKey.ROLLOUT_APPROVAL_ENABLED, - "if approval mode for Rollout Management is enabled."); - CONFIG_ITEM_DESCRIPTIONS.put(TenantConfigurationKey.ACTION_CLEANUP_ENABLED, - "if automatic cleanup of deployment actions is enabled."); - CONFIG_ITEM_DESCRIPTIONS.put(TenantConfigurationKey.ACTION_CLEANUP_ACTION_STATUS, - "the list of action status that should be taken into account for the cleanup."); - CONFIG_ITEM_DESCRIPTIONS.put(TenantConfigurationKey.ACTION_CLEANUP_ACTION_EXPIRY, - "the expiry time in milliseconds that needs to elapse before an action may be cleaned up."); - CONFIG_ITEM_DESCRIPTIONS.put(TenantConfigurationKey.MULTI_ASSIGNMENTS_ENABLED, - "if multiple distribution sets can be assigned to the same targets."); - CONFIG_ITEM_DESCRIPTIONS.put(TenantConfigurationKey.BATCH_ASSIGNMENTS_ENABLED, - "if distribution set can be assigned to multiple targets in a single batch message."); - CONFIG_ITEM_DESCRIPTIONS.put(TenantConfigurationKey.USER_CONFIRMATION_ENABLED, - "if confirmation is required when distribution set is assigned to target."); - } - - @Autowired - protected TenantConfigurationProperties tenantConfigurationProperties; - - @Override - public String getResourceName() { - return "tenant"; - } - - @Test - @Description("Handles GET request for receiving all tenant specific configurations. Required Permission: " - + SpPermission.TENANT_CONFIGURATION) - public void getTenantConfigrations() throws Exception { - - mockMvc.perform(get(MgmtRestConstants.SYSTEM_V1_REQUEST_MAPPING + "/configs/")).andExpect(status().isOk()) - .andDo(MockMvcResultPrinter.print()) - .andDo(this.document.document(responseFields(getTenantConfigurationValuesKeyResponseFields()))); - } - - @Test - @Description("Handles GET request for receiving a tenant specific configuration. Required Permission: " - + SpPermission.TENANT_CONFIGURATION) - public void getTenantConfigration() throws Exception { - mockMvc.perform(get(MgmtRestConstants.SYSTEM_V1_REQUEST_MAPPING + "/configs/{keyName}/", - TenantConfigurationKey.AUTHENTICATION_MODE_GATEWAY_SECURITY_TOKEN_KEY)).andExpect(status().isOk()) - .andDo(MockMvcResultPrinter.print()) - .andDo(this.document.document( - pathParameters(parameterWithName("keyName").description(MgmtApiModelProperties.CONFIG_PARAM)), - responseFields(getTenantConfigurationValueResponseField()))); - } - - @Test - @Description("Handles PUT request for settings values in tenant specific configuration. Required Permission: " - + SpPermission.TENANT_CONFIGURATION) - public void putTenantConfigration() throws Exception { - - final MgmtSystemTenantConfigurationValueRequest bodyPut = new MgmtSystemTenantConfigurationValueRequest(); - bodyPut.setValue("exampleToken"); - final ObjectMapper mapper = new ObjectMapper(); - final String json = mapper.writeValueAsString(bodyPut); - - mockMvc.perform(put(MgmtRestConstants.SYSTEM_V1_REQUEST_MAPPING + "/configs/{keyName}/", - TenantConfigurationKey.AUTHENTICATION_MODE_GATEWAY_SECURITY_TOKEN_KEY).content(json) - .contentType(MediaType.APPLICATION_JSON)) - .andExpect(status().isOk()).andDo(MockMvcResultPrinter.print()) - .andDo(this.document.document( - pathParameters(parameterWithName("keyName").description(MgmtApiModelProperties.CONFIG_PARAM)), - requestFields(requestFieldWithPath("value").description(MgmtApiModelProperties.CONFIG_VALUE)), - responseFields(getTenantConfigurationValueResponseField()))); - } - - @Test - @Description("Handles DELETE request deleting a tenant specific configuration. Required Permission: " - + SpPermission.TENANT_CONFIGURATION) - public void deleteTenantConfigration() throws Exception { - mockMvc.perform(delete(MgmtRestConstants.SYSTEM_V1_REQUEST_MAPPING + "/configs/{keyName}/", - TenantConfigurationKey.AUTHENTICATION_MODE_GATEWAY_SECURITY_TOKEN_KEY)).andExpect(status().isOk()) - .andDo(MockMvcResultPrinter.print()).andDo(this.document.document( - pathParameters(parameterWithName("keyName").description(MgmtApiModelProperties.CONFIG_PARAM)))); - } - - private FieldDescriptor[] getTenantConfigurationValuesKeyResponseFields() { - final List fields = new ArrayList<>(); - for (final TenantConfigurationKey key : tenantConfigurationProperties.getConfigurationKeys()) { - fields.add(fieldWithPath("['" + key.getKeyName() + "']").type(key.getDataType().getSimpleName()) - .description(getTenantConfigurationKeyDescription(key))); - } - return fields.toArray(new FieldDescriptor[fields.size()]); - } - - private FieldDescriptor[] getTenantConfigurationValueResponseField() { - return new FieldDescriptor[] { fieldWithPath("value").description(MgmtApiModelProperties.CONFIG_VALUE), - fieldWithPath("global").description(MgmtApiModelProperties.CONFIG_GLOBAL), - fieldWithPath("createdBy").description(ApiModelPropertiesGeneric.CREATED_BY).type("Number").optional(), - fieldWithPath("createdAt").description(ApiModelPropertiesGeneric.CREATED_AT).type("String").optional(), - fieldWithPath("lastModifiedAt").description(ApiModelPropertiesGeneric.LAST_MODIFIED_AT).type("Number") - .optional(), - fieldWithPath("lastModifiedBy").description(ApiModelPropertiesGeneric.LAST_MODIFIED_BY).type("String") - .optional(), - fieldWithPath("_links.self").ignored() }; - } - - private String getTenantConfigurationKeyDescription(final TenantConfigurationKey key) { - if (!CONFIG_ITEM_DESCRIPTIONS.containsKey(key.getKeyName())) { - throw new IllegalArgumentException("Description for key " + key.getKeyName() + " is missing."); - } - - return "The configuration key '" + key.getKeyName() + "' defines " - + CONFIG_ITEM_DESCRIPTIONS.get(key.getKeyName()); - } - -} diff --git a/hawkbit-rest/hawkbit-rest-docs/src/test/resources/org/springframework/restdocs/templates/path-parameters.snippet b/hawkbit-rest/hawkbit-rest-docs/src/test/resources/org/springframework/restdocs/templates/path-parameters.snippet deleted file mode 100644 index 067e1fb833..0000000000 --- a/hawkbit-rest/hawkbit-rest-docs/src/test/resources/org/springframework/restdocs/templates/path-parameters.snippet +++ /dev/null @@ -1,9 +0,0 @@ -|=== -|Parameter|Description - -{{#parameters}} -|{{name}} -|{{description}} - -{{/parameters}} -|=== \ No newline at end of file diff --git a/hawkbit-rest/hawkbit-rest-docs/src/test/resources/org/springframework/restdocs/templates/request-fields.snippet b/hawkbit-rest/hawkbit-rest-docs/src/test/resources/org/springframework/restdocs/templates/request-fields.snippet deleted file mode 100644 index eb6d5b353e..0000000000 --- a/hawkbit-rest/hawkbit-rest-docs/src/test/resources/org/springframework/restdocs/templates/request-fields.snippet +++ /dev/null @@ -1,12 +0,0 @@ -|=== -|Path|Type|Description|Allowed Values|Mandatory - -{{#fields}} -|{{path}} -|{{type}} -|{{description}} -|{{value}} -|{{mandatory}} -{{/fields}} - -|=== \ No newline at end of file diff --git a/hawkbit-rest/hawkbit-rest-docs/src/test/resources/org/springframework/restdocs/templates/response-fields.snippet b/hawkbit-rest/hawkbit-rest-docs/src/test/resources/org/springframework/restdocs/templates/response-fields.snippet deleted file mode 100644 index 1578cb28f0..0000000000 --- a/hawkbit-rest/hawkbit-rest-docs/src/test/resources/org/springframework/restdocs/templates/response-fields.snippet +++ /dev/null @@ -1,11 +0,0 @@ -|=== -|Path|Type|Description|Allowed Values - -{{#fields}} -|{{path}} -|{{type}} -|{{description}} -|{{value}} -{{/fields}} - -|=== \ No newline at end of file diff --git a/hawkbit-rest/hawkbit-rest-docs/src/test/resources/updateserver-restdocumentation-test.properties b/hawkbit-rest/hawkbit-rest-docs/src/test/resources/updateserver-restdocumentation-test.properties deleted file mode 100644 index 3daafd433a..0000000000 --- a/hawkbit-rest/hawkbit-rest-docs/src/test/resources/updateserver-restdocumentation-test.properties +++ /dev/null @@ -1,38 +0,0 @@ -# -# Copyright (c) 2018 Bosch Software Innovations GmbH and others -# -# This program and the accompanying materials are made -# available under the terms of the Eclipse Public License 2.0 -# which is available at https://www.eclipse.org/legal/epl-2.0/ -# -# SPDX-License-Identifier: EPL-2.0 -# - -hawkbit.controller.pollingTime=12:00:00 -hawkbit.controller.pollingOverdueTime=23:59:59 - -## Configuration for building download URLs - START -# HTTP -hawkbit.artifact.url.protocols.download-http.rel=download-http -hawkbit.artifact.url.protocols.download-http.protocol=http -hawkbit.artifact.url.protocols.download-http.hostname=link-to-cdn.com -hawkbit.artifact.url.protocols.download-http.supports=DMF,DDI -hawkbit.artifact.url.protocols.download-http.ref={protocol}://{hostname}/api/v1/{tenant}/download/controller/{controllerId}/softwaremodules/{softwareModuleId}/filename/{artifactFileName} -hawkbit.artifact.url.protocols.md5sum-http.rel=md5sum-http -hawkbit.artifact.url.protocols.md5sum-http.protocol=${hawkbit.artifact.url.protocols.download-http.protocol} -hawkbit.artifact.url.protocols.md5sum-http.hostname=${hawkbit.artifact.url.protocols.download-http.hostname} -hawkbit.artifact.url.protocols.md5sum-http.supports=DDI -hawkbit.artifact.url.protocols.md5sum-http.ref=${hawkbit.artifact.url.protocols.download-http.ref}.MD5SUM - -# HTTPS -hawkbit.artifact.url.protocols.download.rel=download -hawkbit.artifact.url.protocols.download.protocol=https -hawkbit.artifact.url.protocols.download.hostname=link-to-cdn.com -hawkbit.artifact.url.protocols.download.supports=DMF,DDI -hawkbit.artifact.url.protocols.download.ref={protocol}://{hostname}/api/v1/{tenant}/download/controller/{controllerId}/softwaremodules/{softwareModuleId}/filename/{artifactFileName} -hawkbit.artifact.url.protocols.md5sum.rel=md5sum -hawkbit.artifact.url.protocols.md5sum.protocol=${hawkbit.artifact.url.protocols.download.protocol} -hawkbit.artifact.url.protocols.md5sum.hostname=${hawkbit.artifact.url.protocols.download.hostname} -hawkbit.artifact.url.protocols.md5sum.supports=DDI -hawkbit.artifact.url.protocols.md5sum.ref=${hawkbit.artifact.url.protocols.download.ref}.MD5SUM -## Configuration for building download URLs - END diff --git a/hawkbit-rest/pom.xml b/hawkbit-rest/pom.xml index 9c0966fd46..adf1431969 100644 --- a/hawkbit-rest/pom.xml +++ b/hawkbit-rest/pom.xml @@ -27,6 +27,5 @@ hawkbit-mgmt-resource hawkbit-ddi-api hawkbit-ddi-resource - hawkbit-rest-docs \ No newline at end of file diff --git a/hawkbit-test-report/pom.xml b/hawkbit-test-report/pom.xml index caaaa084fe..b1f39f71ff 100644 --- a/hawkbit-test-report/pom.xml +++ b/hawkbit-test-report/pom.xml @@ -96,11 +96,6 @@ hawkbit-rest-core ${project.version} - - org.eclipse.hawkbit - hawkbit-rest-docs - ${project.version} - org.eclipse.hawkbit hawkbit-dmf-amqp