summaryrefslogtreecommitdiffstats
path: root/cps-ncmp-rest
diff options
context:
space:
mode:
authorDaniel Hanrahan <daniel.hanrahan@est.tech>2024-10-29 10:06:43 +0000
committerGerrit Code Review <gerrit@onap.org>2024-10-29 10:06:43 +0000
commit44498392f9d74510247de52de7a75f3e144c6b2c (patch)
tree0e6e6d94282798e04a821bb7647a4629d03d12e9 /cps-ncmp-rest
parenteefb5b3de6e35615ac010805ba4b2e54ec6c5f11 (diff)
parentccf48efa15fa6cce9d2e245601105043f939bcce (diff)
Merge "Support Alternate-Id for CPS-E05 id-searches and searchCmHandleIds"
Diffstat (limited to 'cps-ncmp-rest')
-rw-r--r--cps-ncmp-rest/docs/openapi/components.yaml8
-rwxr-xr-xcps-ncmp-rest/docs/openapi/ncmp-inventory.yml6
-rwxr-xr-xcps-ncmp-rest/docs/openapi/ncmp.yml4
-rwxr-xr-xcps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java14
-rwxr-xr-xcps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyInventoryController.java15
-rw-r--r--cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyControllerSpec.groovy2
-rw-r--r--cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyInventoryControllerSpec.groovy6
7 files changed, 39 insertions, 16 deletions
diff --git a/cps-ncmp-rest/docs/openapi/components.yaml b/cps-ncmp-rest/docs/openapi/components.yaml
index 112dddf61c..99072c43e5 100644
--- a/cps-ncmp-rest/docs/openapi/components.yaml
+++ b/cps-ncmp-rest/docs/openapi/components.yaml
@@ -513,6 +513,14 @@ components:
schema:
type: string
example: my-cm-handle-reference
+ outputAlternateIdOptionInQuery:
+ name: outputAlternateId
+ in: query
+ description: Boolean parameter to determine if returned value(s) will be cmHandle Ids or Alternate Ids for a given query
+ required: false
+ schema:
+ type: boolean
+ default: false
moduleNameInQuery:
name: module-name
in: query
diff --git a/cps-ncmp-rest/docs/openapi/ncmp-inventory.yml b/cps-ncmp-rest/docs/openapi/ncmp-inventory.yml
index ea020f9e81..24b83cf368 100755
--- a/cps-ncmp-rest/docs/openapi/ncmp-inventory.yml
+++ b/cps-ncmp-rest/docs/openapi/ncmp-inventory.yml
@@ -1,6 +1,6 @@
# ============LICENSE_START=======================================================
# Copyright (C) 2021 Bell Canada
-# Modifications Copyright (C) 2021-2022 Nordix Foundation
+# Modifications Copyright (C) 2021-2024 Nordix Foundation
# ================================================================================
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -121,11 +121,13 @@ getAllCmHandleIdsForRegisteredDmi:
searchCmHandleIds:
post:
- description: Query and get CMHandleIds for additional properties, public properties and registered DMI plugin (DMI plugin, DMI data plugin, DMI model plugin).
+ description: Query and get CMHandle references for additional properties, public properties and registered DMI plugin (DMI plugin, DMI data plugin, DMI model plugin).
tags:
- network-cm-proxy-inventory
summary: Query for CM Handle IDs
operationId: searchCmHandleIds
+ parameters:
+ - $ref: 'components.yaml#/components/parameters/outputAlternateIdOptionInQuery'
requestBody:
required: true
content:
diff --git a/cps-ncmp-rest/docs/openapi/ncmp.yml b/cps-ncmp-rest/docs/openapi/ncmp.yml
index adb2419c8a..a3ddc3fb3b 100755
--- a/cps-ncmp-rest/docs/openapi/ncmp.yml
+++ b/cps-ncmp-rest/docs/openapi/ncmp.yml
@@ -417,11 +417,13 @@ getCmHandleStateById:
searchCmHandleIds:
post:
- description: Execute cm handle query search and return a list of cm handle ids. Any number of conditions can be applied. To be included in the result a cm-handle must fulfill ALL the conditions. An empty collection will be returned in the case that the cm handle does not match a condition. For more on cm handle query search please refer to <a href="https://docs.onap.org/projects/onap-cps/en/latest/ncmp-cmhandle-querying.html">cm handle query search Read the Docs</a>.<br/>By supplying a CPS Path it is possible to query on any data related to the cm handle. For more on CPS Path please refer to <a href="https://docs.onap.org/projects/onap-cps/en/latest/cps-path.html">CPS Path Read the Docs</a>. The cm handle ancestor is automatically returned for this query.
+ description: Execute cm handle query search and return a list of cm handle references. Any number of conditions can be applied. To be included in the result a cm-handle must fulfill ALL the conditions. An empty collection will be returned in the case that the cm handle does not match a condition. For more on cm handle query search please refer to <a href="https://docs.onap.org/projects/onap-cps/en/latest/ncmp-cmhandle-querying.html">cm handle query search Read the Docs</a>.<br/>By supplying a CPS Path it is possible to query on any data related to the cm handle. For more on CPS Path please refer to <a href="https://docs.onap.org/projects/onap-cps/en/latest/cps-path.html">CPS Path Read the Docs</a>. The cm handle ancestor is automatically returned for this query.
tags:
- network-cm-proxy
summary: Execute cm handle query upon a given set of query parameters
operationId: searchCmHandleIds
+ parameters:
+ - $ref: 'components.yaml#/components/parameters/outputAlternateIdOptionInQuery'
requestBody:
required: true
content:
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 42f709dcf5..3676bb1393 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
@@ -268,18 +268,20 @@ public class NetworkCmProxyController implements NetworkCmProxyApi {
}
/**
- * Query and return cm handle ids that match the given query parameters.
+ * Query and return cm handle ids or alternate ids that match the given query parameters.
*
- * @param cmHandleQueryParameters the cm handle query parameters
- * @return collection of cm handle ids
+ * @param cmHandleQueryParameters the cm handle query parameters
+ * @param outputAlternateId Boolean for cm handle reference type either
+ * cm handle id (false or null) or alternate id (true)
+ * @return collection of cm handle ids
*/
@Override
- public ResponseEntity<List<String>> searchCmHandleIds(
- final CmHandleQueryParameters cmHandleQueryParameters) {
+ public ResponseEntity<List<String>> searchCmHandleIds(final CmHandleQueryParameters cmHandleQueryParameters,
+ final Boolean outputAlternateId) {
final CmHandleQueryApiParameters cmHandleQueryApiParameters =
jsonObjectMapper.convertToValueType(cmHandleQueryParameters, CmHandleQueryApiParameters.class);
final Collection<String> cmHandleIds
- = networkCmProxyInventoryFacade.executeCmHandleIdSearch(cmHandleQueryApiParameters);
+ = networkCmProxyInventoryFacade.executeCmHandleIdSearch(cmHandleQueryApiParameters, outputAlternateId);
return ResponseEntity.ok(List.copyOf(cmHandleIds));
}
diff --git a/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyInventoryController.java b/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyInventoryController.java
index cea3d2a6b9..f76376991a 100755
--- a/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyInventoryController.java
+++ b/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyInventoryController.java
@@ -1,7 +1,7 @@
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2021-2022 Bell Canada
- * Modifications Copyright (C) 2022-2023 Nordix Foundation
+ * Modifications Copyright (C) 2022-2024 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -51,13 +51,22 @@ public class NetworkCmProxyInventoryController implements NetworkCmProxyInventor
private final NetworkCmProxyInventoryFacade networkCmProxyInventoryFacade;
private final NcmpRestInputMapper ncmpRestInputMapper;
+ /**
+ * Get all cm handle references under a registered DMI plugin.
+ *
+ * @param cmHandleQueryParameters DMI plugin identifier
+ * @param outputAlternateId Boolean for cm handle reference type either
+ * cm handle id (False) or alternate id (True)
+ * @return list of cm handle IDs
+ */
@Override
- public ResponseEntity<List<String>> searchCmHandleIds(final CmHandleQueryParameters cmHandleQueryParameters) {
+ public ResponseEntity<List<String>> searchCmHandleIds(final CmHandleQueryParameters cmHandleQueryParameters,
+ final Boolean outputAlternateId) {
final CmHandleQueryServiceParameters cmHandleQueryServiceParameters = ncmpRestInputMapper
.toCmHandleQueryServiceParameters(cmHandleQueryParameters);
final Collection<String> cmHandleIds = networkCmProxyInventoryFacade
- .executeParameterizedCmHandleIdSearch(cmHandleQueryServiceParameters);
+ .executeParameterizedCmHandleIdSearch(cmHandleQueryServiceParameters, outputAlternateId);
return ResponseEntity.ok(List.copyOf(cmHandleIds));
}
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 43403fa890..5340c6d93f 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
@@ -363,7 +363,7 @@ class NetworkCmProxyControllerSpec extends Specification {
given: 'an endpoint and json data'
def searchesEndpoint = "$ncmpBasePathV1/ch/id-searches"
and: 'the service method is invoked with module names and returns cm handle ids'
- 1 * mockNetworkCmProxyInventoryFacade.executeCmHandleIdSearch(_) >> ['ch-1', 'ch-2']
+ 1 * mockNetworkCmProxyInventoryFacade.executeCmHandleIdSearch(_, _) >> ['ch-1', 'ch-2']
when: 'the searches api is invoked'
def response = mvc.perform(post(searchesEndpoint).contentType(MediaType.APPLICATION_JSON).content('{}')).andReturn().response
then: 'cm handle ids are returned'
diff --git a/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyInventoryControllerSpec.groovy b/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyInventoryControllerSpec.groovy
index d7ac46632c..74e6759f72 100644
--- a/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyInventoryControllerSpec.groovy
+++ b/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyInventoryControllerSpec.groovy
@@ -1,7 +1,7 @@
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2021-2022 Bell Canada
- * Modifications Copyright (C) 2021-2023 Nordix Foundation
+ * Modifications Copyright (C) 2021-2024 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -113,7 +113,7 @@ class NetworkCmProxyInventoryControllerSpec extends Specification {
and: 'the mapper service returns a converted object'
ncmpRestInputMapper.toCmHandleQueryServiceParameters(_) >> cmHandleQueryServiceParameters
and: 'the service returns the desired results'
- mockNetworkCmProxyInventoryFacade.executeParameterizedCmHandleIdSearch(cmHandleQueryServiceParameters) >> serviceMockResponse
+ mockNetworkCmProxyInventoryFacade.executeParameterizedCmHandleIdSearch(cmHandleQueryServiceParameters, _) >> serviceMockResponse
when: 'post request is performed & search is called with the given request parameters'
def response = mvc.perform(
post("$ncmpBasePathV1/ch/searches")
@@ -136,7 +136,7 @@ class NetworkCmProxyInventoryControllerSpec extends Specification {
and: 'the mapper service returns a converted object'
ncmpRestInputMapper.toCmHandleQueryServiceParameters(_) >> cmHandleQueryServiceParameters
and: 'the service returns the desired results'
- mockNetworkCmProxyInventoryFacade.executeParameterizedCmHandleIdSearch(cmHandleQueryServiceParameters) >> serviceMockResponse
+ mockNetworkCmProxyInventoryFacade.executeParameterizedCmHandleIdSearch(cmHandleQueryServiceParameters, _) >> serviceMockResponse
when: 'post request is performed & search is called with the given request parameters'
def response = mvc.perform(
post("$ncmpBasePathV1/ch/searches")