Merge "Adding examples in openapi for cps-core"
[cps.git] / cps-ncmp-service / src / main / java / org / onap / cps / ncmp / api / NetworkCmProxyDataService.java
1 /*
2  *  ============LICENSE_START=======================================================
3  *  Copyright (C) 2021 highstreet technologies GmbH
4  *  Modifications Copyright (C) 2021 Nordix Foundation
5  *  Modifications Copyright (C) 2021 Pantheon.tech
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.ncmp.api;
24
25 import static org.onap.cps.ncmp.api.impl.operations.DmiRequestBody.OperationEnum;
26
27 import java.util.Collection;
28 import org.checkerframework.checker.nullness.qual.NonNull;
29 import org.onap.cps.ncmp.api.models.DmiPluginRegistration;
30 import org.onap.cps.spi.FetchDescendantsOption;
31 import org.onap.cps.spi.model.DataNode;
32 import org.onap.cps.spi.model.ModuleReference;
33
34 /*
35  * Datastore interface for handling CPS data.
36  */
37 public interface NetworkCmProxyDataService {
38
39     /**
40      * Retrieves datanode by XPath for a given cm handle.
41      *
42      * @param cmHandle               The identifier for a network function, network element, subnetwork or any other cm
43      *                               object by managed Network CM Proxy
44      * @param xpath                  xpath
45      * @param fetchDescendantsOption defines the scope of data to fetch: either single node or all the descendant nodes
46      *                               (recursively) as well
47      * @return data node object
48      */
49     DataNode getDataNode(@NonNull String cmHandle, @NonNull String xpath,
50         @NonNull FetchDescendantsOption fetchDescendantsOption);
51
52     /**
53      * Get datanodes for the given cm handle by cps path.
54      *
55      * @param cmHandle               The identifier for a network function, network element, subnetwork or any other cm
56      *                               object by managed Network CM Proxy
57      * @param cpsPath                cps path
58      * @param fetchDescendantsOption defines whether the descendants of the node(s) found by the query should be
59      *                               included in the output
60      * @return a collection of datanodes
61      */
62     Collection<DataNode> queryDataNodes(@NonNull String cmHandle, @NonNull String cpsPath,
63         @NonNull FetchDescendantsOption fetchDescendantsOption);
64
65     /**
66      * Creates data node with descendants at root level or under existing node (if parent node xpath is provided).
67      *
68      * @param cmHandle        The identifier for a network function, network element, subnetwork or any other cm
69      *                        object managed by Network CM Proxy
70      * @param parentNodeXpath xpath to parent node or '/' for root level
71      * @param jsonData        data as JSON string
72      */
73     void createDataNode(@NonNull String cmHandle, @NonNull String parentNodeXpath, @NonNull String jsonData);
74
75     /**
76      * Creates one or more child node elements with descendants under existing node from list-node data fragment.
77      *
78      * @param cmHandle        The identifier for a network function, network element, subnetwork or any other cm
79      *                        object managed by Network CM Proxy
80      * @param parentNodeXpath xpath to parent node
81      * @param jsonData        data as JSON string
82      */
83     void addListNodeElements(@NonNull String cmHandle, @NonNull String parentNodeXpath, @NonNull String jsonData);
84
85     /**
86      * Updates data node for given cm handle using xpath to parent node.
87      *
88      * @param cmHandle        The identifier for a network function, network element, subnetwork or any other cm object
89      *                        by managed Network CM Proxy
90      * @param parentNodeXpath xpath to parent node
91      * @param jsonData        json data
92      */
93     void updateNodeLeaves(@NonNull String cmHandle, @NonNull String parentNodeXpath, @NonNull String jsonData);
94
95     /**
96      * Replaces existing data node content including descendants.
97      *
98      * @param cmHandle        The identifier for a network function, network element, subnetwork or any other cm object
99      *                        by managed Network CM Proxy
100      * @param parentNodeXpath xpath to parent node
101      * @param jsonData        json data
102      */
103     void replaceNodeTree(@NonNull String cmHandle, @NonNull String parentNodeXpath, @NonNull String jsonData);
104
105     /**
106      * Registration of New CM Handles.
107      *
108      * @param dmiPluginRegistration Dmi Plugin Registration
109      */
110     void updateDmiRegistrationAndSyncModule(DmiPluginRegistration dmiPluginRegistration);
111
112     /**
113      * Get resource data for data store pass-through operational
114      * using dmi.
115      *
116      * @param cmHandle cm handle
117      * @param resourceIdentifier resource identifier
118      * @param acceptParamInHeader accept param
119      * @param optionsParamInQuery options query
120      * @return {@code Object} resource data
121      */
122     Object getResourceDataOperationalForCmHandle(String cmHandle,
123                                                  String resourceIdentifier,
124                                                  String acceptParamInHeader,
125                                                  String optionsParamInQuery);
126
127     /**
128      * Get resource data for data store pass-through running
129      * using dmi.
130      *
131      * @param cmHandle cm handle
132      * @param resourceIdentifier resource identifier
133      * @param acceptParamInHeader accept param
134      * @param optionsParamInQuery options query
135      * @return {@code Object} resource data
136      */
137     Object getResourceDataPassThroughRunningForCmHandle(String cmHandle,
138                                                         String resourceIdentifier,
139                                                         String acceptParamInHeader,
140                                                         String optionsParamInQuery);
141
142     /**
143      * Write resource data for data store pass-through running
144      * using dmi for given cm-handle.
145      *  @param cmHandle cm handle
146      * @param resourceIdentifier resource identifier
147      * @param operation required operation
148      * @param requestBody request body to create resource
149      * @param contentType content type in body
150      */
151     void writeResourceDataPassThroughRunningForCmHandle(String cmHandle,
152                                                         String resourceIdentifier,
153                                                         OperationEnum operation,
154                                                         String requestBody,
155                                                         String contentType);
156
157     /**
158      * Retrieve module references for the given cm handle.
159      *
160      * @param cmHandle cm handle
161      * @return a collection of modules names and revisions
162      */
163     Collection<ModuleReference> getYangResourcesModuleReferences(String cmHandle);
164
165     /**
166      * Query cm handle identifiers for the given collection of module names.
167      *
168      * @param moduleNames module names.
169      * @return a collection of cm handle identifiers. The schema set for each cm handle must include all the
170      *         given module names
171      */
172     Collection<String> executeCmHandleHasAllModulesSearch(Collection<String> moduleNames);
173
174 }