Add support for RFC8072 media types
[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_RFC8072 + RestconfConstants.JSON,
172         Rfc8040.MediaTypes.YANG_PATCH_RFC8072 + RestconfConstants.XML,
173         Rfc8040.MediaTypes.YANG_PATCH + RestconfConstants.JSON,
174         Rfc8040.MediaTypes.YANG_PATCH + RestconfConstants.XML,
175     })
176     @Produces({
177         Rfc8040.MediaTypes.DATA + RestconfConstants.JSON,
178         Rfc8040.MediaTypes.DATA + RestconfConstants.XML,
179         Rfc8040.MediaTypes.YANG_PATCH_STATUS + RestconfConstants.JSON,
180         Rfc8040.MediaTypes.YANG_PATCH_STATUS + RestconfConstants.XML
181     })
182     PatchStatusContext patchData(@Encoded @PathParam("identifier") String identifier, PatchContext context,
183                                  @Context UriInfo uriInfo);
184
185     /**
186      * Ordered list of edits that are applied to the datastore by the server.
187      *
188      * @param context
189      *            edits
190      * @param uriInfo
191      *            URI info
192      * @return {@link PatchStatusContext}
193      */
194     @Patch
195     @Path("/data")
196     @Consumes({
197         Rfc8040.MediaTypes.YANG_PATCH_RFC8072 + RestconfConstants.JSON,
198         Rfc8040.MediaTypes.YANG_PATCH_RFC8072 + RestconfConstants.XML,
199         Rfc8040.MediaTypes.YANG_PATCH + RestconfConstants.JSON,
200         Rfc8040.MediaTypes.YANG_PATCH + RestconfConstants.XML
201     })
202     @Produces({
203         Rfc8040.MediaTypes.DATA + RestconfConstants.JSON,
204         Rfc8040.MediaTypes.DATA + RestconfConstants.XML,
205         Rfc8040.MediaTypes.YANG_PATCH_STATUS + RestconfConstants.JSON,
206         Rfc8040.MediaTypes.YANG_PATCH_STATUS + RestconfConstants.XML
207     })
208     PatchStatusContext patchData(PatchContext context, @Context UriInfo uriInfo);
209
210     /**
211      * Partially modify the target data resource.
212      *
213      * @param identifier
214      *            path to target
215      * @param payload
216      *            data node for put to config DS
217      * @return {@link Response}
218      */
219     @Patch
220     @Path("/data/{identifier:.+}")
221     @Consumes({
222         Rfc8040.MediaTypes.DATA + RestconfConstants.JSON,
223         Rfc8040.MediaTypes.DATA + RestconfConstants.XML,
224         Rfc8040.MediaTypes.DATA,
225         MediaType.APPLICATION_JSON,
226         MediaType.APPLICATION_XML,
227         MediaType.TEXT_XML
228     })
229     Response patchData(@Encoded @PathParam("identifier") String identifier, NormalizedNodeContext payload,
230                        @Context UriInfo uriInfo);
231 }