blob: 581728c4a06ac1a9d283784d3061c92f32554cee [file] [log] [blame]
David K. Bainbridgeeda2b052017-07-12 09:41:04 -07001/*
2 * Copyright 2017-present Open Networking Laboratory
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.opencord.sadis;
17
18import com.fasterxml.jackson.databind.node.ObjectNode;
19import org.onosproject.rest.AbstractWebResource;
20
21import java.net.URI;
22import java.net.URISyntaxException;
23
24import javax.ws.rs.GET;
25import javax.ws.rs.POST;
26import javax.ws.rs.PUT;
27import javax.ws.rs.DELETE;
28import javax.ws.rs.Path;
29import javax.ws.rs.PathParam;
30import javax.ws.rs.Produces;
31import javax.ws.rs.Consumes;
32import javax.ws.rs.core.MediaType;
33import javax.ws.rs.core.Response;
34
35//import static org.onlab.util.Tools.nullIsNotFound;
36
37/**
38 * Subscriber And Device Information Service web resource.
39 */
40@Path("sadis")
41public class AppWebResource extends AbstractWebResource {
42
43 /**
44 * Get subscriber object.
45 *
46 * @param id
47 * ID of the subscriber
48 *
49 * @return 200 OK
50 */
51 @GET
52 @Path("/subscriber/{id}")
53 @Produces(MediaType.APPLICATION_JSON)
54 public Response getSubscriber(@PathParam("id") String id) {
55 ObjectNode node = mapper().createObjectNode().put("hello", "world");
56 return ok(node).build();
57 }
58
59 /**
60 * Update subscriber object.
61 *
62 * @param id
63 * ID of the subscriber
64 *
65 * @return 200 OK
66 */
67 @PUT
68 @Path("/subscriber/{id}")
69 @Consumes(MediaType.APPLICATION_JSON)
70 public Response putSubscriber(@PathParam("id") String id) {
71 return Response.ok().build();
72 }
73
74 /**
75 * Create subscriber object.
76 *
77 * @return 201 Created
78 */
79 @POST
80 @Path("/subscriber")
81 @Consumes(MediaType.APPLICATION_JSON)
82 public Response postSubscriber() {
83 try {
84 return Response.created(new URI("/subsciber/123")).build();
85 } catch (URISyntaxException e) {
86 return Response.serverError().build();
87 }
88 }
89
90 /**
91 * Delete subscriber object.
92 *
93 * @param id
94 * ID of the subscriber
95 * @return 204 NoContent
96 */
97 @DELETE
98 @Path("/subscriber/{id}")
99 public Response deleteSubscriber(@PathParam("id") String id) {
100 return Response.noContent().build();
101 }
102}