diff --git a/build.gradle.kts b/build.gradle.kts index 8f77cf7..725dda3 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -24,7 +24,7 @@ plugins { } allprojects { - version = "0.5.1" + version = "0.5.2" group = "eu.cloudnetservice.ext" apply(plugin = "signing") diff --git a/cloudnet-rest-module/build.gradle.kts b/cloudnet-rest-module/build.gradle.kts index 6c04c70..bc1c70a 100644 --- a/cloudnet-rest-module/build.gradle.kts +++ b/cloudnet-rest-module/build.gradle.kts @@ -55,8 +55,8 @@ dependencies { compileOnly(libs.logbackCore) compileOnly(libs.logbackClassic) - compileOnly("eu.cloudnetservice.cloudnet:node-impl:4.0.0-RC16-SNAPSHOT") - compileOnly("eu.cloudnetservice.cloudnet:bridge-impl:4.0.0-RC16-SNAPSHOT") + compileOnly("eu.cloudnetservice.cloudnet:node-impl:4.0.0-RC16") + compileOnly("eu.cloudnetservice.cloudnet:bridge-impl:4.0.0-RC16") } tasks.withType { diff --git a/cloudnet-rest-module/src/main/java/eu/cloudnetservice/ext/modules/rest/v3/V3HttpHandlerDatabase.java b/cloudnet-rest-module/src/main/java/eu/cloudnetservice/ext/modules/rest/v3/V3HttpHandlerDatabase.java index 108d0a2..ef748ce 100644 --- a/cloudnet-rest-module/src/main/java/eu/cloudnetservice/ext/modules/rest/v3/V3HttpHandlerDatabase.java +++ b/cloudnet-rest-module/src/main/java/eu/cloudnetservice/ext/modules/rest/v3/V3HttpHandlerDatabase.java @@ -81,7 +81,8 @@ public V3HttpHandlerDatabase(@NonNull DatabaseProvider databaseProvider) { return JsonResponse.builder().body(Map.of("count", database.documentCount())); } - @RequestHandler(path = "/api/v3/database/{name}", method = HttpMethod.POST) + + @RequestHandler(path = "/api/v3/database/{name}/document", method = HttpMethod.POST) @Authentication(providers = "jwt", scopes = {"cloudnet_rest:database_write", "cloudnet_rest:database_insert"}) public @NonNull IntoResponse handleInsert( @NonNull @RequestPathParam("name") String name, @@ -110,8 +111,8 @@ public V3HttpHandlerDatabase(@NonNull DatabaseProvider databaseProvider) { } } - @RequestHandler(path = "/api/v3/database/{name}/get") - @Authentication(providers = "jwt", scopes = {"cloudnet_rest:database_read", "cloudnet_rest:database_get"}) + @RequestHandler(path = "/api/v3/database/{name}/document") + @Authentication(providers = "jwt", scopes = {"cloudnet_rest:database_read", "cloudnet_rest:database_document_get"}) public @NonNull IntoResponse handleGetRequest( @NonNull @RequestPathParam("name") String name, @NonNull @FirstRequestQueryParam("key") String key @@ -120,8 +121,8 @@ public V3HttpHandlerDatabase(@NonNull DatabaseProvider databaseProvider) { return JsonResponse.builder().body(DocumentFactory.json().newDocument("result", database.get(key))); } - @RequestHandler(path = "/api/v3/database/{name}/find") - @Authentication(providers = "jwt", scopes = {"cloudnet_rest:database_read", "cloudnet_rest:database_find"}) + @RequestHandler(path = "/api/v3/database/{name}/document/find") + @Authentication(providers = "jwt", scopes = {"cloudnet_rest:database_read", "cloudnet_rest:database_document_find"}) public @NonNull IntoResponse handleFindRequest( @NonNull @RequestPathParam("name") String name, @NonNull @RequestTypedBody Map filter @@ -130,9 +131,9 @@ public V3HttpHandlerDatabase(@NonNull DatabaseProvider databaseProvider) { return JsonResponse.builder().body(database.find(filter)); } - @RequestHandler(path = "/api/v3/database/{name}", method = HttpMethod.DELETE) - @Authentication(providers = "jwt", scopes = {"cloudnet_rest:database_write", "cloudnet_rest:database_delete"}) - public @NonNull IntoResponse handleDeleteRequest( + @RequestHandler(path = "/api/v3/database/{name}/document", method = HttpMethod.DELETE) + @Authentication(providers = "jwt", scopes = {"cloudnet_rest:database_write", "cloudnet_rest:database_document_delete"}) + public @NonNull IntoResponse handleDocumentDeleteRequest( @NonNull @RequestPathParam("name") String name, @NonNull @FirstRequestQueryParam("key") String key ) { @@ -140,11 +141,25 @@ public V3HttpHandlerDatabase(@NonNull DatabaseProvider databaseProvider) { if (database.delete(key)) { return HttpResponseCode.NO_CONTENT; } - return ProblemDetail.builder() .status(HttpResponseCode.OK) .type("database-delete-failed") .title("Database Delete Failed") .detail("The database had nothing to delete. The key was not associated with any data."); } + + @RequestHandler(path = "/api/v3/database/{name}", method = HttpMethod.DELETE) + @Authentication(providers = "jwt", scopes = {"cloudnet_rest:database_write", "cloudnet_rest:database_delete"}) + public @NonNull IntoResponse handleDatabaseDeleteRequest( + @NonNull @RequestPathParam("name") String name + ) { + if (this.databaseProvider.deleteDatabase(name)) { + return HttpResponseCode.NO_CONTENT; + } + return ProblemDetail.builder() + .status(HttpResponseCode.NOT_FOUND) + .type("database-delete-failed") + .title("Database Delete Failed") + .detail("The provided database was not found."); + } } diff --git a/cloudnet-rest-module/src/main/resources/documentation/swagger.yaml b/cloudnet-rest-module/src/main/resources/documentation/swagger.yaml index 698fe35..9494bb1 100644 --- a/cloudnet-rest-module/src/main/resources/documentation/swagger.yaml +++ b/cloudnet-rest-module/src/main/resources/documentation/swagger.yaml @@ -848,6 +848,67 @@ paths: required: true schema: type: string + delete: + tags: + - Database + summary: Deletes the database + description: | + One of the following scopes is needed to execute the request: + - `cloudnet_rest:database_write` + - `cloudnet_rest:database_delete` + responses: + '204': + description: Successful deletion of the database. + '400': + $ref: '#/components/responses/Problem' + '401': + $ref: '#/components/responses/Problem' + '403': + $ref: '#/components/responses/Problem' + /database/{name}/document: + parameters: + - name: name + in: path + required: true + schema: + type: string + get: + tags: + - Database + parameters: + - name: name + in: path + required: true + schema: + type: string + - name: key + in: query + required: true + schema: + type: string + summary: Get a specific document from a database + description: | + Get the document out of the provided database by using the provided key. + + One of the following scopes is needed to execute the request: + - `cloudnet_rest:database_read` + - `cloudnet_rest:database_document_get` + responses: + '200': + description: OK + content: + application/json: + schema: + type: object + properties: + result: + type: object + examples: + - Name: Peter + '401': + $ref: '#/components/responses/Problem' + '403': + $ref: '#/components/responses/Problem' post: requestBody: required: true @@ -893,7 +954,7 @@ paths: description: | One of the following scopes is needed to execute the request: - `cloudnet_rest:database_write` - - `cloudnet_rest:database_delete` + - `cloudnet_rest:database_document_delete` responses: '204': description: Successful deletion of the entry from the database. @@ -903,6 +964,52 @@ paths: $ref: '#/components/responses/Problem' '403': $ref: '#/components/responses/Problem' + /database/{name}/document/find: + get: + requestBody: + required: true + description: Defines the search filter to get the documents + content: + application/json: + schema: + oneOf: + - type: object + examples: + - Signs: 0utplayyyy + tags: + - Database + parameters: + - name: name + in: path + required: true + schema: + type: string + summary: Find a specific document in a database + description: | + Gets all documents out of the provided database, by using the provided + search filter. + + One of the following scopes is needed to execute the request: + - `cloudnet_rest:database_read` + - `cloudnet_rest:database_document_find` + responses: + '200': + description: OK + content: + application/json: + schema: + type: array + items: + type: object + examples: + - Name: Peter + - LastName: Parker + '400': + $ref: '#/components/responses/Problem' + '401': + $ref: '#/components/responses/Problem' + '403': + $ref: '#/components/responses/Problem' /database/{name}/clear: post: tags: @@ -1027,90 +1134,6 @@ paths: $ref: '#/components/responses/Problem' '403': $ref: '#/components/responses/Problem' - /database/{name}/get: - get: - tags: - - Database - parameters: - - name: name - in: path - required: true - schema: - type: string - - name: key - in: query - required: true - schema: - type: string - summary: Get a specific document from a database - description: | - Get the document out of the provided database by using the provided key. - - One of the following scopes is needed to execute the request: - - `cloudnet_rest:database_read` - - `cloudnet_rest:database_get` - responses: - '200': - description: OK - content: - application/json: - schema: - type: object - properties: - result: - type: object - examples: - - Name: Peter - '401': - $ref: '#/components/responses/Problem' - '403': - $ref: '#/components/responses/Problem' - /database/{name}/find: - get: - requestBody: - required: true - description: Defines the search filter to get the documents - content: - application/json: - schema: - oneOf: - - type: object - examples: - - Signs: 0utplayyyy - tags: - - Database - parameters: - - name: name - in: path - required: true - schema: - type: string - summary: Get a specific document from a database - description: | - Gets all documents out of the provided database, by using the provided - search filter. - - One of the following scopes is needed to execute the request: - - `cloudnet_rest:database_read` - - `cloudnet_rest:database_find` - responses: - '200': - description: OK - content: - application/json: - schema: - type: array - items: - type: object - examples: - - Name: Peter - - LastName: Parker - '400': - $ref: '#/components/responses/Problem' - '401': - $ref: '#/components/responses/Problem' - '403': - $ref: '#/components/responses/Problem' /group: post: requestBody: diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index f8e1ee3..d997cfc 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index bad7c24..c61a118 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.0-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.1-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/gradlew b/gradlew index adff685..739907d 100755 --- a/gradlew +++ b/gradlew @@ -57,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/2d6327017519d23b96af35865dc997fcb544fb40/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/.