bd800311d7f6f0fc8a21c822499372eba012a68f
[netconf.git] / restconf / sal-rest-connector / 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.NormalizedNodeContext;
25 import org.opendaylight.netconf.sal.restconf.impl.PATCHContext;
26 import org.opendaylight.netconf.sal.restconf.impl.PATCHStatusContext;
27 import org.opendaylight.restconf.Draft15;
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({ Draft15.MediaTypes.DATA + RestconfConstants.JSON, Draft15.MediaTypes.DATA + RestconfConstants.XML,
49             MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_XML })
50     NormalizedNodeContext readData(@Encoded @PathParam("identifier") String identifier,
51             @Context UriInfo uriInfo);
52
53     /**
54      * Create or replace the target data resource.
55      *
56      * @param identifier
57      *            - path to target
58      * @param payload
59      *            - data node for put to config DS
60      * @return {@link Response}
61      */
62     @PUT
63     @Path("/data/{identifier:.+}")
64     @Consumes({ Draft15.MediaTypes.DATA + RestconfConstants.JSON, Draft15.MediaTypes.DATA + RestconfConstants.XML,
65             MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_XML })
66     Response putData(@Encoded @PathParam("identifier") String identifier, NormalizedNodeContext payload);
67
68     /**
69      * Create a data resource in target.
70      *
71      * @param identifier
72      *            - path to target
73      * @param payload
74      *            - new data
75      * @param uriInfo
76      *            - URI info
77      * @return {@link Response}
78      */
79     @POST
80     @Path("/data/{identifier:.+}")
81     @Consumes({ Draft15.MediaTypes.DATA + RestconfConstants.JSON, Draft15.MediaTypes.DATA + RestconfConstants.XML,
82             MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_XML })
83     Response postData(@Encoded @PathParam("identifier") String identifier, NormalizedNodeContext payload,
84             @Context UriInfo uriInfo);
85
86     /**
87      * Create a data resource.
88      *
89      * @param payload
90      *            - new data
91      * @param uriInfo
92      *            - URI info
93      * @return {@link Response}
94      */
95     @POST
96     @Path("/data")
97     @Consumes({ Draft15.MediaTypes.DATA + RestconfConstants.JSON, Draft15.MediaTypes.DATA + RestconfConstants.XML,
98             MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_XML })
99     Response postData(NormalizedNodeContext payload, @Context UriInfo uriInfo);
100
101     /**
102      * Delete the target data resource.
103      *
104      * @param identifier
105      *            - path to target
106      * @return {@link Response}
107      */
108     @DELETE
109     @Path("/data/{identifier:.+}")
110     Response deleteData(@Encoded @PathParam("identifier") String identifier);
111
112     /**
113      * Ordered list of edits that are applied to the target datastore by the
114      * server.
115      *
116      * @param identifier
117      *            - path to target
118      * @param context
119      *            - edits
120      * @param uriInfo
121      *            - URI info
122      * @return {@link PATCHStatusContext}
123      */
124     @PATCH
125     @Path("/data/{identifier:.+}")
126     @Consumes({ Draft15.MediaTypes.PATCH + RestconfConstants.JSON, Draft15.MediaTypes.PATCH + RestconfConstants.XML })
127     @Produces({ Draft15.MediaTypes.PATCH_STATUS + RestconfConstants.JSON,
128             Draft15.MediaTypes.PATCH_STATUS + RestconfConstants.XML })
129     PATCHStatusContext patchData(@Encoded @PathParam("identifier") String identifier, PATCHContext context,
130             @Context UriInfo uriInfo);
131
132     /**
133      * Ordered list of edits that are applied to the datastore by the server.
134      *
135      * @param context
136      *            - edits
137      * @param uriInfo
138      *            - URI info
139      * @return {@link PATCHStatusContext}
140      */
141     @PATCH
142     @Path("/data")
143     @Consumes({ Draft15.MediaTypes.PATCH + RestconfConstants.JSON, Draft15.MediaTypes.PATCH + RestconfConstants.XML })
144     @Produces({ Draft15.MediaTypes.PATCH_STATUS + RestconfConstants.JSON,
145             Draft15.MediaTypes.PATCH_STATUS + RestconfConstants.XML })
146     PATCHStatusContext patchData(PATCHContext context, @Context UriInfo uriInfo);
147 }