Skip to content
Open
Show file tree
Hide file tree
Changes from all 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")
@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.");
}
}
193 changes: 108 additions & 85 deletions cloudnet-rest-module/src/main/resources/documentation/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand All @@ -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:
Expand Down Expand Up @@ -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:
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.