From 8618348c3bb0e7c1267a8f6efbef79c228435239 Mon Sep 17 00:00:00 2001 From: 0utplay Date: Sun, 22 Dec 2024 21:28:55 +0100 Subject: [PATCH] chore: mostly styling --- .../ext/modules/rest/v3/V3HttpHandlerNode.java | 2 +- .../ext/modules/rest/validation/LogLevel.java | 2 -- .../rest/validation/validator/LogLevelValidator.java | 6 ++++-- .../src/main/resources/documentation/swagger.yaml | 5 ++++- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/cloudnet-rest-module/src/main/java/eu/cloudnetservice/ext/modules/rest/v3/V3HttpHandlerNode.java b/cloudnet-rest-module/src/main/java/eu/cloudnetservice/ext/modules/rest/v3/V3HttpHandlerNode.java index da8fb94..8db669c 100644 --- a/cloudnet-rest-module/src/main/java/eu/cloudnetservice/ext/modules/rest/v3/V3HttpHandlerNode.java +++ b/cloudnet-rest-module/src/main/java/eu/cloudnetservice/ext/modules/rest/v3/V3HttpHandlerNode.java @@ -178,7 +178,7 @@ public V3HttpHandlerNode( @RequestHandler(path = "/api/v3/node/liveConsole") public @NonNull IntoResponse handleLiveConsoleRequest( @NonNull HttpContext context, - @Optional @Valid @LogLevel @FirstRequestQueryParam("threshold") String threshold, + @FirstRequestQueryParam("threshold") @Optional @Valid @LogLevel String threshold, @Authentication( providers = {"ticket", "jwt"}, scopes = {"cloudnet_rest:node_read", "cloudnet_rest:node_live_console"}) @NonNull RestUser restUser diff --git a/cloudnet-rest-module/src/main/java/eu/cloudnetservice/ext/modules/rest/validation/LogLevel.java b/cloudnet-rest-module/src/main/java/eu/cloudnetservice/ext/modules/rest/validation/LogLevel.java index 2a31ea9..92f5290 100644 --- a/cloudnet-rest-module/src/main/java/eu/cloudnetservice/ext/modules/rest/validation/LogLevel.java +++ b/cloudnet-rest-module/src/main/java/eu/cloudnetservice/ext/modules/rest/validation/LogLevel.java @@ -39,6 +39,4 @@ Class[] groups() default {}; Class[] payload() default {}; - - } diff --git a/cloudnet-rest-module/src/main/java/eu/cloudnetservice/ext/modules/rest/validation/validator/LogLevelValidator.java b/cloudnet-rest-module/src/main/java/eu/cloudnetservice/ext/modules/rest/validation/validator/LogLevelValidator.java index ad1f04d..78d23b9 100644 --- a/cloudnet-rest-module/src/main/java/eu/cloudnetservice/ext/modules/rest/validation/validator/LogLevelValidator.java +++ b/cloudnet-rest-module/src/main/java/eu/cloudnetservice/ext/modules/rest/validation/validator/LogLevelValidator.java @@ -20,11 +20,13 @@ import eu.cloudnetservice.ext.modules.rest.validation.LogLevel; import jakarta.validation.ConstraintValidator; import jakarta.validation.ConstraintValidatorContext; +import lombok.NonNull; +import org.jetbrains.annotations.Nullable; -public class LogLevelValidator implements ConstraintValidator { +public final class LogLevelValidator implements ConstraintValidator { @Override - public boolean isValid(String value, ConstraintValidatorContext context) { + public boolean isValid(@Nullable String value, @NonNull ConstraintValidatorContext context) { return value == null || Level.toLevel(value, null) != null; } } diff --git a/cloudnet-rest-module/src/main/resources/documentation/swagger.yaml b/cloudnet-rest-module/src/main/resources/documentation/swagger.yaml index c31fb8b..5989d40 100644 --- a/cloudnet-rest-module/src/main/resources/documentation/swagger.yaml +++ b/cloudnet-rest-module/src/main/resources/documentation/swagger.yaml @@ -686,7 +686,8 @@ paths: required: false description: | The log level threshold. Only log entries with the same or higher log level will be sent. - The lowest level possible is the configured log level of the node itself. + The lowest level that is actually sent is the configured log level of the node itself, + requesting lower levels is possible but there is no effect. schema: $ref: '#/components/schemas/LogLevel' summary: Live console @@ -703,6 +704,8 @@ paths: responses: '101': description: Switching the protocol to a websocket + '400': + $ref: '#/components/responses/Problem' '401': $ref: '#/components/responses/Problem' '403':