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;
25 import org.eclipse.jetty.http.HttpStatus;
26 import org.onap.aai.esr.entity.rest.EmsRegisterInfo;
27 import org.onap.aai.esr.util.ExtsysUtil;
28 import org.onap.aai.esr.util.RestResponseUtil;
29 import org.onap.aai.esr.wrapper.EmsManagerWrapper;
30 import org.slf4j.Logger;
31 import org.slf4j.LoggerFactory;
33 import javax.ws.rs.Consumes;
34 import javax.ws.rs.DELETE;
35 import javax.ws.rs.GET;
36 import javax.ws.rs.POST;
37 import javax.ws.rs.PUT;
38 import javax.ws.rs.Path;
39 import javax.ws.rs.PathParam;
40 import javax.ws.rs.Produces;
41 import javax.ws.rs.core.MediaType;
42 import javax.ws.rs.core.Response;
45 @Api(tags = {" ems Management "})
46 public class EmsManager {
48 private static final Logger LOGGER = LoggerFactory.getLogger(EmsManager.class);
54 @ApiOperation(value = "get all ems ")
55 @Produces(MediaType.APPLICATION_JSON)
56 @ApiResponses(value = {
57 @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "microservice not found",
58 response = String.class),
59 @ApiResponse(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE_415,
60 message = "Unprocessable MicroServiceInfo Entity ", response = String.class),
61 @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "internal server error",
62 response = String.class)})
64 public Response queryEmsList() {
65 LOGGER.info("start query all ems!");
66 return EmsManagerWrapper.getInstance().queryEmsList();
70 * query ems info by id.
74 @ApiOperation(value = "get ems by id")
75 @Produces(MediaType.APPLICATION_JSON)
76 @ApiResponses(value = {
77 @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "microservice not found",
78 response = String.class),
79 @ApiResponse(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE_415,
80 message = "Unprocessable MicroServiceInfo Entity ", response = String.class),
81 @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "internal server error",
82 response = String.class)})
84 public Response queryemsById(@ApiParam(value = "ems id") @PathParam("emsId") String emsId) {
85 LOGGER.info("start query ems by id." + emsId);
86 return EmsManagerWrapper.getInstance().queryEmsById(emsId);
94 @ApiOperation(value = "delete a ems")
95 @ApiResponses(value = {
96 @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "microservice not found",
97 response = String.class),
98 @ApiResponse(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE_415,
99 message = "Unprocessable MicroServiceInfo Entity ", response = String.class),
100 @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "internal server error",
101 response = String.class)})
103 public Response delems(@ApiParam(value = "ems id") @PathParam("emsId") String emsId) {
104 LOGGER.info("start delete ems .id:" + emsId);
105 return EmsManagerWrapper.getInstance().delEms(emsId);
113 @Consumes(MediaType.APPLICATION_JSON)
114 @Produces({MediaType.TEXT_PLAIN, MediaType.APPLICATION_JSON})
115 @ApiOperation(value = "update a ems")
116 @ApiResponses(value = {
117 @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "microservice not found",
118 response = String.class),
119 @ApiResponse(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE_415,
120 message = "Unprocessable MicroServiceInfo Entity ", response = String.class),
121 @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "internal server error",
122 response = String.class)})
124 public Response updateEms(@ApiParam(value = "ems", required = true) EmsRegisterInfo ems,
125 @ApiParam(value = "ems id", required = true) @PathParam("emsId") String emsId) {
126 LOGGER.info("start update ems .id:" + emsId + " info:" + ExtsysUtil.objectToString(ems));
127 return RestResponseUtil.getSuccessResponse(new EmsRegisterInfo());
135 @Consumes(MediaType.APPLICATION_JSON)
136 @Produces({MediaType.TEXT_PLAIN, MediaType.APPLICATION_JSON})
137 @ApiOperation(value = "create a ems")
138 @ApiResponses(value = {
139 @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "microservice not found",
140 response = String.class),
141 @ApiResponse(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE_415,
142 message = "Unprocessable MicroServiceInfo Entity ", response = String.class),
143 @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "internal server error",
144 response = String.class)})
146 public Response registerEms(@ApiParam(value = "ems", required = true) EmsRegisterInfo ems) {
147 LOGGER.info("start add ems" + " info:" + ExtsysUtil.objectToString(ems));
148 return EmsManagerWrapper.getInstance().registerEms(ems);