1dccf49c9bcbd28cc5b59b8469a8dc4a688d78c1
[cps.git] / cps-service / src / main / java / org / onap / cps / api / CpsModuleService.java
1 /*
2  *  ============LICENSE_START=======================================================
3  *  Copyright (C) 2020 Nordix Foundation
4  *  Modifications Copyright (C) 2020-2021 Pantheon.tech
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.api;
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.CascadeDeleteAllowed;
29 import org.onap.cps.spi.exceptions.DataInUseException;
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(@NonNull String dataspaceName, @NonNull String schemaSetName,
47                          @NonNull Map<String, String> yangResourcesNameToContentMap);
48
49     /**
50      * Create a schema set from new modules and existing modules.
51      *
52      * @param dataspaceName                          Dataspace name
53      * @param schemaSetName                          schema set name
54      * @param newYangResourcesModuleNameToContentMap YANG resources map where key is a module name and value is content
55      * @param moduleReferences               List of YANG resources module references of the modules
56      *                                               needed for this handle that are already in CPS
57      */
58     void createSchemaSetFromModules(@NonNull String dataspaceName, @NonNull String schemaSetName,
59                                     @NonNull Map<String, String> newYangResourcesModuleNameToContentMap,
60                                     @NonNull List<ModuleReference> moduleReferences);
61
62     /**
63      * Read schema set in the given dataspace.
64      *
65      * @param dataspaceName dataspace name
66      * @param schemaSetName schema set name
67      * @return a SchemaSet
68      */
69     SchemaSet getSchemaSet(@NonNull String dataspaceName, @NonNull String schemaSetName);
70
71     /**
72      * Deletes Schema Set.
73      *
74      * @param dataspaceName        dataspace name
75      * @param schemaSetName        schema set name
76      * @param cascadeDeleteAllowed indicates the allowance to remove associated anchors and data if exist
77      * @throws DataInUseException if cascadeDeleteAllowed is set to CASCADE_DELETE_PROHIBITED and there
78      *                           is associated anchor record exists in database
79      */
80     void deleteSchemaSet(@NonNull String dataspaceName, @NonNull String schemaSetName,
81         @NonNull CascadeDeleteAllowed cascadeDeleteAllowed);
82
83     /**
84      * Retrieve module references for the given dataspace name.
85      *
86      * @param dataspaceName        dataspace name
87      * @return a list of ModuleReference objects
88      */
89     Collection<ModuleReference> getYangResourceModuleReferences(String dataspaceName);
90
91     /**
92      * Retrieve module references for the given dataspace name and anchor name.
93      *
94      * @param dataspaceName dataspace name
95      * @param anchorName    anchor name
96      * @return a list of ModuleReference objects
97      */
98     Collection<ModuleReference> getYangResourcesModuleReferences(String dataspaceName, String anchorName);
99 }