blob: 7fc4afe6b0fd3aeceac82478ded973d0fc8638a4 [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)
Simon Huntc296d2c2015-06-08 12:54:57 -070034 @Path("login/{email}")
35 public Response login(@PathParam("email") String email) {
36 return Response.ok(CordModelCache.INSTANCE.jsonLogin(email)).build();
37 }
38
39 @GET
40 @Produces(MediaType.APPLICATION_JSON)
Simon Hunta29c87b2015-05-21 09:56:19 -070041 @Path("dashboard")
42 public Response dashboard() {
Simon Hunt09a32db2015-05-21 15:00:42 -070043 return Response.ok(CordModelCache.INSTANCE.jsonDashboard()).build();
Simon Hunta29c87b2015-05-21 09:56:19 -070044 }
45
Simon Hunt09a32db2015-05-21 15:00:42 -070046 @GET
47 @Produces(MediaType.APPLICATION_JSON)
48 @Path("bundle")
49 public Response bundle() {
50 return Response.ok(CordModelCache.INSTANCE.jsonBundle()).build();
51 }
52
53 @GET
54 @Produces(MediaType.APPLICATION_JSON)
55 @Path("users")
56 public Response users() {
57 return Response.ok(CordModelCache.INSTANCE.jsonUsers()).build();
58 }
59
Simon Hunt09a32db2015-05-21 15:00:42 -070060 @GET
61 @Produces(MediaType.APPLICATION_JSON)
Simon Huntc296d2c2015-06-08 12:54:57 -070062 @Path("logout")
63 public Response logout() {
64 return Response.ok(CordModelCache.INSTANCE.jsonLogout()).build();
Simon Huntc686c6a2015-06-05 14:33:30 -070065 }
66
Simon Huntc296d2c2015-06-08 12:54:57 -070067 // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
68
Simon Huntc686c6a2015-06-05 14:33:30 -070069 @GET
70 @Produces(MediaType.APPLICATION_JSON)
Simon Hunt09a32db2015-05-21 15:00:42 -070071 @Path("bundle/{id}")
Simon Hunt09a32db2015-05-21 15:00:42 -070072 public Response bundle(@PathParam("id") String bundleId) {
73 CordModelCache.INSTANCE.setCurrentBundle(bundleId);
74 return bundle();
75 }
Simon Hunt6c2555b2015-05-21 18:17:56 -070076
77 @GET
78 @Produces(MediaType.APPLICATION_JSON)
79 @Path("users/{id}/apply/{func}/{param}/{value}")
80 public Response bundle(@PathParam("id") String userId,
81 @PathParam("func") String funcId,
82 @PathParam("param") String param,
83 @PathParam("value") String value) {
84 CordModelCache.INSTANCE.applyPerUserParam(userId, funcId, param, value);
85 return users();
86 }
Thomas Vachuskaf7582552015-05-14 10:13:46 -070087}