summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorleventecsanyi <levente.csanyi@est.tech>2024-08-15 13:52:21 +0200
committerleventecsanyi <levente.csanyi@est.tech>2024-08-15 13:56:31 +0200
commit636c228c5d646e7c919bc5ce135fa2967b3fef5a (patch)
tree26b71946894823dab64a0377060e6b278e7ed705
parent202fc696cdf0a2503b2d5f738f892b8cb5da7bd9 (diff)
Refactored dat job interfaces - result endpoint changed is a separate commit
-changed openapi and stub implementations Issue-ID: CPS-2360 Signed-off-by: leventecsanyi <levente.csanyi@est.tech> Change-Id: Ib7d826f5909278309b7c16dc5caaabbe5f01732b
-rw-r--r--dmi-service/openapi/openapi-datajob.yml25
-rw-r--r--dmi-service/src/main/java/org/onap/cps/ncmp/dmi/datajobs/rest/controller/DmiDatajobsRestController.java15
-rw-r--r--dmi-service/src/test/groovy/org/onap/cps/ncmp/dmi/datajobs/rest/controller/DmiDatajobsRestControllerSpec.groovy6
-rw-r--r--dmi-stub/dmi-plugin-demo-and-csit-stub-service/src/main/java/org/onap/cps/ncmp/dmi/rest/stub/controller/DmiRestStubController.java24
-rw-r--r--docs/api/swagger/openapi-datajob.yaml71
5 files changed, 71 insertions, 70 deletions
diff --git a/dmi-service/openapi/openapi-datajob.yml b/dmi-service/openapi/openapi-datajob.yml
index aa93623c..09e23a9e 100644
--- a/dmi-service/openapi/openapi-datajob.yml
+++ b/dmi-service/openapi/openapi-datajob.yml
@@ -27,12 +27,12 @@ tags:
- description: DMI plugin rest apis
name: dmi-datajob
paths:
- /v1/readJob/{requestId}:
+ /v1/cmreadJob:
post:
description: Create a read request
operationId: readDataJob
parameters:
- - $ref: '#/components/parameters/requestIdInPath'
+ - $ref: '#/components/parameters/destinationInQuery'
requestBody:
description: Operation body
content:
@@ -44,12 +44,12 @@ paths:
responses:
"501":
$ref: '#/components/responses/NotImplemented'
- /v1/writeJob/{requestId}:
+ /v1/cmwriteJob:
post:
description: Create a write request
operationId: writeDataJob
parameters:
- - $ref: '#/components/parameters/requestIdInPath'
+ - $ref: '#/components/parameters/destinationInQuery'
requestBody:
description: Operation body
content:
@@ -61,14 +61,13 @@ paths:
responses:
"501":
$ref: '#/components/responses/NotImplemented'
- /v1/dataJob/{requestId}/dataProducerJob/{dataProducerJobId}/status:
+ /v1/cmwriteJob/dataProducer/{dataProducerId}/dataProducerJob/{dataProducerJobId}/status:
get:
description: Retrieve the status of a specific data job.
operationId: getDataJobStatus
parameters:
- - $ref: '#/components/parameters/requestIdInPath'
+ - $ref: '#/components/parameters/dataProducerIdInPath'
- $ref: '#/components/parameters/dataProducerJobIdInPath'
- - $ref: '#/components/parameters/dataProducerIdInQuery'
tags:
- dmi-datajob
responses:
@@ -107,6 +106,14 @@ components:
schema:
example: some-producer-job-identifier
type: string
+ dataProducerIdInPath:
+ name: dataProducerId
+ in: path
+ description: Identifier for the data producer
+ required: true
+ schema:
+ type: string
+ example: some-data-producer-identifier
dataProducerIdInQuery:
name: dataProducerId
in: query
@@ -227,6 +234,10 @@ components:
description: ID of the producer registered by DMI for the paths in the operations in this request
example: my-data-producer-identifier
type: string
+ dataJobId:
+ description: Identifier for the overall Data Job
+ example: my-data-producer-identifier
+ type: string
data:
example:
op: add
diff --git a/dmi-service/src/main/java/org/onap/cps/ncmp/dmi/datajobs/rest/controller/DmiDatajobsRestController.java b/dmi-service/src/main/java/org/onap/cps/ncmp/dmi/datajobs/rest/controller/DmiDatajobsRestController.java
index 928ec6b6..6ab56f57 100644
--- a/dmi-service/src/main/java/org/onap/cps/ncmp/dmi/datajobs/rest/controller/DmiDatajobsRestController.java
+++ b/dmi-service/src/main/java/org/onap/cps/ncmp/dmi/datajobs/rest/controller/DmiDatajobsRestController.java
@@ -34,13 +34,11 @@ public class DmiDatajobsRestController implements DmiDatajobApi {
/**
* This method is not implemented for ONAP DMI plugin.
*
- * @param requestId Identifier for the overall Datajob (required)
* @param subjobReadRequest Operation body (optional)
* @return (@ code ResponseEntity) Response entity
*/
@Override
- public ResponseEntity<Void> readDataJob(final String requestId,
- final SubjobReadRequest subjobReadRequest) {
+ public ResponseEntity<Void> readDataJob(final String destination, final SubjobReadRequest subjobReadRequest) {
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
}
@@ -48,27 +46,23 @@ public class DmiDatajobsRestController implements DmiDatajobApi {
/**
* This method is not implemented for ONAP DMI plugin.
*
- * @param requestId Identifier for the overall Datajob (required)
* @param subjobWriteRequest Operation body (optional)
* @return (@ code ResponseEntity) Response entity
*/
@Override
- public ResponseEntity<Void> writeDataJob(final String requestId,
- final SubjobWriteRequest subjobWriteRequest) {
+ public ResponseEntity<Void> writeDataJob(final String destination, final SubjobWriteRequest subjobWriteRequest) {
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
}
/**
* This method is not implemented for ONAP DMI plugin.
*
- * @param requestId Identifier for the overall Datajob (required)
* @param dataProducerJobId Identifier for the data producer job (required)
- * @param dataProducerId Identifier for the data producer as a query parameter (required)
+ * @param dataProducerId Identifier for the data producer (required)
* @return ResponseEntity Response entity indicating the method is not implemented
*/
@Override
- public ResponseEntity<Void> getDataJobStatus(final String requestId,
- final String dataProducerJobId,
+ public ResponseEntity<Void> getDataJobStatus(final String dataProducerJobId,
final String dataProducerId) {
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
}
@@ -76,7 +70,6 @@ public class DmiDatajobsRestController implements DmiDatajobApi {
/**
* This method is not implemented for ONAP DMI plugin.
*
- * @param requestId Identifier for the overall Datajob (required)
* @param dataProducerJobId Identifier for the data producer job (required)
* @param dataProducerId Identifier for the data producer as a query parameter (required)
* @param destination The destination of the results, Kafka topic name or s3 bucket name (required)
diff --git a/dmi-service/src/test/groovy/org/onap/cps/ncmp/dmi/datajobs/rest/controller/DmiDatajobsRestControllerSpec.groovy b/dmi-service/src/test/groovy/org/onap/cps/ncmp/dmi/datajobs/rest/controller/DmiDatajobsRestControllerSpec.groovy
index 6c05f6f3..17354e65 100644
--- a/dmi-service/src/test/groovy/org/onap/cps/ncmp/dmi/datajobs/rest/controller/DmiDatajobsRestControllerSpec.groovy
+++ b/dmi-service/src/test/groovy/org/onap/cps/ncmp/dmi/datajobs/rest/controller/DmiDatajobsRestControllerSpec.groovy
@@ -46,7 +46,7 @@ class DmiDatajobsRestControllerSpec extends Specification{
def 'write request should return 501 HTTP Status' () {
given: 'URL to write a data job'
- def getModuleUrl = "${basePathV1}/writeJob/001"
+ def getModuleUrl = "${basePathV1}/cmwriteJob?destination=001"
when: 'the request is posted'
def response = mvc.perform(
post(getModuleUrl)
@@ -58,7 +58,7 @@ class DmiDatajobsRestControllerSpec extends Specification{
def 'read request should return 501 HTTP Status' () {
given: 'URL to write a data job'
- def getModuleUrl = "${basePathV1}/readJob/001"
+ def getModuleUrl = "${basePathV1}/cmreadJob?destination=001"
when: 'the request is posted'
def response = mvc.perform(
post(getModuleUrl)
@@ -70,7 +70,7 @@ class DmiDatajobsRestControllerSpec extends Specification{
def 'get status request should return 501 HTTP Status' () {
given: 'URL to get the status of a data job'
- def getStatus = "${basePathV1}/dataJob/some-identifier/dataProducerJob/some-producer-job-identifier/status?dataProducerId=some-data-producer-identifier"
+ def getStatus = "${basePathV1}/cmwriteJob/dataProducer/data-producer-id/dataProducerJob/data-producerd-job-id}/status"
when: 'the request is performed'
def response = mvc.perform(
get(getStatus)
diff --git a/dmi-stub/dmi-plugin-demo-and-csit-stub-service/src/main/java/org/onap/cps/ncmp/dmi/rest/stub/controller/DmiRestStubController.java b/dmi-stub/dmi-plugin-demo-and-csit-stub-service/src/main/java/org/onap/cps/ncmp/dmi/rest/stub/controller/DmiRestStubController.java
index e06c528d..5218db43 100644
--- a/dmi-stub/dmi-plugin-demo-and-csit-stub-service/src/main/java/org/onap/cps/ncmp/dmi/rest/stub/controller/DmiRestStubController.java
+++ b/dmi-stub/dmi-plugin-demo-and-csit-stub-service/src/main/java/org/onap/cps/ncmp/dmi/rest/stub/controller/DmiRestStubController.java
@@ -264,14 +264,15 @@ public class DmiRestStubController {
/**
* Consume sub-job write requests from NCMP.
*
- * @param requestId requestId generated by NCMP as an ack for client.
* @param subJobWriteRequest contains a collection of write requests and metadata.
+ * @param destination the destination of the results. ( e.g. S3 Bucket).
* @return (@ code ResponseEntity) response for the write request.
*/
- @PostMapping("/v1/writeJob/{requestId}")
- public ResponseEntity<SubjobWriteResponse> consumeWriteSubJobs(@PathVariable("requestId") final String requestId,
- @RequestBody final SubjobWriteRequest subJobWriteRequest) {
- log.debug("Request ID: {}", requestId);
+ @PostMapping("/v1/cmwriteJob")
+ public ResponseEntity<SubjobWriteResponse> consumeWriteSubJobs(
+ @RequestBody final SubjobWriteRequest subJobWriteRequest,
+ @RequestParam("destination") final String destination) {
+ log.debug("Destination: {}", destination);
log.debug("Request body: {}", subJobWriteRequest);
return ResponseEntity.ok(new SubjobWriteResponse(String.valueOf(subJobWriteRequestCounter.incrementAndGet()),
"some-dmi-service-name", "my-data-producer-id"));
@@ -280,17 +281,18 @@ public class DmiRestStubController {
/**
* Retrieves the status of a given data job identified by {@code requestId} and {@code dataProducerJobId}.
*
- * @param requestId Unique identifier for the outgoing request.
+ * @param dataProducerId ID of the producer registered by DMI for the alternateIDs
+ * in the operations in this request.
* @param dataProducerJobId Identifier of the data producer job.
* @return A ResponseEntity with HTTP status 200 (OK) and the data job's status as a string.
*/
- @GetMapping("/v1/dataJob/{requestId}/dataProducerJob/{dataProducerJobId}/status")
- public ResponseEntity<String> retrieveDataJobStatus(
- @PathVariable("requestId") final String requestId,
+ @GetMapping("/v1/cmwriteJob/dataProducer/{dataProducerId}/dataProducerJob/{dataProducerJobId}/status")
+ public ResponseEntity<Map<String, String>> retrieveDataJobStatus(
+ @PathVariable("dataProducerId") final String dataProducerId,
@PathVariable("dataProducerJobId") final String dataProducerJobId) {
log.info("Received request to retrieve data job status. Request ID: {}, Data Producer Job ID: {}",
- requestId, dataProducerJobId);
- return ResponseEntity.ok("FINISHED");
+ dataProducerId, dataProducerJobId);
+ return ResponseEntity.ok(Map.of("status", "FINISHED"));
}
/**
diff --git a/docs/api/swagger/openapi-datajob.yaml b/docs/api/swagger/openapi-datajob.yaml
index 18efbc38..ea2c3a9e 100644
--- a/docs/api/swagger/openapi-datajob.yaml
+++ b/docs/api/swagger/openapi-datajob.yaml
@@ -10,20 +10,20 @@ tags:
- description: DMI plugin rest apis
name: dmi-datajob
paths:
- /v1/readJob/{requestId}:
+ /v1/cmreadJob:
post:
description: Create a read request
operationId: readDataJob
parameters:
- - description: Identifier for the overall Datajob
- explode: false
- in: path
- name: requestId
+ - description: The destination of the results (Kafka topic name or s3 bucket
+ name)
+ in: query
+ name: destination
required: true
schema:
- example: some-identifier
+ example: some-destination
type: string
- style: simple
+ style: form
requestBody:
content:
application/3gpp-json-patch+json:
@@ -43,20 +43,20 @@ paths:
description: Not Implemented
tags:
- dmi-datajob
- /v1/writeJob/{requestId}:
+ /v1/cmwriteJob:
post:
description: Create a write request
operationId: writeDataJob
parameters:
- - description: Identifier for the overall Datajob
- explode: false
- in: path
- name: requestId
+ - description: The destination of the results (Kafka topic name or s3 bucket
+ name)
+ in: query
+ name: destination
required: true
schema:
- example: some-identifier
+ example: some-destination
type: string
- style: simple
+ style: form
requestBody:
content:
application/3gpp-json-patch+json:
@@ -76,22 +76,20 @@ paths:
description: Not Implemented
tags:
- dmi-datajob
- /v1/dataJob/{requestId}/dataProducerJob/{dataProducerJobId}/status:
+ /v1/cmwriteJob/dataProducer/{dataProducerId}/dataProducerJob/{dataProducerJobId}/status:
get:
description: Retrieve the status of a specific data job.
operationId: getDataJobStatus
parameters:
- - description: Identifier for the overall Datajob
- explode: false
+ - description: Identifier for the data producer
in: path
- name: requestId
+ name: dataProducerId
required: true
schema:
- example: some-identifier
+ example: some-data-producer-identifier
type: string
style: simple
- description: Identifier for the data producer job
- explode: false
in: path
name: dataProducerJobId
required: true
@@ -99,15 +97,6 @@ paths:
example: some-producer-job-identifier
type: string
style: simple
- - description: Identifier for the data producer
- explode: true
- in: query
- name: dataProducerId
- required: true
- schema:
- example: some-data-producer-identifier
- type: string
- style: form
responses:
"501":
content:
@@ -127,7 +116,6 @@ paths:
operationId: getDataJobResult
parameters:
- description: Identifier for the overall Datajob
- explode: false
in: path
name: requestId
required: true
@@ -136,7 +124,6 @@ paths:
type: string
style: simple
- description: Identifier for the data producer job
- explode: false
in: path
name: dataProducerJobId
required: true
@@ -145,7 +132,6 @@ paths:
type: string
style: simple
- description: Identifier for the data producer
- explode: true
in: query
name: dataProducerId
required: true
@@ -153,8 +139,8 @@ paths:
example: some-data-producer-identifier
type: string
style: form
- - description: The destination of the results (Kafka topic name or s3 bucket name)
- explode: true
+ - description: The destination of the results (Kafka topic name or s3 bucket
+ name)
in: query
name: destination
required: true
@@ -179,7 +165,6 @@ components:
parameters:
requestIdInPath:
description: Identifier for the overall Datajob
- explode: false
in: path
name: requestId
required: true
@@ -189,7 +174,6 @@ components:
style: simple
dataProducerJobIdInPath:
description: Identifier for the data producer job
- explode: false
in: path
name: dataProducerJobId
required: true
@@ -197,9 +181,17 @@ components:
example: some-producer-job-identifier
type: string
style: simple
+ dataProducerIdInPath:
+ description: Identifier for the data producer
+ in: path
+ name: dataProducerId
+ required: true
+ schema:
+ example: some-data-producer-identifier
+ type: string
+ style: simple
dataProducerIdInQuery:
description: Identifier for the data producer
- explode: true
in: query
name: dataProducerId
required: true
@@ -209,7 +201,6 @@ components:
style: form
destinationInQuery:
description: The destination of the results (Kafka topic name or s3 bucket name)
- explode: true
in: query
name: destination
required: true
@@ -284,6 +275,10 @@ components:
in this request
example: my-data-producer-identifier
type: string
+ dataJobId:
+ description: Identifier for the overall Data Job
+ example: my-data-producer-identifier
+ type: string
data:
example:
op: add