Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New API controller: server #5

Merged
merged 5 commits into from
Jul 23, 2020
Merged
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
1 change: 1 addition & 0 deletions .ci/doc/templates/print-result.tpl.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import io.kuzzle.sdk.Kuzzle;
import io.kuzzle.sdk.protocol.WebSocket;
import java.util.Date;
import io.kuzzle.sdk.coreClasses.responses.Response;

import java.util.concurrent.ConcurrentHashMap;
Expand Down
1 change: 1 addition & 0 deletions .ci/doc/templates/print-result.tpl.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import io.kuzzle.sdk.Kuzzle
import io.kuzzle.sdk.protocol.WebSocket
import java.util.Date
import java.util.concurrent.ConcurrentHashMap
import java.util.concurrent.ExecutionException
import io.kuzzle.sdk.coreClasses.responses.Response
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ hooks:
before: curl -X POST kuzzle:7512/users/foo/_create -H "Content-Type:application/json" --data '{"content":{"profileIds":["default"]},"credentials":{"local":{"username":"foo","password":"bar"}}}'
after: curl -X DELETE kuzzle:7512/users/foo
template: print-result
expected: ^{_source={profileIds=\[default\],\ _kuzzle_info={createdAt=[0-9]+,\ author=-1},\ age=42},\ _id=foo}$
expected: ^{_source={profileIds=\[default\],\ _kuzzle_info={updatedAt=[0-9]+,\ updater=foo},\ age=42},\ _id=foo}$
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ hooks:
before: curl -X POST kuzzle:7512/users/foo/_create -H "Content-Type:application/json" --data '{"content":{"profileIds":["default"]},"credentials":{"local":{"username":"foo","password":"bar"}}}'
after: curl -X DELETE kuzzle:7512/users/foo
template: print-result
expected: ^{_source={profileIds=\[default\],\ _kuzzle_info={createdAt=[0-9]+,\ author=-1},\ age=42},\ _id=foo}$
expected: ^{_source={profileIds=\[default\],\ _kuzzle_info={updatedAt=[0-9]+,\ updater=foo},\ age=42},\ _id=foo}$
40 changes: 40 additions & 0 deletions doc/1/controllers/server/admin-exists/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
code: true
type: page
title: adminExists
description: Checks that an administrator account exists.
---

# adminExists

Checks that an administrator account exists.

:::: tabs
::: tab Java

```java
CompletableFuture<Boolean> adminExists()
```

## Return

A boolean indicating whether an admin user exists or not.

## Usage

<<< ./snippets/adminExists-java.java

:::: tabs
::: tab Kotlin

```kotlin
fun adminExists(): CompletableFuture<Boolean>
```

## Return

A boolean indicating whether an admin user exists or not.

## Usage

<<< ./snippets/adminExists-kotlin.kotlin
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Boolean result = kuzzle.getServerController().adminExists().get();
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name: java-Server#AdminExistsAsync
description: Checks that an administrator account exists.
hooks:
before:
after:
template: print-result
expected: false
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
val result: Boolean =
kuzzle.serverController.adminExists().get()
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name: kotlin-Server#AdminExistsAsync
description: Checks that an administrator account exists.
hooks:
before:
after:
template: print-result
expected: false
47 changes: 47 additions & 0 deletions doc/1/controllers/server/get-all-stats/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
code: true
type: page
title: getAllStats
description: Gets all stored internal statistic snapshots.
---

# getAllStats

Gets all stored internal statistic snapshots.
By default, snapshots are made every 10 seconds and they are stored for 1 hour.

These statistics include:

- the number of connected users per protocol (not available for all protocols)
- the number of ongoing requests
- the number of completed requests since the last frame
- the number of failed requests since the last frame

:::: tabs
::: tab Java

```java
CompletableFuture<ConcurrentHashMap<String, Object>> getAllStats()
```

## Return

Returns a `ConcurrentHashMap<String, Object>` containing all stored internal statistic snapshots.

## Usage

<<< ./snippets/get-all-stats-java.java

::: tab Kotlin

```kotlin
fun getAllStats(): CompletableFuture<ConcurrentHashMap<String, Any?>>
```

## Return

Returns a `ConcurrentHashMap<String, Any?>` containing all stored internal statistic snapshots.

## Usage

<<< ./snippets/get-all-stats-kotlin.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
ConcurrentHashMap<String, Object> result = kuzzle
.getServerController()
.getAllStats()
.get();
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name: java-server#getAllStats
description: Gets all stored internal statistic snapshots.
hooks:
before:
after:
template: print-result
expected: ongoingRequests
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
val result: ConcurrentHashMap<String, Any?> = kuzzle
.serverController
.getAllStats()
.get()
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name: kotlin-server#getAllStats
description: Gets all stored internal statistic snapshots.
hooks:
before:
after:
template: print-result
expected: ongoingRequests
43 changes: 43 additions & 0 deletions doc/1/controllers/server/get-config/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
code: true
type: page
title: getConfig
description: Returns the current Kuzzle configuration.
---

# getConfig

Returns the current Kuzzle configuration.

:::warning
This route should only be accessible to administrators, as it might return sensitive information about the backend.
:::

:::: tabs
::: tab Java

```java
CompletableFuture<ConcurrentHashMap<String, Object>> getConfig()
```

## Return

Returns a `ConcurrentHashMap<String, Object>` containing server configuration.

## Usage

<<< ./snippets/get-config-java.java

::: tab Kotlin

```kotlin
fun getConfig(): CompletableFuture<ConcurrentHashMap<String, Any?>>
```

## Return

Returns a `ConcurrentHashMap<String, Any?>` containing server configuration.

## Usage

<<< ./snippets/get-config-kotlin.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
ConcurrentHashMap<String, Object> result = kuzzle
.getServerController()
.getConfig()
.get();
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name: java-server#getConfig
description: Returns the current Kuzzle configuration.
hooks:
before:
after:
template: print-result
expected: ^{server={.*}$
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
val result: ConcurrentHashMap<String, Any?> = kuzzle
.serverController
.getConfig()
.get()
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name: kotlin-server#getConfig
description: Returns the current Kuzzle configuration.
hooks:
before:
after:
template: print-result
expected: ^{server={.*}$
48 changes: 48 additions & 0 deletions doc/1/controllers/server/get-last-stats/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
code: true
type: page
title: getLastStats
description: Returns the most recent statistics snapshot.
---

# getLastStats

Returns the most recent statistics snapshot.

By default, snapshots are made every 10 seconds and they are stored for 1 hour.

These statistics include:

- the number of connected users per protocol (not available for all protocols)
- the number of ongoing requests
- the number of completed requests since the last frame
- the number of failed requests since the last frame

:::: tabs
::: tab Java

```java
CompletableFuture<ConcurrentHashMap<String, Object>> getLastStats()
```

## Return

Returns an `ConcurrentHashMap<String, Object>` containing the most recent statistics snapshot.

## Usage

<<< ./snippets/get-last-stats-java.java

::: tab Kotlin

```kotlin
fun getConfig(): CompletableFuture<ConcurrentHashMap<String, Any?>>
```

## Return

Returns an `ConcurrentHashMap<String, Any?>` containing the most recent statistics snapshot.

## Usage

<<< ./snippets/get-last-stats-kotlin.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
ConcurrentHashMap<String, Object> result = kuzzle
.getServerController()
.getLastStats()
.get();
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name: java-server#getLastStats
description: Gets all stored internal statistic snapshots.
hooks:
before:
after:
template: print-result
expected: ongoingRequests
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
val result: ConcurrentHashMap<String, Any?> = kuzzle
.serverController
.getLastStats()
.get()
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name: kotlin-server#getLastStats
description: Gets all stored internal statistic snapshots.
hooks:
before:
after:
template: print-result
expected: ongoingRequests
62 changes: 62 additions & 0 deletions doc/1/controllers/server/get-stats/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
---
code: true
type: page
title: getStats
description: Returns statistics snapshots within a provided timestamp range.
---

# getStats

Returns statistics snapshots within a provided timestamp range.
By default, snapshots are made every 10 seconds and they are stored for 1 hour.

These statistics include:

- the number of connected users per protocol (not available for all protocols)
- the number of ongoing requests
- the number of completed requests since the last frame
- the number of failed requests since the last frame

:::: tabs
::: tab Java

```java
CompletableFuture<ConcurrentHashMap<String, Object>> getStats(
Date startTime, Date stopTime)
```

<br/>

| Arguments | Type | Description |
| ----------- | ------------------------- | --------------------------------------------------------------- |
| `startTime` | <pre>Date</pre> | Beginning of statistics frame set |
| `stopTime` | <pre>Date</pre> | End of statistics frame set |

## Return

Returns a `ConcurrentHashMap<String, Object>` containing statistics snapshots within the provided range.

## Usage

<<< ./snippets/get-stats-java.java

::: tab Kotlin

```kotlin
fun getStats(startTime: Date, stopTime: Date): CompletableFuture<ConcurrentHashMap<String, Any?>>
```

<br/>

| Arguments | Type | Description |
| ----------- | ------------------------- | --------------------------------------------------------------- |
| `startTime` | <pre>Date</pre> | Beginning of statistics frame set |
| `stopTime` | <pre>Date</pre> | End of statistics frame set |

## Return

Returns a `ConcurrentHashMap<String, Any?>` containing statistics snapshots within the provided range.

## Usage

<<< ./snippets/get-stats-kotlin.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Date startTime = new Date(1234567890);
Date stopTime = new Date(1541426610);

ConcurrentHashMap<String, Object> result = kuzzle
.getServerController()
.getStats(startTime, stopTime)
.get();
Loading