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.ThirdpartySdncRegisterInfo;
27 import org.onap.aai.esr.util.ExtsysUtil;
28 import org.onap.aai.esr.wrapper.ThirdpatySdncWrapper;
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;
43 @Path("/sdncontrollers")
44 @Api(tags = {"ThirdParty sdnc Management "})
45 public class ThirdpatySdncManager {
47 private static final Logger LOGGER = LoggerFactory.getLogger(ThirdpatySdncManager.class);
49 private static ExtsysUtil extsysUtil = new ExtsysUtil();
51 *query all thirdParty sdnc.
54 @ApiOperation(value = "get all thirdParty sdnc ")
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 queryThirdpartySdncList() {
65 LOGGER.info("start query all thirdParty sdnc!");
66 return ThirdpatySdncWrapper.getInstance().queryThirdpartySdncList();
70 *query thirdParty sdnc by id.
72 @Path("/{thirdPartySdncId}")
74 @ApiOperation(value = "get thirdParty sdnc 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 queryThirdpartySdncById(@ApiParam(value = "thirdparty sdnc id") @PathParam("thirdPartySdncId") String thirdPartySdncId) {
85 LOGGER.info("start query thirdparty sdnc by id." + thirdPartySdncId);
86 return ThirdpatySdncWrapper.getInstance().queryThirdpartySdncById(thirdPartySdncId);
90 *delete thirdparty sdnc by id.
92 @Path("/{thirdPartySdncId}")
94 @ApiOperation(value = "delete a thirdparty sdnc")
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 delThirdpartySdnc(@ApiParam(value = "thirdparty sdnc id") @PathParam("thirdPartySdncId") String thirdPartySdncId) {
104 LOGGER.info("start delete thirdparty sdnc .id:" + thirdPartySdncId);
105 return ThirdpatySdncWrapper.getInstance().delThirdpartySdnc(thirdPartySdncId);
109 *update thirdParty sdnc by id.
112 @Path("/{thirdPartySdncId}")
113 @Consumes(MediaType.APPLICATION_JSON)
114 @Produces({MediaType.TEXT_PLAIN, MediaType.APPLICATION_JSON})
115 @ApiOperation(value = "update a thirdParty Sdnc")
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 updateThirdpartySdnc(@ApiParam(value = "thirdpartySdnc", required = true) ThirdpartySdncRegisterInfo thirdPartySdnc,
125 @ApiParam(value = "sdnc id", required = true) @PathParam("thirdPartySdncId") String thirdPartySdncId) {
126 LOGGER.info("start update sdnc .id:" + thirdPartySdncId + " info:" + extsysUtil.objectToString(thirdPartySdnc));
127 return ThirdpatySdncWrapper.getInstance().updateThirdpartySdnc(thirdPartySdnc, thirdPartySdncId);
131 *thirdParty sdnc register.
134 @Consumes(MediaType.APPLICATION_JSON)
135 @Produces({MediaType.TEXT_PLAIN, MediaType.APPLICATION_JSON})
136 @ApiOperation(value = "register a thirdparty sdnc")
137 @ApiResponses(value = {
138 @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "microservice not found",
139 response = String.class),
140 @ApiResponse(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE_415,
141 message = "Unprocessable MicroServiceInfo Entity ", response = String.class),
142 @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "internal server error",
143 response = String.class)})
145 public Response registerThirdpatySdnc(@ApiParam(value = "thirdPartySdnc", required = true) ThirdpartySdncRegisterInfo thirdPartySdnc) {
146 LOGGER.info("start register sdnc" + " info:" + extsysUtil.objectToString(thirdPartySdnc));
147 return ThirdpatySdncWrapper.getInstance().registerThirdpartySdnc(thirdPartySdnc);