Support alternate id interface for CPS-E-05 - publicProperties 55/138855/2
authormpriyank <priyank.maheshwari@est.tech>
Tue, 27 Aug 2024 15:08:31 +0000 (16:08 +0100)
committerPriyank Maheshwari <priyank.maheshwari@est.tech>
Fri, 30 Aug 2024 11:17:14 +0000 (11:17 +0000)
- added alternate id support for the existing endpoint
- Incorporated previous comments on the indendation
- Added new component cmHandleReferenceInPath in openapi docs to depict
  the correct example

Issue-ID: CPS-2378
Change-Id: I63e752fbb6cb0bde49d1ced53f063743d904d74e
Signed-off-by: mpriyank <priyank.maheshwari@est.tech>
cps-ncmp-rest/docs/openapi/components.yaml
cps-ncmp-rest/docs/openapi/ncmp.yml
cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java
cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyControllerSpec.groovy
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/NetworkCmProxyInventoryFacade.java
cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/NetworkCmProxyInventoryFacadeSpec.groovy

index a9311d0..112dddf 100644 (file)
@@ -505,6 +505,14 @@ components:
       schema:
         type: string
         example: my-cm-handle
+    cmHandleReferenceInPath:
+      name: cm-handle
+      in: path
+      description: The identifier (cmHandle or alternate) for a network function, network element, subnetwork or any other cm object by managed Network CM Proxy
+      required: true
+      schema:
+        type: string
+        example: my-cm-handle-reference
     moduleNameInQuery:
       name: module-name
       in: query
index 6972463..9a6c076 100755 (executable)
@@ -27,7 +27,7 @@ resourceDataForCmHandle:
     operationId: getResourceDataForCmHandle
     parameters:
       - $ref: 'components.yaml#/components/parameters/datastoreName'
-      - $ref: 'components.yaml#/components/parameters/cmHandleInPath'
+      - $ref: 'components.yaml#/components/parameters/cmHandleReferenceInPath'
       - $ref: 'components.yaml#/components/parameters/resourceIdentifierInQuery'
       - $ref: 'components.yaml#/components/parameters/optionsParamInQuery'
       - $ref: 'components.yaml#/components/parameters/topicParamInQuery'
@@ -60,7 +60,7 @@ resourceDataForCmHandle:
     operationId: createResourceDataRunningForCmHandle
     parameters:
       - $ref: 'components.yaml#/components/parameters/datastoreName'
-      - $ref: 'components.yaml#/components/parameters/cmHandleInPath'
+      - $ref: 'components.yaml#/components/parameters/cmHandleReferenceInPath'
       - $ref: 'components.yaml#/components/parameters/resourceIdentifierInQuery'
       - $ref: 'components.yaml#/components/parameters/contentParamInHeader'
       - $ref: 'components.yaml#/components/parameters/authorizationParamInHeader'
@@ -99,7 +99,7 @@ resourceDataForCmHandle:
     operationId: updateResourceDataRunningForCmHandle
     parameters:
       - $ref: 'components.yaml#/components/parameters/datastoreName'
-      - $ref: 'components.yaml#/components/parameters/cmHandleInPath'
+      - $ref: 'components.yaml#/components/parameters/cmHandleReferenceInPath'
       - $ref: 'components.yaml#/components/parameters/resourceIdentifierInQuery'
       - $ref: 'components.yaml#/components/parameters/contentParamInHeader'
       - $ref: 'components.yaml#/components/parameters/authorizationParamInHeader'
@@ -138,7 +138,7 @@ resourceDataForCmHandle:
     operationId: patchResourceDataRunningForCmHandle
     parameters:
       - $ref: 'components.yaml#/components/parameters/datastoreName'
-      - $ref: 'components.yaml#/components/parameters/cmHandleInPath'
+      - $ref: 'components.yaml#/components/parameters/cmHandleReferenceInPath'
       - $ref: 'components.yaml#/components/parameters/resourceIdentifierInQuery'
       - $ref: 'components.yaml#/components/parameters/contentParamInHeader'
       - $ref: 'components.yaml#/components/parameters/authorizationParamInHeader'
@@ -171,7 +171,7 @@ resourceDataForCmHandle:
     operationId: deleteResourceDataRunningForCmHandle
     parameters:
       - $ref: 'components.yaml#/components/parameters/datastoreName'
-      - $ref: 'components.yaml#/components/parameters/cmHandleInPath'
+      - $ref: 'components.yaml#/components/parameters/cmHandleReferenceInPath'
       - $ref: 'components.yaml#/components/parameters/resourceIdentifierInQuery'
       - $ref: 'components.yaml#/components/parameters/contentParamInHeader'
       - $ref: 'components.yaml#/components/parameters/authorizationParamInHeader'
@@ -377,7 +377,7 @@ getCmHandlePropertiesById:
     summary: Get CM handle properties
     operationId: getCmHandlePublicPropertiesByCmHandleId
     parameters:
-      - $ref: 'components.yaml#/components/parameters/cmHandleInPath'
+      - $ref: 'components.yaml#/components/parameters/cmHandleReferenceInPath'
     responses:
       200:
         description: OK
@@ -400,7 +400,7 @@ getCmHandleStateById:
     summary: Get CM handle state
     operationId: getCmHandleStateByCmHandleId
     parameters:
-      - $ref: 'components.yaml#/components/parameters/cmHandleInPath'
+      - $ref: 'components.yaml#/components/parameters/cmHandleReferenceInPath'
     responses:
       200:
         description: OK
index 6a2e9a1..ca2907b 100755 (executable)
@@ -148,7 +148,7 @@ public class NetworkCmProxyController implements NetworkCmProxyApi {
      * Patch resource data.
      *
      * @param datastoreName      name of the datastore (currently only supports "ncmp-datastore:passthrough-running")
-     * @param cmHandleReference           cm handle or alternate identifier
+     * @param cmHandleReference  cm handle or alternate identifier
      * @param resourceIdentifier resource identifier
      * @param requestBody        the request body
      * @param contentType        content type of body
@@ -177,7 +177,7 @@ public class NetworkCmProxyController implements NetworkCmProxyApi {
      * Create resource data for given cm-handle.
      *
      * @param datastoreName      name of the datastore (currently only supports "ncmp-datastore:passthrough-running")
-     * @param cmHandleReference           cm handle or alternate identifier
+     * @param cmHandleReference  cm handle or alternate identifier
      * @param resourceIdentifier resource identifier
      * @param requestBody        the request body
      * @param contentType        content type of body
@@ -202,7 +202,7 @@ public class NetworkCmProxyController implements NetworkCmProxyApi {
      * Update resource data for given cm-handle.
      *
      * @param datastoreName      name of the datastore (currently only supports "ncmp-datastore:passthrough-running")
-     * @param cmHandleReference           cm handle or alternate identifier
+     * @param cmHandleReference  cm handle or alternate identifier
      * @param resourceIdentifier resource identifier
      * @param requestBody        the request body
      * @param contentType        content type of the body
@@ -228,7 +228,7 @@ public class NetworkCmProxyController implements NetworkCmProxyApi {
      * Delete resource data for a given cm-handle.
      *
      * @param datastoreName      name of the datastore (currently only supports "ncmp-datastore:passthrough-running")
-     * @param cmHandleReference           cm handle or alternate identifier
+     * @param cmHandleReference  cm handle or alternate identifier
      * @param resourceIdentifier resource identifier
      * @param contentType        content type of the body
      * @param authorization      contents of Authorization header, or null if not present
@@ -298,16 +298,16 @@ public class NetworkCmProxyController implements NetworkCmProxyApi {
     }
 
     /**
-     * Get Cm Handle Properties by Cm Handle Id.
+     * Get Cm Handle Properties by Cm Handle or alternate Identifier.
      *
-     * @param cmHandleId cm-handle identifier
+     * @param cmHandleReference cm-handle or alternate identifier
      * @return cm handle properties
      */
     @Override
     public ResponseEntity<RestOutputCmHandlePublicProperties> getCmHandlePublicPropertiesByCmHandleId(
-            final String cmHandleId) {
+            final String cmHandleReference) {
         final CmHandlePublicProperties cmHandlePublicProperties = new CmHandlePublicProperties();
-        cmHandlePublicProperties.add(networkCmProxyInventoryFacade.getCmHandlePublicProperties(cmHandleId));
+        cmHandlePublicProperties.add(networkCmProxyInventoryFacade.getCmHandlePublicProperties(cmHandleReference));
         final RestOutputCmHandlePublicProperties restOutputCmHandlePublicProperties =
                 new RestOutputCmHandlePublicProperties();
         restOutputCmHandlePublicProperties.setPublicCmHandleProperties(cmHandlePublicProperties);
index 92b47c6..80e74ca 100644 (file)
@@ -308,13 +308,13 @@ class NetworkCmProxyControllerSpec extends Specification {
             assert !response.contentAsString.contains("some DMI property")
     }
 
-    def 'Get Cm Handle public properties by Cm Handle id.'() {
+    def 'Get Cm Handle public properties by Cm Handle Reference.'() {
         given: 'a cm handle properties endpoint'
-            def cmHandlePropertiesEndpoint = "$ncmpBasePathV1/ch/some-cm-handle/properties"
+            def cmHandlePropertiesEndpoint = "$ncmpBasePathV1/ch/some-cm-handle-reference/properties"
         and: 'some cm handle public properties'
             def publicProperties = ['public prop': 'some public property']
         and: 'the service method is invoked with the cm handle id returning the cm handle public properties'
-            1 * mockNetworkCmProxyInventoryFacade.getCmHandlePublicProperties('some-cm-handle') >> publicProperties
+            1 * mockNetworkCmProxyInventoryFacade.getCmHandlePublicProperties('some-cm-handle-reference') >> publicProperties
         when: 'the cm handle properties api is invoked'
             def response = mvc.perform(get(cmHandlePropertiesEndpoint)).andReturn().response
         then: 'the correct response is returned'
index e678159..785eb8f 100644 (file)
@@ -191,12 +191,13 @@ public class NetworkCmProxyInventoryFacade {
     }
 
     /**
-     * Get cm handle public properties for a given cm handle id.
+     * Get cm handle public properties for a given cm handle or alternate id.
      *
-     * @param cmHandleId cm handle identifier
+     * @param cmHandleReference cm handle or alternate identifier
      * @return cm handle public properties
      */
-    public Map<String, String> getCmHandlePublicProperties(final String cmHandleId) {
+    public Map<String, String> getCmHandlePublicProperties(final String cmHandleReference) {
+        final String cmHandleId = alternateIdMatcher.getCmHandleId(cmHandleReference);
         final YangModelCmHandle yangModelCmHandle = inventoryPersistence.getYangModelCmHandle(cmHandleId);
         return YangDataConverter.toPropertiesMap(yangModelCmHandle.getPublicProperties());
     }
index b243a74..9d51fff 100644 (file)
@@ -134,17 +134,25 @@ class NetworkCmProxyInventoryFacadeSpec extends Specification {
             assert result.currentTrustLevel == TrustLevel.COMPLETE
     }
 
-    def 'Get cm handle public properties'() {
+    def 'Get cm handle public properties using #scenario'() {
         given: 'a yang modelled cm handle'
             def dmiProperties = [new YangModelCmHandle.Property('prop', 'some DMI property')]
             def publicProperties = [new YangModelCmHandle.Property('public prop', 'some public prop')]
-            def yangModelCmHandle = new YangModelCmHandle(id:'some-cm-handle', dmiServiceName: 'some service name', dmiProperties: dmiProperties, publicProperties: publicProperties)
+            def cmHandleId = 'some-cm-handle'
+            def alternateId = 'some-alternate-id'
+            def yangModelCmHandle = new YangModelCmHandle(id:cmHandleId, alternateId: alternateId, dmiServiceName: 'some service name', dmiProperties: dmiProperties, publicProperties: publicProperties)
+        and: 'we have corresponding cm handle for the cm handle reference'
+            1 * mockAlternateIdMatcher.getCmHandleId(cmHandleRef) >> cmHandleId
         and: 'the system returns this yang modelled cm handle'
-            1 * mockInventoryPersistence.getYangModelCmHandle('some-cm-handle') >> yangModelCmHandle
-        when: 'getting cm handle public properties for a given cm handle id from ncmp service'
-            def result = objectUnderTest.getCmHandlePublicProperties('some-cm-handle')
+            1 * mockInventoryPersistence.getYangModelCmHandle(cmHandleId) >> yangModelCmHandle
+        when: 'getting cm handle public properties for a given cm handle reference from ncmp service'
+            def result = objectUnderTest.getCmHandlePublicProperties(cmHandleRef)
         then: 'the result returns the correct data'
             assert result == [ 'public prop' : 'some public prop' ]
+        where: 'following cm handle reference is used'
+            scenario                              | cmHandleRef
+            'Cm Handle Reference as cm handle-id' | 'some-cm-handle'
+            'Cm Handle Reference as alternate-id' | 'some-alternate-id'
     }
 
     def 'Get cm handle composite state using #scenario'() {