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.wrapper.EmsManagerWrapper;
29 import org.slf4j.Logger;
30 import org.slf4j.LoggerFactory;
32 import javax.ws.rs.Consumes;
33 import javax.ws.rs.DELETE;
34 import javax.ws.rs.GET;
35 import javax.ws.rs.POST;
36 import javax.ws.rs.PUT;
37 import javax.ws.rs.Path;
38 import javax.ws.rs.PathParam;
39 import javax.ws.rs.Produces;
40 import javax.ws.rs.core.MediaType;
41 import javax.ws.rs.core.Response;
44 @Api(tags = {" ems Management "})
45 public class EmsManager {
47 private static final Logger LOGGER = LoggerFactory.getLogger(EmsManager.class);
53 @ApiOperation(value = "get all ems ")
54 @Produces(MediaType.APPLICATION_JSON)
55 @ApiResponses(value = {
56 @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "microservice not found",
57 response = String.class),
58 @ApiResponse(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE_415,
59 message = "Unprocessable MicroServiceInfo Entity ", response = String.class),
60 @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "internal server error",
61 response = String.class)})
63 public Response queryEmsList() {
64 LOGGER.info("start query all ems!");
65 return EmsManagerWrapper.getInstance().queryEmsList();
69 * query ems info by id.
73 @ApiOperation(value = "get ems by id")
74 @Produces(MediaType.APPLICATION_JSON)
75 @ApiResponses(value = {
76 @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "microservice not found",
77 response = String.class),
78 @ApiResponse(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE_415,
79 message = "Unprocessable MicroServiceInfo Entity ", response = String.class),
80 @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "internal server error",
81 response = String.class)})
83 public Response queryemsById(@ApiParam(value = "ems id") @PathParam("emsId") String emsId) {
84 LOGGER.info("start query ems by id." + emsId);
85 return EmsManagerWrapper.getInstance().queryEmsById(emsId);
93 @ApiOperation(value = "delete a ems")
94 @ApiResponses(value = {
95 @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "microservice not found",
96 response = String.class),
97 @ApiResponse(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE_415,
98 message = "Unprocessable MicroServiceInfo Entity ", response = String.class),
99 @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "internal server error",
100 response = String.class)})
102 public Response delems(@ApiParam(value = "ems id") @PathParam("emsId") String emsId) {
103 LOGGER.info("start delete ems .id:" + emsId);
104 return EmsManagerWrapper.getInstance().delEms(emsId);
112 @Consumes(MediaType.APPLICATION_JSON)
113 @Produces({MediaType.TEXT_PLAIN, MediaType.APPLICATION_JSON})
114 @ApiOperation(value = "update a ems")
115 @ApiResponses(value = {
116 @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "microservice not found",
117 response = String.class),
118 @ApiResponse(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE_415,
119 message = "Unprocessable MicroServiceInfo Entity ", response = String.class),
120 @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "internal server error",
121 response = String.class)})
123 public Response updateEms(@ApiParam(value = "ems", required = true) EmsRegisterInfo ems,
124 @ApiParam(value = "ems id", required = true) @PathParam("emsId") String emsId) {
125 LOGGER.info("start update ems .id:" + emsId + " info:" + ExtsysUtil.objectToString(ems));
126 return EmsManagerWrapper.getInstance().updateEms(ems, emsId);
133 @Consumes(MediaType.APPLICATION_JSON)
134 @Produces({MediaType.TEXT_PLAIN, MediaType.APPLICATION_JSON})
135 @ApiOperation(value = "create a ems")
136 @ApiResponses(value = {
137 @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "microservice not found",
138 response = String.class),
139 @ApiResponse(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE_415,
140 message = "Unprocessable MicroServiceInfo Entity ", response = String.class),
141 @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "internal server error",
142 response = String.class)})
144 public Response registerEms(@ApiParam(value = "ems", required = true) EmsRegisterInfo ems) {
145 LOGGER.info("start add ems" + " info:" + ExtsysUtil.objectToString(ems));
146 return EmsManagerWrapper.getInstance().registerEms(ems);