mirror of
https://github.com/LukeHagar/plexjava.git
synced 2025-12-06 12:37:47 +00:00
143 lines
5.9 KiB
Markdown
143 lines
5.9 KiB
Markdown
# Activities
|
|
(*activities()*)
|
|
|
|
## Overview
|
|
|
|
Activities are awesome. They provide a way to monitor and control asynchronous operations on the server. In order to receive real-time updates for activities, a client would normally subscribe via either EventSource or Websocket endpoints.
|
|
Activities are associated with HTTP replies via a special `X-Plex-Activity` header which contains the UUID of the activity.
|
|
Activities are optional cancellable. If cancellable, they may be cancelled via the `DELETE` endpoint. Other details:
|
|
- They can contain a `progress` (from 0 to 100) marking the percent completion of the activity.
|
|
- They must contain an `type` which is used by clients to distinguish the specific activity.
|
|
- They may contain a `Context` object with attributes which associate the activity with various specific entities (items, libraries, etc.)
|
|
- The may contain a `Response` object which attributes which represent the result of the asynchronous operation.
|
|
|
|
|
|
### Available Operations
|
|
|
|
* [getServerActivities](#getserveractivities) - Get Server Activities
|
|
* [cancelServerActivities](#cancelserveractivities) - Cancel Server Activities
|
|
|
|
## getServerActivities
|
|
|
|
Get Server Activities
|
|
|
|
### Example Usage
|
|
|
|
```java
|
|
package hello.world;
|
|
|
|
import dev.plexapi.sdk.PlexAPI;
|
|
import dev.plexapi.sdk.models.errors.SDKError;
|
|
import dev.plexapi.sdk.models.operations.GetServerActivitiesResponse;
|
|
import java.lang.Exception;
|
|
|
|
public class Application {
|
|
|
|
public static void main(String[] args) throws Exception {
|
|
try {
|
|
PlexAPI sdk = PlexAPI.builder()
|
|
.accessToken("<YOUR_API_KEY_HERE>")
|
|
.xPlexClientIdentifier("gcgzw5rz2xovp84b4vha3a40")
|
|
.build();
|
|
|
|
GetServerActivitiesResponse res = sdk.activities().getServerActivities()
|
|
.call();
|
|
|
|
if (res.object().isPresent()) {
|
|
// handle response
|
|
}
|
|
} catch (dev.plexapi.sdk.models.errors.GetServerActivitiesBadRequest e) {
|
|
// handle exception
|
|
throw e;
|
|
} catch (dev.plexapi.sdk.models.errors.GetServerActivitiesUnauthorized e) {
|
|
// handle exception
|
|
throw e;
|
|
} catch (SDKError e) {
|
|
// handle exception
|
|
throw e;
|
|
} catch (Exception e) {
|
|
// handle exception
|
|
throw e;
|
|
}
|
|
|
|
}
|
|
}
|
|
```
|
|
|
|
### Response
|
|
|
|
**[GetServerActivitiesResponse](../../models/operations/GetServerActivitiesResponse.md)**
|
|
|
|
### Errors
|
|
|
|
| Error Object | Status Code | Content Type |
|
|
| --------------------------------------------- | --------------------------------------------- | --------------------------------------------- |
|
|
| models/errors/GetServerActivitiesBadRequest | 400 | application/json |
|
|
| models/errors/GetServerActivitiesUnauthorized | 401 | application/json |
|
|
| models/errors/SDKError | 4xx-5xx | \*\/* |
|
|
|
|
|
|
## cancelServerActivities
|
|
|
|
Cancel Server Activities
|
|
|
|
### Example Usage
|
|
|
|
```java
|
|
package hello.world;
|
|
|
|
import dev.plexapi.sdk.PlexAPI;
|
|
import dev.plexapi.sdk.models.errors.SDKError;
|
|
import dev.plexapi.sdk.models.operations.CancelServerActivitiesResponse;
|
|
import java.lang.Exception;
|
|
|
|
public class Application {
|
|
|
|
public static void main(String[] args) throws Exception {
|
|
try {
|
|
PlexAPI sdk = PlexAPI.builder()
|
|
.accessToken("<YOUR_API_KEY_HERE>")
|
|
.xPlexClientIdentifier("gcgzw5rz2xovp84b4vha3a40")
|
|
.build();
|
|
|
|
CancelServerActivitiesResponse res = sdk.activities().cancelServerActivities()
|
|
.activityUUID("25b71ed5-0f9d-461c-baa7-d404e9e10d3e")
|
|
.call();
|
|
|
|
// handle response
|
|
} catch (dev.plexapi.sdk.models.errors.CancelServerActivitiesBadRequest e) {
|
|
// handle exception
|
|
throw e;
|
|
} catch (dev.plexapi.sdk.models.errors.CancelServerActivitiesUnauthorized e) {
|
|
// handle exception
|
|
throw e;
|
|
} catch (SDKError e) {
|
|
// handle exception
|
|
throw e;
|
|
} catch (Exception e) {
|
|
// handle exception
|
|
throw e;
|
|
}
|
|
|
|
}
|
|
}
|
|
```
|
|
|
|
### Parameters
|
|
|
|
| Parameter | Type | Required | Description | Example |
|
|
| ------------------------------------ | ------------------------------------ | ------------------------------------ | ------------------------------------ | ------------------------------------ |
|
|
| `activityUUID` | *String* | :heavy_check_mark: | The UUID of the activity to cancel. | 25b71ed5-0f9d-461c-baa7-d404e9e10d3e |
|
|
|
|
### Response
|
|
|
|
**[CancelServerActivitiesResponse](../../models/operations/CancelServerActivitiesResponse.md)**
|
|
|
|
### Errors
|
|
|
|
| Error Object | Status Code | Content Type |
|
|
| ------------------------------------------------ | ------------------------------------------------ | ------------------------------------------------ |
|
|
| models/errors/CancelServerActivitiesBadRequest | 400 | application/json |
|
|
| models/errors/CancelServerActivitiesUnauthorized | 401 | application/json |
|
|
| models/errors/SDKError | 4xx-5xx | \*\/* |
|