9b50f9e917c383d20a18987c59fdd315a4819b8d
[cps.git] / cps-service / src / main / java / org / onap / cps / spi / CpsModulePersistenceService.java
1 /*
2  * ============LICENSE_START=======================================================
3  *  Copyright (C) 2020 Nordix Foundation
4  *  Modifications Copyright (C) 2020 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.List;
26 import java.util.Map;
27 import org.checkerframework.checker.nullness.qual.NonNull;
28 import org.onap.cps.spi.exceptions.DataInUseException;
29 import org.onap.cps.spi.model.ModuleReference;
30
31 /**
32  * Service to manage modules.
33  */
34 public interface CpsModulePersistenceService {
35
36     /**
37      * Stores Schema Set.
38      *
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
42      */
43     void storeSchemaSet(@NonNull String dataspaceName, @NonNull String schemaSetName,
44         @NonNull Map<String, String> yangResourcesNameToContentMap);
45
46     /**
47      * Stores a schema set from new modules and existing modules.
48      *
49      * @param dataspaceName                          Dataspace name
50      * @param schemaSetName                          Schema set name
51      * @param newYangResourcesModuleNameToContentMap YANG resources map where key is a module name and value is content
52      * @param moduleReferences                    List of YANG resources module references
53      */
54     void storeSchemaSetFromModules(@NonNull String dataspaceName, @NonNull String schemaSetName,
55                                    @NonNull Map<String, String> newYangResourcesModuleNameToContentMap,
56                                    @NonNull List<ModuleReference> moduleReferences);
57
58     /**
59      * Deletes Schema Set.
60      *
61      * @param dataspaceName        dataspace name
62      * @param schemaSetName        schema set name
63      * @param cascadeDeleteAllowed indicates the allowance to remove associated anchors and data if exist
64      * @throws DataInUseException if cascadeDeleteAllowed is set to CASCADE_DELETE_PROHIBITED and there
65      *                           is associated anchor record exists in database
66      */
67     void deleteSchemaSet(@NonNull String dataspaceName, @NonNull String schemaSetName,
68         @NonNull CascadeDeleteAllowed cascadeDeleteAllowed);
69
70     /**
71      * Returns YANG resources per specific dataspace / schemaSetName.
72      *
73      * @param dataspaceName   dataspace name
74      * @param schemaSetName schema set name
75      * @return YANG resources (files) map where key is a name and value is content
76      */
77     @NonNull
78     Map<String, String> getYangSchemaResources(@NonNull String dataspaceName,
79         @NonNull String schemaSetName);
80
81     /**
82      * Returns YANG resources per specific dataspace / anchorName.
83      *
84      * @param dataspaceName dataspace name
85      * @param anchorName anchor name
86      * @return YANG resources (files) map where key is a name and value is content
87      */
88     @NonNull
89     Map<String, String> getYangSchemaSetResources(@NonNull String dataspaceName,
90         @NonNull String anchorName);
91
92     /**
93      * Returns YANG resources module references for the given dataspace name.
94      *
95      * @param dataspaceName dataspace name
96      * @return Collection of all YANG resources module information in the database
97      */
98     Collection<ModuleReference> getYangResourceModuleReferences(String dataspaceName);
99
100     /**
101      * Get YANG resource module references for the given anchor name and dataspace name.
102      *
103      * @param dataspaceName dataspace name
104      * @param anchorName    anchor name
105      * @return a collection of module names and revisions
106      */
107     Collection<ModuleReference> getYangResourceModuleReferences(String dataspaceName, String anchorName);
108 }