diff options
Diffstat (limited to 'participant/participant-impl/participant-impl-acelement/src')
2 files changed, 54 insertions, 146 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 +} |