Add plain PATCH capability to RFC8040 server
[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({ Rfc8040.MediaTypes.DATA + RestconfConstants.JSON, Rfc8040.MediaTypes.DATA, MediaType.APPLICATION_JSON,
50             MediaType.APPLICATION_XML, MediaType.TEXT_XML })
51     Response readData(@Encoded @PathParam("identifier") String identifier, @Context UriInfo uriInfo);
52
53     /**
54      * Get target data resource from data root.
55      *
56      * @param uriInfo
57      *            URI info
58      * @return {@link NormalizedNodeContext}
59      */
60     @GET
61     @Path("/data")
62     @Produces({ Rfc8040.MediaTypes.DATA + RestconfConstants.JSON, Rfc8040.MediaTypes.DATA, MediaType.APPLICATION_JSON,
63             MediaType.APPLICATION_XML, MediaType.TEXT_XML })
64     Response readData(@Context UriInfo uriInfo);
65
66     /**
67      * Create or replace the target data resource.
68      *
69      * @param identifier
70      *            path to target
71      * @param payload
72      *            data node for put to config DS
73      * @return {@link Response}
74      */
75     @PUT
76     @Path("/data/{identifier:.+}")
77     @Consumes({ Rfc8040.MediaTypes.DATA + RestconfConstants.JSON, Rfc8040.MediaTypes.DATA, MediaType.APPLICATION_JSON,
78             MediaType.APPLICATION_XML, MediaType.TEXT_XML })
79     Response putData(@Encoded @PathParam("identifier") String identifier, NormalizedNodeContext payload,
80             @Context UriInfo uriInfo);
81
82     /**
83      * Create a data resource in target.
84      *
85      * @param identifier
86      *            path to target
87      * @param payload
88      *            new data
89      * @param uriInfo
90      *            URI info
91      * @return {@link Response}
92      */
93     @POST
94     @Path("/data/{identifier:.+}")
95     @Consumes({ Rfc8040.MediaTypes.DATA + RestconfConstants.JSON, Rfc8040.MediaTypes.DATA, MediaType.APPLICATION_JSON,
96             MediaType.APPLICATION_XML, MediaType.TEXT_XML })
97     Response postData(@Encoded @PathParam("identifier") String identifier, NormalizedNodeContext payload,
98             @Context UriInfo uriInfo);
99
100     /**
101      * Create a data resource.
102      *
103      * @param payload
104      *            new data
105      * @param uriInfo
106      *            URI info
107      * @return {@link Response}
108      */
109     @POST
110     @Path("/data")
111     @Consumes({ Rfc8040.MediaTypes.DATA + RestconfConstants.JSON, Rfc8040.MediaTypes.DATA, MediaType.APPLICATION_JSON,
112             MediaType.APPLICATION_XML, MediaType.TEXT_XML })
113     Response postData(NormalizedNodeContext payload, @Context UriInfo uriInfo);
114
115     /**
116      * Delete the target data resource.
117      *
118      * @param identifier
119      *            path to target
120      * @return {@link Response}
121      */
122     @DELETE
123     @Path("/data/{identifier:.+}")
124     Response deleteData(@Encoded @PathParam("identifier") String identifier);
125
126     /**
127      * Ordered list of edits that are applied to the target datastore by the
128      * server.
129      *
130      * @param identifier
131      *            path to target
132      * @param context
133      *            edits
134      * @param uriInfo
135      *            URI info
136      * @return {@link PatchStatusContext}
137      */
138     @Patch
139     @Path("/data/{identifier:.+}")
140     @Consumes({ Rfc8040.MediaTypes.YANG_PATCH + RestconfConstants.JSON,
141             Rfc8040.MediaTypes.YANG_PATCH + RestconfConstants.XML })
142     @Produces({ Rfc8040.MediaTypes.YANG_PATCH_STATUS + RestconfConstants.JSON,
143             Rfc8040.MediaTypes.YANG_PATCH_STATUS + RestconfConstants.XML })
144     PatchStatusContext patchData(@Encoded @PathParam("identifier") String identifier, PatchContext context,
145                                  @Context UriInfo uriInfo);
146
147     /**
148      * Ordered list of edits that are applied to the datastore by the server.
149      *
150      * @param context
151      *            edits
152      * @param uriInfo
153      *            URI info
154      * @return {@link PatchStatusContext}
155      */
156     @Patch
157     @Path("/data")
158     @Consumes({ Rfc8040.MediaTypes.YANG_PATCH + RestconfConstants.JSON,
159             Rfc8040.MediaTypes.YANG_PATCH + RestconfConstants.XML })
160     @Produces({ Rfc8040.MediaTypes.YANG_PATCH_STATUS + RestconfConstants.JSON,
161             Rfc8040.MediaTypes.YANG_PATCH_STATUS + RestconfConstants.XML })
162     PatchStatusContext patchData(PatchContext context, @Context UriInfo uriInfo);
163
164
165     /**
166      * Partially modify the target data resource.
167      *
168      * @param identifier
169      *            path to target
170      * @param payload
171      *            data node for put to config DS
172      * @return {@link Response}
173      */
174     @Patch
175     @Path("/data/{identifier:.+}")
176     @Consumes({ Rfc8040.MediaTypes.DATA + RestconfConstants.JSON, Rfc8040.MediaTypes.DATA, MediaType.APPLICATION_JSON,
177             MediaType.APPLICATION_XML, MediaType.TEXT_XML })
178     Response patchData(@Encoded @PathParam("identifier") String identifier, NormalizedNodeContext payload,
179                        @Context UriInfo uriInfo);
180 }