CM Data Subscriptions PoC/Performance test fixes
[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      * Method to delete multiple schema sets.
119      *
120      * @param schemaSetNames schema set names
121      */
122     void deleteSchemaSetsWithCascade(Collection<String> schemaSetNames);
123
124     /**
125      * Get data node via xpath.
126      *
127      * @param xpath xpath
128      * @return data node
129      */
130     Collection<DataNode> getDataNode(String xpath);
131
132     /**
133      * Get data node via xpath.
134      *
135      * @param xpath xpath
136      * @param fetchDescendantsOption fetch descendants option
137      * @return data node
138      */
139     Collection<DataNode> getDataNode(String xpath, FetchDescendantsOption fetchDescendantsOption);
140
141     /**
142      * Get collection of data nodes via xpaths.
143      *
144      * @param xpaths collection of xpaths
145      * @return collection of data nodes
146      */
147     Collection<DataNode> getDataNodes(Collection<String> xpaths);
148
149     /**
150      * Get collection of data nodes via xpaths.
151      *
152      * @param xpaths collection of xpaths
153      * @param fetchDescendantsOption fetch descendants option
154      * @return collection of data nodes
155      */
156     Collection<DataNode> getDataNodes(Collection<String> xpaths, FetchDescendantsOption fetchDescendantsOption);
157
158     /**
159      * Get data node of given cm handle.
160      *
161      * @param cmHandleId cmHandle ID
162      * @return data node
163      */
164     Collection<DataNode> getCmHandleDataNode(String cmHandleId);
165
166     /**
167      * Get collection of data nodes of given cm handles.
168      *
169      * @param cmHandleIds collection of cmHandle IDs
170      * @return collection of data nodes
171      */
172     Collection<DataNode> getCmHandleDataNodes(Collection<String> cmHandleIds);
173
174     /**
175      * get CM handles that has given module names.
176      *
177      * @param moduleNamesForQuery module names
178      * @return Collection of CM handle Ids
179      */
180     Collection<String> getCmHandleIdsWithGivenModules(Collection<String> moduleNamesForQuery);
181
182     /**
183      * Replaces list content by removing all existing elements and inserting the given new elements as data nodes.
184      *
185      * @param parentNodeXpath parent node xpath
186      * @param dataNodes       datanodes representing the updated data
187      */
188     void replaceListContent(String parentNodeXpath, Collection<DataNode> dataNodes);
189
190     /**
191      * Deletes data node.
192      *
193      * @param dataNodeXpath data node xpath
194      */
195     void deleteDataNode(String dataNodeXpath);
196
197     /**
198      * Deletes multiple data nodes.
199      *
200      * @param dataNodeXpaths data node xpaths
201      */
202     void deleteDataNodes(Collection<String> dataNodeXpaths);
203 }