mirror of
https://github.com/LukeHagar/plexpy.git
synced 2025-12-10 04:21:03 +00:00
109 lines
5.8 KiB
Markdown
109 lines
5.8 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
|
|
|
|
* [get_server_activities](#get_server_activities) - Get Server Activities
|
|
* [cancel_server_activities](#cancel_server_activities) - Cancel Server Activities
|
|
|
|
## get_server_activities
|
|
|
|
Get Server Activities
|
|
|
|
### Example Usage
|
|
|
|
```python
|
|
from plex_api_client import PlexAPI
|
|
|
|
s = PlexAPI(
|
|
access_token="<YOUR_API_KEY_HERE>",
|
|
client_id="gcgzw5rz2xovp84b4vha3a40",
|
|
client_name="Plex Web",
|
|
client_version="4.133.0",
|
|
client_platform="Chrome",
|
|
device_name="Linux",
|
|
)
|
|
|
|
res = s.activities.get_server_activities()
|
|
|
|
if res.object is not None:
|
|
# handle response
|
|
pass
|
|
|
|
```
|
|
|
|
### Parameters
|
|
|
|
| Parameter | Type | Required | Description |
|
|
| ------------------------------------------------------------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------- |
|
|
| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.md) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. |
|
|
|
|
### Response
|
|
|
|
**[operations.GetServerActivitiesResponse](../../models/operations/getserveractivitiesresponse.md)**
|
|
|
|
### Errors
|
|
|
|
| Error Object | Status Code | Content Type |
|
|
| -------------------------------------- | -------------------------------------- | -------------------------------------- |
|
|
| errors.GetServerActivitiesBadRequest | 400 | application/json |
|
|
| errors.GetServerActivitiesUnauthorized | 401 | application/json |
|
|
| errors.SDKError | 4xx-5xx | */* |
|
|
|
|
|
|
## cancel_server_activities
|
|
|
|
Cancel Server Activities
|
|
|
|
### Example Usage
|
|
|
|
```python
|
|
from plex_api_client import PlexAPI
|
|
|
|
s = PlexAPI(
|
|
access_token="<YOUR_API_KEY_HERE>",
|
|
client_id="gcgzw5rz2xovp84b4vha3a40",
|
|
client_name="Plex Web",
|
|
client_version="4.133.0",
|
|
client_platform="Chrome",
|
|
device_name="Linux",
|
|
)
|
|
|
|
res = s.activities.cancel_server_activities(activity_uuid="25b71ed5-0f9d-461c-baa7-d404e9e10d3e")
|
|
|
|
if res is not None:
|
|
# handle response
|
|
pass
|
|
|
|
```
|
|
|
|
### Parameters
|
|
|
|
| Parameter | Type | Required | Description | Example |
|
|
| ------------------------------------------------------------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------- |
|
|
| `activity_uuid` | *str* | :heavy_check_mark: | The UUID of the activity to cancel. | 25b71ed5-0f9d-461c-baa7-d404e9e10d3e |
|
|
| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.md) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. | |
|
|
|
|
### Response
|
|
|
|
**[operations.CancelServerActivitiesResponse](../../models/operations/cancelserveractivitiesresponse.md)**
|
|
|
|
### Errors
|
|
|
|
| Error Object | Status Code | Content Type |
|
|
| ----------------------------------------- | ----------------------------------------- | ----------------------------------------- |
|
|
| errors.CancelServerActivitiesBadRequest | 400 | application/json |
|
|
| errors.CancelServerActivitiesUnauthorized | 401 | application/json |
|
|
| errors.SDKError | 4xx-5xx | */* |
|