Files
plexphp/docs/sdks/updater/README.md

8.4 KiB
Raw Blame History

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

Example Usage

declare(strict_types=1);

require 'vendor/autoload.php';

use LukeHagar\Plex_API;
use LukeHagar\Plex_API\Models\Components;

$security = new Components\Security();
$security->accessToken = '<YOUR_API_KEY_HERE>';

$sdk = Plex_API\PlexAPI::builder()
    ->setXPlexClientIdentifier('Postman')
    ->setSecurity($security)->build();

try {
    $response = $sdk->updater->getUpdateStatus();

    if ($response->object !== null) {
        // handle response
    }
} catch (Throwable $e) {
    // handle exception
}

Response

?Operations\GetUpdateStatusResponse

Errors

Error Object Status Code Content Type
Errors\GetUpdateStatusResponseBody 401 application/json
LukeHagar\Plex_API\Models\Errors.SDKException 4xx-5xx /

checkForUpdates

Checking for updates

Example Usage

declare(strict_types=1);

require 'vendor/autoload.php';

use LukeHagar\Plex_API;
use LukeHagar\Plex_API\Models\Components;
use LukeHagar\Plex_API\Models\Operations;

$security = new Components\Security();
$security->accessToken = '<YOUR_API_KEY_HERE>';

$sdk = Plex_API\PlexAPI::builder()
    ->setXPlexClientIdentifier('Postman')
    ->setSecurity($security)->build();

try {

    $response = $sdk->updater->checkForUpdates(Operations\Download::One);

    if ($response->statusCode === 200) {
        // handle response
    }
} catch (Throwable $e) {
    // handle exception
}

Parameters

Parameter Type Required Description Example
download Operations\Download Indicate that you want to start download any updates found. 1

Response

?Operations\CheckForUpdatesResponse

Errors

Error Object Status Code Content Type
Errors\CheckForUpdatesResponseBody 401 application/json
LukeHagar\Plex_API\Models\Errors.SDKException 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

declare(strict_types=1);

require 'vendor/autoload.php';

use LukeHagar\Plex_API;
use LukeHagar\Plex_API\Models\Components;
use LukeHagar\Plex_API\Models\Operations;

$security = new Components\Security();
$security->accessToken = '<YOUR_API_KEY_HERE>';

$sdk = Plex_API\PlexAPI::builder()
    ->setXPlexClientIdentifier('Postman')
    ->setSecurity($security)->build();

try {

    $response = $sdk->updater->applyUpdates(Operations\Tonight::One, Operations\Skip::Zero);

    if ($response->statusCode === 200) {
        // handle response
    }
} catch (Throwable $e) {
    // handle exception
}

Parameters

Parameter Type Required Description Example
tonight Operations\Tonight 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 Operations\Skip Indicate that the latest version should be marked as skipped. The entry for this version will have the state set to skipped. 1

Response

?Operations\ApplyUpdatesResponse

Errors

Error Object Status Code Content Type
Errors\ApplyUpdatesResponseBody 401 application/json
LukeHagar\Plex_API\Models\Errors.SDKException 4xx-5xx /