Add swagger.json to main/resources.
[aai/esr-server.git] / esr-mgr / src / main / java / org / onap / aai / esr / resource / ThirdpatySdncManager.java
1 /**
2  * Copyright 2016-2017 ZTE Corporation.
3  *
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
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16 package org.onap.aai.esr.resource;
17
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;
25
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.ThirdpatySdncWrapper;
30 import org.slf4j.Logger;
31 import org.slf4j.LoggerFactory;
32
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;
43
44 @SwaggerDefinition
45 @Path("/sdncontrollers")
46 @Api(tags = {"ThirdParty sdnc Management     "})
47 public class ThirdpatySdncManager {
48
49   private static final Logger LOGGER = LoggerFactory.getLogger(ThirdpatySdncManager.class);
50
51   private static ExtsysUtil extsysUtil = new ExtsysUtil();
52   /**
53    *query all thirdParty sdnc.
54    */
55   @GET
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)})
65   @Timed
66   public Response queryThirdpartySdncList() {
67     LOGGER.info("start query all thirdParty sdnc!");
68     return ThirdpatySdncWrapper.getInstance().queryThirdpartySdncList();
69   }
70   
71   /**
72    *query thirdParty sdnc by id.
73    */
74   @Path("/{thirdPartySdncId}")
75   @GET
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)})
85   @Timed
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 ThirdpatySdncWrapper.getInstance().queryThirdpartySdncById(thirdPartySdncId);
89   }
90   
91   /**
92    *delete thirdparty sdnc by id.
93    */
94   @Path("/{thirdPartySdncId}")
95   @DELETE
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)})
104   @Timed
105   public Response delThirdpartySdnc(@ApiParam(value = "thirdparty sdnc id") @PathParam("thirdPartySdncId") String thirdPartySdncId) {
106     LOGGER.info("start delete thirdparty sdnc .id:" + thirdPartySdncId);
107     return ThirdpatySdncWrapper.getInstance().delThirdpartySdnc(thirdPartySdncId);
108   }
109   
110   /**
111    *update thirdParty sdnc by id.
112    */
113   @PUT
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)})
125   @Timed
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 ThirdpatySdncWrapper.getInstance().updateThirdpartySdnc(thirdPartySdnc, thirdPartySdncId);
130   }
131   
132   /**
133    *thirdParty sdnc register.
134    */
135   @POST
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)})
146   @Timed
147   public Response registerThirdpatySdnc(@ApiParam(value = "thirdPartySdnc", required = true) ThirdpartySdncRegisterInfo thirdPartySdnc) {
148     LOGGER.info("start register sdnc" + " info:" + extsysUtil.objectToString(thirdPartySdnc));
149     return ThirdpatySdncWrapper.getInstance().registerThirdpartySdnc(thirdPartySdnc);
150   }
151 }