From 7272f11fa4a3876cf61451a21916a7244c2d045b Mon Sep 17 00:00:00 2001 From: "raviteja.karumuri" Date: Wed, 24 May 2023 18:23:38 +0100 Subject: DMI-Plugin : Update batch endpoint (move url param into rest body) Issue-ID: CPS-1636 Signed-off-by: raviteja.karumuri Change-Id: I787be1be899a69c0972ccfd17016e67eaf8a771a --- openapi/components.yml | 79 ++++++++++++++++++++++ openapi/openapi.yml | 40 +++++------ .../dmi/rest/controller/DmiRestController.java | 13 ++-- .../rest/controller/DmiRestControllerSpec.groovy | 23 +++---- 4 files changed, 115 insertions(+), 40 deletions(-) diff --git a/openapi/components.yml b/openapi/components.yml index 2bddd8b9..b32130b9 100644 --- a/openapi/components.yml +++ b/openapi/components.yml @@ -49,6 +49,53 @@ components: cmHandleProperties: $ref: '#/components/schemas/cmHandleProperties' + ResourceBatchDataRequest: + type: array + items: + type: object + title: 'ResourceBatchRequest' + properties: + operation: + type: string + example: 'read' + operationId: + description: 'it is recommended that the operationId is unique within the scope of the request' + type: string + example: '12' + datastore: + type: string + example: 'ncmp-datastore:passthrough-operational' + options: + type: string + example: 'some option' + resourceIdentifier: + type: string + example: 'some resource identifier' + cmHandles: + type: array + items: + $ref: '#/components/schemas/cmHandle' + required: + - operation + - operationId + - datastore + - cmHandles + + cmHandle: + type: object + title: 'cmHandle' + properties: + id: + type: string + cmHandleProperties: + additionalProperties: + type: string + example: + id: cmHandle123 + cmHandleProperties: + myProp: some value + otherProp: other value + ModuleResourcesReadRequest: type: object properties: @@ -134,6 +181,7 @@ components: NoContent: description: No Content content: {} + BadRequest: description: Bad Request content: @@ -144,6 +192,7 @@ components: status: 400 message: Bad Request details: The provided request is not valid + NotFound: description: The specified resource was not found content: @@ -154,6 +203,7 @@ components: status: 404 message: Resource Not Found details: The requested resource is not found + ServerError: description: Internal Server Error content: @@ -164,6 +214,7 @@ components: status: 500 message: Internal Server Error details: Internal Server Error occured + NotImplemented: description: Not Implemented content: @@ -174,6 +225,7 @@ components: status: 501 message: Not Implemented details: Method Not Implemented + parameters: cmHandleInPath: name: cmHandle @@ -212,6 +264,7 @@ components: sample3: value: options: (key1=10,key2=value2,key3=val31,val32) + topicParamInQuery: name: topic in: query @@ -223,6 +276,32 @@ components: examples: sample1: value: my-topic-name + + requiredTopicParamInQuery: + name: topic + in: query + description: mandatory topic name passed from client(NCMP). + required: true + schema: + type: string + allowReserved: true + examples: + sample1: + value: + topic: my-topic-name + + requiredRequestIdParamInQuery: + name: requestId + in: query + description: request Id generated by NCMP and sent as an acknowledgement for the client request the same including here. + required: true + schema: + type: string + allowReserved: true + examples: + sample1: + value: 4753fc1f-7de2-449a-b306-a6204b5370b3 + datastoreName: name: datastore-name in: path diff --git a/openapi/openapi.yml b/openapi/openapi.yml index 24854e9c..4bca4108 100644 --- a/openapi/openapi.yml +++ b/openapi/openapi.yml @@ -1,5 +1,5 @@ # ============LICENSE_START======================================================= -# Copyright (C) 2021 Nordix Foundation +# Copyright (C) 2021-2023 Nordix Foundation # Modifications Copyright (C) 2022 Bell Canada # ================================================================================ # Licensed under the Apache License, Version 2.0 (the "License"); @@ -150,32 +150,28 @@ paths: '500': $ref: 'components.yml#/components/responses/ServerError' - /v1/ch/batch/data/ds/{datastore-name}: + /v1/data: post: tags: - dmi-plugin - summary: Get a collection of CMHandles - description: Get a collection of cm handles by datastore (not implemented) - operationId: getResourceDataByCmHandles + summary: Get resource data for batch of cm handle ids. + description: Get resource data for batch of cm handle ids by supplied operation details + operationId: getResourceDataForCmHandleBatch parameters: - - $ref: 'components.yml#/components/parameters/datastoreName' - - $ref: 'components.yml#/components/parameters/topicParamInQuery' + - $ref: 'components.yml#/components/parameters/requiredTopicParamInQuery' + - $ref: 'components.yml#/components/parameters/requiredRequestIdParamInQuery' requestBody: - description: Contains collection of cm handles with it's private properties and requestId - content: - application/json: - schema: - type: object - responses: - '200': - description: OK + description: list of operation details content: application/json: schema: - type: object - '400': - $ref: 'components.yml#/components/responses/BadRequest' - '500': - $ref: 'components.yml#/components/responses/ServerError' - '501': - $ref: 'components.yml#/components/responses/NotImplemented' \ No newline at end of file + $ref: 'components.yml#/components/schemas/ResourceBatchDataRequest' + responses: + '202': + description: Accepted + '400': + $ref: 'components.yml#/components/responses/BadRequest' + '500': + $ref: 'components.yml#/components/responses/ServerError' + '501': + $ref: 'components.yml#/components/responses/NotImplemented' \ No newline at end of file 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 9459d1b1..6a404c6a 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 @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2021-2022 Nordix Foundation + * Copyright (C) 2021-2023 Nordix Foundation * Modifications Copyright (C) 2022 Bell Canada * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -35,6 +35,7 @@ import org.onap.cps.ncmp.dmi.model.DataAccessRequest; import org.onap.cps.ncmp.dmi.model.ModuleReferencesRequest; import org.onap.cps.ncmp.dmi.model.ModuleResourcesReadRequest; import org.onap.cps.ncmp.dmi.model.ModuleSet; +import org.onap.cps.ncmp.dmi.model.ResourceBatchRequest; import org.onap.cps.ncmp.dmi.model.YangResources; import org.onap.cps.ncmp.dmi.notifications.async.AsyncTaskExecutor; import org.onap.cps.ncmp.dmi.rest.api.DmiPluginApi; @@ -106,14 +107,14 @@ public class DmiRestController implements DmiPluginApi, DmiPluginInternalApi { /** * This method is not implemented for ONAP DMI plugin. * - * @param datastoreName name of the data store - * @param topic Kafka topic name - * @param body list of cm-handles + * @param requestId requestId generated by NCMP as an ack for client + * @param topic client given topic name + * @param resourceDataBatchRequest list of operation details * @return (@ code ResponseEntity) response entity */ @Override - public ResponseEntity getResourceDataByCmHandles(final String datastoreName, final String topic, - final Object body) { + public ResponseEntity getResourceDataForCmHandleBatch(final String requestId, final String topic, + final List resourceDataBatchRequest) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } 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 acc8b63b..8499ae25 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 @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2021-2022 Nordix Foundation + * Copyright (C) 2021-2023 Nordix Foundation * Modifications Copyright (C) 2021-2022 Bell Canada * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -312,18 +312,17 @@ class DmiRestControllerSpec extends Specification { } - def 'Get resource data for a collection of cm handles (unimplemented).'() { - given: 'an endpoint for adding a batch of cm handle Ids' - def url = "$basePathV1/ch/batch/data/ds/test-datastore?topic=test" - and: 'a request body' - def body = '{"CmHandles": []}' - when: 'the endpoint is invoked' + def 'Get resource data for a list of operations.'() { + given: 'an endpoint for a batch data request with list of cmhandles in request body' + def resourceDataUrl = "$basePathV1/data?topic=client-topic-name&requestId=some-requestId" + and: 'list of operation details are received into request body' + def batchDataRequestBody = '[{"operation": "read", "operationId": "14", "datastore": "ncmp-datastore:passthrough-operational", "options": "some options", "resourceIdentifier": "some resourceIdentifier",' + + ' "cmhandles": [ {"id": "cmHanlde123", "cmHandleProperties": { "myProp`": "some value", "otherProp": "other value"}}]}]' + when: 'the dmi resource data for batch operation api is called.' def response = mvc.perform( - post(url) - .contentType(MediaType.APPLICATION_JSON) - .content(body) + post(resourceDataUrl).contentType(MediaType.APPLICATION_JSON).content(batchDataRequestBody) ).andReturn().response - then: 'the response status code is 501' + then: 'the batch data endpoint returns the not implemented response' assert response.status == 501 } -} +} \ No newline at end of file -- cgit 1.2.3-korg