Added DELETE operation
[controller.git] / opendaylight / md-sal / sal-rest-connector / src / main / java / org / opendaylight / controller / 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.controller.sal.rest.api;
9
10 import javax.ws.rs.Consumes;
11 import javax.ws.rs.DELETE;
12 import javax.ws.rs.GET;
13 import javax.ws.rs.POST;
14 import javax.ws.rs.PUT;
15 import javax.ws.rs.Path;
16 import javax.ws.rs.PathParam;
17 import javax.ws.rs.Produces;
18 import javax.ws.rs.core.MediaType;
19 import javax.ws.rs.core.Response;
20
21 import org.opendaylight.controller.sal.restconf.impl.StructuredData;
22 import org.opendaylight.yangtools.yang.data.api.CompositeNode;
23
24 /**
25  *   The URI hierarchy for the RESTCONF resources consists of an entry
26  *   point container, 3 top-level resources, and 1 field.  Refer to
27  *  Section 5 for details on each URI.
28  *    <ul>
29  *    <li><b>/restconf</b> - {@link #getRoot()}
30  *     <ul><li><b>/config</b> 
31  *         <li><b>/operational</b> - {@link #readAllData()} - Added in Draft02
32  *         <li><b>/datastore</b> - {@link #readAllData()}
33  *         <ul>
34  *            <li>/(top-level-data-nodes) (config=true or false)
35  *         </ul>
36  *         <li>/modules
37  *          <ul><li>/module
38  *              <li>/name
39  *              <li>/revision
40  *              <li>/namespace
41  *              <li>/feature
42  *             <li>/deviation
43  *          </ul>
44  *          <li>/operations
45  *          <ul>
46  *             <li>/(custom protocol operations)
47  *          </ul>
48  *         <li>/version (field)
49  *     </ul>
50  */
51 @Path("/")
52 public interface RestconfService extends RestconfServiceLegacy {
53
54     public static final String XML = "+xml";
55     public static final String JSON = "+json";
56
57     @GET
58     public Object getRoot();
59
60     @GET
61     @Path("/modules")
62     @Produces({Draft01.MediaTypes.API+JSON,Draft01.MediaTypes.API+XML,
63                Draft02.MediaTypes.API+JSON,Draft02.MediaTypes.API+XML})
64     public StructuredData getModules();
65
66     @POST
67     @Path("/operations/{identifier}")
68     @Produces({Draft01.MediaTypes.DATA+JSON,Draft01.MediaTypes.DATA+XML,
69                Draft02.MediaTypes.DATA+JSON,Draft02.MediaTypes.DATA+XML, 
70                MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_XML})
71     @Consumes({Draft01.MediaTypes.DATA+JSON,Draft01.MediaTypes.DATA+XML,
72                Draft02.MediaTypes.DATA+JSON,Draft02.MediaTypes.DATA+XML, 
73                MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_XML})
74     public StructuredData invokeRpc(@PathParam("identifier") String identifier, CompositeNode payload);
75     
76     @POST
77     @Path("/operations/{identifier}")
78     @Produces({Draft01.MediaTypes.DATA+JSON,Draft01.MediaTypes.DATA+XML,
79                Draft02.MediaTypes.DATA+JSON,Draft02.MediaTypes.DATA+XML, 
80                MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_XML})
81     public StructuredData invokeRpc(@PathParam("identifier") String identifier);
82     
83     @GET
84     @Path("/config/{identifier:.+}")
85     @Produces({Draft02.MediaTypes.DATA+JSON,Draft02.MediaTypes.DATA+XML, 
86                MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_XML})
87     public StructuredData readConfigurationData(@PathParam("identifier") String identifier);
88
89     @GET
90     @Path("/operational/{identifier:.+}")
91     @Produces({Draft02.MediaTypes.DATA+JSON,Draft02.MediaTypes.DATA+XML, 
92                MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_XML})
93     public StructuredData readOperationalData(@PathParam("identifier") String identifier);
94
95     @PUT
96     @Path("/config/{identifier:.+}")
97     @Consumes({Draft02.MediaTypes.DATA+JSON,Draft02.MediaTypes.DATA+XML, 
98                MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_XML})
99     public Response updateConfigurationData(@PathParam("identifier") String identifier, CompositeNode payload);
100
101     @POST
102     @Path("/config/{identifier:.+}")
103     @Consumes({Draft02.MediaTypes.DATA+JSON,Draft02.MediaTypes.DATA+XML, 
104                MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_XML})
105     public Response createConfigurationData(@PathParam("identifier") String identifier, CompositeNode payload);
106
107     @POST
108     @Path("/config")
109     @Consumes({Draft02.MediaTypes.DATA+JSON,Draft02.MediaTypes.DATA+XML, 
110                MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_XML})
111     public Response createConfigurationData(CompositeNode payload);
112
113     @DELETE
114     @Path("/config/{identifier:.+}")
115     public Response deleteConfigurationData(@PathParam("identifier") String identifier);
116
117 }