2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2020-2023 Nordix Foundation
4 * Modifications Copyright (C) 2020-2022 Bell Canada.
5 * Modifications Copyright (C) 2022 TechMahindra Ltd.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
19 * SPDX-License-Identifier: Apache-2.0
20 * ============LICENSE_END=========================================================
23 package org.onap.cps.spi;
25 import java.util.Collection;
27 import org.onap.cps.spi.model.ModuleDefinition;
28 import org.onap.cps.spi.model.ModuleReference;
29 import org.onap.cps.spi.model.SchemaSet;
32 * Service to manage modules.
34 public interface CpsModulePersistenceService {
39 * @param dataspaceName dataspace name
40 * @param schemaSetName schema set name
41 * @param yangResourcesNameToContentMap YANG resources (files) map where key is a name and value is content
43 void storeSchemaSet(String dataspaceName, String schemaSetName, Map<String, String> yangResourcesNameToContentMap);
46 * Stores a schema set from new modules and existing modules.
48 * @param dataspaceName Dataspace name
49 * @param schemaSetName Schema set name
50 * @param newModuleNameToContentMap YANG resources map where key is a module name and value is content
51 * @param allModuleReferences All YANG resources module references
53 void storeSchemaSetFromModules(String dataspaceName, String schemaSetName,
54 Map<String, String> newModuleNameToContentMap, Collection<ModuleReference> allModuleReferences);
57 * Get all schema sets for a given dataspace.
59 * @param dataspaceName dataspace name.
60 * @return List of schema sets
62 Collection<SchemaSet> getSchemaSetsByDataspaceName(String dataspaceName);
67 * @param dataspaceName dataspace name
68 * @param schemaSetName schema set name
70 void deleteSchemaSet(String dataspaceName, String schemaSetName);
73 * Deletes Schema Sets.
75 * @param dataspaceName dataspace name
76 * @param schemaSetNames schema set names
78 void deleteSchemaSets(String dataspaceName, Collection<String> schemaSetNames);
81 * Returns YANG resources per specific dataspace / schemaSetName.
83 * @param dataspaceName dataspace name
84 * @param schemaSetName schema set name
85 * @return YANG resources (files) map where key is a name and value is content
87 Map<String, String> getYangSchemaResources(String dataspaceName, String schemaSetName);
90 * Returns YANG resources per specific dataspace / anchorName.
92 * @param dataspaceName dataspace name
93 * @param anchorName anchor name
94 * @return YANG resources (files) map where key is a name and value is content
96 Map<String, String> getYangSchemaSetResources(String dataspaceName, String anchorName);
99 * Returns YANG resources module references for the given dataspace name.
101 * @param dataspaceName dataspace name
102 * @return Collection of all YANG resources module information in the database
104 Collection<ModuleReference> getYangResourceModuleReferences(String dataspaceName);
107 * Get YANG resource module references for the given anchor name and dataspace name.
109 * @param dataspaceName dataspace name
110 * @param anchorName anchor name
111 * @return a collection of module reference (moduleName and revision)
113 Collection<ModuleReference> getYangResourceModuleReferences(String dataspaceName, String anchorName);
116 * Get YANG resource definitions for the given anchor name and dataspace name.
118 * @param dataspaceName dataspace name
119 * @param anchorName anchor name
120 * @return a collection of module definitions (moduleName, revision and yang resource content)
122 Collection<ModuleDefinition> getYangResourceDefinitions(String dataspaceName, String anchorName);
125 * Remove unused Yang Resource Modules.
127 void deleteUnusedYangResourceModules();
130 * Identify new module references from those returned by a node compared to what is in CPS already.
131 * The system will ignore the namespace of all module references.
133 * @param moduleReferencesToCheck the module references ot check
134 * @returns Collection of {@link ModuleReference} (namespace will be always blank)
137 Collection<ModuleReference> identifyNewModuleReferences(
138 Collection<ModuleReference> moduleReferencesToCheck);