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