b06be1ed5f90750efd7c30800408c217ceba07ca
[netconf.git] / restconf / restconf-nb-bierman02 / src / main / java / org / opendaylight / restconf / restful / 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.restful.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.netconf.sal.rest.impl.Patch;
24 import org.opendaylight.netconf.sal.restconf.impl.PatchContext;
25 import org.opendaylight.netconf.sal.restconf.impl.PatchStatusContext;
26 import org.opendaylight.restconf.Rfc8040;
27 import org.opendaylight.restconf.common.context.NormalizedNodeContext;
28 import org.opendaylight.restconf.utils.RestconfConstants;
29
30 /**
31  * The "{+restconf}/data" subtree represents the datastore resource type, which
32  * is a collection of configuration data and state data nodes.
33  *
34  */
35 public interface RestconfDataService {
36
37     /**
38      * Get target data resource.
39      *
40      * @param identifier
41      *            path to target
42      * @param uriInfo
43      *            URI info
44      * @return {@link NormalizedNodeContext}
45      */
46     @GET
47     @Path("/data/{identifier:.+}")
48     @Produces({ Rfc8040.MediaTypes.DATA + RestconfConstants.JSON, Rfc8040.MediaTypes.DATA, MediaType.APPLICATION_JSON,
49             MediaType.APPLICATION_XML, MediaType.TEXT_XML })
50     Response readData(@Encoded @PathParam("identifier") String identifier, @Context UriInfo uriInfo);
51
52     /**
53      * Get target data resource from data root.
54      *
55      * @param uriInfo
56      *            URI info
57      * @return {@link NormalizedNodeContext}
58      */
59     @GET
60     @Path("/data")
61     @Produces({ Rfc8040.MediaTypes.DATA + RestconfConstants.JSON, Rfc8040.MediaTypes.DATA, MediaType.APPLICATION_JSON,
62             MediaType.APPLICATION_XML, MediaType.TEXT_XML })
63     Response readData(@Context UriInfo uriInfo);
64
65     /**
66      * Create or replace the target data resource.
67      *
68      * @param identifier
69      *            path to target
70      * @param payload
71      *            data node for put to config DS
72      * @return {@link Response}
73      */
74     @PUT
75     @Path("/data/{identifier:.+}")
76     @Consumes({ Rfc8040.MediaTypes.DATA + RestconfConstants.JSON, Rfc8040.MediaTypes.DATA, MediaType.APPLICATION_JSON,
77             MediaType.APPLICATION_XML, MediaType.TEXT_XML })
78     Response putData(@Encoded @PathParam("identifier") String identifier, NormalizedNodeContext payload,
79             @Context UriInfo uriInfo);
80
81     /**
82      * Create a data resource in target.
83      *
84      * @param identifier
85      *            path to target
86      * @param payload
87      *            new data
88      * @param uriInfo
89      *            URI info
90      * @return {@link Response}
91      */
92     @POST
93     @Path("/data/{identifier:.+}")
94     @Consumes({ Rfc8040.MediaTypes.DATA + RestconfConstants.JSON, Rfc8040.MediaTypes.DATA, MediaType.APPLICATION_JSON,
95             MediaType.APPLICATION_XML, MediaType.TEXT_XML })
96     Response postData(@Encoded @PathParam("identifier") String identifier, NormalizedNodeContext payload,
97             @Context UriInfo uriInfo);
98
99     /**
100      * Create a data resource.
101      *
102      * @param payload
103      *            new data
104      * @param uriInfo
105      *            URI info
106      * @return {@link Response}
107      */
108     @POST
109     @Path("/data")
110     @Consumes({ Rfc8040.MediaTypes.DATA + RestconfConstants.JSON, Rfc8040.MediaTypes.DATA, MediaType.APPLICATION_JSON,
111             MediaType.APPLICATION_XML, MediaType.TEXT_XML })
112     Response postData(NormalizedNodeContext payload, @Context UriInfo uriInfo);
113
114     /**
115      * Delete the target data resource.
116      *
117      * @param identifier
118      *            path to target
119      * @return {@link Response}
120      */
121     @DELETE
122     @Path("/data/{identifier:.+}")
123     Response deleteData(@Encoded @PathParam("identifier") String identifier);
124
125     /**
126      * Ordered list of edits that are applied to the target datastore by the
127      * server.
128      *
129      * @param identifier
130      *            path to target
131      * @param context
132      *            edits
133      * @param uriInfo
134      *            URI info
135      * @return {@link PatchStatusContext}
136      */
137     @Patch
138     @Path("/data/{identifier:.+}")
139     @Consumes({ Rfc8040.MediaTypes.PATCH + RestconfConstants.JSON, Rfc8040.MediaTypes.PATCH + RestconfConstants.XML })
140     @Produces({ Rfc8040.MediaTypes.PATCH_STATUS + RestconfConstants.JSON,
141             Rfc8040.MediaTypes.PATCH_STATUS + RestconfConstants.XML })
142     PatchStatusContext patchData(@Encoded @PathParam("identifier") String identifier, PatchContext context,
143                                  @Context UriInfo uriInfo);
144
145     /**
146      * Ordered list of edits that are applied to the datastore by the server.
147      *
148      * @param context
149      *            edits
150      * @param uriInfo
151      *            URI info
152      * @return {@link PatchStatusContext}
153      */
154     @Patch
155     @Path("/data")
156     @Consumes({ Rfc8040.MediaTypes.PATCH + RestconfConstants.JSON, Rfc8040.MediaTypes.PATCH + RestconfConstants.XML })
157     @Produces({ Rfc8040.MediaTypes.PATCH_STATUS + RestconfConstants.JSON,
158             Rfc8040.MediaTypes.PATCH_STATUS + RestconfConstants.XML })
159     PatchStatusContext patchData(PatchContext context, @Context UriInfo uriInfo);
160 }