b5a1e30222d6924335b8fd5aac15f212cfb9f639
[aai/esr-server.git] / esr-core / 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
25 import org.eclipse.jetty.http.HttpStatus;
26 import org.onap.aai.esr.entity.rest.ThirdPartySdncRestData;
27 import org.onap.aai.esr.handle.SdncHandler;
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 @Path("/sdncontrollers")
45 @Api(tags = {"ThirdParty sdnc Management     "})
46 public class ThirdpatySdncManager {
47
48   SdncHandler handler = new SdncHandler();
49   private static final Logger LOGGER = LoggerFactory.getLogger(ThirdpatySdncManager.class);
50
51   /**
52    *query all thirdParty sdnc.
53    */
54   @Path("")
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) ThirdPartySdncRestData 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);
130   }
131   
132   /**
133    *thirdParty sdnc register.
134    */
135   @POST
136   @Path("")
137   @Consumes(MediaType.APPLICATION_JSON)
138   @Produces({MediaType.TEXT_PLAIN, MediaType.APPLICATION_JSON})
139   @ApiOperation(value = "register a thirdparty sdnc")
140   @ApiResponses(value = {
141       @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "microservice not found",
142           response = String.class),
143       @ApiResponse(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE_415,
144           message = "Unprocessable MicroServiceInfo Entity ", response = String.class),
145       @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "internal server error",
146           response = String.class)})
147   @Timed
148   public Response registerThirdpatySdnc(@ApiParam(value = "thirdPartySdnc", required = true) ThirdPartySdncRestData thirdPartySdnc) {
149     LOGGER.info("start register sdnc" + " info:" + ExtsysUtil.objectToString(thirdPartySdnc));
150     return ThirdpatySdncWrapper.getInstance().registerThirdpartySdnc(thirdPartySdnc);
151   }
152 }