diff options
Diffstat (limited to 'cps-ncmp-rest')
4 files changed, 43 insertions, 33 deletions
diff --git a/cps-ncmp-rest/docs/openapi/components.yaml b/cps-ncmp-rest/docs/openapi/components.yaml index a9311d0861..112dddf61c 100644 --- a/cps-ncmp-rest/docs/openapi/components.yaml +++ b/cps-ncmp-rest/docs/openapi/components.yaml @@ -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 diff --git a/cps-ncmp-rest/docs/openapi/ncmp.yml b/cps-ncmp-rest/docs/openapi/ncmp.yml index 6972463e3c..32942a4b1b 100755 --- a/cps-ncmp-rest/docs/openapi/ncmp.yml +++ b/cps-ncmp-rest/docs/openapi/ncmp.yml @@ -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' @@ -264,7 +264,7 @@ fetchModuleReferencesByCmHandle: summary: Fetch all module references (name and revision) for a given cm handle operationId: getModuleReferencesByCmHandle parameters: - - $ref: 'components.yaml#/components/parameters/cmHandleInPath' + - $ref: 'components.yaml#/components/parameters/cmHandleReferenceInPath' responses: 200: description: OK @@ -289,7 +289,7 @@ getModuleDefinitions: description: Get module definitions (module name, revision, yang resource) with options to filter on module name and revision operationId: getModuleDefinitions parameters: - - $ref: 'components.yaml#/components/parameters/cmHandleInPath' + - $ref: 'components.yaml#/components/parameters/cmHandleReferenceInPath' - $ref: 'components.yaml#/components/parameters/moduleNameInQuery' - $ref: 'components.yaml#/components/parameters/revisionInQuery' responses: @@ -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 diff --git a/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java b/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java index 6a2e9a1541..9dc227a910 100755 --- a/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java +++ b/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java @@ -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); @@ -334,21 +334,23 @@ public class NetworkCmProxyController implements NetworkCmProxyApi { /** * Return module definitions. * - * @param cmHandleId cm-handle identifier - * @param moduleName module name - * @param revision the revision of the module + * @param cmHandleReference cm handle or alternate id identifier + * @param moduleName module name + * @param revision the revision of the module * @return list of module definitions (module name, revision, yang resource content) */ @Override - public ResponseEntity<List<RestModuleDefinition>> getModuleDefinitions(final String cmHandleId, + public ResponseEntity<List<RestModuleDefinition>> getModuleDefinitions(final String cmHandleReference, final String moduleName, final String revision) { final Collection<ModuleDefinition> moduleDefinitions; if (StringUtils.hasText(moduleName)) { moduleDefinitions = - networkCmProxyInventoryFacade.getModuleDefinitionsByCmHandleAndModule(cmHandleId, moduleName, revision); + networkCmProxyInventoryFacade.getModuleDefinitionsByCmHandleAndModule(cmHandleReference, + moduleName, revision); } else { - moduleDefinitions = networkCmProxyInventoryFacade.getModuleDefinitionsByCmHandleId(cmHandleId); + moduleDefinitions = + networkCmProxyInventoryFacade.getModuleDefinitionsByCmHandleReference(cmHandleReference); if (StringUtils.hasText(revision)) { log.warn("Ignoring revision filter as no module name is provided"); } @@ -363,12 +365,12 @@ public class NetworkCmProxyController implements NetworkCmProxyApi { /** * Return module references for a cm handle. * - * @param cmHandle the cm handle + * @param cmHandleReference cm handle or alternate id identifier * @return module references for cm handle. Namespace will be always blank because restConf does not include this. */ - public ResponseEntity<List<RestModuleReference>> getModuleReferencesByCmHandle(final String cmHandle) { + public ResponseEntity<List<RestModuleReference>> getModuleReferencesByCmHandle(final String cmHandleReference) { final List<RestModuleReference> restModuleReferences = - networkCmProxyInventoryFacade.getYangResourcesModuleReferences(cmHandle).stream() + networkCmProxyInventoryFacade.getYangResourcesModuleReferences(cmHandleReference).stream() .map(ncmpRestInputMapper::toRestModuleReference) .collect(Collectors.toList()); return new ResponseEntity<>(restModuleReferences, HttpStatus.OK); diff --git a/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyControllerSpec.groovy b/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyControllerSpec.groovy index 92b47c6c8b..ef4cdfa8c3 100644 --- a/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyControllerSpec.groovy +++ b/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyControllerSpec.groovy @@ -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' @@ -415,12 +415,12 @@ class NetworkCmProxyControllerSpec extends Specification { def 'Getting module definitions filtering on #scenario'() { when: 'get module definition request is performed' def response = mvc.perform( - get("$ncmpBasePathV1/ch/some-cmhandle/modules/definitions?module-name=" + moduleName + "&revision=" + revision)) + get("$ncmpBasePathV1/ch/some-cmhandle-reference/modules/definitions?module-name=" + moduleName + "&revision=" + revision)) .andReturn().response - then: 'ncmp service method to get definitions by cm handle is invoked when needed' - numberOfCallsToByCmHandleId * mockNetworkCmProxyInventoryFacade.getModuleDefinitionsByCmHandleId('some-cmhandle') >> [] + then: 'ncmp service method to get definitions by cm handle reference is invoked when needed' + numberOfCallsToByCmHandleId * mockNetworkCmProxyInventoryFacade.getModuleDefinitionsByCmHandleReference('some-cmhandle-reference') >> [] and: 'ncmp service method to get definitions by module is invoked when needed' - numberOfCallsToByModule * mockNetworkCmProxyInventoryFacade.getModuleDefinitionsByCmHandleAndModule('some-cmhandle', moduleName, revision) >> [] + numberOfCallsToByModule * mockNetworkCmProxyInventoryFacade.getModuleDefinitionsByCmHandleAndModule('some-cmhandle-reference', moduleName, revision) >> [] and: 'response returns an OK http code' response.status == HttpStatus.OK.value() and: 'the correct message is logged when needed' |