dbad05a6ca4d3ace39164b1695f106d302434dee
[netconf.git] / restconf / restconf-nb-rfc8040 / src / main / java / org / opendaylight / restconf / nb / rfc8040 / rests / services / api / RestconfDataService.java
1 /*
2  * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.restconf.nb.rfc8040.rests.services.api;
9
10 import javax.ws.rs.Consumes;
11 import javax.ws.rs.DELETE;
12 import javax.ws.rs.Encoded;
13 import javax.ws.rs.GET;
14 import javax.ws.rs.POST;
15 import javax.ws.rs.PUT;
16 import javax.ws.rs.Path;
17 import javax.ws.rs.PathParam;
18 import javax.ws.rs.Produces;
19 import javax.ws.rs.core.Context;
20 import javax.ws.rs.core.MediaType;
21 import javax.ws.rs.core.Response;
22 import javax.ws.rs.core.UriInfo;
23 import org.opendaylight.restconf.common.context.NormalizedNodeContext;
24 import org.opendaylight.restconf.common.patch.Patch;
25 import org.opendaylight.restconf.common.patch.PatchContext;
26 import org.opendaylight.restconf.common.patch.PatchStatusContext;
27 import org.opendaylight.restconf.nb.rfc8040.Rfc8040;
28 import org.opendaylight.restconf.nb.rfc8040.services.simple.api.UpdateHandlers;
29 import org.opendaylight.restconf.nb.rfc8040.utils.RestconfConstants;
30
31 /**
32  * The "{+restconf}/data" subtree represents the datastore resource type, which
33  * is a collection of configuration data and state data nodes.
34  *
35  */
36 public interface RestconfDataService extends UpdateHandlers {
37
38     /**
39      * Get target data resource.
40      *
41      * @param identifier
42      *            path to target
43      * @param uriInfo
44      *            URI info
45      * @return {@link NormalizedNodeContext}
46      */
47     @GET
48     @Path("/data/{identifier:.+}")
49     @Produces({
50         Rfc8040.MediaTypes.DATA + RestconfConstants.JSON,
51         Rfc8040.MediaTypes.DATA + RestconfConstants.XML,
52         Rfc8040.MediaTypes.DATA,
53         MediaType.APPLICATION_JSON,
54         MediaType.APPLICATION_XML,
55         MediaType.TEXT_XML
56     })
57     Response readData(@Encoded @PathParam("identifier") String identifier, @Context UriInfo uriInfo);
58
59     /**
60      * Get target data resource from data root.
61      *
62      * @param uriInfo
63      *            URI info
64      * @return {@link NormalizedNodeContext}
65      */
66     @GET
67     @Path("/data")
68     @Produces({
69         Rfc8040.MediaTypes.DATA + RestconfConstants.JSON,
70         Rfc8040.MediaTypes.DATA + RestconfConstants.XML,
71         Rfc8040.MediaTypes.DATA,
72         MediaType.APPLICATION_JSON,
73         MediaType.APPLICATION_XML,
74         MediaType.TEXT_XML
75     })
76     Response readData(@Context UriInfo uriInfo);
77
78     /**
79      * Create or replace the target data resource.
80      *
81      * @param identifier
82      *            path to target
83      * @param payload
84      *            data node for put to config DS
85      * @return {@link Response}
86      */
87     @PUT
88     @Path("/data/{identifier:.+}")
89     @Consumes({
90         Rfc8040.MediaTypes.DATA + RestconfConstants.JSON,
91         Rfc8040.MediaTypes.DATA + RestconfConstants.XML,
92         Rfc8040.MediaTypes.DATA,
93         MediaType.APPLICATION_JSON,
94         MediaType.APPLICATION_XML,
95         MediaType.TEXT_XML
96     })
97     Response putData(@Encoded @PathParam("identifier") String identifier, NormalizedNodeContext payload,
98             @Context UriInfo uriInfo);
99
100     /**
101      * Create a data resource in target.
102      *
103      * @param identifier
104      *            path to target
105      * @param payload
106      *            new data
107      * @param uriInfo
108      *            URI info
109      * @return {@link Response}
110      */
111     @POST
112     @Path("/data/{identifier:.+}")
113     @Consumes({
114         Rfc8040.MediaTypes.DATA + RestconfConstants.JSON,
115         Rfc8040.MediaTypes.DATA + RestconfConstants.XML,
116         Rfc8040.MediaTypes.DATA,
117         MediaType.APPLICATION_JSON,
118         MediaType.APPLICATION_XML,
119         MediaType.TEXT_XML
120     })
121     Response postData(@Encoded @PathParam("identifier") String identifier, NormalizedNodeContext payload,
122             @Context UriInfo uriInfo);
123
124     /**
125      * Create a data resource.
126      *
127      * @param payload
128      *            new data
129      * @param uriInfo
130      *            URI info
131      * @return {@link Response}
132      */
133     @POST
134     @Path("/data")
135     @Consumes({
136         Rfc8040.MediaTypes.DATA + RestconfConstants.JSON,
137         Rfc8040.MediaTypes.DATA + RestconfConstants.XML,
138         Rfc8040.MediaTypes.DATA,
139         MediaType.APPLICATION_JSON,
140         MediaType.APPLICATION_XML,
141         MediaType.TEXT_XML
142     })
143     Response postData(NormalizedNodeContext payload, @Context UriInfo uriInfo);
144
145     /**
146      * Delete the target data resource.
147      *
148      * @param identifier
149      *            path to target
150      * @return {@link Response}
151      */
152     @DELETE
153     @Path("/data/{identifier:.+}")
154     Response deleteData(@Encoded @PathParam("identifier") String identifier);
155
156     /**
157      * Ordered list of edits that are applied to the target datastore by the
158      * server.
159      *
160      * @param identifier
161      *            path to target
162      * @param context
163      *            edits
164      * @param uriInfo
165      *            URI info
166      * @return {@link PatchStatusContext}
167      */
168     @Patch
169     @Path("/data/{identifier:.+}")
170     @Consumes({
171         Rfc8040.MediaTypes.YANG_PATCH + RestconfConstants.JSON,
172         Rfc8040.MediaTypes.YANG_PATCH + RestconfConstants.XML
173     })
174     @Produces({
175         Rfc8040.MediaTypes.YANG_PATCH_STATUS + RestconfConstants.JSON,
176         Rfc8040.MediaTypes.YANG_PATCH_STATUS + RestconfConstants.XML
177     })
178     PatchStatusContext patchData(@Encoded @PathParam("identifier") String identifier, PatchContext context,
179                                  @Context UriInfo uriInfo);
180
181     /**
182      * Ordered list of edits that are applied to the datastore by the server.
183      *
184      * @param context
185      *            edits
186      * @param uriInfo
187      *            URI info
188      * @return {@link PatchStatusContext}
189      */
190     @Patch
191     @Path("/data")
192     @Consumes({
193         Rfc8040.MediaTypes.YANG_PATCH + RestconfConstants.JSON,
194         Rfc8040.MediaTypes.YANG_PATCH + RestconfConstants.XML
195     })
196     @Produces({
197         Rfc8040.MediaTypes.YANG_PATCH_STATUS + RestconfConstants.JSON,
198         Rfc8040.MediaTypes.YANG_PATCH_STATUS + RestconfConstants.XML
199     })
200     PatchStatusContext patchData(PatchContext context, @Context UriInfo uriInfo);
201
202
203     /**
204      * Partially modify the target data resource.
205      *
206      * @param identifier
207      *            path to target
208      * @param payload
209      *            data node for put to config DS
210      * @return {@link Response}
211      */
212     @Patch
213     @Path("/data/{identifier:.+}")
214     @Consumes({
215         Rfc8040.MediaTypes.DATA + RestconfConstants.JSON,
216         Rfc8040.MediaTypes.DATA + RestconfConstants.XML,
217         Rfc8040.MediaTypes.DATA,
218         MediaType.APPLICATION_JSON,
219         MediaType.APPLICATION_XML,
220         MediaType.TEXT_XML
221     })
222     Response patchData(@Encoded @PathParam("identifier") String identifier, NormalizedNodeContext payload,
223                        @Context UriInfo uriInfo);
224 }