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