2 * Copyright 2016-2017 ZTE Corporation.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 package org.onap.aai.esr.resource;
18 import com.codahale.metrics.annotation.Timed;
19 import io.swagger.annotations.Api;
20 import io.swagger.annotations.ApiOperation;
21 import io.swagger.annotations.ApiParam;
22 import io.swagger.annotations.ApiResponse;
23 import io.swagger.annotations.ApiResponses;
24 import org.eclipse.jetty.http.HttpStatus;
25 import org.onap.aai.esr.entity.aai.VnfmData;
26 import org.onap.aai.esr.entity.rest.VnfmRestData;
27 import org.onap.aai.esr.exception.ExtsysException;
28 import org.onap.aai.esr.handle.VnfmHandler;
29 import org.onap.aai.esr.util.ExtsysDbUtil;
30 import org.onap.aai.esr.util.RestResponseUtil;
31 import org.onap.aai.esr.wrapper.VnfmManagerWrapper;
32 import org.slf4j.Logger;
33 import org.slf4j.LoggerFactory;
35 import java.util.ArrayList;
36 import java.util.List;
37 import javax.ws.rs.Consumes;
38 import javax.ws.rs.DELETE;
39 import javax.ws.rs.GET;
40 import javax.ws.rs.POST;
41 import javax.ws.rs.PUT;
42 import javax.ws.rs.Path;
43 import javax.ws.rs.PathParam;
44 import javax.ws.rs.Produces;
45 import javax.ws.rs.core.MediaType;
46 import javax.ws.rs.core.Response;
49 @Api(tags = {" vnfm Management "})
50 public class VnfmManager {
52 VnfmHandler handler = new VnfmHandler();
53 private static final Logger LOGGER = LoggerFactory.getLogger(VnfmManager.class);
60 @ApiOperation(value = "get all vnfm ")
61 @Produces(MediaType.APPLICATION_JSON)
62 @ApiResponses(value = {
63 @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "microservice not found",
64 response = String.class),
65 @ApiResponse(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE_415,
66 message = "Unprocessable MicroServiceInfo Entity ", response = String.class),
67 @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "internal server error",
68 response = String.class)})
70 public Response queryVnfmList() {
71 LOGGER.info("start query all vnfm!");
72 return VnfmManagerWrapper.getInstance().queryVnfmList();
80 @ApiOperation(value = "get vnfm by id")
81 @Produces(MediaType.APPLICATION_JSON)
82 @ApiResponses(value = {
83 @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "microservice not found",
84 response = String.class),
85 @ApiResponse(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE_415,
86 message = "Unprocessable MicroServiceInfo Entity ", response = String.class),
87 @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "internal server error",
88 response = String.class)})
90 public Response queryVnfmById(@ApiParam(value = "vnfm id") @PathParam("vnfmId") String vnfmId) {
91 LOGGER.info("start query vnfm by id." + vnfmId);
92 return VnfmManagerWrapper.getInstance().queryVnfmById(vnfmId);
100 @ApiOperation(value = "delete a vnfm")
101 @ApiResponses(value = {
102 @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "microservice not found",
103 response = String.class),
104 @ApiResponse(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE_415,
105 message = "Unprocessable MicroServiceInfo Entity ", response = String.class),
106 @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "internal server error",
107 response = String.class)})
109 public Response delVnfm(@ApiParam(value = "vnfm id") @PathParam("vnfmId") String vnfmId) {
110 LOGGER.info("start delete vnfm .id:" + vnfmId);
111 return VnfmManagerWrapper.getInstance().delVnfm(vnfmId);
119 @Consumes(MediaType.APPLICATION_JSON)
120 @Produces({MediaType.TEXT_PLAIN, MediaType.APPLICATION_JSON})
121 @ApiOperation(value = "update a vnfm")
122 @ApiResponses(value = {
123 @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "microservice not found",
124 response = String.class),
125 @ApiResponse(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE_415,
126 message = "Unprocessable MicroServiceInfo Entity ", response = String.class),
127 @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "internal server error",
128 response = String.class)})
130 public Response updateVnfm(@ApiParam(value = "vnfm", required = true) VnfmRestData vnfm,
131 @ApiParam(value = "vnfm id", required = true) @PathParam("vnfmId") String vnfmId) {
132 LOGGER.info("start update vnfm .id:" + vnfmId + " info:" + ExtsysDbUtil.objectToString(vnfm));
133 return VnfmManagerWrapper.getInstance().updateVnfm(vnfm, vnfmId);
141 @Consumes(MediaType.APPLICATION_JSON)
142 @Produces({MediaType.TEXT_PLAIN, MediaType.APPLICATION_JSON})
143 @ApiOperation(value = "create a vnfm")
144 @ApiResponses(value = {
145 @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "microservice not found",
146 response = String.class),
147 @ApiResponse(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE_415,
148 message = "Unprocessable MicroServiceInfo Entity ", response = String.class),
149 @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "internal server error",
150 response = String.class)})
152 public Response registerVnfm(@ApiParam(value = "vnfm", required = true) VnfmRestData vnfm) {
153 return VnfmManagerWrapper.getInstance().registerVnfm(vnfm);