mirror of
https://github.com/LukeHagar/plexjava.git
synced 2025-12-06 20:47:45 +00:00
Updater
(updater())
Overview
This describes the API for searching and applying updates to the Plex Media Server. Updates to the status can be observed via the Event API.
Available Operations
- getUpdateStatus - Querying status of updates
- checkForUpdates - Checking for updates
- applyUpdates - Apply Updates
getUpdateStatus
Querying status of updates
Example Usage
package hello.world;
import dev.plexapi.sdk.PlexAPI;
import dev.plexapi.sdk.models.errors.SDKError;
import dev.plexapi.sdk.models.operations.GetUpdateStatusResponse;
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();
GetUpdateStatusResponse res = sdk.updater().getUpdateStatus()
.call();
if (res.object().isPresent()) {
// handle response
}
} catch (dev.plexapi.sdk.models.errors.GetUpdateStatusBadRequest e) {
// handle exception
throw e;
} catch (dev.plexapi.sdk.models.errors.GetUpdateStatusUnauthorized e) {
// handle exception
throw e;
} catch (SDKError e) {
// handle exception
throw e;
} catch (Exception e) {
// handle exception
throw e;
}
}
}
Response
Errors
| Error Object | Status Code | Content Type |
|---|---|---|
| models/errors/GetUpdateStatusBadRequest | 400 | application/json |
| models/errors/GetUpdateStatusUnauthorized | 401 | application/json |
| models/errors/SDKError | 4xx-5xx | */* |
checkForUpdates
Checking for updates
Example Usage
package hello.world;
import dev.plexapi.sdk.PlexAPI;
import dev.plexapi.sdk.models.errors.SDKError;
import dev.plexapi.sdk.models.operations.CheckForUpdatesResponse;
import dev.plexapi.sdk.models.operations.Download;
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();
CheckForUpdatesResponse res = sdk.updater().checkForUpdates()
.download(Download.ONE)
.call();
// handle response
} catch (dev.plexapi.sdk.models.errors.CheckForUpdatesBadRequest e) {
// handle exception
throw e;
} catch (dev.plexapi.sdk.models.errors.CheckForUpdatesUnauthorized 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 |
|---|---|---|---|---|
download |
Optional | ➖ | Indicate that you want to start download any updates found. | 1 |
Response
Errors
| Error Object | Status Code | Content Type |
|---|---|---|
| models/errors/CheckForUpdatesBadRequest | 400 | application/json |
| models/errors/CheckForUpdatesUnauthorized | 401 | application/json |
| models/errors/SDKError | 4xx-5xx | */* |
applyUpdates
Note that these two parameters are effectively mutually exclusive. The tonight parameter takes precedence and skip will be ignored if tonight is also passed
Example Usage
package hello.world;
import dev.plexapi.sdk.PlexAPI;
import dev.plexapi.sdk.models.errors.SDKError;
import dev.plexapi.sdk.models.operations.ApplyUpdatesResponse;
import dev.plexapi.sdk.models.operations.Skip;
import dev.plexapi.sdk.models.operations.Tonight;
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();
ApplyUpdatesResponse res = sdk.updater().applyUpdates()
.tonight(Tonight.ONE)
.skip(Skip.ONE)
.call();
// handle response
} catch (dev.plexapi.sdk.models.errors.ApplyUpdatesBadRequest e) {
// handle exception
throw e;
} catch (dev.plexapi.sdk.models.errors.ApplyUpdatesUnauthorized 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 |
|---|---|---|---|---|
tonight |
Optional | ➖ | Indicate that you want the update to run during the next Butler execution. Omitting this or setting it to false indicates that the update should install | 1 |
skip |
Optional | ➖ | Indicate that the latest version should be marked as skipped. The [Release] entry for this version will have the state set to skipped. |
1 |
Response
Errors
| Error Object | Status Code | Content Type |
|---|---|---|
| models/errors/ApplyUpdatesBadRequest | 400 | application/json |
| models/errors/ApplyUpdatesUnauthorized | 401 | application/json |
| models/errors/SDKError | 4xx-5xx | */* |