diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock
index 47ceb9f0..fa2f9ff0 100755
--- a/.speakeasy/gen.lock
+++ b/.speakeasy/gen.lock
@@ -1,12 +1,12 @@
lockVersion: 2.0.0
id: 1732900d-e173-47c1-a90d-d45182eb35d9
management:
- docChecksum: 1ee2e5413af07e886e33659b9b269dd5
+ docChecksum: 23094f3a9fe02710a8628ad5456f5d42
docVersion: 0.0.3
speakeasyVersion: 1.406.0
generationVersion: 2.429.0
- releaseVersion: 0.8.0
- configChecksum: c0c94b0c04fc6858e1ced149989e0cf6
+ releaseVersion: 0.9.0
+ configChecksum: 870175070f35ff1b0f848e5e0d3ef934
repoURL: https://github.com/LukeHagar/plexjava.git
published: true
features:
@@ -27,7 +27,6 @@ features:
methodServerURLs: 2.82.1
nameOverrides: 2.81.3
nullables: 0.1.0
- retries: 0.1.1
sdkHooks: 0.1.0
generatedFiles:
- .gitattributes
@@ -2798,7 +2797,7 @@ examples:
speakeasy-default-get-token-details:
responses:
"200":
- application/json: {"adsConsent": true, "adsConsentReminderAt": "2019-08-24T14:15:22Z", "adsConsentSetAt": "2019-08-24T14:15:22Z", "anonymous": false, "authToken": "CxoUzBTSV5hsxjTpFKaf", "backupCodesCreated": false, "confirmed": false, "country": "US", "email": "username@email.com", "emailOnlyAuth": false, "experimentalFeatures": false, "friendlyName": "friendlyUsername", "entitlements": ["[]"], "guest": false, "hasPassword": true, "home": false, "homeAdmin": false, "homeSize": 1, "id": 13692262, "joinedAt": 1556281940, "locale": null, "mailingListActive": false, "mailingListStatus": "active", "maxHomeSize": 15, "pin": "string", "profile": {"autoSelectAudio": true, "defaultAudioLanguage": "ja", "defaultSubtitleLanguage": "en", "autoSelectSubtitle": 1, "defaultSubtitleAccessibility": 1, "defaultSubtitleForced": 1, "watchedIndicator": 1, "mediaReviewsVisibility": 1}, "protected": false, "rememberExpiresAt": 1556281940, "restricted": false, "roles": ["string"], "scrobbleTypes": "", "services": [{"identifier": "metadata-dev", "endpoint": "https://epg.provider.plex.tv", "token": "DjoMtqFAGRL1uVtCyF1dKIorTbShJeqv", "secret": "string", "status": "online"}], "subscription": {"features": ["Android - Dolby Vision"], "active": true, "subscribedAt": "2021-04-12T18:21:12Z", "status": "Inactive", "paymentService": "string", "plan": "string"}, "subscriptionDescription": "string", "subscriptions": [{"features": ["Android - Dolby Vision"], "active": true, "subscribedAt": "2021-04-12T18:21:12Z", "status": "Inactive", "paymentService": "string", "plan": "string"}], "thumb": "https://plex.tv/users/a4f43c1ebfde43a5/avatar?c=8372075101", "title": "UsernameTitle", "twoFactorEnabled": false, "username": "Username", "uuid": "dae343c1f45beb4f", "attributionPartner": null}
+ application/json: {"adsConsent": true, "adsConsentReminderAt": 1556281940, "adsConsentSetAt": 1556281940, "anonymous": false, "authToken": "CxoUzBTSV5hsxjTpFKaf", "backupCodesCreated": false, "confirmed": false, "country": "US", "email": "username@email.com", "emailOnlyAuth": false, "experimentalFeatures": false, "friendlyName": "friendlyUsername", "entitlements": ["[]"], "guest": false, "hasPassword": true, "home": false, "homeAdmin": false, "homeSize": 1, "id": 13692262, "joinedAt": 1556281940, "locale": null, "mailingListActive": false, "mailingListStatus": "active", "maxHomeSize": 15, "pin": "string", "profile": {"autoSelectAudio": true, "defaultAudioLanguage": "ja", "defaultSubtitleLanguage": "en", "autoSelectSubtitle": 1, "defaultSubtitleAccessibility": 1, "defaultSubtitleForced": 1, "watchedIndicator": 1, "mediaReviewsVisibility": 1}, "protected": false, "rememberExpiresAt": 1556281940, "restricted": false, "roles": ["string"], "scrobbleTypes": "", "services": [{"identifier": "metadata-dev", "endpoint": "https://epg.provider.plex.tv", "token": "DjoMtqFAGRL1uVtCyF1dKIorTbShJeqv", "secret": "string", "status": "online"}], "subscription": {"features": ["Android - Dolby Vision"], "active": true, "subscribedAt": "2021-04-12T18:21:12Z", "status": "Inactive", "paymentService": "string", "plan": "string"}, "subscriptionDescription": "string", "subscriptions": [{"features": ["Android - Dolby Vision"], "active": true, "subscribedAt": "2021-04-12T18:21:12Z", "status": "Inactive", "paymentService": "string", "plan": "string"}], "thumb": "https://plex.tv/users/a4f43c1ebfde43a5/avatar?c=8372075101", "title": "UsernameTitle", "twoFactorEnabled": false, "username": "Username", "uuid": "dae343c1f45beb4f", "attributionPartner": null}
"400":
application/json: {"errors": []}
"401":
diff --git a/.speakeasy/gen.yaml b/.speakeasy/gen.yaml
index a0b0ee84..2c558fbc 100644
--- a/.speakeasy/gen.yaml
+++ b/.speakeasy/gen.yaml
@@ -12,7 +12,7 @@ generation:
auth:
oAuth2ClientCredentialsEnabled: true
java:
- version: 0.8.0
+ version: 0.9.0
additionalDependencies: []
additionalPlugins: []
artifactID: plexapi
diff --git a/.speakeasy/workflow.lock b/.speakeasy/workflow.lock
index 144a51e5..e9c167b6 100644
--- a/.speakeasy/workflow.lock
+++ b/.speakeasy/workflow.lock
@@ -8,8 +8,8 @@ sources:
- latest
plexapi:
sourceNamespace: plexapi
- sourceRevisionDigest: sha256:c6ab8f13847c7cdc4ab3752f517164d7da08266726255aa0d614b1eaea66fb0e
- sourceBlobDigest: sha256:64c7694915a0828aeb256d10d2fa0ea477681785b818916b6681be8cc5ffb93b
+ sourceRevisionDigest: sha256:790c7c67b0edef8c35ed69943d43e9c5bda385414c06f9c90410f93f546e5e4f
+ sourceBlobDigest: sha256:3e48471b7e058840fc598ccd75b2cbf8187961c7e625fe7b606555ce9a9bf109
tags:
- latest
- main
@@ -17,10 +17,10 @@ targets:
plexjava:
source: plexapi
sourceNamespace: plexapi
- sourceRevisionDigest: sha256:c6ab8f13847c7cdc4ab3752f517164d7da08266726255aa0d614b1eaea66fb0e
- sourceBlobDigest: sha256:64c7694915a0828aeb256d10d2fa0ea477681785b818916b6681be8cc5ffb93b
+ sourceRevisionDigest: sha256:790c7c67b0edef8c35ed69943d43e9c5bda385414c06f9c90410f93f546e5e4f
+ sourceBlobDigest: sha256:3e48471b7e058840fc598ccd75b2cbf8187961c7e625fe7b606555ce9a9bf109
codeSamplesNamespace: code-samples-java-plexjava
- codeSamplesRevisionDigest: sha256:46ccc091bbcaf0f056953e6349cd4c115250f9fc4359e7a23f6364979e2be555
+ codeSamplesRevisionDigest: sha256:1be6f3e64a42e2f5a878957fcaa19df7ee718649f6503954dad2c4a934e4eed3
workflow:
workflowVersion: 1.0.0
speakeasyVersion: latest
diff --git a/README.md b/README.md
index 36115ff3..fb0e3cb1 100644
--- a/README.md
+++ b/README.md
@@ -45,7 +45,6 @@ The following SDKs are generated from the OpenAPI Specification. They are automa
* [SDK Installation](#sdk-installation)
* [SDK Example Usage](#sdk-example-usage)
* [Available Resources and Operations](#available-resources-and-operations)
-* [Retries](#retries)
* [Error Handling](#error-handling)
* [Server Selection](#server-selection)
* [Authentication](#authentication)
@@ -62,7 +61,7 @@ The samples below show how a published SDK artifact is used:
Gradle:
```groovy
-implementation 'dev.plexapi:plexapi:0.8.0'
+implementation 'dev.plexapi:plexapi:0.9.0'
```
Maven:
@@ -70,7 +69,7 @@ Maven:
dev.plexapi
plexapi
- 0.8.0
+ 0.9.0
```
@@ -261,104 +260,6 @@ public class Application {
-
-## Retries
-
-Some of the endpoints in this SDK support retries. If you use the SDK without any configuration, it will fall back to the default retry strategy provided by the API. However, the default retry strategy can be overridden on a per-operation basis, or across the entire SDK.
-
-To change the default retry strategy for a single API call, you can provide a `RetryConfig` object through the `retryConfig` builder method:
-```java
-package hello.world;
-
-import dev.plexapi.sdk.PlexAPI;
-import dev.plexapi.sdk.models.errors.GetServerCapabilitiesBadRequest;
-import dev.plexapi.sdk.models.errors.GetServerCapabilitiesUnauthorized;
-import dev.plexapi.sdk.models.operations.GetServerCapabilitiesResponse;
-import dev.plexapi.sdk.utils.BackoffStrategy;
-import dev.plexapi.sdk.utils.RetryConfig;
-import java.lang.Exception;
-import java.util.concurrent.TimeUnit;
-
-public class Application {
-
- public static void main(String[] args) throws GetServerCapabilitiesBadRequest, GetServerCapabilitiesUnauthorized, Exception {
-
- PlexAPI sdk = PlexAPI.builder()
- .accessToken("")
- .clientID("3381b62b-9ab7-4e37-827b-203e9809eb58")
- .clientName("Plex for Roku")
- .clientVersion("2.4.1")
- .platform("Roku")
- .deviceNickname("Roku 3")
- .build();
-
- GetServerCapabilitiesResponse res = sdk.server().getServerCapabilities()
- .retryConfig(RetryConfig.builder()
- .backoff(BackoffStrategy.builder()
- .initialInterval(1L, TimeUnit.MILLISECONDS)
- .maxInterval(50L, TimeUnit.MILLISECONDS)
- .maxElapsedTime(1000L, TimeUnit.MILLISECONDS)
- .baseFactor(1.1)
- .jitterFactor(0.15)
- .retryConnectError(false)
- .build())
- .build())
- .call();
-
- if (res.object().isPresent()) {
- // handle response
- }
- }
-}
-```
-
-If you'd like to override the default retry strategy for all operations that support retries, you can provide a configuration at SDK initialization:
-```java
-package hello.world;
-
-import dev.plexapi.sdk.PlexAPI;
-import dev.plexapi.sdk.models.errors.GetServerCapabilitiesBadRequest;
-import dev.plexapi.sdk.models.errors.GetServerCapabilitiesUnauthorized;
-import dev.plexapi.sdk.models.operations.GetServerCapabilitiesResponse;
-import dev.plexapi.sdk.utils.BackoffStrategy;
-import dev.plexapi.sdk.utils.RetryConfig;
-import java.lang.Exception;
-import java.util.concurrent.TimeUnit;
-
-public class Application {
-
- public static void main(String[] args) throws GetServerCapabilitiesBadRequest, GetServerCapabilitiesUnauthorized, Exception {
-
- PlexAPI sdk = PlexAPI.builder()
- .retryConfig(RetryConfig.builder()
- .backoff(BackoffStrategy.builder()
- .initialInterval(1L, TimeUnit.MILLISECONDS)
- .maxInterval(50L, TimeUnit.MILLISECONDS)
- .maxElapsedTime(1000L, TimeUnit.MILLISECONDS)
- .baseFactor(1.1)
- .jitterFactor(0.15)
- .retryConnectError(false)
- .build())
- .build())
- .accessToken("")
- .clientID("3381b62b-9ab7-4e37-827b-203e9809eb58")
- .clientName("Plex for Roku")
- .clientVersion("2.4.1")
- .platform("Roku")
- .deviceNickname("Roku 3")
- .build();
-
- GetServerCapabilitiesResponse res = sdk.server().getServerCapabilities()
- .call();
-
- if (res.object().isPresent()) {
- // handle response
- }
- }
-}
-```
-
-
## Error Handling
diff --git a/RELEASES.md b/RELEASES.md
index 576699a1..56a3bc7a 100644
--- a/RELEASES.md
+++ b/RELEASES.md
@@ -148,4 +148,14 @@ Based on:
### Generated
- [java v0.8.0] .
### Releases
-- [Maven Central v0.8.0] https://central.sonatype.com/artifact/dev.plexapi/plexapi/0.8.0 - .
\ No newline at end of file
+- [Maven Central v0.8.0] https://central.sonatype.com/artifact/dev.plexapi/plexapi/0.8.0 - .
+
+## 2024-10-04 00:25:27
+### Changes
+Based on:
+- OpenAPI Doc
+- Speakeasy CLI 1.406.0 (2.429.0) https://github.com/speakeasy-api/speakeasy
+### Generated
+- [java v0.9.0] .
+### Releases
+- [Maven Central v0.9.0] https://central.sonatype.com/artifact/dev.plexapi/plexapi/0.9.0 - .
\ No newline at end of file
diff --git a/build.gradle b/build.gradle
index c03c82e9..9039d4c9 100644
--- a/build.gradle
+++ b/build.gradle
@@ -63,7 +63,7 @@ tasks.withType(Javadoc) {
}
group = "dev.plexapi"
-version = "0.8.0"
+version = "0.9.0"
sourcesJar {
archiveBaseName = "plexapi"
@@ -101,7 +101,7 @@ publishing {
maven(MavenPublication) {
groupId = 'dev.plexapi'
artifactId = 'plexapi'
- version = '0.8.0'
+ version = '0.9.0'
from components.java
diff --git a/docs/models/operations/GetLibraryItemsMediaContainer.md b/docs/models/operations/GetLibraryItemsMediaContainer.md
index 8bc8472f..a2083415 100644
--- a/docs/models/operations/GetLibraryItemsMediaContainer.md
+++ b/docs/models/operations/GetLibraryItemsMediaContainer.md
@@ -29,5 +29,5 @@ The Meta object is only included in the response if the `includeMeta` parameter
| `viewGroup` | *String* | :heavy_check_mark: | N/A | movie |
| `viewMode` | *Optional* | :heavy_minus_sign: | N/A | 65592 |
| `mixedParents` | *Optional* | :heavy_minus_sign: | N/A | true |
-| `metadata` | List<[GetLibraryItemsMetadata](../../models/operations/GetLibraryItemsMetadata.md)> | :heavy_check_mark: | N/A | |
+| `metadata` | List<[GetLibraryItemsMetadata](../../models/operations/GetLibraryItemsMetadata.md)> | :heavy_minus_sign: | N/A | |
| `meta` | [Optional](../../models/operations/GetLibraryItemsMeta.md) | :heavy_minus_sign: | The Meta object is only included in the response if the `includeMeta` parameter is set to `1`.
| |
\ No newline at end of file
diff --git a/docs/models/operations/GetTokenDetailsResponse.md b/docs/models/operations/GetTokenDetailsResponse.md
index e460fa74..751ec58b 100644
--- a/docs/models/operations/GetTokenDetailsResponse.md
+++ b/docs/models/operations/GetTokenDetailsResponse.md
@@ -3,9 +3,9 @@
## Fields
-| Field | Type | Required | Description | Example |
-| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| `contentType` | *String* | :heavy_check_mark: | HTTP response content type for this operation | |
-| `statusCode` | *int* | :heavy_check_mark: | HTTP response status code for this operation | |
-| `rawResponse` | [HttpResponse](https://docs.oracle.com/en/java/javase/11/docs/api/java.net.http/java/net/http/HttpResponse.html) | :heavy_check_mark: | Raw HTTP response; suitable for custom response parsing | |
-| `userPlexAccount` | [Optional](../../models/operations/GetTokenDetailsUserPlexAccount.md) | :heavy_minus_sign: | Logged in user details | {
"adsConsent": true,
"adsConsentReminderAt": "2019-08-24T14:15:22Z",
"adsConsentSetAt": "2019-08-24T14:15:22Z",
"anonymous": false,
"authToken": "CxoUzBTSV5hsxjTpFKaf",
"backupCodesCreated": false,
"confirmed": false,
"country": "US",
"email": "username@email.com",
"emailOnlyAuth": false,
"experimentalFeatures": false,
"friendlyName": "friendlyUsername",
"entitlements": [],
"guest": false,
"hasPassword": true,
"home": false,
"homeAdmin": false,
"homeSize": 1,
"id": 13692262,
"joinedAt": 1721154902,
"locale": null,
"mailingListActive": false,
"mailingListStatus": "subscribed",
"maxHomeSize": 15,
"pastSubscriptions": [
{
"id": "string",
"mode": "string",
"renewsAt": "string",
"endsAt": "1556281940",
"canceled": "0",
"gracePeriod": "0",
"onHold": "0",
"canReactivate": "0",
"canUpgrade": "0",
"canDowngrade": "0",
"canConvert": "0",
"type": "plexpass",
"transfer": "string",
"state": "ended",
"billing": [
{
"internalPaymentMethod": "string",
"paymentMethodId": "string"
}
]
}
],
"pin": "string",
"profile": [
{
"autoSelectAudio": true,
"defaultAudioLanguage": "ja",
"defaultSubtitleLanguage": "en",
"autoSelectSubtitle": 1,
"defaultSubtitleAccessibility": 1,
"defaultSubtitleForced": 0,
"watchedIndicator": 1,
"mediaReviewsVisibility": 0
}
],
"protected": false,
"rememberExpiresAt": 1722364046,
"restricted": false,
"roles": [
"string"
],
"scrobbleTypes": "",
"services": [
{
"identifier": "metadata-dev",
"endpoint": "https://epg.provider.plex.tv",
"token": "DjoMtqFAGRL1uVtCyF1dKIorTbShJeqv",
"secret": "string",
"status": "online"
}
],
"subscription": {
"features": [
"Android - Dolby Vision"
],
"active": true,
"subscribedAt": "2021-04-12T18:21:12Z",
"status": "Inactive",
"paymentService": "string",
"plan": "string"
},
"subscriptionDescription": "string",
"subscriptions": [
{
"features": [
"Android - Dolby Vision"
],
"active": true,
"subscribedAt": "2021-04-12T18:21:12Z",
"status": "Inactive",
"paymentService": "string",
"plan": "string"
}
],
"thumb": "https://plex.tv/users/a4f43c1ebfde43a5/avatar?c=8372075101",
"title": "UsernameTitle",
"trials": [
{}
],
"twoFactorEnabled": false,
"username": "Username",
"uuid": "dae343c1f45beb4f"
} |
\ No newline at end of file
+| Field | Type | Required | Description |
+| ----------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- |
+| `contentType` | *String* | :heavy_check_mark: | HTTP response content type for this operation |
+| `statusCode` | *int* | :heavy_check_mark: | HTTP response status code for this operation |
+| `rawResponse` | [HttpResponse](https://docs.oracle.com/en/java/javase/11/docs/api/java.net.http/java/net/http/HttpResponse.html) | :heavy_check_mark: | Raw HTTP response; suitable for custom response parsing |
+| `userPlexAccount` | [Optional](../../models/operations/GetTokenDetailsUserPlexAccount.md) | :heavy_minus_sign: | Logged in user details |
\ No newline at end of file
diff --git a/docs/models/operations/GetTokenDetailsUserPlexAccount.md b/docs/models/operations/GetTokenDetailsUserPlexAccount.md
index 6a9ee402..10f893c8 100644
--- a/docs/models/operations/GetTokenDetailsUserPlexAccount.md
+++ b/docs/models/operations/GetTokenDetailsUserPlexAccount.md
@@ -8,8 +8,8 @@ Logged in user details
| Field | Type | Required | Description | Example |
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `adsConsent` | *Optional* | :heavy_check_mark: | Unknown | |
-| `adsConsentReminderAt` | [OffsetDateTime](https://docs.oracle.com/javase/8/docs/api/java/time/OffsetDateTime.html) | :heavy_check_mark: | Unknown | |
-| `adsConsentSetAt` | [OffsetDateTime](https://docs.oracle.com/javase/8/docs/api/java/time/OffsetDateTime.html) | :heavy_check_mark: | Unknown | |
+| `adsConsentReminderAt` | *Optional* | :heavy_check_mark: | N/A | 1556281940 |
+| `adsConsentSetAt` | *Optional* | :heavy_check_mark: | N/A | 1556281940 |
| `anonymous` | *JsonNullable* | :heavy_minus_sign: | Unknown | |
| `authToken` | *String* | :heavy_check_mark: | The account token | CxoUzBTSV5hsxjTpFKaf |
| `backupCodesCreated` | *Optional* | :heavy_minus_sign: | If the two-factor authentication backup codes have been created | |
diff --git a/docs/models/operations/PostUsersSignInDataResponse.md b/docs/models/operations/PostUsersSignInDataResponse.md
index 80864095..1e9d52df 100644
--- a/docs/models/operations/PostUsersSignInDataResponse.md
+++ b/docs/models/operations/PostUsersSignInDataResponse.md
@@ -3,9 +3,9 @@
## Fields
-| Field | Type | Required | Description | Example |
-| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| `contentType` | *String* | :heavy_check_mark: | HTTP response content type for this operation | |
-| `statusCode` | *int* | :heavy_check_mark: | HTTP response status code for this operation | |
-| `rawResponse` | [HttpResponse](https://docs.oracle.com/en/java/javase/11/docs/api/java.net.http/java/net/http/HttpResponse.html) | :heavy_check_mark: | Raw HTTP response; suitable for custom response parsing | |
-| `userPlexAccount` | [Optional](../../models/operations/PostUsersSignInDataUserPlexAccount.md) | :heavy_minus_sign: | Returns the user account data with a valid auth token | {
"adsConsent": true,
"adsConsentReminderAt": "2019-08-24T14:15:22Z",
"adsConsentSetAt": "2019-08-24T14:15:22Z",
"anonymous": false,
"authToken": "CxoUzBTSV5hsxjTpFKaf",
"backupCodesCreated": false,
"confirmed": false,
"country": "US",
"email": "username@email.com",
"emailOnlyAuth": false,
"experimentalFeatures": false,
"friendlyName": "friendlyUsername",
"entitlements": [],
"guest": false,
"hasPassword": true,
"home": false,
"homeAdmin": false,
"homeSize": 1,
"id": 13692262,
"joinedAt": 1721154902,
"locale": null,
"mailingListActive": false,
"mailingListStatus": "subscribed",
"maxHomeSize": 15,
"pastSubscriptions": [
{
"id": "string",
"mode": "string",
"renewsAt": "string",
"endsAt": "1556281940",
"canceled": "0",
"gracePeriod": "0",
"onHold": "0",
"canReactivate": "0",
"canUpgrade": "0",
"canDowngrade": "0",
"canConvert": "0",
"type": "plexpass",
"transfer": "string",
"state": "ended",
"billing": [
{
"internalPaymentMethod": "string",
"paymentMethodId": "string"
}
]
}
],
"pin": "string",
"profile": [
{
"autoSelectAudio": true,
"defaultAudioLanguage": "ja",
"defaultSubtitleLanguage": "en",
"autoSelectSubtitle": 1,
"defaultSubtitleAccessibility": 1,
"defaultSubtitleForced": 0,
"watchedIndicator": 1,
"mediaReviewsVisibility": 0
}
],
"protected": false,
"rememberExpiresAt": 1722364046,
"restricted": false,
"roles": [
"string"
],
"scrobbleTypes": "",
"services": [
{
"identifier": "metadata-dev",
"endpoint": "https://epg.provider.plex.tv",
"token": "DjoMtqFAGRL1uVtCyF1dKIorTbShJeqv",
"secret": "string",
"status": "online"
}
],
"subscription": {
"features": [
"Android - Dolby Vision"
],
"active": true,
"subscribedAt": "2021-04-12T18:21:12Z",
"status": "Inactive",
"paymentService": "string",
"plan": "string"
},
"subscriptionDescription": "string",
"subscriptions": [
{
"features": [
"Android - Dolby Vision"
],
"active": true,
"subscribedAt": "2021-04-12T18:21:12Z",
"status": "Inactive",
"paymentService": "string",
"plan": "string"
}
],
"thumb": "https://plex.tv/users/a4f43c1ebfde43a5/avatar?c=8372075101",
"title": "UsernameTitle",
"trials": [
{}
],
"twoFactorEnabled": false,
"username": "Username",
"uuid": "dae343c1f45beb4f"
} |
\ No newline at end of file
+| Field | Type | Required | Description |
+| ----------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- |
+| `contentType` | *String* | :heavy_check_mark: | HTTP response content type for this operation |
+| `statusCode` | *int* | :heavy_check_mark: | HTTP response status code for this operation |
+| `rawResponse` | [HttpResponse](https://docs.oracle.com/en/java/javase/11/docs/api/java.net.http/java/net/http/HttpResponse.html) | :heavy_check_mark: | Raw HTTP response; suitable for custom response parsing |
+| `userPlexAccount` | [Optional](../../models/operations/PostUsersSignInDataUserPlexAccount.md) | :heavy_minus_sign: | Returns the user account data with a valid auth token |
\ No newline at end of file
diff --git a/docs/models/operations/PostUsersSignInDataUserPlexAccount.md b/docs/models/operations/PostUsersSignInDataUserPlexAccount.md
index decd690b..c788e1e0 100644
--- a/docs/models/operations/PostUsersSignInDataUserPlexAccount.md
+++ b/docs/models/operations/PostUsersSignInDataUserPlexAccount.md
@@ -8,8 +8,8 @@ Returns the user account data with a valid auth token
| Field | Type | Required | Description | Example |
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `adsConsent` | *Optional* | :heavy_check_mark: | Unknown | |
-| `adsConsentReminderAt` | [OffsetDateTime](https://docs.oracle.com/javase/8/docs/api/java/time/OffsetDateTime.html) | :heavy_check_mark: | Unknown | |
-| `adsConsentSetAt` | [OffsetDateTime](https://docs.oracle.com/javase/8/docs/api/java/time/OffsetDateTime.html) | :heavy_check_mark: | Unknown | |
+| `adsConsentReminderAt` | *Optional* | :heavy_check_mark: | N/A | 1556281940 |
+| `adsConsentSetAt` | *Optional* | :heavy_check_mark: | N/A | 1556281940 |
| `anonymous` | *JsonNullable* | :heavy_minus_sign: | Unknown | |
| `authToken` | *String* | :heavy_check_mark: | The account token | CxoUzBTSV5hsxjTpFKaf |
| `backupCodesCreated` | *Optional* | :heavy_minus_sign: | If the two-factor authentication backup codes have been created | |
diff --git a/src/main/java/dev/plexapi/sdk/Activities.java b/src/main/java/dev/plexapi/sdk/Activities.java
index 8f1a52c2..aada74ce 100644
--- a/src/main/java/dev/plexapi/sdk/Activities.java
+++ b/src/main/java/dev/plexapi/sdk/Activities.java
@@ -17,27 +17,19 @@ import dev.plexapi.sdk.models.operations.GetServerActivitiesRequestBuilder;
import dev.plexapi.sdk.models.operations.GetServerActivitiesResponse;
import dev.plexapi.sdk.models.operations.GetServerActivitiesResponseBody;
import dev.plexapi.sdk.models.operations.SDKMethodInterfaces.*;
-import dev.plexapi.sdk.utils.BackoffStrategy;
import dev.plexapi.sdk.utils.HTTPClient;
import dev.plexapi.sdk.utils.HTTPRequest;
import dev.plexapi.sdk.utils.Hook.AfterErrorContextImpl;
import dev.plexapi.sdk.utils.Hook.AfterSuccessContextImpl;
import dev.plexapi.sdk.utils.Hook.BeforeRequestContextImpl;
-import dev.plexapi.sdk.utils.Options;
-import dev.plexapi.sdk.utils.Retries.NonRetryableException;
-import dev.plexapi.sdk.utils.Retries;
-import dev.plexapi.sdk.utils.RetryConfig;
import dev.plexapi.sdk.utils.Utils;
import java.io.InputStream;
import java.lang.Exception;
import java.lang.String;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
-import java.util.ArrayList;
-import java.util.Arrays;
import java.util.List;
-import java.util.Optional;
-import java.util.concurrent.TimeUnit;
+import java.util.Optional;
/**
* 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.
@@ -76,22 +68,6 @@ public class Activities implements
* @throws Exception if the API call fails
*/
public GetServerActivitiesResponse getServerActivitiesDirect() throws Exception {
- return getServerActivities(Optional.empty());
- }
-
- /**
- * Get Server Activities
- * Get Server Activities
- * @param options additional options
- * @return The response from the API call
- * @throws Exception if the API call fails
- */
- public GetServerActivitiesResponse getServerActivities(
- Optional options) throws Exception {
-
- if (options.isPresent()) {
- options.get().validate(Arrays.asList(Options.Option.RETRY_CONFIG));
- }
String _baseUrl = Utils.templateUrl(
this.sdkConfiguration.serverUrl, this.sdkConfiguration.getServerVariableDefaults());
String _url = Utils.generateURL(
@@ -107,62 +83,45 @@ public class Activities implements
this.sdkConfiguration.securitySource.getSecurity());
HTTPClient _client = this.sdkConfiguration.defaultClient;
- HTTPRequest _finalReq = _req;
- RetryConfig _retryConfig;
- if (options.isPresent() && options.get().retryConfig().isPresent()) {
- _retryConfig = options.get().retryConfig().get();
- } else if (this.sdkConfiguration.retryConfig.isPresent()) {
- _retryConfig = this.sdkConfiguration.retryConfig.get();
- } else {
- _retryConfig = RetryConfig.builder()
- .backoff(BackoffStrategy.builder()
- .initialInterval(500, TimeUnit.MILLISECONDS)
- .maxInterval(60000, TimeUnit.MILLISECONDS)
- .baseFactor((double)(1.5))
- .maxElapsedTime(3600000, TimeUnit.MILLISECONDS)
- .retryConnectError(true)
- .build())
- .build();
+ HttpRequest _r =
+ sdkConfiguration.hooks()
+ .beforeRequest(
+ new BeforeRequestContextImpl(
+ "getServerActivities",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ _req.build());
+ HttpResponse _httpRes;
+ try {
+ _httpRes = _client.send(_r);
+ if (Utils.statusCodeMatches(_httpRes.statusCode(), "400", "401", "4XX", "5XX")) {
+ _httpRes = sdkConfiguration.hooks()
+ .afterError(
+ new AfterErrorContextImpl(
+ "getServerActivities",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ Optional.of(_httpRes),
+ Optional.empty());
+ } else {
+ _httpRes = sdkConfiguration.hooks()
+ .afterSuccess(
+ new AfterSuccessContextImpl(
+ "getServerActivities",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ _httpRes);
+ }
+ } catch (Exception _e) {
+ _httpRes = sdkConfiguration.hooks()
+ .afterError(
+ new AfterErrorContextImpl(
+ "getServerActivities",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ Optional.empty(),
+ Optional.of(_e));
}
- List _statusCodes = new ArrayList<>();
- _statusCodes.add("5XX");
- Retries _retries = Retries.builder()
- .action(() -> {
- HttpRequest _r = null;
- try {
- _r = sdkConfiguration.hooks()
- .beforeRequest(
- new BeforeRequestContextImpl(
- "getServerActivities",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- _finalReq.build());
- } catch (Exception _e) {
- throw new NonRetryableException(_e);
- }
- try {
- return _client.send(_r);
- } catch (Exception _e) {
- return sdkConfiguration.hooks()
- .afterError(
- new AfterErrorContextImpl(
- "getServerActivities",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- Optional.empty(),
- Optional.of(_e));
- }
- })
- .retryConfig(_retryConfig)
- .statusCodes(_statusCodes)
- .build();
- HttpResponse _httpRes = sdkConfiguration.hooks()
- .afterSuccess(
- new AfterSuccessContextImpl(
- "getServerActivities",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- _retries.run());
String _contentType = _httpRes
.headers()
.firstValue("Content-Type")
@@ -258,24 +217,6 @@ public class Activities implements
*/
public CancelServerActivitiesResponse cancelServerActivities(
String activityUUID) throws Exception {
- return cancelServerActivities(activityUUID, Optional.empty());
- }
-
- /**
- * Cancel Server Activities
- * Cancel Server Activities
- * @param activityUUID The UUID of the activity to cancel.
- * @param options additional options
- * @return The response from the API call
- * @throws Exception if the API call fails
- */
- public CancelServerActivitiesResponse cancelServerActivities(
- String activityUUID,
- Optional options) throws Exception {
-
- if (options.isPresent()) {
- options.get().validate(Arrays.asList(Options.Option.RETRY_CONFIG));
- }
CancelServerActivitiesRequest request =
CancelServerActivitiesRequest
.builder()
@@ -299,62 +240,45 @@ public class Activities implements
this.sdkConfiguration.securitySource.getSecurity());
HTTPClient _client = this.sdkConfiguration.defaultClient;
- HTTPRequest _finalReq = _req;
- RetryConfig _retryConfig;
- if (options.isPresent() && options.get().retryConfig().isPresent()) {
- _retryConfig = options.get().retryConfig().get();
- } else if (this.sdkConfiguration.retryConfig.isPresent()) {
- _retryConfig = this.sdkConfiguration.retryConfig.get();
- } else {
- _retryConfig = RetryConfig.builder()
- .backoff(BackoffStrategy.builder()
- .initialInterval(500, TimeUnit.MILLISECONDS)
- .maxInterval(60000, TimeUnit.MILLISECONDS)
- .baseFactor((double)(1.5))
- .maxElapsedTime(3600000, TimeUnit.MILLISECONDS)
- .retryConnectError(true)
- .build())
- .build();
+ HttpRequest _r =
+ sdkConfiguration.hooks()
+ .beforeRequest(
+ new BeforeRequestContextImpl(
+ "cancelServerActivities",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ _req.build());
+ HttpResponse _httpRes;
+ try {
+ _httpRes = _client.send(_r);
+ if (Utils.statusCodeMatches(_httpRes.statusCode(), "400", "401", "4XX", "5XX")) {
+ _httpRes = sdkConfiguration.hooks()
+ .afterError(
+ new AfterErrorContextImpl(
+ "cancelServerActivities",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ Optional.of(_httpRes),
+ Optional.empty());
+ } else {
+ _httpRes = sdkConfiguration.hooks()
+ .afterSuccess(
+ new AfterSuccessContextImpl(
+ "cancelServerActivities",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ _httpRes);
+ }
+ } catch (Exception _e) {
+ _httpRes = sdkConfiguration.hooks()
+ .afterError(
+ new AfterErrorContextImpl(
+ "cancelServerActivities",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ Optional.empty(),
+ Optional.of(_e));
}
- List _statusCodes = new ArrayList<>();
- _statusCodes.add("5XX");
- Retries _retries = Retries.builder()
- .action(() -> {
- HttpRequest _r = null;
- try {
- _r = sdkConfiguration.hooks()
- .beforeRequest(
- new BeforeRequestContextImpl(
- "cancelServerActivities",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- _finalReq.build());
- } catch (Exception _e) {
- throw new NonRetryableException(_e);
- }
- try {
- return _client.send(_r);
- } catch (Exception _e) {
- return sdkConfiguration.hooks()
- .afterError(
- new AfterErrorContextImpl(
- "cancelServerActivities",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- Optional.empty(),
- Optional.of(_e));
- }
- })
- .retryConfig(_retryConfig)
- .statusCodes(_statusCodes)
- .build();
- HttpResponse _httpRes = sdkConfiguration.hooks()
- .afterSuccess(
- new AfterSuccessContextImpl(
- "cancelServerActivities",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- _retries.run());
String _contentType = _httpRes
.headers()
.firstValue("Content-Type")
diff --git a/src/main/java/dev/plexapi/sdk/Authentication.java b/src/main/java/dev/plexapi/sdk/Authentication.java
index 8b64cccd..64cf5d7e 100644
--- a/src/main/java/dev/plexapi/sdk/Authentication.java
+++ b/src/main/java/dev/plexapi/sdk/Authentication.java
@@ -30,16 +30,11 @@ import dev.plexapi.sdk.models.operations.PostUsersSignInDataResponse;
import dev.plexapi.sdk.models.operations.PostUsersSignInDataUserPlexAccount;
import dev.plexapi.sdk.models.operations.SDKMethodInterfaces.*;
import dev.plexapi.sdk.models.operations.Scope;
-import dev.plexapi.sdk.utils.BackoffStrategy;
import dev.plexapi.sdk.utils.HTTPClient;
import dev.plexapi.sdk.utils.HTTPRequest;
import dev.plexapi.sdk.utils.Hook.AfterErrorContextImpl;
import dev.plexapi.sdk.utils.Hook.AfterSuccessContextImpl;
import dev.plexapi.sdk.utils.Hook.BeforeRequestContextImpl;
-import dev.plexapi.sdk.utils.Options;
-import dev.plexapi.sdk.utils.Retries.NonRetryableException;
-import dev.plexapi.sdk.utils.Retries;
-import dev.plexapi.sdk.utils.RetryConfig;
import dev.plexapi.sdk.utils.SerializedBody;
import dev.plexapi.sdk.utils.Utils.JsonShape;
import dev.plexapi.sdk.utils.Utils;
@@ -49,12 +44,9 @@ import java.lang.Object;
import java.lang.String;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
-import java.util.ArrayList;
-import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
-import java.util.Optional;
-import java.util.concurrent.TimeUnit;
+import java.util.Optional;
/**
* API Calls regarding authentication for Plex Media Server
@@ -109,27 +101,6 @@ public class Authentication implements
public GetTransientTokenResponse getTransientToken(
GetTransientTokenQueryParamType type,
Scope scope) throws Exception {
- return getTransientToken(type, scope, Optional.empty());
- }
-
- /**
- * Get a Transient Token
- * This endpoint provides the caller with a temporary token with the same access level as the caller's token. These tokens are valid for up to 48 hours and are destroyed if the server instance is restarted.
- *
- * @param type `delegation` - This is the only supported `type` parameter.
- * @param scope `all` - This is the only supported `scope` parameter.
- * @param options additional options
- * @return The response from the API call
- * @throws Exception if the API call fails
- */
- public GetTransientTokenResponse getTransientToken(
- GetTransientTokenQueryParamType type,
- Scope scope,
- Optional options) throws Exception {
-
- if (options.isPresent()) {
- options.get().validate(Arrays.asList(Options.Option.RETRY_CONFIG));
- }
GetTransientTokenRequest request =
GetTransientTokenRequest
.builder()
@@ -157,62 +128,45 @@ public class Authentication implements
this.sdkConfiguration.securitySource.getSecurity());
HTTPClient _client = this.sdkConfiguration.defaultClient;
- HTTPRequest _finalReq = _req;
- RetryConfig _retryConfig;
- if (options.isPresent() && options.get().retryConfig().isPresent()) {
- _retryConfig = options.get().retryConfig().get();
- } else if (this.sdkConfiguration.retryConfig.isPresent()) {
- _retryConfig = this.sdkConfiguration.retryConfig.get();
- } else {
- _retryConfig = RetryConfig.builder()
- .backoff(BackoffStrategy.builder()
- .initialInterval(500, TimeUnit.MILLISECONDS)
- .maxInterval(60000, TimeUnit.MILLISECONDS)
- .baseFactor((double)(1.5))
- .maxElapsedTime(3600000, TimeUnit.MILLISECONDS)
- .retryConnectError(true)
- .build())
- .build();
+ HttpRequest _r =
+ sdkConfiguration.hooks()
+ .beforeRequest(
+ new BeforeRequestContextImpl(
+ "getTransientToken",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ _req.build());
+ HttpResponse _httpRes;
+ try {
+ _httpRes = _client.send(_r);
+ if (Utils.statusCodeMatches(_httpRes.statusCode(), "400", "401", "4XX", "5XX")) {
+ _httpRes = sdkConfiguration.hooks()
+ .afterError(
+ new AfterErrorContextImpl(
+ "getTransientToken",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ Optional.of(_httpRes),
+ Optional.empty());
+ } else {
+ _httpRes = sdkConfiguration.hooks()
+ .afterSuccess(
+ new AfterSuccessContextImpl(
+ "getTransientToken",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ _httpRes);
+ }
+ } catch (Exception _e) {
+ _httpRes = sdkConfiguration.hooks()
+ .afterError(
+ new AfterErrorContextImpl(
+ "getTransientToken",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ Optional.empty(),
+ Optional.of(_e));
}
- List _statusCodes = new ArrayList<>();
- _statusCodes.add("5XX");
- Retries _retries = Retries.builder()
- .action(() -> {
- HttpRequest _r = null;
- try {
- _r = sdkConfiguration.hooks()
- .beforeRequest(
- new BeforeRequestContextImpl(
- "getTransientToken",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- _finalReq.build());
- } catch (Exception _e) {
- throw new NonRetryableException(_e);
- }
- try {
- return _client.send(_r);
- } catch (Exception _e) {
- return sdkConfiguration.hooks()
- .afterError(
- new AfterErrorContextImpl(
- "getTransientToken",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- Optional.empty(),
- Optional.of(_e));
- }
- })
- .retryConfig(_retryConfig)
- .statusCodes(_statusCodes)
- .build();
- HttpResponse _httpRes = sdkConfiguration.hooks()
- .afterSuccess(
- new AfterSuccessContextImpl(
- "getTransientToken",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- _retries.run());
String _contentType = _httpRes
.headers()
.firstValue("Content-Type")
@@ -301,26 +255,6 @@ public class Authentication implements
*/
public GetSourceConnectionInformationResponse getSourceConnectionInformation(
String source) throws Exception {
- return getSourceConnectionInformation(source, Optional.empty());
- }
-
- /**
- * Get Source Connection Information
- * If a caller requires connection details and a transient token for a source that is known to the server, for example a cloud media provider or shared PMS, then this endpoint can be called. This endpoint is only accessible with either an admin token or a valid transient token generated from an admin token.
- * Note: requires Plex Media Server >= 1.15.4.
- *
- * @param source The source identifier with an included prefix.
- * @param options additional options
- * @return The response from the API call
- * @throws Exception if the API call fails
- */
- public GetSourceConnectionInformationResponse getSourceConnectionInformation(
- String source,
- Optional options) throws Exception {
-
- if (options.isPresent()) {
- options.get().validate(Arrays.asList(Options.Option.RETRY_CONFIG));
- }
GetSourceConnectionInformationRequest request =
GetSourceConnectionInformationRequest
.builder()
@@ -347,62 +281,45 @@ public class Authentication implements
this.sdkConfiguration.securitySource.getSecurity());
HTTPClient _client = this.sdkConfiguration.defaultClient;
- HTTPRequest _finalReq = _req;
- RetryConfig _retryConfig;
- if (options.isPresent() && options.get().retryConfig().isPresent()) {
- _retryConfig = options.get().retryConfig().get();
- } else if (this.sdkConfiguration.retryConfig.isPresent()) {
- _retryConfig = this.sdkConfiguration.retryConfig.get();
- } else {
- _retryConfig = RetryConfig.builder()
- .backoff(BackoffStrategy.builder()
- .initialInterval(500, TimeUnit.MILLISECONDS)
- .maxInterval(60000, TimeUnit.MILLISECONDS)
- .baseFactor((double)(1.5))
- .maxElapsedTime(3600000, TimeUnit.MILLISECONDS)
- .retryConnectError(true)
- .build())
- .build();
+ HttpRequest _r =
+ sdkConfiguration.hooks()
+ .beforeRequest(
+ new BeforeRequestContextImpl(
+ "getSourceConnectionInformation",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ _req.build());
+ HttpResponse _httpRes;
+ try {
+ _httpRes = _client.send(_r);
+ if (Utils.statusCodeMatches(_httpRes.statusCode(), "400", "401", "4XX", "5XX")) {
+ _httpRes = sdkConfiguration.hooks()
+ .afterError(
+ new AfterErrorContextImpl(
+ "getSourceConnectionInformation",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ Optional.of(_httpRes),
+ Optional.empty());
+ } else {
+ _httpRes = sdkConfiguration.hooks()
+ .afterSuccess(
+ new AfterSuccessContextImpl(
+ "getSourceConnectionInformation",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ _httpRes);
+ }
+ } catch (Exception _e) {
+ _httpRes = sdkConfiguration.hooks()
+ .afterError(
+ new AfterErrorContextImpl(
+ "getSourceConnectionInformation",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ Optional.empty(),
+ Optional.of(_e));
}
- List _statusCodes = new ArrayList<>();
- _statusCodes.add("5XX");
- Retries _retries = Retries.builder()
- .action(() -> {
- HttpRequest _r = null;
- try {
- _r = sdkConfiguration.hooks()
- .beforeRequest(
- new BeforeRequestContextImpl(
- "getSourceConnectionInformation",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- _finalReq.build());
- } catch (Exception _e) {
- throw new NonRetryableException(_e);
- }
- try {
- return _client.send(_r);
- } catch (Exception _e) {
- return sdkConfiguration.hooks()
- .afterError(
- new AfterErrorContextImpl(
- "getSourceConnectionInformation",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- Optional.empty(),
- Optional.of(_e));
- }
- })
- .retryConfig(_retryConfig)
- .statusCodes(_statusCodes)
- .build();
- HttpResponse _httpRes = sdkConfiguration.hooks()
- .afterSuccess(
- new AfterSuccessContextImpl(
- "getSourceConnectionInformation",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- _retries.run());
String _contentType = _httpRes
.headers()
.firstValue("Content-Type")
@@ -485,24 +402,18 @@ public class Authentication implements
* @throws Exception if the API call fails
*/
public GetTokenDetailsResponse getTokenDetailsDirect() throws Exception {
- return getTokenDetails(Optional.empty(), Optional.empty());
+ return getTokenDetails(Optional.empty());
}
/**
* Get Token Details
* Get the User data from the provided X-Plex-Token
* @param serverURL Overrides the server URL.
- * @param options additional options
* @return The response from the API call
* @throws Exception if the API call fails
*/
public GetTokenDetailsResponse getTokenDetails(
- Optional serverURL,
- Optional options) throws Exception {
-
- if (options.isPresent()) {
- options.get().validate(Arrays.asList(Options.Option.RETRY_CONFIG));
- }
+ Optional serverURL) throws Exception {
String _baseUrl = Utils.templateUrl(GET_TOKEN_DETAILS_SERVERS[0], new HashMap());
if (serverURL.isPresent() && !serverURL.get().isBlank()) {
_baseUrl = serverURL.get();
@@ -520,62 +431,45 @@ public class Authentication implements
this.sdkConfiguration.securitySource.getSecurity());
HTTPClient _client = this.sdkConfiguration.defaultClient;
- HTTPRequest _finalReq = _req;
- RetryConfig _retryConfig;
- if (options.isPresent() && options.get().retryConfig().isPresent()) {
- _retryConfig = options.get().retryConfig().get();
- } else if (this.sdkConfiguration.retryConfig.isPresent()) {
- _retryConfig = this.sdkConfiguration.retryConfig.get();
- } else {
- _retryConfig = RetryConfig.builder()
- .backoff(BackoffStrategy.builder()
- .initialInterval(500, TimeUnit.MILLISECONDS)
- .maxInterval(60000, TimeUnit.MILLISECONDS)
- .baseFactor((double)(1.5))
- .maxElapsedTime(3600000, TimeUnit.MILLISECONDS)
- .retryConnectError(true)
- .build())
- .build();
+ HttpRequest _r =
+ sdkConfiguration.hooks()
+ .beforeRequest(
+ new BeforeRequestContextImpl(
+ "getTokenDetails",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ _req.build());
+ HttpResponse _httpRes;
+ try {
+ _httpRes = _client.send(_r);
+ if (Utils.statusCodeMatches(_httpRes.statusCode(), "400", "401", "4XX", "5XX")) {
+ _httpRes = sdkConfiguration.hooks()
+ .afterError(
+ new AfterErrorContextImpl(
+ "getTokenDetails",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ Optional.of(_httpRes),
+ Optional.empty());
+ } else {
+ _httpRes = sdkConfiguration.hooks()
+ .afterSuccess(
+ new AfterSuccessContextImpl(
+ "getTokenDetails",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ _httpRes);
+ }
+ } catch (Exception _e) {
+ _httpRes = sdkConfiguration.hooks()
+ .afterError(
+ new AfterErrorContextImpl(
+ "getTokenDetails",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ Optional.empty(),
+ Optional.of(_e));
}
- List _statusCodes = new ArrayList<>();
- _statusCodes.add("5XX");
- Retries _retries = Retries.builder()
- .action(() -> {
- HttpRequest _r = null;
- try {
- _r = sdkConfiguration.hooks()
- .beforeRequest(
- new BeforeRequestContextImpl(
- "getTokenDetails",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- _finalReq.build());
- } catch (Exception _e) {
- throw new NonRetryableException(_e);
- }
- try {
- return _client.send(_r);
- } catch (Exception _e) {
- return sdkConfiguration.hooks()
- .afterError(
- new AfterErrorContextImpl(
- "getTokenDetails",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- Optional.empty(),
- Optional.of(_e));
- }
- })
- .retryConfig(_retryConfig)
- .statusCodes(_statusCodes)
- .build();
- HttpResponse _httpRes = sdkConfiguration.hooks()
- .afterSuccess(
- new AfterSuccessContextImpl(
- "getTokenDetails",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- _retries.run());
String _contentType = _httpRes
.headers()
.firstValue("Content-Type")
@@ -671,7 +565,7 @@ public class Authentication implements
*/
public PostUsersSignInDataResponse postUsersSignInData(
PostUsersSignInDataRequest request) throws Exception {
- return postUsersSignInData(request, Optional.empty(), Optional.empty());
+ return postUsersSignInData(request, Optional.empty());
}
/**
@@ -679,18 +573,12 @@ public class Authentication implements
* Sign in user with username and password and return user data with Plex authentication token
* @param request The request object containing all of the parameters for the API call.
* @param serverURL Overrides the server URL.
- * @param options additional options
* @return The response from the API call
* @throws Exception if the API call fails
*/
public PostUsersSignInDataResponse postUsersSignInData(
PostUsersSignInDataRequest request,
- Optional serverURL,
- Optional options) throws Exception {
-
- if (options.isPresent()) {
- options.get().validate(Arrays.asList(Options.Option.RETRY_CONFIG));
- }
+ Optional serverURL) throws Exception {
String _baseUrl = Utils.templateUrl(POST_USERS_SIGN_IN_DATA_SERVERS[0], new HashMap());
if (serverURL.isPresent() && !serverURL.get().isBlank()) {
_baseUrl = serverURL.get();
@@ -716,62 +604,45 @@ public class Authentication implements
_req.addHeaders(Utils.getHeadersFromMetadata(request, this.sdkConfiguration.globals));
HTTPClient _client = this.sdkConfiguration.defaultClient;
- HTTPRequest _finalReq = _req;
- RetryConfig _retryConfig;
- if (options.isPresent() && options.get().retryConfig().isPresent()) {
- _retryConfig = options.get().retryConfig().get();
- } else if (this.sdkConfiguration.retryConfig.isPresent()) {
- _retryConfig = this.sdkConfiguration.retryConfig.get();
- } else {
- _retryConfig = RetryConfig.builder()
- .backoff(BackoffStrategy.builder()
- .initialInterval(500, TimeUnit.MILLISECONDS)
- .maxInterval(60000, TimeUnit.MILLISECONDS)
- .baseFactor((double)(1.5))
- .maxElapsedTime(3600000, TimeUnit.MILLISECONDS)
- .retryConnectError(true)
- .build())
- .build();
+ HttpRequest _r =
+ sdkConfiguration.hooks()
+ .beforeRequest(
+ new BeforeRequestContextImpl(
+ "post-users-sign-in-data",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ _req.build());
+ HttpResponse _httpRes;
+ try {
+ _httpRes = _client.send(_r);
+ if (Utils.statusCodeMatches(_httpRes.statusCode(), "400", "401", "4XX", "5XX")) {
+ _httpRes = sdkConfiguration.hooks()
+ .afterError(
+ new AfterErrorContextImpl(
+ "post-users-sign-in-data",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ Optional.of(_httpRes),
+ Optional.empty());
+ } else {
+ _httpRes = sdkConfiguration.hooks()
+ .afterSuccess(
+ new AfterSuccessContextImpl(
+ "post-users-sign-in-data",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ _httpRes);
+ }
+ } catch (Exception _e) {
+ _httpRes = sdkConfiguration.hooks()
+ .afterError(
+ new AfterErrorContextImpl(
+ "post-users-sign-in-data",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ Optional.empty(),
+ Optional.of(_e));
}
- List _statusCodes = new ArrayList<>();
- _statusCodes.add("5XX");
- Retries _retries = Retries.builder()
- .action(() -> {
- HttpRequest _r = null;
- try {
- _r = sdkConfiguration.hooks()
- .beforeRequest(
- new BeforeRequestContextImpl(
- "post-users-sign-in-data",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- _finalReq.build());
- } catch (Exception _e) {
- throw new NonRetryableException(_e);
- }
- try {
- return _client.send(_r);
- } catch (Exception _e) {
- return sdkConfiguration.hooks()
- .afterError(
- new AfterErrorContextImpl(
- "post-users-sign-in-data",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- Optional.empty(),
- Optional.of(_e));
- }
- })
- .retryConfig(_retryConfig)
- .statusCodes(_statusCodes)
- .build();
- HttpResponse _httpRes = sdkConfiguration.hooks()
- .afterSuccess(
- new AfterSuccessContextImpl(
- "post-users-sign-in-data",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- _retries.run());
String _contentType = _httpRes
.headers()
.firstValue("Content-Type")
diff --git a/src/main/java/dev/plexapi/sdk/Butler.java b/src/main/java/dev/plexapi/sdk/Butler.java
index 2be0ad4b..03491621 100644
--- a/src/main/java/dev/plexapi/sdk/Butler.java
+++ b/src/main/java/dev/plexapi/sdk/Butler.java
@@ -32,27 +32,19 @@ import dev.plexapi.sdk.models.operations.StopTaskRequest;
import dev.plexapi.sdk.models.operations.StopTaskRequestBuilder;
import dev.plexapi.sdk.models.operations.StopTaskResponse;
import dev.plexapi.sdk.models.operations.TaskName;
-import dev.plexapi.sdk.utils.BackoffStrategy;
import dev.plexapi.sdk.utils.HTTPClient;
import dev.plexapi.sdk.utils.HTTPRequest;
import dev.plexapi.sdk.utils.Hook.AfterErrorContextImpl;
import dev.plexapi.sdk.utils.Hook.AfterSuccessContextImpl;
import dev.plexapi.sdk.utils.Hook.BeforeRequestContextImpl;
-import dev.plexapi.sdk.utils.Options;
-import dev.plexapi.sdk.utils.Retries.NonRetryableException;
-import dev.plexapi.sdk.utils.Retries;
-import dev.plexapi.sdk.utils.RetryConfig;
import dev.plexapi.sdk.utils.Utils;
import java.io.InputStream;
import java.lang.Exception;
import java.lang.String;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
-import java.util.ArrayList;
-import java.util.Arrays;
import java.util.List;
-import java.util.Optional;
-import java.util.concurrent.TimeUnit;
+import java.util.Optional;
/**
* Butler is the task manager of the Plex Media Server Ecosystem.
@@ -88,22 +80,6 @@ public class Butler implements
* @throws Exception if the API call fails
*/
public GetButlerTasksResponse getButlerTasksDirect() throws Exception {
- return getButlerTasks(Optional.empty());
- }
-
- /**
- * Get Butler tasks
- * Returns a list of butler tasks
- * @param options additional options
- * @return The response from the API call
- * @throws Exception if the API call fails
- */
- public GetButlerTasksResponse getButlerTasks(
- Optional options) throws Exception {
-
- if (options.isPresent()) {
- options.get().validate(Arrays.asList(Options.Option.RETRY_CONFIG));
- }
String _baseUrl = Utils.templateUrl(
this.sdkConfiguration.serverUrl, this.sdkConfiguration.getServerVariableDefaults());
String _url = Utils.generateURL(
@@ -119,62 +95,45 @@ public class Butler implements
this.sdkConfiguration.securitySource.getSecurity());
HTTPClient _client = this.sdkConfiguration.defaultClient;
- HTTPRequest _finalReq = _req;
- RetryConfig _retryConfig;
- if (options.isPresent() && options.get().retryConfig().isPresent()) {
- _retryConfig = options.get().retryConfig().get();
- } else if (this.sdkConfiguration.retryConfig.isPresent()) {
- _retryConfig = this.sdkConfiguration.retryConfig.get();
- } else {
- _retryConfig = RetryConfig.builder()
- .backoff(BackoffStrategy.builder()
- .initialInterval(500, TimeUnit.MILLISECONDS)
- .maxInterval(60000, TimeUnit.MILLISECONDS)
- .baseFactor((double)(1.5))
- .maxElapsedTime(3600000, TimeUnit.MILLISECONDS)
- .retryConnectError(true)
- .build())
- .build();
+ HttpRequest _r =
+ sdkConfiguration.hooks()
+ .beforeRequest(
+ new BeforeRequestContextImpl(
+ "getButlerTasks",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ _req.build());
+ HttpResponse _httpRes;
+ try {
+ _httpRes = _client.send(_r);
+ if (Utils.statusCodeMatches(_httpRes.statusCode(), "400", "401", "4XX", "5XX")) {
+ _httpRes = sdkConfiguration.hooks()
+ .afterError(
+ new AfterErrorContextImpl(
+ "getButlerTasks",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ Optional.of(_httpRes),
+ Optional.empty());
+ } else {
+ _httpRes = sdkConfiguration.hooks()
+ .afterSuccess(
+ new AfterSuccessContextImpl(
+ "getButlerTasks",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ _httpRes);
+ }
+ } catch (Exception _e) {
+ _httpRes = sdkConfiguration.hooks()
+ .afterError(
+ new AfterErrorContextImpl(
+ "getButlerTasks",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ Optional.empty(),
+ Optional.of(_e));
}
- List _statusCodes = new ArrayList<>();
- _statusCodes.add("5XX");
- Retries _retries = Retries.builder()
- .action(() -> {
- HttpRequest _r = null;
- try {
- _r = sdkConfiguration.hooks()
- .beforeRequest(
- new BeforeRequestContextImpl(
- "getButlerTasks",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- _finalReq.build());
- } catch (Exception _e) {
- throw new NonRetryableException(_e);
- }
- try {
- return _client.send(_r);
- } catch (Exception _e) {
- return sdkConfiguration.hooks()
- .afterError(
- new AfterErrorContextImpl(
- "getButlerTasks",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- Optional.empty(),
- Optional.of(_e));
- }
- })
- .retryConfig(_retryConfig)
- .statusCodes(_statusCodes)
- .build();
- HttpResponse _httpRes = sdkConfiguration.hooks()
- .afterSuccess(
- new AfterSuccessContextImpl(
- "getButlerTasks",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- _retries.run());
String _contentType = _httpRes
.headers()
.firstValue("Content-Type")
@@ -278,27 +237,6 @@ public class Butler implements
* @throws Exception if the API call fails
*/
public StartAllTasksResponse startAllTasksDirect() throws Exception {
- return startAllTasks(Optional.empty());
- }
-
- /**
- * Start all Butler tasks
- * This endpoint will attempt to start all Butler tasks that are enabled in the settings. Butler tasks normally run automatically during a time window configured on the server's Settings page but can be manually started using this endpoint. Tasks will run with the following criteria:
- * 1. Any tasks not scheduled to run on the current day will be skipped.
- * 2. If a task is configured to run at a random time during the configured window and we are outside that window, the task will start immediately.
- * 3. If a task is configured to run at a random time during the configured window and we are within that window, the task will be scheduled at a random time within the window.
- * 4. If we are outside the configured window, the task will start immediately.
- *
- * @param options additional options
- * @return The response from the API call
- * @throws Exception if the API call fails
- */
- public StartAllTasksResponse startAllTasks(
- Optional options) throws Exception {
-
- if (options.isPresent()) {
- options.get().validate(Arrays.asList(Options.Option.RETRY_CONFIG));
- }
String _baseUrl = Utils.templateUrl(
this.sdkConfiguration.serverUrl, this.sdkConfiguration.getServerVariableDefaults());
String _url = Utils.generateURL(
@@ -314,62 +252,45 @@ public class Butler implements
this.sdkConfiguration.securitySource.getSecurity());
HTTPClient _client = this.sdkConfiguration.defaultClient;
- HTTPRequest _finalReq = _req;
- RetryConfig _retryConfig;
- if (options.isPresent() && options.get().retryConfig().isPresent()) {
- _retryConfig = options.get().retryConfig().get();
- } else if (this.sdkConfiguration.retryConfig.isPresent()) {
- _retryConfig = this.sdkConfiguration.retryConfig.get();
- } else {
- _retryConfig = RetryConfig.builder()
- .backoff(BackoffStrategy.builder()
- .initialInterval(500, TimeUnit.MILLISECONDS)
- .maxInterval(60000, TimeUnit.MILLISECONDS)
- .baseFactor((double)(1.5))
- .maxElapsedTime(3600000, TimeUnit.MILLISECONDS)
- .retryConnectError(true)
- .build())
- .build();
+ HttpRequest _r =
+ sdkConfiguration.hooks()
+ .beforeRequest(
+ new BeforeRequestContextImpl(
+ "startAllTasks",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ _req.build());
+ HttpResponse _httpRes;
+ try {
+ _httpRes = _client.send(_r);
+ if (Utils.statusCodeMatches(_httpRes.statusCode(), "400", "401", "4XX", "5XX")) {
+ _httpRes = sdkConfiguration.hooks()
+ .afterError(
+ new AfterErrorContextImpl(
+ "startAllTasks",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ Optional.of(_httpRes),
+ Optional.empty());
+ } else {
+ _httpRes = sdkConfiguration.hooks()
+ .afterSuccess(
+ new AfterSuccessContextImpl(
+ "startAllTasks",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ _httpRes);
+ }
+ } catch (Exception _e) {
+ _httpRes = sdkConfiguration.hooks()
+ .afterError(
+ new AfterErrorContextImpl(
+ "startAllTasks",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ Optional.empty(),
+ Optional.of(_e));
}
- List _statusCodes = new ArrayList<>();
- _statusCodes.add("5XX");
- Retries _retries = Retries.builder()
- .action(() -> {
- HttpRequest _r = null;
- try {
- _r = sdkConfiguration.hooks()
- .beforeRequest(
- new BeforeRequestContextImpl(
- "startAllTasks",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- _finalReq.build());
- } catch (Exception _e) {
- throw new NonRetryableException(_e);
- }
- try {
- return _client.send(_r);
- } catch (Exception _e) {
- return sdkConfiguration.hooks()
- .afterError(
- new AfterErrorContextImpl(
- "startAllTasks",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- Optional.empty(),
- Optional.of(_e));
- }
- })
- .retryConfig(_retryConfig)
- .statusCodes(_statusCodes)
- .build();
- HttpResponse _httpRes = sdkConfiguration.hooks()
- .afterSuccess(
- new AfterSuccessContextImpl(
- "startAllTasks",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- _retries.run());
String _contentType = _httpRes
.headers()
.firstValue("Content-Type")
@@ -454,23 +375,6 @@ public class Butler implements
* @throws Exception if the API call fails
*/
public StopAllTasksResponse stopAllTasksDirect() throws Exception {
- return stopAllTasks(Optional.empty());
- }
-
- /**
- * Stop all Butler tasks
- * This endpoint will stop all currently running tasks and remove any scheduled tasks from the queue.
- *
- * @param options additional options
- * @return The response from the API call
- * @throws Exception if the API call fails
- */
- public StopAllTasksResponse stopAllTasks(
- Optional options) throws Exception {
-
- if (options.isPresent()) {
- options.get().validate(Arrays.asList(Options.Option.RETRY_CONFIG));
- }
String _baseUrl = Utils.templateUrl(
this.sdkConfiguration.serverUrl, this.sdkConfiguration.getServerVariableDefaults());
String _url = Utils.generateURL(
@@ -486,62 +390,45 @@ public class Butler implements
this.sdkConfiguration.securitySource.getSecurity());
HTTPClient _client = this.sdkConfiguration.defaultClient;
- HTTPRequest _finalReq = _req;
- RetryConfig _retryConfig;
- if (options.isPresent() && options.get().retryConfig().isPresent()) {
- _retryConfig = options.get().retryConfig().get();
- } else if (this.sdkConfiguration.retryConfig.isPresent()) {
- _retryConfig = this.sdkConfiguration.retryConfig.get();
- } else {
- _retryConfig = RetryConfig.builder()
- .backoff(BackoffStrategy.builder()
- .initialInterval(500, TimeUnit.MILLISECONDS)
- .maxInterval(60000, TimeUnit.MILLISECONDS)
- .baseFactor((double)(1.5))
- .maxElapsedTime(3600000, TimeUnit.MILLISECONDS)
- .retryConnectError(true)
- .build())
- .build();
+ HttpRequest _r =
+ sdkConfiguration.hooks()
+ .beforeRequest(
+ new BeforeRequestContextImpl(
+ "stopAllTasks",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ _req.build());
+ HttpResponse _httpRes;
+ try {
+ _httpRes = _client.send(_r);
+ if (Utils.statusCodeMatches(_httpRes.statusCode(), "400", "401", "4XX", "5XX")) {
+ _httpRes = sdkConfiguration.hooks()
+ .afterError(
+ new AfterErrorContextImpl(
+ "stopAllTasks",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ Optional.of(_httpRes),
+ Optional.empty());
+ } else {
+ _httpRes = sdkConfiguration.hooks()
+ .afterSuccess(
+ new AfterSuccessContextImpl(
+ "stopAllTasks",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ _httpRes);
+ }
+ } catch (Exception _e) {
+ _httpRes = sdkConfiguration.hooks()
+ .afterError(
+ new AfterErrorContextImpl(
+ "stopAllTasks",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ Optional.empty(),
+ Optional.of(_e));
}
- List _statusCodes = new ArrayList<>();
- _statusCodes.add("5XX");
- Retries _retries = Retries.builder()
- .action(() -> {
- HttpRequest _r = null;
- try {
- _r = sdkConfiguration.hooks()
- .beforeRequest(
- new BeforeRequestContextImpl(
- "stopAllTasks",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- _finalReq.build());
- } catch (Exception _e) {
- throw new NonRetryableException(_e);
- }
- try {
- return _client.send(_r);
- } catch (Exception _e) {
- return sdkConfiguration.hooks()
- .afterError(
- new AfterErrorContextImpl(
- "stopAllTasks",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- Optional.empty(),
- Optional.of(_e));
- }
- })
- .retryConfig(_retryConfig)
- .statusCodes(_statusCodes)
- .build();
- HttpResponse _httpRes = sdkConfiguration.hooks()
- .afterSuccess(
- new AfterSuccessContextImpl(
- "stopAllTasks",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- _retries.run());
String _contentType = _httpRes
.headers()
.firstValue("Content-Type")
@@ -636,29 +523,6 @@ public class Butler implements
*/
public StartTaskResponse startTask(
TaskName taskName) throws Exception {
- return startTask(taskName, Optional.empty());
- }
-
- /**
- * Start a single Butler task
- * This endpoint will attempt to start a single Butler task that is enabled in the settings. Butler tasks normally run automatically during a time window configured on the server's Settings page but can be manually started using this endpoint. Tasks will run with the following criteria:
- * 1. Any tasks not scheduled to run on the current day will be skipped.
- * 2. If a task is configured to run at a random time during the configured window and we are outside that window, the task will start immediately.
- * 3. If a task is configured to run at a random time during the configured window and we are within that window, the task will be scheduled at a random time within the window.
- * 4. If we are outside the configured window, the task will start immediately.
- *
- * @param taskName the name of the task to be started.
- * @param options additional options
- * @return The response from the API call
- * @throws Exception if the API call fails
- */
- public StartTaskResponse startTask(
- TaskName taskName,
- Optional options) throws Exception {
-
- if (options.isPresent()) {
- options.get().validate(Arrays.asList(Options.Option.RETRY_CONFIG));
- }
StartTaskRequest request =
StartTaskRequest
.builder()
@@ -682,62 +546,45 @@ public class Butler implements
this.sdkConfiguration.securitySource.getSecurity());
HTTPClient _client = this.sdkConfiguration.defaultClient;
- HTTPRequest _finalReq = _req;
- RetryConfig _retryConfig;
- if (options.isPresent() && options.get().retryConfig().isPresent()) {
- _retryConfig = options.get().retryConfig().get();
- } else if (this.sdkConfiguration.retryConfig.isPresent()) {
- _retryConfig = this.sdkConfiguration.retryConfig.get();
- } else {
- _retryConfig = RetryConfig.builder()
- .backoff(BackoffStrategy.builder()
- .initialInterval(500, TimeUnit.MILLISECONDS)
- .maxInterval(60000, TimeUnit.MILLISECONDS)
- .baseFactor((double)(1.5))
- .maxElapsedTime(3600000, TimeUnit.MILLISECONDS)
- .retryConnectError(true)
- .build())
- .build();
+ HttpRequest _r =
+ sdkConfiguration.hooks()
+ .beforeRequest(
+ new BeforeRequestContextImpl(
+ "startTask",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ _req.build());
+ HttpResponse _httpRes;
+ try {
+ _httpRes = _client.send(_r);
+ if (Utils.statusCodeMatches(_httpRes.statusCode(), "400", "401", "4XX", "5XX")) {
+ _httpRes = sdkConfiguration.hooks()
+ .afterError(
+ new AfterErrorContextImpl(
+ "startTask",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ Optional.of(_httpRes),
+ Optional.empty());
+ } else {
+ _httpRes = sdkConfiguration.hooks()
+ .afterSuccess(
+ new AfterSuccessContextImpl(
+ "startTask",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ _httpRes);
+ }
+ } catch (Exception _e) {
+ _httpRes = sdkConfiguration.hooks()
+ .afterError(
+ new AfterErrorContextImpl(
+ "startTask",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ Optional.empty(),
+ Optional.of(_e));
}
- List _statusCodes = new ArrayList<>();
- _statusCodes.add("5XX");
- Retries _retries = Retries.builder()
- .action(() -> {
- HttpRequest _r = null;
- try {
- _r = sdkConfiguration.hooks()
- .beforeRequest(
- new BeforeRequestContextImpl(
- "startTask",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- _finalReq.build());
- } catch (Exception _e) {
- throw new NonRetryableException(_e);
- }
- try {
- return _client.send(_r);
- } catch (Exception _e) {
- return sdkConfiguration.hooks()
- .afterError(
- new AfterErrorContextImpl(
- "startTask",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- Optional.empty(),
- Optional.of(_e));
- }
- })
- .retryConfig(_retryConfig)
- .statusCodes(_statusCodes)
- .build();
- HttpResponse _httpRes = sdkConfiguration.hooks()
- .afterSuccess(
- new AfterSuccessContextImpl(
- "startTask",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- _retries.run());
String _contentType = _httpRes
.headers()
.firstValue("Content-Type")
@@ -824,25 +671,6 @@ public class Butler implements
*/
public StopTaskResponse stopTask(
PathParamTaskName taskName) throws Exception {
- return stopTask(taskName, Optional.empty());
- }
-
- /**
- * Stop a single Butler task
- * This endpoint will stop a currently running task by name, or remove it from the list of scheduled tasks if it exists. See the section above for a list of task names for this endpoint.
- *
- * @param taskName The name of the task to be started.
- * @param options additional options
- * @return The response from the API call
- * @throws Exception if the API call fails
- */
- public StopTaskResponse stopTask(
- PathParamTaskName taskName,
- Optional options) throws Exception {
-
- if (options.isPresent()) {
- options.get().validate(Arrays.asList(Options.Option.RETRY_CONFIG));
- }
StopTaskRequest request =
StopTaskRequest
.builder()
@@ -866,62 +694,45 @@ public class Butler implements
this.sdkConfiguration.securitySource.getSecurity());
HTTPClient _client = this.sdkConfiguration.defaultClient;
- HTTPRequest _finalReq = _req;
- RetryConfig _retryConfig;
- if (options.isPresent() && options.get().retryConfig().isPresent()) {
- _retryConfig = options.get().retryConfig().get();
- } else if (this.sdkConfiguration.retryConfig.isPresent()) {
- _retryConfig = this.sdkConfiguration.retryConfig.get();
- } else {
- _retryConfig = RetryConfig.builder()
- .backoff(BackoffStrategy.builder()
- .initialInterval(500, TimeUnit.MILLISECONDS)
- .maxInterval(60000, TimeUnit.MILLISECONDS)
- .baseFactor((double)(1.5))
- .maxElapsedTime(3600000, TimeUnit.MILLISECONDS)
- .retryConnectError(true)
- .build())
- .build();
+ HttpRequest _r =
+ sdkConfiguration.hooks()
+ .beforeRequest(
+ new BeforeRequestContextImpl(
+ "stopTask",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ _req.build());
+ HttpResponse _httpRes;
+ try {
+ _httpRes = _client.send(_r);
+ if (Utils.statusCodeMatches(_httpRes.statusCode(), "400", "401", "404", "4XX", "5XX")) {
+ _httpRes = sdkConfiguration.hooks()
+ .afterError(
+ new AfterErrorContextImpl(
+ "stopTask",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ Optional.of(_httpRes),
+ Optional.empty());
+ } else {
+ _httpRes = sdkConfiguration.hooks()
+ .afterSuccess(
+ new AfterSuccessContextImpl(
+ "stopTask",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ _httpRes);
+ }
+ } catch (Exception _e) {
+ _httpRes = sdkConfiguration.hooks()
+ .afterError(
+ new AfterErrorContextImpl(
+ "stopTask",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ Optional.empty(),
+ Optional.of(_e));
}
- List _statusCodes = new ArrayList<>();
- _statusCodes.add("5XX");
- Retries _retries = Retries.builder()
- .action(() -> {
- HttpRequest _r = null;
- try {
- _r = sdkConfiguration.hooks()
- .beforeRequest(
- new BeforeRequestContextImpl(
- "stopTask",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- _finalReq.build());
- } catch (Exception _e) {
- throw new NonRetryableException(_e);
- }
- try {
- return _client.send(_r);
- } catch (Exception _e) {
- return sdkConfiguration.hooks()
- .afterError(
- new AfterErrorContextImpl(
- "stopTask",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- Optional.empty(),
- Optional.of(_e));
- }
- })
- .retryConfig(_retryConfig)
- .statusCodes(_statusCodes)
- .build();
- HttpResponse _httpRes = sdkConfiguration.hooks()
- .afterSuccess(
- new AfterSuccessContextImpl(
- "stopTask",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- _retries.run());
String _contentType = _httpRes
.headers()
.firstValue("Content-Type")
diff --git a/src/main/java/dev/plexapi/sdk/Hubs.java b/src/main/java/dev/plexapi/sdk/Hubs.java
index 31f3ef86..43a2e0d7 100644
--- a/src/main/java/dev/plexapi/sdk/Hubs.java
+++ b/src/main/java/dev/plexapi/sdk/Hubs.java
@@ -25,16 +25,11 @@ import dev.plexapi.sdk.models.operations.GetRecentlyAddedResponseBody;
import dev.plexapi.sdk.models.operations.OnlyTransient;
import dev.plexapi.sdk.models.operations.QueryParamOnlyTransient;
import dev.plexapi.sdk.models.operations.SDKMethodInterfaces.*;
-import dev.plexapi.sdk.utils.BackoffStrategy;
import dev.plexapi.sdk.utils.HTTPClient;
import dev.plexapi.sdk.utils.HTTPRequest;
import dev.plexapi.sdk.utils.Hook.AfterErrorContextImpl;
import dev.plexapi.sdk.utils.Hook.AfterSuccessContextImpl;
import dev.plexapi.sdk.utils.Hook.BeforeRequestContextImpl;
-import dev.plexapi.sdk.utils.Options;
-import dev.plexapi.sdk.utils.Retries.NonRetryableException;
-import dev.plexapi.sdk.utils.Retries;
-import dev.plexapi.sdk.utils.RetryConfig;
import dev.plexapi.sdk.utils.Utils;
import java.io.InputStream;
import java.lang.Double;
@@ -42,11 +37,8 @@ import java.lang.Exception;
import java.lang.String;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
-import java.util.ArrayList;
-import java.util.Arrays;
import java.util.List;
-import java.util.Optional;
-import java.util.concurrent.TimeUnit;
+import java.util.Optional;
/**
* Hubs are a structured two-dimensional container for media, generally represented by multiple horizontal rows.
@@ -80,7 +72,7 @@ public class Hubs implements
* @throws Exception if the API call fails
*/
public GetGlobalHubsResponse getGlobalHubsDirect() throws Exception {
- return getGlobalHubs(Optional.empty(), Optional.empty(), Optional.empty());
+ return getGlobalHubs(Optional.empty(), Optional.empty());
}
/**
@@ -88,18 +80,12 @@ public class Hubs implements
* Get Global Hubs filtered by the parameters provided.
* @param count The number of items to return with each hub.
* @param onlyTransient Only return hubs which are "transient", meaning those which are prone to changing after media playback or addition (e.g. On Deck, or Recently Added).
- * @param options additional options
* @return The response from the API call
* @throws Exception if the API call fails
*/
public GetGlobalHubsResponse getGlobalHubs(
Optional count,
- Optional extends OnlyTransient> onlyTransient,
- Optional options) throws Exception {
-
- if (options.isPresent()) {
- options.get().validate(Arrays.asList(Options.Option.RETRY_CONFIG));
- }
+ Optional extends OnlyTransient> onlyTransient) throws Exception {
GetGlobalHubsRequest request =
GetGlobalHubsRequest
.builder()
@@ -127,62 +113,45 @@ public class Hubs implements
this.sdkConfiguration.securitySource.getSecurity());
HTTPClient _client = this.sdkConfiguration.defaultClient;
- HTTPRequest _finalReq = _req;
- RetryConfig _retryConfig;
- if (options.isPresent() && options.get().retryConfig().isPresent()) {
- _retryConfig = options.get().retryConfig().get();
- } else if (this.sdkConfiguration.retryConfig.isPresent()) {
- _retryConfig = this.sdkConfiguration.retryConfig.get();
- } else {
- _retryConfig = RetryConfig.builder()
- .backoff(BackoffStrategy.builder()
- .initialInterval(500, TimeUnit.MILLISECONDS)
- .maxInterval(60000, TimeUnit.MILLISECONDS)
- .baseFactor((double)(1.5))
- .maxElapsedTime(3600000, TimeUnit.MILLISECONDS)
- .retryConnectError(true)
- .build())
- .build();
+ HttpRequest _r =
+ sdkConfiguration.hooks()
+ .beforeRequest(
+ new BeforeRequestContextImpl(
+ "getGlobalHubs",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ _req.build());
+ HttpResponse _httpRes;
+ try {
+ _httpRes = _client.send(_r);
+ if (Utils.statusCodeMatches(_httpRes.statusCode(), "400", "401", "4XX", "5XX")) {
+ _httpRes = sdkConfiguration.hooks()
+ .afterError(
+ new AfterErrorContextImpl(
+ "getGlobalHubs",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ Optional.of(_httpRes),
+ Optional.empty());
+ } else {
+ _httpRes = sdkConfiguration.hooks()
+ .afterSuccess(
+ new AfterSuccessContextImpl(
+ "getGlobalHubs",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ _httpRes);
+ }
+ } catch (Exception _e) {
+ _httpRes = sdkConfiguration.hooks()
+ .afterError(
+ new AfterErrorContextImpl(
+ "getGlobalHubs",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ Optional.empty(),
+ Optional.of(_e));
}
- List _statusCodes = new ArrayList<>();
- _statusCodes.add("5XX");
- Retries _retries = Retries.builder()
- .action(() -> {
- HttpRequest _r = null;
- try {
- _r = sdkConfiguration.hooks()
- .beforeRequest(
- new BeforeRequestContextImpl(
- "getGlobalHubs",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- _finalReq.build());
- } catch (Exception _e) {
- throw new NonRetryableException(_e);
- }
- try {
- return _client.send(_r);
- } catch (Exception _e) {
- return sdkConfiguration.hooks()
- .afterError(
- new AfterErrorContextImpl(
- "getGlobalHubs",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- Optional.empty(),
- Optional.of(_e));
- }
- })
- .retryConfig(_retryConfig)
- .statusCodes(_statusCodes)
- .build();
- HttpResponse _httpRes = sdkConfiguration.hooks()
- .afterSuccess(
- new AfterSuccessContextImpl(
- "getGlobalHubs",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- _retries.run());
String _contentType = _httpRes
.headers()
.firstValue("Content-Type")
@@ -280,25 +249,6 @@ public class Hubs implements
*/
public GetRecentlyAddedResponse getRecentlyAdded(
GetRecentlyAddedRequest request) throws Exception {
- return getRecentlyAdded(request, Optional.empty());
- }
-
- /**
- * Get Recently Added
- * This endpoint will return the recently added content.
- *
- * @param request The request object containing all of the parameters for the API call.
- * @param options additional options
- * @return The response from the API call
- * @throws Exception if the API call fails
- */
- public GetRecentlyAddedResponse getRecentlyAdded(
- GetRecentlyAddedRequest request,
- Optional options) throws Exception {
-
- if (options.isPresent()) {
- options.get().validate(Arrays.asList(Options.Option.RETRY_CONFIG));
- }
String _baseUrl = Utils.templateUrl(
this.sdkConfiguration.serverUrl, this.sdkConfiguration.getServerVariableDefaults());
String _url = Utils.generateURL(
@@ -319,62 +269,45 @@ public class Hubs implements
this.sdkConfiguration.securitySource.getSecurity());
HTTPClient _client = this.sdkConfiguration.defaultClient;
- HTTPRequest _finalReq = _req;
- RetryConfig _retryConfig;
- if (options.isPresent() && options.get().retryConfig().isPresent()) {
- _retryConfig = options.get().retryConfig().get();
- } else if (this.sdkConfiguration.retryConfig.isPresent()) {
- _retryConfig = this.sdkConfiguration.retryConfig.get();
- } else {
- _retryConfig = RetryConfig.builder()
- .backoff(BackoffStrategy.builder()
- .initialInterval(500, TimeUnit.MILLISECONDS)
- .maxInterval(60000, TimeUnit.MILLISECONDS)
- .baseFactor((double)(1.5))
- .maxElapsedTime(3600000, TimeUnit.MILLISECONDS)
- .retryConnectError(true)
- .build())
- .build();
+ HttpRequest _r =
+ sdkConfiguration.hooks()
+ .beforeRequest(
+ new BeforeRequestContextImpl(
+ "get-recently-added",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ _req.build());
+ HttpResponse _httpRes;
+ try {
+ _httpRes = _client.send(_r);
+ if (Utils.statusCodeMatches(_httpRes.statusCode(), "400", "401", "4XX", "5XX")) {
+ _httpRes = sdkConfiguration.hooks()
+ .afterError(
+ new AfterErrorContextImpl(
+ "get-recently-added",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ Optional.of(_httpRes),
+ Optional.empty());
+ } else {
+ _httpRes = sdkConfiguration.hooks()
+ .afterSuccess(
+ new AfterSuccessContextImpl(
+ "get-recently-added",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ _httpRes);
+ }
+ } catch (Exception _e) {
+ _httpRes = sdkConfiguration.hooks()
+ .afterError(
+ new AfterErrorContextImpl(
+ "get-recently-added",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ Optional.empty(),
+ Optional.of(_e));
}
- List _statusCodes = new ArrayList<>();
- _statusCodes.add("5XX");
- Retries _retries = Retries.builder()
- .action(() -> {
- HttpRequest _r = null;
- try {
- _r = sdkConfiguration.hooks()
- .beforeRequest(
- new BeforeRequestContextImpl(
- "get-recently-added",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- _finalReq.build());
- } catch (Exception _e) {
- throw new NonRetryableException(_e);
- }
- try {
- return _client.send(_r);
- } catch (Exception _e) {
- return sdkConfiguration.hooks()
- .afterError(
- new AfterErrorContextImpl(
- "get-recently-added",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- Optional.empty(),
- Optional.of(_e));
- }
- })
- .retryConfig(_retryConfig)
- .statusCodes(_statusCodes)
- .build();
- HttpResponse _httpRes = sdkConfiguration.hooks()
- .afterSuccess(
- new AfterSuccessContextImpl(
- "get-recently-added",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- _retries.run());
String _contentType = _httpRes
.headers()
.firstValue("Content-Type")
@@ -440,7 +373,7 @@ public class Hubs implements
*/
public GetLibraryHubsResponse getLibraryHubs(
double sectionId) throws Exception {
- return getLibraryHubs(sectionId, Optional.empty(), Optional.empty(), Optional.empty());
+ return getLibraryHubs(sectionId, Optional.empty(), Optional.empty());
}
/**
@@ -450,19 +383,13 @@ public class Hubs implements
* @param sectionId the Id of the library to query
* @param count The number of items to return with each hub.
* @param onlyTransient Only return hubs which are "transient", meaning those which are prone to changing after media playback or addition (e.g. On Deck, or Recently Added).
- * @param options additional options
* @return The response from the API call
* @throws Exception if the API call fails
*/
public GetLibraryHubsResponse getLibraryHubs(
double sectionId,
Optional count,
- Optional extends QueryParamOnlyTransient> onlyTransient,
- Optional options) throws Exception {
-
- if (options.isPresent()) {
- options.get().validate(Arrays.asList(Options.Option.RETRY_CONFIG));
- }
+ Optional extends QueryParamOnlyTransient> onlyTransient) throws Exception {
GetLibraryHubsRequest request =
GetLibraryHubsRequest
.builder()
@@ -493,62 +420,45 @@ public class Hubs implements
this.sdkConfiguration.securitySource.getSecurity());
HTTPClient _client = this.sdkConfiguration.defaultClient;
- HTTPRequest _finalReq = _req;
- RetryConfig _retryConfig;
- if (options.isPresent() && options.get().retryConfig().isPresent()) {
- _retryConfig = options.get().retryConfig().get();
- } else if (this.sdkConfiguration.retryConfig.isPresent()) {
- _retryConfig = this.sdkConfiguration.retryConfig.get();
- } else {
- _retryConfig = RetryConfig.builder()
- .backoff(BackoffStrategy.builder()
- .initialInterval(500, TimeUnit.MILLISECONDS)
- .maxInterval(60000, TimeUnit.MILLISECONDS)
- .baseFactor((double)(1.5))
- .maxElapsedTime(3600000, TimeUnit.MILLISECONDS)
- .retryConnectError(true)
- .build())
- .build();
+ HttpRequest _r =
+ sdkConfiguration.hooks()
+ .beforeRequest(
+ new BeforeRequestContextImpl(
+ "getLibraryHubs",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ _req.build());
+ HttpResponse _httpRes;
+ try {
+ _httpRes = _client.send(_r);
+ if (Utils.statusCodeMatches(_httpRes.statusCode(), "400", "401", "4XX", "5XX")) {
+ _httpRes = sdkConfiguration.hooks()
+ .afterError(
+ new AfterErrorContextImpl(
+ "getLibraryHubs",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ Optional.of(_httpRes),
+ Optional.empty());
+ } else {
+ _httpRes = sdkConfiguration.hooks()
+ .afterSuccess(
+ new AfterSuccessContextImpl(
+ "getLibraryHubs",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ _httpRes);
+ }
+ } catch (Exception _e) {
+ _httpRes = sdkConfiguration.hooks()
+ .afterError(
+ new AfterErrorContextImpl(
+ "getLibraryHubs",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ Optional.empty(),
+ Optional.of(_e));
}
- List _statusCodes = new ArrayList<>();
- _statusCodes.add("5XX");
- Retries _retries = Retries.builder()
- .action(() -> {
- HttpRequest _r = null;
- try {
- _r = sdkConfiguration.hooks()
- .beforeRequest(
- new BeforeRequestContextImpl(
- "getLibraryHubs",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- _finalReq.build());
- } catch (Exception _e) {
- throw new NonRetryableException(_e);
- }
- try {
- return _client.send(_r);
- } catch (Exception _e) {
- return sdkConfiguration.hooks()
- .afterError(
- new AfterErrorContextImpl(
- "getLibraryHubs",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- Optional.empty(),
- Optional.of(_e));
- }
- })
- .retryConfig(_retryConfig)
- .statusCodes(_statusCodes)
- .build();
- HttpResponse _httpRes = sdkConfiguration.hooks()
- .afterSuccess(
- new AfterSuccessContextImpl(
- "getLibraryHubs",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- _retries.run());
String _contentType = _httpRes
.headers()
.firstValue("Content-Type")
diff --git a/src/main/java/dev/plexapi/sdk/Library.java b/src/main/java/dev/plexapi/sdk/Library.java
index 5c82038c..49679359 100644
--- a/src/main/java/dev/plexapi/sdk/Library.java
+++ b/src/main/java/dev/plexapi/sdk/Library.java
@@ -84,16 +84,11 @@ import dev.plexapi.sdk.models.operations.GetTopWatchedContentResponse;
import dev.plexapi.sdk.models.operations.GetTopWatchedContentResponseBody;
import dev.plexapi.sdk.models.operations.IncludeDetails;
import dev.plexapi.sdk.models.operations.SDKMethodInterfaces.*;
-import dev.plexapi.sdk.utils.BackoffStrategy;
import dev.plexapi.sdk.utils.HTTPClient;
import dev.plexapi.sdk.utils.HTTPRequest;
import dev.plexapi.sdk.utils.Hook.AfterErrorContextImpl;
import dev.plexapi.sdk.utils.Hook.AfterSuccessContextImpl;
import dev.plexapi.sdk.utils.Hook.BeforeRequestContextImpl;
-import dev.plexapi.sdk.utils.Options;
-import dev.plexapi.sdk.utils.Retries.NonRetryableException;
-import dev.plexapi.sdk.utils.Retries;
-import dev.plexapi.sdk.utils.RetryConfig;
import dev.plexapi.sdk.utils.Utils;
import java.io.InputStream;
import java.lang.Double;
@@ -102,11 +97,8 @@ import java.lang.Long;
import java.lang.String;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
-import java.util.ArrayList;
-import java.util.Arrays;
import java.util.List;
-import java.util.Optional;
-import java.util.concurrent.TimeUnit;
+import java.util.Optional;
/**
* API Calls interacting with Plex Media Server Libraries
@@ -152,7 +144,7 @@ public class Library implements
*/
public GetFileHashResponse getFileHash(
String url) throws Exception {
- return getFileHash(url, Optional.empty(), Optional.empty());
+ return getFileHash(url, Optional.empty());
}
/**
@@ -160,18 +152,12 @@ public class Library implements
* This resource returns hash values for local files
* @param url This is the path to the local file, must be prefixed by `file://`
* @param type Item type
- * @param options additional options
* @return The response from the API call
* @throws Exception if the API call fails
*/
public GetFileHashResponse getFileHash(
String url,
- Optional type,
- Optional options) throws Exception {
-
- if (options.isPresent()) {
- options.get().validate(Arrays.asList(Options.Option.RETRY_CONFIG));
- }
+ Optional type) throws Exception {
GetFileHashRequest request =
GetFileHashRequest
.builder()
@@ -199,62 +185,45 @@ public class Library implements
this.sdkConfiguration.securitySource.getSecurity());
HTTPClient _client = this.sdkConfiguration.defaultClient;
- HTTPRequest _finalReq = _req;
- RetryConfig _retryConfig;
- if (options.isPresent() && options.get().retryConfig().isPresent()) {
- _retryConfig = options.get().retryConfig().get();
- } else if (this.sdkConfiguration.retryConfig.isPresent()) {
- _retryConfig = this.sdkConfiguration.retryConfig.get();
- } else {
- _retryConfig = RetryConfig.builder()
- .backoff(BackoffStrategy.builder()
- .initialInterval(500, TimeUnit.MILLISECONDS)
- .maxInterval(60000, TimeUnit.MILLISECONDS)
- .baseFactor((double)(1.5))
- .maxElapsedTime(3600000, TimeUnit.MILLISECONDS)
- .retryConnectError(true)
- .build())
- .build();
+ HttpRequest _r =
+ sdkConfiguration.hooks()
+ .beforeRequest(
+ new BeforeRequestContextImpl(
+ "getFileHash",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ _req.build());
+ HttpResponse _httpRes;
+ try {
+ _httpRes = _client.send(_r);
+ if (Utils.statusCodeMatches(_httpRes.statusCode(), "400", "401", "4XX", "5XX")) {
+ _httpRes = sdkConfiguration.hooks()
+ .afterError(
+ new AfterErrorContextImpl(
+ "getFileHash",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ Optional.of(_httpRes),
+ Optional.empty());
+ } else {
+ _httpRes = sdkConfiguration.hooks()
+ .afterSuccess(
+ new AfterSuccessContextImpl(
+ "getFileHash",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ _httpRes);
+ }
+ } catch (Exception _e) {
+ _httpRes = sdkConfiguration.hooks()
+ .afterError(
+ new AfterErrorContextImpl(
+ "getFileHash",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ Optional.empty(),
+ Optional.of(_e));
}
- List _statusCodes = new ArrayList<>();
- _statusCodes.add("5XX");
- Retries _retries = Retries.builder()
- .action(() -> {
- HttpRequest _r = null;
- try {
- _r = sdkConfiguration.hooks()
- .beforeRequest(
- new BeforeRequestContextImpl(
- "getFileHash",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- _finalReq.build());
- } catch (Exception _e) {
- throw new NonRetryableException(_e);
- }
- try {
- return _client.send(_r);
- } catch (Exception _e) {
- return sdkConfiguration.hooks()
- .afterError(
- new AfterErrorContextImpl(
- "getFileHash",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- Optional.empty(),
- Optional.of(_e));
- }
- })
- .retryConfig(_retryConfig)
- .statusCodes(_statusCodes)
- .build();
- HttpResponse _httpRes = sdkConfiguration.hooks()
- .afterSuccess(
- new AfterSuccessContextImpl(
- "getFileHash",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- _retries.run());
String _contentType = _httpRes
.headers()
.firstValue("Content-Type")
@@ -341,25 +310,6 @@ public class Library implements
*/
public GetRecentlyAddedLibraryResponse getRecentlyAddedLibrary(
GetRecentlyAddedLibraryRequest request) throws Exception {
- return getRecentlyAddedLibrary(request, Optional.empty());
- }
-
- /**
- * Get Recently Added
- * This endpoint will return the recently added content.
- *
- * @param request The request object containing all of the parameters for the API call.
- * @param options additional options
- * @return The response from the API call
- * @throws Exception if the API call fails
- */
- public GetRecentlyAddedLibraryResponse getRecentlyAddedLibrary(
- GetRecentlyAddedLibraryRequest request,
- Optional options) throws Exception {
-
- if (options.isPresent()) {
- options.get().validate(Arrays.asList(Options.Option.RETRY_CONFIG));
- }
String _baseUrl = Utils.templateUrl(
this.sdkConfiguration.serverUrl, this.sdkConfiguration.getServerVariableDefaults());
String _url = Utils.generateURL(
@@ -380,62 +330,45 @@ public class Library implements
this.sdkConfiguration.securitySource.getSecurity());
HTTPClient _client = this.sdkConfiguration.defaultClient;
- HTTPRequest _finalReq = _req;
- RetryConfig _retryConfig;
- if (options.isPresent() && options.get().retryConfig().isPresent()) {
- _retryConfig = options.get().retryConfig().get();
- } else if (this.sdkConfiguration.retryConfig.isPresent()) {
- _retryConfig = this.sdkConfiguration.retryConfig.get();
- } else {
- _retryConfig = RetryConfig.builder()
- .backoff(BackoffStrategy.builder()
- .initialInterval(500, TimeUnit.MILLISECONDS)
- .maxInterval(60000, TimeUnit.MILLISECONDS)
- .baseFactor((double)(1.5))
- .maxElapsedTime(3600000, TimeUnit.MILLISECONDS)
- .retryConnectError(true)
- .build())
- .build();
+ HttpRequest _r =
+ sdkConfiguration.hooks()
+ .beforeRequest(
+ new BeforeRequestContextImpl(
+ "get-recently-added-library",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ _req.build());
+ HttpResponse _httpRes;
+ try {
+ _httpRes = _client.send(_r);
+ if (Utils.statusCodeMatches(_httpRes.statusCode(), "400", "401", "4XX", "5XX")) {
+ _httpRes = sdkConfiguration.hooks()
+ .afterError(
+ new AfterErrorContextImpl(
+ "get-recently-added-library",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ Optional.of(_httpRes),
+ Optional.empty());
+ } else {
+ _httpRes = sdkConfiguration.hooks()
+ .afterSuccess(
+ new AfterSuccessContextImpl(
+ "get-recently-added-library",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ _httpRes);
+ }
+ } catch (Exception _e) {
+ _httpRes = sdkConfiguration.hooks()
+ .afterError(
+ new AfterErrorContextImpl(
+ "get-recently-added-library",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ Optional.empty(),
+ Optional.of(_e));
}
- List _statusCodes = new ArrayList<>();
- _statusCodes.add("5XX");
- Retries _retries = Retries.builder()
- .action(() -> {
- HttpRequest _r = null;
- try {
- _r = sdkConfiguration.hooks()
- .beforeRequest(
- new BeforeRequestContextImpl(
- "get-recently-added-library",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- _finalReq.build());
- } catch (Exception _e) {
- throw new NonRetryableException(_e);
- }
- try {
- return _client.send(_r);
- } catch (Exception _e) {
- return sdkConfiguration.hooks()
- .afterError(
- new AfterErrorContextImpl(
- "get-recently-added-library",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- Optional.empty(),
- Optional.of(_e));
- }
- })
- .retryConfig(_retryConfig)
- .statusCodes(_statusCodes)
- .build();
- HttpResponse _httpRes = sdkConfiguration.hooks()
- .afterSuccess(
- new AfterSuccessContextImpl(
- "get-recently-added-library",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- _retries.run());
String _contentType = _httpRes
.headers()
.firstValue("Content-Type")
@@ -541,28 +474,6 @@ public class Library implements
* @throws Exception if the API call fails
*/
public GetAllLibrariesResponse getAllLibrariesDirect() throws Exception {
- return getAllLibraries(Optional.empty());
- }
-
- /**
- * Get All Libraries
- * A library section (commonly referred to as just a library) is a collection of media.
- * Libraries are typed, and depending on their type provide either a flat or a hierarchical view of the media.
- * For example, a music library has an artist > albums > tracks structure, whereas a movie library is flat.
- *
- * Libraries have features beyond just being a collection of media; for starters, they include information about supported types, filters and sorts.
- * This allows a client to provide a rich interface around the media (e.g. allow sorting movies by release year).
- *
- * @param options additional options
- * @return The response from the API call
- * @throws Exception if the API call fails
- */
- public GetAllLibrariesResponse getAllLibraries(
- Optional options) throws Exception {
-
- if (options.isPresent()) {
- options.get().validate(Arrays.asList(Options.Option.RETRY_CONFIG));
- }
String _baseUrl = Utils.templateUrl(
this.sdkConfiguration.serverUrl, this.sdkConfiguration.getServerVariableDefaults());
String _url = Utils.generateURL(
@@ -578,62 +489,45 @@ public class Library implements
this.sdkConfiguration.securitySource.getSecurity());
HTTPClient _client = this.sdkConfiguration.defaultClient;
- HTTPRequest _finalReq = _req;
- RetryConfig _retryConfig;
- if (options.isPresent() && options.get().retryConfig().isPresent()) {
- _retryConfig = options.get().retryConfig().get();
- } else if (this.sdkConfiguration.retryConfig.isPresent()) {
- _retryConfig = this.sdkConfiguration.retryConfig.get();
- } else {
- _retryConfig = RetryConfig.builder()
- .backoff(BackoffStrategy.builder()
- .initialInterval(500, TimeUnit.MILLISECONDS)
- .maxInterval(60000, TimeUnit.MILLISECONDS)
- .baseFactor((double)(1.5))
- .maxElapsedTime(3600000, TimeUnit.MILLISECONDS)
- .retryConnectError(true)
- .build())
- .build();
+ HttpRequest _r =
+ sdkConfiguration.hooks()
+ .beforeRequest(
+ new BeforeRequestContextImpl(
+ "get-all-libraries",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ _req.build());
+ HttpResponse _httpRes;
+ try {
+ _httpRes = _client.send(_r);
+ if (Utils.statusCodeMatches(_httpRes.statusCode(), "400", "401", "4XX", "5XX")) {
+ _httpRes = sdkConfiguration.hooks()
+ .afterError(
+ new AfterErrorContextImpl(
+ "get-all-libraries",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ Optional.of(_httpRes),
+ Optional.empty());
+ } else {
+ _httpRes = sdkConfiguration.hooks()
+ .afterSuccess(
+ new AfterSuccessContextImpl(
+ "get-all-libraries",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ _httpRes);
+ }
+ } catch (Exception _e) {
+ _httpRes = sdkConfiguration.hooks()
+ .afterError(
+ new AfterErrorContextImpl(
+ "get-all-libraries",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ Optional.empty(),
+ Optional.of(_e));
}
- List _statusCodes = new ArrayList<>();
- _statusCodes.add("5XX");
- Retries _retries = Retries.builder()
- .action(() -> {
- HttpRequest _r = null;
- try {
- _r = sdkConfiguration.hooks()
- .beforeRequest(
- new BeforeRequestContextImpl(
- "get-all-libraries",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- _finalReq.build());
- } catch (Exception _e) {
- throw new NonRetryableException(_e);
- }
- try {
- return _client.send(_r);
- } catch (Exception _e) {
- return sdkConfiguration.hooks()
- .afterError(
- new AfterErrorContextImpl(
- "get-all-libraries",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- Optional.empty(),
- Optional.of(_e));
- }
- })
- .retryConfig(_retryConfig)
- .statusCodes(_statusCodes)
- .build();
- HttpResponse _httpRes = sdkConfiguration.hooks()
- .afterSuccess(
- new AfterSuccessContextImpl(
- "get-all-libraries",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- _retries.run());
String _contentType = _httpRes
.headers()
.firstValue("Content-Type")
@@ -809,7 +703,7 @@ public class Library implements
*/
public GetLibraryDetailsResponse getLibraryDetails(
int sectionKey) throws Exception {
- return getLibraryDetails(Optional.empty(), sectionKey, Optional.empty());
+ return getLibraryDetails(Optional.empty(), sectionKey);
}
/**
@@ -860,18 +754,12 @@ public class Library implements
* @param sectionKey The unique key of the Plex library.
Note: This is unique in the context of the Plex server.
- * @param options additional options
* @return The response from the API call
* @throws Exception if the API call fails
*/
public GetLibraryDetailsResponse getLibraryDetails(
Optional extends IncludeDetails> includeDetails,
- int sectionKey,
- Optional options) throws Exception {
-
- if (options.isPresent()) {
- options.get().validate(Arrays.asList(Options.Option.RETRY_CONFIG));
- }
+ int sectionKey) throws Exception {
GetLibraryDetailsRequest request =
GetLibraryDetailsRequest
.builder()
@@ -901,62 +789,45 @@ public class Library implements
this.sdkConfiguration.securitySource.getSecurity());
HTTPClient _client = this.sdkConfiguration.defaultClient;
- HTTPRequest _finalReq = _req;
- RetryConfig _retryConfig;
- if (options.isPresent() && options.get().retryConfig().isPresent()) {
- _retryConfig = options.get().retryConfig().get();
- } else if (this.sdkConfiguration.retryConfig.isPresent()) {
- _retryConfig = this.sdkConfiguration.retryConfig.get();
- } else {
- _retryConfig = RetryConfig.builder()
- .backoff(BackoffStrategy.builder()
- .initialInterval(500, TimeUnit.MILLISECONDS)
- .maxInterval(60000, TimeUnit.MILLISECONDS)
- .baseFactor((double)(1.5))
- .maxElapsedTime(3600000, TimeUnit.MILLISECONDS)
- .retryConnectError(true)
- .build())
- .build();
+ HttpRequest _r =
+ sdkConfiguration.hooks()
+ .beforeRequest(
+ new BeforeRequestContextImpl(
+ "get-library-details",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ _req.build());
+ HttpResponse _httpRes;
+ try {
+ _httpRes = _client.send(_r);
+ if (Utils.statusCodeMatches(_httpRes.statusCode(), "400", "401", "4XX", "5XX")) {
+ _httpRes = sdkConfiguration.hooks()
+ .afterError(
+ new AfterErrorContextImpl(
+ "get-library-details",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ Optional.of(_httpRes),
+ Optional.empty());
+ } else {
+ _httpRes = sdkConfiguration.hooks()
+ .afterSuccess(
+ new AfterSuccessContextImpl(
+ "get-library-details",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ _httpRes);
+ }
+ } catch (Exception _e) {
+ _httpRes = sdkConfiguration.hooks()
+ .afterError(
+ new AfterErrorContextImpl(
+ "get-library-details",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ Optional.empty(),
+ Optional.of(_e));
}
- List _statusCodes = new ArrayList<>();
- _statusCodes.add("5XX");
- Retries _retries = Retries.builder()
- .action(() -> {
- HttpRequest _r = null;
- try {
- _r = sdkConfiguration.hooks()
- .beforeRequest(
- new BeforeRequestContextImpl(
- "get-library-details",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- _finalReq.build());
- } catch (Exception _e) {
- throw new NonRetryableException(_e);
- }
- try {
- return _client.send(_r);
- } catch (Exception _e) {
- return sdkConfiguration.hooks()
- .afterError(
- new AfterErrorContextImpl(
- "get-library-details",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- Optional.empty(),
- Optional.of(_e));
- }
- })
- .retryConfig(_retryConfig)
- .statusCodes(_statusCodes)
- .build();
- HttpResponse _httpRes = sdkConfiguration.hooks()
- .afterSuccess(
- new AfterSuccessContextImpl(
- "get-library-details",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- _retries.run());
String _contentType = _httpRes
.headers()
.firstValue("Content-Type")
@@ -1054,26 +925,6 @@ public class Library implements
*/
public DeleteLibraryResponse deleteLibrary(
int sectionKey) throws Exception {
- return deleteLibrary(sectionKey, Optional.empty());
- }
-
- /**
- * Delete Library Section
- * Delete a library using a specific section id
- * @param sectionKey The unique key of the Plex library.
- Note: This is unique in the context of the Plex server.
-
- * @param options additional options
- * @return The response from the API call
- * @throws Exception if the API call fails
- */
- public DeleteLibraryResponse deleteLibrary(
- int sectionKey,
- Optional options) throws Exception {
-
- if (options.isPresent()) {
- options.get().validate(Arrays.asList(Options.Option.RETRY_CONFIG));
- }
DeleteLibraryRequest request =
DeleteLibraryRequest
.builder()
@@ -1097,62 +948,45 @@ public class Library implements
this.sdkConfiguration.securitySource.getSecurity());
HTTPClient _client = this.sdkConfiguration.defaultClient;
- HTTPRequest _finalReq = _req;
- RetryConfig _retryConfig;
- if (options.isPresent() && options.get().retryConfig().isPresent()) {
- _retryConfig = options.get().retryConfig().get();
- } else if (this.sdkConfiguration.retryConfig.isPresent()) {
- _retryConfig = this.sdkConfiguration.retryConfig.get();
- } else {
- _retryConfig = RetryConfig.builder()
- .backoff(BackoffStrategy.builder()
- .initialInterval(500, TimeUnit.MILLISECONDS)
- .maxInterval(60000, TimeUnit.MILLISECONDS)
- .baseFactor((double)(1.5))
- .maxElapsedTime(3600000, TimeUnit.MILLISECONDS)
- .retryConnectError(true)
- .build())
- .build();
+ HttpRequest _r =
+ sdkConfiguration.hooks()
+ .beforeRequest(
+ new BeforeRequestContextImpl(
+ "deleteLibrary",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ _req.build());
+ HttpResponse _httpRes;
+ try {
+ _httpRes = _client.send(_r);
+ if (Utils.statusCodeMatches(_httpRes.statusCode(), "400", "401", "4XX", "5XX")) {
+ _httpRes = sdkConfiguration.hooks()
+ .afterError(
+ new AfterErrorContextImpl(
+ "deleteLibrary",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ Optional.of(_httpRes),
+ Optional.empty());
+ } else {
+ _httpRes = sdkConfiguration.hooks()
+ .afterSuccess(
+ new AfterSuccessContextImpl(
+ "deleteLibrary",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ _httpRes);
+ }
+ } catch (Exception _e) {
+ _httpRes = sdkConfiguration.hooks()
+ .afterError(
+ new AfterErrorContextImpl(
+ "deleteLibrary",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ Optional.empty(),
+ Optional.of(_e));
}
- List _statusCodes = new ArrayList<>();
- _statusCodes.add("5XX");
- Retries _retries = Retries.builder()
- .action(() -> {
- HttpRequest _r = null;
- try {
- _r = sdkConfiguration.hooks()
- .beforeRequest(
- new BeforeRequestContextImpl(
- "deleteLibrary",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- _finalReq.build());
- } catch (Exception _e) {
- throw new NonRetryableException(_e);
- }
- try {
- return _client.send(_r);
- } catch (Exception _e) {
- return sdkConfiguration.hooks()
- .afterError(
- new AfterErrorContextImpl(
- "deleteLibrary",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- Optional.empty(),
- Optional.of(_e));
- }
- })
- .retryConfig(_retryConfig)
- .statusCodes(_statusCodes)
- .build();
- HttpResponse _httpRes = sdkConfiguration.hooks()
- .afterSuccess(
- new AfterSuccessContextImpl(
- "deleteLibrary",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- _retries.run());
String _contentType = _httpRes
.headers()
.firstValue("Content-Type")
@@ -1277,44 +1111,6 @@ public class Library implements
*/
public GetLibraryItemsResponse getLibraryItems(
GetLibraryItemsRequest request) throws Exception {
- return getLibraryItems(request, Optional.empty());
- }
-
- /**
- * Get Library Items
- * Fetches details from a specific section of the library identified by a section key and a tag. The tag parameter accepts the following values:
- * - `all`: All items in the section.
- * - `unwatched`: Items that have not been played.
- * - `newest`: Items that are recently released.
- * - `recentlyAdded`: Items that are recently added to the library.
- * - `recentlyViewed`: Items that were recently viewed.
- * - `onDeck`: Items to continue watching.
- * - `collection`: Items categorized by collection.
- * - `edition`: Items categorized by edition.
- * - `genre`: Items categorized by genre.
- * - `year`: Items categorized by year of release.
- * - `decade`: Items categorized by decade.
- * - `director`: Items categorized by director.
- * - `actor`: Items categorized by starring actor.
- * - `country`: Items categorized by country of origin.
- * - `contentRating`: Items categorized by content rating.
- * - `rating`: Items categorized by rating.
- * - `resolution`: Items categorized by resolution.
- * - `firstCharacter`: Items categorized by the first letter.
- * - `folder`: Items categorized by folder.
- *
- * @param request The request object containing all of the parameters for the API call.
- * @param options additional options
- * @return The response from the API call
- * @throws Exception if the API call fails
- */
- public GetLibraryItemsResponse getLibraryItems(
- GetLibraryItemsRequest request,
- Optional options) throws Exception {
-
- if (options.isPresent()) {
- options.get().validate(Arrays.asList(Options.Option.RETRY_CONFIG));
- }
String _baseUrl = Utils.templateUrl(
this.sdkConfiguration.serverUrl, this.sdkConfiguration.getServerVariableDefaults());
String _url = Utils.generateURL(
@@ -1337,62 +1133,45 @@ public class Library implements
this.sdkConfiguration.securitySource.getSecurity());
HTTPClient _client = this.sdkConfiguration.defaultClient;
- HTTPRequest _finalReq = _req;
- RetryConfig _retryConfig;
- if (options.isPresent() && options.get().retryConfig().isPresent()) {
- _retryConfig = options.get().retryConfig().get();
- } else if (this.sdkConfiguration.retryConfig.isPresent()) {
- _retryConfig = this.sdkConfiguration.retryConfig.get();
- } else {
- _retryConfig = RetryConfig.builder()
- .backoff(BackoffStrategy.builder()
- .initialInterval(500, TimeUnit.MILLISECONDS)
- .maxInterval(60000, TimeUnit.MILLISECONDS)
- .baseFactor((double)(1.5))
- .maxElapsedTime(3600000, TimeUnit.MILLISECONDS)
- .retryConnectError(true)
- .build())
- .build();
+ HttpRequest _r =
+ sdkConfiguration.hooks()
+ .beforeRequest(
+ new BeforeRequestContextImpl(
+ "get-library-items",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ _req.build());
+ HttpResponse _httpRes;
+ try {
+ _httpRes = _client.send(_r);
+ if (Utils.statusCodeMatches(_httpRes.statusCode(), "400", "401", "4XX", "5XX")) {
+ _httpRes = sdkConfiguration.hooks()
+ .afterError(
+ new AfterErrorContextImpl(
+ "get-library-items",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ Optional.of(_httpRes),
+ Optional.empty());
+ } else {
+ _httpRes = sdkConfiguration.hooks()
+ .afterSuccess(
+ new AfterSuccessContextImpl(
+ "get-library-items",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ _httpRes);
+ }
+ } catch (Exception _e) {
+ _httpRes = sdkConfiguration.hooks()
+ .afterError(
+ new AfterErrorContextImpl(
+ "get-library-items",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ Optional.empty(),
+ Optional.of(_e));
}
- List _statusCodes = new ArrayList<>();
- _statusCodes.add("5XX");
- Retries _retries = Retries.builder()
- .action(() -> {
- HttpRequest _r = null;
- try {
- _r = sdkConfiguration.hooks()
- .beforeRequest(
- new BeforeRequestContextImpl(
- "get-library-items",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- _finalReq.build());
- } catch (Exception _e) {
- throw new NonRetryableException(_e);
- }
- try {
- return _client.send(_r);
- } catch (Exception _e) {
- return sdkConfiguration.hooks()
- .afterError(
- new AfterErrorContextImpl(
- "get-library-items",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- Optional.empty(),
- Optional.of(_e));
- }
- })
- .retryConfig(_retryConfig)
- .statusCodes(_statusCodes)
- .build();
- HttpResponse _httpRes = sdkConfiguration.hooks()
- .afterSuccess(
- new AfterSuccessContextImpl(
- "get-library-items",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- _retries.run());
String _contentType = _httpRes
.headers()
.firstValue("Content-Type")
@@ -1492,7 +1271,7 @@ public class Library implements
*/
public GetRefreshLibraryMetadataResponse getRefreshLibraryMetadata(
int sectionKey) throws Exception {
- return getRefreshLibraryMetadata(Optional.empty(), sectionKey, Optional.empty());
+ return getRefreshLibraryMetadata(Optional.empty(), sectionKey);
}
/**
@@ -1503,18 +1282,12 @@ public class Library implements
* @param sectionKey The unique key of the Plex library.
Note: This is unique in the context of the Plex server.
- * @param options additional options
* @return The response from the API call
* @throws Exception if the API call fails
*/
public GetRefreshLibraryMetadataResponse getRefreshLibraryMetadata(
Optional extends Force> force,
- int sectionKey,
- Optional options) throws Exception {
-
- if (options.isPresent()) {
- options.get().validate(Arrays.asList(Options.Option.RETRY_CONFIG));
- }
+ int sectionKey) throws Exception {
GetRefreshLibraryMetadataRequest request =
GetRefreshLibraryMetadataRequest
.builder()
@@ -1544,62 +1317,45 @@ public class Library implements
this.sdkConfiguration.securitySource.getSecurity());
HTTPClient _client = this.sdkConfiguration.defaultClient;
- HTTPRequest _finalReq = _req;
- RetryConfig _retryConfig;
- if (options.isPresent() && options.get().retryConfig().isPresent()) {
- _retryConfig = options.get().retryConfig().get();
- } else if (this.sdkConfiguration.retryConfig.isPresent()) {
- _retryConfig = this.sdkConfiguration.retryConfig.get();
- } else {
- _retryConfig = RetryConfig.builder()
- .backoff(BackoffStrategy.builder()
- .initialInterval(500, TimeUnit.MILLISECONDS)
- .maxInterval(60000, TimeUnit.MILLISECONDS)
- .baseFactor((double)(1.5))
- .maxElapsedTime(3600000, TimeUnit.MILLISECONDS)
- .retryConnectError(true)
- .build())
- .build();
+ HttpRequest _r =
+ sdkConfiguration.hooks()
+ .beforeRequest(
+ new BeforeRequestContextImpl(
+ "get-refresh-library-metadata",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ _req.build());
+ HttpResponse _httpRes;
+ try {
+ _httpRes = _client.send(_r);
+ if (Utils.statusCodeMatches(_httpRes.statusCode(), "400", "401", "4XX", "5XX")) {
+ _httpRes = sdkConfiguration.hooks()
+ .afterError(
+ new AfterErrorContextImpl(
+ "get-refresh-library-metadata",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ Optional.of(_httpRes),
+ Optional.empty());
+ } else {
+ _httpRes = sdkConfiguration.hooks()
+ .afterSuccess(
+ new AfterSuccessContextImpl(
+ "get-refresh-library-metadata",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ _httpRes);
+ }
+ } catch (Exception _e) {
+ _httpRes = sdkConfiguration.hooks()
+ .afterError(
+ new AfterErrorContextImpl(
+ "get-refresh-library-metadata",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ Optional.empty(),
+ Optional.of(_e));
}
- List _statusCodes = new ArrayList<>();
- _statusCodes.add("5XX");
- Retries _retries = Retries.builder()
- .action(() -> {
- HttpRequest _r = null;
- try {
- _r = sdkConfiguration.hooks()
- .beforeRequest(
- new BeforeRequestContextImpl(
- "get-refresh-library-metadata",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- _finalReq.build());
- } catch (Exception _e) {
- throw new NonRetryableException(_e);
- }
- try {
- return _client.send(_r);
- } catch (Exception _e) {
- return sdkConfiguration.hooks()
- .afterError(
- new AfterErrorContextImpl(
- "get-refresh-library-metadata",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- Optional.empty(),
- Optional.of(_e));
- }
- })
- .retryConfig(_retryConfig)
- .statusCodes(_statusCodes)
- .build();
- HttpResponse _httpRes = sdkConfiguration.hooks()
- .afterSuccess(
- new AfterSuccessContextImpl(
- "get-refresh-library-metadata",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- _retries.run());
String _contentType = _httpRes
.headers()
.firstValue("Content-Type")
@@ -1730,52 +1486,6 @@ public class Library implements
public GetSearchLibraryResponse getSearchLibrary(
int sectionKey,
GetSearchLibraryQueryParamType type) throws Exception {
- return getSearchLibrary(sectionKey, type, Optional.empty());
- }
-
- /**
- * Search Library
- * Search for content within a specific section of the library.
- *
- * ### Types
- * Each type in the library comes with a set of filters and sorts, aiding in building dynamic media controls:
- *
- * - **Type Object Attributes**:
- * - `type`: Metadata type (if standard Plex type).
- * - `title`: Title for this content type (e.g., "Movies").
- *
- * - **Filter Objects**:
- * - Subset of the media query language.
- * - Attributes include `filter` (name), `filterType` (data type), `key` (endpoint for value range), and `title`.
- *
- * - **Sort Objects**:
- * - Description of sort fields.
- * - Attributes include `defaultDirection` (asc/desc), `descKey` and `key` (sort parameters), and `title`.
- *
- * > **Note**: Filters and sorts are optional; without them, no filtering controls are rendered.
- *
- * @param sectionKey The unique key of the Plex library.
- Note: This is unique in the context of the Plex server.
-
- * @param type The type of media to retrieve.
- 1 = movie
- 2 = show
- 3 = season
- 4 = episode
- E.g. A movie library will not return anything with type 3 as there are no seasons for movie libraries
-
- * @param options additional options
- * @return The response from the API call
- * @throws Exception if the API call fails
- */
- public GetSearchLibraryResponse getSearchLibrary(
- int sectionKey,
- GetSearchLibraryQueryParamType type,
- Optional options) throws Exception {
-
- if (options.isPresent()) {
- options.get().validate(Arrays.asList(Options.Option.RETRY_CONFIG));
- }
GetSearchLibraryRequest request =
GetSearchLibraryRequest
.builder()
@@ -1805,62 +1515,45 @@ public class Library implements
this.sdkConfiguration.securitySource.getSecurity());
HTTPClient _client = this.sdkConfiguration.defaultClient;
- HTTPRequest _finalReq = _req;
- RetryConfig _retryConfig;
- if (options.isPresent() && options.get().retryConfig().isPresent()) {
- _retryConfig = options.get().retryConfig().get();
- } else if (this.sdkConfiguration.retryConfig.isPresent()) {
- _retryConfig = this.sdkConfiguration.retryConfig.get();
- } else {
- _retryConfig = RetryConfig.builder()
- .backoff(BackoffStrategy.builder()
- .initialInterval(500, TimeUnit.MILLISECONDS)
- .maxInterval(60000, TimeUnit.MILLISECONDS)
- .baseFactor((double)(1.5))
- .maxElapsedTime(3600000, TimeUnit.MILLISECONDS)
- .retryConnectError(true)
- .build())
- .build();
+ HttpRequest _r =
+ sdkConfiguration.hooks()
+ .beforeRequest(
+ new BeforeRequestContextImpl(
+ "get-search-library",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ _req.build());
+ HttpResponse _httpRes;
+ try {
+ _httpRes = _client.send(_r);
+ if (Utils.statusCodeMatches(_httpRes.statusCode(), "400", "401", "4XX", "5XX")) {
+ _httpRes = sdkConfiguration.hooks()
+ .afterError(
+ new AfterErrorContextImpl(
+ "get-search-library",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ Optional.of(_httpRes),
+ Optional.empty());
+ } else {
+ _httpRes = sdkConfiguration.hooks()
+ .afterSuccess(
+ new AfterSuccessContextImpl(
+ "get-search-library",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ _httpRes);
+ }
+ } catch (Exception _e) {
+ _httpRes = sdkConfiguration.hooks()
+ .afterError(
+ new AfterErrorContextImpl(
+ "get-search-library",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ Optional.empty(),
+ Optional.of(_e));
}
- List _statusCodes = new ArrayList<>();
- _statusCodes.add("5XX");
- Retries _retries = Retries.builder()
- .action(() -> {
- HttpRequest _r = null;
- try {
- _r = sdkConfiguration.hooks()
- .beforeRequest(
- new BeforeRequestContextImpl(
- "get-search-library",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- _finalReq.build());
- } catch (Exception _e) {
- throw new NonRetryableException(_e);
- }
- try {
- return _client.send(_r);
- } catch (Exception _e) {
- return sdkConfiguration.hooks()
- .afterError(
- new AfterErrorContextImpl(
- "get-search-library",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- Optional.empty(),
- Optional.of(_e));
- }
- })
- .retryConfig(_retryConfig)
- .statusCodes(_statusCodes)
- .build();
- HttpResponse _httpRes = sdkConfiguration.hooks()
- .afterSuccess(
- new AfterSuccessContextImpl(
- "get-search-library",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- _retries.run());
String _contentType = _httpRes
.headers()
.firstValue("Content-Type")
@@ -1958,25 +1651,6 @@ public class Library implements
*/
public GetSearchAllLibrariesResponse getSearchAllLibraries(
GetSearchAllLibrariesRequest request) throws Exception {
- return getSearchAllLibraries(request, Optional.empty());
- }
-
- /**
- * Search All Libraries
- * Search the provided query across all library sections, or a single section, and return matches as hubs, split up by type.
- *
- * @param request The request object containing all of the parameters for the API call.
- * @param options additional options
- * @return The response from the API call
- * @throws Exception if the API call fails
- */
- public GetSearchAllLibrariesResponse getSearchAllLibraries(
- GetSearchAllLibrariesRequest request,
- Optional options) throws Exception {
-
- if (options.isPresent()) {
- options.get().validate(Arrays.asList(Options.Option.RETRY_CONFIG));
- }
String _baseUrl = Utils.templateUrl(
this.sdkConfiguration.serverUrl, this.sdkConfiguration.getServerVariableDefaults());
String _url = Utils.generateURL(
@@ -1998,62 +1672,45 @@ public class Library implements
this.sdkConfiguration.securitySource.getSecurity());
HTTPClient _client = this.sdkConfiguration.defaultClient;
- HTTPRequest _finalReq = _req;
- RetryConfig _retryConfig;
- if (options.isPresent() && options.get().retryConfig().isPresent()) {
- _retryConfig = options.get().retryConfig().get();
- } else if (this.sdkConfiguration.retryConfig.isPresent()) {
- _retryConfig = this.sdkConfiguration.retryConfig.get();
- } else {
- _retryConfig = RetryConfig.builder()
- .backoff(BackoffStrategy.builder()
- .initialInterval(500, TimeUnit.MILLISECONDS)
- .maxInterval(60000, TimeUnit.MILLISECONDS)
- .baseFactor((double)(1.5))
- .maxElapsedTime(3600000, TimeUnit.MILLISECONDS)
- .retryConnectError(true)
- .build())
- .build();
+ HttpRequest _r =
+ sdkConfiguration.hooks()
+ .beforeRequest(
+ new BeforeRequestContextImpl(
+ "get-search-all-libraries",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ _req.build());
+ HttpResponse _httpRes;
+ try {
+ _httpRes = _client.send(_r);
+ if (Utils.statusCodeMatches(_httpRes.statusCode(), "400", "401", "4XX", "5XX")) {
+ _httpRes = sdkConfiguration.hooks()
+ .afterError(
+ new AfterErrorContextImpl(
+ "get-search-all-libraries",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ Optional.of(_httpRes),
+ Optional.empty());
+ } else {
+ _httpRes = sdkConfiguration.hooks()
+ .afterSuccess(
+ new AfterSuccessContextImpl(
+ "get-search-all-libraries",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ _httpRes);
+ }
+ } catch (Exception _e) {
+ _httpRes = sdkConfiguration.hooks()
+ .afterError(
+ new AfterErrorContextImpl(
+ "get-search-all-libraries",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ Optional.empty(),
+ Optional.of(_e));
}
- List _statusCodes = new ArrayList<>();
- _statusCodes.add("5XX");
- Retries _retries = Retries.builder()
- .action(() -> {
- HttpRequest _r = null;
- try {
- _r = sdkConfiguration.hooks()
- .beforeRequest(
- new BeforeRequestContextImpl(
- "get-search-all-libraries",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- _finalReq.build());
- } catch (Exception _e) {
- throw new NonRetryableException(_e);
- }
- try {
- return _client.send(_r);
- } catch (Exception _e) {
- return sdkConfiguration.hooks()
- .afterError(
- new AfterErrorContextImpl(
- "get-search-all-libraries",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- Optional.empty(),
- Optional.of(_e));
- }
- })
- .retryConfig(_retryConfig)
- .statusCodes(_statusCodes)
- .build();
- HttpResponse _httpRes = sdkConfiguration.hooks()
- .afterSuccess(
- new AfterSuccessContextImpl(
- "get-search-all-libraries",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- _retries.run());
String _contentType = _httpRes
.headers()
.firstValue("Content-Type")
@@ -2151,25 +1808,6 @@ public class Library implements
*/
public GetMetaDataByRatingKeyResponse getMetaDataByRatingKey(
long ratingKey) throws Exception {
- return getMetaDataByRatingKey(ratingKey, Optional.empty());
- }
-
- /**
- * Get Metadata by RatingKey
- * This endpoint will return the metadata of a library item specified with the ratingKey.
- *
- * @param ratingKey the id of the library item to return the children of.
- * @param options additional options
- * @return The response from the API call
- * @throws Exception if the API call fails
- */
- public GetMetaDataByRatingKeyResponse getMetaDataByRatingKey(
- long ratingKey,
- Optional options) throws Exception {
-
- if (options.isPresent()) {
- options.get().validate(Arrays.asList(Options.Option.RETRY_CONFIG));
- }
GetMetaDataByRatingKeyRequest request =
GetMetaDataByRatingKeyRequest
.builder()
@@ -2193,62 +1831,45 @@ public class Library implements
this.sdkConfiguration.securitySource.getSecurity());
HTTPClient _client = this.sdkConfiguration.defaultClient;
- HTTPRequest _finalReq = _req;
- RetryConfig _retryConfig;
- if (options.isPresent() && options.get().retryConfig().isPresent()) {
- _retryConfig = options.get().retryConfig().get();
- } else if (this.sdkConfiguration.retryConfig.isPresent()) {
- _retryConfig = this.sdkConfiguration.retryConfig.get();
- } else {
- _retryConfig = RetryConfig.builder()
- .backoff(BackoffStrategy.builder()
- .initialInterval(500, TimeUnit.MILLISECONDS)
- .maxInterval(60000, TimeUnit.MILLISECONDS)
- .baseFactor((double)(1.5))
- .maxElapsedTime(3600000, TimeUnit.MILLISECONDS)
- .retryConnectError(true)
- .build())
- .build();
+ HttpRequest _r =
+ sdkConfiguration.hooks()
+ .beforeRequest(
+ new BeforeRequestContextImpl(
+ "get-meta-data-by-rating-key",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ _req.build());
+ HttpResponse _httpRes;
+ try {
+ _httpRes = _client.send(_r);
+ if (Utils.statusCodeMatches(_httpRes.statusCode(), "400", "401", "4XX", "5XX")) {
+ _httpRes = sdkConfiguration.hooks()
+ .afterError(
+ new AfterErrorContextImpl(
+ "get-meta-data-by-rating-key",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ Optional.of(_httpRes),
+ Optional.empty());
+ } else {
+ _httpRes = sdkConfiguration.hooks()
+ .afterSuccess(
+ new AfterSuccessContextImpl(
+ "get-meta-data-by-rating-key",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ _httpRes);
+ }
+ } catch (Exception _e) {
+ _httpRes = sdkConfiguration.hooks()
+ .afterError(
+ new AfterErrorContextImpl(
+ "get-meta-data-by-rating-key",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ Optional.empty(),
+ Optional.of(_e));
}
- List _statusCodes = new ArrayList<>();
- _statusCodes.add("5XX");
- Retries _retries = Retries.builder()
- .action(() -> {
- HttpRequest _r = null;
- try {
- _r = sdkConfiguration.hooks()
- .beforeRequest(
- new BeforeRequestContextImpl(
- "get-meta-data-by-rating-key",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- _finalReq.build());
- } catch (Exception _e) {
- throw new NonRetryableException(_e);
- }
- try {
- return _client.send(_r);
- } catch (Exception _e) {
- return sdkConfiguration.hooks()
- .afterError(
- new AfterErrorContextImpl(
- "get-meta-data-by-rating-key",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- Optional.empty(),
- Optional.of(_e));
- }
- })
- .retryConfig(_retryConfig)
- .statusCodes(_statusCodes)
- .build();
- HttpResponse _httpRes = sdkConfiguration.hooks()
- .afterSuccess(
- new AfterSuccessContextImpl(
- "get-meta-data-by-rating-key",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- _retries.run());
String _contentType = _httpRes
.headers()
.firstValue("Content-Type")
@@ -2346,7 +1967,7 @@ public class Library implements
*/
public GetMetadataChildrenResponse getMetadataChildren(
double ratingKey) throws Exception {
- return getMetadataChildren(ratingKey, Optional.empty(), Optional.empty());
+ return getMetadataChildren(ratingKey, Optional.empty());
}
/**
@@ -2356,18 +1977,12 @@ public class Library implements
* @param ratingKey the id of the library item to return the children of.
* @param includeElements Adds additional elements to the response. Supported types are (Stream)
- * @param options additional options
* @return The response from the API call
* @throws Exception if the API call fails
*/
public GetMetadataChildrenResponse getMetadataChildren(
double ratingKey,
- Optional includeElements,
- Optional options) throws Exception {
-
- if (options.isPresent()) {
- options.get().validate(Arrays.asList(Options.Option.RETRY_CONFIG));
- }
+ Optional includeElements) throws Exception {
GetMetadataChildrenRequest request =
GetMetadataChildrenRequest
.builder()
@@ -2397,62 +2012,45 @@ public class Library implements
this.sdkConfiguration.securitySource.getSecurity());
HTTPClient _client = this.sdkConfiguration.defaultClient;
- HTTPRequest _finalReq = _req;
- RetryConfig _retryConfig;
- if (options.isPresent() && options.get().retryConfig().isPresent()) {
- _retryConfig = options.get().retryConfig().get();
- } else if (this.sdkConfiguration.retryConfig.isPresent()) {
- _retryConfig = this.sdkConfiguration.retryConfig.get();
- } else {
- _retryConfig = RetryConfig.builder()
- .backoff(BackoffStrategy.builder()
- .initialInterval(500, TimeUnit.MILLISECONDS)
- .maxInterval(60000, TimeUnit.MILLISECONDS)
- .baseFactor((double)(1.5))
- .maxElapsedTime(3600000, TimeUnit.MILLISECONDS)
- .retryConnectError(true)
- .build())
- .build();
+ HttpRequest _r =
+ sdkConfiguration.hooks()
+ .beforeRequest(
+ new BeforeRequestContextImpl(
+ "getMetadataChildren",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ _req.build());
+ HttpResponse _httpRes;
+ try {
+ _httpRes = _client.send(_r);
+ if (Utils.statusCodeMatches(_httpRes.statusCode(), "400", "401", "4XX", "5XX")) {
+ _httpRes = sdkConfiguration.hooks()
+ .afterError(
+ new AfterErrorContextImpl(
+ "getMetadataChildren",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ Optional.of(_httpRes),
+ Optional.empty());
+ } else {
+ _httpRes = sdkConfiguration.hooks()
+ .afterSuccess(
+ new AfterSuccessContextImpl(
+ "getMetadataChildren",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ _httpRes);
+ }
+ } catch (Exception _e) {
+ _httpRes = sdkConfiguration.hooks()
+ .afterError(
+ new AfterErrorContextImpl(
+ "getMetadataChildren",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ Optional.empty(),
+ Optional.of(_e));
}
- List _statusCodes = new ArrayList<>();
- _statusCodes.add("5XX");
- Retries _retries = Retries.builder()
- .action(() -> {
- HttpRequest _r = null;
- try {
- _r = sdkConfiguration.hooks()
- .beforeRequest(
- new BeforeRequestContextImpl(
- "getMetadataChildren",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- _finalReq.build());
- } catch (Exception _e) {
- throw new NonRetryableException(_e);
- }
- try {
- return _client.send(_r);
- } catch (Exception _e) {
- return sdkConfiguration.hooks()
- .afterError(
- new AfterErrorContextImpl(
- "getMetadataChildren",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- Optional.empty(),
- Optional.of(_e));
- }
- })
- .retryConfig(_retryConfig)
- .statusCodes(_statusCodes)
- .build();
- HttpResponse _httpRes = sdkConfiguration.hooks()
- .afterSuccess(
- new AfterSuccessContextImpl(
- "getMetadataChildren",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- _retries.run());
String _contentType = _httpRes
.headers()
.firstValue("Content-Type")
@@ -2556,7 +2154,7 @@ public class Library implements
*/
public GetTopWatchedContentResponse getTopWatchedContent(
GetTopWatchedContentQueryParamType type) throws Exception {
- return getTopWatchedContent(Optional.empty(), type, Optional.empty());
+ return getTopWatchedContent(Optional.empty(), type);
}
/**
@@ -2572,18 +2170,12 @@ public class Library implements
4 = episode
E.g. A movie library will not return anything with type 3 as there are no seasons for movie libraries
- * @param options additional options
* @return The response from the API call
* @throws Exception if the API call fails
*/
public GetTopWatchedContentResponse getTopWatchedContent(
Optional includeGuids,
- GetTopWatchedContentQueryParamType type,
- Optional options) throws Exception {
-
- if (options.isPresent()) {
- options.get().validate(Arrays.asList(Options.Option.RETRY_CONFIG));
- }
+ GetTopWatchedContentQueryParamType type) throws Exception {
GetTopWatchedContentRequest request =
GetTopWatchedContentRequest
.builder()
@@ -2611,62 +2203,45 @@ public class Library implements
this.sdkConfiguration.securitySource.getSecurity());
HTTPClient _client = this.sdkConfiguration.defaultClient;
- HTTPRequest _finalReq = _req;
- RetryConfig _retryConfig;
- if (options.isPresent() && options.get().retryConfig().isPresent()) {
- _retryConfig = options.get().retryConfig().get();
- } else if (this.sdkConfiguration.retryConfig.isPresent()) {
- _retryConfig = this.sdkConfiguration.retryConfig.get();
- } else {
- _retryConfig = RetryConfig.builder()
- .backoff(BackoffStrategy.builder()
- .initialInterval(500, TimeUnit.MILLISECONDS)
- .maxInterval(60000, TimeUnit.MILLISECONDS)
- .baseFactor((double)(1.5))
- .maxElapsedTime(3600000, TimeUnit.MILLISECONDS)
- .retryConnectError(true)
- .build())
- .build();
+ HttpRequest _r =
+ sdkConfiguration.hooks()
+ .beforeRequest(
+ new BeforeRequestContextImpl(
+ "getTopWatchedContent",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ _req.build());
+ HttpResponse _httpRes;
+ try {
+ _httpRes = _client.send(_r);
+ if (Utils.statusCodeMatches(_httpRes.statusCode(), "400", "401", "4XX", "5XX")) {
+ _httpRes = sdkConfiguration.hooks()
+ .afterError(
+ new AfterErrorContextImpl(
+ "getTopWatchedContent",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ Optional.of(_httpRes),
+ Optional.empty());
+ } else {
+ _httpRes = sdkConfiguration.hooks()
+ .afterSuccess(
+ new AfterSuccessContextImpl(
+ "getTopWatchedContent",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ _httpRes);
+ }
+ } catch (Exception _e) {
+ _httpRes = sdkConfiguration.hooks()
+ .afterError(
+ new AfterErrorContextImpl(
+ "getTopWatchedContent",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ Optional.empty(),
+ Optional.of(_e));
}
- List _statusCodes = new ArrayList<>();
- _statusCodes.add("5XX");
- Retries _retries = Retries.builder()
- .action(() -> {
- HttpRequest _r = null;
- try {
- _r = sdkConfiguration.hooks()
- .beforeRequest(
- new BeforeRequestContextImpl(
- "getTopWatchedContent",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- _finalReq.build());
- } catch (Exception _e) {
- throw new NonRetryableException(_e);
- }
- try {
- return _client.send(_r);
- } catch (Exception _e) {
- return sdkConfiguration.hooks()
- .afterError(
- new AfterErrorContextImpl(
- "getTopWatchedContent",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- Optional.empty(),
- Optional.of(_e));
- }
- })
- .retryConfig(_retryConfig)
- .statusCodes(_statusCodes)
- .build();
- HttpResponse _httpRes = sdkConfiguration.hooks()
- .afterSuccess(
- new AfterSuccessContextImpl(
- "getTopWatchedContent",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- _retries.run());
String _contentType = _httpRes
.headers()
.firstValue("Content-Type")
@@ -2762,23 +2337,6 @@ public class Library implements
* @throws Exception if the API call fails
*/
public GetOnDeckResponse getOnDeckDirect() throws Exception {
- return getOnDeck(Optional.empty());
- }
-
- /**
- * Get On Deck
- * This endpoint will return the on deck content.
- *
- * @param options additional options
- * @return The response from the API call
- * @throws Exception if the API call fails
- */
- public GetOnDeckResponse getOnDeck(
- Optional options) throws Exception {
-
- if (options.isPresent()) {
- options.get().validate(Arrays.asList(Options.Option.RETRY_CONFIG));
- }
String _baseUrl = Utils.templateUrl(
this.sdkConfiguration.serverUrl, this.sdkConfiguration.getServerVariableDefaults());
String _url = Utils.generateURL(
@@ -2794,62 +2352,45 @@ public class Library implements
this.sdkConfiguration.securitySource.getSecurity());
HTTPClient _client = this.sdkConfiguration.defaultClient;
- HTTPRequest _finalReq = _req;
- RetryConfig _retryConfig;
- if (options.isPresent() && options.get().retryConfig().isPresent()) {
- _retryConfig = options.get().retryConfig().get();
- } else if (this.sdkConfiguration.retryConfig.isPresent()) {
- _retryConfig = this.sdkConfiguration.retryConfig.get();
- } else {
- _retryConfig = RetryConfig.builder()
- .backoff(BackoffStrategy.builder()
- .initialInterval(500, TimeUnit.MILLISECONDS)
- .maxInterval(60000, TimeUnit.MILLISECONDS)
- .baseFactor((double)(1.5))
- .maxElapsedTime(3600000, TimeUnit.MILLISECONDS)
- .retryConnectError(true)
- .build())
- .build();
+ HttpRequest _r =
+ sdkConfiguration.hooks()
+ .beforeRequest(
+ new BeforeRequestContextImpl(
+ "getOnDeck",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ _req.build());
+ HttpResponse _httpRes;
+ try {
+ _httpRes = _client.send(_r);
+ if (Utils.statusCodeMatches(_httpRes.statusCode(), "400", "401", "4XX", "5XX")) {
+ _httpRes = sdkConfiguration.hooks()
+ .afterError(
+ new AfterErrorContextImpl(
+ "getOnDeck",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ Optional.of(_httpRes),
+ Optional.empty());
+ } else {
+ _httpRes = sdkConfiguration.hooks()
+ .afterSuccess(
+ new AfterSuccessContextImpl(
+ "getOnDeck",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ _httpRes);
+ }
+ } catch (Exception _e) {
+ _httpRes = sdkConfiguration.hooks()
+ .afterError(
+ new AfterErrorContextImpl(
+ "getOnDeck",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ Optional.empty(),
+ Optional.of(_e));
}
- List _statusCodes = new ArrayList<>();
- _statusCodes.add("5XX");
- Retries _retries = Retries.builder()
- .action(() -> {
- HttpRequest _r = null;
- try {
- _r = sdkConfiguration.hooks()
- .beforeRequest(
- new BeforeRequestContextImpl(
- "getOnDeck",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- _finalReq.build());
- } catch (Exception _e) {
- throw new NonRetryableException(_e);
- }
- try {
- return _client.send(_r);
- } catch (Exception _e) {
- return sdkConfiguration.hooks()
- .afterError(
- new AfterErrorContextImpl(
- "getOnDeck",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- Optional.empty(),
- Optional.of(_e));
- }
- })
- .retryConfig(_retryConfig)
- .statusCodes(_statusCodes)
- .build();
- HttpResponse _httpRes = sdkConfiguration.hooks()
- .afterSuccess(
- new AfterSuccessContextImpl(
- "getOnDeck",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- _retries.run());
String _contentType = _httpRes
.headers()
.firstValue("Content-Type")
diff --git a/src/main/java/dev/plexapi/sdk/Log.java b/src/main/java/dev/plexapi/sdk/Log.java
index 44e6ada0..28ca5d90 100644
--- a/src/main/java/dev/plexapi/sdk/Log.java
+++ b/src/main/java/dev/plexapi/sdk/Log.java
@@ -21,16 +21,11 @@ import dev.plexapi.sdk.models.operations.LogLineResponse;
import dev.plexapi.sdk.models.operations.LogMultiLineRequestBuilder;
import dev.plexapi.sdk.models.operations.LogMultiLineResponse;
import dev.plexapi.sdk.models.operations.SDKMethodInterfaces.*;
-import dev.plexapi.sdk.utils.BackoffStrategy;
import dev.plexapi.sdk.utils.HTTPClient;
import dev.plexapi.sdk.utils.HTTPRequest;
import dev.plexapi.sdk.utils.Hook.AfterErrorContextImpl;
import dev.plexapi.sdk.utils.Hook.AfterSuccessContextImpl;
import dev.plexapi.sdk.utils.Hook.BeforeRequestContextImpl;
-import dev.plexapi.sdk.utils.Options;
-import dev.plexapi.sdk.utils.Retries.NonRetryableException;
-import dev.plexapi.sdk.utils.Retries;
-import dev.plexapi.sdk.utils.RetryConfig;
import dev.plexapi.sdk.utils.SerializedBody;
import dev.plexapi.sdk.utils.Utils.JsonShape;
import dev.plexapi.sdk.utils.Utils;
@@ -40,11 +35,8 @@ import java.lang.Object;
import java.lang.String;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
-import java.util.ArrayList;
-import java.util.Arrays;
import java.util.List;
-import java.util.Optional;
-import java.util.concurrent.TimeUnit;
+import java.util.Optional;
/**
* Submit logs to the Log Handler for Plex Media Server
@@ -92,35 +84,6 @@ public class Log implements
Level level,
String message,
String source) throws Exception {
- return logLine(level, message, source, Optional.empty());
- }
-
- /**
- * Logging a single line message.
- * This endpoint will write a single-line log message, including a level and source to the main Plex Media Server log.
- *
- * @param level An integer log level to write to the PMS log with.
- 0: Error
- 1: Warning
- 2: Info
- 3: Debug
- 4: Verbose
-
- * @param message The text of the message to write to the log.
- * @param source a string indicating the source of the message.
- * @param options additional options
- * @return The response from the API call
- * @throws Exception if the API call fails
- */
- public LogLineResponse logLine(
- Level level,
- String message,
- String source,
- Optional options) throws Exception {
-
- if (options.isPresent()) {
- options.get().validate(Arrays.asList(Options.Option.RETRY_CONFIG));
- }
LogLineRequest request =
LogLineRequest
.builder()
@@ -149,62 +112,45 @@ public class Log implements
this.sdkConfiguration.securitySource.getSecurity());
HTTPClient _client = this.sdkConfiguration.defaultClient;
- HTTPRequest _finalReq = _req;
- RetryConfig _retryConfig;
- if (options.isPresent() && options.get().retryConfig().isPresent()) {
- _retryConfig = options.get().retryConfig().get();
- } else if (this.sdkConfiguration.retryConfig.isPresent()) {
- _retryConfig = this.sdkConfiguration.retryConfig.get();
- } else {
- _retryConfig = RetryConfig.builder()
- .backoff(BackoffStrategy.builder()
- .initialInterval(500, TimeUnit.MILLISECONDS)
- .maxInterval(60000, TimeUnit.MILLISECONDS)
- .baseFactor((double)(1.5))
- .maxElapsedTime(3600000, TimeUnit.MILLISECONDS)
- .retryConnectError(true)
- .build())
- .build();
+ HttpRequest _r =
+ sdkConfiguration.hooks()
+ .beforeRequest(
+ new BeforeRequestContextImpl(
+ "logLine",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ _req.build());
+ HttpResponse _httpRes;
+ try {
+ _httpRes = _client.send(_r);
+ if (Utils.statusCodeMatches(_httpRes.statusCode(), "400", "401", "4XX", "5XX")) {
+ _httpRes = sdkConfiguration.hooks()
+ .afterError(
+ new AfterErrorContextImpl(
+ "logLine",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ Optional.of(_httpRes),
+ Optional.empty());
+ } else {
+ _httpRes = sdkConfiguration.hooks()
+ .afterSuccess(
+ new AfterSuccessContextImpl(
+ "logLine",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ _httpRes);
+ }
+ } catch (Exception _e) {
+ _httpRes = sdkConfiguration.hooks()
+ .afterError(
+ new AfterErrorContextImpl(
+ "logLine",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ Optional.empty(),
+ Optional.of(_e));
}
- List _statusCodes = new ArrayList<>();
- _statusCodes.add("5XX");
- Retries _retries = Retries.builder()
- .action(() -> {
- HttpRequest _r = null;
- try {
- _r = sdkConfiguration.hooks()
- .beforeRequest(
- new BeforeRequestContextImpl(
- "logLine",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- _finalReq.build());
- } catch (Exception _e) {
- throw new NonRetryableException(_e);
- }
- try {
- return _client.send(_r);
- } catch (Exception _e) {
- return sdkConfiguration.hooks()
- .afterError(
- new AfterErrorContextImpl(
- "logLine",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- Optional.empty(),
- Optional.of(_e));
- }
- })
- .retryConfig(_retryConfig)
- .statusCodes(_statusCodes)
- .build();
- HttpResponse _httpRes = sdkConfiguration.hooks()
- .afterSuccess(
- new AfterSuccessContextImpl(
- "logLine",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- _retries.run());
String _contentType = _httpRes
.headers()
.firstValue("Content-Type")
@@ -331,45 +277,6 @@ public class Log implements
*/
public LogMultiLineResponse logMultiLine(
String request) throws Exception {
- return logMultiLine(request, Optional.empty());
- }
-
- /**
- * Logging a multi-line message
- * This endpoint allows for the batch addition of log entries to the main Plex Media Server log.
- * It accepts a text/plain request body, where each line represents a distinct log entry.
- * Each log entry consists of URL-encoded key-value pairs, specifying log attributes such as 'level', 'message', and 'source'.
- *
- * Log entries are separated by a newline character (`\n`).
- * Each entry's parameters should be URL-encoded to ensure accurate parsing and handling of special characters.
- * This method is efficient for logging multiple entries in a single API call, reducing the overhead of multiple individual requests.
- *
- * The 'level' parameter specifies the log entry's severity or importance, with the following integer values:
- * - `0`: Error - Critical issues that require immediate attention.
- * - `1`: Warning - Important events that are not critical but may indicate potential issues.
- * - `2`: Info - General informational messages about system operation.
- * - `3`: Debug - Detailed information useful for debugging purposes.
- * - `4`: Verbose - Highly detailed diagnostic information for in-depth analysis.
- *
- * The 'message' parameter contains the log text, and 'source' identifies the log message's origin (e.g., an application name or module).
- *
- * Example of a single log entry format:
- * `level=4&message=Sample%20log%20entry&source=applicationName`
- *
- * Ensure each parameter is properly URL-encoded to avoid interpretation issues.
- *
- * @param request The request object containing all of the parameters for the API call.
- * @param options additional options
- * @return The response from the API call
- * @throws Exception if the API call fails
- */
- public LogMultiLineResponse logMultiLine(
- String request,
- Optional options) throws Exception {
-
- if (options.isPresent()) {
- options.get().validate(Arrays.asList(Options.Option.RETRY_CONFIG));
- }
String _baseUrl = Utils.templateUrl(
this.sdkConfiguration.serverUrl, this.sdkConfiguration.getServerVariableDefaults());
String _url = Utils.generateURL(
@@ -398,62 +305,45 @@ public class Log implements
this.sdkConfiguration.securitySource.getSecurity());
HTTPClient _client = this.sdkConfiguration.defaultClient;
- HTTPRequest _finalReq = _req;
- RetryConfig _retryConfig;
- if (options.isPresent() && options.get().retryConfig().isPresent()) {
- _retryConfig = options.get().retryConfig().get();
- } else if (this.sdkConfiguration.retryConfig.isPresent()) {
- _retryConfig = this.sdkConfiguration.retryConfig.get();
- } else {
- _retryConfig = RetryConfig.builder()
- .backoff(BackoffStrategy.builder()
- .initialInterval(500, TimeUnit.MILLISECONDS)
- .maxInterval(60000, TimeUnit.MILLISECONDS)
- .baseFactor((double)(1.5))
- .maxElapsedTime(3600000, TimeUnit.MILLISECONDS)
- .retryConnectError(true)
- .build())
- .build();
+ HttpRequest _r =
+ sdkConfiguration.hooks()
+ .beforeRequest(
+ new BeforeRequestContextImpl(
+ "logMultiLine",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ _req.build());
+ HttpResponse _httpRes;
+ try {
+ _httpRes = _client.send(_r);
+ if (Utils.statusCodeMatches(_httpRes.statusCode(), "400", "401", "4XX", "5XX")) {
+ _httpRes = sdkConfiguration.hooks()
+ .afterError(
+ new AfterErrorContextImpl(
+ "logMultiLine",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ Optional.of(_httpRes),
+ Optional.empty());
+ } else {
+ _httpRes = sdkConfiguration.hooks()
+ .afterSuccess(
+ new AfterSuccessContextImpl(
+ "logMultiLine",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ _httpRes);
+ }
+ } catch (Exception _e) {
+ _httpRes = sdkConfiguration.hooks()
+ .afterError(
+ new AfterErrorContextImpl(
+ "logMultiLine",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ Optional.empty(),
+ Optional.of(_e));
}
- List _statusCodes = new ArrayList<>();
- _statusCodes.add("5XX");
- Retries _retries = Retries.builder()
- .action(() -> {
- HttpRequest _r = null;
- try {
- _r = sdkConfiguration.hooks()
- .beforeRequest(
- new BeforeRequestContextImpl(
- "logMultiLine",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- _finalReq.build());
- } catch (Exception _e) {
- throw new NonRetryableException(_e);
- }
- try {
- return _client.send(_r);
- } catch (Exception _e) {
- return sdkConfiguration.hooks()
- .afterError(
- new AfterErrorContextImpl(
- "logMultiLine",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- Optional.empty(),
- Optional.of(_e));
- }
- })
- .retryConfig(_retryConfig)
- .statusCodes(_statusCodes)
- .build();
- HttpResponse _httpRes = sdkConfiguration.hooks()
- .afterSuccess(
- new AfterSuccessContextImpl(
- "logMultiLine",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- _retries.run());
String _contentType = _httpRes
.headers()
.firstValue("Content-Type")
@@ -538,23 +428,6 @@ public class Log implements
* @throws Exception if the API call fails
*/
public EnablePaperTrailResponse enablePaperTrailDirect() throws Exception {
- return enablePaperTrail(Optional.empty());
- }
-
- /**
- * Enabling Papertrail
- * This endpoint will enable all Plex Media Serverlogs to be sent to the Papertrail networked logging site for a period of time.
- *
- * @param options additional options
- * @return The response from the API call
- * @throws Exception if the API call fails
- */
- public EnablePaperTrailResponse enablePaperTrail(
- Optional options) throws Exception {
-
- if (options.isPresent()) {
- options.get().validate(Arrays.asList(Options.Option.RETRY_CONFIG));
- }
String _baseUrl = Utils.templateUrl(
this.sdkConfiguration.serverUrl, this.sdkConfiguration.getServerVariableDefaults());
String _url = Utils.generateURL(
@@ -570,62 +443,45 @@ public class Log implements
this.sdkConfiguration.securitySource.getSecurity());
HTTPClient _client = this.sdkConfiguration.defaultClient;
- HTTPRequest _finalReq = _req;
- RetryConfig _retryConfig;
- if (options.isPresent() && options.get().retryConfig().isPresent()) {
- _retryConfig = options.get().retryConfig().get();
- } else if (this.sdkConfiguration.retryConfig.isPresent()) {
- _retryConfig = this.sdkConfiguration.retryConfig.get();
- } else {
- _retryConfig = RetryConfig.builder()
- .backoff(BackoffStrategy.builder()
- .initialInterval(500, TimeUnit.MILLISECONDS)
- .maxInterval(60000, TimeUnit.MILLISECONDS)
- .baseFactor((double)(1.5))
- .maxElapsedTime(3600000, TimeUnit.MILLISECONDS)
- .retryConnectError(true)
- .build())
- .build();
+ HttpRequest _r =
+ sdkConfiguration.hooks()
+ .beforeRequest(
+ new BeforeRequestContextImpl(
+ "enablePaperTrail",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ _req.build());
+ HttpResponse _httpRes;
+ try {
+ _httpRes = _client.send(_r);
+ if (Utils.statusCodeMatches(_httpRes.statusCode(), "400", "401", "403", "4XX", "5XX")) {
+ _httpRes = sdkConfiguration.hooks()
+ .afterError(
+ new AfterErrorContextImpl(
+ "enablePaperTrail",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ Optional.of(_httpRes),
+ Optional.empty());
+ } else {
+ _httpRes = sdkConfiguration.hooks()
+ .afterSuccess(
+ new AfterSuccessContextImpl(
+ "enablePaperTrail",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ _httpRes);
+ }
+ } catch (Exception _e) {
+ _httpRes = sdkConfiguration.hooks()
+ .afterError(
+ new AfterErrorContextImpl(
+ "enablePaperTrail",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ Optional.empty(),
+ Optional.of(_e));
}
- List _statusCodes = new ArrayList<>();
- _statusCodes.add("5XX");
- Retries _retries = Retries.builder()
- .action(() -> {
- HttpRequest _r = null;
- try {
- _r = sdkConfiguration.hooks()
- .beforeRequest(
- new BeforeRequestContextImpl(
- "enablePaperTrail",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- _finalReq.build());
- } catch (Exception _e) {
- throw new NonRetryableException(_e);
- }
- try {
- return _client.send(_r);
- } catch (Exception _e) {
- return sdkConfiguration.hooks()
- .afterError(
- new AfterErrorContextImpl(
- "enablePaperTrail",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- Optional.empty(),
- Optional.of(_e));
- }
- })
- .retryConfig(_retryConfig)
- .statusCodes(_statusCodes)
- .build();
- HttpResponse _httpRes = sdkConfiguration.hooks()
- .afterSuccess(
- new AfterSuccessContextImpl(
- "enablePaperTrail",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- _retries.run());
String _contentType = _httpRes
.headers()
.firstValue("Content-Type")
diff --git a/src/main/java/dev/plexapi/sdk/Media.java b/src/main/java/dev/plexapi/sdk/Media.java
index 9955706b..ac12e6f4 100644
--- a/src/main/java/dev/plexapi/sdk/Media.java
+++ b/src/main/java/dev/plexapi/sdk/Media.java
@@ -32,27 +32,19 @@ import dev.plexapi.sdk.models.operations.SDKMethodInterfaces.*;
import dev.plexapi.sdk.models.operations.UpdatePlayProgressRequest;
import dev.plexapi.sdk.models.operations.UpdatePlayProgressRequestBuilder;
import dev.plexapi.sdk.models.operations.UpdatePlayProgressResponse;
-import dev.plexapi.sdk.utils.BackoffStrategy;
import dev.plexapi.sdk.utils.HTTPClient;
import dev.plexapi.sdk.utils.HTTPRequest;
import dev.plexapi.sdk.utils.Hook.AfterErrorContextImpl;
import dev.plexapi.sdk.utils.Hook.AfterSuccessContextImpl;
import dev.plexapi.sdk.utils.Hook.BeforeRequestContextImpl;
-import dev.plexapi.sdk.utils.Options;
-import dev.plexapi.sdk.utils.Retries.NonRetryableException;
-import dev.plexapi.sdk.utils.Retries;
-import dev.plexapi.sdk.utils.RetryConfig;
import dev.plexapi.sdk.utils.Utils;
import java.io.InputStream;
import java.lang.Exception;
import java.lang.String;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
-import java.util.ArrayList;
-import java.util.Arrays;
import java.util.List;
-import java.util.Optional;
-import java.util.concurrent.TimeUnit;
+import java.util.Optional;
/**
* API Calls interacting with Plex Media Server Media
@@ -90,24 +82,6 @@ public class Media implements
*/
public MarkPlayedResponse markPlayed(
double key) throws Exception {
- return markPlayed(key, Optional.empty());
- }
-
- /**
- * Mark Media Played
- * This will mark the provided media key as Played.
- * @param key The media key to mark as played
- * @param options additional options
- * @return The response from the API call
- * @throws Exception if the API call fails
- */
- public MarkPlayedResponse markPlayed(
- double key,
- Optional options) throws Exception {
-
- if (options.isPresent()) {
- options.get().validate(Arrays.asList(Options.Option.RETRY_CONFIG));
- }
MarkPlayedRequest request =
MarkPlayedRequest
.builder()
@@ -134,62 +108,45 @@ public class Media implements
this.sdkConfiguration.securitySource.getSecurity());
HTTPClient _client = this.sdkConfiguration.defaultClient;
- HTTPRequest _finalReq = _req;
- RetryConfig _retryConfig;
- if (options.isPresent() && options.get().retryConfig().isPresent()) {
- _retryConfig = options.get().retryConfig().get();
- } else if (this.sdkConfiguration.retryConfig.isPresent()) {
- _retryConfig = this.sdkConfiguration.retryConfig.get();
- } else {
- _retryConfig = RetryConfig.builder()
- .backoff(BackoffStrategy.builder()
- .initialInterval(500, TimeUnit.MILLISECONDS)
- .maxInterval(60000, TimeUnit.MILLISECONDS)
- .baseFactor((double)(1.5))
- .maxElapsedTime(3600000, TimeUnit.MILLISECONDS)
- .retryConnectError(true)
- .build())
- .build();
+ HttpRequest _r =
+ sdkConfiguration.hooks()
+ .beforeRequest(
+ new BeforeRequestContextImpl(
+ "markPlayed",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ _req.build());
+ HttpResponse _httpRes;
+ try {
+ _httpRes = _client.send(_r);
+ if (Utils.statusCodeMatches(_httpRes.statusCode(), "400", "401", "4XX", "5XX")) {
+ _httpRes = sdkConfiguration.hooks()
+ .afterError(
+ new AfterErrorContextImpl(
+ "markPlayed",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ Optional.of(_httpRes),
+ Optional.empty());
+ } else {
+ _httpRes = sdkConfiguration.hooks()
+ .afterSuccess(
+ new AfterSuccessContextImpl(
+ "markPlayed",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ _httpRes);
+ }
+ } catch (Exception _e) {
+ _httpRes = sdkConfiguration.hooks()
+ .afterError(
+ new AfterErrorContextImpl(
+ "markPlayed",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ Optional.empty(),
+ Optional.of(_e));
}
- List _statusCodes = new ArrayList<>();
- _statusCodes.add("5XX");
- Retries _retries = Retries.builder()
- .action(() -> {
- HttpRequest _r = null;
- try {
- _r = sdkConfiguration.hooks()
- .beforeRequest(
- new BeforeRequestContextImpl(
- "markPlayed",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- _finalReq.build());
- } catch (Exception _e) {
- throw new NonRetryableException(_e);
- }
- try {
- return _client.send(_r);
- } catch (Exception _e) {
- return sdkConfiguration.hooks()
- .afterError(
- new AfterErrorContextImpl(
- "markPlayed",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- Optional.empty(),
- Optional.of(_e));
- }
- })
- .retryConfig(_retryConfig)
- .statusCodes(_statusCodes)
- .build();
- HttpResponse _httpRes = sdkConfiguration.hooks()
- .afterSuccess(
- new AfterSuccessContextImpl(
- "markPlayed",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- _retries.run());
String _contentType = _httpRes
.headers()
.firstValue("Content-Type")
@@ -274,24 +231,6 @@ public class Media implements
*/
public MarkUnplayedResponse markUnplayed(
double key) throws Exception {
- return markUnplayed(key, Optional.empty());
- }
-
- /**
- * Mark Media Unplayed
- * This will mark the provided media key as Unplayed.
- * @param key The media key to mark as Unplayed
- * @param options additional options
- * @return The response from the API call
- * @throws Exception if the API call fails
- */
- public MarkUnplayedResponse markUnplayed(
- double key,
- Optional options) throws Exception {
-
- if (options.isPresent()) {
- options.get().validate(Arrays.asList(Options.Option.RETRY_CONFIG));
- }
MarkUnplayedRequest request =
MarkUnplayedRequest
.builder()
@@ -318,62 +257,45 @@ public class Media implements
this.sdkConfiguration.securitySource.getSecurity());
HTTPClient _client = this.sdkConfiguration.defaultClient;
- HTTPRequest _finalReq = _req;
- RetryConfig _retryConfig;
- if (options.isPresent() && options.get().retryConfig().isPresent()) {
- _retryConfig = options.get().retryConfig().get();
- } else if (this.sdkConfiguration.retryConfig.isPresent()) {
- _retryConfig = this.sdkConfiguration.retryConfig.get();
- } else {
- _retryConfig = RetryConfig.builder()
- .backoff(BackoffStrategy.builder()
- .initialInterval(500, TimeUnit.MILLISECONDS)
- .maxInterval(60000, TimeUnit.MILLISECONDS)
- .baseFactor((double)(1.5))
- .maxElapsedTime(3600000, TimeUnit.MILLISECONDS)
- .retryConnectError(true)
- .build())
- .build();
+ HttpRequest _r =
+ sdkConfiguration.hooks()
+ .beforeRequest(
+ new BeforeRequestContextImpl(
+ "markUnplayed",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ _req.build());
+ HttpResponse _httpRes;
+ try {
+ _httpRes = _client.send(_r);
+ if (Utils.statusCodeMatches(_httpRes.statusCode(), "400", "401", "4XX", "5XX")) {
+ _httpRes = sdkConfiguration.hooks()
+ .afterError(
+ new AfterErrorContextImpl(
+ "markUnplayed",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ Optional.of(_httpRes),
+ Optional.empty());
+ } else {
+ _httpRes = sdkConfiguration.hooks()
+ .afterSuccess(
+ new AfterSuccessContextImpl(
+ "markUnplayed",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ _httpRes);
+ }
+ } catch (Exception _e) {
+ _httpRes = sdkConfiguration.hooks()
+ .afterError(
+ new AfterErrorContextImpl(
+ "markUnplayed",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ Optional.empty(),
+ Optional.of(_e));
}
- List _statusCodes = new ArrayList<>();
- _statusCodes.add("5XX");
- Retries _retries = Retries.builder()
- .action(() -> {
- HttpRequest _r = null;
- try {
- _r = sdkConfiguration.hooks()
- .beforeRequest(
- new BeforeRequestContextImpl(
- "markUnplayed",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- _finalReq.build());
- } catch (Exception _e) {
- throw new NonRetryableException(_e);
- }
- try {
- return _client.send(_r);
- } catch (Exception _e) {
- return sdkConfiguration.hooks()
- .afterError(
- new AfterErrorContextImpl(
- "markUnplayed",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- Optional.empty(),
- Optional.of(_e));
- }
- })
- .retryConfig(_retryConfig)
- .statusCodes(_statusCodes)
- .build();
- HttpResponse _httpRes = sdkConfiguration.hooks()
- .afterSuccess(
- new AfterSuccessContextImpl(
- "markUnplayed",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- _retries.run());
String _contentType = _httpRes
.headers()
.firstValue("Content-Type")
@@ -464,29 +386,6 @@ public class Media implements
String key,
double time,
String state) throws Exception {
- return updatePlayProgress(key, time, state, Optional.empty());
- }
-
- /**
- * Update Media Play Progress
- * This API command can be used to update the play progress of a media item.
- *
- * @param key the media key
- * @param time The time, in milliseconds, used to set the media playback progress.
- * @param state The playback state of the media item.
- * @param options additional options
- * @return The response from the API call
- * @throws Exception if the API call fails
- */
- public UpdatePlayProgressResponse updatePlayProgress(
- String key,
- double time,
- String state,
- Optional options) throws Exception {
-
- if (options.isPresent()) {
- options.get().validate(Arrays.asList(Options.Option.RETRY_CONFIG));
- }
UpdatePlayProgressRequest request =
UpdatePlayProgressRequest
.builder()
@@ -515,62 +414,45 @@ public class Media implements
this.sdkConfiguration.securitySource.getSecurity());
HTTPClient _client = this.sdkConfiguration.defaultClient;
- HTTPRequest _finalReq = _req;
- RetryConfig _retryConfig;
- if (options.isPresent() && options.get().retryConfig().isPresent()) {
- _retryConfig = options.get().retryConfig().get();
- } else if (this.sdkConfiguration.retryConfig.isPresent()) {
- _retryConfig = this.sdkConfiguration.retryConfig.get();
- } else {
- _retryConfig = RetryConfig.builder()
- .backoff(BackoffStrategy.builder()
- .initialInterval(500, TimeUnit.MILLISECONDS)
- .maxInterval(60000, TimeUnit.MILLISECONDS)
- .baseFactor((double)(1.5))
- .maxElapsedTime(3600000, TimeUnit.MILLISECONDS)
- .retryConnectError(true)
- .build())
- .build();
+ HttpRequest _r =
+ sdkConfiguration.hooks()
+ .beforeRequest(
+ new BeforeRequestContextImpl(
+ "updatePlayProgress",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ _req.build());
+ HttpResponse _httpRes;
+ try {
+ _httpRes = _client.send(_r);
+ if (Utils.statusCodeMatches(_httpRes.statusCode(), "400", "401", "4XX", "5XX")) {
+ _httpRes = sdkConfiguration.hooks()
+ .afterError(
+ new AfterErrorContextImpl(
+ "updatePlayProgress",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ Optional.of(_httpRes),
+ Optional.empty());
+ } else {
+ _httpRes = sdkConfiguration.hooks()
+ .afterSuccess(
+ new AfterSuccessContextImpl(
+ "updatePlayProgress",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ _httpRes);
+ }
+ } catch (Exception _e) {
+ _httpRes = sdkConfiguration.hooks()
+ .afterError(
+ new AfterErrorContextImpl(
+ "updatePlayProgress",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ Optional.empty(),
+ Optional.of(_e));
}
- List _statusCodes = new ArrayList<>();
- _statusCodes.add("5XX");
- Retries _retries = Retries.builder()
- .action(() -> {
- HttpRequest _r = null;
- try {
- _r = sdkConfiguration.hooks()
- .beforeRequest(
- new BeforeRequestContextImpl(
- "updatePlayProgress",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- _finalReq.build());
- } catch (Exception _e) {
- throw new NonRetryableException(_e);
- }
- try {
- return _client.send(_r);
- } catch (Exception _e) {
- return sdkConfiguration.hooks()
- .afterError(
- new AfterErrorContextImpl(
- "updatePlayProgress",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- Optional.empty(),
- Optional.of(_e));
- }
- })
- .retryConfig(_retryConfig)
- .statusCodes(_statusCodes)
- .build();
- HttpResponse _httpRes = sdkConfiguration.hooks()
- .afterSuccess(
- new AfterSuccessContextImpl(
- "updatePlayProgress",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- _retries.run());
String _contentType = _httpRes
.headers()
.firstValue("Content-Type")
@@ -655,24 +537,6 @@ public class Media implements
*/
public GetBannerImageResponse getBannerImage(
GetBannerImageRequest request) throws Exception {
- return getBannerImage(request, Optional.empty());
- }
-
- /**
- * Get Banner Image
- * Gets the banner image of the media item
- * @param request The request object containing all of the parameters for the API call.
- * @param options additional options
- * @return The response from the API call
- * @throws Exception if the API call fails
- */
- public GetBannerImageResponse getBannerImage(
- GetBannerImageRequest request,
- Optional options) throws Exception {
-
- if (options.isPresent()) {
- options.get().validate(Arrays.asList(Options.Option.RETRY_CONFIG));
- }
String _baseUrl = Utils.templateUrl(
this.sdkConfiguration.serverUrl, this.sdkConfiguration.getServerVariableDefaults());
String _url = Utils.generateURL(
@@ -696,62 +560,45 @@ public class Media implements
this.sdkConfiguration.securitySource.getSecurity());
HTTPClient _client = this.sdkConfiguration.defaultClient;
- HTTPRequest _finalReq = _req;
- RetryConfig _retryConfig;
- if (options.isPresent() && options.get().retryConfig().isPresent()) {
- _retryConfig = options.get().retryConfig().get();
- } else if (this.sdkConfiguration.retryConfig.isPresent()) {
- _retryConfig = this.sdkConfiguration.retryConfig.get();
- } else {
- _retryConfig = RetryConfig.builder()
- .backoff(BackoffStrategy.builder()
- .initialInterval(500, TimeUnit.MILLISECONDS)
- .maxInterval(60000, TimeUnit.MILLISECONDS)
- .baseFactor((double)(1.5))
- .maxElapsedTime(3600000, TimeUnit.MILLISECONDS)
- .retryConnectError(true)
- .build())
- .build();
+ HttpRequest _r =
+ sdkConfiguration.hooks()
+ .beforeRequest(
+ new BeforeRequestContextImpl(
+ "get-banner-image",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ _req.build());
+ HttpResponse _httpRes;
+ try {
+ _httpRes = _client.send(_r);
+ if (Utils.statusCodeMatches(_httpRes.statusCode(), "400", "401", "4XX", "5XX")) {
+ _httpRes = sdkConfiguration.hooks()
+ .afterError(
+ new AfterErrorContextImpl(
+ "get-banner-image",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ Optional.of(_httpRes),
+ Optional.empty());
+ } else {
+ _httpRes = sdkConfiguration.hooks()
+ .afterSuccess(
+ new AfterSuccessContextImpl(
+ "get-banner-image",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ _httpRes);
+ }
+ } catch (Exception _e) {
+ _httpRes = sdkConfiguration.hooks()
+ .afterError(
+ new AfterErrorContextImpl(
+ "get-banner-image",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ Optional.empty(),
+ Optional.of(_e));
}
- List _statusCodes = new ArrayList<>();
- _statusCodes.add("5XX");
- Retries _retries = Retries.builder()
- .action(() -> {
- HttpRequest _r = null;
- try {
- _r = sdkConfiguration.hooks()
- .beforeRequest(
- new BeforeRequestContextImpl(
- "get-banner-image",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- _finalReq.build());
- } catch (Exception _e) {
- throw new NonRetryableException(_e);
- }
- try {
- return _client.send(_r);
- } catch (Exception _e) {
- return sdkConfiguration.hooks()
- .afterError(
- new AfterErrorContextImpl(
- "get-banner-image",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- Optional.empty(),
- Optional.of(_e));
- }
- })
- .retryConfig(_retryConfig)
- .statusCodes(_statusCodes)
- .build();
- HttpResponse _httpRes = sdkConfiguration.hooks()
- .afterSuccess(
- new AfterSuccessContextImpl(
- "get-banner-image",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- _retries.run());
String _contentType = _httpRes
.headers()
.firstValue("Content-Type")
@@ -847,24 +694,6 @@ public class Media implements
*/
public GetThumbImageResponse getThumbImage(
GetThumbImageRequest request) throws Exception {
- return getThumbImage(request, Optional.empty());
- }
-
- /**
- * Get Thumb Image
- * Gets the thumbnail image of the media item
- * @param request The request object containing all of the parameters for the API call.
- * @param options additional options
- * @return The response from the API call
- * @throws Exception if the API call fails
- */
- public GetThumbImageResponse getThumbImage(
- GetThumbImageRequest request,
- Optional options) throws Exception {
-
- if (options.isPresent()) {
- options.get().validate(Arrays.asList(Options.Option.RETRY_CONFIG));
- }
String _baseUrl = Utils.templateUrl(
this.sdkConfiguration.serverUrl, this.sdkConfiguration.getServerVariableDefaults());
String _url = Utils.generateURL(
@@ -888,62 +717,45 @@ public class Media implements
this.sdkConfiguration.securitySource.getSecurity());
HTTPClient _client = this.sdkConfiguration.defaultClient;
- HTTPRequest _finalReq = _req;
- RetryConfig _retryConfig;
- if (options.isPresent() && options.get().retryConfig().isPresent()) {
- _retryConfig = options.get().retryConfig().get();
- } else if (this.sdkConfiguration.retryConfig.isPresent()) {
- _retryConfig = this.sdkConfiguration.retryConfig.get();
- } else {
- _retryConfig = RetryConfig.builder()
- .backoff(BackoffStrategy.builder()
- .initialInterval(500, TimeUnit.MILLISECONDS)
- .maxInterval(60000, TimeUnit.MILLISECONDS)
- .baseFactor((double)(1.5))
- .maxElapsedTime(3600000, TimeUnit.MILLISECONDS)
- .retryConnectError(true)
- .build())
- .build();
+ HttpRequest _r =
+ sdkConfiguration.hooks()
+ .beforeRequest(
+ new BeforeRequestContextImpl(
+ "get-thumb-image",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ _req.build());
+ HttpResponse _httpRes;
+ try {
+ _httpRes = _client.send(_r);
+ if (Utils.statusCodeMatches(_httpRes.statusCode(), "400", "401", "4XX", "5XX")) {
+ _httpRes = sdkConfiguration.hooks()
+ .afterError(
+ new AfterErrorContextImpl(
+ "get-thumb-image",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ Optional.of(_httpRes),
+ Optional.empty());
+ } else {
+ _httpRes = sdkConfiguration.hooks()
+ .afterSuccess(
+ new AfterSuccessContextImpl(
+ "get-thumb-image",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ _httpRes);
+ }
+ } catch (Exception _e) {
+ _httpRes = sdkConfiguration.hooks()
+ .afterError(
+ new AfterErrorContextImpl(
+ "get-thumb-image",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ Optional.empty(),
+ Optional.of(_e));
}
- List _statusCodes = new ArrayList<>();
- _statusCodes.add("5XX");
- Retries _retries = Retries.builder()
- .action(() -> {
- HttpRequest _r = null;
- try {
- _r = sdkConfiguration.hooks()
- .beforeRequest(
- new BeforeRequestContextImpl(
- "get-thumb-image",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- _finalReq.build());
- } catch (Exception _e) {
- throw new NonRetryableException(_e);
- }
- try {
- return _client.send(_r);
- } catch (Exception _e) {
- return sdkConfiguration.hooks()
- .afterError(
- new AfterErrorContextImpl(
- "get-thumb-image",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- Optional.empty(),
- Optional.of(_e));
- }
- })
- .retryConfig(_retryConfig)
- .statusCodes(_statusCodes)
- .build();
- HttpResponse _httpRes = sdkConfiguration.hooks()
- .afterSuccess(
- new AfterSuccessContextImpl(
- "get-thumb-image",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- _retries.run());
String _contentType = _httpRes
.headers()
.firstValue("Content-Type")
diff --git a/src/main/java/dev/plexapi/sdk/Playlists.java b/src/main/java/dev/plexapi/sdk/Playlists.java
index 4fd81189..3fd57515 100644
--- a/src/main/java/dev/plexapi/sdk/Playlists.java
+++ b/src/main/java/dev/plexapi/sdk/Playlists.java
@@ -61,16 +61,11 @@ import dev.plexapi.sdk.models.operations.UpdatePlaylistResponse;
import dev.plexapi.sdk.models.operations.UploadPlaylistRequest;
import dev.plexapi.sdk.models.operations.UploadPlaylistRequestBuilder;
import dev.plexapi.sdk.models.operations.UploadPlaylistResponse;
-import dev.plexapi.sdk.utils.BackoffStrategy;
import dev.plexapi.sdk.utils.HTTPClient;
import dev.plexapi.sdk.utils.HTTPRequest;
import dev.plexapi.sdk.utils.Hook.AfterErrorContextImpl;
import dev.plexapi.sdk.utils.Hook.AfterSuccessContextImpl;
import dev.plexapi.sdk.utils.Hook.BeforeRequestContextImpl;
-import dev.plexapi.sdk.utils.Options;
-import dev.plexapi.sdk.utils.Retries.NonRetryableException;
-import dev.plexapi.sdk.utils.Retries;
-import dev.plexapi.sdk.utils.RetryConfig;
import dev.plexapi.sdk.utils.Utils;
import java.io.InputStream;
import java.lang.Double;
@@ -78,11 +73,8 @@ import java.lang.Exception;
import java.lang.String;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
-import java.util.ArrayList;
-import java.util.Arrays;
import java.util.List;
-import java.util.Optional;
-import java.util.concurrent.TimeUnit;
+import java.util.Optional;
/**
* Playlists are ordered collections of media. They can be dumb (just a list of media) or smart (based on a media query, such as "all albums from 2017").
@@ -133,27 +125,6 @@ public class Playlists implements
*/
public CreatePlaylistResponse createPlaylist(
CreatePlaylistRequest request) throws Exception {
- return createPlaylist(request, Optional.empty());
- }
-
- /**
- * Create a Playlist
- * Create a new playlist. By default the playlist is blank. To create a playlist along with a first item, pass:
- * - `uri` - The content URI for what we're playing (e.g. `server://1234/com.plexapp.plugins.library/library/metadata/1`).
- * - `playQueueID` - To create a playlist from an existing play queue.
- *
- * @param request The request object containing all of the parameters for the API call.
- * @param options additional options
- * @return The response from the API call
- * @throws Exception if the API call fails
- */
- public CreatePlaylistResponse createPlaylist(
- CreatePlaylistRequest request,
- Optional options) throws Exception {
-
- if (options.isPresent()) {
- options.get().validate(Arrays.asList(Options.Option.RETRY_CONFIG));
- }
String _baseUrl = Utils.templateUrl(
this.sdkConfiguration.serverUrl, this.sdkConfiguration.getServerVariableDefaults());
String _url = Utils.generateURL(
@@ -174,62 +145,45 @@ public class Playlists implements
this.sdkConfiguration.securitySource.getSecurity());
HTTPClient _client = this.sdkConfiguration.defaultClient;
- HTTPRequest _finalReq = _req;
- RetryConfig _retryConfig;
- if (options.isPresent() && options.get().retryConfig().isPresent()) {
- _retryConfig = options.get().retryConfig().get();
- } else if (this.sdkConfiguration.retryConfig.isPresent()) {
- _retryConfig = this.sdkConfiguration.retryConfig.get();
- } else {
- _retryConfig = RetryConfig.builder()
- .backoff(BackoffStrategy.builder()
- .initialInterval(500, TimeUnit.MILLISECONDS)
- .maxInterval(60000, TimeUnit.MILLISECONDS)
- .baseFactor((double)(1.5))
- .maxElapsedTime(3600000, TimeUnit.MILLISECONDS)
- .retryConnectError(true)
- .build())
- .build();
+ HttpRequest _r =
+ sdkConfiguration.hooks()
+ .beforeRequest(
+ new BeforeRequestContextImpl(
+ "createPlaylist",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ _req.build());
+ HttpResponse _httpRes;
+ try {
+ _httpRes = _client.send(_r);
+ if (Utils.statusCodeMatches(_httpRes.statusCode(), "400", "401", "4XX", "5XX")) {
+ _httpRes = sdkConfiguration.hooks()
+ .afterError(
+ new AfterErrorContextImpl(
+ "createPlaylist",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ Optional.of(_httpRes),
+ Optional.empty());
+ } else {
+ _httpRes = sdkConfiguration.hooks()
+ .afterSuccess(
+ new AfterSuccessContextImpl(
+ "createPlaylist",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ _httpRes);
+ }
+ } catch (Exception _e) {
+ _httpRes = sdkConfiguration.hooks()
+ .afterError(
+ new AfterErrorContextImpl(
+ "createPlaylist",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ Optional.empty(),
+ Optional.of(_e));
}
- List _statusCodes = new ArrayList<>();
- _statusCodes.add("5XX");
- Retries _retries = Retries.builder()
- .action(() -> {
- HttpRequest _r = null;
- try {
- _r = sdkConfiguration.hooks()
- .beforeRequest(
- new BeforeRequestContextImpl(
- "createPlaylist",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- _finalReq.build());
- } catch (Exception _e) {
- throw new NonRetryableException(_e);
- }
- try {
- return _client.send(_r);
- } catch (Exception _e) {
- return sdkConfiguration.hooks()
- .afterError(
- new AfterErrorContextImpl(
- "createPlaylist",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- Optional.empty(),
- Optional.of(_e));
- }
- })
- .retryConfig(_retryConfig)
- .statusCodes(_statusCodes)
- .build();
- HttpResponse _httpRes = sdkConfiguration.hooks()
- .afterSuccess(
- new AfterSuccessContextImpl(
- "createPlaylist",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- _retries.run());
String _contentType = _httpRes
.headers()
.firstValue("Content-Type")
@@ -323,7 +277,7 @@ public class Playlists implements
* @throws Exception if the API call fails
*/
public GetPlaylistsResponse getPlaylistsDirect() throws Exception {
- return getPlaylists(Optional.empty(), Optional.empty(), Optional.empty());
+ return getPlaylists(Optional.empty(), Optional.empty());
}
/**
@@ -331,18 +285,12 @@ public class Playlists implements
* Get All Playlists given the specified filters.
* @param playlistType limit to a type of playlist.
* @param smart type of playlists to return (default is all).
- * @param options additional options
* @return The response from the API call
* @throws Exception if the API call fails
*/
public GetPlaylistsResponse getPlaylists(
Optional extends PlaylistType> playlistType,
- Optional extends QueryParamSmart> smart,
- Optional options) throws Exception {
-
- if (options.isPresent()) {
- options.get().validate(Arrays.asList(Options.Option.RETRY_CONFIG));
- }
+ Optional extends QueryParamSmart> smart) throws Exception {
GetPlaylistsRequest request =
GetPlaylistsRequest
.builder()
@@ -370,62 +318,45 @@ public class Playlists implements
this.sdkConfiguration.securitySource.getSecurity());
HTTPClient _client = this.sdkConfiguration.defaultClient;
- HTTPRequest _finalReq = _req;
- RetryConfig _retryConfig;
- if (options.isPresent() && options.get().retryConfig().isPresent()) {
- _retryConfig = options.get().retryConfig().get();
- } else if (this.sdkConfiguration.retryConfig.isPresent()) {
- _retryConfig = this.sdkConfiguration.retryConfig.get();
- } else {
- _retryConfig = RetryConfig.builder()
- .backoff(BackoffStrategy.builder()
- .initialInterval(500, TimeUnit.MILLISECONDS)
- .maxInterval(60000, TimeUnit.MILLISECONDS)
- .baseFactor((double)(1.5))
- .maxElapsedTime(3600000, TimeUnit.MILLISECONDS)
- .retryConnectError(true)
- .build())
- .build();
+ HttpRequest _r =
+ sdkConfiguration.hooks()
+ .beforeRequest(
+ new BeforeRequestContextImpl(
+ "getPlaylists",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ _req.build());
+ HttpResponse _httpRes;
+ try {
+ _httpRes = _client.send(_r);
+ if (Utils.statusCodeMatches(_httpRes.statusCode(), "400", "401", "4XX", "5XX")) {
+ _httpRes = sdkConfiguration.hooks()
+ .afterError(
+ new AfterErrorContextImpl(
+ "getPlaylists",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ Optional.of(_httpRes),
+ Optional.empty());
+ } else {
+ _httpRes = sdkConfiguration.hooks()
+ .afterSuccess(
+ new AfterSuccessContextImpl(
+ "getPlaylists",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ _httpRes);
+ }
+ } catch (Exception _e) {
+ _httpRes = sdkConfiguration.hooks()
+ .afterError(
+ new AfterErrorContextImpl(
+ "getPlaylists",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ Optional.empty(),
+ Optional.of(_e));
}
- List _statusCodes = new ArrayList<>();
- _statusCodes.add("5XX");
- Retries _retries = Retries.builder()
- .action(() -> {
- HttpRequest _r = null;
- try {
- _r = sdkConfiguration.hooks()
- .beforeRequest(
- new BeforeRequestContextImpl(
- "getPlaylists",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- _finalReq.build());
- } catch (Exception _e) {
- throw new NonRetryableException(_e);
- }
- try {
- return _client.send(_r);
- } catch (Exception _e) {
- return sdkConfiguration.hooks()
- .afterError(
- new AfterErrorContextImpl(
- "getPlaylists",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- Optional.empty(),
- Optional.of(_e));
- }
- })
- .retryConfig(_retryConfig)
- .statusCodes(_statusCodes)
- .build();
- HttpResponse _httpRes = sdkConfiguration.hooks()
- .afterSuccess(
- new AfterSuccessContextImpl(
- "getPlaylists",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- _retries.run());
String _contentType = _httpRes
.headers()
.firstValue("Content-Type")
@@ -525,26 +456,6 @@ public class Playlists implements
*/
public GetPlaylistResponse getPlaylist(
double playlistID) throws Exception {
- return getPlaylist(playlistID, Optional.empty());
- }
-
- /**
- * Retrieve Playlist
- * Gets detailed metadata for a playlist. A playlist for many purposes (rating, editing metadata, tagging), can be treated like a regular metadata item:
- * Smart playlist details contain the `content` attribute. This is the content URI for the generator. This can then be parsed by a client to provide smart playlist editing.
- *
- * @param playlistID the ID of the playlist
- * @param options additional options
- * @return The response from the API call
- * @throws Exception if the API call fails
- */
- public GetPlaylistResponse getPlaylist(
- double playlistID,
- Optional options) throws Exception {
-
- if (options.isPresent()) {
- options.get().validate(Arrays.asList(Options.Option.RETRY_CONFIG));
- }
GetPlaylistRequest request =
GetPlaylistRequest
.builder()
@@ -568,62 +479,45 @@ public class Playlists implements
this.sdkConfiguration.securitySource.getSecurity());
HTTPClient _client = this.sdkConfiguration.defaultClient;
- HTTPRequest _finalReq = _req;
- RetryConfig _retryConfig;
- if (options.isPresent() && options.get().retryConfig().isPresent()) {
- _retryConfig = options.get().retryConfig().get();
- } else if (this.sdkConfiguration.retryConfig.isPresent()) {
- _retryConfig = this.sdkConfiguration.retryConfig.get();
- } else {
- _retryConfig = RetryConfig.builder()
- .backoff(BackoffStrategy.builder()
- .initialInterval(500, TimeUnit.MILLISECONDS)
- .maxInterval(60000, TimeUnit.MILLISECONDS)
- .baseFactor((double)(1.5))
- .maxElapsedTime(3600000, TimeUnit.MILLISECONDS)
- .retryConnectError(true)
- .build())
- .build();
+ HttpRequest _r =
+ sdkConfiguration.hooks()
+ .beforeRequest(
+ new BeforeRequestContextImpl(
+ "getPlaylist",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ _req.build());
+ HttpResponse _httpRes;
+ try {
+ _httpRes = _client.send(_r);
+ if (Utils.statusCodeMatches(_httpRes.statusCode(), "400", "401", "4XX", "5XX")) {
+ _httpRes = sdkConfiguration.hooks()
+ .afterError(
+ new AfterErrorContextImpl(
+ "getPlaylist",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ Optional.of(_httpRes),
+ Optional.empty());
+ } else {
+ _httpRes = sdkConfiguration.hooks()
+ .afterSuccess(
+ new AfterSuccessContextImpl(
+ "getPlaylist",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ _httpRes);
+ }
+ } catch (Exception _e) {
+ _httpRes = sdkConfiguration.hooks()
+ .afterError(
+ new AfterErrorContextImpl(
+ "getPlaylist",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ Optional.empty(),
+ Optional.of(_e));
}
- List _statusCodes = new ArrayList<>();
- _statusCodes.add("5XX");
- Retries _retries = Retries.builder()
- .action(() -> {
- HttpRequest _r = null;
- try {
- _r = sdkConfiguration.hooks()
- .beforeRequest(
- new BeforeRequestContextImpl(
- "getPlaylist",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- _finalReq.build());
- } catch (Exception _e) {
- throw new NonRetryableException(_e);
- }
- try {
- return _client.send(_r);
- } catch (Exception _e) {
- return sdkConfiguration.hooks()
- .afterError(
- new AfterErrorContextImpl(
- "getPlaylist",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- Optional.empty(),
- Optional.of(_e));
- }
- })
- .retryConfig(_retryConfig)
- .statusCodes(_statusCodes)
- .build();
- HttpResponse _httpRes = sdkConfiguration.hooks()
- .afterSuccess(
- new AfterSuccessContextImpl(
- "getPlaylist",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- _retries.run());
String _contentType = _httpRes
.headers()
.firstValue("Content-Type")
@@ -721,25 +615,6 @@ public class Playlists implements
*/
public DeletePlaylistResponse deletePlaylist(
double playlistID) throws Exception {
- return deletePlaylist(playlistID, Optional.empty());
- }
-
- /**
- * Deletes a Playlist
- * This endpoint will delete a playlist
- *
- * @param playlistID the ID of the playlist
- * @param options additional options
- * @return The response from the API call
- * @throws Exception if the API call fails
- */
- public DeletePlaylistResponse deletePlaylist(
- double playlistID,
- Optional options) throws Exception {
-
- if (options.isPresent()) {
- options.get().validate(Arrays.asList(Options.Option.RETRY_CONFIG));
- }
DeletePlaylistRequest request =
DeletePlaylistRequest
.builder()
@@ -763,62 +638,45 @@ public class Playlists implements
this.sdkConfiguration.securitySource.getSecurity());
HTTPClient _client = this.sdkConfiguration.defaultClient;
- HTTPRequest _finalReq = _req;
- RetryConfig _retryConfig;
- if (options.isPresent() && options.get().retryConfig().isPresent()) {
- _retryConfig = options.get().retryConfig().get();
- } else if (this.sdkConfiguration.retryConfig.isPresent()) {
- _retryConfig = this.sdkConfiguration.retryConfig.get();
- } else {
- _retryConfig = RetryConfig.builder()
- .backoff(BackoffStrategy.builder()
- .initialInterval(500, TimeUnit.MILLISECONDS)
- .maxInterval(60000, TimeUnit.MILLISECONDS)
- .baseFactor((double)(1.5))
- .maxElapsedTime(3600000, TimeUnit.MILLISECONDS)
- .retryConnectError(true)
- .build())
- .build();
+ HttpRequest _r =
+ sdkConfiguration.hooks()
+ .beforeRequest(
+ new BeforeRequestContextImpl(
+ "deletePlaylist",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ _req.build());
+ HttpResponse _httpRes;
+ try {
+ _httpRes = _client.send(_r);
+ if (Utils.statusCodeMatches(_httpRes.statusCode(), "400", "401", "4XX", "5XX")) {
+ _httpRes = sdkConfiguration.hooks()
+ .afterError(
+ new AfterErrorContextImpl(
+ "deletePlaylist",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ Optional.of(_httpRes),
+ Optional.empty());
+ } else {
+ _httpRes = sdkConfiguration.hooks()
+ .afterSuccess(
+ new AfterSuccessContextImpl(
+ "deletePlaylist",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ _httpRes);
+ }
+ } catch (Exception _e) {
+ _httpRes = sdkConfiguration.hooks()
+ .afterError(
+ new AfterErrorContextImpl(
+ "deletePlaylist",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ Optional.empty(),
+ Optional.of(_e));
}
- List _statusCodes = new ArrayList<>();
- _statusCodes.add("5XX");
- Retries _retries = Retries.builder()
- .action(() -> {
- HttpRequest _r = null;
- try {
- _r = sdkConfiguration.hooks()
- .beforeRequest(
- new BeforeRequestContextImpl(
- "deletePlaylist",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- _finalReq.build());
- } catch (Exception _e) {
- throw new NonRetryableException(_e);
- }
- try {
- return _client.send(_r);
- } catch (Exception _e) {
- return sdkConfiguration.hooks()
- .afterError(
- new AfterErrorContextImpl(
- "deletePlaylist",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- Optional.empty(),
- Optional.of(_e));
- }
- })
- .retryConfig(_retryConfig)
- .statusCodes(_statusCodes)
- .build();
- HttpResponse _httpRes = sdkConfiguration.hooks()
- .afterSuccess(
- new AfterSuccessContextImpl(
- "deletePlaylist",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- _retries.run());
String _contentType = _httpRes
.headers()
.firstValue("Content-Type")
@@ -905,7 +763,7 @@ public class Playlists implements
*/
public UpdatePlaylistResponse updatePlaylist(
double playlistID) throws Exception {
- return updatePlaylist(playlistID, Optional.empty(), Optional.empty(), Optional.empty());
+ return updatePlaylist(playlistID, Optional.empty(), Optional.empty());
}
/**
@@ -915,19 +773,13 @@ public class Playlists implements
* @param playlistID the ID of the playlist
* @param title name of the playlist
* @param summary summary description of the playlist
- * @param options additional options
* @return The response from the API call
* @throws Exception if the API call fails
*/
public UpdatePlaylistResponse updatePlaylist(
double playlistID,
Optional title,
- Optional summary,
- Optional options) throws Exception {
-
- if (options.isPresent()) {
- options.get().validate(Arrays.asList(Options.Option.RETRY_CONFIG));
- }
+ Optional summary) throws Exception {
UpdatePlaylistRequest request =
UpdatePlaylistRequest
.builder()
@@ -958,62 +810,45 @@ public class Playlists implements
this.sdkConfiguration.securitySource.getSecurity());
HTTPClient _client = this.sdkConfiguration.defaultClient;
- HTTPRequest _finalReq = _req;
- RetryConfig _retryConfig;
- if (options.isPresent() && options.get().retryConfig().isPresent()) {
- _retryConfig = options.get().retryConfig().get();
- } else if (this.sdkConfiguration.retryConfig.isPresent()) {
- _retryConfig = this.sdkConfiguration.retryConfig.get();
- } else {
- _retryConfig = RetryConfig.builder()
- .backoff(BackoffStrategy.builder()
- .initialInterval(500, TimeUnit.MILLISECONDS)
- .maxInterval(60000, TimeUnit.MILLISECONDS)
- .baseFactor((double)(1.5))
- .maxElapsedTime(3600000, TimeUnit.MILLISECONDS)
- .retryConnectError(true)
- .build())
- .build();
+ HttpRequest _r =
+ sdkConfiguration.hooks()
+ .beforeRequest(
+ new BeforeRequestContextImpl(
+ "updatePlaylist",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ _req.build());
+ HttpResponse _httpRes;
+ try {
+ _httpRes = _client.send(_r);
+ if (Utils.statusCodeMatches(_httpRes.statusCode(), "400", "401", "4XX", "5XX")) {
+ _httpRes = sdkConfiguration.hooks()
+ .afterError(
+ new AfterErrorContextImpl(
+ "updatePlaylist",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ Optional.of(_httpRes),
+ Optional.empty());
+ } else {
+ _httpRes = sdkConfiguration.hooks()
+ .afterSuccess(
+ new AfterSuccessContextImpl(
+ "updatePlaylist",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ _httpRes);
+ }
+ } catch (Exception _e) {
+ _httpRes = sdkConfiguration.hooks()
+ .afterError(
+ new AfterErrorContextImpl(
+ "updatePlaylist",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ Optional.empty(),
+ Optional.of(_e));
}
- List _statusCodes = new ArrayList<>();
- _statusCodes.add("5XX");
- Retries _retries = Retries.builder()
- .action(() -> {
- HttpRequest _r = null;
- try {
- _r = sdkConfiguration.hooks()
- .beforeRequest(
- new BeforeRequestContextImpl(
- "updatePlaylist",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- _finalReq.build());
- } catch (Exception _e) {
- throw new NonRetryableException(_e);
- }
- try {
- return _client.send(_r);
- } catch (Exception _e) {
- return sdkConfiguration.hooks()
- .afterError(
- new AfterErrorContextImpl(
- "updatePlaylist",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- Optional.empty(),
- Optional.of(_e));
- }
- })
- .retryConfig(_retryConfig)
- .statusCodes(_statusCodes)
- .build();
- HttpResponse _httpRes = sdkConfiguration.hooks()
- .afterSuccess(
- new AfterSuccessContextImpl(
- "updatePlaylist",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- _retries.run());
String _contentType = _httpRes
.headers()
.firstValue("Content-Type")
@@ -1114,36 +949,6 @@ public class Playlists implements
public GetPlaylistContentsResponse getPlaylistContents(
double playlistID,
GetPlaylistContentsQueryParamType type) throws Exception {
- return getPlaylistContents(playlistID, type, Optional.empty());
- }
-
- /**
- * Retrieve Playlist Contents
- * Gets the contents of a playlist. Should be paged by clients via standard mechanisms.
- * By default leaves are returned (e.g. episodes, movies). In order to return other types you can use the `type` parameter.
- * For example, you could use this to display a list of recently added albums vis a smart playlist.
- * Note that for dumb playlists, items have a `playlistItemID` attribute which is used for deleting or moving items.
- *
- * @param playlistID the ID of the playlist
- * @param type The type of media to retrieve.
- 1 = movie
- 2 = show
- 3 = season
- 4 = episode
- E.g. A movie library will not return anything with type 3 as there are no seasons for movie libraries
-
- * @param options additional options
- * @return The response from the API call
- * @throws Exception if the API call fails
- */
- public GetPlaylistContentsResponse getPlaylistContents(
- double playlistID,
- GetPlaylistContentsQueryParamType type,
- Optional options) throws Exception {
-
- if (options.isPresent()) {
- options.get().validate(Arrays.asList(Options.Option.RETRY_CONFIG));
- }
GetPlaylistContentsRequest request =
GetPlaylistContentsRequest
.builder()
@@ -1173,62 +978,45 @@ public class Playlists implements
this.sdkConfiguration.securitySource.getSecurity());
HTTPClient _client = this.sdkConfiguration.defaultClient;
- HTTPRequest _finalReq = _req;
- RetryConfig _retryConfig;
- if (options.isPresent() && options.get().retryConfig().isPresent()) {
- _retryConfig = options.get().retryConfig().get();
- } else if (this.sdkConfiguration.retryConfig.isPresent()) {
- _retryConfig = this.sdkConfiguration.retryConfig.get();
- } else {
- _retryConfig = RetryConfig.builder()
- .backoff(BackoffStrategy.builder()
- .initialInterval(500, TimeUnit.MILLISECONDS)
- .maxInterval(60000, TimeUnit.MILLISECONDS)
- .baseFactor((double)(1.5))
- .maxElapsedTime(3600000, TimeUnit.MILLISECONDS)
- .retryConnectError(true)
- .build())
- .build();
+ HttpRequest _r =
+ sdkConfiguration.hooks()
+ .beforeRequest(
+ new BeforeRequestContextImpl(
+ "getPlaylistContents",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ _req.build());
+ HttpResponse _httpRes;
+ try {
+ _httpRes = _client.send(_r);
+ if (Utils.statusCodeMatches(_httpRes.statusCode(), "400", "401", "4XX", "5XX")) {
+ _httpRes = sdkConfiguration.hooks()
+ .afterError(
+ new AfterErrorContextImpl(
+ "getPlaylistContents",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ Optional.of(_httpRes),
+ Optional.empty());
+ } else {
+ _httpRes = sdkConfiguration.hooks()
+ .afterSuccess(
+ new AfterSuccessContextImpl(
+ "getPlaylistContents",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ _httpRes);
+ }
+ } catch (Exception _e) {
+ _httpRes = sdkConfiguration.hooks()
+ .afterError(
+ new AfterErrorContextImpl(
+ "getPlaylistContents",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ Optional.empty(),
+ Optional.of(_e));
}
- List _statusCodes = new ArrayList<>();
- _statusCodes.add("5XX");
- Retries _retries = Retries.builder()
- .action(() -> {
- HttpRequest _r = null;
- try {
- _r = sdkConfiguration.hooks()
- .beforeRequest(
- new BeforeRequestContextImpl(
- "getPlaylistContents",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- _finalReq.build());
- } catch (Exception _e) {
- throw new NonRetryableException(_e);
- }
- try {
- return _client.send(_r);
- } catch (Exception _e) {
- return sdkConfiguration.hooks()
- .afterError(
- new AfterErrorContextImpl(
- "getPlaylistContents",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- Optional.empty(),
- Optional.of(_e));
- }
- })
- .retryConfig(_retryConfig)
- .statusCodes(_statusCodes)
- .build();
- HttpResponse _httpRes = sdkConfiguration.hooks()
- .afterSuccess(
- new AfterSuccessContextImpl(
- "getPlaylistContents",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- _retries.run());
String _contentType = _httpRes
.headers()
.firstValue("Content-Type")
@@ -1326,25 +1114,6 @@ public class Playlists implements
*/
public ClearPlaylistContentsResponse clearPlaylistContents(
double playlistID) throws Exception {
- return clearPlaylistContents(playlistID, Optional.empty());
- }
-
- /**
- * Delete Playlist Contents
- * Clears a playlist, only works with dumb playlists. Returns the playlist.
- *
- * @param playlistID the ID of the playlist
- * @param options additional options
- * @return The response from the API call
- * @throws Exception if the API call fails
- */
- public ClearPlaylistContentsResponse clearPlaylistContents(
- double playlistID,
- Optional options) throws Exception {
-
- if (options.isPresent()) {
- options.get().validate(Arrays.asList(Options.Option.RETRY_CONFIG));
- }
ClearPlaylistContentsRequest request =
ClearPlaylistContentsRequest
.builder()
@@ -1368,62 +1137,45 @@ public class Playlists implements
this.sdkConfiguration.securitySource.getSecurity());
HTTPClient _client = this.sdkConfiguration.defaultClient;
- HTTPRequest _finalReq = _req;
- RetryConfig _retryConfig;
- if (options.isPresent() && options.get().retryConfig().isPresent()) {
- _retryConfig = options.get().retryConfig().get();
- } else if (this.sdkConfiguration.retryConfig.isPresent()) {
- _retryConfig = this.sdkConfiguration.retryConfig.get();
- } else {
- _retryConfig = RetryConfig.builder()
- .backoff(BackoffStrategy.builder()
- .initialInterval(500, TimeUnit.MILLISECONDS)
- .maxInterval(60000, TimeUnit.MILLISECONDS)
- .baseFactor((double)(1.5))
- .maxElapsedTime(3600000, TimeUnit.MILLISECONDS)
- .retryConnectError(true)
- .build())
- .build();
+ HttpRequest _r =
+ sdkConfiguration.hooks()
+ .beforeRequest(
+ new BeforeRequestContextImpl(
+ "clearPlaylistContents",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ _req.build());
+ HttpResponse _httpRes;
+ try {
+ _httpRes = _client.send(_r);
+ if (Utils.statusCodeMatches(_httpRes.statusCode(), "400", "401", "4XX", "5XX")) {
+ _httpRes = sdkConfiguration.hooks()
+ .afterError(
+ new AfterErrorContextImpl(
+ "clearPlaylistContents",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ Optional.of(_httpRes),
+ Optional.empty());
+ } else {
+ _httpRes = sdkConfiguration.hooks()
+ .afterSuccess(
+ new AfterSuccessContextImpl(
+ "clearPlaylistContents",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ _httpRes);
+ }
+ } catch (Exception _e) {
+ _httpRes = sdkConfiguration.hooks()
+ .afterError(
+ new AfterErrorContextImpl(
+ "clearPlaylistContents",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ Optional.empty(),
+ Optional.of(_e));
}
- List _statusCodes = new ArrayList<>();
- _statusCodes.add("5XX");
- Retries _retries = Retries.builder()
- .action(() -> {
- HttpRequest _r = null;
- try {
- _r = sdkConfiguration.hooks()
- .beforeRequest(
- new BeforeRequestContextImpl(
- "clearPlaylistContents",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- _finalReq.build());
- } catch (Exception _e) {
- throw new NonRetryableException(_e);
- }
- try {
- return _client.send(_r);
- } catch (Exception _e) {
- return sdkConfiguration.hooks()
- .afterError(
- new AfterErrorContextImpl(
- "clearPlaylistContents",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- Optional.empty(),
- Optional.of(_e));
- }
- })
- .retryConfig(_retryConfig)
- .statusCodes(_statusCodes)
- .build();
- HttpResponse _httpRes = sdkConfiguration.hooks()
- .afterSuccess(
- new AfterSuccessContextImpl(
- "clearPlaylistContents",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- _retries.run());
String _contentType = _httpRes
.headers()
.firstValue("Content-Type")
@@ -1514,7 +1266,7 @@ public class Playlists implements
public AddPlaylistContentsResponse addPlaylistContents(
double playlistID,
String uri) throws Exception {
- return addPlaylistContents(playlistID, uri, Optional.empty(), Optional.empty());
+ return addPlaylistContents(playlistID, uri, Optional.empty());
}
/**
@@ -1525,19 +1277,13 @@ public class Playlists implements
* @param playlistID the ID of the playlist
* @param uri the content URI for the playlist
* @param playQueueID the play queue to add to a playlist
- * @param options additional options
* @return The response from the API call
* @throws Exception if the API call fails
*/
public AddPlaylistContentsResponse addPlaylistContents(
double playlistID,
String uri,
- Optional playQueueID,
- Optional options) throws Exception {
-
- if (options.isPresent()) {
- options.get().validate(Arrays.asList(Options.Option.RETRY_CONFIG));
- }
+ Optional playQueueID) throws Exception {
AddPlaylistContentsRequest request =
AddPlaylistContentsRequest
.builder()
@@ -1568,62 +1314,45 @@ public class Playlists implements
this.sdkConfiguration.securitySource.getSecurity());
HTTPClient _client = this.sdkConfiguration.defaultClient;
- HTTPRequest _finalReq = _req;
- RetryConfig _retryConfig;
- if (options.isPresent() && options.get().retryConfig().isPresent()) {
- _retryConfig = options.get().retryConfig().get();
- } else if (this.sdkConfiguration.retryConfig.isPresent()) {
- _retryConfig = this.sdkConfiguration.retryConfig.get();
- } else {
- _retryConfig = RetryConfig.builder()
- .backoff(BackoffStrategy.builder()
- .initialInterval(500, TimeUnit.MILLISECONDS)
- .maxInterval(60000, TimeUnit.MILLISECONDS)
- .baseFactor((double)(1.5))
- .maxElapsedTime(3600000, TimeUnit.MILLISECONDS)
- .retryConnectError(true)
- .build())
- .build();
+ HttpRequest _r =
+ sdkConfiguration.hooks()
+ .beforeRequest(
+ new BeforeRequestContextImpl(
+ "addPlaylistContents",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ _req.build());
+ HttpResponse _httpRes;
+ try {
+ _httpRes = _client.send(_r);
+ if (Utils.statusCodeMatches(_httpRes.statusCode(), "400", "401", "4XX", "5XX")) {
+ _httpRes = sdkConfiguration.hooks()
+ .afterError(
+ new AfterErrorContextImpl(
+ "addPlaylistContents",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ Optional.of(_httpRes),
+ Optional.empty());
+ } else {
+ _httpRes = sdkConfiguration.hooks()
+ .afterSuccess(
+ new AfterSuccessContextImpl(
+ "addPlaylistContents",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ _httpRes);
+ }
+ } catch (Exception _e) {
+ _httpRes = sdkConfiguration.hooks()
+ .afterError(
+ new AfterErrorContextImpl(
+ "addPlaylistContents",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ Optional.empty(),
+ Optional.of(_e));
}
- List _statusCodes = new ArrayList<>();
- _statusCodes.add("5XX");
- Retries _retries = Retries.builder()
- .action(() -> {
- HttpRequest _r = null;
- try {
- _r = sdkConfiguration.hooks()
- .beforeRequest(
- new BeforeRequestContextImpl(
- "addPlaylistContents",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- _finalReq.build());
- } catch (Exception _e) {
- throw new NonRetryableException(_e);
- }
- try {
- return _client.send(_r);
- } catch (Exception _e) {
- return sdkConfiguration.hooks()
- .afterError(
- new AfterErrorContextImpl(
- "addPlaylistContents",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- Optional.empty(),
- Optional.of(_e));
- }
- })
- .retryConfig(_retryConfig)
- .statusCodes(_statusCodes)
- .build();
- HttpResponse _httpRes = sdkConfiguration.hooks()
- .afterSuccess(
- new AfterSuccessContextImpl(
- "addPlaylistContents",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- _retries.run());
String _contentType = _httpRes
.headers()
.firstValue("Content-Type")
@@ -1735,39 +1464,6 @@ public class Playlists implements
String path,
QueryParamForce force,
long sectionID) throws Exception {
- return uploadPlaylist(path, force, sectionID, Optional.empty());
- }
-
- /**
- * Upload Playlist
- * Imports m3u playlists by passing a path on the server to scan for m3u-formatted playlist files, or a path to a single playlist file.
- *
- * @param path absolute path to a directory on the server where m3u files are stored, or the absolute path to a playlist file on the server.
- If the `path` argument is a directory, that path will be scanned for playlist files to be processed.
- Each file in that directory creates a separate playlist, with a name based on the filename of the file that created it.
- The GUID of each playlist is based on the filename.
- If the `path` argument is a file, that file will be used to create a new playlist, with the name based on the filename of the file that created it.
- The GUID of each playlist is based on the filename.
-
- * @param force Force overwriting of duplicate playlists.
- By default, a playlist file uploaded with the same path will overwrite the existing playlist.
- The `force` argument is used to disable overwriting.
- If the `force` argument is set to 0, a new playlist will be created suffixed with the date and time that the duplicate was uploaded.
-
- * @param sectionID Possibly the section ID to upload the playlist to, we are not certain.
- * @param options additional options
- * @return The response from the API call
- * @throws Exception if the API call fails
- */
- public UploadPlaylistResponse uploadPlaylist(
- String path,
- QueryParamForce force,
- long sectionID,
- Optional options) throws Exception {
-
- if (options.isPresent()) {
- options.get().validate(Arrays.asList(Options.Option.RETRY_CONFIG));
- }
UploadPlaylistRequest request =
UploadPlaylistRequest
.builder()
@@ -1796,62 +1492,45 @@ public class Playlists implements
this.sdkConfiguration.securitySource.getSecurity());
HTTPClient _client = this.sdkConfiguration.defaultClient;
- HTTPRequest _finalReq = _req;
- RetryConfig _retryConfig;
- if (options.isPresent() && options.get().retryConfig().isPresent()) {
- _retryConfig = options.get().retryConfig().get();
- } else if (this.sdkConfiguration.retryConfig.isPresent()) {
- _retryConfig = this.sdkConfiguration.retryConfig.get();
- } else {
- _retryConfig = RetryConfig.builder()
- .backoff(BackoffStrategy.builder()
- .initialInterval(500, TimeUnit.MILLISECONDS)
- .maxInterval(60000, TimeUnit.MILLISECONDS)
- .baseFactor((double)(1.5))
- .maxElapsedTime(3600000, TimeUnit.MILLISECONDS)
- .retryConnectError(true)
- .build())
- .build();
+ HttpRequest _r =
+ sdkConfiguration.hooks()
+ .beforeRequest(
+ new BeforeRequestContextImpl(
+ "uploadPlaylist",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ _req.build());
+ HttpResponse _httpRes;
+ try {
+ _httpRes = _client.send(_r);
+ if (Utils.statusCodeMatches(_httpRes.statusCode(), "400", "401", "4XX", "5XX")) {
+ _httpRes = sdkConfiguration.hooks()
+ .afterError(
+ new AfterErrorContextImpl(
+ "uploadPlaylist",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ Optional.of(_httpRes),
+ Optional.empty());
+ } else {
+ _httpRes = sdkConfiguration.hooks()
+ .afterSuccess(
+ new AfterSuccessContextImpl(
+ "uploadPlaylist",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ _httpRes);
+ }
+ } catch (Exception _e) {
+ _httpRes = sdkConfiguration.hooks()
+ .afterError(
+ new AfterErrorContextImpl(
+ "uploadPlaylist",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ Optional.empty(),
+ Optional.of(_e));
}
- List _statusCodes = new ArrayList<>();
- _statusCodes.add("5XX");
- Retries _retries = Retries.builder()
- .action(() -> {
- HttpRequest _r = null;
- try {
- _r = sdkConfiguration.hooks()
- .beforeRequest(
- new BeforeRequestContextImpl(
- "uploadPlaylist",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- _finalReq.build());
- } catch (Exception _e) {
- throw new NonRetryableException(_e);
- }
- try {
- return _client.send(_r);
- } catch (Exception _e) {
- return sdkConfiguration.hooks()
- .afterError(
- new AfterErrorContextImpl(
- "uploadPlaylist",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- Optional.empty(),
- Optional.of(_e));
- }
- })
- .retryConfig(_retryConfig)
- .statusCodes(_statusCodes)
- .build();
- HttpResponse _httpRes = sdkConfiguration.hooks()
- .afterSuccess(
- new AfterSuccessContextImpl(
- "uploadPlaylist",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- _retries.run());
String _contentType = _httpRes
.headers()
.firstValue("Content-Type")
diff --git a/src/main/java/dev/plexapi/sdk/Plex.java b/src/main/java/dev/plexapi/sdk/Plex.java
index cc26db9d..696f0615 100644
--- a/src/main/java/dev/plexapi/sdk/Plex.java
+++ b/src/main/java/dev/plexapi/sdk/Plex.java
@@ -47,28 +47,20 @@ import dev.plexapi.sdk.models.operations.IncludeRelay;
import dev.plexapi.sdk.models.operations.PlexDevice;
import dev.plexapi.sdk.models.operations.ResponseBody;
import dev.plexapi.sdk.models.operations.SDKMethodInterfaces.*;
-import dev.plexapi.sdk.utils.BackoffStrategy;
import dev.plexapi.sdk.utils.HTTPClient;
import dev.plexapi.sdk.utils.HTTPRequest;
import dev.plexapi.sdk.utils.Hook.AfterErrorContextImpl;
import dev.plexapi.sdk.utils.Hook.AfterSuccessContextImpl;
import dev.plexapi.sdk.utils.Hook.BeforeRequestContextImpl;
-import dev.plexapi.sdk.utils.Options;
-import dev.plexapi.sdk.utils.Retries.NonRetryableException;
-import dev.plexapi.sdk.utils.Retries;
-import dev.plexapi.sdk.utils.RetryConfig;
import dev.plexapi.sdk.utils.Utils;
import java.io.InputStream;
import java.lang.Exception;
import java.lang.String;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
-import java.util.ArrayList;
-import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
-import java.util.Optional;
-import java.util.concurrent.TimeUnit;
+import java.util.Optional;
/**
* API Calls that perform operations directly against https://Plex.tv
@@ -148,24 +140,18 @@ public class Plex implements
* @throws Exception if the API call fails
*/
public GetCompanionsDataResponse getCompanionsDataDirect() throws Exception {
- return getCompanionsData(Optional.empty(), Optional.empty());
+ return getCompanionsData(Optional.empty());
}
/**
* Get Companions Data
* Get Companions Data
* @param serverURL Overrides the server URL.
- * @param options additional options
* @return The response from the API call
* @throws Exception if the API call fails
*/
public GetCompanionsDataResponse getCompanionsData(
- Optional serverURL,
- Optional options) throws Exception {
-
- if (options.isPresent()) {
- options.get().validate(Arrays.asList(Options.Option.RETRY_CONFIG));
- }
+ Optional serverURL) throws Exception {
String _baseUrl = Utils.templateUrl(GET_COMPANIONS_DATA_SERVERS[0], new HashMap());
if (serverURL.isPresent() && !serverURL.get().isBlank()) {
_baseUrl = serverURL.get();
@@ -183,62 +169,45 @@ public class Plex implements
this.sdkConfiguration.securitySource.getSecurity());
HTTPClient _client = this.sdkConfiguration.defaultClient;
- HTTPRequest _finalReq = _req;
- RetryConfig _retryConfig;
- if (options.isPresent() && options.get().retryConfig().isPresent()) {
- _retryConfig = options.get().retryConfig().get();
- } else if (this.sdkConfiguration.retryConfig.isPresent()) {
- _retryConfig = this.sdkConfiguration.retryConfig.get();
- } else {
- _retryConfig = RetryConfig.builder()
- .backoff(BackoffStrategy.builder()
- .initialInterval(500, TimeUnit.MILLISECONDS)
- .maxInterval(60000, TimeUnit.MILLISECONDS)
- .baseFactor((double)(1.5))
- .maxElapsedTime(3600000, TimeUnit.MILLISECONDS)
- .retryConnectError(true)
- .build())
- .build();
+ HttpRequest _r =
+ sdkConfiguration.hooks()
+ .beforeRequest(
+ new BeforeRequestContextImpl(
+ "getCompanionsData",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ _req.build());
+ HttpResponse _httpRes;
+ try {
+ _httpRes = _client.send(_r);
+ if (Utils.statusCodeMatches(_httpRes.statusCode(), "400", "401", "4XX", "5XX")) {
+ _httpRes = sdkConfiguration.hooks()
+ .afterError(
+ new AfterErrorContextImpl(
+ "getCompanionsData",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ Optional.of(_httpRes),
+ Optional.empty());
+ } else {
+ _httpRes = sdkConfiguration.hooks()
+ .afterSuccess(
+ new AfterSuccessContextImpl(
+ "getCompanionsData",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ _httpRes);
+ }
+ } catch (Exception _e) {
+ _httpRes = sdkConfiguration.hooks()
+ .afterError(
+ new AfterErrorContextImpl(
+ "getCompanionsData",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ Optional.empty(),
+ Optional.of(_e));
}
- List _statusCodes = new ArrayList<>();
- _statusCodes.add("5XX");
- Retries _retries = Retries.builder()
- .action(() -> {
- HttpRequest _r = null;
- try {
- _r = sdkConfiguration.hooks()
- .beforeRequest(
- new BeforeRequestContextImpl(
- "getCompanionsData",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- _finalReq.build());
- } catch (Exception _e) {
- throw new NonRetryableException(_e);
- }
- try {
- return _client.send(_r);
- } catch (Exception _e) {
- return sdkConfiguration.hooks()
- .afterError(
- new AfterErrorContextImpl(
- "getCompanionsData",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- Optional.empty(),
- Optional.of(_e));
- }
- })
- .retryConfig(_retryConfig)
- .statusCodes(_statusCodes)
- .build();
- HttpResponse _httpRes = sdkConfiguration.hooks()
- .afterSuccess(
- new AfterSuccessContextImpl(
- "getCompanionsData",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- _retries.run());
String _contentType = _httpRes
.headers()
.firstValue("Content-Type")
@@ -332,24 +301,18 @@ public class Plex implements
* @throws Exception if the API call fails
*/
public GetUserFriendsResponse getUserFriendsDirect() throws Exception {
- return getUserFriends(Optional.empty(), Optional.empty());
+ return getUserFriends(Optional.empty());
}
/**
* Get list of friends of the user logged in
* Get friends of provided auth token.
* @param serverURL Overrides the server URL.
- * @param options additional options
* @return The response from the API call
* @throws Exception if the API call fails
*/
public GetUserFriendsResponse getUserFriends(
- Optional serverURL,
- Optional options) throws Exception {
-
- if (options.isPresent()) {
- options.get().validate(Arrays.asList(Options.Option.RETRY_CONFIG));
- }
+ Optional serverURL) throws Exception {
String _baseUrl = Utils.templateUrl(GET_USER_FRIENDS_SERVERS[0], new HashMap());
if (serverURL.isPresent() && !serverURL.get().isBlank()) {
_baseUrl = serverURL.get();
@@ -367,62 +330,45 @@ public class Plex implements
this.sdkConfiguration.securitySource.getSecurity());
HTTPClient _client = this.sdkConfiguration.defaultClient;
- HTTPRequest _finalReq = _req;
- RetryConfig _retryConfig;
- if (options.isPresent() && options.get().retryConfig().isPresent()) {
- _retryConfig = options.get().retryConfig().get();
- } else if (this.sdkConfiguration.retryConfig.isPresent()) {
- _retryConfig = this.sdkConfiguration.retryConfig.get();
- } else {
- _retryConfig = RetryConfig.builder()
- .backoff(BackoffStrategy.builder()
- .initialInterval(500, TimeUnit.MILLISECONDS)
- .maxInterval(60000, TimeUnit.MILLISECONDS)
- .baseFactor((double)(1.5))
- .maxElapsedTime(3600000, TimeUnit.MILLISECONDS)
- .retryConnectError(true)
- .build())
- .build();
+ HttpRequest _r =
+ sdkConfiguration.hooks()
+ .beforeRequest(
+ new BeforeRequestContextImpl(
+ "getUserFriends",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ _req.build());
+ HttpResponse _httpRes;
+ try {
+ _httpRes = _client.send(_r);
+ if (Utils.statusCodeMatches(_httpRes.statusCode(), "400", "401", "4XX", "5XX")) {
+ _httpRes = sdkConfiguration.hooks()
+ .afterError(
+ new AfterErrorContextImpl(
+ "getUserFriends",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ Optional.of(_httpRes),
+ Optional.empty());
+ } else {
+ _httpRes = sdkConfiguration.hooks()
+ .afterSuccess(
+ new AfterSuccessContextImpl(
+ "getUserFriends",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ _httpRes);
+ }
+ } catch (Exception _e) {
+ _httpRes = sdkConfiguration.hooks()
+ .afterError(
+ new AfterErrorContextImpl(
+ "getUserFriends",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ Optional.empty(),
+ Optional.of(_e));
}
- List _statusCodes = new ArrayList<>();
- _statusCodes.add("5XX");
- Retries _retries = Retries.builder()
- .action(() -> {
- HttpRequest _r = null;
- try {
- _r = sdkConfiguration.hooks()
- .beforeRequest(
- new BeforeRequestContextImpl(
- "getUserFriends",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- _finalReq.build());
- } catch (Exception _e) {
- throw new NonRetryableException(_e);
- }
- try {
- return _client.send(_r);
- } catch (Exception _e) {
- return sdkConfiguration.hooks()
- .afterError(
- new AfterErrorContextImpl(
- "getUserFriends",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- Optional.empty(),
- Optional.of(_e));
- }
- })
- .retryConfig(_retryConfig)
- .statusCodes(_statusCodes)
- .build();
- HttpResponse _httpRes = sdkConfiguration.hooks()
- .afterSuccess(
- new AfterSuccessContextImpl(
- "getUserFriends",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- _retries.run());
String _contentType = _httpRes
.headers()
.firstValue("Content-Type")
@@ -516,24 +462,18 @@ public class Plex implements
* @throws Exception if the API call fails
*/
public GetGeoDataResponse getGeoDataDirect() throws Exception {
- return getGeoData(Optional.empty(), Optional.empty());
+ return getGeoData(Optional.empty());
}
/**
* Get Geo Data
* Returns the geolocation and locale data of the caller
* @param serverURL Overrides the server URL.
- * @param options additional options
* @return The response from the API call
* @throws Exception if the API call fails
*/
public GetGeoDataResponse getGeoData(
- Optional serverURL,
- Optional options) throws Exception {
-
- if (options.isPresent()) {
- options.get().validate(Arrays.asList(Options.Option.RETRY_CONFIG));
- }
+ Optional serverURL) throws Exception {
String _baseUrl = Utils.templateUrl(GET_GEO_DATA_SERVERS[0], new HashMap());
if (serverURL.isPresent() && !serverURL.get().isBlank()) {
_baseUrl = serverURL.get();
@@ -548,62 +488,45 @@ public class Plex implements
SDKConfiguration.USER_AGENT);
HTTPClient _client = this.sdkConfiguration.defaultClient;
- HTTPRequest _finalReq = _req;
- RetryConfig _retryConfig;
- if (options.isPresent() && options.get().retryConfig().isPresent()) {
- _retryConfig = options.get().retryConfig().get();
- } else if (this.sdkConfiguration.retryConfig.isPresent()) {
- _retryConfig = this.sdkConfiguration.retryConfig.get();
- } else {
- _retryConfig = RetryConfig.builder()
- .backoff(BackoffStrategy.builder()
- .initialInterval(500, TimeUnit.MILLISECONDS)
- .maxInterval(60000, TimeUnit.MILLISECONDS)
- .baseFactor((double)(1.5))
- .maxElapsedTime(3600000, TimeUnit.MILLISECONDS)
- .retryConnectError(true)
- .build())
- .build();
+ HttpRequest _r =
+ sdkConfiguration.hooks()
+ .beforeRequest(
+ new BeforeRequestContextImpl(
+ "getGeoData",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ _req.build());
+ HttpResponse _httpRes;
+ try {
+ _httpRes = _client.send(_r);
+ if (Utils.statusCodeMatches(_httpRes.statusCode(), "400", "401", "4XX", "5XX")) {
+ _httpRes = sdkConfiguration.hooks()
+ .afterError(
+ new AfterErrorContextImpl(
+ "getGeoData",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ Optional.of(_httpRes),
+ Optional.empty());
+ } else {
+ _httpRes = sdkConfiguration.hooks()
+ .afterSuccess(
+ new AfterSuccessContextImpl(
+ "getGeoData",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ _httpRes);
+ }
+ } catch (Exception _e) {
+ _httpRes = sdkConfiguration.hooks()
+ .afterError(
+ new AfterErrorContextImpl(
+ "getGeoData",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ Optional.empty(),
+ Optional.of(_e));
}
- List _statusCodes = new ArrayList<>();
- _statusCodes.add("5XX");
- Retries _retries = Retries.builder()
- .action(() -> {
- HttpRequest _r = null;
- try {
- _r = sdkConfiguration.hooks()
- .beforeRequest(
- new BeforeRequestContextImpl(
- "getGeoData",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- _finalReq.build());
- } catch (Exception _e) {
- throw new NonRetryableException(_e);
- }
- try {
- return _client.send(_r);
- } catch (Exception _e) {
- return sdkConfiguration.hooks()
- .afterError(
- new AfterErrorContextImpl(
- "getGeoData",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- Optional.empty(),
- Optional.of(_e));
- }
- })
- .retryConfig(_retryConfig)
- .statusCodes(_statusCodes)
- .build();
- HttpResponse _httpRes = sdkConfiguration.hooks()
- .afterSuccess(
- new AfterSuccessContextImpl(
- "getGeoData",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- _retries.run());
String _contentType = _httpRes
.headers()
.firstValue("Content-Type")
@@ -697,22 +620,6 @@ public class Plex implements
* @throws Exception if the API call fails
*/
public GetHomeDataResponse getHomeDataDirect() throws Exception {
- return getHomeData(Optional.empty());
- }
-
- /**
- * Get Plex Home Data
- * Retrieves the home data for the authenticated user, including details like home ID, name, guest access information, and subscription status.
- * @param options additional options
- * @return The response from the API call
- * @throws Exception if the API call fails
- */
- public GetHomeDataResponse getHomeData(
- Optional options) throws Exception {
-
- if (options.isPresent()) {
- options.get().validate(Arrays.asList(Options.Option.RETRY_CONFIG));
- }
String _baseUrl = Utils.templateUrl(
this.sdkConfiguration.serverUrl, this.sdkConfiguration.getServerVariableDefaults());
String _url = Utils.generateURL(
@@ -728,62 +635,45 @@ public class Plex implements
this.sdkConfiguration.securitySource.getSecurity());
HTTPClient _client = this.sdkConfiguration.defaultClient;
- HTTPRequest _finalReq = _req;
- RetryConfig _retryConfig;
- if (options.isPresent() && options.get().retryConfig().isPresent()) {
- _retryConfig = options.get().retryConfig().get();
- } else if (this.sdkConfiguration.retryConfig.isPresent()) {
- _retryConfig = this.sdkConfiguration.retryConfig.get();
- } else {
- _retryConfig = RetryConfig.builder()
- .backoff(BackoffStrategy.builder()
- .initialInterval(500, TimeUnit.MILLISECONDS)
- .maxInterval(60000, TimeUnit.MILLISECONDS)
- .baseFactor((double)(1.5))
- .maxElapsedTime(3600000, TimeUnit.MILLISECONDS)
- .retryConnectError(true)
- .build())
- .build();
+ HttpRequest _r =
+ sdkConfiguration.hooks()
+ .beforeRequest(
+ new BeforeRequestContextImpl(
+ "getHomeData",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ _req.build());
+ HttpResponse _httpRes;
+ try {
+ _httpRes = _client.send(_r);
+ if (Utils.statusCodeMatches(_httpRes.statusCode(), "400", "401", "4XX", "5XX")) {
+ _httpRes = sdkConfiguration.hooks()
+ .afterError(
+ new AfterErrorContextImpl(
+ "getHomeData",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ Optional.of(_httpRes),
+ Optional.empty());
+ } else {
+ _httpRes = sdkConfiguration.hooks()
+ .afterSuccess(
+ new AfterSuccessContextImpl(
+ "getHomeData",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ _httpRes);
+ }
+ } catch (Exception _e) {
+ _httpRes = sdkConfiguration.hooks()
+ .afterError(
+ new AfterErrorContextImpl(
+ "getHomeData",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ Optional.empty(),
+ Optional.of(_e));
}
- List _statusCodes = new ArrayList<>();
- _statusCodes.add("5XX");
- Retries _retries = Retries.builder()
- .action(() -> {
- HttpRequest _r = null;
- try {
- _r = sdkConfiguration.hooks()
- .beforeRequest(
- new BeforeRequestContextImpl(
- "getHomeData",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- _finalReq.build());
- } catch (Exception _e) {
- throw new NonRetryableException(_e);
- }
- try {
- return _client.send(_r);
- } catch (Exception _e) {
- return sdkConfiguration.hooks()
- .afterError(
- new AfterErrorContextImpl(
- "getHomeData",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- Optional.empty(),
- Optional.of(_e));
- }
- })
- .retryConfig(_retryConfig)
- .statusCodes(_statusCodes)
- .build();
- HttpResponse _httpRes = sdkConfiguration.hooks()
- .afterSuccess(
- new AfterSuccessContextImpl(
- "getHomeData",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- _retries.run());
String _contentType = _httpRes
.headers()
.firstValue("Content-Type")
@@ -877,7 +767,7 @@ public class Plex implements
* @throws Exception if the API call fails
*/
public GetServerResourcesResponse getServerResourcesDirect() throws Exception {
- return getServerResources(Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty());
+ return getServerResources(Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty());
}
/**
@@ -890,7 +780,6 @@ public class Plex implements
* @param includeIPv6 Include IPv6 entries in the results
* @param clientID An opaque identifier unique to the client (UUID, serial number, or other unique device ID)
* @param serverURL Overrides the server URL.
- * @param options additional options
* @return The response from the API call
* @throws Exception if the API call fails
*/
@@ -899,12 +788,7 @@ public class Plex implements
Optional extends IncludeRelay> includeRelay,
Optional extends IncludeIPv6> includeIPv6,
Optional clientID,
- Optional serverURL,
- Optional options) throws Exception {
-
- if (options.isPresent()) {
- options.get().validate(Arrays.asList(Options.Option.RETRY_CONFIG));
- }
+ Optional serverURL) throws Exception {
GetServerResourcesRequest request =
GetServerResourcesRequest
.builder()
@@ -937,62 +821,45 @@ public class Plex implements
this.sdkConfiguration.securitySource.getSecurity());
HTTPClient _client = this.sdkConfiguration.defaultClient;
- HTTPRequest _finalReq = _req;
- RetryConfig _retryConfig;
- if (options.isPresent() && options.get().retryConfig().isPresent()) {
- _retryConfig = options.get().retryConfig().get();
- } else if (this.sdkConfiguration.retryConfig.isPresent()) {
- _retryConfig = this.sdkConfiguration.retryConfig.get();
- } else {
- _retryConfig = RetryConfig.builder()
- .backoff(BackoffStrategy.builder()
- .initialInterval(500, TimeUnit.MILLISECONDS)
- .maxInterval(60000, TimeUnit.MILLISECONDS)
- .baseFactor((double)(1.5))
- .maxElapsedTime(3600000, TimeUnit.MILLISECONDS)
- .retryConnectError(true)
- .build())
- .build();
+ HttpRequest _r =
+ sdkConfiguration.hooks()
+ .beforeRequest(
+ new BeforeRequestContextImpl(
+ "get-server-resources",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ _req.build());
+ HttpResponse _httpRes;
+ try {
+ _httpRes = _client.send(_r);
+ if (Utils.statusCodeMatches(_httpRes.statusCode(), "400", "401", "4XX", "5XX")) {
+ _httpRes = sdkConfiguration.hooks()
+ .afterError(
+ new AfterErrorContextImpl(
+ "get-server-resources",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ Optional.of(_httpRes),
+ Optional.empty());
+ } else {
+ _httpRes = sdkConfiguration.hooks()
+ .afterSuccess(
+ new AfterSuccessContextImpl(
+ "get-server-resources",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ _httpRes);
+ }
+ } catch (Exception _e) {
+ _httpRes = sdkConfiguration.hooks()
+ .afterError(
+ new AfterErrorContextImpl(
+ "get-server-resources",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ Optional.empty(),
+ Optional.of(_e));
}
- List _statusCodes = new ArrayList<>();
- _statusCodes.add("5XX");
- Retries _retries = Retries.builder()
- .action(() -> {
- HttpRequest _r = null;
- try {
- _r = sdkConfiguration.hooks()
- .beforeRequest(
- new BeforeRequestContextImpl(
- "get-server-resources",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- _finalReq.build());
- } catch (Exception _e) {
- throw new NonRetryableException(_e);
- }
- try {
- return _client.send(_r);
- } catch (Exception _e) {
- return sdkConfiguration.hooks()
- .afterError(
- new AfterErrorContextImpl(
- "get-server-resources",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- Optional.empty(),
- Optional.of(_e));
- }
- })
- .retryConfig(_retryConfig)
- .statusCodes(_statusCodes)
- .build();
- HttpResponse _httpRes = sdkConfiguration.hooks()
- .afterSuccess(
- new AfterSuccessContextImpl(
- "get-server-resources",
- Optional.of(List.of()),
- sdkConfiguration.securitySource()),
- _retries.run());
String _contentType = _httpRes
.headers()
.firstValue("Content-Type")
@@ -1088,7 +955,7 @@ public class Plex implements
*/
public GetPinResponse getPin(
GetPinRequest request) throws Exception {
- return getPin(request, Optional.empty(), Optional.empty());
+ return getPin(request, Optional.empty());
}
/**
@@ -1096,18 +963,12 @@ public class Plex implements
* Retrieve a Pin ID from Plex.tv to use for authentication flows
* @param request The request object containing all of the parameters for the API call.
* @param serverURL Overrides the server URL.
- * @param options additional options
* @return The response from the API call
* @throws Exception if the API call fails
*/
public GetPinResponse getPin(
GetPinRequest request,
- Optional serverURL,
- Optional options) throws Exception {
-
- if (options.isPresent()) {
- options.get().validate(Arrays.asList(Options.Option.RETRY_CONFIG));
- }
+ Optional serverURL) throws Exception {
String _baseUrl = Utils.templateUrl(GET_PIN_SERVERS[0], new HashMap());
if (serverURL.isPresent() && !serverURL.get().isBlank()) {
_baseUrl = serverURL.get();
@@ -1128,62 +989,45 @@ public class Plex implements
_req.addHeaders(Utils.getHeadersFromMetadata(request, this.sdkConfiguration.globals));
HTTPClient _client = this.sdkConfiguration.defaultClient;
- HTTPRequest _finalReq = _req;
- RetryConfig _retryConfig;
- if (options.isPresent() && options.get().retryConfig().isPresent()) {
- _retryConfig = options.get().retryConfig().get();
- } else if (this.sdkConfiguration.retryConfig.isPresent()) {
- _retryConfig = this.sdkConfiguration.retryConfig.get();
- } else {
- _retryConfig = RetryConfig.builder()
- .backoff(BackoffStrategy.builder()
- .initialInterval(500, TimeUnit.MILLISECONDS)
- .maxInterval(60000, TimeUnit.MILLISECONDS)
- .baseFactor((double)(1.5))
- .maxElapsedTime(3600000, TimeUnit.MILLISECONDS)
- .retryConnectError(true)
- .build())
- .build();
+ HttpRequest _r =
+ sdkConfiguration.hooks()
+ .beforeRequest(
+ new BeforeRequestContextImpl(
+ "getPin",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ _req.build());
+ HttpResponse _httpRes;
+ try {
+ _httpRes = _client.send(_r);
+ if (Utils.statusCodeMatches(_httpRes.statusCode(), "400", "4XX", "5XX")) {
+ _httpRes = sdkConfiguration.hooks()
+ .afterError(
+ new AfterErrorContextImpl(
+ "getPin",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ Optional.of(_httpRes),
+ Optional.empty());
+ } else {
+ _httpRes = sdkConfiguration.hooks()
+ .afterSuccess(
+ new AfterSuccessContextImpl(
+ "getPin",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ _httpRes);
+ }
+ } catch (Exception _e) {
+ _httpRes = sdkConfiguration.hooks()
+ .afterError(
+ new AfterErrorContextImpl(
+ "getPin",
+ Optional.of(List.of()),
+ sdkConfiguration.securitySource()),
+ Optional.empty(),
+ Optional.of(_e));
}
- List