summaryrefslogtreecommitdiffstats
path: root/participant
diff options
context:
space:
mode:
Diffstat (limited to 'participant')
-rw-r--r--participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/main/rest/AbstractRestController.java43
-rw-r--r--participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/main/rest/AcElementController.java157
-rw-r--r--participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/controller/ChartController.java52
3 files changed, 80 insertions, 172 deletions
diff --git a/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/main/rest/AbstractRestController.java b/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/main/rest/AbstractRestController.java
index 7c963b6da..369342b11 100644
--- a/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/main/rest/AbstractRestController.java
+++ b/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/main/rest/AbstractRestController.java
@@ -20,13 +20,6 @@
package org.onap.policy.clamp.acm.element.main.rest;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.BasicAuthDefinition;
-import io.swagger.annotations.Info;
-import io.swagger.annotations.SecurityDefinition;
-import io.swagger.annotations.SwaggerDefinition;
-import io.swagger.annotations.Tag;
-import java.net.HttpURLConnection;
import javax.ws.rs.core.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -41,32 +34,11 @@ import org.springframework.web.bind.annotation.RequestMapping;
AbstractRestController.APPLICATION_YAML
}
)
-@Api(value = "AC Element API")
-@SwaggerDefinition(
- info = @Info(
- description = "AC Element",
- version = "v1.0",
- title = "AC Element"
- ),
- consumes = {MediaType.APPLICATION_JSON, AbstractRestController.APPLICATION_YAML},
- produces = {MediaType.APPLICATION_JSON, AbstractRestController.APPLICATION_YAML},
- schemes = {SwaggerDefinition.Scheme.HTTP, SwaggerDefinition.Scheme.HTTPS},
- tags = {
- @Tag(name = "acelement", description = "Ac element implementation")
- },
- securityDefinition = @SecurityDefinition(basicAuthDefinitions = {@BasicAuthDefinition(key = "basicAuth")})
-)
// @formatter:on
public abstract class AbstractRestController {
public static final String APPLICATION_YAML = "application/yaml";
- public static final String EXTENSION_NAME = "interface info";
-
public static final String API_VERSION_NAME = "api-version";
- public static final String API_VERSION = "1.0.0";
-
- public static final String LAST_MOD_NAME = "last-mod-release";
- public static final String LAST_MOD_RELEASE = "Dublin";
public static final String VERSION_MINOR_NAME = "X-MinorVersion";
public static final String VERSION_MINOR_DESCRIPTION =
@@ -83,14 +55,13 @@ public abstract class AbstractRestController {
public static final String REQUEST_ID_NAME = "X-ONAP-RequestID";
public static final String REQUEST_ID_HDR_DESCRIPTION = "Used to track REST transactions for logging purpose";
- public static final String AUTHORIZATION_TYPE = "basicAuth";
-
- public static final int AUTHENTICATION_ERROR_CODE = HttpURLConnection.HTTP_UNAUTHORIZED;
- public static final int AUTHORIZATION_ERROR_CODE = HttpURLConnection.HTTP_FORBIDDEN;
- public static final int SERVER_ERROR_CODE = HttpURLConnection.HTTP_INTERNAL_ERROR;
+ public static final String OK_CODE = "200";
+ public static final String CREATED_CODE = "201";
+ public static final String NO_CONTENT_CODE = "204";
+ public static final String AUTHENTICATION_ERROR_CODE = "401";
+ public static final String BAD_REQUEST_ERROR_CODE = "400";
public static final String AUTHENTICATION_ERROR_MESSAGE = "Authentication Error";
- public static final String AUTHORIZATION_ERROR_MESSAGE = "Authorization Error";
- public static final String SERVER_ERROR_MESSAGE = "Internal Server Error";
-
+ public static final String BAD_REQUEST_ERROR_MESSAGE = "Bad request";
+ public static final String SERVER_OK_MESSAGE = "Success";
} \ No newline at end of file
diff --git a/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/main/rest/AcElementController.java b/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/main/rest/AcElementController.java
index 7a8662c34..afe864edc 100644
--- a/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/main/rest/AcElementController.java
+++ b/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/main/rest/AcElementController.java
@@ -20,14 +20,12 @@
package org.onap.policy.clamp.acm.element.main.rest;
-import io.swagger.annotations.ApiOperation;
-import io.swagger.annotations.ApiResponse;
-import io.swagger.annotations.ApiResponses;
-import io.swagger.annotations.Authorization;
-import io.swagger.annotations.Extension;
-import io.swagger.annotations.ExtensionProperty;
-import io.swagger.annotations.ResponseHeader;
-import java.util.UUID;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.headers.Header;
+import io.swagger.v3.oas.annotations.media.Content;
+import io.swagger.v3.oas.annotations.media.Schema;
+import io.swagger.v3.oas.annotations.responses.ApiResponse;
+import io.swagger.v3.oas.annotations.responses.ApiResponses;
import lombok.RequiredArgsConstructor;
import org.onap.policy.clamp.acm.element.service.ConfigService;
import org.onap.policy.clamp.models.acm.messages.rest.element.ElementConfig;
@@ -46,7 +44,6 @@ public class AcElementController extends AbstractRestController {
private final ConfigService configService;
-
/**
* REST endpoint to get the existing element config.
*
@@ -54,40 +51,21 @@ public class AcElementController extends AbstractRestController {
*/
// @formatter:off
@GetMapping(path = "/config", produces = MediaType.APPLICATION_JSON_VALUE)
- @ApiOperation(
- value = "Return the element config",
- response = ElementConfig.class,
- tags = {
- "Clamp Automation Composition AC Element Impl API"
- },
- authorizations = @Authorization(value = AUTHORIZATION_TYPE),
- responseHeaders = {
- @ResponseHeader(
- name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION,
- response = String.class),
- @ResponseHeader(
- name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION,
- response = String.class),
- @ResponseHeader(
- name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
- response = String.class),
- @ResponseHeader(
- name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION,
- response = UUID.class)},
- extensions = {
- @Extension(
- name = EXTENSION_NAME,
- properties = {
- @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
- @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
- }
- )
- })
+ @Operation(summary = "Return the element config",
+ tags = { "Clamp Automation Composition AC Element Impl API" })
@ApiResponses(
value = {
- @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE),
- @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE),
- @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE)
+ @ApiResponse(responseCode = OK_CODE, description = SERVER_OK_MESSAGE,
+ content = @Content(schema = @Schema(implementation = ElementConfig.class)),
+ headers = {
+ @Header(name = API_VERSION_NAME),
+ @Header(name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION),
+ @Header(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION),
+ @Header(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION),
+ @Header(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION),
+ @Header(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION)
+ }),
+ @ApiResponse(responseCode = AUTHENTICATION_ERROR_CODE, description = AUTHENTICATION_ERROR_MESSAGE)
}
)
// @formatter:on
@@ -102,43 +80,23 @@ public class AcElementController extends AbstractRestController {
*/
// @formatter:off
@PostMapping(path = "/activate", consumes = MediaType.APPLICATION_JSON_VALUE,
- produces = MediaType.APPLICATION_JSON_VALUE)
- @ApiOperation(
- value = "Activates the element config",
- response = ElementConfig.class,
- tags = {
- "Clamp Automation Composition AC Element Impl API"
- },
- authorizations = @Authorization(value = AUTHORIZATION_TYPE),
- responseHeaders = {
- @ResponseHeader(
- name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION,
- response = String.class),
- @ResponseHeader(
- name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION,
- response = String.class),
- @ResponseHeader(
- name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
- response = String.class),
- @ResponseHeader(
- name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION,
- response = UUID.class)
- },
- extensions = {
- @Extension (
- name = EXTENSION_NAME,
- properties = {
- @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
- @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
- }
- )
- }
+ produces = MediaType.APPLICATION_JSON_VALUE)
+ @Operation(summary = "Activates the element config",
+ tags = { "Clamp Automation Composition AC Element Impl API" }
)
@ApiResponses(
value = {
- @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE),
- @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE),
- @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE)
+ @ApiResponse(responseCode = CREATED_CODE, description = SERVER_OK_MESSAGE,
+ headers = {
+ @Header(name = API_VERSION_NAME),
+ @Header(name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION),
+ @Header(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION),
+ @Header(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION),
+ @Header(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION),
+ @Header(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION)
+ }),
+ @ApiResponse(responseCode = AUTHENTICATION_ERROR_CODE, description = AUTHENTICATION_ERROR_MESSAGE),
+ @ApiResponse(responseCode = BAD_REQUEST_ERROR_CODE, description = BAD_REQUEST_ERROR_MESSAGE)
}
)
// formatter:on
@@ -154,47 +112,26 @@ public class AcElementController extends AbstractRestController {
*/
// @formatter:off
@DeleteMapping(path = "/deactivate")
- @ApiOperation(
- value = "Delete the element config",
- response = ElementConfig.class,
- tags = {
- "Clamp Automation Composition AC Element Impl API"
- },
- authorizations = @Authorization(value = AUTHORIZATION_TYPE),
- responseHeaders = {
- @ResponseHeader(
- name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION,
- response = String.class),
- @ResponseHeader(
- name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION,
- response = String.class),
- @ResponseHeader(
- name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
- response = String.class),
- @ResponseHeader(
- name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION,
- response = UUID.class)},
- extensions = {
- @Extension(
- name = EXTENSION_NAME,
- properties = {
- @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
- @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
- }
- )
- }
+ @Operation(summary = "Delete the element config",
+ tags = { "Clamp Automation Composition AC Element Impl API" }
)
@ApiResponses(
value = {
- @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE),
- @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE),
- @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE)
+ @ApiResponse(responseCode = NO_CONTENT_CODE, description = SERVER_OK_MESSAGE,
+ headers = {
+ @Header(name = API_VERSION_NAME),
+ @Header(name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION),
+ @Header(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION),
+ @Header(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION),
+ @Header(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION),
+ @Header(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION)
+ }),
+ @ApiResponse(responseCode = AUTHENTICATION_ERROR_CODE, description = AUTHENTICATION_ERROR_MESSAGE)
}
)
// @formatter:on
- public ResponseEntity<Object> deleteConfig() {
+ public ResponseEntity<Void> deleteConfig() {
configService.deleteConfig();
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
-
}
-} \ No newline at end of file
+}
diff --git a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/controller/ChartController.java b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/controller/ChartController.java
index 7d0c6c0d8..1186b7bf5 100644
--- a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/controller/ChartController.java
+++ b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/controller/ChartController.java
@@ -18,13 +18,14 @@
package org.onap.policy.clamp.acm.participant.kubernetes.controller;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import io.swagger.annotations.ApiResponse;
-import io.swagger.annotations.ApiResponses;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.responses.ApiResponse;
+import io.swagger.v3.oas.annotations.responses.ApiResponses;
+import io.swagger.v3.oas.annotations.tags.Tag;
import java.io.IOException;
import java.lang.invoke.MethodHandles;
import java.util.ArrayList;
+import lombok.RequiredArgsConstructor;
import org.onap.policy.clamp.acm.participant.kubernetes.exception.ServiceException;
import org.onap.policy.clamp.acm.participant.kubernetes.models.ChartInfo;
import org.onap.policy.clamp.acm.participant.kubernetes.models.ChartList;
@@ -35,7 +36,6 @@ import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.common.utils.coder.StandardCoder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
@@ -51,15 +51,15 @@ import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
+@RequiredArgsConstructor
@RestController("chartController")
@ConditionalOnExpression("${chart.api.enabled:false}")
@RequestMapping("helm")
-@Api(tags = {"k8s-participant"})
+@Tag(name = "k8s-participant")
public class ChartController {
private final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
- @Autowired
- private ChartService chartService;
+ private final ChartService chartService;
private static final StandardCoder CODER = new StandardCoder();
@@ -69,8 +69,8 @@ public class ChartController {
* @return List of charts installed
*/
@GetMapping(path = "/charts", produces = MediaType.APPLICATION_JSON_VALUE)
- @ApiOperation(value = "Return all Charts")
- @ApiResponses(value = {@ApiResponse(code = 200, message = "chart List")})
+ @Operation(summary = "Return all Charts")
+ @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "chart List")})
public ResponseEntity<ChartList> getAllCharts() {
return new ResponseEntity<>(ChartList.builder().charts(new ArrayList<>(chartService.getAllCharts())).build(),
HttpStatus.OK);
@@ -86,9 +86,9 @@ public class ChartController {
*/
@PostMapping(path = "/install", consumes = MediaType.APPLICATION_JSON_VALUE,
produces = MediaType.APPLICATION_JSON_VALUE)
- @ApiOperation(value = "Install the chart")
- @ApiResponses(value = {@ApiResponse(code = 201, message = "chart Installed")})
- public ResponseEntity<Object> installChart(@RequestBody InstallationInfo info)
+ @Operation(summary = "Install the chart")
+ @ApiResponses(value = {@ApiResponse(responseCode = "201", description = "chart Installed")})
+ public ResponseEntity<Void> installChart(@RequestBody InstallationInfo info)
throws ServiceException, IOException {
ChartInfo chart = chartService.getChart(info.getName(), info.getVersion());
if (chart == null) {
@@ -108,9 +108,9 @@ public class ChartController {
* @throws ServiceException in case of error.
*/
@DeleteMapping(path = "/uninstall/{name}/{version}", produces = MediaType.APPLICATION_JSON_VALUE)
- @ApiOperation(value = "Uninstall the Chart")
- @ApiResponses(value = {@ApiResponse(code = 201, message = "chart Uninstalled")})
- public ResponseEntity<Object> uninstallChart(@PathVariable("name") String name,
+ @Operation(summary = "Uninstall the Chart")
+ @ApiResponses(value = {@ApiResponse(responseCode = "204", description = "chart Uninstalled")})
+ public ResponseEntity<Void> uninstallChart(@PathVariable("name") String name,
@PathVariable("version") String version) throws ServiceException {
ChartInfo chart = chartService.getChart(name, version);
if (chart == null) {
@@ -133,9 +133,9 @@ public class ChartController {
*/
@PostMapping(path = "/onboard/chart", consumes = MediaType.MULTIPART_FORM_DATA_VALUE,
produces = MediaType.APPLICATION_JSON_VALUE)
- @ApiOperation(value = "Onboard the Chart")
- @ApiResponses(value = {@ApiResponse(code = 201, message = "Chart Onboarded")})
- public ResponseEntity<String> onboardChart(@RequestPart("chart") MultipartFile chartFile,
+ @Operation(summary = "Onboard the Chart")
+ @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "Chart Onboarded")})
+ public ResponseEntity<Void> onboardChart(@RequestPart("chart") MultipartFile chartFile,
@RequestParam(name = "values", required = false) MultipartFile overrideFile,
@RequestParam("info") String infoJson) throws ServiceException, IOException {
@@ -158,9 +158,9 @@ public class ChartController {
* @return Status of operation
*/
@DeleteMapping(path = "/chart/{name}/{version}")
- @ApiOperation(value = "Delete the chart")
- @ApiResponses(value = {@ApiResponse(code = 204, message = "Chart Deleted")})
- public ResponseEntity<Object> deleteChart(@PathVariable("name") String name,
+ @Operation(summary = "Delete the chart")
+ @ApiResponses(value = {@ApiResponse(responseCode = "204", description = "Chart Deleted")})
+ public ResponseEntity<Void> deleteChart(@PathVariable("name") String name,
@PathVariable("version") String version) {
ChartInfo chart = chartService.getChart(name, version);
@@ -182,10 +182,10 @@ public class ChartController {
*/
@PostMapping(path = "/repo", consumes = MediaType.APPLICATION_JSON_VALUE,
produces = MediaType.APPLICATION_JSON_VALUE)
- @ApiOperation(value = "Configure helm repository")
- @ApiResponses(value = {@ApiResponse(code = 201, message = "Repository added"),
- @ApiResponse(code = 409, message = "Repository already Exist")})
- public ResponseEntity<Object> configureRepo(@RequestBody String repo)
+ @ApiResponses(
+ value = {@ApiResponse(responseCode = "201", description = "Repository added"),
+ @ApiResponse(responseCode = "409", description = "Repository already Exist")})
+ public ResponseEntity<String> configureRepo(@RequestBody String repo)
throws ServiceException, IOException {
HelmRepository repository;
try {