Include ProvMnS interface on ONAP-DMI 63/141563/1
authorseanbeirne <sean.beirne@est.tech>
Mon, 21 Jul 2025 15:14:20 +0000 (16:14 +0100)
committerseanbeirne <sean.beirne@est.tech>
Mon, 21 Jul 2025 15:17:01 +0000 (16:17 +0100)
- DMI-stub will be completed on seperate patch
- ONAP-DMI will only return 501 NOT_IMPLEMENTED

Issue-ID: CPS-2737
Change-Id: Ibf76130734c7293b4b063a9ab6319796fb023771
Signed-off-by: seanbeirne <sean.beirne@est.tech>
dmi-service/.openapi-generator-ignore-provmns [new file with mode: 0644]
dmi-service/pom.xml
dmi-service/src/main/java/org/onap/cps/ncmp/dmi/provmns/model/ClassNameIdGetDataNodeSelectorParameter.java [new file with mode: 0644]
dmi-service/src/main/java/org/onap/cps/ncmp/dmi/provmns/model/Resource.java [new file with mode: 0644]
dmi-service/src/main/java/org/onap/cps/ncmp/dmi/rest/controller/ProvMnsController.java [new file with mode: 0644]
dmi-service/src/main/resources/application.yml
dmi-service/src/test/groovy/org/onap/cps/ncmp/dmi/rest/controller/ProvMnsControllerSpec.groovy [new file with mode: 0644]
dmi-service/src/test/resources/application.yml

diff --git a/dmi-service/.openapi-generator-ignore-provmns b/dmi-service/.openapi-generator-ignore-provmns
new file mode 100644 (file)
index 0000000..b69e17b
--- /dev/null
@@ -0,0 +1,16 @@
+# Ignore generation of all the models for ProvMns
+target/generated-sources/openapi/src/gen/java/org/onap/cps/ncmp/dmi/provmns/model/*.java
+
+# Allow generation of the below model for ProvMns
+!target/generated-sources/openapi/src/gen/java/org/onap/cps/ncmp/dmi/provmns/model/ClassNameIdPatchDefaultResponse.java
+!target/generated-sources/openapi/src/gen/java/org/onap/cps/ncmp/dmi/provmns/model/ErrorResponseDefault.java
+!target/generated-sources/openapi/src/gen/java/org/onap/cps/ncmp/dmi/provmns/model/ErrorResponseDefaultOtherProblemsInner.java
+!target/generated-sources/openapi/src/gen/java/org/onap/cps/ncmp/dmi/provmns/model/ErrorResponseGet.java
+!target/generated-sources/openapi/src/gen/java/org/onap/cps/ncmp/dmi/provmns/model/ErrorResponseGetOtherProblemsInner.java
+!target/generated-sources/openapi/src/gen/java/org/onap/cps/ncmp/dmi/provmns/model/ErrorResponsePatch.java
+!target/generated-sources/openapi/src/gen/java/org/onap/cps/ncmp/dmi/provmns/model/ErrorResponsePatchOtherProblemsInner.java
+!target/generated-sources/openapi/src/gen/java/org/onap/cps/ncmp/dmi/provmns/model/PatchItem.java
+!target/generated-sources/openapi/src/gen/java/org/onap/cps/ncmp/dmi/provmns/model/PatchOperation.java
+!target/generated-sources/openapi/src/gen/java/org/onap/cps/ncmp/dmi/provmns/model/ResourceOneOf.java
+!target/generated-sources/openapi/src/gen/java/org/onap/cps/ncmp/dmi/provmns/model/Scope.java
+!target/generated-sources/openapi/src/gen/java/org/onap/cps/ncmp/dmi/provmns/model/ScopeType.java
\ No newline at end of file
index 463b14f..8ea98b2 100644 (file)
                             </configOptions>
                         </configuration>
                     </execution>
+                    <execution>
+                        <id>dmi-code-gen-provmns</id>
+                        <goals>
+                            <goal>generate</goal>
+                        </goals>
+                        <configuration>
+                            <inputSpec>https://forge.3gpp.org/rep/all/5G_APIs/-/raw/REL-18/TS28532_ProvMnS.yaml</inputSpec>
+                            <invokerPackage>org.onap.cps.ncmp.dmi.provmns.rest.controller</invokerPackage>
+                            <modelPackage>org.onap.cps.ncmp.dmi.provmns.model</modelPackage>
+                            <apiPackage>org.onap.cps.ncmp.dmi.provmns.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>
+                            <importMappings>
+                                <importMapping>Resource=org.onap.cps.ncmp.dmi.provmns.model.Resource</importMapping>
+                                <importMapping>ClassNameIdGetDataNodeSelectorParameter=org.onap.cps.ncmp.dmi.provmns.model.ClassNameIdGetDataNodeSelectorParameter</importMapping>
+                            </importMappings>
+                            <ignoreFileOverride>${project.basedir}/.openapi-generator-ignore-provmns</ignoreFileOverride>
+                        </configuration>
+                    </execution>
                     </executions>
             </plugin>
             <plugin>
                     <threshold>Low</threshold>
                     <failOnError>true</failOnError>
                     <excludeFilterFile>spotbugs-exclude.xml</excludeFilterFile>
-                    <addSources>true</addSources>
+                    <addSourceDirs>true</addSourceDirs>
                     <xmlOutput>true</xmlOutput>
                     <xmlOutputDirectory>${basedir}/target/spotbugs</xmlOutputDirectory>
                 </configuration>
                     <excludes>
                         <exclude>org/onap/cps/ncmp/dmi/model/*</exclude>
                         <exclude>org/onap/cps/ncmp/dmi/datajobs/model/*</exclude>
+                        <exclude>org/onap/cps/ncmp/dmi/provmns/model/*</exclude>
                         <exclude>**/pom.xml</exclude>
                     </excludes>
                 </configuration>
diff --git a/dmi-service/src/main/java/org/onap/cps/ncmp/dmi/provmns/model/ClassNameIdGetDataNodeSelectorParameter.java b/dmi-service/src/main/java/org/onap/cps/ncmp/dmi/provmns/model/ClassNameIdGetDataNodeSelectorParameter.java
new file mode 100644 (file)
index 0000000..56d1074
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ *  ============LICENSE_START=======================================================
+ *  Copyright (C) 2025 OpenInfra Foundation Europe
+ *  ================================================================================
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ *  SPDX-License-Identifier: Apache-2.0
+ *  ============LICENSE_END=========================================================
+ */
+
+package org.onap.cps.ncmp.dmi.provmns.model;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * This class serves as a replacement for the generated ClassNameIdGetDataNodeSelector class which contains dependencies
+ * that cause code generation issues.
+ */
+@Getter
+@Setter
+public class ClassNameIdGetDataNodeSelectorParameter {
+
+    private String dataNodeSelector;
+
+}
diff --git a/dmi-service/src/main/java/org/onap/cps/ncmp/dmi/provmns/model/Resource.java b/dmi-service/src/main/java/org/onap/cps/ncmp/dmi/provmns/model/Resource.java
new file mode 100644 (file)
index 0000000..470c7ae
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ *  ============LICENSE_START=======================================================
+ *  Copyright (C) 2025 OpenInfra Foundation Europe
+ *  ================================================================================
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ *  SPDX-License-Identifier: Apache-2.0
+ *  ============LICENSE_END=========================================================
+ */
+
+package org.onap.cps.ncmp.dmi.provmns.model;
+
+import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+
+/**
+ * This interface serves as a replacement for the generated Resource class, which has dependencies on the NRM-related
+ * models that we want to avoid for our implementation of Provisioning and Management Services (ProvMnS) API.
+ */
+@JsonSerialize(as = ResourceOneOf.class)
+@JsonDeserialize(as = ResourceOneOf.class)
+public interface Resource { }
diff --git a/dmi-service/src/main/java/org/onap/cps/ncmp/dmi/rest/controller/ProvMnsController.java b/dmi-service/src/main/java/org/onap/cps/ncmp/dmi/rest/controller/ProvMnsController.java
new file mode 100644 (file)
index 0000000..1fe5d3d
--- /dev/null
@@ -0,0 +1,107 @@
+/*
+ *  ============LICENSE_START=======================================================
+ *  Copyright (C) 2025 OpenInfra Foundation Europe
+ *  ================================================================================
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ *  SPDX-License-Identifier: Apache-2.0
+ *  ============LICENSE_END=========================================================
+ */
+
+package org.onap.cps.ncmp.dmi.rest.controller;
+
+
+import java.util.List;
+import lombok.RequiredArgsConstructor;
+import org.onap.cps.ncmp.dmi.provmns.api.DefaultApi;
+import org.onap.cps.ncmp.dmi.provmns.model.ClassNameIdGetDataNodeSelectorParameter;
+import org.onap.cps.ncmp.dmi.provmns.model.Resource;
+import org.onap.cps.ncmp.dmi.provmns.model.Scope;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+@RequestMapping("${rest.api.provmns-base-path}")
+@RequiredArgsConstructor
+public class ProvMnsController implements DefaultApi {
+
+    /**
+     * Replaces a complete single resource or creates it if it does not exist.
+     *
+     * @param className               Class name of the targeted resource
+     * @param id                      Identifier of the targeted resource
+     * @param resource                Resource representation of the resource to be created or replaced
+     * @return {@code ResponseEntity} The representation of the updated resource is returned in the response
+     *                                message body.
+     */
+    @Override
+    public ResponseEntity<Resource> classNameidPut(final String className, final String id, final Resource resource) {
+        return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
+    }
+
+    /**
+     * Reads one or multiple resources.
+     *
+     * @param className               Class name of the targeted resource
+     * @param id                      Identifier of the targeted resource
+     * @param scope                   Extends the set of targeted resources beyond the base
+     *                                resource identified with the authority and path component of
+     *                                the URI.
+     * @param filter                  Reduces the targeted set of resources by applying a filter to
+     *                                the scoped set of resource representations. Only resources
+     *                                representations for which the filter construct evaluates to
+     *                                "true" are targeted.
+     * @param attributes              Attributes of the scoped resources to be returned. The
+     *                                value is a comma-separated list of attribute names.
+     * @param fields                  Attribute fields of the scoped resources to be returned. The
+     *                                value is a comma-separated list of JSON pointers to the
+     *                                attribute fields.
+     * @param dataNodeSelector        dataNodeSelector object
+     * @return {@code ResponseEntity} The resources identified in the request for retrieval are returned
+     *                                in the response message body.
+     */
+    @Override
+    public ResponseEntity<Resource> classNameidGet(final String className, final String id, final Scope scope,
+                                                   final String filter, final List<String> attributes,
+                                                   final List<String> fields,
+                                                   final ClassNameIdGetDataNodeSelectorParameter dataNodeSelector) {
+        return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
+    }
+
+    /**
+     * Patches (Create, Update or Delete) one or multiple resources.
+     *
+     * @param className               Class name of the targeted resource
+     * @param id                      Identifier of the targeted resource
+     * @param resource                Resource representation of the resource to be created or replaced
+     * @return {@code ResponseEntity} The updated resource representations are returned in the response message body.
+     */
+    @Override
+    public ResponseEntity<Resource> classNameidPatch(final String className, final String id, final Resource resource) {
+        return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
+    }
+
+    /**
+     * Delete one or multiple resources.
+     *
+     * @param className               Class name of the targeted resource
+     * @param id                      Identifier of the targeted resource
+     * @return {@code ResponseEntity} The response body is empty, HTTP status returned.
+     */
+    @Override
+    public ResponseEntity<Void> classNameidDelete(final String className, final String id) {
+        return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
+    }
+}
index 7ba9b25..285a8bf 100644 (file)
@@ -28,9 +28,10 @@ dmi:
 rest:
   api:
     dmi-base-path: /dmi
+    provmns-base-path: /ProvMnS
 
 security:
-  permit-uri: /actuator/**,/swagger-ui.html,/swagger-ui/**,/swagger-resources/**,/api-docs/**,/v3/api-docs/**
+  permit-uri: /actuator/**,/swagger-ui.html,/swagger-ui/**,/swagger-resources/**,/api-docs/**,/v3/api-docs/**,/ProvMnS/**
   auth:
     username: ${DMI_USERNAME}
     password: ${DMI_PASSWORD}
diff --git a/dmi-service/src/test/groovy/org/onap/cps/ncmp/dmi/rest/controller/ProvMnsControllerSpec.groovy b/dmi-service/src/test/groovy/org/onap/cps/ncmp/dmi/rest/controller/ProvMnsControllerSpec.groovy
new file mode 100644 (file)
index 0000000..0c97f67
--- /dev/null
@@ -0,0 +1,98 @@
+/*
+ *  ============LICENSE_START=======================================================
+ *  Copyright (C) 2025 OpenInfra Foundation Europe. All rights reserved.
+ *  ================================================================================
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ *  SPDX-License-Identifier: Apache-2.0
+ *  ============LICENSE_END=========================================================
+ */
+
+package org.onap.cps.ncmp.dmi.rest.controller
+
+import com.fasterxml.jackson.databind.ObjectMapper
+import org.onap.cps.ncmp.dmi.config.WebSecurityConfig
+import org.onap.cps.ncmp.dmi.provmns.model.ResourceOneOf
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.beans.factory.annotation.Value
+import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest
+import org.springframework.context.annotation.Import
+import org.springframework.http.HttpStatus
+import org.springframework.http.MediaType
+import org.springframework.test.web.servlet.MockMvc
+import spock.lang.Specification
+
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.patch
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.put
+
+@WebMvcTest(ProvMnsController)
+@Import(WebSecurityConfig)
+class ProvMnsControllerSpec extends Specification {
+
+    @Autowired
+    MockMvc mvc
+
+    def objectMapper = new ObjectMapper()
+
+    @Value('${rest.api.provmns-base-path}')
+    def provMnSBasePath
+
+    def 'Get Resource Data from provmns interface.'() {
+        given: 'resource data url'
+            def getUrl = "$provMnSBasePath/test=another"
+        when: 'get data resource request is performed'
+            def response = mvc.perform(get(getUrl).contentType(MediaType.APPLICATION_JSON)).andReturn().response
+        then: 'response status is Not Implemented (501)'
+            assert response.status == HttpStatus.NOT_IMPLEMENTED.value()
+    }
+
+    def 'Put Resource Data from provmns interface.'() {
+        given: 'resource data url'
+            def putUrl = "$provMnSBasePath/test=another"
+        and: 'an example resource json object'
+            def jsonBody = objectMapper.writeValueAsString((new ResourceOneOf('test')))
+        when: 'put data resource request is performed'
+            def response = mvc.perform(put(putUrl)
+                    .contentType(MediaType.APPLICATION_JSON)
+                    .content(jsonBody))
+                    .andReturn().response
+        then: 'response status is Not Implemented (501)'
+            assert response.status == HttpStatus.NOT_IMPLEMENTED.value()
+    }
+
+    def 'Patch Resource Data from provmns interface.'() {
+        given: 'resource data url'
+            def patchUrl = "$provMnSBasePath/test=another"
+        and: 'an example resource json object'
+            def jsonBody = objectMapper.writeValueAsString((new ResourceOneOf('test')))
+        when: 'patch data resource request is performed'
+            def response = mvc.perform(patch(patchUrl)
+                    .contentType(new MediaType('application', 'json-patch+json'))
+                    .content(jsonBody))
+                    .andReturn().response
+        then: 'response status is Not Implemented (501)'
+            assert response.status == HttpStatus.NOT_IMPLEMENTED.value()
+    }
+
+    def 'Delete Resource Data from provmns interface.'() {
+        given: 'resource data url'
+            def deleteUrl = "$provMnSBasePath/test=another"
+        when: 'delete data resource request is performed'
+            def response = mvc.perform(delete(deleteUrl)).andReturn().response
+        then: 'response status is Not Implemented (501)'
+            assert response.status == HttpStatus.NOT_IMPLEMENTED.value()
+    }
+
+}
index 2a6269a..f3dda8b 100644 (file)
 rest:
   api:
     dmi-base-path: /dmi
+    provmns-base-path: /ProvMnS
 
 security:
-  permit-uri: /actuator/**,/swagger-ui/**,/swagger-resources/**,/v3/api-docs
+  permit-uri: /actuator/**,/swagger-ui/**,/swagger-resources/**,/v3/api-docs,/ProvMnS/**
   auth:
     username: cpsuser
     password: cpsr0cks!