Tests of CM-handle module upgrade & moduleSetTag
[cps.git] / cps-ncmp-service / src / main / java / org / onap / cps / ncmp / api / impl / inventory / InventoryPersistence.java
1 /*
2  *  ============LICENSE_START=======================================================
3  *  Copyright (C) 2022-2024 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.impl.inventory;
23
24 import java.util.Collection;
25 import java.util.List;
26 import java.util.Map;
27 import org.onap.cps.ncmp.api.impl.ncmppersistence.NcmpPersistence;
28 import org.onap.cps.ncmp.api.impl.yangmodels.YangModelCmHandle;
29 import org.onap.cps.spi.model.DataNode;
30 import org.onap.cps.spi.model.ModuleDefinition;
31 import org.onap.cps.spi.model.ModuleReference;
32
33 public interface InventoryPersistence extends NcmpPersistence {
34
35     /**
36      * Get the Cm Handle Composite State from the data node.
37      *
38      * @param cmHandleId cm handle id
39      * @return the cm handle composite state
40      */
41     CompositeState getCmHandleState(String cmHandleId);
42
43     /**
44      * Save the cm handles state.
45      *
46      * @param cmHandleId     cm handle id
47      * @param compositeState composite state
48      */
49     void saveCmHandleState(String cmHandleId, CompositeState compositeState);
50
51     /**
52      * Save all cm handles states in batch.
53      *
54      * @param cmHandleStatePerCmHandleId contains cm handle id and updated state
55      */
56     void saveCmHandleStateBatch(Map<String, CompositeState> cmHandleStatePerCmHandleId);
57
58     /**
59      * This method retrieves DMI service name, DMI properties and the state for a given cm handle.
60      *
61      * @param cmHandleId the id of the cm handle
62      * @return yang model cm handle
63      */
64     YangModelCmHandle getYangModelCmHandle(String cmHandleId);
65
66     /**
67      * This method retrieves DMI service name, DMI properties and the state for a given cm handle.
68      *
69      * @param cmHandleIds a list of the ids of the cm handles
70      * @return collection of yang model cm handles
71      */
72     Collection<YangModelCmHandle> getYangModelCmHandles(Collection<String> cmHandleIds);
73
74     /**
75      * Method to return module definitions by cmHandleId.
76      *
77      * @param cmHandleId cm handle ID
78      * @return a collection of module definitions (moduleName, revision and yang resource content)
79      */
80     Collection<ModuleDefinition> getModuleDefinitionsByCmHandleId(String cmHandleId);
81
82     /**
83      * Method to return module definitions for the given parameters.
84      *
85      * @param cmHandleId        cm-handle identifier
86      * @param moduleName        module name
87      * @param moduleRevision    the revision of the module
88      * @return list of module definitions (module name, revision, yang resource content)
89      */
90     Collection<ModuleDefinition> getModuleDefinitionsByCmHandleAndModule(String cmHandleId,
91                                                                          String moduleName,
92                                                                          String moduleRevision);
93
94     /**
95      * Method to return module references by cmHandleId.
96      *
97      * @param cmHandleId cm handle ID
98      * @return a collection of module references (moduleName and revision)
99      */
100     Collection<ModuleReference> getYangResourcesModuleReferences(String cmHandleId);
101
102     /**
103      * Method to save cmHandle.
104      *
105      * @param yangModelCmHandle cmHandle represented as Yang Model
106      */
107     void saveCmHandle(YangModelCmHandle yangModelCmHandle);
108
109     /**
110      * Method to save batch of cm handles.
111      *
112      * @param yangModelCmHandles cm handle represented as Yang Models
113      */
114     void saveCmHandleBatch(List<YangModelCmHandle> yangModelCmHandles);
115
116     /**
117      * Get data node of given cm handle.
118      *
119      * @param cmHandleId cmHandle ID
120      * @return data node
121      */
122     Collection<DataNode> getCmHandleDataNode(String cmHandleId);
123
124     /**
125      * Get collection of data nodes of given cm handles.
126      *
127      * @param cmHandleIds collection of cmHandle IDs
128      * @return collection of data nodes
129      */
130     Collection<DataNode> getCmHandleDataNodes(Collection<String> cmHandleIds);
131
132     /**
133      * get CM handles that has given module names.
134      *
135      * @param moduleNamesForQuery module names
136      * @return Collection of CM handle Ids
137      */
138     Collection<String> getCmHandleIdsWithGivenModules(Collection<String> moduleNamesForQuery);
139 }