CPS-1401 Implement V2 of GET Data Node API
[cps.git] / cps-ncmp-service / src / main / java / org / onap / cps / ncmp / api / inventory / InventoryPersistence.java
1 /*
2  *  ============LICENSE_START=======================================================
3  *  Copyright (C) 2022-2023 Nordix Foundation
4  *  Modifications Copyright (C) 2023 TechMahindra Ltd.
5  *  ================================================================================
6  *  Licensed under the Apache License, Version 2.0 (the "License");
7  *  you may not use this file except in compliance with the License.
8  *  You may obtain a copy of the License at
9  *
10  *        http://www.apache.org/licenses/LICENSE-2.0
11  *
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.inventory;
23
24 import java.util.Collection;
25 import java.util.Map;
26 import org.onap.cps.ncmp.api.impl.yangmodels.YangModelCmHandle;
27 import org.onap.cps.spi.FetchDescendantsOption;
28 import org.onap.cps.spi.model.DataNode;
29 import org.onap.cps.spi.model.ModuleDefinition;
30 import org.onap.cps.spi.model.ModuleReference;
31
32 public interface InventoryPersistence {
33
34     /**
35      * Get the Cm Handle Composite State from the data node.
36      *
37      * @param cmHandleId cm handle id
38      * @return the cm handle composite state
39      */
40     CompositeState getCmHandleState(String cmHandleId);
41
42     /**
43      * Save the cm handles state.
44      *
45      * @param cmHandleId     cm handle id
46      * @param compositeState composite state
47      */
48     void saveCmHandleState(String cmHandleId, CompositeState compositeState);
49
50     /**
51      * Save all cm handles states in batch.
52      *
53      * @param cmHandleStatePerCmHandleId contains cm handle id and updated state
54      */
55     void saveCmHandleStateBatch(Map<String, CompositeState> cmHandleStatePerCmHandleId);
56
57     /**
58      * This method retrieves DMI service name, DMI properties and the state for a given cm handle.
59      *
60      * @param cmHandleId the id of the cm handle
61      * @return yang model cm handle
62      */
63     YangModelCmHandle getYangModelCmHandle(String cmHandleId);
64
65     /**
66      * This method retrieves DMI service name, DMI properties and the state for a given cm handle.
67      *
68      * @param cmHandleIds a list of the ids of the cm handles
69      * @return collection of yang model cm handles
70      */
71     Collection<YangModelCmHandle> getYangModelCmHandles(Collection<String> cmHandleIds);
72
73     /**
74      * Method to return module definitions by cmHandleId.
75      *
76      * @param cmHandleId cm handle ID
77      * @return a collection of module definitions (moduleName, revision and yang resource content)
78      */
79     Collection<ModuleDefinition> getModuleDefinitionsByCmHandleId(String cmHandleId);
80
81     /**
82      * Method to return module references by cmHandleId.
83      *
84      * @param cmHandleId cm handle ID
85      * @return a collection of module references (moduleName and revision)
86      */
87     Collection<ModuleReference> getYangResourcesModuleReferences(String cmHandleId);
88
89     /**
90      * Method to save cmHandle.
91      *
92      * @param yangModelCmHandle cmHandle represented as Yang Model
93      */
94     void saveCmHandle(YangModelCmHandle yangModelCmHandle);
95
96     /**
97      * Method to save batch of cm handles.
98      *
99      * @param yangModelCmHandles cm handle represented as Yang Models
100      */
101     void saveCmHandleBatch(Collection<YangModelCmHandle> yangModelCmHandles);
102
103     /**
104      * Method to delete a list or a list element.
105      *
106      * @param listElementXpath list element xPath
107      */
108     void deleteListOrListElement(String listElementXpath);
109
110     /**
111      * Method to delete a schema set.
112      *
113      * @param schemaSetName schema set name
114      */
115     void deleteSchemaSetWithCascade(String schemaSetName);
116
117     /**
118      * Get data node via xpath.
119      *
120      * @param xpath xpath
121      * @return data node
122      */
123     Collection<DataNode> getDataNode(String xpath);
124
125     /**
126      * Get data node via xpath.
127      *
128      * @param xpath xpath
129      * @param fetchDescendantsOption fetch descendants option
130      * @return data node
131      */
132     Collection<DataNode> getDataNode(String xpath, FetchDescendantsOption fetchDescendantsOption);
133
134     /**
135      * Get collection of data nodes via xpaths.
136      *
137      * @param xpaths collection of xpaths
138      * @return collection of data nodes
139      */
140     Collection<DataNode> getDataNodes(Collection<String> xpaths);
141
142     /**
143      * Get collection of data nodes via xpaths.
144      *
145      * @param xpaths collection of xpaths
146      * @param fetchDescendantsOption fetch descendants option
147      * @return collection of data nodes
148      */
149     Collection<DataNode> getDataNodes(Collection<String> xpaths, FetchDescendantsOption fetchDescendantsOption);
150
151     /**
152      * Get data node of given cm handle.
153      *
154      * @param cmHandleId cmHandle ID
155      * @return data node
156      */
157     Collection<DataNode> getCmHandleDataNode(String cmHandleId);
158
159     /**
160      * Get collection of data nodes of given cm handles.
161      *
162      * @param cmHandleIds collection of cmHandle IDs
163      * @return collection of data nodes
164      */
165     Collection<DataNode> getCmHandleDataNodes(Collection<String> cmHandleIds);
166
167     /**
168      * get CM handles that has given module names.
169      *
170      * @param moduleNamesForQuery module names
171      * @return Collection of CM handle Ids
172      */
173     Collection<String> getCmHandleIdsWithGivenModules(Collection<String> moduleNamesForQuery);
174
175     /**
176      * Replaces list content by removing all existing elements and inserting the given new elements as data nodes.
177      *
178      * @param parentNodeXpath parent node xpath
179      * @param dataNodes       datanodes representing the updated data
180      */
181     void replaceListContent(String parentNodeXpath, Collection<DataNode> dataNodes);
182
183     /**
184      * Deletes data node.
185      *
186      * @param dataNodeXpath data node xpath
187      */
188     void deleteDataNode(String dataNodeXpath);
189
190     /**
191      * Deletes multiple data nodes.
192      *
193      * @param dataNodeXpaths data node xpaths
194      */
195     void deleteDataNodes(Collection<String> dataNodeXpaths);
196 }