blob: 2f13ee621b953027f6f39e097fa72dec2e84e68e [file] [log] [blame]
David K. Bainbridgeeda2b052017-07-12 09:41:04 -07001/*
Brian O'Connor180c1092017-08-03 22:46:14 -07002 * Copyright 2017-present Open Networking Foundation
David K. Bainbridgeeda2b052017-07-12 09:41:04 -07003 *
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 */
Amit Ghoshc29c7a92017-08-01 09:59:13 +010016package org.opencord.sadis.rest;
David K. Bainbridgeeda2b052017-07-12 09:41:04 -070017
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
David K. Bainbridgeeda2b052017-07-12 09:41:04 -070035/**
36 * Subscriber And Device Information Service web resource.
37 */
38@Path("sadis")
39public class AppWebResource extends AbstractWebResource {
40
41 /**
42 * Get subscriber object.
43 *
44 * @param id
45 * ID of the subscriber
46 *
47 * @return 200 OK
48 */
49 @GET
50 @Path("/subscriber/{id}")
51 @Produces(MediaType.APPLICATION_JSON)
52 public Response getSubscriber(@PathParam("id") String id) {
53 ObjectNode node = mapper().createObjectNode().put("hello", "world");
54 return ok(node).build();
55 }
56
57 /**
58 * Update subscriber object.
59 *
60 * @param id
61 * ID of the subscriber
62 *
63 * @return 200 OK
64 */
65 @PUT
66 @Path("/subscriber/{id}")
67 @Consumes(MediaType.APPLICATION_JSON)
68 public Response putSubscriber(@PathParam("id") String id) {
69 return Response.ok().build();
70 }
71
72 /**
73 * Create subscriber object.
74 *
75 * @return 201 Created
76 */
77 @POST
78 @Path("/subscriber")
79 @Consumes(MediaType.APPLICATION_JSON)
80 public Response postSubscriber() {
81 try {
82 return Response.created(new URI("/subsciber/123")).build();
83 } catch (URISyntaxException e) {
84 return Response.serverError().build();
85 }
86 }
87
88 /**
89 * Delete subscriber object.
90 *
91 * @param id
92 * ID of the subscriber
93 * @return 204 NoContent
94 */
95 @DELETE
96 @Path("/subscriber/{id}")
97 public Response deleteSubscriber(@PathParam("id") String id) {
98 return Response.noContent().build();
99 }
100}