Hyunsun Moon | 9274aaf | 2015-12-04 11:35:25 -0800 | [diff] [blame] | 1 | /* |
| 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 | package org.onosproject.cordvtn.rest; |
| 17 | |
Hyunsun Moon | 97eaf50 | 2015-12-07 14:06:28 -0800 | [diff] [blame] | 18 | import org.onosproject.cordvtn.CordVtnService; |
| 19 | import org.onosproject.cordvtn.CordServiceId; |
Hyunsun Moon | 9274aaf | 2015-12-04 11:35:25 -0800 | [diff] [blame] | 20 | import org.onosproject.rest.AbstractWebResource; |
| 21 | |
Hyunsun Moon | 97eaf50 | 2015-12-07 14:06:28 -0800 | [diff] [blame] | 22 | import javax.ws.rs.Consumes; |
| 23 | import javax.ws.rs.DELETE; |
| 24 | import javax.ws.rs.POST; |
| 25 | import javax.ws.rs.PUT; |
Hyunsun Moon | 9274aaf | 2015-12-04 11:35:25 -0800 | [diff] [blame] | 26 | import javax.ws.rs.Path; |
Hyunsun Moon | 97eaf50 | 2015-12-07 14:06:28 -0800 | [diff] [blame] | 27 | import javax.ws.rs.PathParam; |
| 28 | import javax.ws.rs.Produces; |
| 29 | import javax.ws.rs.core.MediaType; |
| 30 | import javax.ws.rs.core.Response; |
| 31 | import java.io.InputStream; |
Hyunsun Moon | 9274aaf | 2015-12-04 11:35:25 -0800 | [diff] [blame] | 32 | |
| 33 | /** |
| 34 | * Manages service dependency. |
| 35 | */ |
| 36 | @Path("service-dependency") |
| 37 | public class ServiceDependencyWebResource extends AbstractWebResource { |
Hyunsun Moon | 97eaf50 | 2015-12-07 14:06:28 -0800 | [diff] [blame] | 38 | |
| 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 Moon | ba29007 | 2015-12-16 20:53:23 -0800 | [diff] [blame] | 61 | * @param tServiceId tenant service id |
| 62 | * @param pServiceId provider service id |
Hyunsun Moon | 97eaf50 | 2015-12-07 14:06:28 -0800 | [diff] [blame] | 63 | * @return 200 OK, or 400 Bad Request |
| 64 | */ |
| 65 | @DELETE |
Hyunsun Moon | ba29007 | 2015-12-16 20:53:23 -0800 | [diff] [blame] | 66 | @Path("{tenantServiceId}/{providerServiceId}") |
Hyunsun Moon | 97eaf50 | 2015-12-07 14:06:28 -0800 | [diff] [blame] | 67 | @Produces(MediaType.APPLICATION_JSON) |
Hyunsun Moon | ba29007 | 2015-12-16 20:53:23 -0800 | [diff] [blame] | 68 | public Response removeServiceDependency(@PathParam("tenantServiceId") String tServiceId, |
| 69 | @PathParam("providerServiceId") String pServiceId) { |
| 70 | service.removeServiceDependency(CordServiceId.of(tServiceId), CordServiceId.of(pServiceId)); |
Hyunsun Moon | 97eaf50 | 2015-12-07 14:06:28 -0800 | [diff] [blame] | 71 | 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 Moon | 9274aaf | 2015-12-04 11:35:25 -0800 | [diff] [blame] | 90 | } |