aboutsummaryrefslogtreecommitdiffstats
path: root/cps-ncmp-rest
diff options
context:
space:
mode:
authortragait <rahul.tyagi@est.tech>2021-10-06 11:04:18 +0100
committertragait <rahul.tyagi@est.tech>2021-10-07 09:58:01 +0100
commitabdff1bf331cc582d017cce9888828fa2e8f6260 (patch)
tree5974fdc5780105696988ac3e71a2412355537a03 /cps-ncmp-rest
parentf3798ee9857edb45243d540606ceac21df1215ab (diff)
fix fields and depth to option query
Issue-ID: CPS-678 Signed-off-by: tragait <rahul.tyagi@est.tech> Change-Id: I8934bd7708ae51dce77b8684081a71ca57bfa3a4
Diffstat (limited to 'cps-ncmp-rest')
-rw-r--r--cps-ncmp-rest/docs/openapi/components.yaml25
-rwxr-xr-xcps-ncmp-rest/docs/openapi/ncmproxy.yml6
-rwxr-xr-xcps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java34
-rw-r--r--cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyControllerSpec.groovy10
4 files changed, 34 insertions, 41 deletions
diff --git a/cps-ncmp-rest/docs/openapi/components.yaml b/cps-ncmp-rest/docs/openapi/components.yaml
index 560c945dd7..d35919da4b 100644
--- a/cps-ncmp-rest/docs/openapi/components.yaml
+++ b/cps-ncmp-rest/docs/openapi/components.yaml
@@ -133,21 +133,24 @@ components:
schema:
type: string
enum: [ application/json, application/yang-data+json ]
- fieldsParamInQuery:
- name: fields
+ optionsParamInQuery:
+ name: options
in: query
- description: Fields parameter to filter resource
+ description: options parameter in query, it is mandatory to wrap key(s)=value(s) in parenthesis'()'.
required: false
schema:
type: string
- depthParamInQuery:
- name: depth
- in: query
- description: Depth parameter for response
- required: false
- schema:
- type: integer
- minimum: 1
+ allowReserved: true
+ examples:
+ sample1:
+ value:
+ options: (key1=value1,key2=value2)
+ sample2:
+ value:
+ options: (key1=value1,key2=value1/value2)
+ sample3:
+ value:
+ options: (key1=10,key2=value2,key3=[val31;val32])
contentParamInHeader:
name: Content-Type
in: header
diff --git a/cps-ncmp-rest/docs/openapi/ncmproxy.yml b/cps-ncmp-rest/docs/openapi/ncmproxy.yml
index 263c76c134..5a45a5c837 100755
--- a/cps-ncmp-rest/docs/openapi/ncmproxy.yml
+++ b/cps-ncmp-rest/docs/openapi/ncmproxy.yml
@@ -213,8 +213,7 @@ getResourceDataForPassthroughOperational:
- $ref: 'components.yaml#/components/parameters/cmHandleInPath'
- $ref: 'components.yaml#/components/parameters/resourceIdentifierInQuery'
- $ref: 'components.yaml#/components/parameters/acceptParamInHeader'
- - $ref: 'components.yaml#/components/parameters/fieldsParamInQuery'
- - $ref: 'components.yaml#/components/parameters/depthParamInQuery'
+ - $ref: 'components.yaml#/components/parameters/optionsParamInQuery'
responses:
200:
$ref: 'components.yaml#/components/responses/Ok'
@@ -238,8 +237,7 @@ resourceDataForPassthroughRunning:
- $ref: 'components.yaml#/components/parameters/cmHandleInPath'
- $ref: 'components.yaml#/components/parameters/resourceIdentifierInQuery'
- $ref: 'components.yaml#/components/parameters/acceptParamInHeader'
- - $ref: 'components.yaml#/components/parameters/fieldsParamInQuery'
- - $ref: 'components.yaml#/components/parameters/depthParamInQuery'
+ - $ref: 'components.yaml#/components/parameters/optionsParamInQuery'
responses:
200:
$ref: 'components.yaml#/components/responses/Ok'
diff --git a/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java b/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java
index 0a1a6419e7..4a9527a832 100755
--- a/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java
+++ b/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java
@@ -157,22 +157,19 @@ public class NetworkCmProxyController implements NetworkCmProxyApi {
*
* @param cmHandle cm handle identifier
* @param resourceIdentifier resource identifier
- * @param accept accept header parameter
- * @param fields fields query parameter
- * @param depth depth query parameter
+ * @param acceptParamInHeader accept header parameter
+ * @param optionsParamInQuery options query parameter
* @return {@code ResponseEntity} response from dmi plugin
*/
@Override
public ResponseEntity<Object> getResourceDataOperationalForCmHandle(final String cmHandle,
- final String resourceIdentifier,
- final String accept,
- final String fields,
- final Integer depth) {
+ final @NotNull @Valid String resourceIdentifier,
+ final String acceptParamInHeader,
+ final @Valid String optionsParamInQuery) {
final Object responseObject = networkCmProxyDataService.getResourceDataOperationalForCmHandle(cmHandle,
resourceIdentifier,
- accept,
- fields,
- depth);
+ acceptParamInHeader,
+ optionsParamInQuery);
return ResponseEntity.ok(responseObject);
}
@@ -181,22 +178,19 @@ public class NetworkCmProxyController implements NetworkCmProxyApi {
*
* @param cmHandle cm handle identifier
* @param resourceIdentifier resource identifier
- * @param accept accept header parameter
- * @param fields fields query parameter
- * @param depth depth query parameter
+ * @param acceptParamInHeader accept header parameter
+ * @param optionsParamInQuery options query parameter
* @return {@code ResponseEntity} response from dmi plugin
*/
@Override
public ResponseEntity<Object> getResourceDataRunningForCmHandle(final String cmHandle,
- final String resourceIdentifier,
- final String accept,
- final String fields,
- final Integer depth) {
+ final @NotNull @Valid String resourceIdentifier,
+ final String acceptParamInHeader,
+ final @Valid String optionsParamInQuery) {
final Object responseObject = networkCmProxyDataService.getResourceDataPassThroughRunningForCmHandle(cmHandle,
resourceIdentifier,
- accept,
- fields,
- depth);
+ acceptParamInHeader,
+ optionsParamInQuery);
return ResponseEntity.ok(responseObject);
}
diff --git a/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyControllerSpec.groovy b/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyControllerSpec.groovy
index d62ae93b09..b8c68d913b 100644
--- a/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyControllerSpec.groovy
+++ b/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyControllerSpec.groovy
@@ -193,7 +193,7 @@ class NetworkCmProxyControllerSpec extends Specification {
def 'Get Resource Data from pass-through operational.' () {
given: 'resource data url'
def getUrl = "$ncmpBasePathV1/ch/testCmHandle/data/ds/ncmp-datastore:passthrough-operational" +
- "?resourceIdentifier=parent/child&fields=testFields&depth=5"
+ "?resourceIdentifier=parent/child&options=(a=1,b=2)"
when: 'get data resource request is performed'
def response = mvc.perform(
get(getUrl)
@@ -204,8 +204,7 @@ class NetworkCmProxyControllerSpec extends Specification {
1 * mockNetworkCmProxyDataService.getResourceDataOperationalForCmHandle('testCmHandle',
'parent/child',
'application/json',
- 'testFields',
- 5)
+ '(a=1,b=2)')
and: 'response status is Ok'
response.status == HttpStatus.OK.value()
}
@@ -213,13 +212,12 @@ class NetworkCmProxyControllerSpec extends Specification {
def 'Get Resource Data from pass-through running with #scenario value in resource identifier param.' () {
given: 'resource data url'
def getUrl = "$ncmpBasePathV1/ch/testCmHandle/data/ds/ncmp-datastore:passthrough-running" +
- "?resourceIdentifier=" + resourceIdentifier + "&fields=testFields&depth=5"
+ "?resourceIdentifier=" + resourceIdentifier + "&options=(a=1,b=2)"
and: 'ncmp service returns json object'
mockNetworkCmProxyDataService.getResourceDataPassThroughRunningForCmHandle('testCmHandle',
resourceIdentifier,
'application/json',
- 'testFields',
- 5) >> '{valid-json}'
+ '(a=1,b=2)') >> '{valid-json}'
when: 'get data resource request is performed'
def response = mvc.perform(
get(getUrl)