diff options
author | leventecsanyi <levente.csanyi@est.tech> | 2024-07-18 13:45:35 +0200 |
---|---|---|
committer | leventecsanyi <levente.csanyi@est.tech> | 2024-07-19 14:19:49 +0200 |
commit | aa4d6e27a7488ff06aae8b97aac9b45d3e4d3bfe (patch) | |
tree | ceee4cca9f8e480fb1c41d26666fe352f6097354 | |
parent | 0fe1b63d10a6ce4ec452d2089b9ffe101acd38f8 (diff) |
Added DataJob related stub implementations
- updated pom.xml
- added dataJob related code to DMI Stub controller
- uplifted swagger core dependency
Issue-ID: CPS-2323
Signed-off-by: leventecsanyi <levente.csanyi@est.tech>
Change-Id: If30e1fad31daec004ad67dd3f2be1815aeb538b2
-rw-r--r-- | dmi-service/openapi/openapi-datajob.yml | 20 | ||||
-rw-r--r-- | dmi-service/pom.xml | 2 | ||||
-rw-r--r-- | dmi-stub/dmi-plugin-demo-and-csit-stub-service/pom.xml | 5 | ||||
-rw-r--r-- | dmi-stub/dmi-plugin-demo-and-csit-stub-service/src/main/java/org/onap/cps/ncmp/dmi/rest/stub/controller/DmiRestStubController.java | 36 | ||||
-rw-r--r-- | dmi-stub/pom.xml | 62 | ||||
-rw-r--r-- | docs/api/swagger/openapi-datajob.yaml | 19 |
6 files changed, 135 insertions, 9 deletions
diff --git a/dmi-service/openapi/openapi-datajob.yml b/dmi-service/openapi/openapi-datajob.yml index 989218d9..31a76bbd 100644 --- a/dmi-service/openapi/openapi-datajob.yml +++ b/dmi-service/openapi/openapi-datajob.yml @@ -240,6 +240,25 @@ components: type: string Object: 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 responses: NotImplemented: description: Not Implemented @@ -251,4 +270,3 @@ components: status: 501 message: Not Implemented details: Method Not Implemented - diff --git a/dmi-service/pom.xml b/dmi-service/pom.xml index 033fd53d..a2a1f054 100644 --- a/dmi-service/pom.xml +++ b/dmi-service/pom.xml @@ -44,7 +44,7 @@ <dependency> <groupId>io.swagger.core.v3</groupId> <artifactId>swagger-annotations</artifactId> - <version>2.2.10</version> + <version>2.2.22</version> </dependency> <dependency> <groupId>io.cloudevents</groupId> diff --git a/dmi-stub/dmi-plugin-demo-and-csit-stub-service/pom.xml b/dmi-stub/dmi-plugin-demo-and-csit-stub-service/pom.xml index 78b56852..7118a616 100644 --- a/dmi-stub/dmi-plugin-demo-and-csit-stub-service/pom.xml +++ b/dmi-stub/dmi-plugin-demo-and-csit-stub-service/pom.xml @@ -93,6 +93,11 @@ <artifactId>cps-ncmp-events</artifactId> <version>3.4.9</version> </dependency> + <dependency> + <groupId>io.swagger.core.v3</groupId> + <artifactId>swagger-annotations</artifactId> + </dependency> + <!-- T E S T D E P E N D E N C I E S --> <dependency> <groupId>org.spockframework</groupId> 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 d97173ce..b8b46f06 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 @@ -32,11 +32,14 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.UUID; +import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Collectors; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.json.simple.parser.JSONParser; import org.json.simple.parser.ParseException; +import org.onap.cps.ncmp.dmi.datajobs.model.SubjobWriteRequest; +import org.onap.cps.ncmp.dmi.datajobs.model.SubjobWriteResponse; import org.onap.cps.ncmp.dmi.rest.stub.model.data.operational.DataOperationRequest; import org.onap.cps.ncmp.dmi.rest.stub.model.data.operational.DmiDataOperationRequest; import org.onap.cps.ncmp.dmi.rest.stub.model.data.operational.DmiOperationCmHandle; @@ -86,6 +89,7 @@ public class DmiRestStubController { private long readDataForCmHandleDelayMs; @Value("${delay.write-data-for-cm-handle-delay-ms}") private long writeDataForCmHandleDelayMs; + private AtomicInteger subJobWriteRequestCounter; /** * This code defines a REST API endpoint for adding new the module set tag mapping. The endpoint receives the @@ -257,6 +261,38 @@ public class DmiRestStubController { return new ResponseEntity<>(HttpStatus.ACCEPTED); } + /** + * 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. + * @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); + log.debug("Request body: {}", subJobWriteRequest); + return ResponseEntity.ok(new SubjobWriteResponse(String.valueOf(subJobWriteRequestCounter.incrementAndGet()), + "some-dmi-service-name", "my-data-producer-id")); + } + + /** + * Retrieves the status of a given data job identified by {@code requestId} and {@code dataProducerJobId}. + * + * @param requestId Unique identifier for the outgoing 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, + @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"); + } + private CloudEvent buildAndGetCloudEvent(final String topic, final String requestId, final DataOperationEvent dataOperationEvent) { CloudEvent cloudEvent = null; diff --git a/dmi-stub/pom.xml b/dmi-stub/pom.xml index 379d873d..17def900 100644 --- a/dmi-stub/pom.xml +++ b/dmi-stub/pom.xml @@ -41,13 +41,61 @@ </modules> <dependencyManagement> <dependencies> - <dependency> - <groupId>org.onap.cps</groupId> - <artifactId>cps-dependencies</artifactId> - <version>3.5.1</version> - <type>pom</type> - <scope>import</scope> - </dependency> + <dependency> + <groupId>org.onap.cps</groupId> + <artifactId>cps-dependencies</artifactId> + <version>3.5.1</version> + <type>pom</type> + <scope>import</scope> + </dependency> </dependencies> </dependencyManagement> +<build> + <plugins> + <plugin> + <groupId>org.openapitools</groupId> + <artifactId>openapi-generator-maven-plugin</artifactId> + <version>6.6.0</version> + <executions> + <execution> + <id>code-gen</id> + <goals> + <goal>generate</goal> + </goals> + <configuration> + <inputSpec>${maven.multiModuleProjectDirectory}/docs/api/swagger/openapi-datajob.yaml</inputSpec> + <modelPackage>org.onap.cps.ncmp.dmi.datajobs.model</modelPackage> + <apiPackage>org.onap.cps.ncmp.dmi.datajobs.rest.api</apiPackage> + <generatorName>spring</generatorName> + <generateSupportingFiles>false</generateSupportingFiles> + <configOptions> + <sourceFolder>src/gen/java</sourceFolder> + <dateLibrary>java11</dateLibrary> + <interfaceOnly>true</interfaceOnly> + <useSpringBoot3>true</useSpringBoot3> + <useTags>true</useTags> + <openApiNullable>false</openApiNullable> + <skipDefaultInterface>true</skipDefaultInterface> + </configOptions> + </configuration> + </execution> + <execution> + <id>openapi-yaml-gen</id> + <goals> + <goal>generate</goal> + </goals> + <phase>compile</phase> + <configuration> + <inputSpec>${maven.multiModuleProjectDirectory}/docs/api/swagger/openapi-datajob.yaml</inputSpec> + <generatorName>openapi-yaml</generatorName> + <configOptions> + <outputFile>openapi-datajob.yaml</outputFile> + </configOptions> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> + </project>
\ No newline at end of file diff --git a/docs/api/swagger/openapi-datajob.yaml b/docs/api/swagger/openapi-datajob.yaml index e58591e0..284b372e 100644 --- a/docs/api/swagger/openapi-datajob.yaml +++ b/docs/api/swagger/openapi-datajob.yaml @@ -282,3 +282,22 @@ components: - 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 |