2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Modifications Copyright (C) 2018 IBM.
8 * Modifications Copyright (c) 2019 Samsung
9 * ================================================================================
10 * Licensed under the Apache License, Version 2.0 (the "License");
11 * you may not use this file except in compliance with the License.
12 * You may obtain a copy of the License at
14 * http://www.apache.org/licenses/LICENSE-2.0
16 * Unless required by applicable law or agreed to in writing, software
17 * distributed under the License is distributed on an "AS IS" BASIS,
18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 * See the License for the specific language governing permissions and
20 * limitations under the License.
21 * ============LICENSE_END=========================================================
24 package org.onap.so.adapters.cloudregion;
27 import javax.ws.rs.Consumes;
28 import javax.ws.rs.DELETE;
29 import javax.ws.rs.POST;
30 import javax.ws.rs.PUT;
31 import javax.ws.rs.Path;
32 import javax.ws.rs.PathParam;
33 import javax.ws.rs.Produces;
34 import javax.ws.rs.core.MediaType;
35 import javax.ws.rs.core.Response;
36 import org.apache.http.HttpStatus;
37 import org.onap.so.db.catalog.beans.CloudSite;
38 import org.slf4j.Logger;
39 import org.slf4j.LoggerFactory;
40 import org.springframework.beans.factory.annotation.Autowired;
41 import org.springframework.stereotype.Component;
42 import io.swagger.annotations.Api;
43 import io.swagger.annotations.ApiOperation;
44 import io.swagger.annotations.ApiParam;
45 import io.swagger.annotations.ApiResponse;
46 import io.swagger.annotations.ApiResponses;
49 @Path("/v1/cloud-region")
50 @Api(value = "/v1/cloud-region", description = "root of cloud region adapter")
52 public class CloudRegionRestV1 {
53 private static Logger logger = LoggerFactory.getLogger(CloudRegionRestV1.class);
56 private CloudRestImpl cloudRestImpl;
59 @Consumes({MediaType.APPLICATION_JSON})
60 @Produces({MediaType.APPLICATION_JSON})
61 @ApiOperation(value = "CreateCloudRegion", response = Response.class,
62 notes = "Create a cloud site in MSO and Region In AAI")
63 @ApiResponses({@ApiResponse(code = 201, message = "Cloud Region has been created"),
64 @ApiResponse(code = 500, message = "Create Cloud Region has failed")})
65 public Response createCloudRegion(
66 @ApiParam(value = "cloud-region-id", required = true) @PathParam("cloud-region-id") String cloudRegionId,
67 @ApiParam(value = "CloudSite", required = true) final CloudSite cloudSite) {
68 cloudRestImpl.createCloudRegion(cloudSite);
69 return Response.status(HttpStatus.SC_CREATED).build();
73 @Path("{cloud-region-id}/{cloud-owner}")
74 @Consumes({MediaType.APPLICATION_JSON})
75 @Produces({MediaType.APPLICATION_JSON})
76 @ApiOperation(value = "CreateCloudRegion", response = Response.class, notes = "Delete an cloud Region in SO")
77 @ApiResponses({@ApiResponse(code = 204, message = "cloud Region has been deleted"),
78 @ApiResponse(code = 500, message = "Cloud Region delete has failed")})
79 public Response deleteCloudRegion(
80 @ApiParam(value = "cloud-region-id", required = true) @PathParam("cloud-region-id") String cloudRegionId,
81 @ApiParam(value = "cloud-owner", required = true) @PathParam("cloud-owner") String cloudOwner) {
82 cloudRestImpl.deleteCloudRegion(cloudRegionId);
83 return Response.status(HttpStatus.SC_NO_CONTENT).build();
87 @Path("{cloud-region-id}/{cloud-owner}")
88 @Consumes({MediaType.APPLICATION_JSON})
89 @Produces({MediaType.APPLICATION_JSON})
90 @ApiOperation(value = "CreateCloudRegion", response = Response.class, notes = "Update an existing Cloud Region")
91 @ApiResponses({@ApiResponse(code = 200, message = "Cloud Region has been updated"),
92 @ApiResponse(code = 500, message = "Update Cloud Region has failed examine entity object for details")})
93 public Response updateCloudRegion(
94 @ApiParam(value = "cloud-region-id", required = true) @PathParam("cloud-region-id") String cloudRegionId,
95 @ApiParam(value = "cloud-owner", required = true) @PathParam("cloud-owner") String cloudOwner,
96 @ApiParam(value = "CloudSite", required = true) final CloudSite cloudSite) {
97 cloudRestImpl.updateCloudRegion(cloudSite);
98 return Response.status(HttpStatus.SC_OK).build();