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 io.swagger.annotations.SwaggerDefinition;
26 import org.eclipse.jetty.http.HttpStatus;
27 import org.onap.aai.esr.entity.rest.ThirdpartySdncRegisterInfo;
28 import org.onap.aai.esr.util.ExtsysUtil;
29 import org.onap.aai.esr.wrapper.ThirdpartySdncWrapper;
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 @Path("/sdncontrollers")
46 @Api(tags = {"ThirdParty sdnc Management "})
47 public class ThirdpartySdncManager {
49 private static final Logger LOGGER = LoggerFactory.getLogger(ThirdpartySdncManager.class);
51 private static ExtsysUtil extsysUtil = new ExtsysUtil();
53 *query all thirdParty sdnc.
56 @ApiOperation(value = "get all thirdParty sdnc ")
57 @Produces(MediaType.APPLICATION_JSON)
58 @ApiResponses(value = {
59 @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "microservice not found",
60 response = String.class),
61 @ApiResponse(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE_415,
62 message = "Unprocessable MicroServiceInfo Entity ", response = String.class),
63 @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "internal server error",
64 response = String.class)})
66 public Response queryThirdpartySdncList() {
67 LOGGER.info("start query all thirdParty sdnc!");
68 return ThirdpartySdncWrapper.getInstance().queryThirdpartySdncList();
72 *query thirdParty sdnc by id.
74 @Path("/{thirdPartySdncId}")
76 @ApiOperation(value = "get thirdParty sdnc by id")
77 @Produces(MediaType.APPLICATION_JSON)
78 @ApiResponses(value = {
79 @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "microservice not found",
80 response = String.class),
81 @ApiResponse(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE_415,
82 message = "Unprocessable MicroServiceInfo Entity ", response = String.class),
83 @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "internal server error",
84 response = String.class)})
86 public Response queryThirdpartySdncById(@ApiParam(value = "thirdparty sdnc id") @PathParam("thirdPartySdncId") String thirdPartySdncId) {
87 LOGGER.info("start query thirdparty sdnc by id." + thirdPartySdncId);
88 return ThirdpartySdncWrapper.getInstance().queryThirdpartySdncById(thirdPartySdncId);
92 *delete thirdparty sdnc by id.
94 @Path("/{thirdPartySdncId}")
96 @ApiOperation(value = "delete a thirdparty sdnc")
97 @ApiResponses(value = {
98 @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "microservice not found",
99 response = String.class),
100 @ApiResponse(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE_415,
101 message = "Unprocessable MicroServiceInfo Entity ", response = String.class),
102 @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "internal server error",
103 response = String.class)})
105 public Response delThirdpartySdnc(@ApiParam(value = "thirdparty sdnc id") @PathParam("thirdPartySdncId") String thirdPartySdncId) {
106 LOGGER.info("start delete thirdparty sdnc .id:" + thirdPartySdncId);
107 return ThirdpartySdncWrapper.getInstance().delThirdpartySdnc(thirdPartySdncId);
111 *update thirdParty sdnc by id.
114 @Path("/{thirdPartySdncId}")
115 @Consumes(MediaType.APPLICATION_JSON)
116 @Produces({MediaType.TEXT_PLAIN, MediaType.APPLICATION_JSON})
117 @ApiOperation(value = "update a thirdParty Sdnc")
118 @ApiResponses(value = {
119 @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "microservice not found",
120 response = String.class),
121 @ApiResponse(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE_415,
122 message = "Unprocessable MicroServiceInfo Entity ", response = String.class),
123 @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "internal server error",
124 response = String.class)})
126 public Response updateThirdpartySdnc(@ApiParam(value = "thirdpartySdnc", required = true) ThirdpartySdncRegisterInfo thirdPartySdnc,
127 @ApiParam(value = "sdnc id", required = true) @PathParam("thirdPartySdncId") String thirdPartySdncId) {
128 LOGGER.info("start update sdnc .id:" + thirdPartySdncId + " info:" + extsysUtil.objectToString(thirdPartySdnc));
129 return ThirdpartySdncWrapper.getInstance().updateThirdpartySdnc(thirdPartySdnc, thirdPartySdncId);
133 *thirdParty sdnc register.
136 @Consumes(MediaType.APPLICATION_JSON)
137 @Produces({MediaType.TEXT_PLAIN, MediaType.APPLICATION_JSON})
138 @ApiOperation(value = "register a thirdparty sdnc")
139 @ApiResponses(value = {
140 @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "microservice not found",
141 response = String.class),
142 @ApiResponse(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE_415,
143 message = "Unprocessable MicroServiceInfo Entity ", response = String.class),
144 @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "internal server error",
145 response = String.class)})
147 public Response registerThirdpatySdnc(@ApiParam(value = "thirdPartySdnc", required = true) ThirdpartySdncRegisterInfo thirdPartySdnc) {
148 LOGGER.info("start register sdnc" + " info:" + extsysUtil.objectToString(thirdPartySdnc));
149 return ThirdpartySdncWrapper.getInstance().registerThirdpartySdnc(thirdPartySdnc);