4306df78da3eb05e2ffcc33c8020ee7569d71656
[cps.git] / cps-service / src / main / java / org / onap / cps / spi / CpsModulePersistenceService.java
1 /*
2  * ============LICENSE_START=======================================================
3  *  Copyright (C) 2020-2022 Nordix Foundation
4  *  Modifications Copyright (C) 2020-2022 Bell Canada.
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.spi;
23
24 import java.util.Collection;
25 import java.util.Map;
26 import org.onap.cps.spi.model.ModuleReference;
27
28 /**
29  * Service to manage modules.
30  */
31 public interface CpsModulePersistenceService {
32
33     /**
34      * Stores Schema Set.
35      *
36      * @param dataspaceName                 dataspace name
37      * @param schemaSetName                 schema set name
38      * @param yangResourcesNameToContentMap YANG resources (files) map where key is a name and value is content
39      */
40     void storeSchemaSet(String dataspaceName, String schemaSetName, Map<String, String> yangResourcesNameToContentMap);
41
42     /**
43      * Stores a schema set from new modules and existing modules.
44      *
45      * @param dataspaceName                          Dataspace name
46      * @param schemaSetName                          Schema set name
47      * @param newModuleNameToContentMap YANG resources map where key is a module name and value is content
48      * @param moduleReferences                       List of YANG resources module references
49      */
50     void storeSchemaSetFromModules(String dataspaceName, String schemaSetName,
51         Map<String, String> newModuleNameToContentMap, Collection<ModuleReference> moduleReferences);
52
53     /**
54      * Deletes Schema Set.
55      *
56      * @param dataspaceName dataspace name
57      * @param schemaSetName schema set name
58      */
59     void deleteSchemaSet(String dataspaceName, String schemaSetName);
60
61     /**
62      * Returns YANG resources per specific dataspace / schemaSetName.
63      *
64      * @param dataspaceName dataspace name
65      * @param schemaSetName schema set name
66      * @return YANG resources (files) map where key is a name and value is content
67      */
68     Map<String, String> getYangSchemaResources(String dataspaceName, String schemaSetName);
69
70     /**
71      * Returns YANG resources per specific dataspace / anchorName.
72      *
73      * @param dataspaceName dataspace name
74      * @param anchorName    anchor name
75      * @return YANG resources (files) map where key is a name and value is content
76      */
77     Map<String, String> getYangSchemaSetResources(String dataspaceName, String anchorName);
78
79     /**
80      * Returns YANG resources module references for the given dataspace name.
81      *
82      * @param dataspaceName dataspace name
83      * @return Collection of all YANG resources module information in the database
84      */
85     Collection<ModuleReference> getYangResourceModuleReferences(String dataspaceName);
86
87     /**
88      * Get YANG resource module references for the given anchor name and dataspace name.
89      *
90      * @param dataspaceName dataspace name
91      * @param anchorName    anchor name
92      * @return a collection of module names and revisions
93      */
94     Collection<ModuleReference> getYangResourceModuleReferences(String dataspaceName, String anchorName);
95
96     /**
97      * Remove unused Yang Resource Modules.
98      */
99     void deleteUnusedYangResourceModules();
100
101     /**
102      * Identify new module references from those returned by a node compared to what is in CPS already.
103      *
104      * @param moduleReferencesToCheck the module references ot check
105      * @returns Collection of {@link ModuleReference} of previously unknown module references
106      */
107     Collection<ModuleReference> identifyNewModuleReferences(
108         Collection<ModuleReference> moduleReferencesToCheck);
109
110 }