Added support for /modules, /modules/module, /operations resources
[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.DefaultValue;
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.MediaType;
20 import javax.ws.rs.core.Response;
21
22 import org.opendaylight.controller.sal.restconf.impl.StructuredData;
23 import org.opendaylight.yangtools.yang.data.api.CompositeNode;
24
25 /**
26  *   The URI hierarchy for the RESTCONF resources consists of an entry
27  *   point container, 4 top-level resources, and 1 field.
28  *   <ul>
29  *    <li><b>/restconf</b> - {@link #getRoot()}
30  *     <ul>
31  *      <li><b>/config</b> - {@link #readConfigurationData(String)} 
32  *                              {@link #updateConfigurationData(String, CompositeNode)}
33  *                              {@link #createConfigurationData(CompositeNode)}
34  *                              {@link #createConfigurationData(String, CompositeNode)}
35  *                              {@link #deleteConfigurationData(String)}
36  *      <li><b>/operational</b> - {@link #readOperationalData(String)} 
37  *      <li>/modules - {@link #getModules()}
38  *       <ul>
39  *        <li>/module
40  *       </ul>
41  *      <li><b>/operations</b> - {@link #invokeRpc(String, CompositeNode)}
42  *                               {@link #invokeRpc(String, CompositeNode)}
43  *      <li>/version (field)
44  *     </ul>
45  *   </ul>
46  */
47 @Path("/")
48 public interface RestconfService {
49
50     public static final String XML = "+xml";
51     public static final String JSON = "+json";
52
53     @GET
54     public Object getRoot();
55
56     @GET
57     @Path("/modules")
58     @Produces({Draft02.MediaTypes.API+XML, Draft02.MediaTypes.API+JSON,
59                MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_XML})
60     public StructuredData getModules();
61
62     @GET
63     @Path("/modules/{identifier:.+}")
64     @Produces({Draft02.MediaTypes.API+XML, Draft02.MediaTypes.API+JSON,
65                MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_XML})
66     public StructuredData getModules(@PathParam("identifier") String identifier);
67
68     @GET
69     @Path("/modules/module/{identifier:.+}")
70     @Produces({Draft02.MediaTypes.API+XML, Draft02.MediaTypes.API+JSON,
71                MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_XML})
72     public StructuredData getModule(@PathParam("identifier") String identifier);
73
74     @GET
75     @Path("/operations")
76     @Produces({Draft02.MediaTypes.API+XML, Draft02.MediaTypes.API+JSON,
77                MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_XML})
78     public StructuredData getOperations();
79
80     @GET
81     @Path("/operations/{identifier:.+}")
82     @Produces({Draft02.MediaTypes.API+XML, Draft02.MediaTypes.API+JSON,
83                MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_XML})
84     public StructuredData getOperations(@PathParam("identifier") String identifier);
85
86     @POST
87     @Path("/operations/{identifier:.+}")
88     @Produces({Draft02.MediaTypes.OPERATION+JSON, Draft02.MediaTypes.OPERATION+XML,
89                Draft02.MediaTypes.DATA+JSON, Draft02.MediaTypes.DATA+XML,
90                MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_XML})
91     @Consumes({Draft02.MediaTypes.OPERATION+JSON, Draft02.MediaTypes.OPERATION+XML,
92                Draft02.MediaTypes.DATA+JSON, Draft02.MediaTypes.DATA+XML,
93                MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_XML})
94     public StructuredData invokeRpc(@PathParam("identifier") String identifier, CompositeNode payload);
95     
96     @POST
97     @Path("/operations/{identifier:.+}")
98     @Produces({Draft02.MediaTypes.OPERATION+JSON, Draft02.MediaTypes.OPERATION+XML,
99                Draft02.MediaTypes.DATA+JSON, Draft02.MediaTypes.DATA+XML,
100                MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_XML})
101     public StructuredData invokeRpc(@PathParam("identifier") String identifier, @DefaultValue("") String noPayload);
102     
103     @GET
104     @Path("/config/{identifier:.+}")
105     @Produces({Draft02.MediaTypes.DATA+JSON,Draft02.MediaTypes.DATA+XML, 
106                MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_XML})
107     public StructuredData readConfigurationData(@PathParam("identifier") String identifier);
108
109     @GET
110     @Path("/operational/{identifier:.+}")
111     @Produces({Draft02.MediaTypes.DATA+JSON,Draft02.MediaTypes.DATA+XML, 
112                MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_XML})
113     public StructuredData readOperationalData(@PathParam("identifier") String identifier);
114
115     @PUT
116     @Path("/config/{identifier:.+}")
117     @Consumes({Draft02.MediaTypes.DATA+JSON,Draft02.MediaTypes.DATA+XML, 
118                MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_XML})
119     public Response updateConfigurationData(@PathParam("identifier") String identifier, CompositeNode payload);
120
121     @POST
122     @Path("/config/{identifier:.+}")
123     @Consumes({Draft02.MediaTypes.DATA+JSON,Draft02.MediaTypes.DATA+XML, 
124                MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_XML})
125     public Response createConfigurationData(@PathParam("identifier") String identifier, CompositeNode payload);
126
127     @POST
128     @Path("/config")
129     @Consumes({Draft02.MediaTypes.DATA+JSON,Draft02.MediaTypes.DATA+XML, 
130                MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_XML})
131     public Response createConfigurationData(CompositeNode payload);
132
133     @DELETE
134     @Path("/config/{identifier:.+}")
135     public Response deleteConfigurationData(@PathParam("identifier") String identifier);
136
137 }