f82e5767df0c1499f2f6a2b7dcbf68c622fd3191
[netconf.git] / restconf / sal-rest-connector / src / main / java / org / opendaylight / netconf / sal / rest / api / RestconfService.java
1 /*
2  * Copyright (c) 2013 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.netconf.sal.rest.api;
9
10 import javax.ws.rs.Consumes;
11 import javax.ws.rs.DELETE;
12 import javax.ws.rs.DefaultValue;
13 import javax.ws.rs.Encoded;
14 import javax.ws.rs.GET;
15 import javax.ws.rs.POST;
16 import javax.ws.rs.PUT;
17 import javax.ws.rs.Path;
18 import javax.ws.rs.PathParam;
19 import javax.ws.rs.Produces;
20 import javax.ws.rs.core.Context;
21 import javax.ws.rs.core.MediaType;
22 import javax.ws.rs.core.Response;
23 import javax.ws.rs.core.UriInfo;
24 import org.opendaylight.netconf.sal.rest.api.Draft02.MediaTypes;
25 import org.opendaylight.netconf.sal.rest.impl.PATCH;
26 import org.opendaylight.netconf.sal.restconf.impl.NormalizedNodeContext;
27 import org.opendaylight.netconf.sal.restconf.impl.PATCHContext;
28 import org.opendaylight.netconf.sal.restconf.impl.PATCHStatusContext;
29 import org.opendaylight.restconf.base.services.api.RestconfModulesService;
30 import org.opendaylight.restconf.base.services.api.RestconfOperationsService;
31 import org.opendaylight.restconf.base.services.api.RestconfStreamsService;
32 import org.opendaylight.restconf.restful.services.api.RestconfDataService;
33 import org.opendaylight.restconf.restful.services.api.RestconfInvokeOperationsService;
34
35 /**
36  * The URI hierarchy for the RESTCONF resources consists of an entry point
37  * container, 4 top-level resources, and 1 field.
38  * <ul>
39  * <li><b>/restconf</b> - {@link #getRoot()}
40  * <ul>
41  * <li><b>/config</b> - {@link #readConfigurationData(String, UriInfo)}
42  * {@link #updateConfigurationData(String, NormalizedNodeContext, UriInfo)}
43  * {@link #createConfigurationData(NormalizedNodeContext, UriInfo)}
44  * {@link #createConfigurationData(String, NormalizedNodeContext, UriInfo)}
45  * {@link #deleteConfigurationData(String)}
46  * <li><b>/operational</b> - {@link #readOperationalData(String, UriInfo)}
47  * <li>/modules - {@link #getModules(UriInfo)}
48  * <ul>
49  * <li>/module
50  * </ul>
51  * <li><b>/operations</b> -
52  * {@link #invokeRpc(String, NormalizedNodeContext, UriInfo)}
53  * {@link #invokeRpc(String, NormalizedNodeContext, UriInfo)}
54  * <li>/version (field)
55  * </ul>
56  * </ul>
57  */
58 @Path("/")
59 public interface RestconfService {
60
61     public static final String XML = "+xml";
62     public static final String JSON = "+json";
63
64     @GET
65     public Object getRoot();
66
67     /**
68      * @deprecated do not use this method. It will be replaced by
69      *             {@link RestconfModulesService#getModules(UriInfo)}
70      */
71     @Deprecated
72     @GET
73     @Path("/modules")
74     @Produces({ Draft02.MediaTypes.API + JSON, Draft02.MediaTypes.API + XML, MediaType.APPLICATION_JSON,
75             MediaType.APPLICATION_XML, MediaType.TEXT_XML })
76     public NormalizedNodeContext getModules(@Context UriInfo uriInfo);
77
78     /**
79      * @deprecated do not use this method. It will be replaced by
80      *             {@link RestconfModulesService#getModules(String, UriInfo)}
81      */
82     @Deprecated
83     @GET
84     @Path("/modules/{identifier:.+}")
85     @Produces({ Draft02.MediaTypes.API + JSON, Draft02.MediaTypes.API + XML, MediaType.APPLICATION_JSON,
86             MediaType.APPLICATION_XML, MediaType.TEXT_XML })
87     public NormalizedNodeContext getModules(@PathParam("identifier") String identifier, @Context UriInfo uriInfo);
88
89     /**
90      * @deprecated do not use this method. It will be replaced by
91      *             {@link RestconfModulesService#getModule(String, UriInfo)}
92      */
93     @Deprecated
94     @GET
95     @Path("/modules/module/{identifier:.+}")
96     @Produces({ Draft02.MediaTypes.API + JSON, Draft02.MediaTypes.API + XML, MediaType.APPLICATION_JSON,
97             MediaType.APPLICATION_XML, MediaType.TEXT_XML })
98     public NormalizedNodeContext getModule(@PathParam("identifier") String identifier, @Context UriInfo uriInfo);
99
100     /**
101      * @deprecated do not use this method. It will be replaced by
102      *             {@link RestconfOperationsService#getOperations(UriInfo)}
103      */
104     @Deprecated
105     @GET
106     @Path("/operations")
107     @Produces({ Draft02.MediaTypes.API + JSON, Draft02.MediaTypes.API + XML, MediaType.APPLICATION_JSON,
108             MediaType.APPLICATION_XML, MediaType.TEXT_XML })
109     public NormalizedNodeContext getOperations(@Context UriInfo uriInfo);
110
111     /**
112      * @deprecated do not use this method. It will be replaced by
113      *             {@link RestconfOperationsService#getOperations(String, UriInfo)}
114      */
115     @Deprecated
116     @GET
117     @Path("/operations/{identifier:.+}")
118     @Produces({ Draft02.MediaTypes.API + JSON, Draft02.MediaTypes.API + XML, MediaType.APPLICATION_JSON,
119             MediaType.APPLICATION_XML, MediaType.TEXT_XML })
120     public NormalizedNodeContext getOperations(@PathParam("identifier") String identifier, @Context UriInfo uriInfo);
121
122     /**
123      * @deprecated do not use this method. It will be replaced by
124      *             {@link RestconfInvokeOperationsService#invokeRpc(String, NormalizedNodeContext, UriInfo)}
125      */
126     @Deprecated
127     @POST
128     @Path("/operations/{identifier:.+}")
129     @Produces({ Draft02.MediaTypes.OPERATION + JSON, Draft02.MediaTypes.OPERATION + XML,
130             Draft02.MediaTypes.DATA + JSON, Draft02.MediaTypes.DATA + XML, MediaType.APPLICATION_JSON,
131             MediaType.APPLICATION_XML, MediaType.TEXT_XML })
132     @Consumes({ Draft02.MediaTypes.OPERATION + JSON, Draft02.MediaTypes.OPERATION + XML,
133             Draft02.MediaTypes.DATA + JSON, Draft02.MediaTypes.DATA + XML, MediaType.APPLICATION_JSON,
134             MediaType.APPLICATION_XML, MediaType.TEXT_XML })
135     public NormalizedNodeContext invokeRpc(@Encoded @PathParam("identifier") String identifier, NormalizedNodeContext payload,
136             @Context UriInfo uriInfo);
137
138     @POST
139     @Path("/operations/{identifier:.+}")
140     @Produces({ Draft02.MediaTypes.OPERATION + JSON, Draft02.MediaTypes.OPERATION + XML,
141             Draft02.MediaTypes.DATA + JSON, Draft02.MediaTypes.DATA + XML, MediaType.APPLICATION_JSON,
142             MediaType.APPLICATION_XML, MediaType.TEXT_XML })
143     @Deprecated // method isn't use anywhere
144     public NormalizedNodeContext invokeRpc(@Encoded @PathParam("identifier") String identifier,
145             @DefaultValue("") String noPayload, @Context UriInfo uriInfo);
146
147     /**
148      * @deprecated do not use this method. It will be replaced by
149      *             {@link RestconfDataService#readData(String, UriInfo)}
150      */
151     @Deprecated
152     @GET
153     @Path("/config/{identifier:.+}")
154     @Produces({ Draft02.MediaTypes.DATA + JSON, Draft02.MediaTypes.DATA + XML, MediaType.APPLICATION_JSON,
155             MediaType.APPLICATION_XML, MediaType.TEXT_XML })
156     public NormalizedNodeContext readConfigurationData(@Encoded @PathParam("identifier") String identifier,
157             @Context UriInfo uriInfo);
158
159     /**
160      * @deprecated do not use this method. It will be replaced by
161      *             {@link RestconfDataService#readData(String, UriInfo)}
162      */
163     @Deprecated
164     @GET
165     @Path("/operational/{identifier:.+}")
166     @Produces({ Draft02.MediaTypes.DATA + JSON, Draft02.MediaTypes.DATA + XML, MediaType.APPLICATION_JSON,
167             MediaType.APPLICATION_XML, MediaType.TEXT_XML })
168     public NormalizedNodeContext readOperationalData(@Encoded @PathParam("identifier") String identifier,
169             @Context UriInfo uriInfo);
170
171     /**
172      * @deprecated do not use this method. It will be replaced by
173      *             {@link RestconfDataService#putData(String, NormalizedNodeContext, UriInfo)}
174      */
175     @Deprecated
176     @PUT
177     @Path("/config/{identifier:.+}")
178     @Consumes({ Draft02.MediaTypes.DATA + JSON, Draft02.MediaTypes.DATA + XML, MediaType.APPLICATION_JSON,
179             MediaType.APPLICATION_XML, MediaType.TEXT_XML })
180     public Response updateConfigurationData(@Encoded @PathParam("identifier") String identifier,
181             NormalizedNodeContext payload, @Context UriInfo uriInfo);
182
183     /**
184      * @deprecated do not use this method. It will be replaced by
185      *             {@link RestconfDataService#postData(String, NormalizedNodeContext, UriInfo)}
186      */
187     @Deprecated
188     @POST
189     @Path("/config/{identifier:.+}")
190     @Consumes({ Draft02.MediaTypes.DATA + JSON, Draft02.MediaTypes.DATA + XML, MediaType.APPLICATION_JSON,
191             MediaType.APPLICATION_XML, MediaType.TEXT_XML })
192     public Response createConfigurationData(@Encoded @PathParam("identifier") String identifier, NormalizedNodeContext payload,
193             @Context UriInfo uriInfo);
194
195     /**
196      * @deprecated do not use this method. It will be replaced by
197      *             {@link RestconfDataService#postData(NormalizedNodeContext, UriInfo)}
198      */
199     @Deprecated
200     @POST
201     @Path("/config")
202     @Consumes({ Draft02.MediaTypes.DATA + JSON, Draft02.MediaTypes.DATA + XML, MediaType.APPLICATION_JSON,
203             MediaType.APPLICATION_XML, MediaType.TEXT_XML })
204     public Response createConfigurationData(NormalizedNodeContext payload, @Context UriInfo uriInfo);
205
206     /**
207      * @deprecated do not use this method. It will be replaced by
208      *             {@link RestconfDataService#deleteData(String)}
209      */
210     @Deprecated
211     @DELETE
212     @Path("/config/{identifier:.+}")
213     public Response deleteConfigurationData(@Encoded @PathParam("identifier") String identifier);
214
215     @GET
216     @Path("/streams/stream/{identifier:.+}")
217     public NormalizedNodeContext subscribeToStream(@Encoded @PathParam("identifier") String identifier,
218             @Context UriInfo uriInfo);
219
220     /**
221      * @deprecated do not use this method. It will be replaced by
222      *             {@link RestconfStreamsService#getAvailableStreams(UriInfo)}
223      */
224     @Deprecated
225     @GET
226     @Path("/streams")
227     @Produces({ Draft02.MediaTypes.API + JSON, Draft02.MediaTypes.API + XML, MediaType.APPLICATION_JSON,
228             MediaType.APPLICATION_XML, MediaType.TEXT_XML })
229     public NormalizedNodeContext getAvailableStreams(@Context UriInfo uriInfo);
230
231     /**
232      * @deprecated do not use this method. It will be replaced by
233      *             {@link RestconfDataService#patchData(String, PATCHContext, UriInfo)}
234      */
235     @Deprecated
236     @PATCH
237     @Path("/config/{identifier:.+}")
238     @Consumes({MediaTypes.PATCH + JSON, MediaTypes.PATCH + XML})
239     @Produces({MediaTypes.PATCH_STATUS + JSON, MediaTypes.PATCH_STATUS + XML})
240     PATCHStatusContext patchConfigurationData(@Encoded @PathParam("identifier") String identifier, PATCHContext
241             context, @Context UriInfo uriInfo);
242
243     /**
244      * @deprecated do not use this method. It will be replaced by
245      *             {@link RestconfDataService#patchData(PATCHContext, UriInfo)}
246      */
247     @Deprecated
248     @PATCH
249     @Path("/config")
250     @Consumes({MediaTypes.PATCH + JSON, MediaTypes.PATCH + XML})
251     @Produces({MediaTypes.PATCH_STATUS + JSON, MediaTypes.PATCH_STATUS + XML})
252     PATCHStatusContext patchConfigurationData(PATCHContext context, @Context UriInfo uriInfo);
253 }