#1: Dedicated web client instance is assigned for data, model and health services
[cps.git] / cps-service / src / main / java / org / onap / cps / api / CpsModuleService.java
1 /*
2  *  ============LICENSE_START=======================================================
3  *  Copyright (C) 2020-2024 Nordix Foundation
4  *  Modifications Copyright (C) 2020-2021 Pantheon.tech
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
10  *
11  *        http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  *
19  *  SPDX-License-Identifier: Apache-2.0
20  *  ============LICENSE_END=========================================================
21  */
22
23 package org.onap.cps.api;
24
25 import java.util.Collection;
26 import java.util.Map;
27 import org.onap.cps.spi.CascadeDeleteAllowed;
28 import org.onap.cps.spi.exceptions.DataInUseException;
29 import org.onap.cps.spi.model.ModuleDefinition;
30 import org.onap.cps.spi.model.ModuleReference;
31 import org.onap.cps.spi.model.SchemaSet;
32
33 /**
34  * Responsible for managing module sets.
35  */
36 public interface CpsModuleService {
37
38     /**
39      * Create schema set.
40      *
41      * @param dataspaceName                 dataspace name
42      * @param schemaSetName                 schema set name
43      * @param yangResourcesNameToContentMap yang resources (files) as a mep where key is resource name
44      *                                      and value is content
45      */
46     void createSchemaSet(String dataspaceName, String schemaSetName,
47                          Map<String, String> yangResourcesNameToContentMap);
48
49     /**
50      * Create or upgrade a schema set from new modules and existing modules or only existing modules.
51      * @param dataspaceName             Dataspace name
52      * @param schemaSetName             schema set name
53      * @param newModuleNameToContentMap YANG resources map where key is a module name and value is content
54      * @param allModuleReferences       All YANG resource module references
55      */
56     void createSchemaSetFromModules(String dataspaceName, String schemaSetName,
57                                     Map<String, String> newModuleNameToContentMap,
58                                     Collection<ModuleReference> allModuleReferences);
59
60     /**
61      * Read schema set in the given dataspace.
62      *
63      * @param dataspaceName dataspace name
64      * @param schemaSetName schema set name
65      * @return a SchemaSet
66      */
67     SchemaSet getSchemaSet(String dataspaceName, String schemaSetName);
68
69     /**
70      * Retrieve all schema sets in the given dataspace.
71      *
72      * @param dataspaceName dataspace name
73      * @return all SchemaSets
74      */
75     Collection<SchemaSet> getSchemaSets(String dataspaceName);
76
77     /**
78      * Deletes Schema Set.
79      *
80      * @param dataspaceName        dataspace name
81      * @param schemaSetName        schema set name
82      * @param cascadeDeleteAllowed indicates the allowance to remove associated anchors and data if exist
83      * @throws DataInUseException  if cascadeDeleteAllowed is set to CASCADE_DELETE_PROHIBITED and there
84      *                             is associated anchor record exists in database
85      */
86     void deleteSchemaSet(String dataspaceName, String schemaSetName,
87                          CascadeDeleteAllowed cascadeDeleteAllowed);
88
89     /**
90      * Deletes Schema Sets with cascade.
91      *
92      * @param dataspaceName        dataspace name
93      * @param schemaSetNames       schema set names
94      */
95     void deleteSchemaSetsWithCascade(String dataspaceName, Collection<String> schemaSetNames);
96
97
98     /**
99      * upgrade schema sets with existing or new modules.
100      *
101      * @param dataspaceName             dataspace name
102      * @param schemaSetName             schema set name
103      * @param newModuleNameToContentMap YANG resources map where key is a module name and value is content
104      * @param allModuleReferences       All YANG resource module references
105      */
106     void upgradeSchemaSetFromModules(final String dataspaceName, final String schemaSetName,
107                                      final Map<String, String> newModuleNameToContentMap,
108                                      final Collection<ModuleReference> allModuleReferences);
109
110     /**
111      * Retrieve module references for the given dataspace name.
112      *
113      * @param dataspaceName        dataspace name
114      * @return a list of ModuleReference objects
115      */
116     Collection<ModuleReference> getYangResourceModuleReferences(String dataspaceName);
117
118     /**
119      * Retrieve module references for the given dataspace name and anchor name.
120      *
121      * @param dataspaceName dataspace name
122      * @param anchorName    anchor name
123      * @return a list of ModuleReference objects
124      */
125     Collection<ModuleReference> getYangResourcesModuleReferences(String dataspaceName, String anchorName);
126
127     /**
128      * Retrieve module definitions for the given dataspace name and anchor name.
129      *
130      * @param dataspaceName dataspace name
131      * @param anchorName    anchor name
132      * @return a collection of module definitions (moduleName, revision, yang resource content)
133      */
134     Collection<ModuleDefinition> getModuleDefinitionsByAnchorName(String dataspaceName, String anchorName);
135
136     /**
137      * Retrieve module definitions for the given parameters.
138      *
139      * @param dataspaceName     dataspace name
140      * @param anchorName        anchor name
141      * @param moduleName        module name
142      * @param moduleRevision    the revision of the module
143      * @return a collection of module definitions (moduleName, revision, yang resource content)
144      */
145     Collection<ModuleDefinition> getModuleDefinitionsByAnchorAndModule(String dataspaceName, String anchorName,
146                                                                   String moduleName, String moduleRevision);
147
148     /**
149      * Identify previously unknown Yang Resource module references.
150      * The system will ignore the namespace of all module references.
151      *
152      * @param moduleReferencesToCheck the moduleReferencesToCheck
153      * @returns collection of module references (namespace will be always blank)
154      */
155     Collection<ModuleReference> identifyNewModuleReferences(
156         Collection<ModuleReference> moduleReferencesToCheck);
157
158 }