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.util.ExtsysUtil;
29 import org.onap.aai.esr.util.RestResponseUtil;
30 import org.onap.aai.esr.wrapper.VnfmManagerWrapper;
31 import org.slf4j.Logger;
32 import org.slf4j.LoggerFactory;
34 import java.util.ArrayList;
35 import java.util.List;
36 import javax.ws.rs.Consumes;
37 import javax.ws.rs.DELETE;
38 import javax.ws.rs.GET;
39 import javax.ws.rs.POST;
40 import javax.ws.rs.PUT;
41 import javax.ws.rs.Path;
42 import javax.ws.rs.PathParam;
43 import javax.ws.rs.Produces;
44 import javax.ws.rs.core.MediaType;
45 import javax.ws.rs.core.Response;
48 @Api(tags = {" vnfm Management "})
49 public class VnfmManager {
51 private static final Logger LOGGER = LoggerFactory.getLogger(VnfmManager.class);
58 @ApiOperation(value = "get all vnfm ")
59 @Produces(MediaType.APPLICATION_JSON)
60 @ApiResponses(value = {
61 @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "microservice not found",
62 response = String.class),
63 @ApiResponse(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE_415,
64 message = "Unprocessable MicroServiceInfo Entity ", response = String.class),
65 @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "internal server error",
66 response = String.class)})
68 public Response queryVnfmList() {
69 LOGGER.info("start query all vnfm!");
70 return VnfmManagerWrapper.getInstance().queryVnfmList();
78 @ApiOperation(value = "get vnfm by id")
79 @Produces(MediaType.APPLICATION_JSON)
80 @ApiResponses(value = {
81 @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "microservice not found",
82 response = String.class),
83 @ApiResponse(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE_415,
84 message = "Unprocessable MicroServiceInfo Entity ", response = String.class),
85 @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "internal server error",
86 response = String.class)})
88 public Response queryVnfmById(@ApiParam(value = "vnfm id") @PathParam("vnfmId") String vnfmId) {
89 LOGGER.info("start query vnfm by id." + vnfmId);
90 return VnfmManagerWrapper.getInstance().queryVnfmById(vnfmId);
98 @ApiOperation(value = "delete a vnfm")
99 @ApiResponses(value = {
100 @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "microservice not found",
101 response = String.class),
102 @ApiResponse(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE_415,
103 message = "Unprocessable MicroServiceInfo Entity ", response = String.class),
104 @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "internal server error",
105 response = String.class)})
107 public Response delVnfm(@ApiParam(value = "vnfm id") @PathParam("vnfmId") String vnfmId) {
108 LOGGER.info("start delete vnfm .id:" + vnfmId);
109 return VnfmManagerWrapper.getInstance().delVnfm(vnfmId);
117 @Consumes(MediaType.APPLICATION_JSON)
118 @Produces({MediaType.TEXT_PLAIN, MediaType.APPLICATION_JSON})
119 @ApiOperation(value = "update a vnfm")
120 @ApiResponses(value = {
121 @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "microservice not found",
122 response = String.class),
123 @ApiResponse(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE_415,
124 message = "Unprocessable MicroServiceInfo Entity ", response = String.class),
125 @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "internal server error",
126 response = String.class)})
128 public Response updateVnfm(@ApiParam(value = "vnfm", required = true) VnfmRestData vnfm,
129 @ApiParam(value = "vnfm id", required = true) @PathParam("vnfmId") String vnfmId) {
130 LOGGER.info("start update vnfm .id:" + vnfmId + " info:" + ExtsysUtil.objectToString(vnfm));
131 return VnfmManagerWrapper.getInstance().updateVnfm(vnfm, vnfmId);
139 @Consumes(MediaType.APPLICATION_JSON)
140 @Produces({MediaType.TEXT_PLAIN, MediaType.APPLICATION_JSON})
141 @ApiOperation(value = "create a vnfm")
142 @ApiResponses(value = {
143 @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "microservice not found",
144 response = String.class),
145 @ApiResponse(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE_415,
146 message = "Unprocessable MicroServiceInfo Entity ", response = String.class),
147 @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "internal server error",
148 response = String.class)})
150 public Response registerVnfm(@ApiParam(value = "vnfm", required = true) VnfmRestData vnfm) {
151 return VnfmManagerWrapper.getInstance().registerVnfm(vnfm);