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