Create list-node elements (part3): NCMP REST and service layers
[cps.git] / cps-ncmp-service / src / main / java / org / onap / cps / ncmp / api / NetworkCmProxyDataService.java
1 /*
2  * ============LICENSE_START=======================================================
3  *  Copyright (C) 2021 highstreet technologies GmbH
4  *  Copyright (C) 2021 Nordix Foundation
5  *  Modifications Copyright (C) 2021 Pantheon.tech
6  *  ================================================================================
7  *  Licensed under the Apache License, Version 2.0 (the "License");
8  *  you may not use this file except in compliance with the License.
9  *  You may obtain a copy of the License at
10  *
11  *        http://www.apache.org/licenses/LICENSE-2.0
12  *  Unless required by applicable law or agreed to in writing, software
13  *  distributed under the License is distributed on an "AS IS" BASIS,
14  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  *  See the License for the specific language governing permissions and
16  *  limitations under the License.
17  *
18  *  SPDX-License-Identifier: Apache-2.0
19  *  ============LICENSE_END=========================================================
20  */
21
22 package org.onap.cps.ncmp.api;
23
24 import java.util.Collection;
25 import org.checkerframework.checker.nullness.qual.NonNull;
26 import org.onap.cps.spi.FetchDescendantsOption;
27 import org.onap.cps.spi.model.DataNode;
28
29 /*
30  * Datastore interface for handling CPS data.
31  */
32 public interface NetworkCmProxyDataService {
33
34     /**
35      * Retrieves datanode by XPath for a given cm handle.
36      *
37      * @param cmHandle               The identifier for a network function, network element, subnetwork or any other cm
38      *                               object by managed Network CM Proxy
39      * @param xpath                  xpath
40      * @param fetchDescendantsOption defines the scope of data to fetch: either single node or all the descendant nodes
41      *                               (recursively) as well
42      * @return data node object
43      */
44     DataNode getDataNode(@NonNull String cmHandle, @NonNull String xpath,
45         @NonNull FetchDescendantsOption fetchDescendantsOption);
46
47     /**
48      * Get datanodes for the given cm handle by cps path.
49      *
50      * @param cmHandle               The identifier for a network function, network element, subnetwork or any other cm
51      *                               object by managed Network CM Proxy
52      * @param cpsPath                cps path
53      * @param fetchDescendantsOption defines whether the descendants of the node(s) found by the query should be
54      *                               included in the output
55      * @return a collection of datanodes
56      */
57     Collection<DataNode> queryDataNodes(@NonNull String cmHandle, @NonNull String cpsPath,
58         @NonNull FetchDescendantsOption fetchDescendantsOption);
59
60     /**
61      * Creates data node with descendants at root level or under existing node (if parent node xpath is provided).
62      *
63      * @param cmHandle        The identifier for a network function, network element, subnetwork or any other cm
64      *                        object managed by Network CM Proxy
65      * @param parentNodeXpath xpath to parent node or '/' for root level
66      * @param jsonData        data as JSON string
67      */
68     void createDataNode(@NonNull String cmHandle, @NonNull String parentNodeXpath, @NonNull String jsonData);
69
70     /**
71      * Creates one or more child node elements with descendants under existing node from list-node data fragment.
72      *
73      * @param cmHandle        The identifier for a network function, network element, subnetwork or any other cm
74      *                        object managed by Network CM Proxy
75      * @param parentNodeXpath xpath to parent node
76      * @param jsonData        data as JSON string
77      */
78     void addListNodeElements(@NonNull String cmHandle, @NonNull String parentNodeXpath, @NonNull String jsonData);
79
80     /**
81      * Updates data node for given cm handle using xpath to parent node.
82      *
83      * @param cmHandle        The identifier for a network function, network element, subnetwork or any other cm object
84      *                        by managed Network CM Proxy
85      * @param parentNodeXpath xpath to parent node
86      * @param jsonData        json data
87      */
88     void updateNodeLeaves(@NonNull String cmHandle, @NonNull String parentNodeXpath, @NonNull String jsonData);
89
90     /**
91      * Replaces existing data node content including descendants.
92      *
93      * @param cmHandle        The identifier for a network function, network element, subnetwork or any other cm object
94      *                        by managed Network CM Proxy
95      * @param parentNodeXpath xpath to parent node
96      * @param jsonData        json data
97      */
98     void replaceNodeTree(@NonNull String cmHandle, @NonNull String parentNodeXpath, @NonNull String jsonData);
99
100 }