b29825e7c09ccae4ac8138b18d04b4e9e597414e
[cps.git] / cps-ncmp-service / src / main / java / org / onap / cps / ncmp / api / inventory / InventoryPersistence.java
1 /*
2  *  ============LICENSE_START=======================================================
3  *  Copyright (C) 2022 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.Anchor;
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      * Method to return module definitions by cmHandleId.
67      *
68      * @param cmHandleId cm handle ID
69      * @return a collection of module definitions (moduleName, revision and yang resource content)
70      */
71     Collection<ModuleDefinition> getModuleDefinitionsByCmHandleId(String cmHandleId);
72
73     /**
74      * Method to return module references by cmHandleId.
75      *
76      * @param cmHandleId cm handle ID
77      * @return a collection of module references (moduleName and revision)
78      */
79     Collection<ModuleReference> getYangResourcesModuleReferences(String cmHandleId);
80
81     /**
82      * Method to save cmHandle.
83      *
84      * @param yangModelCmHandle cmHandle represented as Yang Model
85      */
86     void saveCmHandle(YangModelCmHandle yangModelCmHandle);
87
88     /**
89      * Method to save batch of cm handles.
90      *
91      * @param yangModelCmHandles cm handle represented as Yang Models
92      */
93     void saveCmHandleBatch(Collection<YangModelCmHandle> yangModelCmHandles);
94
95     /**
96      * Method to delete a list or a list element.
97      *
98      * @param listElementXpath list element xPath
99      */
100     void deleteListOrListElement(String listElementXpath);
101
102     /**
103      * Method to delete a schema set.
104      *
105      * @param schemaSetName schema set name
106      */
107     void deleteSchemaSetWithCascade(String schemaSetName);
108
109     /**
110      * Get data node via xpath.
111      *
112      * @param xpath xpath
113      * @return data node
114      */
115     DataNode getDataNode(String xpath);
116
117     /**
118      * Get data node via xpath.
119      *
120      * @param xpath xpath
121      * @param fetchDescendantsOption fetch descendants option
122      * @return data node
123      */
124     DataNode getDataNode(String xpath, FetchDescendantsOption fetchDescendantsOption);
125
126     /**
127      * Get data node of given cm handle.
128      *
129      * @param cmHandleId cmHandle ID
130      * @return data node
131      */
132     DataNode getCmHandleDataNode(String cmHandleId);
133
134     /**
135      * Query anchors via module names.
136      *
137      * @param moduleNamesForQuery module names
138      * @return Collection of anchors
139      */
140     Collection<Anchor> queryAnchors(Collection<String> moduleNamesForQuery);
141
142     /**
143      * Method to get all anchors.
144      *
145      * @return Collection of anchors
146      */
147     Collection<Anchor> getAnchors();
148
149     /**
150      * Replaces list content by removing all existing elements and inserting the given new elements as data nodes.
151      *
152      * @param parentNodeXpath parent node xpath
153      * @param dataNodes       datanodes representing the updated data
154      */
155     void replaceListContent(String parentNodeXpath, Collection<DataNode> dataNodes);
156
157     /**
158      * Deletes data node for given anchor and dataspace.
159      *
160      * @param dataNodeXpath data node xpath
161      */
162     void deleteDataNode(String dataNodeXpath);
163 }