diff options
-rw-r--r-- | docs/openapi/components.yml | 5 | ||||
-rw-r--r-- | docs/openapi/openapi.yml | 10 | ||||
-rw-r--r-- | docs/requirements-docs.txt | 17 | ||||
-rw-r--r-- | docs/tox.ini | 6 | ||||
-rw-r--r-- | pom.xml | 25 | ||||
-rw-r--r-- | src/main/java/org/onap/cps/ncmp/dmi/rest/controller/DmiRestController.java | 16 | ||||
-rw-r--r-- | src/test/groovy/org/onap/cps/ncmp/dmi/rest/controller/DmiRestControllerSpec.groovy | 23 |
7 files changed, 39 insertions, 63 deletions
diff --git a/docs/openapi/components.yml b/docs/openapi/components.yml index 9cce52de..736639d8 100644 --- a/docs/openapi/components.yml +++ b/docs/openapi/components.yml @@ -157,11 +157,12 @@ components: schema: type: string - resourceIdentifierInPath: + resourceIdentifierInQuery: name: resourceIdentifier - in: path + in: query description: Resource identifier to get/set the resource data required: true + allowReserved: true schema: type: string diff --git a/docs/openapi/openapi.yml b/docs/openapi/openapi.yml index f66897a2..1e7b38c9 100644 --- a/docs/openapi/openapi.yml +++ b/docs/openapi/openapi.yml @@ -128,7 +128,7 @@ paths: '403': $ref: 'components.yml#/components/responses/Forbidden' - /v1/ch/{cmHandle}/data/ds/ncmp-datastore:passthrough-operational/{resourceIdentifier}: + /v1/ch/{cmHandle}/data/ds/ncmp-datastore:passthrough-operational: put: tags: - dmi-plugin @@ -137,7 +137,7 @@ paths: operationId: getResourceDataOperationalForCmHandle parameters: - $ref: 'components.yml#/components/parameters/cmHandleInPath' - - $ref: 'components.yml#/components/parameters/resourceIdentifierInPath' + - $ref: 'components.yml#/components/parameters/resourceIdentifierInQuery' - $ref: 'components.yml#/components/parameters/acceptParamInHeader' - $ref: 'components.yml#/components/parameters/fieldsParamInQuery' - $ref: 'components.yml#/components/parameters/depthParamInQuery' @@ -157,7 +157,7 @@ paths: '403': $ref: 'components.yml#/components/responses/Forbidden' - /v1/ch/{cmHandle}/data/ds/ncmp-datastore:passthrough-running/{resourceIdentifier}: + /v1/ch/{cmHandle}/data/ds/ncmp-datastore:passthrough-running: put: tags: - dmi-plugin @@ -166,7 +166,7 @@ paths: operationId: getResourceDataPassthroughRunningForCmHandle parameters: - $ref: 'components.yml#/components/parameters/cmHandleInPath' - - $ref: 'components.yml#/components/parameters/resourceIdentifierInPath' + - $ref: 'components.yml#/components/parameters/resourceIdentifierInQuery' - $ref: 'components.yml#/components/parameters/acceptParamInHeader' - $ref: 'components.yml#/components/parameters/fieldsParamInQuery' - $ref: 'components.yml#/components/parameters/depthParamInQuery' @@ -194,7 +194,7 @@ paths: operationId: writeDataByPassthroughRunningForCmHandle parameters: - $ref: 'components.yml#/components/parameters/cmHandleInPath' - - $ref: 'components.yml#/components/parameters/resourceIdentifierInPath' + - $ref: 'components.yml#/components/parameters/resourceIdentifierInQuery' requestBody: required: true content: diff --git a/docs/requirements-docs.txt b/docs/requirements-docs.txt index c7912888..5a3d2f17 100644 --- a/docs/requirements-docs.txt +++ b/docs/requirements-docs.txt @@ -1,16 +1 @@ -tox -Sphinx -doc8 -docutils -setuptools -six -sphinx_bootstrap_theme -lfdocs-conf~=0.7.5 -funcparserlib~=1.0.0a0 -sphinxcontrib.blockdiag~=2.0.0 -sphinxcontrib-needs<0.6.0 -sphinxcontrib.plantuml~=0.21 -sphinxcontrib.nwdiag~=2.0.0 -sphinxcontrib-seqdiag~=2.0.0 -sphinxcontrib-swaggerdoc~=0.1.7 -sphinx-rtd-theme~=1.0.0 +lfdocs-conf
\ No newline at end of file diff --git a/docs/tox.ini b/docs/tox.ini index edac8c35..4e9449e2 100644 --- a/docs/tox.ini +++ b/docs/tox.ini @@ -6,6 +6,8 @@ skipsdist = true [testenv:docs] basepython = python3 deps = -r{toxinidir}/requirements-docs.txt + -chttps://git.onap.org/doc/plain/etc/upper-constraints.os.txt + -chttps://git.onap.org/doc/plain/etc/upper-constraints.onap.txt commands = sphinx-build -b html -n -d {envtmpdir}/doctrees ./ {toxinidir}/_build/html echo "Generated docs available in {toxinidir}/_build/html" @@ -16,7 +18,9 @@ whitelist_externals = [testenv:docs-linkcheck] basepython = python3 -#deps = -r{toxinidir}/requirements-docs.txt +deps = -r{toxinidir}/requirements-docs.txt + -chttps://git.onap.org/doc/plain/etc/upper-constraints.os.txt + -chttps://git.onap.org/doc/plain/etc/upper-constraints.onap.txt commands = echo "Link Checking not enforced" #commands = sphinx-build -b linkcheck -d {envtmpdir}/doctrees ./ {toxinidir}/_build/linkcheck whitelist_externals = echo @@ -392,7 +392,7 @@ <plugin> <groupId>com.google.cloud.tools</groupId> <artifactId>jib-maven-plugin</artifactId> - <version>2.8.0</version> + <version>3.1.4</version> <configuration> <container> <mainClass>${app}</mainClass> @@ -425,29 +425,6 @@ </execution> </executions> </plugin> - <plugin> - <artifactId>maven-resources-plugin</artifactId> - <executions> - <execution> - <id>copy-resources</id> - <phase>compile</phase> - <goals> - <goal>copy-resources</goal> - </goals> - <configuration> - <outputDirectory>${project.basedir}/docs/openapi/</outputDirectory> - <resources> - <resource> - <directory>${project.basedir}/target/generated-sources/swagger/</directory> - <includes> - <include>openapi.yaml</include> - </includes> - </resource> - </resources> - </configuration> - </execution> - </executions> - </plugin> </plugins> </pluginManagement> </build> diff --git a/src/main/java/org/onap/cps/ncmp/dmi/rest/controller/DmiRestController.java b/src/main/java/org/onap/cps/ncmp/dmi/rest/controller/DmiRestController.java index 0afefeb0..2c2536ff 100644 --- a/src/main/java/org/onap/cps/ncmp/dmi/rest/controller/DmiRestController.java +++ b/src/main/java/org/onap/cps/ncmp/dmi/rest/controller/DmiRestController.java @@ -82,14 +82,14 @@ public class DmiRestController implements DmiPluginApi, DmiPluginInternalApi { * Write data using passthrough for the given cmHandle. * * @param dataAccessWriteRequest pass through request - * @param cmHandle cmHandle * @param resourceIdentifier resource identifier + * @param cmHandle cmHandle * @return (@ code ResponseEntity) response entity */ @Override public ResponseEntity<String> writeDataByPassthroughRunningForCmHandle( final DataAccessWriteRequest dataAccessWriteRequest, - final String cmHandle, final String resourceIdentifier) { + final String resourceIdentifier, final String cmHandle) { final String response = dmiService.writeResourceDataPassthroughForCmHandle(cmHandle, resourceIdentifier, MediaType.APPLICATION_JSON_VALUE, @@ -116,8 +116,8 @@ public class DmiRestController implements DmiPluginApi, DmiPluginInternalApi { * This method fetches the resource for given cm handle using pass through operational. It filters the response on * the basis of depth and field query parameters and returns response. * - * @param cmHandle cm handle identifier * @param resourceIdentifier resource identifier to fetch data + * @param cmHandle cm handle identifier * @param dataAccessReadRequest data Access Read Request * @param accept accept header parameter * @param fields fields to filter the response data @@ -125,8 +125,8 @@ public class DmiRestController implements DmiPluginApi, DmiPluginInternalApi { * @return {@code ResponseEntity} response entity */ @Override - public ResponseEntity<Object> getResourceDataOperationalForCmHandle(final String cmHandle, - final String resourceIdentifier, + public ResponseEntity<Object> getResourceDataOperationalForCmHandle(final String resourceIdentifier, + final String cmHandle, final @Valid DataAccessReadRequest dataAccessReadRequest, final String accept, final @Valid String fields, @@ -144,8 +144,8 @@ public class DmiRestController implements DmiPluginApi, DmiPluginInternalApi { * This method fetches the resource for given cm handle using pass through running. It filters the response on the * basis of depth and field query parameters and returns response. * - * @param cmHandle cm handle identifier * @param resourceIdentifier resource identifier to fetch data + * @param cmHandle cm handle identifier * @param dataAccessReadRequest data Access Read Request * @param accept accept header parameter * @param fields fields to filter the response data @@ -153,8 +153,8 @@ public class DmiRestController implements DmiPluginApi, DmiPluginInternalApi { * @return {@code ResponseEntity} response entity */ @Override - public ResponseEntity<Object> getResourceDataPassthroughRunningForCmHandle(final String cmHandle, - final String resourceIdentifier, + public ResponseEntity<Object> getResourceDataPassthroughRunningForCmHandle(final String resourceIdentifier, + final String cmHandle, final @Valid DataAccessReadRequest dataAccessReadRequest, final String accept, final @Valid String fields, diff --git a/src/test/groovy/org/onap/cps/ncmp/dmi/rest/controller/DmiRestControllerSpec.groovy b/src/test/groovy/org/onap/cps/ncmp/dmi/rest/controller/DmiRestControllerSpec.groovy index 8aebbca2..256db4e9 100644 --- a/src/test/groovy/org/onap/cps/ncmp/dmi/rest/controller/DmiRestControllerSpec.groovy +++ b/src/test/groovy/org/onap/cps/ncmp/dmi/rest/controller/DmiRestControllerSpec.groovy @@ -20,7 +20,6 @@ package org.onap.cps.ncmp.dmi.rest.controller - import com.fasterxml.jackson.databind.ObjectMapper import org.onap.cps.ncmp.dmi.TestUtils import org.onap.cps.ncmp.dmi.exception.DmiException @@ -199,7 +198,7 @@ class DmiRestControllerSpec extends Specification { def 'Get resource data for pass-through operational from cm handle.'() { given: 'Get resource data url' def getResourceDataForCmHandleUrl = "${basePathV1}/ch/some-cmHandle/data/ds/ncmp-datastore:passthrough-operational" + - "/resourceIdentifier?fields=myfields&depth=5" + "?resourceIdentifier=abc/xyz&fields=myfields&depth=5" def json = '{"cmHandleProperties" : { "prop1" : "value1", "prop2" : "value2"}}' when: 'get resource data PUT api is invoked' def response = mvc.perform( @@ -210,7 +209,7 @@ class DmiRestControllerSpec extends Specification { response.status == HttpStatus.OK.value() and: 'dmi service called with get resource data for cm handle' 1 * mockDmiService.getResourceDataOperationalForCmHandle('some-cmHandle', - 'resourceIdentifier', + 'abc/xyz', 'application/json', 'myfields', 5, @@ -219,7 +218,8 @@ class DmiRestControllerSpec extends Specification { def 'Write data using passthrough running for a cm handle using #scenario.'() { given: 'write data for cmHandle url and jsonData' - def writeDataforCmHandlePassthroughRunning = "${basePathV1}/ch/some-cmHandle/data/ds/ncmp-datastore:passthrough-running/some-resourceIdentifier" + def writeDataforCmHandlePassthroughRunning = "${basePathV1}/ch/some-cmHandle/data/ds/ncmp-datastore:passthrough-running" + + "?resourceIdentifier=some-resourceIdentifier" def jsonData = TestUtils.getResourceFileContent(requestBodyFile) and: 'dmi service is called' mockDmiService.writeResourceDataPassthroughForCmHandle('some-cmHandle', @@ -240,10 +240,10 @@ class DmiRestControllerSpec extends Specification { 'data with special chars' | 'dataWithSpecialChar.json'|| 'data with quote \" and new line \n' } - def 'Get resource data for pass-through running from cm handle.'() { + def 'Get resource data for pass-through running from cm handle with #scenario value in resource identifier param.'() { given: 'Get resource data url' def getResourceDataForCmHandleUrl = "${basePathV1}/ch/some-cmHandle/data/ds/ncmp-datastore:passthrough-running" + - "/testResourceIdentifier?fields=testFields&depth=5" + "?resourceIdentifier="+resourceIdentifier+"&fields=testFields&depth=5" def json = '{"cmHandleProperties" : { "prop1" : "value1", "prop2" : "value2"}}' when: 'get resource data PUT api is invoked' def response = mvc.perform( @@ -254,11 +254,20 @@ class DmiRestControllerSpec extends Specification { response.status == HttpStatus.OK.value() and: 'dmi service called with get resource data for cm handle' 1 * mockDmiService.getResourceDataPassThroughRunningForCmHandle('some-cmHandle', - 'testResourceIdentifier', + resourceIdentifier, 'application/json', 'testFields', 5, ['prop1':'value1', 'prop2':'value2']) + where: 'tokens are used in the resource identifier parameter' + scenario | resourceIdentifier + '/' | 'id/with/slashes' + '?' | 'idWith?' + ',' | 'idWith,' + '=' | 'idWith=' + '[]' | 'idWith[]' + '? needs to be encoded as %3F' | 'idWith%3F' + } def getJsonDataForGetModules(operation) { |