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.rest.VnfmRegisterInfo;
26 import org.onap.aai.esr.util.ExtsysUtil;
27 import org.onap.aai.esr.wrapper.VnfmManagerWrapper;
28 import org.slf4j.Logger;
29 import org.slf4j.LoggerFactory;
31 import javax.ws.rs.Consumes;
32 import javax.ws.rs.DELETE;
33 import javax.ws.rs.GET;
34 import javax.ws.rs.POST;
35 import javax.ws.rs.PUT;
36 import javax.ws.rs.Path;
37 import javax.ws.rs.PathParam;
38 import javax.ws.rs.Produces;
39 import javax.ws.rs.core.MediaType;
40 import javax.ws.rs.core.Response;
43 @Api(tags = {" vnfm Management "})
44 public class VnfmManager {
46 private static final Logger LOGGER = LoggerFactory.getLogger(VnfmManager.class);
52 @ApiOperation(value = "get all vnfm ")
53 @Produces(MediaType.APPLICATION_JSON)
54 @ApiResponses(value = {
55 @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "microservice not found",
56 response = String.class),
57 @ApiResponse(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE_415,
58 message = "Unprocessable MicroServiceInfo Entity ", response = String.class),
59 @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "internal server error",
60 response = String.class)})
62 public Response queryVnfmList() {
63 LOGGER.info("start query all vnfm!");
64 return VnfmManagerWrapper.getInstance().queryVnfmList();
72 @ApiOperation(value = "get vnfm by id")
73 @Produces(MediaType.APPLICATION_JSON)
74 @ApiResponses(value = {
75 @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "microservice not found",
76 response = String.class),
77 @ApiResponse(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE_415,
78 message = "Unprocessable MicroServiceInfo Entity ", response = String.class),
79 @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "internal server error",
80 response = String.class)})
82 public Response queryVnfmById(@ApiParam(value = "vnfm id") @PathParam("vnfmId") String vnfmId) {
83 LOGGER.info("start query vnfm by id." + vnfmId);
84 return VnfmManagerWrapper.getInstance().queryVnfmById(vnfmId);
92 @ApiOperation(value = "delete a vnfm")
93 @ApiResponses(value = {
94 @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "microservice not found",
95 response = String.class),
96 @ApiResponse(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE_415,
97 message = "Unprocessable MicroServiceInfo Entity ", response = String.class),
98 @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "internal server error",
99 response = String.class)})
101 public Response delVnfm(@ApiParam(value = "vnfm id") @PathParam("vnfmId") String vnfmId) {
102 LOGGER.info("start delete vnfm .id:" + vnfmId);
103 return VnfmManagerWrapper.getInstance().delVnfm(vnfmId);
111 @Consumes(MediaType.APPLICATION_JSON)
112 @Produces({MediaType.TEXT_PLAIN, MediaType.APPLICATION_JSON})
113 @ApiOperation(value = "update a vnfm")
114 @ApiResponses(value = {
115 @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "microservice not found",
116 response = String.class),
117 @ApiResponse(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE_415,
118 message = "Unprocessable MicroServiceInfo Entity ", response = String.class),
119 @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "internal server error",
120 response = String.class)})
122 public Response updateVnfm(@ApiParam(value = "vnfm", required = true) VnfmRegisterInfo vnfm,
123 @ApiParam(value = "vnfm id", required = true) @PathParam("vnfmId") String vnfmId) {
124 LOGGER.info("start update vnfm .id:" + vnfmId + " info:" + ExtsysUtil.objectToString(vnfm));
125 return VnfmManagerWrapper.getInstance().updateVnfm(vnfm, vnfmId);
132 @Consumes(MediaType.APPLICATION_JSON)
133 @Produces({MediaType.TEXT_PLAIN, MediaType.APPLICATION_JSON})
134 @ApiOperation(value = "create a vnfm")
135 @ApiResponses(value = {
136 @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "microservice not found",
137 response = String.class),
138 @ApiResponse(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE_415,
139 message = "Unprocessable MicroServiceInfo Entity ", response = String.class),
140 @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "internal server error",
141 response = String.class)})
143 public Response registerVnfm(@ApiParam(value = "vnfm", required = true) VnfmRegisterInfo vnfm) {
144 return VnfmManagerWrapper.getInstance().registerVnfm(vnfm);