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