Added REST endpoint for data job status 63/138563/6
authorleventecsanyi <levente.csanyi@est.tech>
Wed, 24 Jul 2024 13:42:32 +0000 (15:42 +0200)
committerleventecsanyi <levente.csanyi@est.tech>
Thu, 25 Jul 2024 15:39:52 +0000 (17:39 +0200)
- extended opanapi
- added not-implemented http error for new endpoint
- added testware

Issue-ID: CPS-2295
Signed-off-by: leventecsanyi <levente.csanyi@est.tech>
Change-Id: Ib7aa90da2ec53dd523740ad267919fd2e709e937

dmi-service/openapi/openapi-datajob.yml
dmi-service/src/main/java/org/onap/cps/ncmp/dmi/datajobs/rest/controller/DmiDatajobsRestController.java
dmi-service/src/test/groovy/org/onap/cps/ncmp/dmi/datajobs/rest/controller/DmiDatajobsRestControllerSpec.groovy
docs/api/swagger/openapi-datajob.yaml

index 31a76bb..68ee3ec 100644 (file)
@@ -61,6 +61,19 @@ paths:
       responses:
         "501":
           $ref: '#/components/responses/NotImplemented'
+  /v1/dataJob/{requestId}/dataProducerJob/{dataProducerJobId}/status:
+    get:
+      description: Retrieve the status of a specific data job.
+      operationId: getDataJobStatus
+      parameters:
+        - $ref: '#/components/parameters/requestIdInPath'
+        - $ref: '#/components/parameters/dataProducerJobIdInPath'
+        - $ref: '#/components/parameters/dataProducerIdInQuery'
+      tags:
+        - dmi-datajob
+      responses:
+        "501":
+          $ref: '#/components/responses/NotImplemented'
 
 components:
   parameters:
@@ -72,6 +85,22 @@ components:
       schema:
         example: some-identifier
         type: string
+    dataProducerJobIdInPath:
+      description: Identifier for the data producer job
+      in: path
+      name: dataProducerJobId
+      required: true
+      schema:
+        example: some-producer-job-identifier
+        type: string
+    dataProducerIdInQuery:
+      name: dataProducerId
+      in: query
+      description: Identifier for the data producer
+      required: true
+      schema:
+        type: string
+        example: some-data-producer-identifier
   schemas:
     ErrorMessage:
       type: object
index bbc1c20..8cf9f1f 100644 (file)
@@ -32,7 +32,7 @@ import org.springframework.web.bind.annotation.RestController;
 @RestController
 public class DmiDatajobsRestController implements DmiDatajobApi {
     /**
-     * This method is not implemented for ONAP DMI plugin.
+     * This method is not implemented for ONAP DMI plugin.
      *
      * @param requestId Identifier for the overall Datajob (required)
      * @param subjobReadRequest Operation body (optional)
@@ -46,7 +46,7 @@ public class DmiDatajobsRestController implements DmiDatajobApi {
     }
 
     /**
-     * This method is not implemented for ONAP DMI plugin.
+     * This method is not implemented for ONAP DMI plugin.
      *
      * @param requestId Identifier for the overall Datajob (required)
      * @param subjobWriteRequest Operation body (optional)
@@ -57,4 +57,19 @@ public class DmiDatajobsRestController implements DmiDatajobApi {
                                                                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)
+     * @return ResponseEntity(Void) response entity indicating the method is not implemented
+     */
+    @Override
+    public ResponseEntity<Void> getDataJobStatus(final String requestId,
+                                                 final String dataProducerJobId,
+                                                 final String dataProducerId) {
+        return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
+    }
 }
index c55f53c..69d2ebd 100644 (file)
@@ -30,6 +30,7 @@ import org.springframework.security.test.context.support.WithMockUser
 import org.springframework.test.web.servlet.MockMvc
 import spock.lang.Specification
 
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get
 import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post
 
 @Import(WebSecurityConfig)
@@ -66,4 +67,16 @@ class DmiDatajobsRestControllerSpec extends Specification{
         then: 'response value is Not Implemented'
         response.status == HttpStatus.NOT_IMPLEMENTED.value()
     }
+
+    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"
+        when: 'the request is performed'
+            def response = mvc.perform(
+                    get(getStatus)
+                            .contentType('application/json')
+            ).andReturn().response
+        then: 'response value is Not Implemented'
+            response.status == HttpStatus.NOT_IMPLEMENTED.value()
+    }
 }
index 284b372..a0b6d4f 100644 (file)
@@ -5,25 +5,25 @@ info:
   title: NCMP Data Subjob API
   version: 1.0.0
 servers:
-- url: /dmi
+  - url: /dmi
 tags:
-- description: DMI plugin rest apis
-  name: dmi-datajob
+  - description: DMI plugin rest apis
+    name: dmi-datajob
 paths:
   /v1/readJob/{requestId}:
     post:
       description: Create a read request
       operationId: readDataJob
       parameters:
-      - description: Identifier for the overall Datajob
-        explode: false
-        in: path
-        name: requestId
-        required: true
-        schema:
-          example: some-identifier
-          type: string
-        style: simple
+        - description: Identifier for the overall Datajob
+          explode: false
+          in: path
+          name: requestId
+          required: true
+          schema:
+            example: some-identifier
+            type: string
+          style: simple
       requestBody:
         content:
           application/3gpp-json-patch+json:
@@ -42,21 +42,21 @@ paths:
                 $ref: '#/components/schemas/ErrorMessage'
           description: Not Implemented
       tags:
-      - dmi-datajob
+        - dmi-datajob
   /v1/writeJob/{requestId}:
     post:
       description: Create a write request
       operationId: writeDataJob
       parameters:
-      - description: Identifier for the overall Datajob
-        explode: false
-        in: path
-        name: requestId
-        required: true
-        schema:
-          example: some-identifier
-          type: string
-        style: simple
+        - description: Identifier for the overall Datajob
+          explode: false
+          in: path
+          name: requestId
+          required: true
+          schema:
+            example: some-identifier
+            type: string
+          style: simple
       requestBody:
         content:
           application/3gpp-json-patch+json:
@@ -75,7 +75,52 @@ paths:
                 $ref: '#/components/schemas/ErrorMessage'
           description: Not Implemented
       tags:
-      - dmi-datajob
+        - dmi-datajob
+  /v1/dataJob/{requestId}/dataProducerJob/{dataProducerJobId}/status:
+    get:
+      description: Retrieve the status of a specific data job.
+      operationId: getDataJobStatus
+      parameters:
+        - description: Identifier for the overall Datajob
+          explode: false
+          in: path
+          name: requestId
+          required: true
+          schema:
+            example: some-identifier
+            type: string
+          style: simple
+        - description: Identifier for the data producer job
+          explode: false
+          in: path
+          name: dataProducerJobId
+          required: true
+          schema:
+            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:
+            application/json:
+              example:
+                status: 501
+                message: Not Implemented
+                details: Method Not Implemented
+              schema:
+                $ref: '#/components/schemas/ErrorMessage'
+          description: Not Implemented
+      tags:
+        - dmi-datajob
 components:
   parameters:
     requestIdInPath:
@@ -88,6 +133,26 @@ components:
         example: some-identifier
         type: string
       style: simple
+    dataProducerJobIdInPath:
+      description: Identifier for the data producer job
+      explode: false
+      in: path
+      name: dataProducerJobId
+      required: true
+      schema:
+        example: some-producer-job-identifier
+        type: string
+      style: simple
+    dataProducerIdInQuery:
+      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:
     NotImplemented:
       content:
@@ -137,8 +202,8 @@ components:
             $ref: '#/components/schemas/SubjobReadRequest_data_inner'
           type: array
       required:
-      - data
-      - dataProducerId
+        - data
+        - dataProducerId
       type: object
     SubjobWriteRequest:
       properties:
@@ -167,8 +232,8 @@ components:
             $ref: '#/components/schemas/SubjobWriteRequest_data_inner'
           type: array
       required:
-      - data
-      - dataProducerId
+        - data
+        - dataProducerId
       type: object
     CmHandleProperties:
       description: Private properties of the cm handle for the given path
@@ -194,6 +259,26 @@ components:
       type: object
     Object:
       type: object
+    SubjobWriteResponse:
+      properties:
+        subJobId:
+          description: Unique identifier for the sub-job
+          example: my-sub-job-id
+          type: string
+        dmiServiceName:
+          description: Name of the relevant DMI Service
+          example: my-dmi-service
+          type: string
+        dataProducerId:
+          description: ID of the producer registered by DMI for the paths in the operations
+            in this request
+          example: my-data-producer-identifier
+          type: string
+      required:
+        - dataProducerId
+        - dmiServiceName
+        - subJobId
+      type: object
     SubjobReadRequest_data_inner:
       properties:
         path:
@@ -244,16 +329,16 @@ components:
           description: Private properties of the cm handle for the given path
           type: object
       required:
-      - op
-      - path
+        - op
+        - path
       type: object
     SubjobWriteRequest_data_inner_value:
       description: Value dependent on the op specified. Resource for an add. Object
         for a replace. ActionParameters for an action.
       oneOf:
-      - $ref: '#/components/schemas/Resource'
-      - $ref: '#/components/schemas/ActionParameters'
-      - $ref: '#/components/schemas/Object'
+        - $ref: '#/components/schemas/Resource'
+        - $ref: '#/components/schemas/ActionParameters'
+        - $ref: '#/components/schemas/Object'
       type: object
     SubjobWriteRequest_data_inner:
       properties:
@@ -279,25 +364,6 @@ components:
         value:
           $ref: '#/components/schemas/SubjobWriteRequest_data_inner_value'
       required:
-      - op
-      - path
+        - op
+        - path
       type: object
-    SubjobWriteResponse:
-      type: object
-      required:
-        - subJobId
-        - dmiServiceName
-        - dataProducerId
-      properties:
-        subJobId:
-          description: Unique identifier for the sub-job
-          example: my-sub-job-id
-          type: string
-        dmiServiceName:
-          description: Name of the relevant DMI Service
-          example: my-dmi-service
-          type: string
-        dataProducerId:
-          description: ID of the producer registered by DMI for the paths in the operations in this request
-          example: my-data-producer-identifier
-          type: string