summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cps-ncmp-rest-stub/src/main/java/org/onap/cps/ncmp/rest/stub/controller/NetworkCmProxyStubController.java10
-rw-r--r--cps-ncmp-rest/docs/openapi/components.yaml9
-rwxr-xr-xcps-ncmp-rest/docs/openapi/ncmp.yml35
-rwxr-xr-xcps-ncmp-rest/docs/openapi/openapi.yml5
-rwxr-xr-xcps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java49
-rw-r--r--cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/handlers/NcmpDatastoreOperationalQueryHandler.java56
-rw-r--r--cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/handlers/NcmpDatastoreOperationalResourceRequestHandler.java20
-rw-r--r--cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/handlers/NcmpDatastorePassthroughOperationalResourceRequestHandler.java14
-rw-r--r--cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/handlers/NcmpDatastorePassthroughRunningResourceRequestHandler.java14
-rw-r--r--cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/handlers/NcmpDatastoreRequestHandler.java106
-rw-r--r--cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/handlers/NcmpDatastoreResourceRequestHandler.java92
-rw-r--r--cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/handlers/NcmpDatastoreResourceRequestHandlerFactory.java15
-rw-r--r--cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyControllerSpec.groovy45
-rw-r--r--cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/handlers/NcmpDatastoreRequestHandlerFactorySpec.groovy40
-rw-r--r--cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/handlers/NcmpDatastoreResourceRequestHandlerFactorySpec.groovy20
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/NetworkCmProxyQueryService.java41
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyQueryServiceImpl.java46
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyQueryServiceImplSpec.groovy46
-rw-r--r--cps-rest/docs/openapi/components.yml9
-rw-r--r--cps-rest/docs/openapi/cpsAdmin.yml53
-rw-r--r--cps-rest/docs/openapi/openapi.yml7
-rwxr-xr-xcps-rest/src/main/java/org/onap/cps/rest/controller/AdminRestController.java18
-rw-r--r--cps-rest/src/main/java/org/onap/cps/rest/controller/CpsRestInputMapper.java4
-rwxr-xr-xcps-rest/src/test/groovy/org/onap/cps/rest/controller/AdminRestControllerSpec.groovy28
-rwxr-xr-xcps-ri/src/main/java/org/onap/cps/spi/impl/CpsAdminPersistenceServiceImpl.java19
-rw-r--r--cps-ri/src/test/groovy/org/onap/cps/spi/impl/CpsAdminPersistenceServiceSpec.groovy28
-rwxr-xr-xcps-service/src/main/java/org/onap/cps/api/CpsAdminService.java18
-rwxr-xr-xcps-service/src/main/java/org/onap/cps/api/impl/CpsAdminServiceImpl.java13
-rwxr-xr-xcps-service/src/main/java/org/onap/cps/spi/CpsAdminPersistenceService.java17
-rw-r--r--cps-service/src/main/java/org/onap/cps/spi/model/Dataspace.java42
-rwxr-xr-xcps-service/src/test/groovy/org/onap/cps/api/impl/CpsAdminServiceImplSpec.groovy18
-rwxr-xr-xcsit/prepare-csit.sh20
-rwxr-xr-xcsit/run-csit.sh12
-rw-r--r--docs/api/swagger/cps/openapi.yaml127
-rw-r--r--docs/api/swagger/ncmp/openapi.yaml12
-rwxr-xr-xdocs/release-notes.rst1
36 files changed, 934 insertions, 175 deletions
diff --git a/cps-ncmp-rest-stub/src/main/java/org/onap/cps/ncmp/rest/stub/controller/NetworkCmProxyStubController.java b/cps-ncmp-rest-stub/src/main/java/org/onap/cps/ncmp/rest/stub/controller/NetworkCmProxyStubController.java
index bb919b5c6e..3990dd15d4 100644
--- a/cps-ncmp-rest-stub/src/main/java/org/onap/cps/ncmp/rest/stub/controller/NetworkCmProxyStubController.java
+++ b/cps-ncmp-rest-stub/src/main/java/org/onap/cps/ncmp/rest/stub/controller/NetworkCmProxyStubController.java
@@ -163,6 +163,16 @@ public class NetworkCmProxyStubController implements NetworkCmProxyApi {
}
@Override
+ public ResponseEntity<Object> queryResourceDataForCmHandle(final String datastoreName,
+ final String cmHandle,
+ final String cpsPath,
+ final String options,
+ final String topic,
+ final Boolean includeDescendants) {
+ return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
+ }
+
+ @Override
public ResponseEntity<RestOutputCmHandle> retrieveCmHandleDetailsById(final String cmHandleId) {
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
}
diff --git a/cps-ncmp-rest/docs/openapi/components.yaml b/cps-ncmp-rest/docs/openapi/components.yaml
index 7ca09ceedb..b4b8c84673 100644
--- a/cps-ncmp-rest/docs/openapi/components.yaml
+++ b/cps-ncmp-rest/docs/openapi/components.yaml
@@ -456,11 +456,16 @@ components:
cpsPathInQuery:
name: cps-path
in: query
- description: cps-path
+ description: For more details on cps path, please refer https://docs.onap.org/projects/onap-cps/en/latest/cps-path.html
required: false
schema:
type: string
default: /
+ examples:
+ container cps path:
+ value: //bookstore
+ list attributes cps path:
+ value: //categories[@code=1]
dmiPluginIdentifierInQuery:
name: dmi-plugin-identifier
in: query
@@ -527,7 +532,7 @@ components:
default: application/json
example: application/yang-data+json
datastoreName:
- name: ncmp-datastore-name
+ name: datastore-name
in: path
description: The type of the requested data
required: true
diff --git a/cps-ncmp-rest/docs/openapi/ncmp.yml b/cps-ncmp-rest/docs/openapi/ncmp.yml
index 38db26f470..1f7cce96ff 100755
--- a/cps-ncmp-rest/docs/openapi/ncmp.yml
+++ b/cps-ncmp-rest/docs/openapi/ncmp.yml
@@ -194,6 +194,41 @@ resourceDataForCmHandle:
502:
$ref: 'components.yaml#/components/responses/BadGateway'
+queryResourceDataForCmHandle:
+ get:
+ tags:
+ - network-cm-proxy
+ summary: Query resource data for a given cm handle
+ description: Query resource data for a given cm handle
+ operationId: queryResourceDataForCmHandle
+ parameters:
+ - $ref: 'components.yaml#/components/parameters/datastoreName'
+ - $ref: 'components.yaml#/components/parameters/cmHandleInPath'
+ - $ref: 'components.yaml#/components/parameters/cpsPathInQuery'
+ - $ref: 'components.yaml#/components/parameters/optionsParamInQuery'
+ - $ref: 'components.yaml#/components/parameters/topicParamInQuery'
+ - $ref: 'components.yaml#/components/parameters/includeDescendantsOptionInQuery'
+ responses:
+ 200:
+ description: OK
+ content:
+ application/json:
+ schema:
+ type: object
+ examples:
+ dataSampleResponse:
+ $ref: 'components.yaml#/components/examples/dataSampleResponse'
+ 400:
+ $ref: 'components.yaml#/components/responses/BadRequest'
+ 401:
+ $ref: 'components.yaml#/components/responses/Unauthorized'
+ 403:
+ $ref: 'components.yaml#/components/responses/Forbidden'
+ 500:
+ $ref: 'components.yaml#/components/responses/InternalServerError'
+ 502:
+ $ref: 'components.yaml#/components/responses/BadGateway'
+
fetchModuleReferencesByCmHandle:
get:
description: fetch all module references (name and revision) for a given cm handle
diff --git a/cps-ncmp-rest/docs/openapi/openapi.yml b/cps-ncmp-rest/docs/openapi/openapi.yml
index fe0c4acfc7..ee29366906 100755
--- a/cps-ncmp-rest/docs/openapi/openapi.yml
+++ b/cps-ncmp-rest/docs/openapi/openapi.yml
@@ -31,9 +31,12 @@ components:
type: http
scheme: basic
paths:
- /v1/ch/{cm-handle}/data/ds/{ncmp-datastore-name}:
+ /v1/ch/{cm-handle}/data/ds/{datastore-name}:
$ref: 'ncmp.yml#/resourceDataForCmHandle'
+ /v1/ch/{cm-handle}/data/ds/{datastore-name}/query:
+ $ref: 'ncmp.yml#/queryResourceDataForCmHandle'
+
/v1/ch/{cm-handle}/modules:
$ref: 'ncmp.yml#/fetchModuleReferencesByCmHandle'
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 2f6668a351..9f171f6094 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
@@ -39,7 +39,7 @@ import org.onap.cps.ncmp.api.models.CmHandleQueryApiParameters;
import org.onap.cps.ncmp.api.models.NcmpServiceCmHandle;
import org.onap.cps.ncmp.rest.api.NetworkCmProxyApi;
import org.onap.cps.ncmp.rest.controller.handlers.DatastoreType;
-import org.onap.cps.ncmp.rest.controller.handlers.NcmpDatastoreResourceRequestHandler;
+import org.onap.cps.ncmp.rest.controller.handlers.NcmpDatastoreRequestHandler;
import org.onap.cps.ncmp.rest.controller.handlers.NcmpDatastoreResourceRequestHandlerFactory;
import org.onap.cps.ncmp.rest.exceptions.InvalidDatastoreException;
import org.onap.cps.ncmp.rest.mapper.CmHandleStateMapper;
@@ -91,15 +91,42 @@ public class NetworkCmProxyController implements NetworkCmProxyApi {
final String topicParamInQuery,
final Boolean includeDescendants) {
- final NcmpDatastoreResourceRequestHandler ncmpDatastoreResourceRequestHandler =
+ final NcmpDatastoreRequestHandler ncmpDatastoreRequestHandler =
ncmpDatastoreResourceRequestHandlerFactory.getNcmpDatastoreResourceRequestHandler(
DatastoreType.fromDatastoreName(datastoreName));
- return ncmpDatastoreResourceRequestHandler.getResourceData(cmHandle, resourceIdentifier,
+ return ncmpDatastoreRequestHandler.executeRequest(cmHandle, resourceIdentifier,
optionsParamInQuery, topicParamInQuery, includeDescendants);
}
/**
+ * Query resource data from datastore.
+ *
+ * @param datastoreName name of the datastore
+ * @param cmHandle cm handle identifier
+ * @param cpsPath CPS Path
+ * @param optionsParamInQuery options query parameter
+ * @param topicParamInQuery topic query parameter
+ * @param includeDescendants whether include descendants
+ * @return {@code ResponseEntity} response from dmi plugin
+ */
+
+ @Override
+ public ResponseEntity<Object> queryResourceDataForCmHandle(final String datastoreName,
+ final String cmHandle,
+ final String cpsPath,
+ final String optionsParamInQuery,
+ final String topicParamInQuery,
+ final Boolean includeDescendants) {
+ validateDataStore(DatastoreType.OPERATIONAL, datastoreName);
+ final NcmpDatastoreRequestHandler ncmpDatastoreRequestHandler =
+ ncmpDatastoreResourceRequestHandlerFactory.getNcmpDatastoreResourceQueryHandler();
+
+ return ncmpDatastoreRequestHandler.executeRequest(cmHandle, cpsPath, optionsParamInQuery,
+ topicParamInQuery, includeDescendants);
+ }
+
+ /**
* Patch resource data from passthrough-running.
*
* @param resourceIdentifier resource identifier
@@ -117,7 +144,7 @@ public class NetworkCmProxyController implements NetworkCmProxyApi {
final Object requestBody,
final String contentType) {
- acceptPassthroughRunningOnly(datastoreName);
+ validateDataStore(DatastoreType.PASSTHROUGH_RUNNING, datastoreName);
final Object responseObject = networkCmProxyDataService
.writeResourceDataPassThroughRunningForCmHandle(
@@ -143,7 +170,7 @@ public class NetworkCmProxyController implements NetworkCmProxyApi {
final Object requestBody,
final String contentType) {
- acceptPassthroughRunningOnly(datastoreName);
+ validateDataStore(DatastoreType.PASSTHROUGH_RUNNING, datastoreName);
networkCmProxyDataService.writeResourceDataPassThroughRunningForCmHandle(cmHandle,
resourceIdentifier, CREATE, jsonObjectMapper.asJsonString(requestBody), contentType);
@@ -167,7 +194,7 @@ public class NetworkCmProxyController implements NetworkCmProxyApi {
final String cmHandle,
final Object requestBody,
final String contentType) {
- acceptPassthroughRunningOnly(datastoreName);
+ validateDataStore(DatastoreType.PASSTHROUGH_RUNNING, datastoreName);
networkCmProxyDataService.writeResourceDataPassThroughRunningForCmHandle(cmHandle,
resourceIdentifier, UPDATE, jsonObjectMapper.asJsonString(requestBody), contentType);
@@ -189,7 +216,7 @@ public class NetworkCmProxyController implements NetworkCmProxyApi {
final String resourceIdentifier,
final String contentType) {
- acceptPassthroughRunningOnly(datastoreName);
+ validateDataStore(DatastoreType.PASSTHROUGH_RUNNING, datastoreName);
networkCmProxyDataService.writeResourceDataPassThroughRunningForCmHandle(cmHandle,
resourceIdentifier, DELETE, NO_BODY, contentType);
@@ -332,11 +359,11 @@ public class NetworkCmProxyController implements NetworkCmProxyApi {
return restOutputCmHandle;
}
- private void acceptPassthroughRunningOnly(final String datastoreName) {
- final DatastoreType datastoreType = DatastoreType.fromDatastoreName(datastoreName);
+ private void validateDataStore(final DatastoreType acceptableDataStoreType, final String requestedDatastoreName) {
+ final DatastoreType datastoreType = DatastoreType.fromDatastoreName(requestedDatastoreName);
- if (DatastoreType.PASSTHROUGH_RUNNING != datastoreType) {
- throw new InvalidDatastoreException(datastoreName + " is not supported");
+ if (acceptableDataStoreType != datastoreType) {
+ throw new InvalidDatastoreException(requestedDatastoreName + " is not supported");
}
}
}
diff --git a/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/handlers/NcmpDatastoreOperationalQueryHandler.java b/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/handlers/NcmpDatastoreOperationalQueryHandler.java
new file mode 100644
index 0000000000..0586d42625
--- /dev/null
+++ b/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/handlers/NcmpDatastoreOperationalQueryHandler.java
@@ -0,0 +1,56 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2022 Nordix Foundation
+ * ================================================================================
+ * 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.rest.controller.handlers;
+
+import java.util.function.Supplier;
+import lombok.extern.slf4j.Slf4j;
+import org.onap.cps.ncmp.api.NetworkCmProxyQueryService;
+import org.onap.cps.ncmp.rest.executor.CpsNcmpTaskExecutor;
+import org.onap.cps.spi.FetchDescendantsOption;
+
+@Slf4j
+public class NcmpDatastoreOperationalQueryHandler extends NcmpDatastoreRequestHandler {
+
+ private final NetworkCmProxyQueryService networkCmProxyQueryService;
+
+ public NcmpDatastoreOperationalQueryHandler(final NetworkCmProxyQueryService networkCmProxyQueryService,
+ final CpsNcmpTaskExecutor cpsNcmpTaskExecutor,
+ final int timeOutInMilliSeconds,
+ final boolean notificationFeatureEnabled) {
+ super(null, cpsNcmpTaskExecutor, timeOutInMilliSeconds, notificationFeatureEnabled);
+ this.networkCmProxyQueryService = networkCmProxyQueryService;
+ }
+
+ @Override
+ public Supplier<Object> getTaskSupplier(final String cmHandle,
+ final String resourceIdentifier,
+ final String optionsParamInQuery,
+ final String topicParamInQuery,
+ final String requestId,
+ final Boolean includeDescendant) {
+
+ final FetchDescendantsOption fetchDescendantsOption = getFetchDescendantsOption(includeDescendant);
+
+ return () -> networkCmProxyQueryService.queryResourceDataOperational(cmHandle, resourceIdentifier,
+ fetchDescendantsOption);
+ }
+
+}
diff --git a/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/handlers/NcmpDatastoreOperationalResourceRequestHandler.java b/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/handlers/NcmpDatastoreOperationalResourceRequestHandler.java
index 6ed9b8c4d1..a4720b22ff 100644
--- a/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/handlers/NcmpDatastoreOperationalResourceRequestHandler.java
+++ b/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/handlers/NcmpDatastoreOperationalResourceRequestHandler.java
@@ -27,7 +27,7 @@ import org.onap.cps.ncmp.rest.executor.CpsNcmpTaskExecutor;
import org.onap.cps.spi.FetchDescendantsOption;
@Slf4j
-public class NcmpDatastoreOperationalResourceRequestHandler extends NcmpDatastoreResourceRequestHandler {
+public class NcmpDatastoreOperationalResourceRequestHandler extends NcmpDatastoreRequestHandler {
public NcmpDatastoreOperationalResourceRequestHandler(final NetworkCmProxyDataService networkCmProxyDataService,
final CpsNcmpTaskExecutor cpsNcmpTaskExecutor,
@@ -37,16 +37,14 @@ public class NcmpDatastoreOperationalResourceRequestHandler extends NcmpDatastor
}
@Override
- public Supplier<Object> getTask(final String cmHandle,
- final String resourceIdentifier,
- final String optionsParamInQuery,
- final String topicParamInQuery,
- final String requestId,
- final Boolean includeDescendant) {
-
- final FetchDescendantsOption fetchDescendantsOption =
- Boolean.TRUE.equals(includeDescendant) ? FetchDescendantsOption.INCLUDE_ALL_DESCENDANTS
- : FetchDescendantsOption.OMIT_DESCENDANTS;
+ public Supplier<Object> getTaskSupplier(final String cmHandle,
+ final String resourceIdentifier,
+ final String optionsParamInQuery,
+ final String topicParamInQuery,
+ final String requestId,
+ final Boolean includeDescendant) {
+
+ final FetchDescendantsOption fetchDescendantsOption = getFetchDescendantsOption(includeDescendant);
return () -> networkCmProxyDataService.getResourceDataOperational(cmHandle, resourceIdentifier,
fetchDescendantsOption);
diff --git a/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/handlers/NcmpDatastorePassthroughOperationalResourceRequestHandler.java b/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/handlers/NcmpDatastorePassthroughOperationalResourceRequestHandler.java
index 196e5bd33d..1445e3e271 100644
--- a/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/handlers/NcmpDatastorePassthroughOperationalResourceRequestHandler.java
+++ b/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/handlers/NcmpDatastorePassthroughOperationalResourceRequestHandler.java
@@ -26,7 +26,7 @@ import org.onap.cps.ncmp.api.NetworkCmProxyDataService;
import org.onap.cps.ncmp.rest.executor.CpsNcmpTaskExecutor;
@Slf4j
-public class NcmpDatastorePassthroughOperationalResourceRequestHandler extends NcmpDatastoreResourceRequestHandler {
+public class NcmpDatastorePassthroughOperationalResourceRequestHandler extends NcmpDatastoreRequestHandler {
public NcmpDatastorePassthroughOperationalResourceRequestHandler(
final NetworkCmProxyDataService networkCmProxyDataService,
@@ -37,12 +37,12 @@ public class NcmpDatastorePassthroughOperationalResourceRequestHandler extends N
}
@Override
- public Supplier<Object> getTask(final String cmHandle,
- final String resourceIdentifier,
- final String optionsParamInQuery,
- final String topicParamInQuery,
- final String requestId,
- final Boolean includeDescendant) {
+ public Supplier<Object> getTaskSupplier(final String cmHandle,
+ final String resourceIdentifier,
+ final String optionsParamInQuery,
+ final String topicParamInQuery,
+ final String requestId,
+ final Boolean includeDescendant) {
return () -> networkCmProxyDataService.getResourceDataOperationalForCmHandle(
cmHandle, resourceIdentifier, optionsParamInQuery, topicParamInQuery, requestId);
diff --git a/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/handlers/NcmpDatastorePassthroughRunningResourceRequestHandler.java b/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/handlers/NcmpDatastorePassthroughRunningResourceRequestHandler.java
index 5bf16b7499..8194ec9fd5 100644
--- a/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/handlers/NcmpDatastorePassthroughRunningResourceRequestHandler.java
+++ b/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/handlers/NcmpDatastorePassthroughRunningResourceRequestHandler.java
@@ -26,7 +26,7 @@ import org.onap.cps.ncmp.api.NetworkCmProxyDataService;
import org.onap.cps.ncmp.rest.executor.CpsNcmpTaskExecutor;
@Slf4j
-public class NcmpDatastorePassthroughRunningResourceRequestHandler extends NcmpDatastoreResourceRequestHandler {
+public class NcmpDatastorePassthroughRunningResourceRequestHandler extends NcmpDatastoreRequestHandler {
public NcmpDatastorePassthroughRunningResourceRequestHandler(
final NetworkCmProxyDataService networkCmProxyDataService,
@@ -37,12 +37,12 @@ public class NcmpDatastorePassthroughRunningResourceRequestHandler extends NcmpD
}
@Override
- public Supplier<Object> getTask(final String cmHandle,
- final String resourceIdentifier,
- final String optionsParamInQuery,
- final String topicParamInQuery,
- final String requestId,
- final Boolean includeDescendant) {
+ public Supplier<Object> getTaskSupplier(final String cmHandle,
+ final String resourceIdentifier,
+ final String optionsParamInQuery,
+ final String topicParamInQuery,
+ final String requestId,
+ final Boolean includeDescendant) {
return () -> networkCmProxyDataService.getResourceDataPassThroughRunningForCmHandle(
cmHandle, resourceIdentifier, optionsParamInQuery, topicParamInQuery, requestId);
diff --git a/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/handlers/NcmpDatastoreRequestHandler.java b/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/handlers/NcmpDatastoreRequestHandler.java
new file mode 100644
index 0000000000..850200396b
--- /dev/null
+++ b/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/handlers/NcmpDatastoreRequestHandler.java
@@ -0,0 +1,106 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2022 Nordix Foundation
+ * ================================================================================
+ * 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.rest.controller.handlers;
+
+import java.util.Map;
+import java.util.UUID;
+import java.util.function.Supplier;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.onap.cps.ncmp.api.NetworkCmProxyDataService;
+import org.onap.cps.ncmp.rest.executor.CpsNcmpTaskExecutor;
+import org.onap.cps.ncmp.rest.util.TopicValidator;
+import org.onap.cps.spi.FetchDescendantsOption;
+import org.springframework.http.ResponseEntity;
+
+@RequiredArgsConstructor
+@Slf4j
+public abstract class NcmpDatastoreRequestHandler {
+
+ private static final String NO_REQUEST_ID = null;
+ private static final String NO_TOPIC = null;
+
+ protected final NetworkCmProxyDataService networkCmProxyDataService;
+ protected final CpsNcmpTaskExecutor cpsNcmpTaskExecutor;
+ protected final int timeOutInMilliSeconds;
+ protected final boolean notificationFeatureEnabled;
+
+ protected abstract Supplier<Object> getTaskSupplier(final String cmHandle,
+ final String resourceIdentifier,
+ final String optionsParamInQuery,
+ final String topicParamInQuery,
+ final String requestId,
+ final Boolean includeDescendant);
+
+ /**
+ * Execute a request on a datastore.
+ *
+ * @param cmHandleId the cm handle
+ * @param resourceIdentifier the resource identifier
+ * @param optionsParamInQuery the options param in query
+ * @param topicParamInQuery the topic param in query
+ * @param includeDescendants whether include descendants
+ * @return the response entity
+ */
+ public ResponseEntity<Object> executeRequest(final String cmHandleId,
+ final String resourceIdentifier,
+ final String optionsParamInQuery,
+ final String topicParamInQuery,
+ final Boolean includeDescendants) {
+
+ final boolean asyncResponseRequested = topicParamInQuery != null;
+ if (asyncResponseRequested && notificationFeatureEnabled) {
+ final String requestId = UUID.randomUUID().toString();
+ final Supplier<Object> taskSupplier = getTaskSupplier(cmHandleId, resourceIdentifier, optionsParamInQuery,
+ topicParamInQuery, requestId, includeDescendants);
+ return executeTaskAsync(topicParamInQuery, requestId, taskSupplier);
+ }
+
+ if (asyncResponseRequested) {
+ log.warn("Asynchronous request is unavailable as notification feature is currently disabled, "
+ + "will use synchronous operation.");
+ }
+ final Supplier<Object> taskSupplier = getTaskSupplier(cmHandleId, resourceIdentifier, optionsParamInQuery,
+ NO_TOPIC, NO_REQUEST_ID, includeDescendants);
+ return executeTaskSync(taskSupplier);
+ }
+
+ protected ResponseEntity<Object> executeTaskAsync(final String topicParamInQuery,
+ final String requestId,
+ final Supplier<Object> taskSupplier) {
+
+ TopicValidator.validateTopicName(topicParamInQuery);
+ log.debug("Received Async request with id {}", requestId);
+ cpsNcmpTaskExecutor.executeTask(taskSupplier, timeOutInMilliSeconds);
+
+ return ResponseEntity.ok(Map.of("requestId", requestId));
+ }
+
+ protected ResponseEntity<Object> executeTaskSync(final Supplier<Object> taskSupplier) {
+ return ResponseEntity.ok(taskSupplier.get());
+ }
+
+ protected static FetchDescendantsOption getFetchDescendantsOption(final Boolean includeDescendant) {
+ return Boolean.TRUE.equals(includeDescendant) ? FetchDescendantsOption.INCLUDE_ALL_DESCENDANTS
+ : FetchDescendantsOption.OMIT_DESCENDANTS;
+ }
+
+}
diff --git a/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/handlers/NcmpDatastoreResourceRequestHandler.java b/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/handlers/NcmpDatastoreResourceRequestHandler.java
deleted file mode 100644
index a6d313b05f..0000000000
--- a/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/handlers/NcmpDatastoreResourceRequestHandler.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Copyright (C) 2022 Nordix Foundation
- * ================================================================================
- * 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.rest.controller.handlers;
-
-import java.util.Map;
-import java.util.UUID;
-import java.util.function.Supplier;
-import lombok.RequiredArgsConstructor;
-import lombok.extern.slf4j.Slf4j;
-import org.onap.cps.ncmp.api.NetworkCmProxyDataService;
-import org.onap.cps.ncmp.rest.executor.CpsNcmpTaskExecutor;
-import org.onap.cps.ncmp.rest.util.TopicValidator;
-import org.springframework.http.ResponseEntity;
-
-@RequiredArgsConstructor
-@Slf4j
-public abstract class NcmpDatastoreResourceRequestHandler {
-
- private static final String NO_REQUEST_ID = null;
- private static final String NO_TOPIC = null;
-
- protected final NetworkCmProxyDataService networkCmProxyDataService;
- protected final CpsNcmpTaskExecutor cpsNcmpTaskExecutor;
- protected final int timeOutInMilliSeconds;
- protected final boolean notificationFeatureEnabled;
-
- protected abstract Supplier<Object> getTask(final String cmHandle,
- final String resourceIdentifier,
- final String optionsParamInQuery,
- final String topicParamInQuery,
- final String requestId,
- final Boolean includeDescendant);
-
-
- /**
- * Get resource data from datastore.
- *
- * @param cmHandleId the cm handle
- * @param resourceIdentifier the resource identifier
- * @param optionsParamInQuery the options param in query
- * @param topicParamInQuery the topic param in query
- * @param includeDescendants whether include descendants
- * @return the response entity
- */
- public ResponseEntity<Object> getResourceData(final String cmHandleId,
- final String resourceIdentifier,
- final String optionsParamInQuery,
- final String topicParamInQuery,
- final Boolean includeDescendants) {
-
- final String requestId = UUID.randomUUID().toString();
- final boolean asyncResponseRequested = topicParamInQuery != null;
-
- if (asyncResponseRequested && notificationFeatureEnabled) {
- TopicValidator.validateTopicName(topicParamInQuery);
- log.debug("Received Async request with id {}", requestId);
- cpsNcmpTaskExecutor.executeTask(
- getTask(cmHandleId, resourceIdentifier, optionsParamInQuery, topicParamInQuery, requestId,
- includeDescendants), timeOutInMilliSeconds);
-
- return ResponseEntity.ok(Map.of("requestId", requestId));
- }
-
- if (asyncResponseRequested) {
- log.warn("Asynchronous messaging is currently disabled, will use synchronous operation.");
- }
-
- final Object responseObject =
- getTask(cmHandleId, resourceIdentifier, optionsParamInQuery, NO_TOPIC, NO_REQUEST_ID,
- includeDescendants).get();
-
- return ResponseEntity.ok(responseObject);
- }
-}
diff --git a/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/handlers/NcmpDatastoreResourceRequestHandlerFactory.java b/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/handlers/NcmpDatastoreResourceRequestHandlerFactory.java
index 7db754279c..ff7bda6a47 100644
--- a/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/handlers/NcmpDatastoreResourceRequestHandlerFactory.java
+++ b/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/handlers/NcmpDatastoreResourceRequestHandlerFactory.java
@@ -22,6 +22,7 @@ package org.onap.cps.ncmp.rest.controller.handlers;
import lombok.RequiredArgsConstructor;
import org.onap.cps.ncmp.api.NetworkCmProxyDataService;
+import org.onap.cps.ncmp.api.NetworkCmProxyQueryService;
import org.onap.cps.ncmp.rest.executor.CpsNcmpTaskExecutor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
@@ -31,6 +32,7 @@ import org.springframework.stereotype.Component;
public class NcmpDatastoreResourceRequestHandlerFactory {
private final NetworkCmProxyDataService networkCmProxyDataService;
+ private final NetworkCmProxyQueryService networkCmProxyQueryService;
private final CpsNcmpTaskExecutor cpsNcmpTaskExecutor;
@Value("${notification.async.executor.time-out-value-in-ms:2000}")
@@ -44,7 +46,7 @@ public class NcmpDatastoreResourceRequestHandlerFactory {
* @param datastoreType the datastore type
* @return the ncmp datastore handler
*/
- public NcmpDatastoreResourceRequestHandler getNcmpDatastoreResourceRequestHandler(
+ public NcmpDatastoreRequestHandler getNcmpDatastoreResourceRequestHandler(
final DatastoreType datastoreType) {
switch (datastoreType) {
@@ -60,4 +62,15 @@ public class NcmpDatastoreResourceRequestHandlerFactory {
cpsNcmpTaskExecutor, timeOutInMilliSeconds, notificationFeatureEnabled);
}
}
+
+ /**
+ * Gets ncmp datastore query handler.
+ * Note. Currently only ncmp-datastore:operational supports query operations
+ * @return a ncmp datastore query handler.
+ */
+ public NcmpDatastoreRequestHandler getNcmpDatastoreResourceQueryHandler() {
+ return new NcmpDatastoreOperationalQueryHandler(networkCmProxyQueryService, cpsNcmpTaskExecutor,
+ timeOutInMilliSeconds, notificationFeatureEnabled);
+ }
+
}
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 b6194bc796..d67804e128 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
@@ -27,20 +27,24 @@ import com.fasterxml.jackson.databind.ObjectMapper
import org.mapstruct.factory.Mappers
import org.onap.cps.TestUtils
import org.onap.cps.ncmp.api.NetworkCmProxyDataService
+import org.onap.cps.ncmp.api.NetworkCmProxyQueryService
import org.onap.cps.ncmp.api.inventory.CmHandleState
import org.onap.cps.ncmp.api.inventory.CompositeState
import org.onap.cps.ncmp.api.inventory.DataStoreSyncState
import org.onap.cps.ncmp.api.inventory.LockReasonCategory
import org.onap.cps.ncmp.api.models.NcmpServiceCmHandle
import org.onap.cps.ncmp.rest.controller.handlers.DatastoreType
+import org.onap.cps.ncmp.rest.controller.handlers.NcmpDatastoreOperationalQueryHandler
import org.onap.cps.ncmp.rest.controller.handlers.NcmpDatastoreOperationalResourceRequestHandler
import org.onap.cps.ncmp.rest.controller.handlers.NcmpDatastorePassthroughOperationalResourceRequestHandler
import org.onap.cps.ncmp.rest.controller.handlers.NcmpDatastorePassthroughRunningResourceRequestHandler
import org.onap.cps.ncmp.rest.controller.handlers.NcmpDatastoreResourceRequestHandlerFactory
+import org.onap.cps.ncmp.rest.exceptions.InvalidDatastoreException
import org.onap.cps.ncmp.rest.executor.CpsNcmpTaskExecutor
import org.onap.cps.ncmp.rest.mapper.CmHandleStateMapper
import org.onap.cps.ncmp.rest.util.DeprecationHelper
import org.onap.cps.spi.FetchDescendantsOption
+import org.onap.cps.spi.exceptions.DataValidationException
import org.onap.cps.spi.model.ModuleDefinition
import org.onap.cps.spi.model.ModuleReference
import org.onap.cps.utils.JsonObjectMapper
@@ -84,6 +88,9 @@ class NetworkCmProxyControllerSpec extends Specification {
NetworkCmProxyDataService mockNetworkCmProxyDataService = Mock()
@SpringBean
+ NetworkCmProxyQueryService mockNetworkCmProxyQueryService = Mock()
+
+ @SpringBean
ObjectMapper objectMapper = new ObjectMapper()
@SpringBean
@@ -131,6 +138,10 @@ class NetworkCmProxyControllerSpec extends Specification {
DatastoreType.PASSTHROUGH_RUNNING) >>
new NcmpDatastorePassthroughRunningResourceRequestHandler(
mockNetworkCmProxyDataService, spiedCpsTaskExecutor, TIMEOUT_IN_MS, NOTIFICATION_ENABLED)
+
+ stubbedNcmpDatastoreResourceRequestHandlerFactory.getNcmpDatastoreResourceQueryHandler() >>
+ new NcmpDatastoreOperationalQueryHandler(mockNetworkCmProxyQueryService, spiedCpsTaskExecutor,
+ TIMEOUT_IN_MS, NOTIFICATION_ENABLED);
}
def 'Get Resource Data from pass-through operational.'() {
@@ -194,6 +205,40 @@ class NetworkCmProxyControllerSpec extends Specification {
'invalid non-empty topic value in url' | 'passthrough-running' | '&topic=1_5_*_#'
}
+ def 'Query Resource Data from operational.'() {
+ given: 'the query resource data url'
+ def getUrl = "$ncmpBasePathV1/ch/testCmHandle/data/ds/ncmp-datastore:operational/query" +
+ "?cps-path=/cps/path"
+ when: 'the query data resource request is performed'
+ def response = mvc.perform(
+ get(getUrl)
+ .contentType(MediaType.APPLICATION_JSON)
+ ).andReturn().response
+ then: 'the NCMP query service is called with queryResourceDataOperationalForCmHandle'
+ 1 * mockNetworkCmProxyQueryService.queryResourceDataOperational('testCmHandle',
+ '/cps/path',
+ FetchDescendantsOption.OMIT_DESCENDANTS)
+ and: 'response status is Ok'
+ response.status == HttpStatus.OK.value()
+ }
+
+ def 'Query Resource Data using datastore of #datastore'() {
+ given: 'the query resource data url'
+ def getUrl = "$ncmpBasePathV1/ch/testCmHandle/data/ds/ncmp-datastore:${datastore}/query" +
+ "?cps-path=/cps/path"
+ when: 'the query data resource request is performed'
+ def response = mvc.perform(
+ get(getUrl)
+ .contentType(MediaType.APPLICATION_JSON)
+ ).andReturn().response
+ then: 'a 400 BAD_REQUEST is returned for the unsupported datastore'
+ response.status == 400
+ and: 'the error message is that datastore #datastore is not supported'
+ response.contentAsString.contains("ncmp-datastore:${datastore} is not supported")
+ where: 'the following datastore is used'
+ datastore << ["passthrough-running", "passthrough-operational"]
+ }
+
def 'Get Resource Data from pass-through running with #scenario value in resource identifier param.'() {
given: 'resource data url'
def getUrl = "$ncmpBasePathV1/ch/testCmHandle/data/ds/ncmp-datastore:passthrough-running" +
diff --git a/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/handlers/NcmpDatastoreRequestHandlerFactorySpec.groovy b/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/handlers/NcmpDatastoreRequestHandlerFactorySpec.groovy
new file mode 100644
index 0000000000..7c504981e2
--- /dev/null
+++ b/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/handlers/NcmpDatastoreRequestHandlerFactorySpec.groovy
@@ -0,0 +1,40 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2022 Nordix Foundation
+ * ================================================================================
+ * 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.rest.controller.handlers
+
+import spock.lang.Specification
+
+class NcmpDatastoreRequestHandlerFactorySpec extends Specification {
+
+ def objectUnderTest = new NcmpDatastoreResourceRequestHandlerFactory(null, null, null)
+
+ def 'Creating ncmp datastore request handlers.'() {
+ when: 'a ncmp datastore request handler is created for #datastoreType'
+ def result = objectUnderTest.getNcmpDatastoreResourceRequestHandler(datastoreType)
+ then: 'the result is of the expected class'
+ result.class == expectedClass
+ where: 'the following type of datastore is used'
+ datastoreType || expectedClass
+ DatastoreType.OPERATIONAL || NcmpDatastoreOperationalResourceRequestHandler
+ DatastoreType.PASSTHROUGH_OPERATIONAL || NcmpDatastorePassthroughOperationalResourceRequestHandler
+ DatastoreType.PASSTHROUGH_RUNNING || NcmpDatastorePassthroughRunningResourceRequestHandler
+ }
+}
diff --git a/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/handlers/NcmpDatastoreResourceRequestHandlerFactorySpec.groovy b/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/handlers/NcmpDatastoreResourceRequestHandlerFactorySpec.groovy
deleted file mode 100644
index 3f7a8a5ce2..0000000000
--- a/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/handlers/NcmpDatastoreResourceRequestHandlerFactorySpec.groovy
+++ /dev/null
@@ -1,20 +0,0 @@
-package org.onap.cps.ncmp.rest.controller.handlers
-
-import spock.lang.Specification
-
-class NcmpDatastoreResourceRequestHandlerFactorySpec extends Specification {
-
- def objectUnderTest = new NcmpDatastoreResourceRequestHandlerFactory(null, null)
-
- def 'Creating ncmp datastore request handlers.'() {
- when: 'a ncmp datastore request handler is created for #datastoreType'
- def result = objectUnderTest.getNcmpDatastoreResourceRequestHandler(datastoreType)
- then: 'the result is of the expected class'
- result.class == expectedClass
- where: 'the following type of datastore is used'
- datastoreType || expectedClass
- DatastoreType.OPERATIONAL || NcmpDatastoreOperationalResourceRequestHandler
- DatastoreType.PASSTHROUGH_OPERATIONAL || NcmpDatastorePassthroughOperationalResourceRequestHandler
- DatastoreType.PASSTHROUGH_RUNNING || NcmpDatastorePassthroughRunningResourceRequestHandler
- }
-} \ No newline at end of file
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/NetworkCmProxyQueryService.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/NetworkCmProxyQueryService.java
new file mode 100644
index 0000000000..340806b892
--- /dev/null
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/NetworkCmProxyQueryService.java
@@ -0,0 +1,41 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2022 Nordix Foundation
+ * ================================================================================
+ * 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.api;
+
+import org.onap.cps.spi.FetchDescendantsOption;
+
+/*
+ * Datastore interface for handling cached CPS data query requests.
+ */
+public interface NetworkCmProxyQueryService {
+
+ /**
+ * Get resource data for operational.
+ *
+ * @param cmHandleId cm handle identifier
+ * @param cpsPath cps path
+ * @Link FetchDescendantsOption fetch descendants option
+ * @return {@code Object} resource data
+ */
+ Object queryResourceDataOperational(String cmHandleId,
+ String cpsPath,
+ FetchDescendantsOption fetchDescendantsOption);
+}
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyQueryServiceImpl.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyQueryServiceImpl.java
new file mode 100644
index 0000000000..5540ecd213
--- /dev/null
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyQueryServiceImpl.java
@@ -0,0 +1,46 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2022 Nordix Foundation
+ * ================================================================================
+ * 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.api.impl;
+
+import static org.onap.cps.ncmp.api.impl.constants.DmiRegistryConstants.NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME;
+
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.onap.cps.api.CpsQueryService;
+import org.onap.cps.ncmp.api.NetworkCmProxyQueryService;
+import org.onap.cps.spi.FetchDescendantsOption;
+import org.springframework.stereotype.Service;
+
+@Slf4j
+@Service
+@RequiredArgsConstructor
+public class NetworkCmProxyQueryServiceImpl implements NetworkCmProxyQueryService {
+
+ private final CpsQueryService cpsQueryService;
+
+ @Override
+ public Object queryResourceDataOperational(final String cmHandleId,
+ final String cpsPath,
+ final FetchDescendantsOption fetchDescendantsOption) {
+ return cpsQueryService.queryDataNodes(NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME, cmHandleId, cpsPath,
+ fetchDescendantsOption);
+ }
+}
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyQueryServiceImplSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyQueryServiceImplSpec.groovy
new file mode 100644
index 0000000000..1e86a0b80a
--- /dev/null
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyQueryServiceImplSpec.groovy
@@ -0,0 +1,46 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2022 Nordix Foundation
+ * ================================================================================
+ * 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.api.impl
+
+import org.onap.cps.api.CpsQueryService
+import org.onap.cps.spi.FetchDescendantsOption
+import org.onap.cps.spi.model.DataNode
+import spock.lang.Specification
+
+class NetworkCmProxyQueryServiceImplSpec extends Specification {
+
+ def mockCpsQueryService = Mock(CpsQueryService)
+
+ def objectUnderTest = new NetworkCmProxyQueryServiceImpl(mockCpsQueryService)
+
+ def 'Query resource data for operational from DMI.'() {
+ given: 'a list of datanodes'
+ def dataNodes = [new DataNode(xpath: '/cps/path'), new DataNode(xpath: '/cps/path/child')]
+ and: 'the list of datanodes is returned for query data node'
+ 1 * mockCpsQueryService.queryDataNodes('NFP-Operational', 'ncmp-dmi-registry',
+ '//cps/path', FetchDescendantsOption.INCLUDE_ALL_DESCENDANTS) >> dataNodes
+ when: 'query resource data operational for cm-handle is called'
+ def response = objectUnderTest.queryResourceDataOperational('ncmp-dmi-registry',
+ '//cps/path', FetchDescendantsOption.INCLUDE_ALL_DESCENDANTS)
+ then: 'the expected datanodes are returned from the DMI'
+ response == dataNodes
+ }
+}
diff --git a/cps-rest/docs/openapi/components.yml b/cps-rest/docs/openapi/components.yml
index 269e724b18..fb0947e54a 100644
--- a/cps-rest/docs/openapi/components.yml
+++ b/cps-rest/docs/openapi/components.yml
@@ -1,6 +1,7 @@
# ============LICENSE_START=======================================================
# Copyright (c) 2021-2022 Bell Canada.
# Modifications Copyright (C) 2021-2022 Nordix Foundation
+# Modifications Copyright (C) 2022 TechMahindra Ltd.
# ================================================================================
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -34,6 +35,14 @@ components:
type: string
example: my-schema-set
+ DataspaceDetails:
+ type: object
+ title: Dataspace details by dataspace Name
+ properties:
+ name:
+ type: string
+ example: my-dataspace
+
ErrorMessage:
type: object
title: Error
diff --git a/cps-rest/docs/openapi/cpsAdmin.yml b/cps-rest/docs/openapi/cpsAdmin.yml
index 5852c0cf16..e887ef2c07 100644
--- a/cps-rest/docs/openapi/cpsAdmin.yml
+++ b/cps-rest/docs/openapi/cpsAdmin.yml
@@ -1,6 +1,7 @@
# ============LICENSE_START=======================================================
# Copyright (c) 2021 Bell Canada.
# Modifications Copyright (C) 2021-2022 Nordix Foundation
+# Modifications Copyright (C) 2022 TechMahindra Ltd.
# ================================================================================
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -233,4 +234,54 @@ anchorByDataspaceAndAnchorName:
'403':
$ref: 'components.yml#/components/responses/Forbidden'
'500':
- $ref: 'components.yml#/components/responses/InternalServerError' \ No newline at end of file
+ $ref: 'components.yml#/components/responses/InternalServerError'
+
+adminDataspaces:
+ get:
+ description: Read all dataspaces
+ tags:
+ - cps-admin
+ summary: Get all dataspaces
+ operationId: getAllDataspaces
+ responses:
+ '200':
+ description: OK
+ content:
+ application/json:
+ schema:
+ type: array
+ items:
+ $ref: 'components.yml#/components/schemas/DataspaceDetails'
+ '400':
+ $ref: 'components.yml#/components/responses/BadRequest'
+ '401':
+ $ref: 'components.yml#/components/responses/Unauthorized'
+ '403':
+ $ref: 'components.yml#/components/responses/Forbidden'
+ '500':
+ $ref: 'components.yml#/components/responses/InternalServerError'
+
+adminDataspace:
+ get:
+ description: Read a dataspace given a dataspace name
+ tags:
+ - cps-admin
+ summary: Get a dataspace
+ operationId: getDataspace
+ parameters:
+ - $ref: 'components.yml#/components/parameters/dataspaceNameInPath'
+ responses:
+ '200':
+ description: OK
+ content:
+ application/json:
+ schema:
+ $ref: 'components.yml#/components/schemas/DataspaceDetails'
+ '400':
+ $ref: 'components.yml#/components/responses/BadRequest'
+ '401':
+ $ref: 'components.yml#/components/responses/Unauthorized'
+ '403':
+ $ref: 'components.yml#/components/responses/Forbidden'
+ '500':
+ $ref: 'components.yml#/components/responses/InternalServerError'
diff --git a/cps-rest/docs/openapi/openapi.yml b/cps-rest/docs/openapi/openapi.yml
index 290bbf44b2..e170295504 100644
--- a/cps-rest/docs/openapi/openapi.yml
+++ b/cps-rest/docs/openapi/openapi.yml
@@ -2,6 +2,7 @@
# Copyright (C) 2021 Nordix Foundation
# Modifications Copyright (C) 2021 Pantheon.tech
# Modifications Copyright (C) 2021 Bell Canada.
+# Modifications Copyright (C) 2022 TechMahindra Ltd.
# ================================================================================
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -52,6 +53,12 @@ paths:
/v1/dataspaces:
$ref: 'cpsAdmin.yml#/dataspaces'
+ /v1/admin/dataspaces:
+ $ref: 'cpsAdmin.yml#/adminDataspaces'
+
+ /v1/admin/dataspaces/{dataspace-name}:
+ $ref: 'cpsAdmin.yml#/adminDataspace'
+
/v1/dataspaces/{dataspace-name}/anchors:
$ref: 'cpsAdmin.yml#/anchorsByDataspace'
diff --git a/cps-rest/src/main/java/org/onap/cps/rest/controller/AdminRestController.java b/cps-rest/src/main/java/org/onap/cps/rest/controller/AdminRestController.java
index 2707d9f294..a29f8d2969 100755
--- a/cps-rest/src/main/java/org/onap/cps/rest/controller/AdminRestController.java
+++ b/cps-rest/src/main/java/org/onap/cps/rest/controller/AdminRestController.java
@@ -3,6 +3,7 @@
* Copyright (C) 2020-2022 Nordix Foundation
* Modifications Copyright (C) 2020-2021 Bell Canada.
* Modifications Copyright (C) 2021 Pantheon.tech
+ * Modifications Copyright (C) 2022 TechMahindra Ltd.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -35,8 +36,10 @@ import org.onap.cps.api.CpsAdminService;
import org.onap.cps.api.CpsModuleService;
import org.onap.cps.rest.api.CpsAdminApi;
import org.onap.cps.rest.model.AnchorDetails;
+import org.onap.cps.rest.model.DataspaceDetails;
import org.onap.cps.rest.model.SchemaSetDetails;
import org.onap.cps.spi.model.Anchor;
+import org.onap.cps.spi.model.Dataspace;
import org.onap.cps.spi.model.SchemaSet;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
@@ -174,4 +177,19 @@ public class AdminRestController implements CpsAdminApi {
.collect(Collectors.toList());
return new ResponseEntity<>(anchorDetails, HttpStatus.OK);
}
+
+ @Override
+ public ResponseEntity<List<DataspaceDetails>> getAllDataspaces() {
+ final Collection<Dataspace> dataspaces = cpsAdminService.getAllDataspaces();
+ final List<DataspaceDetails> dataspaceDetails = dataspaces.stream().map(cpsRestInputMapper::toDataspaceDetails)
+ .collect(Collectors.toList());
+ return new ResponseEntity<>(dataspaceDetails, HttpStatus.OK);
+ }
+
+ @Override
+ public ResponseEntity<DataspaceDetails> getDataspace(final String dataspaceName) {
+ final Dataspace dataspace = cpsAdminService.getDataspace(dataspaceName);
+ final DataspaceDetails dataspaceDetails = cpsRestInputMapper.toDataspaceDetails(dataspace);
+ return new ResponseEntity<>(dataspaceDetails, HttpStatus.OK);
+ }
}
diff --git a/cps-rest/src/main/java/org/onap/cps/rest/controller/CpsRestInputMapper.java b/cps-rest/src/main/java/org/onap/cps/rest/controller/CpsRestInputMapper.java
index d0a4a108c8..3d3ab1145b 100644
--- a/cps-rest/src/main/java/org/onap/cps/rest/controller/CpsRestInputMapper.java
+++ b/cps-rest/src/main/java/org/onap/cps/rest/controller/CpsRestInputMapper.java
@@ -1,6 +1,7 @@
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2022 Nordix Foundation
+ * Modifications Copyright (C) 2022 TechMahindra Ltd.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -25,8 +26,10 @@ import org.mapstruct.Mapping;
import org.mapstruct.NullValueCheckStrategy;
import org.mapstruct.NullValuePropertyMappingStrategy;
import org.onap.cps.rest.model.AnchorDetails;
+import org.onap.cps.rest.model.DataspaceDetails;
import org.onap.cps.rest.model.SchemaSetDetails;
import org.onap.cps.spi.model.Anchor;
+import org.onap.cps.spi.model.Dataspace;
import org.onap.cps.spi.model.SchemaSet;
@Mapper(componentModel = "spring")
@@ -39,4 +42,5 @@ public interface CpsRestInputMapper {
AnchorDetails toAnchorDetails(final Anchor anchor);
+ DataspaceDetails toDataspaceDetails(final Dataspace dataspace);
}
diff --git a/cps-rest/src/test/groovy/org/onap/cps/rest/controller/AdminRestControllerSpec.groovy b/cps-rest/src/test/groovy/org/onap/cps/rest/controller/AdminRestControllerSpec.groovy
index 41ad9ca5b2..e9612fc395 100755
--- a/cps-rest/src/test/groovy/org/onap/cps/rest/controller/AdminRestControllerSpec.groovy
+++ b/cps-rest/src/test/groovy/org/onap/cps/rest/controller/AdminRestControllerSpec.groovy
@@ -3,6 +3,7 @@
* Copyright (C) 2020-2021 Pantheon.tech
* Modifications Copyright (C) 2020-2021 Bell Canada.
* Modifications Copyright (C) 2021-2022 Nordix Foundation
+ * Modifications Copyright (C) 2022 TechMahindra Ltd.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -34,6 +35,7 @@ import org.onap.cps.api.CpsModuleService
import org.onap.cps.spi.exceptions.AlreadyDefinedException
import org.onap.cps.spi.exceptions.SchemaSetInUseException
import org.onap.cps.spi.model.Anchor
+import org.onap.cps.spi.model.Dataspace
import org.onap.cps.spi.model.SchemaSet
import org.spockframework.spring.SpringBean
import org.springframework.beans.factory.annotation.Autowired
@@ -69,6 +71,7 @@ class AdminRestControllerSpec extends Specification {
def anchorName = 'my_anchor'
def schemaSetName = 'my_schema_set'
def anchor = new Anchor(name: anchorName, dataspaceName: dataspaceName, schemaSetName: schemaSetName)
+ def dataspace = new Dataspace(name: dataspaceName)
def 'Create new dataspace.'() {
given: 'an endpoint'
@@ -101,6 +104,31 @@ class AdminRestControllerSpec extends Specification {
response.status == HttpStatus.CONFLICT.value()
}
+ def 'Get a dataspace.'() {
+ given: 'service method returns a dataspace'
+ mockCpsAdminService.getDataspace(dataspaceName) >> dataspace
+ and: 'an endpoint'
+ def getDataspaceEndpoint = "$basePath/v1/admin/dataspaces/$dataspaceName"
+ when: 'get dataspace API is invoked'
+ def response = mvc.perform(get(getDataspaceEndpoint)).andReturn().response
+ then: 'the correct dataspace is returned'
+ response.status == HttpStatus.OK.value()
+ response.getContentAsString().contains(dataspaceName)
+ }
+
+ def 'Get all dataspaces.'() {
+ given: 'service method returns all dataspace'
+ mockCpsAdminService.getAllDataspaces() >> [dataspace, new Dataspace(name: "dataspace-test2")]
+ and: 'an endpoint'
+ def getAllDataspaceEndpoint = "$basePath/v1/admin/dataspaces"
+ when: 'get all dataspace API is invoked'
+ def response = mvc.perform(get(getAllDataspaceEndpoint)).andReturn().response
+ then: 'the correct dataspace is returned'
+ response.status == HttpStatus.OK.value()
+ response.getContentAsString().contains(dataspaceName)
+ response.getContentAsString().contains("dataspace-test2")
+ }
+
def 'Create schema set from yang file.'() {
def yangResourceMapCapture
given: 'single yang file'
diff --git a/cps-ri/src/main/java/org/onap/cps/spi/impl/CpsAdminPersistenceServiceImpl.java b/cps-ri/src/main/java/org/onap/cps/spi/impl/CpsAdminPersistenceServiceImpl.java
index 20a39f98e3..2cebfc72c0 100755
--- a/cps-ri/src/main/java/org/onap/cps/spi/impl/CpsAdminPersistenceServiceImpl.java
+++ b/cps-ri/src/main/java/org/onap/cps/spi/impl/CpsAdminPersistenceServiceImpl.java
@@ -3,6 +3,7 @@
* Copyright (C) 2020-2022 Nordix Foundation.
* Modifications Copyright (C) 2020-2022 Bell Canada.
* Modifications Copyright (C) 2021 Pantheon.tech
+ * Modifications Copyright (C) 2022 TechMahindra Ltd.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -39,6 +40,7 @@ import org.onap.cps.spi.exceptions.DataspaceInUseException;
import org.onap.cps.spi.exceptions.DataspaceNotFoundException;
import org.onap.cps.spi.exceptions.ModuleNamesNotFoundException;
import org.onap.cps.spi.model.Anchor;
+import org.onap.cps.spi.model.Dataspace;
import org.onap.cps.spi.repository.AnchorRepository;
import org.onap.cps.spi.repository.DataspaceRepository;
import org.onap.cps.spi.repository.SchemaSetRepository;
@@ -82,6 +84,19 @@ public class CpsAdminPersistenceServiceImpl implements CpsAdminPersistenceServic
}
@Override
+ public Dataspace getDataspace(final String dataspaceName) {
+ final DataspaceEntity dataspaceEntity = dataspaceRepository.getByName(dataspaceName);
+ return toDataspace(dataspaceEntity);
+ }
+
+ @Override
+ public Collection<Dataspace> getAllDataspaces() {
+ final Collection<DataspaceEntity> dataspaceEntities = dataspaceRepository.findAll();
+ return dataspaceEntities.stream().map(CpsAdminPersistenceServiceImpl::toDataspace)
+ .collect(Collectors.toSet());
+ }
+
+ @Override
public void createAnchor(final String dataspaceName, final String schemaSetName, final String anchorName) {
final var dataspaceEntity = dataspaceRepository.getByName(dataspaceName);
final var schemaSetEntity =
@@ -155,6 +170,10 @@ public class CpsAdminPersistenceServiceImpl implements CpsAdminPersistenceServic
.build();
}
+ private static Dataspace toDataspace(final DataspaceEntity dataspaceEntity) {
+ return Dataspace.builder().name(dataspaceEntity.getName()).build();
+ }
+
private void validateDataspaceAndModuleNames(final String dataspaceName,
final Collection<String> inputModuleNames) {
final Collection<String> retrievedModuleReferences =
diff --git a/cps-ri/src/test/groovy/org/onap/cps/spi/impl/CpsAdminPersistenceServiceSpec.groovy b/cps-ri/src/test/groovy/org/onap/cps/spi/impl/CpsAdminPersistenceServiceSpec.groovy
index cdb3e6c735..99d44aac89 100644
--- a/cps-ri/src/test/groovy/org/onap/cps/spi/impl/CpsAdminPersistenceServiceSpec.groovy
+++ b/cps-ri/src/test/groovy/org/onap/cps/spi/impl/CpsAdminPersistenceServiceSpec.groovy
@@ -3,6 +3,7 @@
* Copyright (C) 2021-2022 Nordix Foundation
* Modifications Copyright (C) 2021 Pantheon.tech
* Modifications Copyright (C) 2022 Bell Canada
+ * Modifications Copyright (C) 2022 TechMahindra Ltd.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -30,6 +31,7 @@ import org.onap.cps.spi.exceptions.DataspaceInUseException
import org.onap.cps.spi.exceptions.DataspaceNotFoundException
import org.onap.cps.spi.exceptions.SchemaSetNotFoundException
import org.onap.cps.spi.model.Anchor
+import org.onap.cps.spi.model.Dataspace
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.test.context.jdbc.Sql
import org.testcontainers.shaded.com.fasterxml.jackson.databind.ObjectMapper
@@ -68,6 +70,32 @@ class CpsAdminPersistenceServiceSpec extends CpsPersistenceSpecBase {
}
@Sql([CLEAR_DATA, SET_DATA])
+ def 'Get a dataspace.'() {
+ when: 'dataspace is retrieved'
+ def dataspace = objectUnderTest.getDataspace(DATASPACE_NAME)
+ then: ' the response contains expected dataspace'
+ assert dataspace.getName().equals(DATASPACE_NAME);
+ }
+
+ @Sql([CLEAR_DATA, SET_DATA])
+ def 'Get all dataspaces.'() {
+ when: 'all dataspaces are retrieved'
+ def dataspaces = objectUnderTest.getAllDataspaces()
+ then: 'the response contains expected dataspaces'
+ def expectedDataspaces = Set.of(new Dataspace(name: 'DATASPACE-001'), new Dataspace(name: 'DATASPACE-002-NO-DATA'),
+ new Dataspace(name: 'DATASPACE-003'))
+ assert dataspaces == expectedDataspaces
+ }
+
+ @Sql([CLEAR_DATA, SET_DATA])
+ def 'Get non existing dataspace.'() {
+ when: 'attempting to retrieve a non-existing dataspace'
+ def dataspace = objectUnderTest.getDataspace('non_existing_dataspace')
+ then: 'an DataspaceNotFoundException is thrown'
+ thrown(DataspaceNotFoundException)
+ }
+
+ @Sql([CLEAR_DATA, SET_DATA])
def 'Create and retrieve a new anchor.'() {
when: 'a new anchor is created'
def newAnchorName = 'my-new-anchor'
diff --git a/cps-service/src/main/java/org/onap/cps/api/CpsAdminService.java b/cps-service/src/main/java/org/onap/cps/api/CpsAdminService.java
index ab3373248a..b0e68cf8fb 100755
--- a/cps-service/src/main/java/org/onap/cps/api/CpsAdminService.java
+++ b/cps-service/src/main/java/org/onap/cps/api/CpsAdminService.java
@@ -3,6 +3,7 @@
* Copyright (C) 2020-2022 Nordix Foundation
* Modifications Copyright (C) 2020-2022 Bell Canada.
* Modifications Copyright (C) 2021 Pantheon.tech
+ * Modifications Copyright (C) 2022 TechMahindra Ltd.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,6 +27,7 @@ import java.util.Collection;
import org.onap.cps.spi.exceptions.AlreadyDefinedException;
import org.onap.cps.spi.exceptions.CpsException;
import org.onap.cps.spi.model.Anchor;
+import org.onap.cps.spi.model.Dataspace;
/**
* CPS Admin Service.
@@ -48,6 +50,22 @@ public interface CpsAdminService {
void deleteDataspace(String dataspaceName);
/**
+ * Get dataspace by given dataspace name.
+ *
+ * @param dataspaceName dataspace name
+ * @return a dataspace
+ */
+ Dataspace getDataspace(String dataspaceName);
+
+ /**
+ * Get All Dataspaces.
+ *
+ *
+ * @return a collection of dataspaces
+ */
+ Collection<Dataspace> getAllDataspaces();
+
+ /**
* Create an Anchor.
*
* @param dataspaceName dataspace name
diff --git a/cps-service/src/main/java/org/onap/cps/api/impl/CpsAdminServiceImpl.java b/cps-service/src/main/java/org/onap/cps/api/impl/CpsAdminServiceImpl.java
index 56f424164f..ece3eb95c9 100755
--- a/cps-service/src/main/java/org/onap/cps/api/impl/CpsAdminServiceImpl.java
+++ b/cps-service/src/main/java/org/onap/cps/api/impl/CpsAdminServiceImpl.java
@@ -3,6 +3,7 @@
* Copyright (C) 2020-2022 Nordix Foundation
* Modifications Copyright (C) 2020-2022 Bell Canada.
* Modifications Copyright (C) 2021 Pantheon.tech
+ * Modifications Copyright (C) 2022 TechMahindra Ltd.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -30,6 +31,7 @@ import org.onap.cps.api.CpsAdminService;
import org.onap.cps.api.CpsDataService;
import org.onap.cps.spi.CpsAdminPersistenceService;
import org.onap.cps.spi.model.Anchor;
+import org.onap.cps.spi.model.Dataspace;
import org.onap.cps.spi.utils.CpsValidator;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;
@@ -56,6 +58,17 @@ public class CpsAdminServiceImpl implements CpsAdminService {
}
@Override
+ public Dataspace getDataspace(final String dataspaceName) {
+ cpsValidator.validateNameCharacters(dataspaceName);
+ return cpsAdminPersistenceService.getDataspace(dataspaceName);
+ }
+
+ @Override
+ public Collection<Dataspace> getAllDataspaces() {
+ return cpsAdminPersistenceService.getAllDataspaces();
+ }
+
+ @Override
public void createAnchor(final String dataspaceName, final String schemaSetName, final String anchorName) {
cpsValidator.validateNameCharacters(dataspaceName, schemaSetName, anchorName);
cpsAdminPersistenceService.createAnchor(dataspaceName, schemaSetName, anchorName);
diff --git a/cps-service/src/main/java/org/onap/cps/spi/CpsAdminPersistenceService.java b/cps-service/src/main/java/org/onap/cps/spi/CpsAdminPersistenceService.java
index db2d2b2d49..6bcb69844d 100755
--- a/cps-service/src/main/java/org/onap/cps/spi/CpsAdminPersistenceService.java
+++ b/cps-service/src/main/java/org/onap/cps/spi/CpsAdminPersistenceService.java
@@ -3,6 +3,7 @@
* Copyright (C) 2020-2022 Nordix Foundation.
* Modifications Copyright (C) 2020-2022 Bell Canada.
* Modifications Copyright (C) 2021 Pantheon.tech
+ * Modifications Copyright (C) 2022 TechMahindra Ltd.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -25,6 +26,7 @@ package org.onap.cps.spi;
import java.util.Collection;
import org.onap.cps.spi.exceptions.AlreadyDefinedException;
import org.onap.cps.spi.model.Anchor;
+import org.onap.cps.spi.model.Dataspace;
/*
Service for handling CPS admin data.
@@ -47,6 +49,21 @@ public interface CpsAdminPersistenceService {
void deleteDataspace(String dataspaceName);
/**
+ * Get dataspace.
+ *
+ * @param dataspaceName dataspace name
+ * @return a dataspace
+ */
+ Dataspace getDataspace(String dataspaceName);
+
+ /**
+ * Get all dataspaces.
+ *
+ * @return a collection of dataspaces.
+ */
+ Collection<Dataspace> getAllDataspaces();
+
+ /**
* Create an Anchor.
*
* @param dataspaceName dataspace name
diff --git a/cps-service/src/main/java/org/onap/cps/spi/model/Dataspace.java b/cps-service/src/main/java/org/onap/cps/spi/model/Dataspace.java
new file mode 100644
index 0000000000..23c6d69063
--- /dev/null
+++ b/cps-service/src/main/java/org/onap/cps/spi/model/Dataspace.java
@@ -0,0 +1,42 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2022 TechMahindra Ltd.
+ * ================================================================================
+ * 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.spi.model;
+
+import java.io.Serializable;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+
+@Setter
+@Getter
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+@EqualsAndHashCode
+public class Dataspace implements Serializable {
+
+ private static final long serialVersionUID = 1464791062718603291L;
+
+ private String name;
+}
diff --git a/cps-service/src/test/groovy/org/onap/cps/api/impl/CpsAdminServiceImplSpec.groovy b/cps-service/src/test/groovy/org/onap/cps/api/impl/CpsAdminServiceImplSpec.groovy
index 2979c09866..e7d4e4ddb1 100755
--- a/cps-service/src/test/groovy/org/onap/cps/api/impl/CpsAdminServiceImplSpec.groovy
+++ b/cps-service/src/test/groovy/org/onap/cps/api/impl/CpsAdminServiceImplSpec.groovy
@@ -3,6 +3,7 @@
* Copyright (C) 2020-2022 Nordix Foundation
* Modifications Copyright (C) 2020-2022 Bell Canada.
* Modifications Copyright (C) 2021 Pantheon.tech
+ * Modifications Copyright (C) 2022 TechMahindra Ltd.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -25,6 +26,7 @@ package org.onap.cps.api.impl
import org.onap.cps.api.CpsDataService
import org.onap.cps.spi.CpsAdminPersistenceService
import org.onap.cps.spi.model.Anchor
+import org.onap.cps.spi.model.Dataspace
import org.onap.cps.spi.utils.CpsValidator
import spock.lang.Specification
import java.time.OffsetDateTime
@@ -89,6 +91,22 @@ class CpsAdminServiceImplSpec extends Specification {
1 * mockCpsValidator.validateNameCharacters('someDataspace', 'someAnchor')
}
+ def 'Retrieve dataspace.'() {
+ given: 'a dataspace is already created'
+ def dataspace = new Dataspace(name: "someDataspace")
+ mockCpsAdminPersistenceService.getDataspace('someDataspace') >> dataspace
+ expect: 'the dataspace provided by persistence service is returned as result'
+ assert objectUnderTest.getDataspace('someDataspace') == dataspace
+ }
+
+ def 'Retrieve all dataspaces.'() {
+ given: 'that all given dataspaces are already created'
+ def dataspaces = [new Dataspace(name: "test-dataspace1"), new Dataspace(name: "test-dataspace2")]
+ mockCpsAdminPersistenceService.getAllDataspaces() >> dataspaces
+ expect: 'the dataspace provided by persistence service is returned as result'
+ assert objectUnderTest.getAllDataspaces() == dataspaces
+ }
+
def 'Delete anchor.'() {
when: 'delete anchor is invoked'
objectUnderTest.deleteAnchor('someDataspace','someAnchor')
diff --git a/csit/prepare-csit.sh b/csit/prepare-csit.sh
index 739266be27..b56c3855dd 100755
--- a/csit/prepare-csit.sh
+++ b/csit/prepare-csit.sh
@@ -26,25 +26,25 @@ fi
TESTPLANDIR=${WORKSPACE}/${TESTPLAN}
-# Assume that if ROBOT_VENV is set and virtualenv with system site packages can be activated,
+# Assume that if ROBOT3_VENV is set and virtualenv with system site packages can be activated,
# ci-management/jjb/integration/include-raw-integration-install-robotframework.sh has already
# been executed
if [ -f ${WORKSPACE}/env.properties ]; then
source ${WORKSPACE}/env.properties
fi
-#if [ -f ${ROBOT_VENV}/bin/activate ]; then
-# source ${ROBOT_VENV}/bin/activate
+if [ -f ${ROBOT3_VENV}/bin/activate ]; then
+ source ${ROBOT3_VENV}/bin/activate
#else
- rm -rf /tmp/ci-management
- rm -f ${WORKSPACE}/env.properties
- cd /tmp
- source ${WORKSPACE}/install-robotframework.sh
-#fi
+# rm -rf /tmp/ci-management
+# rm -f ${WORKSPACE}/env.properties
+# cd /tmp
+# source ${WORKSPACE}/install-robotframework.sh
+fi
# install eteutils
-mkdir -p ${ROBOT_VENV}/src/onap
-rm -rf ${ROBOT_VENV}/src/onap/testsuite
+mkdir -p ${ROBOT3_VENV}/src/onap
+rm -rf ${ROBOT3_VENV}/src/onap/testsuite
python3 -m pip install --upgrade --extra-index-url="https://nexus3.onap.org/repository/PyPi.staging/simple" 'robotframework-onap==0.5.1.*' --pre
pip freeze
diff --git a/csit/run-csit.sh b/csit/run-csit.sh
index 52ec218630..aefcc8539f 100755
--- a/csit/run-csit.sh
+++ b/csit/run-csit.sh
@@ -20,6 +20,11 @@
# Branched from ccsdk/distribution to this repository Feb 23, 2021
+# Activate the virtualenv containing all the required libraries installed by prepare-csit.sh
+source_safely "${ROBOT3_VENV}/bin/activate"
+
+WORKDIR=$(mktemp -d --suffix=-robot-workdir)
+
#
# functions
#
@@ -154,14 +159,11 @@ TESTPLANDIR="${WORKSPACE}/${TESTPLAN}"
# Run installation of prerequired libraries
source_safely "${WORKSPACE}/prepare-csit.sh"
-# Activate the virtualenv containing all the required libraries installed by prepare-csit.sh
-source_safely "${ROBOT_VENV}/bin/activate"
-
-WORKDIR=$(mktemp -d --suffix=-robot-workdir)
+# Use robot framework working directory
cd "${WORKDIR}"
# Add csit scripts to PATH
-export PATH="${PATH}:${WORKSPACE}/docker/scripts:${WORKSPACE}/scripts:${ROBOT_VENV}/bin"
+export PATH="${PATH}:${WORKSPACE}/docker/scripts:${WORKSPACE}/scripts:${ROBOT3_VENV}/bin"
export SCRIPTS="${WORKSPACE}/scripts"
export ROBOT_VARIABLES=
diff --git a/docs/api/swagger/cps/openapi.yaml b/docs/api/swagger/cps/openapi.yaml
index e8f13d4df9..8ea0d7b03e 100644
--- a/docs/api/swagger/cps/openapi.yaml
+++ b/docs/api/swagger/cps/openapi.yaml
@@ -163,6 +163,124 @@ paths:
status: 500
message: Internal Server Error
details: Internal Server Error occurred
+ /v1/admin/dataspaces:
+ get:
+ tags:
+ - cps-admin
+ summary: Get dataspaces
+ description: "Read all dataspaces"
+ operationId: getAllDataspaces
+ responses:
+ "200":
+ description: OK
+ content:
+ application/json:
+ schema:
+ type: array
+ items:
+ $ref: '#/components/schemas/DataspaceDetails'
+ "400":
+ description: Bad Request
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/ErrorMessage'
+ example:
+ status: 400
+ message: Bad Request
+ details: The provided request is not valid
+ "401":
+ description: Unauthorized
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/ErrorMessage'
+ example:
+ status: 401
+ message: Unauthorized request
+ details: This request is unauthorized
+ "403":
+ description: Forbidden
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/ErrorMessage'
+ example:
+ status: 403
+ message: Request Forbidden
+ details: This request is forbidden
+ "500":
+ description: Internal Server Error
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/ErrorMessage'
+ example:
+ status: 500
+ message: Internal Server Error
+ details: Internal Server Error occurred
+ /v1/admin/dataspaces/{dataspace-name}:
+ get:
+ tags:
+ - cps-admin
+ summary: Get a dataspace
+ description: Read an dataspace given a dataspace name
+ operationId: getDataspace
+ parameters:
+ - name: dataspace-name
+ in: path
+ description: dataspace-name
+ required: true
+ schema:
+ type: string
+ example: my-dataspace
+ responses:
+ "200":
+ description: OK
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/DataspaceDetails'
+ "400":
+ description: Bad Request
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/ErrorMessage'
+ example:
+ status: 400
+ message: Bad Request
+ details: The provided request is not valid
+ "401":
+ description: Unauthorized
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/ErrorMessage'
+ example:
+ status: 401
+ message: Unauthorized request
+ details: This request is unauthorized
+ "403":
+ description: Forbidden
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/ErrorMessage'
+ example:
+ status: 403
+ message: Request Forbidden
+ details: This request is forbidden
+ "500":
+ description: Internal Server Error
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/ErrorMessage'
+ example:
+ status: 500
+ message: Internal Server Error
+ details: Internal Server Error occurred
/v1/dataspaces/{dataspace-name}/anchors:
get:
tags:
@@ -1565,6 +1683,13 @@ components:
schemaSetName:
type: string
example: my-schema-set
+ DataspaceDetails:
+ title: Dataspace details by dataspace Name
+ type: object
+ properties:
+ name:
+ type: string
+ example: my-dataspace
MultipartFile:
required:
- file
@@ -1615,4 +1740,4 @@ components:
name: kids
security:
- - basicAuth: [] \ No newline at end of file
+ - basicAuth: []
diff --git a/docs/api/swagger/ncmp/openapi.yaml b/docs/api/swagger/ncmp/openapi.yaml
index b9eee5603d..44c4788cfd 100644
--- a/docs/api/swagger/ncmp/openapi.yaml
+++ b/docs/api/swagger/ncmp/openapi.yaml
@@ -6,7 +6,7 @@ info:
servers:
- url: /ncmp
paths:
- /v1/ch/{cm-handle}/data/ds/{ncmp-datastore-name}:
+ /v1/ch/{cm-handle}/data/ds/{datastore-name}:
get:
tags:
- network-cm-proxy
@@ -14,7 +14,7 @@ paths:
description: Get resource data for given cm handle
operationId: getResourceDataForCmHandle
parameters:
- - name: ncmp-datastore-name
+ - name: datastore-name
in: path
description: The type of the requested data
required: true
@@ -154,7 +154,7 @@ paths:
handle
operationId: updateResourceDataRunningForCmHandle
parameters:
- - name: ncmp-datastore-name
+ - name: datastore-name
in: path
description: The type of the requested data
required: true
@@ -277,7 +277,7 @@ paths:
description: create resource data from pass-through running for given cm handle
operationId: createResourceDataRunningForCmHandle
parameters:
- - name: ncmp-datastore-name
+ - name: datastore-name
in: path
description: The type of the requested data
required: true
@@ -397,7 +397,7 @@ paths:
description: Delete resource data from pass-through running for a given cm handle
operationId: deleteResourceDataRunningForCmHandle
parameters:
- - name: ncmp-datastore-name
+ - name: datastore-name
in: path
description: The type of the requested data
required: true
@@ -513,7 +513,7 @@ paths:
handle
operationId: patchResourceDataRunningForCmHandle
parameters:
- - name: ncmp-datastore-name
+ - name: datastore-name
in: path
description: The type of the requested data
required: true
diff --git a/docs/release-notes.rst b/docs/release-notes.rst
index 195f062237..b757f19d85 100755
--- a/docs/release-notes.rst
+++ b/docs/release-notes.rst
@@ -37,6 +37,7 @@ Release Data
+--------------------------------------+--------------------------------------------------------+
Features
--------
+ - `CPS-1002 <https://jira.onap.org/browse/CPS-1002>`_ Query data NCMP-Operational with CPSpath
- `CPS-1185 <https://jira.onap.org/browse/CPS-1185>`_ Get all dataspaces
- `CPS-1186 <https://jira.onap.org/browse/CPS-1186>`_ Get all schema sets for a dataspace
- `CPS-1187 <https://jira.onap.org/browse/CPS-1187>`_ Get single dataspace