Skip to content
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ plugins {
}

allprojects {
version = "0.5.1"
version = "0.5.2"
group = "eu.cloudnetservice.ext"

apply(plugin = "signing")
Expand Down
4 changes: 2 additions & 2 deletions cloudnet-rest-module/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Test> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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/get")
Comment thread
Unbemerkt marked this conversation as resolved.
Outdated
@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
Expand All @@ -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<String, String> filter
Expand All @@ -130,21 +131,35 @@ 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
) {
var database = this.databaseProvider.database(name);
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.");
}
}
32 changes: 28 additions & 4 deletions cloudnet-rest-module/src/main/resources/documentation/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -842,6 +842,30 @@ paths:
'403':
$ref: '#/components/responses/Problem'
/database/{name}:
parameters:
- name: name
in: path
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 entry from the database.
Comment thread
Unbemerkt marked this conversation as resolved.
Outdated
'400':
$ref: '#/components/responses/Problem'
'401':
$ref: '#/components/responses/Problem'
'403':
$ref: '#/components/responses/Problem'
/database/{name}/document:
parameters:
- name: name
in: path
Expand Down Expand Up @@ -893,7 +917,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.
Expand Down Expand Up @@ -1027,7 +1051,7 @@ paths:
$ref: '#/components/responses/Problem'
'403':
$ref: '#/components/responses/Problem'
/database/{name}/get:
/database/{name}/document/get:
get:
tags:
- Database
Expand Down Expand Up @@ -1065,7 +1089,7 @@ paths:
$ref: '#/components/responses/Problem'
'403':
$ref: '#/components/responses/Problem'
/database/{name}/find:
/database/{name}/document/find:
get:
requestBody:
required: true
Expand All @@ -1085,7 +1109,7 @@ paths:
required: true
schema:
type: string
summary: Get a specific document from a database
summary: Find a specific document in a database
description: |
Gets all documents out of the provided database, by using the provided
search filter.
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion gradlew

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.