Split out RFC8040-only constructs from yang-common
[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.patch.Patch;
24 import org.opendaylight.restconf.common.patch.PatchContext;
25 import org.opendaylight.restconf.common.patch.PatchStatusContext;
26 import org.opendaylight.restconf.nb.rfc8040.MediaTypes;
27 import org.opendaylight.restconf.nb.rfc8040.legacy.NormalizedNodePayload;
28
29 /**
30  * The "{+restconf}/data" subtree represents the datastore resource type, which
31  * is a collection of configuration data and state data nodes.
32  *
33  */
34 public interface RestconfDataService {
35     /**
36      * Get target data resource.
37      *
38      * @param identifier
39      *            path to target
40      * @param uriInfo
41      *            URI info
42      * @return {@link NormalizedNodePayload}
43      */
44     @GET
45     @Path("/data/{identifier:.+}")
46     @Produces({
47         MediaTypes.APPLICATION_YANG_DATA_JSON,
48         MediaTypes.APPLICATION_YANG_DATA_XML,
49         MediaType.APPLICATION_JSON,
50         MediaType.APPLICATION_XML,
51         MediaType.TEXT_XML
52     })
53     Response readData(@Encoded @PathParam("identifier") String identifier, @Context UriInfo uriInfo);
54
55     /**
56      * Get target data resource from data root.
57      *
58      * @param uriInfo
59      *            URI info
60      * @return {@link NormalizedNodePayload}
61      */
62     @GET
63     @Path("/data")
64     @Produces({
65         MediaTypes.APPLICATION_YANG_DATA_JSON,
66         MediaTypes.APPLICATION_YANG_DATA_XML,
67         MediaType.APPLICATION_JSON,
68         MediaType.APPLICATION_XML,
69         MediaType.TEXT_XML
70     })
71     Response readData(@Context UriInfo uriInfo);
72
73     /**
74      * Create or replace the target data resource.
75      *
76      * @param identifier
77      *            path to target
78      * @param payload
79      *            data node for put to config DS
80      * @return {@link Response}
81      */
82     @PUT
83     @Path("/data/{identifier:.+}")
84     @Consumes({
85         MediaTypes.APPLICATION_YANG_DATA_JSON,
86         MediaTypes.APPLICATION_YANG_DATA_XML,
87         MediaType.APPLICATION_JSON,
88         MediaType.APPLICATION_XML,
89         MediaType.TEXT_XML
90     })
91     Response putData(@Encoded @PathParam("identifier") String identifier, NormalizedNodePayload payload,
92             @Context UriInfo uriInfo);
93
94     /**
95      * Create a data resource in target.
96      *
97      * @param identifier
98      *            path to target
99      * @param payload
100      *            new data
101      * @param uriInfo
102      *            URI info
103      * @return {@link Response}
104      */
105     @POST
106     @Path("/data/{identifier:.+}")
107     @Consumes({
108         MediaTypes.APPLICATION_YANG_DATA_JSON,
109         MediaTypes.APPLICATION_YANG_DATA_XML,
110         MediaType.APPLICATION_JSON,
111         MediaType.APPLICATION_XML,
112         MediaType.TEXT_XML
113     })
114     Response postData(@Encoded @PathParam("identifier") String identifier, NormalizedNodePayload payload,
115             @Context UriInfo uriInfo);
116
117     /**
118      * Create a data resource.
119      *
120      * @param payload
121      *            new data
122      * @param uriInfo
123      *            URI info
124      * @return {@link Response}
125      */
126     @POST
127     @Path("/data")
128     @Consumes({
129         MediaTypes.APPLICATION_YANG_DATA_JSON,
130         MediaTypes.APPLICATION_YANG_DATA_XML,
131         MediaType.APPLICATION_JSON,
132         MediaType.APPLICATION_XML,
133         MediaType.TEXT_XML
134     })
135     Response postData(NormalizedNodePayload payload, @Context UriInfo uriInfo);
136
137     /**
138      * Delete the target data resource.
139      *
140      * @param identifier
141      *            path to target
142      * @return {@link Response}
143      */
144     @DELETE
145     @Path("/data/{identifier:.+}")
146     Response deleteData(@Encoded @PathParam("identifier") String identifier);
147
148     /**
149      * Ordered list of edits that are applied to the target datastore by the
150      * server.
151      *
152      * @param identifier
153      *            path to target
154      * @param context
155      *            edits
156      * @param uriInfo
157      *            URI info
158      * @return {@link PatchStatusContext}
159      */
160     @Patch
161     @Path("/data/{identifier:.+}")
162     @Consumes({
163         MediaTypes.APPLICATION_YANG_PATCH_JSON,
164         MediaTypes.APPLICATION_YANG_PATCH_XML
165     })
166     @Produces({
167         MediaTypes.APPLICATION_YANG_DATA_JSON,
168         MediaTypes.APPLICATION_YANG_DATA_XML
169     })
170     PatchStatusContext patchData(@Encoded @PathParam("identifier") String identifier, PatchContext context,
171                                  @Context UriInfo uriInfo);
172
173     /**
174      * Ordered list of edits that are applied to the datastore by the server.
175      *
176      * @param context
177      *            edits
178      * @param uriInfo
179      *            URI info
180      * @return {@link PatchStatusContext}
181      */
182     @Patch
183     @Path("/data")
184     @Consumes({
185         MediaTypes.APPLICATION_YANG_PATCH_JSON,
186         MediaTypes.APPLICATION_YANG_PATCH_XML
187     })
188     @Produces({
189         MediaTypes.APPLICATION_YANG_DATA_JSON,
190         MediaTypes.APPLICATION_YANG_DATA_XML
191     })
192     PatchStatusContext patchData(PatchContext context, @Context UriInfo uriInfo);
193
194
195     /**
196      * Partially modify the target data resource.
197      *
198      * @param identifier
199      *            path to target
200      * @param payload
201      *            data node for put to config DS
202      * @return {@link Response}
203      */
204     @Patch
205     @Path("/data/{identifier:.+}")
206     @Consumes({
207         MediaTypes.APPLICATION_YANG_DATA_JSON,
208         MediaTypes.APPLICATION_YANG_DATA_XML,
209         MediaType.APPLICATION_JSON,
210         MediaType.APPLICATION_XML,
211         MediaType.TEXT_XML
212     })
213     Response patchData(@Encoded @PathParam("identifier") String identifier, NormalizedNodePayload payload,
214                        @Context UriInfo uriInfo);
215 }