blob: c5d1ded478294088b7e8f6006f843b74721333fe [file] [log] [blame]
Hyunsun Moon9274aaf2015-12-04 11:35:25 -08001/*
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 */
16package org.onosproject.cordvtn.rest;
17
Hyunsun Moon97eaf502015-12-07 14:06:28 -080018import org.onosproject.cordvtn.CordVtnService;
19import org.onosproject.cordvtn.CordServiceId;
Hyunsun Moon9274aaf2015-12-04 11:35:25 -080020import org.onosproject.rest.AbstractWebResource;
21
Hyunsun Moon97eaf502015-12-07 14:06:28 -080022import javax.ws.rs.Consumes;
23import javax.ws.rs.DELETE;
24import javax.ws.rs.POST;
25import javax.ws.rs.PUT;
Hyunsun Moon9274aaf2015-12-04 11:35:25 -080026import javax.ws.rs.Path;
Hyunsun Moon97eaf502015-12-07 14:06:28 -080027import javax.ws.rs.PathParam;
28import javax.ws.rs.Produces;
29import javax.ws.rs.core.MediaType;
30import javax.ws.rs.core.Response;
31import java.io.InputStream;
Hyunsun Moon9274aaf2015-12-04 11:35:25 -080032
33/**
34 * Manages service dependency.
35 */
36@Path("service-dependency")
37public class ServiceDependencyWebResource extends AbstractWebResource {
Hyunsun Moon97eaf502015-12-07 14:06:28 -080038
39 private final CordVtnService service = get(CordVtnService.class);
40
41 /**
42 * Creates service dependencies.
43 *
44 * @param tServiceId tenant service id
45 * @param pServiceId provider service id
46 * @return 200 OK
47 */
48 @POST
49 @Path("{tenantServiceId}/{providerServiceId}")
50 @Produces(MediaType.APPLICATION_JSON)
51 @Consumes(MediaType.APPLICATION_JSON)
52 public Response createServiceDependency(@PathParam("tenantServiceId") String tServiceId,
53 @PathParam("providerServiceId") String pServiceId) {
54 service.createServiceDependency(CordServiceId.of(tServiceId), CordServiceId.of(pServiceId));
55 return Response.status(Response.Status.OK).build();
56 }
57
58 /**
59 * Removes service dependencies.
60 *
Hyunsun Moonba290072015-12-16 20:53:23 -080061 * @param tServiceId tenant service id
62 * @param pServiceId provider service id
Hyunsun Moon97eaf502015-12-07 14:06:28 -080063 * @return 200 OK, or 400 Bad Request
64 */
65 @DELETE
Hyunsun Moonba290072015-12-16 20:53:23 -080066 @Path("{tenantServiceId}/{providerServiceId}")
Hyunsun Moon97eaf502015-12-07 14:06:28 -080067 @Produces(MediaType.APPLICATION_JSON)
Hyunsun Moonba290072015-12-16 20:53:23 -080068 public Response removeServiceDependency(@PathParam("tenantServiceId") String tServiceId,
69 @PathParam("providerServiceId") String pServiceId) {
70 service.removeServiceDependency(CordServiceId.of(tServiceId), CordServiceId.of(pServiceId));
Hyunsun Moon97eaf502015-12-07 14:06:28 -080071 return Response.status(Response.Status.OK).build();
72 }
73
74 /**
75 * Updates service dependencies.
76 *
77 * @param serviceId service id
78 * @param stream input JSON
79 * @return 200 OK, or 400 Bad Request
80 */
81 @PUT
82 @Path("{serviceId}")
83 @Produces(MediaType.APPLICATION_JSON)
84 @Consumes(MediaType.APPLICATION_JSON)
85 public Response updateServiceDependency(@PathParam("serviceId") String serviceId,
86 InputStream stream) {
87 // TODO define input stream
88 return Response.status(Response.Status.OK).build();
89 }
Hyunsun Moon9274aaf2015-12-04 11:35:25 -080090}