blob: ab3f3116c6f306d0413f39f44cea24c75bbb4978 [file] [log] [blame]
Thomas Vachuskaf7582552015-05-14 10:13:46 -07001/*
2 * Copyright 2015 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 */
16
17package org.onosproject.cord.gui;
18
19import javax.ws.rs.GET;
20import javax.ws.rs.Path;
Simon Hunt3e59c602015-05-18 15:29:42 -070021import javax.ws.rs.PathParam;
22import javax.ws.rs.Produces;
23import javax.ws.rs.core.MediaType;
Thomas Vachuskaf7582552015-05-14 10:13:46 -070024import javax.ws.rs.core.Response;
25
26/**
27 * Web resource to use as the GUI back-end and as a proxy to XOS REST API.
28 */
29@Path("")
30public class CordWebResource {
31
Simon Hunta29c87b2015-05-21 09:56:19 -070032 @GET
33 @Produces(MediaType.APPLICATION_JSON)
34 @Path("dashboard")
35 public Response dashboard() {
Simon Hunt09a32db2015-05-21 15:00:42 -070036 return Response.ok(CordModelCache.INSTANCE.jsonDashboard()).build();
Simon Hunta29c87b2015-05-21 09:56:19 -070037 }
38
Simon Hunt09a32db2015-05-21 15:00:42 -070039 @GET
40 @Produces(MediaType.APPLICATION_JSON)
41 @Path("bundle")
42 public Response bundle() {
43 return Response.ok(CordModelCache.INSTANCE.jsonBundle()).build();
44 }
45
46 @GET
47 @Produces(MediaType.APPLICATION_JSON)
48 @Path("users")
49 public Response users() {
50 return Response.ok(CordModelCache.INSTANCE.jsonUsers()).build();
51 }
52
53 // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
54
55 @GET
56 @Produces(MediaType.APPLICATION_JSON)
Simon Huntc686c6a2015-06-05 14:33:30 -070057 @Path("login/{email}")
58 public Response login(@PathParam("email") String email) {
59 return Response.ok(CordModelCache.INSTANCE.jsonLogin(email)).build();
60 }
61
62 @GET
63 @Produces(MediaType.APPLICATION_JSON)
Simon Hunt09a32db2015-05-21 15:00:42 -070064 @Path("bundle/{id}")
Simon Hunt09a32db2015-05-21 15:00:42 -070065 public Response bundle(@PathParam("id") String bundleId) {
66 CordModelCache.INSTANCE.setCurrentBundle(bundleId);
67 return bundle();
68 }
Simon Hunt6c2555b2015-05-21 18:17:56 -070069
70 @GET
71 @Produces(MediaType.APPLICATION_JSON)
72 @Path("users/{id}/apply/{func}/{param}/{value}")
73 public Response bundle(@PathParam("id") String userId,
74 @PathParam("func") String funcId,
75 @PathParam("param") String param,
76 @PathParam("value") String value) {
77 CordModelCache.INSTANCE.applyPerUserParam(userId, funcId, param, value);
78 return users();
79 }
Thomas Vachuskaf7582552015-05-14 10:13:46 -070080}