From 025b6c4640a0c6c9ab04fe0730531351090d2c9f Mon Sep 17 00:00:00 2001 From: speakeasybot Date: Fri, 4 Oct 2024 00:27:05 +0000 Subject: [PATCH] ci: regenerated with OpenAPI Doc , Speakeasy CLI 1.406.0 --- .speakeasy/gen.lock | 9 +- .speakeasy/gen.yaml | 2 +- .speakeasy/workflow.lock | 10 +- README.md | 103 +- RELEASES.md | 12 +- build.gradle | 4 +- .../GetLibraryItemsMediaContainer.md | 2 +- .../operations/GetTokenDetailsResponse.md | 12 +- .../GetTokenDetailsUserPlexAccount.md | 4 +- .../operations/PostUsersSignInDataResponse.md | 12 +- .../PostUsersSignInDataUserPlexAccount.md | 4 +- src/main/java/dev/plexapi/sdk/Activities.java | 230 +-- .../java/dev/plexapi/sdk/Authentication.java | 443 ++--- src/main/java/dev/plexapi/sdk/Butler.java | 571 +++---- src/main/java/dev/plexapi/sdk/Hubs.java | 328 ++-- src/main/java/dev/plexapi/sdk/Library.java | 1469 ++++++----------- src/main/java/dev/plexapi/sdk/Log.java | 374 ++--- src/main/java/dev/plexapi/sdk/Media.java | 570 +++---- src/main/java/dev/plexapi/sdk/Playlists.java | 1019 ++++-------- src/main/java/dev/plexapi/sdk/Plex.java | 737 ++++----- .../dev/plexapi/sdk/SDKConfiguration.java | 2 +- src/main/java/dev/plexapi/sdk/Search.java | 327 ++-- src/main/java/dev/plexapi/sdk/Server.java | 996 ++++------- src/main/java/dev/plexapi/sdk/Sessions.java | 442 ++--- src/main/java/dev/plexapi/sdk/Statistics.java | 319 ++-- src/main/java/dev/plexapi/sdk/Updater.java | 325 ++-- src/main/java/dev/plexapi/sdk/Video.java | 232 +-- src/main/java/dev/plexapi/sdk/Watchlist.java | 113 +- .../AddPlaylistContentsRequestBuilder.java | 22 +- .../ApplyUpdatesRequestBuilder.java | 22 +- .../CancelServerActivitiesRequestBuilder.java | 23 +- .../CheckForUpdatesRequestBuilder.java | 22 +- .../ClearPlaylistContentsRequestBuilder.java | 23 +- .../CreatePlaylistRequestBuilder.java | 23 +- .../DeleteLibraryRequestBuilder.java | 23 +- .../DeletePlaylistRequestBuilder.java | 23 +- .../EnablePaperTrailRequestBuilder.java | 24 +- .../GetAllLibrariesRequestBuilder.java | 24 +- .../GetAvailableClientsRequestBuilder.java | 24 +- .../GetBandwidthStatisticsRequestBuilder.java | 22 +- .../GetBannerImageRequestBuilder.java | 23 +- .../GetButlerTasksRequestBuilder.java | 24 +- .../GetCompanionsDataRequestBuilder.java | 22 +- .../operations/GetDevicesRequestBuilder.java | 24 +- .../operations/GetFileHashRequestBuilder.java | 22 +- .../operations/GetGeoDataRequestBuilder.java | 22 +- .../GetGlobalHubsRequestBuilder.java | 22 +- .../operations/GetHomeDataRequestBuilder.java | 24 +- .../GetLibraryDetailsRequestBuilder.java | 22 +- .../GetLibraryHubsRequestBuilder.java | 22 +- .../GetLibraryItemsMediaContainer.java | 29 +- .../GetLibraryItemsRequestBuilder.java | 23 +- .../GetMediaProvidersRequestBuilder.java | 23 +- .../GetMetaDataByRatingKeyRequestBuilder.java | 23 +- .../GetMetadataChildrenRequestBuilder.java | 22 +- .../GetMyPlexAccountRequestBuilder.java | 24 +- .../operations/GetOnDeckRequestBuilder.java | 24 +- .../operations/GetPinRequestBuilder.java | 22 +- .../GetPlaylistContentsRequestBuilder.java | 23 +- .../operations/GetPlaylistRequestBuilder.java | 23 +- .../GetPlaylistsRequestBuilder.java | 22 +- ...GetRecentlyAddedLibraryRequestBuilder.java | 23 +- .../GetRecentlyAddedRequestBuilder.java | 23 +- ...tRefreshLibraryMetadataRequestBuilder.java | 22 +- .../GetResizedPhotoRequestBuilder.java | 23 +- .../GetResourcesStatisticsRequestBuilder.java | 22 +- .../GetSearchAllLibrariesRequestBuilder.java | 23 +- .../GetSearchLibraryRequestBuilder.java | 23 +- .../GetSearchResultsRequestBuilder.java | 23 +- .../GetServerActivitiesRequestBuilder.java | 24 +- .../GetServerCapabilitiesRequestBuilder.java | 24 +- .../GetServerIdentityRequestBuilder.java | 24 +- .../GetServerListRequestBuilder.java | 24 +- .../GetServerPreferencesRequestBuilder.java | 24 +- .../GetServerResourcesRequestBuilder.java | 22 +- .../GetSessionHistoryRequestBuilder.java | 22 +- .../operations/GetSessionsRequestBuilder.java | 24 +- ...ceConnectionInformationRequestBuilder.java | 23 +- .../GetStatisticsRequestBuilder.java | 22 +- .../GetThumbImageRequestBuilder.java | 23 +- .../operations/GetTimelineRequestBuilder.java | 23 +- .../GetTokenByPinIdRequestBuilder.java | 22 +- .../GetTokenDetailsRequestBuilder.java | 22 +- .../GetTokenDetailsUserPlexAccount.java | 69 +- .../GetTopWatchedContentRequestBuilder.java | 22 +- .../GetTranscodeSessionsRequestBuilder.java | 24 +- .../GetTransientTokenRequestBuilder.java | 23 +- .../GetUpdateStatusRequestBuilder.java | 24 +- .../GetUserFriendsRequestBuilder.java | 22 +- .../GetWatchListRequestBuilder.java | 22 +- .../operations/LogLineRequestBuilder.java | 23 +- .../LogMultiLineRequestBuilder.java | 23 +- .../operations/MarkPlayedRequestBuilder.java | 23 +- .../MarkUnplayedRequestBuilder.java | 23 +- .../PerformSearchRequestBuilder.java | 22 +- .../PerformVoiceSearchRequestBuilder.java | 22 +- .../PostUsersSignInDataRequestBuilder.java | 22 +- .../PostUsersSignInDataUserPlexAccount.java | 69 +- .../operations/SDKMethodInterfaces.java | 229 +-- .../StartAllTasksRequestBuilder.java | 24 +- .../operations/StartTaskRequestBuilder.java | 23 +- ...StartUniversalTranscodeRequestBuilder.java | 23 +- .../StopAllTasksRequestBuilder.java | 24 +- .../operations/StopTaskRequestBuilder.java | 23 +- .../StopTranscodeSessionRequestBuilder.java | 23 +- .../UpdatePlayProgressRequestBuilder.java | 23 +- .../UpdatePlaylistRequestBuilder.java | 22 +- .../UploadPlaylistRequestBuilder.java | 23 +- 108 files changed, 3282 insertions(+), 7524 deletions(-) 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 onlyTransient, - Optional options) throws Exception { - - if (options.isPresent()) { - options.get().validate(Arrays.asList(Options.Option.RETRY_CONFIG)); - } + Optional 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 onlyTransient, - Optional options) throws Exception { - - if (options.isPresent()) { - options.get().validate(Arrays.asList(Options.Option.RETRY_CONFIG)); - } + Optional 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 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 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 playlistType, - Optional smart, - Optional options) throws Exception { - - if (options.isPresent()) { - options.get().validate(Arrays.asList(Options.Option.RETRY_CONFIG)); - } + Optional 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 includeRelay, Optional 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 _statusCodes = new ArrayList<>(); - _statusCodes.add("5XX"); - Retries _retries = Retries.builder() - .action(() -> { - HttpRequest _r = null; - try { - _r = sdkConfiguration.hooks() - .beforeRequest( - new BeforeRequestContextImpl( - "getPin", - 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( - "getPin", - Optional.of(List.of()), - sdkConfiguration.securitySource()), - Optional.empty(), - Optional.of(_e)); - } - }) - .retryConfig(_retryConfig) - .statusCodes(_statusCodes) - .build(); - HttpResponse _httpRes = sdkConfiguration.hooks() - .afterSuccess( - new AfterSuccessContextImpl( - "getPin", - Optional.of(List.of()), - sdkConfiguration.securitySource()), - _retries.run()); String _contentType = _httpRes .headers() .firstValue("Content-Type") @@ -1263,7 +1107,7 @@ public class Plex implements */ public GetTokenByPinIdResponse getTokenByPinId( GetTokenByPinIdRequest request) throws Exception { - return getTokenByPinId(request, Optional.empty(), Optional.empty()); + return getTokenByPinId(request, Optional.empty()); } /** @@ -1271,18 +1115,12 @@ public class Plex implements * Retrieve an Access Token from Plex.tv after the Pin has been authenticated * @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 GetTokenByPinIdResponse getTokenByPinId( GetTokenByPinIdRequest 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_TOKEN_BY_PIN_ID_SERVERS[0], new HashMap()); if (serverURL.isPresent() && !serverURL.get().isBlank()) { _baseUrl = serverURL.get(); @@ -1300,62 +1138,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( + "getTokenByPinId", + Optional.of(List.of()), + sdkConfiguration.securitySource()), + _req.build()); + HttpResponse _httpRes; + try { + _httpRes = _client.send(_r); + if (Utils.statusCodeMatches(_httpRes.statusCode(), "400", "404", "4XX", "5XX")) { + _httpRes = sdkConfiguration.hooks() + .afterError( + new AfterErrorContextImpl( + "getTokenByPinId", + Optional.of(List.of()), + sdkConfiguration.securitySource()), + Optional.of(_httpRes), + Optional.empty()); + } else { + _httpRes = sdkConfiguration.hooks() + .afterSuccess( + new AfterSuccessContextImpl( + "getTokenByPinId", + Optional.of(List.of()), + sdkConfiguration.securitySource()), + _httpRes); + } + } catch (Exception _e) { + _httpRes = sdkConfiguration.hooks() + .afterError( + new AfterErrorContextImpl( + "getTokenByPinId", + 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( - "getTokenByPinId", - 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( - "getTokenByPinId", - Optional.of(List.of()), - sdkConfiguration.securitySource()), - Optional.empty(), - Optional.of(_e)); - } - }) - .retryConfig(_retryConfig) - .statusCodes(_statusCodes) - .build(); - HttpResponse _httpRes = sdkConfiguration.hooks() - .afterSuccess( - new AfterSuccessContextImpl( - "getTokenByPinId", - Optional.of(List.of()), - sdkConfiguration.securitySource()), - _retries.run()); String _contentType = _httpRes .headers() .firstValue("Content-Type") diff --git a/src/main/java/dev/plexapi/sdk/SDKConfiguration.java b/src/main/java/dev/plexapi/sdk/SDKConfiguration.java index aa026352..38457429 100644 --- a/src/main/java/dev/plexapi/sdk/SDKConfiguration.java +++ b/src/main/java/dev/plexapi/sdk/SDKConfiguration.java @@ -36,7 +36,7 @@ class SDKConfiguration { } }; private static final String LANGUAGE = "java"; public static final String OPENAPI_DOC_VERSION = "0.0.3"; - public static final String SDK_VERSION = "0.8.0"; + public static final String SDK_VERSION = "0.9.0"; public static final String GEN_VERSION = "2.429.0"; private static final String BASE_PACKAGE = "dev.plexapi.sdk"; public static final String USER_AGENT = diff --git a/src/main/java/dev/plexapi/sdk/Search.java b/src/main/java/dev/plexapi/sdk/Search.java index d5942b55..79fa01f5 100644 --- a/src/main/java/dev/plexapi/sdk/Search.java +++ b/src/main/java/dev/plexapi/sdk/Search.java @@ -23,16 +23,11 @@ import dev.plexapi.sdk.models.operations.PerformVoiceSearchRequest; import dev.plexapi.sdk.models.operations.PerformVoiceSearchRequestBuilder; import dev.plexapi.sdk.models.operations.PerformVoiceSearchResponse; 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; @@ -40,11 +35,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; /** * API Calls that perform search operations with Plex Media Server @@ -104,7 +96,7 @@ public class Search implements */ public PerformSearchResponse performSearch( String query) throws Exception { - return performSearch(query, Optional.empty(), Optional.empty(), Optional.empty()); + return performSearch(query, Optional.empty(), Optional.empty()); } /** @@ -125,19 +117,13 @@ public class Search implements * @param query The query term * @param sectionId This gives context to the search, and can result in re-ordering of search result hubs * @param limit The number of items to return per hub - * @param options additional options * @return The response from the API call * @throws Exception if the API call fails */ public PerformSearchResponse performSearch( String query, Optional sectionId, - Optional limit, - Optional options) throws Exception { - - if (options.isPresent()) { - options.get().validate(Arrays.asList(Options.Option.RETRY_CONFIG)); - } + Optional limit) throws Exception { PerformSearchRequest request = PerformSearchRequest .builder() @@ -166,62 +152,45 @@ public class Search 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( + "performSearch", + 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( + "performSearch", + Optional.of(List.of()), + sdkConfiguration.securitySource()), + Optional.of(_httpRes), + Optional.empty()); + } else { + _httpRes = sdkConfiguration.hooks() + .afterSuccess( + new AfterSuccessContextImpl( + "performSearch", + Optional.of(List.of()), + sdkConfiguration.securitySource()), + _httpRes); + } + } catch (Exception _e) { + _httpRes = sdkConfiguration.hooks() + .afterError( + new AfterErrorContextImpl( + "performSearch", + 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( - "performSearch", - 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( - "performSearch", - Optional.of(List.of()), - sdkConfiguration.securitySource()), - Optional.empty(), - Optional.of(_e)); - } - }) - .retryConfig(_retryConfig) - .statusCodes(_statusCodes) - .build(); - HttpResponse _httpRes = sdkConfiguration.hooks() - .afterSuccess( - new AfterSuccessContextImpl( - "performSearch", - Optional.of(List.of()), - sdkConfiguration.securitySource()), - _retries.run()); String _contentType = _httpRes .headers() .firstValue("Content-Type") @@ -314,7 +283,7 @@ public class Search implements */ public PerformVoiceSearchResponse performVoiceSearch( String query) throws Exception { - return performVoiceSearch(query, Optional.empty(), Optional.empty(), Optional.empty()); + return performVoiceSearch(query, Optional.empty(), Optional.empty()); } /** @@ -327,19 +296,13 @@ public class Search implements * @param query The query term * @param sectionId This gives context to the search, and can result in re-ordering of search result hubs * @param limit The number of items to return per hub - * @param options additional options * @return The response from the API call * @throws Exception if the API call fails */ public PerformVoiceSearchResponse performVoiceSearch( String query, Optional sectionId, - Optional limit, - Optional options) throws Exception { - - if (options.isPresent()) { - options.get().validate(Arrays.asList(Options.Option.RETRY_CONFIG)); - } + Optional limit) throws Exception { PerformVoiceSearchRequest request = PerformVoiceSearchRequest .builder() @@ -368,62 +331,45 @@ public class Search 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( + "performVoiceSearch", + 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( + "performVoiceSearch", + Optional.of(List.of()), + sdkConfiguration.securitySource()), + Optional.of(_httpRes), + Optional.empty()); + } else { + _httpRes = sdkConfiguration.hooks() + .afterSuccess( + new AfterSuccessContextImpl( + "performVoiceSearch", + Optional.of(List.of()), + sdkConfiguration.securitySource()), + _httpRes); + } + } catch (Exception _e) { + _httpRes = sdkConfiguration.hooks() + .afterError( + new AfterErrorContextImpl( + "performVoiceSearch", + 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( - "performVoiceSearch", - 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( - "performVoiceSearch", - Optional.of(List.of()), - sdkConfiguration.securitySource()), - Optional.empty(), - Optional.of(_e)); - } - }) - .retryConfig(_retryConfig) - .statusCodes(_statusCodes) - .build(); - HttpResponse _httpRes = sdkConfiguration.hooks() - .afterSuccess( - new AfterSuccessContextImpl( - "performVoiceSearch", - Optional.of(List.of()), - sdkConfiguration.securitySource()), - _retries.run()); String _contentType = _httpRes .headers() .firstValue("Content-Type") @@ -508,24 +454,6 @@ public class Search implements */ public GetSearchResultsResponse getSearchResults( String query) throws Exception { - return getSearchResults(query, Optional.empty()); - } - - /** - * Get Search Results - * This will search the database for the string provided. - * @param query The search query string to use - * @param options additional options - * @return The response from the API call - * @throws Exception if the API call fails - */ - public GetSearchResultsResponse getSearchResults( - String query, - Optional options) throws Exception { - - if (options.isPresent()) { - options.get().validate(Arrays.asList(Options.Option.RETRY_CONFIG)); - } GetSearchResultsRequest request = GetSearchResultsRequest .builder() @@ -552,62 +480,45 @@ public class Search 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( + "getSearchResults", + 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( + "getSearchResults", + Optional.of(List.of()), + sdkConfiguration.securitySource()), + Optional.of(_httpRes), + Optional.empty()); + } else { + _httpRes = sdkConfiguration.hooks() + .afterSuccess( + new AfterSuccessContextImpl( + "getSearchResults", + Optional.of(List.of()), + sdkConfiguration.securitySource()), + _httpRes); + } + } catch (Exception _e) { + _httpRes = sdkConfiguration.hooks() + .afterError( + new AfterErrorContextImpl( + "getSearchResults", + 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( - "getSearchResults", - 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( - "getSearchResults", - Optional.of(List.of()), - sdkConfiguration.securitySource()), - Optional.empty(), - Optional.of(_e)); - } - }) - .retryConfig(_retryConfig) - .statusCodes(_statusCodes) - .build(); - HttpResponse _httpRes = sdkConfiguration.hooks() - .afterSuccess( - new AfterSuccessContextImpl( - "getSearchResults", - Optional.of(List.of()), - sdkConfiguration.securitySource()), - _retries.run()); String _contentType = _httpRes .headers() .firstValue("Content-Type") diff --git a/src/main/java/dev/plexapi/sdk/Server.java b/src/main/java/dev/plexapi/sdk/Server.java index 28069009..ab1b125a 100644 --- a/src/main/java/dev/plexapi/sdk/Server.java +++ b/src/main/java/dev/plexapi/sdk/Server.java @@ -52,27 +52,19 @@ import dev.plexapi.sdk.models.operations.GetServerPreferencesRequestBuilder; import dev.plexapi.sdk.models.operations.GetServerPreferencesResponse; import dev.plexapi.sdk.models.operations.GetServerPreferencesResponseBody; 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; /** * Operations against the Plex Media Server System. @@ -112,22 +104,6 @@ public class Server implements * @throws Exception if the API call fails */ public GetServerCapabilitiesResponse getServerCapabilitiesDirect() throws Exception { - return getServerCapabilities(Optional.empty()); - } - - /** - * Get Server Capabilities - * Get Server Capabilities - * @param options additional options - * @return The response from the API call - * @throws Exception if the API call fails - */ - public GetServerCapabilitiesResponse getServerCapabilities( - 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( @@ -143,62 +119,45 @@ public class Server 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( + "getServerCapabilities", + 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( + "getServerCapabilities", + Optional.of(List.of()), + sdkConfiguration.securitySource()), + Optional.of(_httpRes), + Optional.empty()); + } else { + _httpRes = sdkConfiguration.hooks() + .afterSuccess( + new AfterSuccessContextImpl( + "getServerCapabilities", + Optional.of(List.of()), + sdkConfiguration.securitySource()), + _httpRes); + } + } catch (Exception _e) { + _httpRes = sdkConfiguration.hooks() + .afterError( + new AfterErrorContextImpl( + "getServerCapabilities", + 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( - "getServerCapabilities", - 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( - "getServerCapabilities", - Optional.of(List.of()), - sdkConfiguration.securitySource()), - Optional.empty(), - Optional.of(_e)); - } - }) - .retryConfig(_retryConfig) - .statusCodes(_statusCodes) - .build(); - HttpResponse _httpRes = sdkConfiguration.hooks() - .afterSuccess( - new AfterSuccessContextImpl( - "getServerCapabilities", - Optional.of(List.of()), - sdkConfiguration.securitySource()), - _retries.run()); String _contentType = _httpRes .headers() .firstValue("Content-Type") @@ -292,22 +251,6 @@ public class Server implements * @throws Exception if the API call fails */ public GetServerPreferencesResponse getServerPreferencesDirect() throws Exception { - return getServerPreferences(Optional.empty()); - } - - /** - * Get Server Preferences - * Get Server Preferences - * @param options additional options - * @return The response from the API call - * @throws Exception if the API call fails - */ - public GetServerPreferencesResponse getServerPreferences( - 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( @@ -323,62 +266,45 @@ public class Server 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( + "getServerPreferences", + 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( + "getServerPreferences", + Optional.of(List.of()), + sdkConfiguration.securitySource()), + Optional.of(_httpRes), + Optional.empty()); + } else { + _httpRes = sdkConfiguration.hooks() + .afterSuccess( + new AfterSuccessContextImpl( + "getServerPreferences", + Optional.of(List.of()), + sdkConfiguration.securitySource()), + _httpRes); + } + } catch (Exception _e) { + _httpRes = sdkConfiguration.hooks() + .afterError( + new AfterErrorContextImpl( + "getServerPreferences", + 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( - "getServerPreferences", - 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( - "getServerPreferences", - Optional.of(List.of()), - sdkConfiguration.securitySource()), - Optional.empty(), - Optional.of(_e)); - } - }) - .retryConfig(_retryConfig) - .statusCodes(_statusCodes) - .build(); - HttpResponse _httpRes = sdkConfiguration.hooks() - .afterSuccess( - new AfterSuccessContextImpl( - "getServerPreferences", - Optional.of(List.of()), - sdkConfiguration.securitySource()), - _retries.run()); String _contentType = _httpRes .headers() .firstValue("Content-Type") @@ -472,22 +398,6 @@ public class Server implements * @throws Exception if the API call fails */ public GetAvailableClientsResponse getAvailableClientsDirect() throws Exception { - return getAvailableClients(Optional.empty()); - } - - /** - * Get Available Clients - * Get Available Clients - * @param options additional options - * @return The response from the API call - * @throws Exception if the API call fails - */ - public GetAvailableClientsResponse getAvailableClients( - 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( @@ -503,62 +413,45 @@ public class Server 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( + "getAvailableClients", + 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( + "getAvailableClients", + Optional.of(List.of()), + sdkConfiguration.securitySource()), + Optional.of(_httpRes), + Optional.empty()); + } else { + _httpRes = sdkConfiguration.hooks() + .afterSuccess( + new AfterSuccessContextImpl( + "getAvailableClients", + Optional.of(List.of()), + sdkConfiguration.securitySource()), + _httpRes); + } + } catch (Exception _e) { + _httpRes = sdkConfiguration.hooks() + .afterError( + new AfterErrorContextImpl( + "getAvailableClients", + 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( - "getAvailableClients", - 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( - "getAvailableClients", - Optional.of(List.of()), - sdkConfiguration.securitySource()), - Optional.empty(), - Optional.of(_e)); - } - }) - .retryConfig(_retryConfig) - .statusCodes(_statusCodes) - .build(); - HttpResponse _httpRes = sdkConfiguration.hooks() - .afterSuccess( - new AfterSuccessContextImpl( - "getAvailableClients", - Optional.of(List.of()), - sdkConfiguration.securitySource()), - _retries.run()); String _contentType = _httpRes .headers() .firstValue("Content-Type") @@ -652,22 +545,6 @@ public class Server implements * @throws Exception if the API call fails */ public GetDevicesResponse getDevicesDirect() throws Exception { - return getDevices(Optional.empty()); - } - - /** - * Get Devices - * Get Devices - * @param options additional options - * @return The response from the API call - * @throws Exception if the API call fails - */ - public GetDevicesResponse getDevices( - 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( @@ -683,62 +560,45 @@ public class Server 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( + "getDevices", + 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( + "getDevices", + Optional.of(List.of()), + sdkConfiguration.securitySource()), + Optional.of(_httpRes), + Optional.empty()); + } else { + _httpRes = sdkConfiguration.hooks() + .afterSuccess( + new AfterSuccessContextImpl( + "getDevices", + Optional.of(List.of()), + sdkConfiguration.securitySource()), + _httpRes); + } + } catch (Exception _e) { + _httpRes = sdkConfiguration.hooks() + .afterError( + new AfterErrorContextImpl( + "getDevices", + 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( - "getDevices", - 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( - "getDevices", - Optional.of(List.of()), - sdkConfiguration.securitySource()), - Optional.empty(), - Optional.of(_e)); - } - }) - .retryConfig(_retryConfig) - .statusCodes(_statusCodes) - .build(); - HttpResponse _httpRes = sdkConfiguration.hooks() - .afterSuccess( - new AfterSuccessContextImpl( - "getDevices", - Optional.of(List.of()), - sdkConfiguration.securitySource()), - _retries.run()); String _contentType = _httpRes .headers() .firstValue("Content-Type") @@ -832,22 +692,6 @@ public class Server implements * @throws Exception if the API call fails */ public GetServerIdentityResponse getServerIdentityDirect() throws Exception { - return getServerIdentity(Optional.empty()); - } - - /** - * Get Server Identity - * This request is useful to determine if the server is online or offline - * @param options additional options - * @return The response from the API call - * @throws Exception if the API call fails - */ - public GetServerIdentityResponse getServerIdentity( - 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( @@ -860,62 +704,45 @@ public class Server 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( + "get-server-identity", + Optional.of(List.of()), + sdkConfiguration.securitySource()), + _req.build()); + HttpResponse _httpRes; + try { + _httpRes = _client.send(_r); + if (Utils.statusCodeMatches(_httpRes.statusCode(), "408", "4XX", "5XX")) { + _httpRes = sdkConfiguration.hooks() + .afterError( + new AfterErrorContextImpl( + "get-server-identity", + Optional.of(List.of()), + sdkConfiguration.securitySource()), + Optional.of(_httpRes), + Optional.empty()); + } else { + _httpRes = sdkConfiguration.hooks() + .afterSuccess( + new AfterSuccessContextImpl( + "get-server-identity", + Optional.of(List.of()), + sdkConfiguration.securitySource()), + _httpRes); + } + } catch (Exception _e) { + _httpRes = sdkConfiguration.hooks() + .afterError( + new AfterErrorContextImpl( + "get-server-identity", + 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-identity", - 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-identity", - 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-identity", - Optional.of(List.of()), - sdkConfiguration.securitySource()), - _retries.run()); String _contentType = _httpRes .headers() .firstValue("Content-Type") @@ -993,22 +820,6 @@ public class Server implements * @throws Exception if the API call fails */ public GetMyPlexAccountResponse getMyPlexAccountDirect() throws Exception { - return getMyPlexAccount(Optional.empty()); - } - - /** - * Get MyPlex Account - * Returns MyPlex Account Information - * @param options additional options - * @return The response from the API call - * @throws Exception if the API call fails - */ - public GetMyPlexAccountResponse getMyPlexAccount( - 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( @@ -1024,62 +835,45 @@ public class Server 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( + "getMyPlexAccount", + 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( + "getMyPlexAccount", + Optional.of(List.of()), + sdkConfiguration.securitySource()), + Optional.of(_httpRes), + Optional.empty()); + } else { + _httpRes = sdkConfiguration.hooks() + .afterSuccess( + new AfterSuccessContextImpl( + "getMyPlexAccount", + Optional.of(List.of()), + sdkConfiguration.securitySource()), + _httpRes); + } + } catch (Exception _e) { + _httpRes = sdkConfiguration.hooks() + .afterError( + new AfterErrorContextImpl( + "getMyPlexAccount", + 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( - "getMyPlexAccount", - 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( - "getMyPlexAccount", - Optional.of(List.of()), - sdkConfiguration.securitySource()), - Optional.empty(), - Optional.of(_e)); - } - }) - .retryConfig(_retryConfig) - .statusCodes(_statusCodes) - .build(); - HttpResponse _httpRes = sdkConfiguration.hooks() - .afterSuccess( - new AfterSuccessContextImpl( - "getMyPlexAccount", - Optional.of(List.of()), - sdkConfiguration.securitySource()), - _retries.run()); String _contentType = _httpRes .headers() .firstValue("Content-Type") @@ -1177,25 +971,6 @@ public class Server implements */ public GetResizedPhotoResponse getResizedPhoto( GetResizedPhotoRequest request) throws Exception { - return getResizedPhoto(request, Optional.empty()); - } - - /** - * Get a Resized Photo - * Plex's Photo transcoder is used throughout the service to serve images at specified sizes. - * - * @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 GetResizedPhotoResponse getResizedPhoto( - GetResizedPhotoRequest 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( @@ -1216,62 +991,45 @@ public class Server 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( + "getResizedPhoto", + 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( + "getResizedPhoto", + Optional.of(List.of()), + sdkConfiguration.securitySource()), + Optional.of(_httpRes), + Optional.empty()); + } else { + _httpRes = sdkConfiguration.hooks() + .afterSuccess( + new AfterSuccessContextImpl( + "getResizedPhoto", + Optional.of(List.of()), + sdkConfiguration.securitySource()), + _httpRes); + } + } catch (Exception _e) { + _httpRes = sdkConfiguration.hooks() + .afterError( + new AfterErrorContextImpl( + "getResizedPhoto", + 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( - "getResizedPhoto", - 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( - "getResizedPhoto", - Optional.of(List.of()), - sdkConfiguration.securitySource()), - Optional.empty(), - Optional.of(_e)); - } - }) - .retryConfig(_retryConfig) - .statusCodes(_statusCodes) - .build(); - HttpResponse _httpRes = sdkConfiguration.hooks() - .afterSuccess( - new AfterSuccessContextImpl( - "getResizedPhoto", - Optional.of(List.of()), - sdkConfiguration.securitySource()), - _retries.run()); String _contentType = _httpRes .headers() .firstValue("Content-Type") @@ -1356,24 +1114,6 @@ public class Server implements */ public GetMediaProvidersResponse getMediaProviders( String xPlexToken) throws Exception { - return getMediaProviders(xPlexToken, Optional.empty()); - } - - /** - * Get Media Providers - * Retrieves media providers and their features from the Plex server. - * @param xPlexToken An authentication token, obtained from plex.tv - * @param options additional options - * @return The response from the API call - * @throws Exception if the API call fails - */ - public GetMediaProvidersResponse getMediaProviders( - String xPlexToken, - Optional options) throws Exception { - - if (options.isPresent()) { - options.get().validate(Arrays.asList(Options.Option.RETRY_CONFIG)); - } GetMediaProvidersRequest request = GetMediaProvidersRequest .builder() @@ -1396,62 +1136,45 @@ public class Server 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-media-providers", + 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-media-providers", + Optional.of(List.of()), + sdkConfiguration.securitySource()), + Optional.of(_httpRes), + Optional.empty()); + } else { + _httpRes = sdkConfiguration.hooks() + .afterSuccess( + new AfterSuccessContextImpl( + "get-media-providers", + Optional.of(List.of()), + sdkConfiguration.securitySource()), + _httpRes); + } + } catch (Exception _e) { + _httpRes = sdkConfiguration.hooks() + .afterError( + new AfterErrorContextImpl( + "get-media-providers", + 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-media-providers", - 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-media-providers", - Optional.of(List.of()), - sdkConfiguration.securitySource()), - Optional.empty(), - Optional.of(_e)); - } - }) - .retryConfig(_retryConfig) - .statusCodes(_statusCodes) - .build(); - HttpResponse _httpRes = sdkConfiguration.hooks() - .afterSuccess( - new AfterSuccessContextImpl( - "get-media-providers", - Optional.of(List.of()), - sdkConfiguration.securitySource()), - _retries.run()); String _contentType = _httpRes .headers() .firstValue("Content-Type") @@ -1545,22 +1268,6 @@ public class Server implements * @throws Exception if the API call fails */ public GetServerListResponse getServerListDirect() throws Exception { - return getServerList(Optional.empty()); - } - - /** - * Get Server List - * Get Server List - * @param options additional options - * @return The response from the API call - * @throws Exception if the API call fails - */ - public GetServerListResponse getServerList( - 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( @@ -1576,62 +1283,45 @@ public class Server 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( + "getServerList", + 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( + "getServerList", + Optional.of(List.of()), + sdkConfiguration.securitySource()), + Optional.of(_httpRes), + Optional.empty()); + } else { + _httpRes = sdkConfiguration.hooks() + .afterSuccess( + new AfterSuccessContextImpl( + "getServerList", + Optional.of(List.of()), + sdkConfiguration.securitySource()), + _httpRes); + } + } catch (Exception _e) { + _httpRes = sdkConfiguration.hooks() + .afterError( + new AfterErrorContextImpl( + "getServerList", + 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( - "getServerList", - 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( - "getServerList", - Optional.of(List.of()), - sdkConfiguration.securitySource()), - Optional.empty(), - Optional.of(_e)); - } - }) - .retryConfig(_retryConfig) - .statusCodes(_statusCodes) - .build(); - HttpResponse _httpRes = sdkConfiguration.hooks() - .afterSuccess( - new AfterSuccessContextImpl( - "getServerList", - Optional.of(List.of()), - sdkConfiguration.securitySource()), - _retries.run()); String _contentType = _httpRes .headers() .firstValue("Content-Type") diff --git a/src/main/java/dev/plexapi/sdk/Sessions.java b/src/main/java/dev/plexapi/sdk/Sessions.java index e40422c0..403ede4d 100644 --- a/src/main/java/dev/plexapi/sdk/Sessions.java +++ b/src/main/java/dev/plexapi/sdk/Sessions.java @@ -29,16 +29,11 @@ import dev.plexapi.sdk.models.operations.SDKMethodInterfaces.*; import dev.plexapi.sdk.models.operations.StopTranscodeSessionRequest; import dev.plexapi.sdk.models.operations.StopTranscodeSessionRequestBuilder; import dev.plexapi.sdk.models.operations.StopTranscodeSessionResponse; -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; @@ -46,11 +41,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 that perform search operations with Plex Media Server Sessions @@ -85,22 +77,6 @@ public class Sessions implements * @throws Exception if the API call fails */ public GetSessionsResponse getSessionsDirect() throws Exception { - return getSessions(Optional.empty()); - } - - /** - * Get Active Sessions - * This will retrieve the "Now Playing" Information of the PMS. - * @param options additional options - * @return The response from the API call - * @throws Exception if the API call fails - */ - public GetSessionsResponse getSessions( - 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( @@ -116,62 +92,45 @@ public class Sessions 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( + "getSessions", + 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( + "getSessions", + Optional.of(List.of()), + sdkConfiguration.securitySource()), + Optional.of(_httpRes), + Optional.empty()); + } else { + _httpRes = sdkConfiguration.hooks() + .afterSuccess( + new AfterSuccessContextImpl( + "getSessions", + Optional.of(List.of()), + sdkConfiguration.securitySource()), + _httpRes); + } + } catch (Exception _e) { + _httpRes = sdkConfiguration.hooks() + .afterError( + new AfterErrorContextImpl( + "getSessions", + 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( - "getSessions", - 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( - "getSessions", - Optional.of(List.of()), - sdkConfiguration.securitySource()), - Optional.empty(), - Optional.of(_e)); - } - }) - .retryConfig(_retryConfig) - .statusCodes(_statusCodes) - .build(); - HttpResponse _httpRes = sdkConfiguration.hooks() - .afterSuccess( - new AfterSuccessContextImpl( - "getSessions", - Optional.of(List.of()), - sdkConfiguration.securitySource()), - _retries.run()); String _contentType = _httpRes .headers() .firstValue("Content-Type") @@ -265,7 +224,7 @@ public class Sessions implements * @throws Exception if the API call fails */ public GetSessionHistoryResponse getSessionHistoryDirect() throws Exception { - return getSessionHistory(Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); + return getSessionHistory(Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); } /** @@ -280,7 +239,6 @@ public class Sessions implements * @param librarySectionID Filters the results based on the id of a valid library section - * @param options additional options * @return The response from the API call * @throws Exception if the API call fails */ @@ -288,12 +246,7 @@ public class Sessions implements Optional sort, Optional accountId, Optional filter, - Optional librarySectionID, - Optional options) throws Exception { - - if (options.isPresent()) { - options.get().validate(Arrays.asList(Options.Option.RETRY_CONFIG)); - } + Optional librarySectionID) throws Exception { GetSessionHistoryRequest request = GetSessionHistoryRequest .builder() @@ -323,62 +276,45 @@ public class Sessions 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( + "getSessionHistory", + 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( + "getSessionHistory", + Optional.of(List.of()), + sdkConfiguration.securitySource()), + Optional.of(_httpRes), + Optional.empty()); + } else { + _httpRes = sdkConfiguration.hooks() + .afterSuccess( + new AfterSuccessContextImpl( + "getSessionHistory", + Optional.of(List.of()), + sdkConfiguration.securitySource()), + _httpRes); + } + } catch (Exception _e) { + _httpRes = sdkConfiguration.hooks() + .afterError( + new AfterErrorContextImpl( + "getSessionHistory", + 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( - "getSessionHistory", - 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( - "getSessionHistory", - Optional.of(List.of()), - sdkConfiguration.securitySource()), - Optional.empty(), - Optional.of(_e)); - } - }) - .retryConfig(_retryConfig) - .statusCodes(_statusCodes) - .build(); - HttpResponse _httpRes = sdkConfiguration.hooks() - .afterSuccess( - new AfterSuccessContextImpl( - "getSessionHistory", - Optional.of(List.of()), - sdkConfiguration.securitySource()), - _retries.run()); String _contentType = _httpRes .headers() .firstValue("Content-Type") @@ -472,22 +408,6 @@ public class Sessions implements * @throws Exception if the API call fails */ public GetTranscodeSessionsResponse getTranscodeSessionsDirect() throws Exception { - return getTranscodeSessions(Optional.empty()); - } - - /** - * Get Transcode Sessions - * Get Transcode Sessions - * @param options additional options - * @return The response from the API call - * @throws Exception if the API call fails - */ - public GetTranscodeSessionsResponse getTranscodeSessions( - 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( @@ -503,62 +423,45 @@ public class Sessions 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( + "getTranscodeSessions", + 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( + "getTranscodeSessions", + Optional.of(List.of()), + sdkConfiguration.securitySource()), + Optional.of(_httpRes), + Optional.empty()); + } else { + _httpRes = sdkConfiguration.hooks() + .afterSuccess( + new AfterSuccessContextImpl( + "getTranscodeSessions", + Optional.of(List.of()), + sdkConfiguration.securitySource()), + _httpRes); + } + } catch (Exception _e) { + _httpRes = sdkConfiguration.hooks() + .afterError( + new AfterErrorContextImpl( + "getTranscodeSessions", + 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( - "getTranscodeSessions", - 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( - "getTranscodeSessions", - Optional.of(List.of()), - sdkConfiguration.securitySource()), - Optional.empty(), - Optional.of(_e)); - } - }) - .retryConfig(_retryConfig) - .statusCodes(_statusCodes) - .build(); - HttpResponse _httpRes = sdkConfiguration.hooks() - .afterSuccess( - new AfterSuccessContextImpl( - "getTranscodeSessions", - Optional.of(List.of()), - sdkConfiguration.securitySource()), - _retries.run()); String _contentType = _httpRes .headers() .firstValue("Content-Type") @@ -654,24 +557,6 @@ public class Sessions implements */ public StopTranscodeSessionResponse stopTranscodeSession( String sessionKey) throws Exception { - return stopTranscodeSession(sessionKey, Optional.empty()); - } - - /** - * Stop a Transcode Session - * Stop a Transcode Session - * @param sessionKey the Key of the transcode session to stop - * @param options additional options - * @return The response from the API call - * @throws Exception if the API call fails - */ - public StopTranscodeSessionResponse stopTranscodeSession( - String sessionKey, - Optional options) throws Exception { - - if (options.isPresent()) { - options.get().validate(Arrays.asList(Options.Option.RETRY_CONFIG)); - } StopTranscodeSessionRequest request = StopTranscodeSessionRequest .builder() @@ -695,62 +580,45 @@ public class Sessions 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( + "stopTranscodeSession", + 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( + "stopTranscodeSession", + Optional.of(List.of()), + sdkConfiguration.securitySource()), + Optional.of(_httpRes), + Optional.empty()); + } else { + _httpRes = sdkConfiguration.hooks() + .afterSuccess( + new AfterSuccessContextImpl( + "stopTranscodeSession", + Optional.of(List.of()), + sdkConfiguration.securitySource()), + _httpRes); + } + } catch (Exception _e) { + _httpRes = sdkConfiguration.hooks() + .afterError( + new AfterErrorContextImpl( + "stopTranscodeSession", + 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( - "stopTranscodeSession", - 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( - "stopTranscodeSession", - Optional.of(List.of()), - sdkConfiguration.securitySource()), - Optional.empty(), - Optional.of(_e)); - } - }) - .retryConfig(_retryConfig) - .statusCodes(_statusCodes) - .build(); - HttpResponse _httpRes = sdkConfiguration.hooks() - .afterSuccess( - new AfterSuccessContextImpl( - "stopTranscodeSession", - Optional.of(List.of()), - sdkConfiguration.securitySource()), - _retries.run()); String _contentType = _httpRes .headers() .firstValue("Content-Type") diff --git a/src/main/java/dev/plexapi/sdk/Statistics.java b/src/main/java/dev/plexapi/sdk/Statistics.java index 0ab883ed..f0873e0b 100644 --- a/src/main/java/dev/plexapi/sdk/Statistics.java +++ b/src/main/java/dev/plexapi/sdk/Statistics.java @@ -25,16 +25,11 @@ import dev.plexapi.sdk.models.operations.GetStatisticsRequestBuilder; import dev.plexapi.sdk.models.operations.GetStatisticsResponse; import dev.plexapi.sdk.models.operations.GetStatisticsResponseBody; 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; @@ -42,11 +37,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 that perform operations with Plex Media Server Statistics @@ -80,7 +72,7 @@ public class Statistics implements * @throws Exception if the API call fails */ public GetStatisticsResponse getStatisticsDirect() throws Exception { - return getStatistics(Optional.empty(), Optional.empty()); + return getStatistics(Optional.empty()); } /** @@ -89,17 +81,11 @@ public class Statistics implements * @param timespan The timespan to retrieve statistics for the exact meaning of this parameter is not known - * @param options additional options * @return The response from the API call * @throws Exception if the API call fails */ public GetStatisticsResponse getStatistics( - Optional timespan, - Optional options) throws Exception { - - if (options.isPresent()) { - options.get().validate(Arrays.asList(Options.Option.RETRY_CONFIG)); - } + Optional timespan) throws Exception { GetStatisticsRequest request = GetStatisticsRequest .builder() @@ -126,62 +112,45 @@ public class Statistics 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( + "getStatistics", + 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( + "getStatistics", + Optional.of(List.of()), + sdkConfiguration.securitySource()), + Optional.of(_httpRes), + Optional.empty()); + } else { + _httpRes = sdkConfiguration.hooks() + .afterSuccess( + new AfterSuccessContextImpl( + "getStatistics", + Optional.of(List.of()), + sdkConfiguration.securitySource()), + _httpRes); + } + } catch (Exception _e) { + _httpRes = sdkConfiguration.hooks() + .afterError( + new AfterErrorContextImpl( + "getStatistics", + 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( - "getStatistics", - 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( - "getStatistics", - Optional.of(List.of()), - sdkConfiguration.securitySource()), - Optional.empty(), - Optional.of(_e)); - } - }) - .retryConfig(_retryConfig) - .statusCodes(_statusCodes) - .build(); - HttpResponse _httpRes = sdkConfiguration.hooks() - .afterSuccess( - new AfterSuccessContextImpl( - "getStatistics", - Optional.of(List.of()), - sdkConfiguration.securitySource()), - _retries.run()); String _contentType = _httpRes .headers() .firstValue("Content-Type") @@ -275,7 +244,7 @@ public class Statistics implements * @throws Exception if the API call fails */ public GetResourcesStatisticsResponse getResourcesStatisticsDirect() throws Exception { - return getResourcesStatistics(Optional.empty(), Optional.empty()); + return getResourcesStatistics(Optional.empty()); } /** @@ -284,17 +253,11 @@ public class Statistics implements * @param timespan The timespan to retrieve statistics for the exact meaning of this parameter is not known - * @param options additional options * @return The response from the API call * @throws Exception if the API call fails */ public GetResourcesStatisticsResponse getResourcesStatistics( - Optional timespan, - Optional options) throws Exception { - - if (options.isPresent()) { - options.get().validate(Arrays.asList(Options.Option.RETRY_CONFIG)); - } + Optional timespan) throws Exception { GetResourcesStatisticsRequest request = GetResourcesStatisticsRequest .builder() @@ -321,62 +284,45 @@ public class Statistics 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( + "getResourcesStatistics", + 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( + "getResourcesStatistics", + Optional.of(List.of()), + sdkConfiguration.securitySource()), + Optional.of(_httpRes), + Optional.empty()); + } else { + _httpRes = sdkConfiguration.hooks() + .afterSuccess( + new AfterSuccessContextImpl( + "getResourcesStatistics", + Optional.of(List.of()), + sdkConfiguration.securitySource()), + _httpRes); + } + } catch (Exception _e) { + _httpRes = sdkConfiguration.hooks() + .afterError( + new AfterErrorContextImpl( + "getResourcesStatistics", + 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( - "getResourcesStatistics", - 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( - "getResourcesStatistics", - Optional.of(List.of()), - sdkConfiguration.securitySource()), - Optional.empty(), - Optional.of(_e)); - } - }) - .retryConfig(_retryConfig) - .statusCodes(_statusCodes) - .build(); - HttpResponse _httpRes = sdkConfiguration.hooks() - .afterSuccess( - new AfterSuccessContextImpl( - "getResourcesStatistics", - Optional.of(List.of()), - sdkConfiguration.securitySource()), - _retries.run()); String _contentType = _httpRes .headers() .firstValue("Content-Type") @@ -470,7 +416,7 @@ public class Statistics implements * @throws Exception if the API call fails */ public GetBandwidthStatisticsResponse getBandwidthStatisticsDirect() throws Exception { - return getBandwidthStatistics(Optional.empty(), Optional.empty()); + return getBandwidthStatistics(Optional.empty()); } /** @@ -479,17 +425,11 @@ public class Statistics implements * @param timespan The timespan to retrieve statistics for the exact meaning of this parameter is not known - * @param options additional options * @return The response from the API call * @throws Exception if the API call fails */ public GetBandwidthStatisticsResponse getBandwidthStatistics( - Optional timespan, - Optional options) throws Exception { - - if (options.isPresent()) { - options.get().validate(Arrays.asList(Options.Option.RETRY_CONFIG)); - } + Optional timespan) throws Exception { GetBandwidthStatisticsRequest request = GetBandwidthStatisticsRequest .builder() @@ -516,62 +456,45 @@ public class Statistics 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( + "getBandwidthStatistics", + 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( + "getBandwidthStatistics", + Optional.of(List.of()), + sdkConfiguration.securitySource()), + Optional.of(_httpRes), + Optional.empty()); + } else { + _httpRes = sdkConfiguration.hooks() + .afterSuccess( + new AfterSuccessContextImpl( + "getBandwidthStatistics", + Optional.of(List.of()), + sdkConfiguration.securitySource()), + _httpRes); + } + } catch (Exception _e) { + _httpRes = sdkConfiguration.hooks() + .afterError( + new AfterErrorContextImpl( + "getBandwidthStatistics", + 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( - "getBandwidthStatistics", - 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( - "getBandwidthStatistics", - Optional.of(List.of()), - sdkConfiguration.securitySource()), - Optional.empty(), - Optional.of(_e)); - } - }) - .retryConfig(_retryConfig) - .statusCodes(_statusCodes) - .build(); - HttpResponse _httpRes = sdkConfiguration.hooks() - .afterSuccess( - new AfterSuccessContextImpl( - "getBandwidthStatistics", - Optional.of(List.of()), - sdkConfiguration.securitySource()), - _retries.run()); String _contentType = _httpRes .headers() .firstValue("Content-Type") diff --git a/src/main/java/dev/plexapi/sdk/Updater.java b/src/main/java/dev/plexapi/sdk/Updater.java index b241868f..14e60e8c 100644 --- a/src/main/java/dev/plexapi/sdk/Updater.java +++ b/src/main/java/dev/plexapi/sdk/Updater.java @@ -25,27 +25,19 @@ import dev.plexapi.sdk.models.operations.GetUpdateStatusResponseBody; import dev.plexapi.sdk.models.operations.SDKMethodInterfaces.*; import dev.plexapi.sdk.models.operations.Skip; import dev.plexapi.sdk.models.operations.Tonight; -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; /** * This describes the API for searching and applying updates to the Plex Media Server. @@ -80,22 +72,6 @@ public class Updater implements * @throws Exception if the API call fails */ public GetUpdateStatusResponse getUpdateStatusDirect() throws Exception { - return getUpdateStatus(Optional.empty()); - } - - /** - * Querying status of updates - * Querying status of updates - * @param options additional options - * @return The response from the API call - * @throws Exception if the API call fails - */ - public GetUpdateStatusResponse getUpdateStatus( - 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( @@ -111,62 +87,45 @@ public class Updater 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( + "getUpdateStatus", + 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( + "getUpdateStatus", + Optional.of(List.of()), + sdkConfiguration.securitySource()), + Optional.of(_httpRes), + Optional.empty()); + } else { + _httpRes = sdkConfiguration.hooks() + .afterSuccess( + new AfterSuccessContextImpl( + "getUpdateStatus", + Optional.of(List.of()), + sdkConfiguration.securitySource()), + _httpRes); + } + } catch (Exception _e) { + _httpRes = sdkConfiguration.hooks() + .afterError( + new AfterErrorContextImpl( + "getUpdateStatus", + 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( - "getUpdateStatus", - 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( - "getUpdateStatus", - Optional.of(List.of()), - sdkConfiguration.securitySource()), - Optional.empty(), - Optional.of(_e)); - } - }) - .retryConfig(_retryConfig) - .statusCodes(_statusCodes) - .build(); - HttpResponse _httpRes = sdkConfiguration.hooks() - .afterSuccess( - new AfterSuccessContextImpl( - "getUpdateStatus", - Optional.of(List.of()), - sdkConfiguration.securitySource()), - _retries.run()); String _contentType = _httpRes .headers() .firstValue("Content-Type") @@ -260,24 +219,18 @@ public class Updater implements * @throws Exception if the API call fails */ public CheckForUpdatesResponse checkForUpdatesDirect() throws Exception { - return checkForUpdates(Optional.empty(), Optional.empty()); + return checkForUpdates(Optional.empty()); } /** * Checking for updates * Checking for updates * @param download Indicate that you want to start download any updates found. - * @param options additional options * @return The response from the API call * @throws Exception if the API call fails */ public CheckForUpdatesResponse checkForUpdates( - Optional download, - Optional options) throws Exception { - - if (options.isPresent()) { - options.get().validate(Arrays.asList(Options.Option.RETRY_CONFIG)); - } + Optional download) throws Exception { CheckForUpdatesRequest request = CheckForUpdatesRequest .builder() @@ -304,62 +257,45 @@ public class Updater 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( + "checkForUpdates", + 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( + "checkForUpdates", + Optional.of(List.of()), + sdkConfiguration.securitySource()), + Optional.of(_httpRes), + Optional.empty()); + } else { + _httpRes = sdkConfiguration.hooks() + .afterSuccess( + new AfterSuccessContextImpl( + "checkForUpdates", + Optional.of(List.of()), + sdkConfiguration.securitySource()), + _httpRes); + } + } catch (Exception _e) { + _httpRes = sdkConfiguration.hooks() + .afterError( + new AfterErrorContextImpl( + "checkForUpdates", + 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( - "checkForUpdates", - 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( - "checkForUpdates", - Optional.of(List.of()), - sdkConfiguration.securitySource()), - Optional.empty(), - Optional.of(_e)); - } - }) - .retryConfig(_retryConfig) - .statusCodes(_statusCodes) - .build(); - HttpResponse _httpRes = sdkConfiguration.hooks() - .afterSuccess( - new AfterSuccessContextImpl( - "checkForUpdates", - Optional.of(List.of()), - sdkConfiguration.securitySource()), - _retries.run()); String _contentType = _httpRes .headers() .firstValue("Content-Type") @@ -444,7 +380,7 @@ public class Updater implements * @throws Exception if the API call fails */ public ApplyUpdatesResponse applyUpdatesDirect() throws Exception { - return applyUpdates(Optional.empty(), Optional.empty(), Optional.empty()); + return applyUpdates(Optional.empty(), Optional.empty()); } /** @@ -453,18 +389,12 @@ public class Updater implements * * @param tonight Indicate that you want the update to run during the next Butler execution. Omitting this or setting it to false indicates that the update should install * @param skip Indicate that the latest version should be marked as skipped. The [Release] entry for this version will have the `state` set to `skipped`. - * @param options additional options * @return The response from the API call * @throws Exception if the API call fails */ public ApplyUpdatesResponse applyUpdates( Optional tonight, - Optional skip, - Optional options) throws Exception { - - if (options.isPresent()) { - options.get().validate(Arrays.asList(Options.Option.RETRY_CONFIG)); - } + Optional skip) throws Exception { ApplyUpdatesRequest request = ApplyUpdatesRequest .builder() @@ -492,62 +422,45 @@ public class Updater 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( + "applyUpdates", + Optional.of(List.of()), + sdkConfiguration.securitySource()), + _req.build()); + HttpResponse _httpRes; + try { + _httpRes = _client.send(_r); + if (Utils.statusCodeMatches(_httpRes.statusCode(), "400", "401", "4XX", "500", "5XX")) { + _httpRes = sdkConfiguration.hooks() + .afterError( + new AfterErrorContextImpl( + "applyUpdates", + Optional.of(List.of()), + sdkConfiguration.securitySource()), + Optional.of(_httpRes), + Optional.empty()); + } else { + _httpRes = sdkConfiguration.hooks() + .afterSuccess( + new AfterSuccessContextImpl( + "applyUpdates", + Optional.of(List.of()), + sdkConfiguration.securitySource()), + _httpRes); + } + } catch (Exception _e) { + _httpRes = sdkConfiguration.hooks() + .afterError( + new AfterErrorContextImpl( + "applyUpdates", + 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( - "applyUpdates", - 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( - "applyUpdates", - Optional.of(List.of()), - sdkConfiguration.securitySource()), - Optional.empty(), - Optional.of(_e)); - } - }) - .retryConfig(_retryConfig) - .statusCodes(_statusCodes) - .build(); - HttpResponse _httpRes = sdkConfiguration.hooks() - .afterSuccess( - new AfterSuccessContextImpl( - "applyUpdates", - Optional.of(List.of()), - sdkConfiguration.securitySource()), - _retries.run()); String _contentType = _httpRes .headers() .firstValue("Content-Type") diff --git a/src/main/java/dev/plexapi/sdk/Video.java b/src/main/java/dev/plexapi/sdk/Video.java index a858021d..19699f3d 100644 --- a/src/main/java/dev/plexapi/sdk/Video.java +++ b/src/main/java/dev/plexapi/sdk/Video.java @@ -17,27 +17,19 @@ import dev.plexapi.sdk.models.operations.SDKMethodInterfaces.*; import dev.plexapi.sdk.models.operations.StartUniversalTranscodeRequest; import dev.plexapi.sdk.models.operations.StartUniversalTranscodeRequestBuilder; import dev.plexapi.sdk.models.operations.StartUniversalTranscodeResponse; -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 that perform operations with Plex Media Server Videos @@ -72,24 +64,6 @@ public class Video implements */ public GetTimelineResponse getTimeline( GetTimelineRequest request) throws Exception { - return getTimeline(request, Optional.empty()); - } - - /** - * Get the timeline for a media item - * Get the timeline for a 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 GetTimelineResponse getTimeline( - GetTimelineRequest 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( @@ -110,62 +84,45 @@ public class Video 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( + "getTimeline", + 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( + "getTimeline", + Optional.of(List.of()), + sdkConfiguration.securitySource()), + Optional.of(_httpRes), + Optional.empty()); + } else { + _httpRes = sdkConfiguration.hooks() + .afterSuccess( + new AfterSuccessContextImpl( + "getTimeline", + Optional.of(List.of()), + sdkConfiguration.securitySource()), + _httpRes); + } + } catch (Exception _e) { + _httpRes = sdkConfiguration.hooks() + .afterError( + new AfterErrorContextImpl( + "getTimeline", + 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( - "getTimeline", - 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( - "getTimeline", - Optional.of(List.of()), - sdkConfiguration.securitySource()), - Optional.empty(), - Optional.of(_e)); - } - }) - .retryConfig(_retryConfig) - .statusCodes(_statusCodes) - .build(); - HttpResponse _httpRes = sdkConfiguration.hooks() - .afterSuccess( - new AfterSuccessContextImpl( - "getTimeline", - Optional.of(List.of()), - sdkConfiguration.securitySource()), - _retries.run()); String _contentType = _httpRes .headers() .firstValue("Content-Type") @@ -250,24 +207,6 @@ public class Video implements */ public StartUniversalTranscodeResponse startUniversalTranscode( StartUniversalTranscodeRequest request) throws Exception { - return startUniversalTranscode(request, Optional.empty()); - } - - /** - * Start Universal Transcode - * Begin a Universal Transcode Session - * @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 StartUniversalTranscodeResponse startUniversalTranscode( - StartUniversalTranscodeRequest 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( @@ -288,62 +227,45 @@ public class Video 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( + "startUniversalTranscode", + 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( + "startUniversalTranscode", + Optional.of(List.of()), + sdkConfiguration.securitySource()), + Optional.of(_httpRes), + Optional.empty()); + } else { + _httpRes = sdkConfiguration.hooks() + .afterSuccess( + new AfterSuccessContextImpl( + "startUniversalTranscode", + Optional.of(List.of()), + sdkConfiguration.securitySource()), + _httpRes); + } + } catch (Exception _e) { + _httpRes = sdkConfiguration.hooks() + .afterError( + new AfterErrorContextImpl( + "startUniversalTranscode", + 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( - "startUniversalTranscode", - 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( - "startUniversalTranscode", - Optional.of(List.of()), - sdkConfiguration.securitySource()), - Optional.empty(), - Optional.of(_e)); - } - }) - .retryConfig(_retryConfig) - .statusCodes(_statusCodes) - .build(); - HttpResponse _httpRes = sdkConfiguration.hooks() - .afterSuccess( - new AfterSuccessContextImpl( - "startUniversalTranscode", - Optional.of(List.of()), - sdkConfiguration.securitySource()), - _retries.run()); String _contentType = _httpRes .headers() .firstValue("Content-Type") diff --git a/src/main/java/dev/plexapi/sdk/Watchlist.java b/src/main/java/dev/plexapi/sdk/Watchlist.java index 0f8beae9..47ae0962 100644 --- a/src/main/java/dev/plexapi/sdk/Watchlist.java +++ b/src/main/java/dev/plexapi/sdk/Watchlist.java @@ -13,28 +13,20 @@ import dev.plexapi.sdk.models.operations.GetWatchListRequestBuilder; import dev.plexapi.sdk.models.operations.GetWatchListResponse; import dev.plexapi.sdk.models.operations.GetWatchListResponseBody; 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 with Plex Media Server Watchlists @@ -78,7 +70,7 @@ public class Watchlist implements */ public GetWatchListResponse getWatchList( GetWatchListRequest request) throws Exception { - return getWatchList(request, Optional.empty(), Optional.empty()); + return getWatchList(request, Optional.empty()); } /** @@ -86,18 +78,12 @@ public class Watchlist implements * Get User Watchlist * @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 GetWatchListResponse getWatchList( GetWatchListRequest 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_WATCH_LIST_SERVERS[0], new HashMap()); if (serverURL.isPresent() && !serverURL.get().isBlank()) { _baseUrl = serverURL.get(); @@ -123,62 +109,45 @@ public class Watchlist 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-watch-list", + 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-watch-list", + Optional.of(List.of()), + sdkConfiguration.securitySource()), + Optional.of(_httpRes), + Optional.empty()); + } else { + _httpRes = sdkConfiguration.hooks() + .afterSuccess( + new AfterSuccessContextImpl( + "get-watch-list", + Optional.of(List.of()), + sdkConfiguration.securitySource()), + _httpRes); + } + } catch (Exception _e) { + _httpRes = sdkConfiguration.hooks() + .afterError( + new AfterErrorContextImpl( + "get-watch-list", + 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-watch-list", - 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-watch-list", - Optional.of(List.of()), - sdkConfiguration.securitySource()), - Optional.empty(), - Optional.of(_e)); - } - }) - .retryConfig(_retryConfig) - .statusCodes(_statusCodes) - .build(); - HttpResponse _httpRes = sdkConfiguration.hooks() - .afterSuccess( - new AfterSuccessContextImpl( - "get-watch-list", - Optional.of(List.of()), - sdkConfiguration.securitySource()), - _retries.run()); String _contentType = _httpRes .headers() .firstValue("Content-Type") diff --git a/src/main/java/dev/plexapi/sdk/models/operations/AddPlaylistContentsRequestBuilder.java b/src/main/java/dev/plexapi/sdk/models/operations/AddPlaylistContentsRequestBuilder.java index fe2b3e50..1758781b 100644 --- a/src/main/java/dev/plexapi/sdk/models/operations/AddPlaylistContentsRequestBuilder.java +++ b/src/main/java/dev/plexapi/sdk/models/operations/AddPlaylistContentsRequestBuilder.java @@ -4,8 +4,6 @@ package dev.plexapi.sdk.models.operations; -import dev.plexapi.sdk.utils.Options; -import dev.plexapi.sdk.utils.RetryConfig; import dev.plexapi.sdk.utils.Utils; import java.lang.Double; import java.lang.String; @@ -16,7 +14,6 @@ public class AddPlaylistContentsRequestBuilder { private Double playlistID; private String uri; private Optional playQueueID = Optional.empty(); - private Optional retryConfig = Optional.empty(); private final SDKMethodInterfaces.MethodCallAddPlaylistContents sdk; public AddPlaylistContentsRequestBuilder(SDKMethodInterfaces.MethodCallAddPlaylistContents sdk) { @@ -46,27 +43,12 @@ public class AddPlaylistContentsRequestBuilder { this.playQueueID = playQueueID; return this; } - - public AddPlaylistContentsRequestBuilder retryConfig(RetryConfig retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = Optional.of(retryConfig); - return this; - } - - public AddPlaylistContentsRequestBuilder retryConfig(Optional retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = retryConfig; - return this; - } public AddPlaylistContentsResponse call() throws Exception { - Optional options = Optional.of(Options.builder() - .retryConfig(retryConfig) - .build()); + return sdk.addPlaylistContents( playlistID, uri, - playQueueID, - options); + playQueueID); } } diff --git a/src/main/java/dev/plexapi/sdk/models/operations/ApplyUpdatesRequestBuilder.java b/src/main/java/dev/plexapi/sdk/models/operations/ApplyUpdatesRequestBuilder.java index cea725f9..afa2efd7 100644 --- a/src/main/java/dev/plexapi/sdk/models/operations/ApplyUpdatesRequestBuilder.java +++ b/src/main/java/dev/plexapi/sdk/models/operations/ApplyUpdatesRequestBuilder.java @@ -4,8 +4,6 @@ package dev.plexapi.sdk.models.operations; -import dev.plexapi.sdk.utils.Options; -import dev.plexapi.sdk.utils.RetryConfig; import dev.plexapi.sdk.utils.Utils; import java.util.Optional; @@ -13,7 +11,6 @@ public class ApplyUpdatesRequestBuilder { private Optional tonight = Optional.empty(); private Optional skip = Optional.empty(); - private Optional retryConfig = Optional.empty(); private final SDKMethodInterfaces.MethodCallApplyUpdates sdk; public ApplyUpdatesRequestBuilder(SDKMethodInterfaces.MethodCallApplyUpdates sdk) { @@ -43,26 +40,11 @@ public class ApplyUpdatesRequestBuilder { this.skip = skip; return this; } - - public ApplyUpdatesRequestBuilder retryConfig(RetryConfig retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = Optional.of(retryConfig); - return this; - } - - public ApplyUpdatesRequestBuilder retryConfig(Optional retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = retryConfig; - return this; - } public ApplyUpdatesResponse call() throws Exception { - Optional options = Optional.of(Options.builder() - .retryConfig(retryConfig) - .build()); + return sdk.applyUpdates( tonight, - skip, - options); + skip); } } diff --git a/src/main/java/dev/plexapi/sdk/models/operations/CancelServerActivitiesRequestBuilder.java b/src/main/java/dev/plexapi/sdk/models/operations/CancelServerActivitiesRequestBuilder.java index 2d350b3b..c1297b2a 100644 --- a/src/main/java/dev/plexapi/sdk/models/operations/CancelServerActivitiesRequestBuilder.java +++ b/src/main/java/dev/plexapi/sdk/models/operations/CancelServerActivitiesRequestBuilder.java @@ -4,16 +4,12 @@ package dev.plexapi.sdk.models.operations; -import dev.plexapi.sdk.utils.Options; -import dev.plexapi.sdk.utils.RetryConfig; import dev.plexapi.sdk.utils.Utils; import java.lang.String; -import java.util.Optional; public class CancelServerActivitiesRequestBuilder { private String activityUUID; - private Optional retryConfig = Optional.empty(); private final SDKMethodInterfaces.MethodCallCancelServerActivities sdk; public CancelServerActivitiesRequestBuilder(SDKMethodInterfaces.MethodCallCancelServerActivities sdk) { @@ -25,25 +21,10 @@ public class CancelServerActivitiesRequestBuilder { this.activityUUID = activityUUID; return this; } - - public CancelServerActivitiesRequestBuilder retryConfig(RetryConfig retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = Optional.of(retryConfig); - return this; - } - - public CancelServerActivitiesRequestBuilder retryConfig(Optional retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = retryConfig; - return this; - } public CancelServerActivitiesResponse call() throws Exception { - Optional options = Optional.of(Options.builder() - .retryConfig(retryConfig) - .build()); + return sdk.cancelServerActivities( - activityUUID, - options); + activityUUID); } } diff --git a/src/main/java/dev/plexapi/sdk/models/operations/CheckForUpdatesRequestBuilder.java b/src/main/java/dev/plexapi/sdk/models/operations/CheckForUpdatesRequestBuilder.java index 135f29b4..b0a8f421 100644 --- a/src/main/java/dev/plexapi/sdk/models/operations/CheckForUpdatesRequestBuilder.java +++ b/src/main/java/dev/plexapi/sdk/models/operations/CheckForUpdatesRequestBuilder.java @@ -4,15 +4,12 @@ package dev.plexapi.sdk.models.operations; -import dev.plexapi.sdk.utils.Options; -import dev.plexapi.sdk.utils.RetryConfig; import dev.plexapi.sdk.utils.Utils; import java.util.Optional; public class CheckForUpdatesRequestBuilder { private Optional download = Optional.empty(); - private Optional retryConfig = Optional.empty(); private final SDKMethodInterfaces.MethodCallCheckForUpdates sdk; public CheckForUpdatesRequestBuilder(SDKMethodInterfaces.MethodCallCheckForUpdates sdk) { @@ -30,25 +27,10 @@ public class CheckForUpdatesRequestBuilder { this.download = download; return this; } - - public CheckForUpdatesRequestBuilder retryConfig(RetryConfig retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = Optional.of(retryConfig); - return this; - } - - public CheckForUpdatesRequestBuilder retryConfig(Optional retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = retryConfig; - return this; - } public CheckForUpdatesResponse call() throws Exception { - Optional options = Optional.of(Options.builder() - .retryConfig(retryConfig) - .build()); + return sdk.checkForUpdates( - download, - options); + download); } } diff --git a/src/main/java/dev/plexapi/sdk/models/operations/ClearPlaylistContentsRequestBuilder.java b/src/main/java/dev/plexapi/sdk/models/operations/ClearPlaylistContentsRequestBuilder.java index 20bd1d89..242779f5 100644 --- a/src/main/java/dev/plexapi/sdk/models/operations/ClearPlaylistContentsRequestBuilder.java +++ b/src/main/java/dev/plexapi/sdk/models/operations/ClearPlaylistContentsRequestBuilder.java @@ -4,16 +4,12 @@ package dev.plexapi.sdk.models.operations; -import dev.plexapi.sdk.utils.Options; -import dev.plexapi.sdk.utils.RetryConfig; import dev.plexapi.sdk.utils.Utils; import java.lang.Double; -import java.util.Optional; public class ClearPlaylistContentsRequestBuilder { private Double playlistID; - private Optional retryConfig = Optional.empty(); private final SDKMethodInterfaces.MethodCallClearPlaylistContents sdk; public ClearPlaylistContentsRequestBuilder(SDKMethodInterfaces.MethodCallClearPlaylistContents sdk) { @@ -25,25 +21,10 @@ public class ClearPlaylistContentsRequestBuilder { this.playlistID = playlistID; return this; } - - public ClearPlaylistContentsRequestBuilder retryConfig(RetryConfig retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = Optional.of(retryConfig); - return this; - } - - public ClearPlaylistContentsRequestBuilder retryConfig(Optional retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = retryConfig; - return this; - } public ClearPlaylistContentsResponse call() throws Exception { - Optional options = Optional.of(Options.builder() - .retryConfig(retryConfig) - .build()); + return sdk.clearPlaylistContents( - playlistID, - options); + playlistID); } } diff --git a/src/main/java/dev/plexapi/sdk/models/operations/CreatePlaylistRequestBuilder.java b/src/main/java/dev/plexapi/sdk/models/operations/CreatePlaylistRequestBuilder.java index 04db1574..187b5ae7 100644 --- a/src/main/java/dev/plexapi/sdk/models/operations/CreatePlaylistRequestBuilder.java +++ b/src/main/java/dev/plexapi/sdk/models/operations/CreatePlaylistRequestBuilder.java @@ -4,15 +4,11 @@ package dev.plexapi.sdk.models.operations; -import dev.plexapi.sdk.utils.Options; -import dev.plexapi.sdk.utils.RetryConfig; import dev.plexapi.sdk.utils.Utils; -import java.util.Optional; public class CreatePlaylistRequestBuilder { private CreatePlaylistRequest request; - private Optional retryConfig = Optional.empty(); private final SDKMethodInterfaces.MethodCallCreatePlaylist sdk; public CreatePlaylistRequestBuilder(SDKMethodInterfaces.MethodCallCreatePlaylist sdk) { @@ -24,25 +20,10 @@ public class CreatePlaylistRequestBuilder { this.request = request; return this; } - - public CreatePlaylistRequestBuilder retryConfig(RetryConfig retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = Optional.of(retryConfig); - return this; - } - - public CreatePlaylistRequestBuilder retryConfig(Optional retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = retryConfig; - return this; - } public CreatePlaylistResponse call() throws Exception { - Optional options = Optional.of(Options.builder() - .retryConfig(retryConfig) - .build()); + return sdk.createPlaylist( - request, - options); + request); } } diff --git a/src/main/java/dev/plexapi/sdk/models/operations/DeleteLibraryRequestBuilder.java b/src/main/java/dev/plexapi/sdk/models/operations/DeleteLibraryRequestBuilder.java index dd4981a3..3b59bfdc 100644 --- a/src/main/java/dev/plexapi/sdk/models/operations/DeleteLibraryRequestBuilder.java +++ b/src/main/java/dev/plexapi/sdk/models/operations/DeleteLibraryRequestBuilder.java @@ -4,16 +4,12 @@ package dev.plexapi.sdk.models.operations; -import dev.plexapi.sdk.utils.Options; -import dev.plexapi.sdk.utils.RetryConfig; import dev.plexapi.sdk.utils.Utils; import java.lang.Integer; -import java.util.Optional; public class DeleteLibraryRequestBuilder { private Integer sectionKey; - private Optional retryConfig = Optional.empty(); private final SDKMethodInterfaces.MethodCallDeleteLibrary sdk; public DeleteLibraryRequestBuilder(SDKMethodInterfaces.MethodCallDeleteLibrary sdk) { @@ -25,25 +21,10 @@ public class DeleteLibraryRequestBuilder { this.sectionKey = sectionKey; return this; } - - public DeleteLibraryRequestBuilder retryConfig(RetryConfig retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = Optional.of(retryConfig); - return this; - } - - public DeleteLibraryRequestBuilder retryConfig(Optional retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = retryConfig; - return this; - } public DeleteLibraryResponse call() throws Exception { - Optional options = Optional.of(Options.builder() - .retryConfig(retryConfig) - .build()); + return sdk.deleteLibrary( - sectionKey, - options); + sectionKey); } } diff --git a/src/main/java/dev/plexapi/sdk/models/operations/DeletePlaylistRequestBuilder.java b/src/main/java/dev/plexapi/sdk/models/operations/DeletePlaylistRequestBuilder.java index c873498f..1e109c4f 100644 --- a/src/main/java/dev/plexapi/sdk/models/operations/DeletePlaylistRequestBuilder.java +++ b/src/main/java/dev/plexapi/sdk/models/operations/DeletePlaylistRequestBuilder.java @@ -4,16 +4,12 @@ package dev.plexapi.sdk.models.operations; -import dev.plexapi.sdk.utils.Options; -import dev.plexapi.sdk.utils.RetryConfig; import dev.plexapi.sdk.utils.Utils; import java.lang.Double; -import java.util.Optional; public class DeletePlaylistRequestBuilder { private Double playlistID; - private Optional retryConfig = Optional.empty(); private final SDKMethodInterfaces.MethodCallDeletePlaylist sdk; public DeletePlaylistRequestBuilder(SDKMethodInterfaces.MethodCallDeletePlaylist sdk) { @@ -25,25 +21,10 @@ public class DeletePlaylistRequestBuilder { this.playlistID = playlistID; return this; } - - public DeletePlaylistRequestBuilder retryConfig(RetryConfig retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = Optional.of(retryConfig); - return this; - } - - public DeletePlaylistRequestBuilder retryConfig(Optional retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = retryConfig; - return this; - } public DeletePlaylistResponse call() throws Exception { - Optional options = Optional.of(Options.builder() - .retryConfig(retryConfig) - .build()); + return sdk.deletePlaylist( - playlistID, - options); + playlistID); } } diff --git a/src/main/java/dev/plexapi/sdk/models/operations/EnablePaperTrailRequestBuilder.java b/src/main/java/dev/plexapi/sdk/models/operations/EnablePaperTrailRequestBuilder.java index 0b834989..c6e1fdc4 100644 --- a/src/main/java/dev/plexapi/sdk/models/operations/EnablePaperTrailRequestBuilder.java +++ b/src/main/java/dev/plexapi/sdk/models/operations/EnablePaperTrailRequestBuilder.java @@ -4,37 +4,17 @@ package dev.plexapi.sdk.models.operations; -import dev.plexapi.sdk.utils.Options; -import dev.plexapi.sdk.utils.RetryConfig; -import dev.plexapi.sdk.utils.Utils; -import java.util.Optional; public class EnablePaperTrailRequestBuilder { - private Optional retryConfig = Optional.empty(); private final SDKMethodInterfaces.MethodCallEnablePaperTrail sdk; public EnablePaperTrailRequestBuilder(SDKMethodInterfaces.MethodCallEnablePaperTrail sdk) { this.sdk = sdk; } - - public EnablePaperTrailRequestBuilder retryConfig(RetryConfig retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = Optional.of(retryConfig); - return this; - } - - public EnablePaperTrailRequestBuilder retryConfig(Optional retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = retryConfig; - return this; - } public EnablePaperTrailResponse call() throws Exception { - Optional options = Optional.of(Options.builder() - .retryConfig(retryConfig) - .build()); - return sdk.enablePaperTrail( - options); + + return sdk.enablePaperTrailDirect(); } } diff --git a/src/main/java/dev/plexapi/sdk/models/operations/GetAllLibrariesRequestBuilder.java b/src/main/java/dev/plexapi/sdk/models/operations/GetAllLibrariesRequestBuilder.java index 085d11f7..d2760b32 100644 --- a/src/main/java/dev/plexapi/sdk/models/operations/GetAllLibrariesRequestBuilder.java +++ b/src/main/java/dev/plexapi/sdk/models/operations/GetAllLibrariesRequestBuilder.java @@ -4,37 +4,17 @@ package dev.plexapi.sdk.models.operations; -import dev.plexapi.sdk.utils.Options; -import dev.plexapi.sdk.utils.RetryConfig; -import dev.plexapi.sdk.utils.Utils; -import java.util.Optional; public class GetAllLibrariesRequestBuilder { - private Optional retryConfig = Optional.empty(); private final SDKMethodInterfaces.MethodCallGetAllLibraries sdk; public GetAllLibrariesRequestBuilder(SDKMethodInterfaces.MethodCallGetAllLibraries sdk) { this.sdk = sdk; } - - public GetAllLibrariesRequestBuilder retryConfig(RetryConfig retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = Optional.of(retryConfig); - return this; - } - - public GetAllLibrariesRequestBuilder retryConfig(Optional retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = retryConfig; - return this; - } public GetAllLibrariesResponse call() throws Exception { - Optional options = Optional.of(Options.builder() - .retryConfig(retryConfig) - .build()); - return sdk.getAllLibraries( - options); + + return sdk.getAllLibrariesDirect(); } } diff --git a/src/main/java/dev/plexapi/sdk/models/operations/GetAvailableClientsRequestBuilder.java b/src/main/java/dev/plexapi/sdk/models/operations/GetAvailableClientsRequestBuilder.java index 6edd1a8c..3198ed08 100644 --- a/src/main/java/dev/plexapi/sdk/models/operations/GetAvailableClientsRequestBuilder.java +++ b/src/main/java/dev/plexapi/sdk/models/operations/GetAvailableClientsRequestBuilder.java @@ -4,37 +4,17 @@ package dev.plexapi.sdk.models.operations; -import dev.plexapi.sdk.utils.Options; -import dev.plexapi.sdk.utils.RetryConfig; -import dev.plexapi.sdk.utils.Utils; -import java.util.Optional; public class GetAvailableClientsRequestBuilder { - private Optional retryConfig = Optional.empty(); private final SDKMethodInterfaces.MethodCallGetAvailableClients sdk; public GetAvailableClientsRequestBuilder(SDKMethodInterfaces.MethodCallGetAvailableClients sdk) { this.sdk = sdk; } - - public GetAvailableClientsRequestBuilder retryConfig(RetryConfig retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = Optional.of(retryConfig); - return this; - } - - public GetAvailableClientsRequestBuilder retryConfig(Optional retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = retryConfig; - return this; - } public GetAvailableClientsResponse call() throws Exception { - Optional options = Optional.of(Options.builder() - .retryConfig(retryConfig) - .build()); - return sdk.getAvailableClients( - options); + + return sdk.getAvailableClientsDirect(); } } diff --git a/src/main/java/dev/plexapi/sdk/models/operations/GetBandwidthStatisticsRequestBuilder.java b/src/main/java/dev/plexapi/sdk/models/operations/GetBandwidthStatisticsRequestBuilder.java index de4a5166..46adc70d 100644 --- a/src/main/java/dev/plexapi/sdk/models/operations/GetBandwidthStatisticsRequestBuilder.java +++ b/src/main/java/dev/plexapi/sdk/models/operations/GetBandwidthStatisticsRequestBuilder.java @@ -4,8 +4,6 @@ package dev.plexapi.sdk.models.operations; -import dev.plexapi.sdk.utils.Options; -import dev.plexapi.sdk.utils.RetryConfig; import dev.plexapi.sdk.utils.Utils; import java.lang.Long; import java.util.Optional; @@ -13,7 +11,6 @@ import java.util.Optional; public class GetBandwidthStatisticsRequestBuilder { private Optional timespan = Optional.empty(); - private Optional retryConfig = Optional.empty(); private final SDKMethodInterfaces.MethodCallGetBandwidthStatistics sdk; public GetBandwidthStatisticsRequestBuilder(SDKMethodInterfaces.MethodCallGetBandwidthStatistics sdk) { @@ -31,25 +28,10 @@ public class GetBandwidthStatisticsRequestBuilder { this.timespan = timespan; return this; } - - public GetBandwidthStatisticsRequestBuilder retryConfig(RetryConfig retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = Optional.of(retryConfig); - return this; - } - - public GetBandwidthStatisticsRequestBuilder retryConfig(Optional retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = retryConfig; - return this; - } public GetBandwidthStatisticsResponse call() throws Exception { - Optional options = Optional.of(Options.builder() - .retryConfig(retryConfig) - .build()); + return sdk.getBandwidthStatistics( - timespan, - options); + timespan); } } diff --git a/src/main/java/dev/plexapi/sdk/models/operations/GetBannerImageRequestBuilder.java b/src/main/java/dev/plexapi/sdk/models/operations/GetBannerImageRequestBuilder.java index 3359137d..7cd6b8f6 100644 --- a/src/main/java/dev/plexapi/sdk/models/operations/GetBannerImageRequestBuilder.java +++ b/src/main/java/dev/plexapi/sdk/models/operations/GetBannerImageRequestBuilder.java @@ -4,15 +4,11 @@ package dev.plexapi.sdk.models.operations; -import dev.plexapi.sdk.utils.Options; -import dev.plexapi.sdk.utils.RetryConfig; import dev.plexapi.sdk.utils.Utils; -import java.util.Optional; public class GetBannerImageRequestBuilder { private GetBannerImageRequest request; - private Optional retryConfig = Optional.empty(); private final SDKMethodInterfaces.MethodCallGetBannerImage sdk; public GetBannerImageRequestBuilder(SDKMethodInterfaces.MethodCallGetBannerImage sdk) { @@ -24,25 +20,10 @@ public class GetBannerImageRequestBuilder { this.request = request; return this; } - - public GetBannerImageRequestBuilder retryConfig(RetryConfig retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = Optional.of(retryConfig); - return this; - } - - public GetBannerImageRequestBuilder retryConfig(Optional retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = retryConfig; - return this; - } public GetBannerImageResponse call() throws Exception { - Optional options = Optional.of(Options.builder() - .retryConfig(retryConfig) - .build()); + return sdk.getBannerImage( - request, - options); + request); } } diff --git a/src/main/java/dev/plexapi/sdk/models/operations/GetButlerTasksRequestBuilder.java b/src/main/java/dev/plexapi/sdk/models/operations/GetButlerTasksRequestBuilder.java index beb680b5..5e683331 100644 --- a/src/main/java/dev/plexapi/sdk/models/operations/GetButlerTasksRequestBuilder.java +++ b/src/main/java/dev/plexapi/sdk/models/operations/GetButlerTasksRequestBuilder.java @@ -4,37 +4,17 @@ package dev.plexapi.sdk.models.operations; -import dev.plexapi.sdk.utils.Options; -import dev.plexapi.sdk.utils.RetryConfig; -import dev.plexapi.sdk.utils.Utils; -import java.util.Optional; public class GetButlerTasksRequestBuilder { - private Optional retryConfig = Optional.empty(); private final SDKMethodInterfaces.MethodCallGetButlerTasks sdk; public GetButlerTasksRequestBuilder(SDKMethodInterfaces.MethodCallGetButlerTasks sdk) { this.sdk = sdk; } - - public GetButlerTasksRequestBuilder retryConfig(RetryConfig retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = Optional.of(retryConfig); - return this; - } - - public GetButlerTasksRequestBuilder retryConfig(Optional retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = retryConfig; - return this; - } public GetButlerTasksResponse call() throws Exception { - Optional options = Optional.of(Options.builder() - .retryConfig(retryConfig) - .build()); - return sdk.getButlerTasks( - options); + + return sdk.getButlerTasksDirect(); } } diff --git a/src/main/java/dev/plexapi/sdk/models/operations/GetCompanionsDataRequestBuilder.java b/src/main/java/dev/plexapi/sdk/models/operations/GetCompanionsDataRequestBuilder.java index 5d8a7cfe..cdbb8870 100644 --- a/src/main/java/dev/plexapi/sdk/models/operations/GetCompanionsDataRequestBuilder.java +++ b/src/main/java/dev/plexapi/sdk/models/operations/GetCompanionsDataRequestBuilder.java @@ -4,8 +4,6 @@ package dev.plexapi.sdk.models.operations; -import dev.plexapi.sdk.utils.Options; -import dev.plexapi.sdk.utils.RetryConfig; import dev.plexapi.sdk.utils.Utils; import java.lang.String; import java.util.Optional; @@ -13,7 +11,6 @@ import java.util.Optional; public class GetCompanionsDataRequestBuilder { private Optional serverURL = Optional.empty(); - private Optional retryConfig = Optional.empty(); private final SDKMethodInterfaces.MethodCallGetCompanionsData sdk; public GetCompanionsDataRequestBuilder(SDKMethodInterfaces.MethodCallGetCompanionsData sdk) { @@ -31,25 +28,10 @@ public class GetCompanionsDataRequestBuilder { this.serverURL = serverURL; return this; } - - public GetCompanionsDataRequestBuilder retryConfig(RetryConfig retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = Optional.of(retryConfig); - return this; - } - - public GetCompanionsDataRequestBuilder retryConfig(Optional retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = retryConfig; - return this; - } public GetCompanionsDataResponse call() throws Exception { - Optional options = Optional.of(Options.builder() - .retryConfig(retryConfig) - .build()); + return sdk.getCompanionsData( - serverURL, - options); + serverURL); } } diff --git a/src/main/java/dev/plexapi/sdk/models/operations/GetDevicesRequestBuilder.java b/src/main/java/dev/plexapi/sdk/models/operations/GetDevicesRequestBuilder.java index f2458328..a7a6546b 100644 --- a/src/main/java/dev/plexapi/sdk/models/operations/GetDevicesRequestBuilder.java +++ b/src/main/java/dev/plexapi/sdk/models/operations/GetDevicesRequestBuilder.java @@ -4,37 +4,17 @@ package dev.plexapi.sdk.models.operations; -import dev.plexapi.sdk.utils.Options; -import dev.plexapi.sdk.utils.RetryConfig; -import dev.plexapi.sdk.utils.Utils; -import java.util.Optional; public class GetDevicesRequestBuilder { - private Optional retryConfig = Optional.empty(); private final SDKMethodInterfaces.MethodCallGetDevices sdk; public GetDevicesRequestBuilder(SDKMethodInterfaces.MethodCallGetDevices sdk) { this.sdk = sdk; } - - public GetDevicesRequestBuilder retryConfig(RetryConfig retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = Optional.of(retryConfig); - return this; - } - - public GetDevicesRequestBuilder retryConfig(Optional retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = retryConfig; - return this; - } public GetDevicesResponse call() throws Exception { - Optional options = Optional.of(Options.builder() - .retryConfig(retryConfig) - .build()); - return sdk.getDevices( - options); + + return sdk.getDevicesDirect(); } } diff --git a/src/main/java/dev/plexapi/sdk/models/operations/GetFileHashRequestBuilder.java b/src/main/java/dev/plexapi/sdk/models/operations/GetFileHashRequestBuilder.java index 833185c3..ad431d38 100644 --- a/src/main/java/dev/plexapi/sdk/models/operations/GetFileHashRequestBuilder.java +++ b/src/main/java/dev/plexapi/sdk/models/operations/GetFileHashRequestBuilder.java @@ -4,8 +4,6 @@ package dev.plexapi.sdk.models.operations; -import dev.plexapi.sdk.utils.Options; -import dev.plexapi.sdk.utils.RetryConfig; import dev.plexapi.sdk.utils.Utils; import java.lang.Double; import java.lang.String; @@ -15,7 +13,6 @@ public class GetFileHashRequestBuilder { private String url; private Optional type = Optional.empty(); - private Optional retryConfig = Optional.empty(); private final SDKMethodInterfaces.MethodCallGetFileHash sdk; public GetFileHashRequestBuilder(SDKMethodInterfaces.MethodCallGetFileHash sdk) { @@ -39,26 +36,11 @@ public class GetFileHashRequestBuilder { this.type = type; return this; } - - public GetFileHashRequestBuilder retryConfig(RetryConfig retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = Optional.of(retryConfig); - return this; - } - - public GetFileHashRequestBuilder retryConfig(Optional retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = retryConfig; - return this; - } public GetFileHashResponse call() throws Exception { - Optional options = Optional.of(Options.builder() - .retryConfig(retryConfig) - .build()); + return sdk.getFileHash( url, - type, - options); + type); } } diff --git a/src/main/java/dev/plexapi/sdk/models/operations/GetGeoDataRequestBuilder.java b/src/main/java/dev/plexapi/sdk/models/operations/GetGeoDataRequestBuilder.java index ef112453..d37c1bed 100644 --- a/src/main/java/dev/plexapi/sdk/models/operations/GetGeoDataRequestBuilder.java +++ b/src/main/java/dev/plexapi/sdk/models/operations/GetGeoDataRequestBuilder.java @@ -4,8 +4,6 @@ package dev.plexapi.sdk.models.operations; -import dev.plexapi.sdk.utils.Options; -import dev.plexapi.sdk.utils.RetryConfig; import dev.plexapi.sdk.utils.Utils; import java.lang.String; import java.util.Optional; @@ -13,7 +11,6 @@ import java.util.Optional; public class GetGeoDataRequestBuilder { private Optional serverURL = Optional.empty(); - private Optional retryConfig = Optional.empty(); private final SDKMethodInterfaces.MethodCallGetGeoData sdk; public GetGeoDataRequestBuilder(SDKMethodInterfaces.MethodCallGetGeoData sdk) { @@ -31,25 +28,10 @@ public class GetGeoDataRequestBuilder { this.serverURL = serverURL; return this; } - - public GetGeoDataRequestBuilder retryConfig(RetryConfig retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = Optional.of(retryConfig); - return this; - } - - public GetGeoDataRequestBuilder retryConfig(Optional retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = retryConfig; - return this; - } public GetGeoDataResponse call() throws Exception { - Optional options = Optional.of(Options.builder() - .retryConfig(retryConfig) - .build()); + return sdk.getGeoData( - serverURL, - options); + serverURL); } } diff --git a/src/main/java/dev/plexapi/sdk/models/operations/GetGlobalHubsRequestBuilder.java b/src/main/java/dev/plexapi/sdk/models/operations/GetGlobalHubsRequestBuilder.java index 02421d68..35b22bb3 100644 --- a/src/main/java/dev/plexapi/sdk/models/operations/GetGlobalHubsRequestBuilder.java +++ b/src/main/java/dev/plexapi/sdk/models/operations/GetGlobalHubsRequestBuilder.java @@ -4,8 +4,6 @@ package dev.plexapi.sdk.models.operations; -import dev.plexapi.sdk.utils.Options; -import dev.plexapi.sdk.utils.RetryConfig; import dev.plexapi.sdk.utils.Utils; import java.lang.Double; import java.util.Optional; @@ -14,7 +12,6 @@ public class GetGlobalHubsRequestBuilder { private Optional count = Optional.empty(); private Optional onlyTransient = Optional.empty(); - private Optional retryConfig = Optional.empty(); private final SDKMethodInterfaces.MethodCallGetGlobalHubs sdk; public GetGlobalHubsRequestBuilder(SDKMethodInterfaces.MethodCallGetGlobalHubs sdk) { @@ -44,26 +41,11 @@ public class GetGlobalHubsRequestBuilder { this.onlyTransient = onlyTransient; return this; } - - public GetGlobalHubsRequestBuilder retryConfig(RetryConfig retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = Optional.of(retryConfig); - return this; - } - - public GetGlobalHubsRequestBuilder retryConfig(Optional retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = retryConfig; - return this; - } public GetGlobalHubsResponse call() throws Exception { - Optional options = Optional.of(Options.builder() - .retryConfig(retryConfig) - .build()); + return sdk.getGlobalHubs( count, - onlyTransient, - options); + onlyTransient); } } diff --git a/src/main/java/dev/plexapi/sdk/models/operations/GetHomeDataRequestBuilder.java b/src/main/java/dev/plexapi/sdk/models/operations/GetHomeDataRequestBuilder.java index 7a481029..016d51c0 100644 --- a/src/main/java/dev/plexapi/sdk/models/operations/GetHomeDataRequestBuilder.java +++ b/src/main/java/dev/plexapi/sdk/models/operations/GetHomeDataRequestBuilder.java @@ -4,37 +4,17 @@ package dev.plexapi.sdk.models.operations; -import dev.plexapi.sdk.utils.Options; -import dev.plexapi.sdk.utils.RetryConfig; -import dev.plexapi.sdk.utils.Utils; -import java.util.Optional; public class GetHomeDataRequestBuilder { - private Optional retryConfig = Optional.empty(); private final SDKMethodInterfaces.MethodCallGetHomeData sdk; public GetHomeDataRequestBuilder(SDKMethodInterfaces.MethodCallGetHomeData sdk) { this.sdk = sdk; } - - public GetHomeDataRequestBuilder retryConfig(RetryConfig retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = Optional.of(retryConfig); - return this; - } - - public GetHomeDataRequestBuilder retryConfig(Optional retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = retryConfig; - return this; - } public GetHomeDataResponse call() throws Exception { - Optional options = Optional.of(Options.builder() - .retryConfig(retryConfig) - .build()); - return sdk.getHomeData( - options); + + return sdk.getHomeDataDirect(); } } diff --git a/src/main/java/dev/plexapi/sdk/models/operations/GetLibraryDetailsRequestBuilder.java b/src/main/java/dev/plexapi/sdk/models/operations/GetLibraryDetailsRequestBuilder.java index 17e3d339..afd39499 100644 --- a/src/main/java/dev/plexapi/sdk/models/operations/GetLibraryDetailsRequestBuilder.java +++ b/src/main/java/dev/plexapi/sdk/models/operations/GetLibraryDetailsRequestBuilder.java @@ -6,8 +6,6 @@ package dev.plexapi.sdk.models.operations; import com.fasterxml.jackson.core.type.TypeReference; import dev.plexapi.sdk.utils.LazySingletonValue; -import dev.plexapi.sdk.utils.Options; -import dev.plexapi.sdk.utils.RetryConfig; import dev.plexapi.sdk.utils.Utils; import java.lang.Integer; import java.util.Optional; @@ -19,7 +17,6 @@ public class GetLibraryDetailsRequestBuilder { "0", new TypeReference>() {}); private Integer sectionKey; - private Optional retryConfig = Optional.empty(); private final SDKMethodInterfaces.MethodCallGetLibraryDetails sdk; public GetLibraryDetailsRequestBuilder(SDKMethodInterfaces.MethodCallGetLibraryDetails sdk) { @@ -43,29 +40,14 @@ public class GetLibraryDetailsRequestBuilder { this.sectionKey = sectionKey; return this; } - - public GetLibraryDetailsRequestBuilder retryConfig(RetryConfig retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = Optional.of(retryConfig); - return this; - } - - public GetLibraryDetailsRequestBuilder retryConfig(Optional retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = retryConfig; - return this; - } public GetLibraryDetailsResponse call() throws Exception { if (includeDetails == null) { includeDetails = _SINGLETON_VALUE_IncludeDetails.value(); - } Optional options = Optional.of(Options.builder() - .retryConfig(retryConfig) - .build()); + } return sdk.getLibraryDetails( includeDetails, - sectionKey, - options); + sectionKey); } private static final LazySingletonValue> _SINGLETON_VALUE_IncludeDetails = diff --git a/src/main/java/dev/plexapi/sdk/models/operations/GetLibraryHubsRequestBuilder.java b/src/main/java/dev/plexapi/sdk/models/operations/GetLibraryHubsRequestBuilder.java index 7be00acd..09e90e4e 100644 --- a/src/main/java/dev/plexapi/sdk/models/operations/GetLibraryHubsRequestBuilder.java +++ b/src/main/java/dev/plexapi/sdk/models/operations/GetLibraryHubsRequestBuilder.java @@ -4,8 +4,6 @@ package dev.plexapi.sdk.models.operations; -import dev.plexapi.sdk.utils.Options; -import dev.plexapi.sdk.utils.RetryConfig; import dev.plexapi.sdk.utils.Utils; import java.lang.Double; import java.util.Optional; @@ -15,7 +13,6 @@ public class GetLibraryHubsRequestBuilder { private Double sectionId; private Optional count = Optional.empty(); private Optional onlyTransient = Optional.empty(); - private Optional retryConfig = Optional.empty(); private final SDKMethodInterfaces.MethodCallGetLibraryHubs sdk; public GetLibraryHubsRequestBuilder(SDKMethodInterfaces.MethodCallGetLibraryHubs sdk) { @@ -51,27 +48,12 @@ public class GetLibraryHubsRequestBuilder { this.onlyTransient = onlyTransient; return this; } - - public GetLibraryHubsRequestBuilder retryConfig(RetryConfig retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = Optional.of(retryConfig); - return this; - } - - public GetLibraryHubsRequestBuilder retryConfig(Optional retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = retryConfig; - return this; - } public GetLibraryHubsResponse call() throws Exception { - Optional options = Optional.of(Options.builder() - .retryConfig(retryConfig) - .build()); + return sdk.getLibraryHubs( sectionId, count, - onlyTransient, - options); + onlyTransient); } } diff --git a/src/main/java/dev/plexapi/sdk/models/operations/GetLibraryItemsMediaContainer.java b/src/main/java/dev/plexapi/sdk/models/operations/GetLibraryItemsMediaContainer.java index 7b889c07..d4596fbf 100644 --- a/src/main/java/dev/plexapi/sdk/models/operations/GetLibraryItemsMediaContainer.java +++ b/src/main/java/dev/plexapi/sdk/models/operations/GetLibraryItemsMediaContainer.java @@ -96,8 +96,9 @@ public class GetLibraryItemsMediaContainer { @JsonProperty("mixedParents") private Optional mixedParents; + @JsonInclude(Include.NON_ABSENT) @JsonProperty("Metadata") - private List metadata; + private Optional> metadata; /** * The Meta object is only included in the response if the `includeMeta` parameter is set to `1`. @@ -130,7 +131,7 @@ public class GetLibraryItemsMediaContainer { @JsonProperty("viewGroup") String viewGroup, @JsonProperty("viewMode") Optional viewMode, @JsonProperty("mixedParents") Optional mixedParents, - @JsonProperty("Metadata") List metadata, + @JsonProperty("Metadata") Optional> metadata, @JsonProperty("Meta") Optional meta) { Utils.checkNotNull(type, "type"); Utils.checkNotNull(fieldType, "fieldType"); @@ -196,9 +197,8 @@ public class GetLibraryItemsMediaContainer { String thumb, String title1, String title2, - String viewGroup, - List metadata) { - this(Optional.empty(), Optional.empty(), size, totalSize, offset, content, allowSync, Optional.empty(), art, identifier, librarySectionID, librarySectionTitle, librarySectionUUID, mediaTagPrefix, mediaTagVersion, thumb, title1, title2, viewGroup, Optional.empty(), Optional.empty(), metadata, Optional.empty()); + String viewGroup) { + this(Optional.empty(), Optional.empty(), size, totalSize, offset, content, allowSync, Optional.empty(), art, identifier, librarySectionID, librarySectionTitle, librarySectionUUID, mediaTagPrefix, mediaTagVersion, thumb, title1, title2, viewGroup, Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); } @SuppressWarnings("unchecked") @@ -308,9 +308,10 @@ public class GetLibraryItemsMediaContainer { return mixedParents; } + @SuppressWarnings("unchecked") @JsonIgnore - public List metadata() { - return metadata; + public Optional> metadata() { + return (Optional>) metadata; } /** @@ -484,6 +485,12 @@ public class GetLibraryItemsMediaContainer { } public GetLibraryItemsMediaContainer withMetadata(List metadata) { + Utils.checkNotNull(metadata, "metadata"); + this.metadata = Optional.ofNullable(metadata); + return this; + } + + public GetLibraryItemsMediaContainer withMetadata(Optional> metadata) { Utils.checkNotNull(metadata, "metadata"); this.metadata = metadata; return this; @@ -644,7 +651,7 @@ public class GetLibraryItemsMediaContainer { private Optional mixedParents = Optional.empty(); - private List metadata; + private Optional> metadata = Optional.empty(); private Optional meta = Optional.empty(); @@ -809,6 +816,12 @@ public class GetLibraryItemsMediaContainer { } public Builder metadata(List metadata) { + Utils.checkNotNull(metadata, "metadata"); + this.metadata = Optional.ofNullable(metadata); + return this; + } + + public Builder metadata(Optional> metadata) { Utils.checkNotNull(metadata, "metadata"); this.metadata = metadata; return this; diff --git a/src/main/java/dev/plexapi/sdk/models/operations/GetLibraryItemsRequestBuilder.java b/src/main/java/dev/plexapi/sdk/models/operations/GetLibraryItemsRequestBuilder.java index 453eca89..e10e71d7 100644 --- a/src/main/java/dev/plexapi/sdk/models/operations/GetLibraryItemsRequestBuilder.java +++ b/src/main/java/dev/plexapi/sdk/models/operations/GetLibraryItemsRequestBuilder.java @@ -4,15 +4,11 @@ package dev.plexapi.sdk.models.operations; -import dev.plexapi.sdk.utils.Options; -import dev.plexapi.sdk.utils.RetryConfig; import dev.plexapi.sdk.utils.Utils; -import java.util.Optional; public class GetLibraryItemsRequestBuilder { private GetLibraryItemsRequest request; - private Optional retryConfig = Optional.empty(); private final SDKMethodInterfaces.MethodCallGetLibraryItems sdk; public GetLibraryItemsRequestBuilder(SDKMethodInterfaces.MethodCallGetLibraryItems sdk) { @@ -24,25 +20,10 @@ public class GetLibraryItemsRequestBuilder { this.request = request; return this; } - - public GetLibraryItemsRequestBuilder retryConfig(RetryConfig retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = Optional.of(retryConfig); - return this; - } - - public GetLibraryItemsRequestBuilder retryConfig(Optional retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = retryConfig; - return this; - } public GetLibraryItemsResponse call() throws Exception { - Optional options = Optional.of(Options.builder() - .retryConfig(retryConfig) - .build()); + return sdk.getLibraryItems( - request, - options); + request); } } diff --git a/src/main/java/dev/plexapi/sdk/models/operations/GetMediaProvidersRequestBuilder.java b/src/main/java/dev/plexapi/sdk/models/operations/GetMediaProvidersRequestBuilder.java index 62dda9ec..15d64b60 100644 --- a/src/main/java/dev/plexapi/sdk/models/operations/GetMediaProvidersRequestBuilder.java +++ b/src/main/java/dev/plexapi/sdk/models/operations/GetMediaProvidersRequestBuilder.java @@ -4,16 +4,12 @@ package dev.plexapi.sdk.models.operations; -import dev.plexapi.sdk.utils.Options; -import dev.plexapi.sdk.utils.RetryConfig; import dev.plexapi.sdk.utils.Utils; import java.lang.String; -import java.util.Optional; public class GetMediaProvidersRequestBuilder { private String xPlexToken; - private Optional retryConfig = Optional.empty(); private final SDKMethodInterfaces.MethodCallGetMediaProviders sdk; public GetMediaProvidersRequestBuilder(SDKMethodInterfaces.MethodCallGetMediaProviders sdk) { @@ -25,25 +21,10 @@ public class GetMediaProvidersRequestBuilder { this.xPlexToken = xPlexToken; return this; } - - public GetMediaProvidersRequestBuilder retryConfig(RetryConfig retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = Optional.of(retryConfig); - return this; - } - - public GetMediaProvidersRequestBuilder retryConfig(Optional retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = retryConfig; - return this; - } public GetMediaProvidersResponse call() throws Exception { - Optional options = Optional.of(Options.builder() - .retryConfig(retryConfig) - .build()); + return sdk.getMediaProviders( - xPlexToken, - options); + xPlexToken); } } diff --git a/src/main/java/dev/plexapi/sdk/models/operations/GetMetaDataByRatingKeyRequestBuilder.java b/src/main/java/dev/plexapi/sdk/models/operations/GetMetaDataByRatingKeyRequestBuilder.java index 0ccdf1c7..818eccbd 100644 --- a/src/main/java/dev/plexapi/sdk/models/operations/GetMetaDataByRatingKeyRequestBuilder.java +++ b/src/main/java/dev/plexapi/sdk/models/operations/GetMetaDataByRatingKeyRequestBuilder.java @@ -4,16 +4,12 @@ package dev.plexapi.sdk.models.operations; -import dev.plexapi.sdk.utils.Options; -import dev.plexapi.sdk.utils.RetryConfig; import dev.plexapi.sdk.utils.Utils; import java.lang.Long; -import java.util.Optional; public class GetMetaDataByRatingKeyRequestBuilder { private Long ratingKey; - private Optional retryConfig = Optional.empty(); private final SDKMethodInterfaces.MethodCallGetMetaDataByRatingKey sdk; public GetMetaDataByRatingKeyRequestBuilder(SDKMethodInterfaces.MethodCallGetMetaDataByRatingKey sdk) { @@ -25,25 +21,10 @@ public class GetMetaDataByRatingKeyRequestBuilder { this.ratingKey = ratingKey; return this; } - - public GetMetaDataByRatingKeyRequestBuilder retryConfig(RetryConfig retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = Optional.of(retryConfig); - return this; - } - - public GetMetaDataByRatingKeyRequestBuilder retryConfig(Optional retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = retryConfig; - return this; - } public GetMetaDataByRatingKeyResponse call() throws Exception { - Optional options = Optional.of(Options.builder() - .retryConfig(retryConfig) - .build()); + return sdk.getMetaDataByRatingKey( - ratingKey, - options); + ratingKey); } } diff --git a/src/main/java/dev/plexapi/sdk/models/operations/GetMetadataChildrenRequestBuilder.java b/src/main/java/dev/plexapi/sdk/models/operations/GetMetadataChildrenRequestBuilder.java index 803e07df..1404d80b 100644 --- a/src/main/java/dev/plexapi/sdk/models/operations/GetMetadataChildrenRequestBuilder.java +++ b/src/main/java/dev/plexapi/sdk/models/operations/GetMetadataChildrenRequestBuilder.java @@ -4,8 +4,6 @@ package dev.plexapi.sdk.models.operations; -import dev.plexapi.sdk.utils.Options; -import dev.plexapi.sdk.utils.RetryConfig; import dev.plexapi.sdk.utils.Utils; import java.lang.Double; import java.lang.String; @@ -15,7 +13,6 @@ public class GetMetadataChildrenRequestBuilder { private Double ratingKey; private Optional includeElements = Optional.empty(); - private Optional retryConfig = Optional.empty(); private final SDKMethodInterfaces.MethodCallGetMetadataChildren sdk; public GetMetadataChildrenRequestBuilder(SDKMethodInterfaces.MethodCallGetMetadataChildren sdk) { @@ -39,26 +36,11 @@ public class GetMetadataChildrenRequestBuilder { this.includeElements = includeElements; return this; } - - public GetMetadataChildrenRequestBuilder retryConfig(RetryConfig retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = Optional.of(retryConfig); - return this; - } - - public GetMetadataChildrenRequestBuilder retryConfig(Optional retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = retryConfig; - return this; - } public GetMetadataChildrenResponse call() throws Exception { - Optional options = Optional.of(Options.builder() - .retryConfig(retryConfig) - .build()); + return sdk.getMetadataChildren( ratingKey, - includeElements, - options); + includeElements); } } diff --git a/src/main/java/dev/plexapi/sdk/models/operations/GetMyPlexAccountRequestBuilder.java b/src/main/java/dev/plexapi/sdk/models/operations/GetMyPlexAccountRequestBuilder.java index cc67e591..a8a465c5 100644 --- a/src/main/java/dev/plexapi/sdk/models/operations/GetMyPlexAccountRequestBuilder.java +++ b/src/main/java/dev/plexapi/sdk/models/operations/GetMyPlexAccountRequestBuilder.java @@ -4,37 +4,17 @@ package dev.plexapi.sdk.models.operations; -import dev.plexapi.sdk.utils.Options; -import dev.plexapi.sdk.utils.RetryConfig; -import dev.plexapi.sdk.utils.Utils; -import java.util.Optional; public class GetMyPlexAccountRequestBuilder { - private Optional retryConfig = Optional.empty(); private final SDKMethodInterfaces.MethodCallGetMyPlexAccount sdk; public GetMyPlexAccountRequestBuilder(SDKMethodInterfaces.MethodCallGetMyPlexAccount sdk) { this.sdk = sdk; } - - public GetMyPlexAccountRequestBuilder retryConfig(RetryConfig retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = Optional.of(retryConfig); - return this; - } - - public GetMyPlexAccountRequestBuilder retryConfig(Optional retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = retryConfig; - return this; - } public GetMyPlexAccountResponse call() throws Exception { - Optional options = Optional.of(Options.builder() - .retryConfig(retryConfig) - .build()); - return sdk.getMyPlexAccount( - options); + + return sdk.getMyPlexAccountDirect(); } } diff --git a/src/main/java/dev/plexapi/sdk/models/operations/GetOnDeckRequestBuilder.java b/src/main/java/dev/plexapi/sdk/models/operations/GetOnDeckRequestBuilder.java index 82c9dff3..a38f4b36 100644 --- a/src/main/java/dev/plexapi/sdk/models/operations/GetOnDeckRequestBuilder.java +++ b/src/main/java/dev/plexapi/sdk/models/operations/GetOnDeckRequestBuilder.java @@ -4,37 +4,17 @@ package dev.plexapi.sdk.models.operations; -import dev.plexapi.sdk.utils.Options; -import dev.plexapi.sdk.utils.RetryConfig; -import dev.plexapi.sdk.utils.Utils; -import java.util.Optional; public class GetOnDeckRequestBuilder { - private Optional retryConfig = Optional.empty(); private final SDKMethodInterfaces.MethodCallGetOnDeck sdk; public GetOnDeckRequestBuilder(SDKMethodInterfaces.MethodCallGetOnDeck sdk) { this.sdk = sdk; } - - public GetOnDeckRequestBuilder retryConfig(RetryConfig retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = Optional.of(retryConfig); - return this; - } - - public GetOnDeckRequestBuilder retryConfig(Optional retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = retryConfig; - return this; - } public GetOnDeckResponse call() throws Exception { - Optional options = Optional.of(Options.builder() - .retryConfig(retryConfig) - .build()); - return sdk.getOnDeck( - options); + + return sdk.getOnDeckDirect(); } } diff --git a/src/main/java/dev/plexapi/sdk/models/operations/GetPinRequestBuilder.java b/src/main/java/dev/plexapi/sdk/models/operations/GetPinRequestBuilder.java index d79a5f1f..d7a9516b 100644 --- a/src/main/java/dev/plexapi/sdk/models/operations/GetPinRequestBuilder.java +++ b/src/main/java/dev/plexapi/sdk/models/operations/GetPinRequestBuilder.java @@ -4,8 +4,6 @@ package dev.plexapi.sdk.models.operations; -import dev.plexapi.sdk.utils.Options; -import dev.plexapi.sdk.utils.RetryConfig; import dev.plexapi.sdk.utils.Utils; import java.lang.String; import java.util.Optional; @@ -14,7 +12,6 @@ public class GetPinRequestBuilder { private GetPinRequest request; private Optional serverURL = Optional.empty(); - private Optional retryConfig = Optional.empty(); private final SDKMethodInterfaces.MethodCallGetPin sdk; public GetPinRequestBuilder(SDKMethodInterfaces.MethodCallGetPin sdk) { @@ -38,26 +35,11 @@ public class GetPinRequestBuilder { this.serverURL = serverURL; return this; } - - public GetPinRequestBuilder retryConfig(RetryConfig retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = Optional.of(retryConfig); - return this; - } - - public GetPinRequestBuilder retryConfig(Optional retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = retryConfig; - return this; - } public GetPinResponse call() throws Exception { - Optional options = Optional.of(Options.builder() - .retryConfig(retryConfig) - .build()); + return sdk.getPin( request, - serverURL, - options); + serverURL); } } diff --git a/src/main/java/dev/plexapi/sdk/models/operations/GetPlaylistContentsRequestBuilder.java b/src/main/java/dev/plexapi/sdk/models/operations/GetPlaylistContentsRequestBuilder.java index a7194401..37cf4497 100644 --- a/src/main/java/dev/plexapi/sdk/models/operations/GetPlaylistContentsRequestBuilder.java +++ b/src/main/java/dev/plexapi/sdk/models/operations/GetPlaylistContentsRequestBuilder.java @@ -4,17 +4,13 @@ package dev.plexapi.sdk.models.operations; -import dev.plexapi.sdk.utils.Options; -import dev.plexapi.sdk.utils.RetryConfig; import dev.plexapi.sdk.utils.Utils; import java.lang.Double; -import java.util.Optional; public class GetPlaylistContentsRequestBuilder { private Double playlistID; private GetPlaylistContentsQueryParamType type; - private Optional retryConfig = Optional.empty(); private final SDKMethodInterfaces.MethodCallGetPlaylistContents sdk; public GetPlaylistContentsRequestBuilder(SDKMethodInterfaces.MethodCallGetPlaylistContents sdk) { @@ -32,26 +28,11 @@ public class GetPlaylistContentsRequestBuilder { this.type = type; return this; } - - public GetPlaylistContentsRequestBuilder retryConfig(RetryConfig retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = Optional.of(retryConfig); - return this; - } - - public GetPlaylistContentsRequestBuilder retryConfig(Optional retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = retryConfig; - return this; - } public GetPlaylistContentsResponse call() throws Exception { - Optional options = Optional.of(Options.builder() - .retryConfig(retryConfig) - .build()); + return sdk.getPlaylistContents( playlistID, - type, - options); + type); } } diff --git a/src/main/java/dev/plexapi/sdk/models/operations/GetPlaylistRequestBuilder.java b/src/main/java/dev/plexapi/sdk/models/operations/GetPlaylistRequestBuilder.java index ec7d9a61..4fdbd0ee 100644 --- a/src/main/java/dev/plexapi/sdk/models/operations/GetPlaylistRequestBuilder.java +++ b/src/main/java/dev/plexapi/sdk/models/operations/GetPlaylistRequestBuilder.java @@ -4,16 +4,12 @@ package dev.plexapi.sdk.models.operations; -import dev.plexapi.sdk.utils.Options; -import dev.plexapi.sdk.utils.RetryConfig; import dev.plexapi.sdk.utils.Utils; import java.lang.Double; -import java.util.Optional; public class GetPlaylistRequestBuilder { private Double playlistID; - private Optional retryConfig = Optional.empty(); private final SDKMethodInterfaces.MethodCallGetPlaylist sdk; public GetPlaylistRequestBuilder(SDKMethodInterfaces.MethodCallGetPlaylist sdk) { @@ -25,25 +21,10 @@ public class GetPlaylistRequestBuilder { this.playlistID = playlistID; return this; } - - public GetPlaylistRequestBuilder retryConfig(RetryConfig retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = Optional.of(retryConfig); - return this; - } - - public GetPlaylistRequestBuilder retryConfig(Optional retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = retryConfig; - return this; - } public GetPlaylistResponse call() throws Exception { - Optional options = Optional.of(Options.builder() - .retryConfig(retryConfig) - .build()); + return sdk.getPlaylist( - playlistID, - options); + playlistID); } } diff --git a/src/main/java/dev/plexapi/sdk/models/operations/GetPlaylistsRequestBuilder.java b/src/main/java/dev/plexapi/sdk/models/operations/GetPlaylistsRequestBuilder.java index e732784f..c4ae92e4 100644 --- a/src/main/java/dev/plexapi/sdk/models/operations/GetPlaylistsRequestBuilder.java +++ b/src/main/java/dev/plexapi/sdk/models/operations/GetPlaylistsRequestBuilder.java @@ -4,8 +4,6 @@ package dev.plexapi.sdk.models.operations; -import dev.plexapi.sdk.utils.Options; -import dev.plexapi.sdk.utils.RetryConfig; import dev.plexapi.sdk.utils.Utils; import java.util.Optional; @@ -13,7 +11,6 @@ public class GetPlaylistsRequestBuilder { private Optional playlistType = Optional.empty(); private Optional smart = Optional.empty(); - private Optional retryConfig = Optional.empty(); private final SDKMethodInterfaces.MethodCallGetPlaylists sdk; public GetPlaylistsRequestBuilder(SDKMethodInterfaces.MethodCallGetPlaylists sdk) { @@ -43,26 +40,11 @@ public class GetPlaylistsRequestBuilder { this.smart = smart; return this; } - - public GetPlaylistsRequestBuilder retryConfig(RetryConfig retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = Optional.of(retryConfig); - return this; - } - - public GetPlaylistsRequestBuilder retryConfig(Optional retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = retryConfig; - return this; - } public GetPlaylistsResponse call() throws Exception { - Optional options = Optional.of(Options.builder() - .retryConfig(retryConfig) - .build()); + return sdk.getPlaylists( playlistType, - smart, - options); + smart); } } diff --git a/src/main/java/dev/plexapi/sdk/models/operations/GetRecentlyAddedLibraryRequestBuilder.java b/src/main/java/dev/plexapi/sdk/models/operations/GetRecentlyAddedLibraryRequestBuilder.java index cb345a4e..7c05a5ca 100644 --- a/src/main/java/dev/plexapi/sdk/models/operations/GetRecentlyAddedLibraryRequestBuilder.java +++ b/src/main/java/dev/plexapi/sdk/models/operations/GetRecentlyAddedLibraryRequestBuilder.java @@ -4,15 +4,11 @@ package dev.plexapi.sdk.models.operations; -import dev.plexapi.sdk.utils.Options; -import dev.plexapi.sdk.utils.RetryConfig; import dev.plexapi.sdk.utils.Utils; -import java.util.Optional; public class GetRecentlyAddedLibraryRequestBuilder { private GetRecentlyAddedLibraryRequest request; - private Optional retryConfig = Optional.empty(); private final SDKMethodInterfaces.MethodCallGetRecentlyAddedLibrary sdk; public GetRecentlyAddedLibraryRequestBuilder(SDKMethodInterfaces.MethodCallGetRecentlyAddedLibrary sdk) { @@ -24,25 +20,10 @@ public class GetRecentlyAddedLibraryRequestBuilder { this.request = request; return this; } - - public GetRecentlyAddedLibraryRequestBuilder retryConfig(RetryConfig retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = Optional.of(retryConfig); - return this; - } - - public GetRecentlyAddedLibraryRequestBuilder retryConfig(Optional retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = retryConfig; - return this; - } public GetRecentlyAddedLibraryResponse call() throws Exception { - Optional options = Optional.of(Options.builder() - .retryConfig(retryConfig) - .build()); + return sdk.getRecentlyAddedLibrary( - request, - options); + request); } } diff --git a/src/main/java/dev/plexapi/sdk/models/operations/GetRecentlyAddedRequestBuilder.java b/src/main/java/dev/plexapi/sdk/models/operations/GetRecentlyAddedRequestBuilder.java index 600b8da0..e7b3cadd 100644 --- a/src/main/java/dev/plexapi/sdk/models/operations/GetRecentlyAddedRequestBuilder.java +++ b/src/main/java/dev/plexapi/sdk/models/operations/GetRecentlyAddedRequestBuilder.java @@ -4,15 +4,11 @@ package dev.plexapi.sdk.models.operations; -import dev.plexapi.sdk.utils.Options; -import dev.plexapi.sdk.utils.RetryConfig; import dev.plexapi.sdk.utils.Utils; -import java.util.Optional; public class GetRecentlyAddedRequestBuilder { private GetRecentlyAddedRequest request; - private Optional retryConfig = Optional.empty(); private final SDKMethodInterfaces.MethodCallGetRecentlyAdded sdk; public GetRecentlyAddedRequestBuilder(SDKMethodInterfaces.MethodCallGetRecentlyAdded sdk) { @@ -24,25 +20,10 @@ public class GetRecentlyAddedRequestBuilder { this.request = request; return this; } - - public GetRecentlyAddedRequestBuilder retryConfig(RetryConfig retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = Optional.of(retryConfig); - return this; - } - - public GetRecentlyAddedRequestBuilder retryConfig(Optional retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = retryConfig; - return this; - } public GetRecentlyAddedResponse call() throws Exception { - Optional options = Optional.of(Options.builder() - .retryConfig(retryConfig) - .build()); + return sdk.getRecentlyAdded( - request, - options); + request); } } diff --git a/src/main/java/dev/plexapi/sdk/models/operations/GetRefreshLibraryMetadataRequestBuilder.java b/src/main/java/dev/plexapi/sdk/models/operations/GetRefreshLibraryMetadataRequestBuilder.java index c507db2c..9a59dbfd 100644 --- a/src/main/java/dev/plexapi/sdk/models/operations/GetRefreshLibraryMetadataRequestBuilder.java +++ b/src/main/java/dev/plexapi/sdk/models/operations/GetRefreshLibraryMetadataRequestBuilder.java @@ -4,8 +4,6 @@ package dev.plexapi.sdk.models.operations; -import dev.plexapi.sdk.utils.Options; -import dev.plexapi.sdk.utils.RetryConfig; import dev.plexapi.sdk.utils.Utils; import java.lang.Integer; import java.util.Optional; @@ -14,7 +12,6 @@ public class GetRefreshLibraryMetadataRequestBuilder { private Optional force = Optional.empty(); private Integer sectionKey; - private Optional retryConfig = Optional.empty(); private final SDKMethodInterfaces.MethodCallGetRefreshLibraryMetadata sdk; public GetRefreshLibraryMetadataRequestBuilder(SDKMethodInterfaces.MethodCallGetRefreshLibraryMetadata sdk) { @@ -38,26 +35,11 @@ public class GetRefreshLibraryMetadataRequestBuilder { this.sectionKey = sectionKey; return this; } - - public GetRefreshLibraryMetadataRequestBuilder retryConfig(RetryConfig retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = Optional.of(retryConfig); - return this; - } - - public GetRefreshLibraryMetadataRequestBuilder retryConfig(Optional retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = retryConfig; - return this; - } public GetRefreshLibraryMetadataResponse call() throws Exception { - Optional options = Optional.of(Options.builder() - .retryConfig(retryConfig) - .build()); + return sdk.getRefreshLibraryMetadata( force, - sectionKey, - options); + sectionKey); } } diff --git a/src/main/java/dev/plexapi/sdk/models/operations/GetResizedPhotoRequestBuilder.java b/src/main/java/dev/plexapi/sdk/models/operations/GetResizedPhotoRequestBuilder.java index 6b023148..bc5b65f0 100644 --- a/src/main/java/dev/plexapi/sdk/models/operations/GetResizedPhotoRequestBuilder.java +++ b/src/main/java/dev/plexapi/sdk/models/operations/GetResizedPhotoRequestBuilder.java @@ -4,15 +4,11 @@ package dev.plexapi.sdk.models.operations; -import dev.plexapi.sdk.utils.Options; -import dev.plexapi.sdk.utils.RetryConfig; import dev.plexapi.sdk.utils.Utils; -import java.util.Optional; public class GetResizedPhotoRequestBuilder { private GetResizedPhotoRequest request; - private Optional retryConfig = Optional.empty(); private final SDKMethodInterfaces.MethodCallGetResizedPhoto sdk; public GetResizedPhotoRequestBuilder(SDKMethodInterfaces.MethodCallGetResizedPhoto sdk) { @@ -24,25 +20,10 @@ public class GetResizedPhotoRequestBuilder { this.request = request; return this; } - - public GetResizedPhotoRequestBuilder retryConfig(RetryConfig retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = Optional.of(retryConfig); - return this; - } - - public GetResizedPhotoRequestBuilder retryConfig(Optional retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = retryConfig; - return this; - } public GetResizedPhotoResponse call() throws Exception { - Optional options = Optional.of(Options.builder() - .retryConfig(retryConfig) - .build()); + return sdk.getResizedPhoto( - request, - options); + request); } } diff --git a/src/main/java/dev/plexapi/sdk/models/operations/GetResourcesStatisticsRequestBuilder.java b/src/main/java/dev/plexapi/sdk/models/operations/GetResourcesStatisticsRequestBuilder.java index 8ad8ae19..60bcfd7f 100644 --- a/src/main/java/dev/plexapi/sdk/models/operations/GetResourcesStatisticsRequestBuilder.java +++ b/src/main/java/dev/plexapi/sdk/models/operations/GetResourcesStatisticsRequestBuilder.java @@ -4,8 +4,6 @@ package dev.plexapi.sdk.models.operations; -import dev.plexapi.sdk.utils.Options; -import dev.plexapi.sdk.utils.RetryConfig; import dev.plexapi.sdk.utils.Utils; import java.lang.Long; import java.util.Optional; @@ -13,7 +11,6 @@ import java.util.Optional; public class GetResourcesStatisticsRequestBuilder { private Optional timespan = Optional.empty(); - private Optional retryConfig = Optional.empty(); private final SDKMethodInterfaces.MethodCallGetResourcesStatistics sdk; public GetResourcesStatisticsRequestBuilder(SDKMethodInterfaces.MethodCallGetResourcesStatistics sdk) { @@ -31,25 +28,10 @@ public class GetResourcesStatisticsRequestBuilder { this.timespan = timespan; return this; } - - public GetResourcesStatisticsRequestBuilder retryConfig(RetryConfig retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = Optional.of(retryConfig); - return this; - } - - public GetResourcesStatisticsRequestBuilder retryConfig(Optional retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = retryConfig; - return this; - } public GetResourcesStatisticsResponse call() throws Exception { - Optional options = Optional.of(Options.builder() - .retryConfig(retryConfig) - .build()); + return sdk.getResourcesStatistics( - timespan, - options); + timespan); } } diff --git a/src/main/java/dev/plexapi/sdk/models/operations/GetSearchAllLibrariesRequestBuilder.java b/src/main/java/dev/plexapi/sdk/models/operations/GetSearchAllLibrariesRequestBuilder.java index 4f0f935f..aa22fcdb 100644 --- a/src/main/java/dev/plexapi/sdk/models/operations/GetSearchAllLibrariesRequestBuilder.java +++ b/src/main/java/dev/plexapi/sdk/models/operations/GetSearchAllLibrariesRequestBuilder.java @@ -4,15 +4,11 @@ package dev.plexapi.sdk.models.operations; -import dev.plexapi.sdk.utils.Options; -import dev.plexapi.sdk.utils.RetryConfig; import dev.plexapi.sdk.utils.Utils; -import java.util.Optional; public class GetSearchAllLibrariesRequestBuilder { private GetSearchAllLibrariesRequest request; - private Optional retryConfig = Optional.empty(); private final SDKMethodInterfaces.MethodCallGetSearchAllLibraries sdk; public GetSearchAllLibrariesRequestBuilder(SDKMethodInterfaces.MethodCallGetSearchAllLibraries sdk) { @@ -24,25 +20,10 @@ public class GetSearchAllLibrariesRequestBuilder { this.request = request; return this; } - - public GetSearchAllLibrariesRequestBuilder retryConfig(RetryConfig retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = Optional.of(retryConfig); - return this; - } - - public GetSearchAllLibrariesRequestBuilder retryConfig(Optional retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = retryConfig; - return this; - } public GetSearchAllLibrariesResponse call() throws Exception { - Optional options = Optional.of(Options.builder() - .retryConfig(retryConfig) - .build()); + return sdk.getSearchAllLibraries( - request, - options); + request); } } diff --git a/src/main/java/dev/plexapi/sdk/models/operations/GetSearchLibraryRequestBuilder.java b/src/main/java/dev/plexapi/sdk/models/operations/GetSearchLibraryRequestBuilder.java index 33fc26a0..ed52545f 100644 --- a/src/main/java/dev/plexapi/sdk/models/operations/GetSearchLibraryRequestBuilder.java +++ b/src/main/java/dev/plexapi/sdk/models/operations/GetSearchLibraryRequestBuilder.java @@ -4,17 +4,13 @@ package dev.plexapi.sdk.models.operations; -import dev.plexapi.sdk.utils.Options; -import dev.plexapi.sdk.utils.RetryConfig; import dev.plexapi.sdk.utils.Utils; import java.lang.Integer; -import java.util.Optional; public class GetSearchLibraryRequestBuilder { private Integer sectionKey; private GetSearchLibraryQueryParamType type; - private Optional retryConfig = Optional.empty(); private final SDKMethodInterfaces.MethodCallGetSearchLibrary sdk; public GetSearchLibraryRequestBuilder(SDKMethodInterfaces.MethodCallGetSearchLibrary sdk) { @@ -32,26 +28,11 @@ public class GetSearchLibraryRequestBuilder { this.type = type; return this; } - - public GetSearchLibraryRequestBuilder retryConfig(RetryConfig retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = Optional.of(retryConfig); - return this; - } - - public GetSearchLibraryRequestBuilder retryConfig(Optional retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = retryConfig; - return this; - } public GetSearchLibraryResponse call() throws Exception { - Optional options = Optional.of(Options.builder() - .retryConfig(retryConfig) - .build()); + return sdk.getSearchLibrary( sectionKey, - type, - options); + type); } } diff --git a/src/main/java/dev/plexapi/sdk/models/operations/GetSearchResultsRequestBuilder.java b/src/main/java/dev/plexapi/sdk/models/operations/GetSearchResultsRequestBuilder.java index e794c91a..873bddf6 100644 --- a/src/main/java/dev/plexapi/sdk/models/operations/GetSearchResultsRequestBuilder.java +++ b/src/main/java/dev/plexapi/sdk/models/operations/GetSearchResultsRequestBuilder.java @@ -4,16 +4,12 @@ package dev.plexapi.sdk.models.operations; -import dev.plexapi.sdk.utils.Options; -import dev.plexapi.sdk.utils.RetryConfig; import dev.plexapi.sdk.utils.Utils; import java.lang.String; -import java.util.Optional; public class GetSearchResultsRequestBuilder { private String query; - private Optional retryConfig = Optional.empty(); private final SDKMethodInterfaces.MethodCallGetSearchResults sdk; public GetSearchResultsRequestBuilder(SDKMethodInterfaces.MethodCallGetSearchResults sdk) { @@ -25,25 +21,10 @@ public class GetSearchResultsRequestBuilder { this.query = query; return this; } - - public GetSearchResultsRequestBuilder retryConfig(RetryConfig retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = Optional.of(retryConfig); - return this; - } - - public GetSearchResultsRequestBuilder retryConfig(Optional retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = retryConfig; - return this; - } public GetSearchResultsResponse call() throws Exception { - Optional options = Optional.of(Options.builder() - .retryConfig(retryConfig) - .build()); + return sdk.getSearchResults( - query, - options); + query); } } diff --git a/src/main/java/dev/plexapi/sdk/models/operations/GetServerActivitiesRequestBuilder.java b/src/main/java/dev/plexapi/sdk/models/operations/GetServerActivitiesRequestBuilder.java index f191d7b3..b8d6bd4d 100644 --- a/src/main/java/dev/plexapi/sdk/models/operations/GetServerActivitiesRequestBuilder.java +++ b/src/main/java/dev/plexapi/sdk/models/operations/GetServerActivitiesRequestBuilder.java @@ -4,37 +4,17 @@ package dev.plexapi.sdk.models.operations; -import dev.plexapi.sdk.utils.Options; -import dev.plexapi.sdk.utils.RetryConfig; -import dev.plexapi.sdk.utils.Utils; -import java.util.Optional; public class GetServerActivitiesRequestBuilder { - private Optional retryConfig = Optional.empty(); private final SDKMethodInterfaces.MethodCallGetServerActivities sdk; public GetServerActivitiesRequestBuilder(SDKMethodInterfaces.MethodCallGetServerActivities sdk) { this.sdk = sdk; } - - public GetServerActivitiesRequestBuilder retryConfig(RetryConfig retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = Optional.of(retryConfig); - return this; - } - - public GetServerActivitiesRequestBuilder retryConfig(Optional retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = retryConfig; - return this; - } public GetServerActivitiesResponse call() throws Exception { - Optional options = Optional.of(Options.builder() - .retryConfig(retryConfig) - .build()); - return sdk.getServerActivities( - options); + + return sdk.getServerActivitiesDirect(); } } diff --git a/src/main/java/dev/plexapi/sdk/models/operations/GetServerCapabilitiesRequestBuilder.java b/src/main/java/dev/plexapi/sdk/models/operations/GetServerCapabilitiesRequestBuilder.java index 2de05727..05ef6d64 100644 --- a/src/main/java/dev/plexapi/sdk/models/operations/GetServerCapabilitiesRequestBuilder.java +++ b/src/main/java/dev/plexapi/sdk/models/operations/GetServerCapabilitiesRequestBuilder.java @@ -4,37 +4,17 @@ package dev.plexapi.sdk.models.operations; -import dev.plexapi.sdk.utils.Options; -import dev.plexapi.sdk.utils.RetryConfig; -import dev.plexapi.sdk.utils.Utils; -import java.util.Optional; public class GetServerCapabilitiesRequestBuilder { - private Optional retryConfig = Optional.empty(); private final SDKMethodInterfaces.MethodCallGetServerCapabilities sdk; public GetServerCapabilitiesRequestBuilder(SDKMethodInterfaces.MethodCallGetServerCapabilities sdk) { this.sdk = sdk; } - - public GetServerCapabilitiesRequestBuilder retryConfig(RetryConfig retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = Optional.of(retryConfig); - return this; - } - - public GetServerCapabilitiesRequestBuilder retryConfig(Optional retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = retryConfig; - return this; - } public GetServerCapabilitiesResponse call() throws Exception { - Optional options = Optional.of(Options.builder() - .retryConfig(retryConfig) - .build()); - return sdk.getServerCapabilities( - options); + + return sdk.getServerCapabilitiesDirect(); } } diff --git a/src/main/java/dev/plexapi/sdk/models/operations/GetServerIdentityRequestBuilder.java b/src/main/java/dev/plexapi/sdk/models/operations/GetServerIdentityRequestBuilder.java index db10a8a5..cdc402de 100644 --- a/src/main/java/dev/plexapi/sdk/models/operations/GetServerIdentityRequestBuilder.java +++ b/src/main/java/dev/plexapi/sdk/models/operations/GetServerIdentityRequestBuilder.java @@ -4,37 +4,17 @@ package dev.plexapi.sdk.models.operations; -import dev.plexapi.sdk.utils.Options; -import dev.plexapi.sdk.utils.RetryConfig; -import dev.plexapi.sdk.utils.Utils; -import java.util.Optional; public class GetServerIdentityRequestBuilder { - private Optional retryConfig = Optional.empty(); private final SDKMethodInterfaces.MethodCallGetServerIdentity sdk; public GetServerIdentityRequestBuilder(SDKMethodInterfaces.MethodCallGetServerIdentity sdk) { this.sdk = sdk; } - - public GetServerIdentityRequestBuilder retryConfig(RetryConfig retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = Optional.of(retryConfig); - return this; - } - - public GetServerIdentityRequestBuilder retryConfig(Optional retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = retryConfig; - return this; - } public GetServerIdentityResponse call() throws Exception { - Optional options = Optional.of(Options.builder() - .retryConfig(retryConfig) - .build()); - return sdk.getServerIdentity( - options); + + return sdk.getServerIdentityDirect(); } } diff --git a/src/main/java/dev/plexapi/sdk/models/operations/GetServerListRequestBuilder.java b/src/main/java/dev/plexapi/sdk/models/operations/GetServerListRequestBuilder.java index d68319ee..9f6f4f6f 100644 --- a/src/main/java/dev/plexapi/sdk/models/operations/GetServerListRequestBuilder.java +++ b/src/main/java/dev/plexapi/sdk/models/operations/GetServerListRequestBuilder.java @@ -4,37 +4,17 @@ package dev.plexapi.sdk.models.operations; -import dev.plexapi.sdk.utils.Options; -import dev.plexapi.sdk.utils.RetryConfig; -import dev.plexapi.sdk.utils.Utils; -import java.util.Optional; public class GetServerListRequestBuilder { - private Optional retryConfig = Optional.empty(); private final SDKMethodInterfaces.MethodCallGetServerList sdk; public GetServerListRequestBuilder(SDKMethodInterfaces.MethodCallGetServerList sdk) { this.sdk = sdk; } - - public GetServerListRequestBuilder retryConfig(RetryConfig retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = Optional.of(retryConfig); - return this; - } - - public GetServerListRequestBuilder retryConfig(Optional retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = retryConfig; - return this; - } public GetServerListResponse call() throws Exception { - Optional options = Optional.of(Options.builder() - .retryConfig(retryConfig) - .build()); - return sdk.getServerList( - options); + + return sdk.getServerListDirect(); } } diff --git a/src/main/java/dev/plexapi/sdk/models/operations/GetServerPreferencesRequestBuilder.java b/src/main/java/dev/plexapi/sdk/models/operations/GetServerPreferencesRequestBuilder.java index bbe0487e..0671e581 100644 --- a/src/main/java/dev/plexapi/sdk/models/operations/GetServerPreferencesRequestBuilder.java +++ b/src/main/java/dev/plexapi/sdk/models/operations/GetServerPreferencesRequestBuilder.java @@ -4,37 +4,17 @@ package dev.plexapi.sdk.models.operations; -import dev.plexapi.sdk.utils.Options; -import dev.plexapi.sdk.utils.RetryConfig; -import dev.plexapi.sdk.utils.Utils; -import java.util.Optional; public class GetServerPreferencesRequestBuilder { - private Optional retryConfig = Optional.empty(); private final SDKMethodInterfaces.MethodCallGetServerPreferences sdk; public GetServerPreferencesRequestBuilder(SDKMethodInterfaces.MethodCallGetServerPreferences sdk) { this.sdk = sdk; } - - public GetServerPreferencesRequestBuilder retryConfig(RetryConfig retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = Optional.of(retryConfig); - return this; - } - - public GetServerPreferencesRequestBuilder retryConfig(Optional retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = retryConfig; - return this; - } public GetServerPreferencesResponse call() throws Exception { - Optional options = Optional.of(Options.builder() - .retryConfig(retryConfig) - .build()); - return sdk.getServerPreferences( - options); + + return sdk.getServerPreferencesDirect(); } } diff --git a/src/main/java/dev/plexapi/sdk/models/operations/GetServerResourcesRequestBuilder.java b/src/main/java/dev/plexapi/sdk/models/operations/GetServerResourcesRequestBuilder.java index 0e4df6fe..ed46ea32 100644 --- a/src/main/java/dev/plexapi/sdk/models/operations/GetServerResourcesRequestBuilder.java +++ b/src/main/java/dev/plexapi/sdk/models/operations/GetServerResourcesRequestBuilder.java @@ -6,8 +6,6 @@ package dev.plexapi.sdk.models.operations; import com.fasterxml.jackson.core.type.TypeReference; import dev.plexapi.sdk.utils.LazySingletonValue; -import dev.plexapi.sdk.utils.Options; -import dev.plexapi.sdk.utils.RetryConfig; import dev.plexapi.sdk.utils.Utils; import java.lang.String; import java.util.Optional; @@ -28,7 +26,6 @@ public class GetServerResourcesRequestBuilder { new TypeReference>() {}); private Optional clientID = Optional.empty(); private Optional serverURL = Optional.empty(); - private Optional retryConfig = Optional.empty(); private final SDKMethodInterfaces.MethodCallGetServerResources sdk; public GetServerResourcesRequestBuilder(SDKMethodInterfaces.MethodCallGetServerResources sdk) { @@ -94,18 +91,6 @@ public class GetServerResourcesRequestBuilder { this.serverURL = serverURL; return this; } - - public GetServerResourcesRequestBuilder retryConfig(RetryConfig retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = Optional.of(retryConfig); - return this; - } - - public GetServerResourcesRequestBuilder retryConfig(Optional retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = retryConfig; - return this; - } public GetServerResourcesResponse call() throws Exception { if (includeHttps == null) { @@ -116,16 +101,13 @@ public class GetServerResourcesRequestBuilder { } if (includeIPv6 == null) { includeIPv6 = _SINGLETON_VALUE_IncludeIPv6.value(); - } Optional options = Optional.of(Options.builder() - .retryConfig(retryConfig) - .build()); + } return sdk.getServerResources( includeHttps, includeRelay, includeIPv6, clientID, - serverURL, - options); + serverURL); } private static final LazySingletonValue> _SINGLETON_VALUE_IncludeHttps = diff --git a/src/main/java/dev/plexapi/sdk/models/operations/GetSessionHistoryRequestBuilder.java b/src/main/java/dev/plexapi/sdk/models/operations/GetSessionHistoryRequestBuilder.java index c5dd7e6b..e21a82ba 100644 --- a/src/main/java/dev/plexapi/sdk/models/operations/GetSessionHistoryRequestBuilder.java +++ b/src/main/java/dev/plexapi/sdk/models/operations/GetSessionHistoryRequestBuilder.java @@ -4,8 +4,6 @@ package dev.plexapi.sdk.models.operations; -import dev.plexapi.sdk.utils.Options; -import dev.plexapi.sdk.utils.RetryConfig; import dev.plexapi.sdk.utils.Utils; import java.lang.Long; import java.lang.String; @@ -17,7 +15,6 @@ public class GetSessionHistoryRequestBuilder { private Optional accountId = Optional.empty(); private Optional filter = Optional.empty(); private Optional librarySectionID = Optional.empty(); - private Optional retryConfig = Optional.empty(); private final SDKMethodInterfaces.MethodCallGetSessionHistory sdk; public GetSessionHistoryRequestBuilder(SDKMethodInterfaces.MethodCallGetSessionHistory sdk) { @@ -71,28 +68,13 @@ public class GetSessionHistoryRequestBuilder { this.librarySectionID = librarySectionID; return this; } - - public GetSessionHistoryRequestBuilder retryConfig(RetryConfig retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = Optional.of(retryConfig); - return this; - } - - public GetSessionHistoryRequestBuilder retryConfig(Optional retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = retryConfig; - return this; - } public GetSessionHistoryResponse call() throws Exception { - Optional options = Optional.of(Options.builder() - .retryConfig(retryConfig) - .build()); + return sdk.getSessionHistory( sort, accountId, filter, - librarySectionID, - options); + librarySectionID); } } diff --git a/src/main/java/dev/plexapi/sdk/models/operations/GetSessionsRequestBuilder.java b/src/main/java/dev/plexapi/sdk/models/operations/GetSessionsRequestBuilder.java index d52467cb..92090850 100644 --- a/src/main/java/dev/plexapi/sdk/models/operations/GetSessionsRequestBuilder.java +++ b/src/main/java/dev/plexapi/sdk/models/operations/GetSessionsRequestBuilder.java @@ -4,37 +4,17 @@ package dev.plexapi.sdk.models.operations; -import dev.plexapi.sdk.utils.Options; -import dev.plexapi.sdk.utils.RetryConfig; -import dev.plexapi.sdk.utils.Utils; -import java.util.Optional; public class GetSessionsRequestBuilder { - private Optional retryConfig = Optional.empty(); private final SDKMethodInterfaces.MethodCallGetSessions sdk; public GetSessionsRequestBuilder(SDKMethodInterfaces.MethodCallGetSessions sdk) { this.sdk = sdk; } - - public GetSessionsRequestBuilder retryConfig(RetryConfig retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = Optional.of(retryConfig); - return this; - } - - public GetSessionsRequestBuilder retryConfig(Optional retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = retryConfig; - return this; - } public GetSessionsResponse call() throws Exception { - Optional options = Optional.of(Options.builder() - .retryConfig(retryConfig) - .build()); - return sdk.getSessions( - options); + + return sdk.getSessionsDirect(); } } diff --git a/src/main/java/dev/plexapi/sdk/models/operations/GetSourceConnectionInformationRequestBuilder.java b/src/main/java/dev/plexapi/sdk/models/operations/GetSourceConnectionInformationRequestBuilder.java index 445fd35c..048c52ea 100644 --- a/src/main/java/dev/plexapi/sdk/models/operations/GetSourceConnectionInformationRequestBuilder.java +++ b/src/main/java/dev/plexapi/sdk/models/operations/GetSourceConnectionInformationRequestBuilder.java @@ -4,16 +4,12 @@ package dev.plexapi.sdk.models.operations; -import dev.plexapi.sdk.utils.Options; -import dev.plexapi.sdk.utils.RetryConfig; import dev.plexapi.sdk.utils.Utils; import java.lang.String; -import java.util.Optional; public class GetSourceConnectionInformationRequestBuilder { private String source; - private Optional retryConfig = Optional.empty(); private final SDKMethodInterfaces.MethodCallGetSourceConnectionInformation sdk; public GetSourceConnectionInformationRequestBuilder(SDKMethodInterfaces.MethodCallGetSourceConnectionInformation sdk) { @@ -25,25 +21,10 @@ public class GetSourceConnectionInformationRequestBuilder { this.source = source; return this; } - - public GetSourceConnectionInformationRequestBuilder retryConfig(RetryConfig retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = Optional.of(retryConfig); - return this; - } - - public GetSourceConnectionInformationRequestBuilder retryConfig(Optional retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = retryConfig; - return this; - } public GetSourceConnectionInformationResponse call() throws Exception { - Optional options = Optional.of(Options.builder() - .retryConfig(retryConfig) - .build()); + return sdk.getSourceConnectionInformation( - source, - options); + source); } } diff --git a/src/main/java/dev/plexapi/sdk/models/operations/GetStatisticsRequestBuilder.java b/src/main/java/dev/plexapi/sdk/models/operations/GetStatisticsRequestBuilder.java index d8c3746f..febdc0d9 100644 --- a/src/main/java/dev/plexapi/sdk/models/operations/GetStatisticsRequestBuilder.java +++ b/src/main/java/dev/plexapi/sdk/models/operations/GetStatisticsRequestBuilder.java @@ -4,8 +4,6 @@ package dev.plexapi.sdk.models.operations; -import dev.plexapi.sdk.utils.Options; -import dev.plexapi.sdk.utils.RetryConfig; import dev.plexapi.sdk.utils.Utils; import java.lang.Long; import java.util.Optional; @@ -13,7 +11,6 @@ import java.util.Optional; public class GetStatisticsRequestBuilder { private Optional timespan = Optional.empty(); - private Optional retryConfig = Optional.empty(); private final SDKMethodInterfaces.MethodCallGetStatistics sdk; public GetStatisticsRequestBuilder(SDKMethodInterfaces.MethodCallGetStatistics sdk) { @@ -31,25 +28,10 @@ public class GetStatisticsRequestBuilder { this.timespan = timespan; return this; } - - public GetStatisticsRequestBuilder retryConfig(RetryConfig retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = Optional.of(retryConfig); - return this; - } - - public GetStatisticsRequestBuilder retryConfig(Optional retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = retryConfig; - return this; - } public GetStatisticsResponse call() throws Exception { - Optional options = Optional.of(Options.builder() - .retryConfig(retryConfig) - .build()); + return sdk.getStatistics( - timespan, - options); + timespan); } } diff --git a/src/main/java/dev/plexapi/sdk/models/operations/GetThumbImageRequestBuilder.java b/src/main/java/dev/plexapi/sdk/models/operations/GetThumbImageRequestBuilder.java index bf7b468e..a6144eb5 100644 --- a/src/main/java/dev/plexapi/sdk/models/operations/GetThumbImageRequestBuilder.java +++ b/src/main/java/dev/plexapi/sdk/models/operations/GetThumbImageRequestBuilder.java @@ -4,15 +4,11 @@ package dev.plexapi.sdk.models.operations; -import dev.plexapi.sdk.utils.Options; -import dev.plexapi.sdk.utils.RetryConfig; import dev.plexapi.sdk.utils.Utils; -import java.util.Optional; public class GetThumbImageRequestBuilder { private GetThumbImageRequest request; - private Optional retryConfig = Optional.empty(); private final SDKMethodInterfaces.MethodCallGetThumbImage sdk; public GetThumbImageRequestBuilder(SDKMethodInterfaces.MethodCallGetThumbImage sdk) { @@ -24,25 +20,10 @@ public class GetThumbImageRequestBuilder { this.request = request; return this; } - - public GetThumbImageRequestBuilder retryConfig(RetryConfig retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = Optional.of(retryConfig); - return this; - } - - public GetThumbImageRequestBuilder retryConfig(Optional retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = retryConfig; - return this; - } public GetThumbImageResponse call() throws Exception { - Optional options = Optional.of(Options.builder() - .retryConfig(retryConfig) - .build()); + return sdk.getThumbImage( - request, - options); + request); } } diff --git a/src/main/java/dev/plexapi/sdk/models/operations/GetTimelineRequestBuilder.java b/src/main/java/dev/plexapi/sdk/models/operations/GetTimelineRequestBuilder.java index 357f093c..64339916 100644 --- a/src/main/java/dev/plexapi/sdk/models/operations/GetTimelineRequestBuilder.java +++ b/src/main/java/dev/plexapi/sdk/models/operations/GetTimelineRequestBuilder.java @@ -4,15 +4,11 @@ package dev.plexapi.sdk.models.operations; -import dev.plexapi.sdk.utils.Options; -import dev.plexapi.sdk.utils.RetryConfig; import dev.plexapi.sdk.utils.Utils; -import java.util.Optional; public class GetTimelineRequestBuilder { private GetTimelineRequest request; - private Optional retryConfig = Optional.empty(); private final SDKMethodInterfaces.MethodCallGetTimeline sdk; public GetTimelineRequestBuilder(SDKMethodInterfaces.MethodCallGetTimeline sdk) { @@ -24,25 +20,10 @@ public class GetTimelineRequestBuilder { this.request = request; return this; } - - public GetTimelineRequestBuilder retryConfig(RetryConfig retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = Optional.of(retryConfig); - return this; - } - - public GetTimelineRequestBuilder retryConfig(Optional retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = retryConfig; - return this; - } public GetTimelineResponse call() throws Exception { - Optional options = Optional.of(Options.builder() - .retryConfig(retryConfig) - .build()); + return sdk.getTimeline( - request, - options); + request); } } diff --git a/src/main/java/dev/plexapi/sdk/models/operations/GetTokenByPinIdRequestBuilder.java b/src/main/java/dev/plexapi/sdk/models/operations/GetTokenByPinIdRequestBuilder.java index 96985879..d0d0b1d8 100644 --- a/src/main/java/dev/plexapi/sdk/models/operations/GetTokenByPinIdRequestBuilder.java +++ b/src/main/java/dev/plexapi/sdk/models/operations/GetTokenByPinIdRequestBuilder.java @@ -4,8 +4,6 @@ package dev.plexapi.sdk.models.operations; -import dev.plexapi.sdk.utils.Options; -import dev.plexapi.sdk.utils.RetryConfig; import dev.plexapi.sdk.utils.Utils; import java.lang.String; import java.util.Optional; @@ -14,7 +12,6 @@ public class GetTokenByPinIdRequestBuilder { private GetTokenByPinIdRequest request; private Optional serverURL = Optional.empty(); - private Optional retryConfig = Optional.empty(); private final SDKMethodInterfaces.MethodCallGetTokenByPinId sdk; public GetTokenByPinIdRequestBuilder(SDKMethodInterfaces.MethodCallGetTokenByPinId sdk) { @@ -38,26 +35,11 @@ public class GetTokenByPinIdRequestBuilder { this.serverURL = serverURL; return this; } - - public GetTokenByPinIdRequestBuilder retryConfig(RetryConfig retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = Optional.of(retryConfig); - return this; - } - - public GetTokenByPinIdRequestBuilder retryConfig(Optional retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = retryConfig; - return this; - } public GetTokenByPinIdResponse call() throws Exception { - Optional options = Optional.of(Options.builder() - .retryConfig(retryConfig) - .build()); + return sdk.getTokenByPinId( request, - serverURL, - options); + serverURL); } } diff --git a/src/main/java/dev/plexapi/sdk/models/operations/GetTokenDetailsRequestBuilder.java b/src/main/java/dev/plexapi/sdk/models/operations/GetTokenDetailsRequestBuilder.java index b6686165..61fa32fb 100644 --- a/src/main/java/dev/plexapi/sdk/models/operations/GetTokenDetailsRequestBuilder.java +++ b/src/main/java/dev/plexapi/sdk/models/operations/GetTokenDetailsRequestBuilder.java @@ -4,8 +4,6 @@ package dev.plexapi.sdk.models.operations; -import dev.plexapi.sdk.utils.Options; -import dev.plexapi.sdk.utils.RetryConfig; import dev.plexapi.sdk.utils.Utils; import java.lang.String; import java.util.Optional; @@ -13,7 +11,6 @@ import java.util.Optional; public class GetTokenDetailsRequestBuilder { private Optional serverURL = Optional.empty(); - private Optional retryConfig = Optional.empty(); private final SDKMethodInterfaces.MethodCallGetTokenDetails sdk; public GetTokenDetailsRequestBuilder(SDKMethodInterfaces.MethodCallGetTokenDetails sdk) { @@ -31,25 +28,10 @@ public class GetTokenDetailsRequestBuilder { this.serverURL = serverURL; return this; } - - public GetTokenDetailsRequestBuilder retryConfig(RetryConfig retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = Optional.of(retryConfig); - return this; - } - - public GetTokenDetailsRequestBuilder retryConfig(Optional retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = retryConfig; - return this; - } public GetTokenDetailsResponse call() throws Exception { - Optional options = Optional.of(Options.builder() - .retryConfig(retryConfig) - .build()); + return sdk.getTokenDetails( - serverURL, - options); + serverURL); } } diff --git a/src/main/java/dev/plexapi/sdk/models/operations/GetTokenDetailsUserPlexAccount.java b/src/main/java/dev/plexapi/sdk/models/operations/GetTokenDetailsUserPlexAccount.java index a9960e23..150e01d4 100644 --- a/src/main/java/dev/plexapi/sdk/models/operations/GetTokenDetailsUserPlexAccount.java +++ b/src/main/java/dev/plexapi/sdk/models/operations/GetTokenDetailsUserPlexAccount.java @@ -20,7 +20,6 @@ import java.lang.Long; import java.lang.Override; import java.lang.String; import java.lang.SuppressWarnings; -import java.time.OffsetDateTime; import java.util.List; import java.util.Objects; import java.util.Optional; @@ -39,19 +38,13 @@ public class GetTokenDetailsUserPlexAccount { @JsonProperty("adsConsent") private Optional adsConsent; - /** - * Unknown - */ @JsonInclude(Include.ALWAYS) @JsonProperty("adsConsentReminderAt") - private Optional adsConsentReminderAt; + private Optional adsConsentReminderAt; - /** - * Unknown - */ @JsonInclude(Include.ALWAYS) @JsonProperty("adsConsentSetAt") - private Optional adsConsentSetAt; + private Optional adsConsentSetAt; /** * Unknown @@ -292,8 +285,8 @@ public class GetTokenDetailsUserPlexAccount { @JsonCreator public GetTokenDetailsUserPlexAccount( @JsonProperty("adsConsent") Optional adsConsent, - @JsonProperty("adsConsentReminderAt") Optional adsConsentReminderAt, - @JsonProperty("adsConsentSetAt") Optional adsConsentSetAt, + @JsonProperty("adsConsentReminderAt") Optional adsConsentReminderAt, + @JsonProperty("adsConsentSetAt") Optional adsConsentSetAt, @JsonProperty("anonymous") JsonNullable anonymous, @JsonProperty("authToken") String authToken, @JsonProperty("backupCodesCreated") Optional backupCodesCreated, @@ -448,19 +441,13 @@ public class GetTokenDetailsUserPlexAccount { return adsConsent; } - /** - * Unknown - */ @JsonIgnore - public Optional adsConsentReminderAt() { + public Optional adsConsentReminderAt() { return adsConsentReminderAt; } - /** - * Unknown - */ @JsonIgnore - public Optional adsConsentSetAt() { + public Optional adsConsentSetAt() { return adsConsentSetAt; } @@ -781,37 +768,25 @@ public class GetTokenDetailsUserPlexAccount { return this; } - /** - * Unknown - */ - public GetTokenDetailsUserPlexAccount withAdsConsentReminderAt(OffsetDateTime adsConsentReminderAt) { + public GetTokenDetailsUserPlexAccount withAdsConsentReminderAt(long adsConsentReminderAt) { Utils.checkNotNull(adsConsentReminderAt, "adsConsentReminderAt"); this.adsConsentReminderAt = Optional.ofNullable(adsConsentReminderAt); return this; } - /** - * Unknown - */ - public GetTokenDetailsUserPlexAccount withAdsConsentReminderAt(Optional adsConsentReminderAt) { + public GetTokenDetailsUserPlexAccount withAdsConsentReminderAt(Optional adsConsentReminderAt) { Utils.checkNotNull(adsConsentReminderAt, "adsConsentReminderAt"); this.adsConsentReminderAt = adsConsentReminderAt; return this; } - /** - * Unknown - */ - public GetTokenDetailsUserPlexAccount withAdsConsentSetAt(OffsetDateTime adsConsentSetAt) { + public GetTokenDetailsUserPlexAccount withAdsConsentSetAt(long adsConsentSetAt) { Utils.checkNotNull(adsConsentSetAt, "adsConsentSetAt"); this.adsConsentSetAt = Optional.ofNullable(adsConsentSetAt); return this; } - /** - * Unknown - */ - public GetTokenDetailsUserPlexAccount withAdsConsentSetAt(Optional adsConsentSetAt) { + public GetTokenDetailsUserPlexAccount withAdsConsentSetAt(Optional adsConsentSetAt) { Utils.checkNotNull(adsConsentSetAt, "adsConsentSetAt"); this.adsConsentSetAt = adsConsentSetAt; return this; @@ -1459,9 +1434,9 @@ public class GetTokenDetailsUserPlexAccount { private Optional adsConsent = Optional.empty(); - private Optional adsConsentReminderAt = Optional.empty(); + private Optional adsConsentReminderAt = Optional.empty(); - private Optional adsConsentSetAt = Optional.empty(); + private Optional adsConsentSetAt = Optional.empty(); private JsonNullable anonymous; @@ -1562,37 +1537,25 @@ public class GetTokenDetailsUserPlexAccount { return this; } - /** - * Unknown - */ - public Builder adsConsentReminderAt(OffsetDateTime adsConsentReminderAt) { + public Builder adsConsentReminderAt(long adsConsentReminderAt) { Utils.checkNotNull(adsConsentReminderAt, "adsConsentReminderAt"); this.adsConsentReminderAt = Optional.ofNullable(adsConsentReminderAt); return this; } - /** - * Unknown - */ - public Builder adsConsentReminderAt(Optional adsConsentReminderAt) { + public Builder adsConsentReminderAt(Optional adsConsentReminderAt) { Utils.checkNotNull(adsConsentReminderAt, "adsConsentReminderAt"); this.adsConsentReminderAt = adsConsentReminderAt; return this; } - /** - * Unknown - */ - public Builder adsConsentSetAt(OffsetDateTime adsConsentSetAt) { + public Builder adsConsentSetAt(long adsConsentSetAt) { Utils.checkNotNull(adsConsentSetAt, "adsConsentSetAt"); this.adsConsentSetAt = Optional.ofNullable(adsConsentSetAt); return this; } - /** - * Unknown - */ - public Builder adsConsentSetAt(Optional adsConsentSetAt) { + public Builder adsConsentSetAt(Optional adsConsentSetAt) { Utils.checkNotNull(adsConsentSetAt, "adsConsentSetAt"); this.adsConsentSetAt = adsConsentSetAt; return this; diff --git a/src/main/java/dev/plexapi/sdk/models/operations/GetTopWatchedContentRequestBuilder.java b/src/main/java/dev/plexapi/sdk/models/operations/GetTopWatchedContentRequestBuilder.java index 44ffe0cb..6ee3ac7a 100644 --- a/src/main/java/dev/plexapi/sdk/models/operations/GetTopWatchedContentRequestBuilder.java +++ b/src/main/java/dev/plexapi/sdk/models/operations/GetTopWatchedContentRequestBuilder.java @@ -4,8 +4,6 @@ package dev.plexapi.sdk.models.operations; -import dev.plexapi.sdk.utils.Options; -import dev.plexapi.sdk.utils.RetryConfig; import dev.plexapi.sdk.utils.Utils; import java.lang.Long; import java.util.Optional; @@ -14,7 +12,6 @@ public class GetTopWatchedContentRequestBuilder { private Optional includeGuids = Optional.empty(); private GetTopWatchedContentQueryParamType type; - private Optional retryConfig = Optional.empty(); private final SDKMethodInterfaces.MethodCallGetTopWatchedContent sdk; public GetTopWatchedContentRequestBuilder(SDKMethodInterfaces.MethodCallGetTopWatchedContent sdk) { @@ -38,26 +35,11 @@ public class GetTopWatchedContentRequestBuilder { this.type = type; return this; } - - public GetTopWatchedContentRequestBuilder retryConfig(RetryConfig retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = Optional.of(retryConfig); - return this; - } - - public GetTopWatchedContentRequestBuilder retryConfig(Optional retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = retryConfig; - return this; - } public GetTopWatchedContentResponse call() throws Exception { - Optional options = Optional.of(Options.builder() - .retryConfig(retryConfig) - .build()); + return sdk.getTopWatchedContent( includeGuids, - type, - options); + type); } } diff --git a/src/main/java/dev/plexapi/sdk/models/operations/GetTranscodeSessionsRequestBuilder.java b/src/main/java/dev/plexapi/sdk/models/operations/GetTranscodeSessionsRequestBuilder.java index 105c709a..46531ad8 100644 --- a/src/main/java/dev/plexapi/sdk/models/operations/GetTranscodeSessionsRequestBuilder.java +++ b/src/main/java/dev/plexapi/sdk/models/operations/GetTranscodeSessionsRequestBuilder.java @@ -4,37 +4,17 @@ package dev.plexapi.sdk.models.operations; -import dev.plexapi.sdk.utils.Options; -import dev.plexapi.sdk.utils.RetryConfig; -import dev.plexapi.sdk.utils.Utils; -import java.util.Optional; public class GetTranscodeSessionsRequestBuilder { - private Optional retryConfig = Optional.empty(); private final SDKMethodInterfaces.MethodCallGetTranscodeSessions sdk; public GetTranscodeSessionsRequestBuilder(SDKMethodInterfaces.MethodCallGetTranscodeSessions sdk) { this.sdk = sdk; } - - public GetTranscodeSessionsRequestBuilder retryConfig(RetryConfig retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = Optional.of(retryConfig); - return this; - } - - public GetTranscodeSessionsRequestBuilder retryConfig(Optional retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = retryConfig; - return this; - } public GetTranscodeSessionsResponse call() throws Exception { - Optional options = Optional.of(Options.builder() - .retryConfig(retryConfig) - .build()); - return sdk.getTranscodeSessions( - options); + + return sdk.getTranscodeSessionsDirect(); } } diff --git a/src/main/java/dev/plexapi/sdk/models/operations/GetTransientTokenRequestBuilder.java b/src/main/java/dev/plexapi/sdk/models/operations/GetTransientTokenRequestBuilder.java index 8f2dc03d..ad320b7d 100644 --- a/src/main/java/dev/plexapi/sdk/models/operations/GetTransientTokenRequestBuilder.java +++ b/src/main/java/dev/plexapi/sdk/models/operations/GetTransientTokenRequestBuilder.java @@ -4,16 +4,12 @@ package dev.plexapi.sdk.models.operations; -import dev.plexapi.sdk.utils.Options; -import dev.plexapi.sdk.utils.RetryConfig; import dev.plexapi.sdk.utils.Utils; -import java.util.Optional; public class GetTransientTokenRequestBuilder { private GetTransientTokenQueryParamType type; private Scope scope; - private Optional retryConfig = Optional.empty(); private final SDKMethodInterfaces.MethodCallGetTransientToken sdk; public GetTransientTokenRequestBuilder(SDKMethodInterfaces.MethodCallGetTransientToken sdk) { @@ -31,26 +27,11 @@ public class GetTransientTokenRequestBuilder { this.scope = scope; return this; } - - public GetTransientTokenRequestBuilder retryConfig(RetryConfig retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = Optional.of(retryConfig); - return this; - } - - public GetTransientTokenRequestBuilder retryConfig(Optional retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = retryConfig; - return this; - } public GetTransientTokenResponse call() throws Exception { - Optional options = Optional.of(Options.builder() - .retryConfig(retryConfig) - .build()); + return sdk.getTransientToken( type, - scope, - options); + scope); } } diff --git a/src/main/java/dev/plexapi/sdk/models/operations/GetUpdateStatusRequestBuilder.java b/src/main/java/dev/plexapi/sdk/models/operations/GetUpdateStatusRequestBuilder.java index 59a1a583..9ec2fffa 100644 --- a/src/main/java/dev/plexapi/sdk/models/operations/GetUpdateStatusRequestBuilder.java +++ b/src/main/java/dev/plexapi/sdk/models/operations/GetUpdateStatusRequestBuilder.java @@ -4,37 +4,17 @@ package dev.plexapi.sdk.models.operations; -import dev.plexapi.sdk.utils.Options; -import dev.plexapi.sdk.utils.RetryConfig; -import dev.plexapi.sdk.utils.Utils; -import java.util.Optional; public class GetUpdateStatusRequestBuilder { - private Optional retryConfig = Optional.empty(); private final SDKMethodInterfaces.MethodCallGetUpdateStatus sdk; public GetUpdateStatusRequestBuilder(SDKMethodInterfaces.MethodCallGetUpdateStatus sdk) { this.sdk = sdk; } - - public GetUpdateStatusRequestBuilder retryConfig(RetryConfig retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = Optional.of(retryConfig); - return this; - } - - public GetUpdateStatusRequestBuilder retryConfig(Optional retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = retryConfig; - return this; - } public GetUpdateStatusResponse call() throws Exception { - Optional options = Optional.of(Options.builder() - .retryConfig(retryConfig) - .build()); - return sdk.getUpdateStatus( - options); + + return sdk.getUpdateStatusDirect(); } } diff --git a/src/main/java/dev/plexapi/sdk/models/operations/GetUserFriendsRequestBuilder.java b/src/main/java/dev/plexapi/sdk/models/operations/GetUserFriendsRequestBuilder.java index 353162fe..5a6c3c26 100644 --- a/src/main/java/dev/plexapi/sdk/models/operations/GetUserFriendsRequestBuilder.java +++ b/src/main/java/dev/plexapi/sdk/models/operations/GetUserFriendsRequestBuilder.java @@ -4,8 +4,6 @@ package dev.plexapi.sdk.models.operations; -import dev.plexapi.sdk.utils.Options; -import dev.plexapi.sdk.utils.RetryConfig; import dev.plexapi.sdk.utils.Utils; import java.lang.String; import java.util.Optional; @@ -13,7 +11,6 @@ import java.util.Optional; public class GetUserFriendsRequestBuilder { private Optional serverURL = Optional.empty(); - private Optional retryConfig = Optional.empty(); private final SDKMethodInterfaces.MethodCallGetUserFriends sdk; public GetUserFriendsRequestBuilder(SDKMethodInterfaces.MethodCallGetUserFriends sdk) { @@ -31,25 +28,10 @@ public class GetUserFriendsRequestBuilder { this.serverURL = serverURL; return this; } - - public GetUserFriendsRequestBuilder retryConfig(RetryConfig retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = Optional.of(retryConfig); - return this; - } - - public GetUserFriendsRequestBuilder retryConfig(Optional retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = retryConfig; - return this; - } public GetUserFriendsResponse call() throws Exception { - Optional options = Optional.of(Options.builder() - .retryConfig(retryConfig) - .build()); + return sdk.getUserFriends( - serverURL, - options); + serverURL); } } diff --git a/src/main/java/dev/plexapi/sdk/models/operations/GetWatchListRequestBuilder.java b/src/main/java/dev/plexapi/sdk/models/operations/GetWatchListRequestBuilder.java index 4c7cef5e..96dc4189 100644 --- a/src/main/java/dev/plexapi/sdk/models/operations/GetWatchListRequestBuilder.java +++ b/src/main/java/dev/plexapi/sdk/models/operations/GetWatchListRequestBuilder.java @@ -4,8 +4,6 @@ package dev.plexapi.sdk.models.operations; -import dev.plexapi.sdk.utils.Options; -import dev.plexapi.sdk.utils.RetryConfig; import dev.plexapi.sdk.utils.Utils; import java.lang.String; import java.util.Optional; @@ -14,7 +12,6 @@ public class GetWatchListRequestBuilder { private GetWatchListRequest request; private Optional serverURL = Optional.empty(); - private Optional retryConfig = Optional.empty(); private final SDKMethodInterfaces.MethodCallGetWatchList sdk; public GetWatchListRequestBuilder(SDKMethodInterfaces.MethodCallGetWatchList sdk) { @@ -38,26 +35,11 @@ public class GetWatchListRequestBuilder { this.serverURL = serverURL; return this; } - - public GetWatchListRequestBuilder retryConfig(RetryConfig retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = Optional.of(retryConfig); - return this; - } - - public GetWatchListRequestBuilder retryConfig(Optional retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = retryConfig; - return this; - } public GetWatchListResponse call() throws Exception { - Optional options = Optional.of(Options.builder() - .retryConfig(retryConfig) - .build()); + return sdk.getWatchList( request, - serverURL, - options); + serverURL); } } diff --git a/src/main/java/dev/plexapi/sdk/models/operations/LogLineRequestBuilder.java b/src/main/java/dev/plexapi/sdk/models/operations/LogLineRequestBuilder.java index de4b8116..01fa9fc3 100644 --- a/src/main/java/dev/plexapi/sdk/models/operations/LogLineRequestBuilder.java +++ b/src/main/java/dev/plexapi/sdk/models/operations/LogLineRequestBuilder.java @@ -4,18 +4,14 @@ package dev.plexapi.sdk.models.operations; -import dev.plexapi.sdk.utils.Options; -import dev.plexapi.sdk.utils.RetryConfig; import dev.plexapi.sdk.utils.Utils; import java.lang.String; -import java.util.Optional; public class LogLineRequestBuilder { private Level level; private String message; private String source; - private Optional retryConfig = Optional.empty(); private final SDKMethodInterfaces.MethodCallLogLine sdk; public LogLineRequestBuilder(SDKMethodInterfaces.MethodCallLogLine sdk) { @@ -39,27 +35,12 @@ public class LogLineRequestBuilder { this.source = source; return this; } - - public LogLineRequestBuilder retryConfig(RetryConfig retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = Optional.of(retryConfig); - return this; - } - - public LogLineRequestBuilder retryConfig(Optional retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = retryConfig; - return this; - } public LogLineResponse call() throws Exception { - Optional options = Optional.of(Options.builder() - .retryConfig(retryConfig) - .build()); + return sdk.logLine( level, message, - source, - options); + source); } } diff --git a/src/main/java/dev/plexapi/sdk/models/operations/LogMultiLineRequestBuilder.java b/src/main/java/dev/plexapi/sdk/models/operations/LogMultiLineRequestBuilder.java index 09c017dc..222c736b 100644 --- a/src/main/java/dev/plexapi/sdk/models/operations/LogMultiLineRequestBuilder.java +++ b/src/main/java/dev/plexapi/sdk/models/operations/LogMultiLineRequestBuilder.java @@ -4,16 +4,12 @@ package dev.plexapi.sdk.models.operations; -import dev.plexapi.sdk.utils.Options; -import dev.plexapi.sdk.utils.RetryConfig; import dev.plexapi.sdk.utils.Utils; import java.lang.String; -import java.util.Optional; public class LogMultiLineRequestBuilder { private String request; - private Optional retryConfig = Optional.empty(); private final SDKMethodInterfaces.MethodCallLogMultiLine sdk; public LogMultiLineRequestBuilder(SDKMethodInterfaces.MethodCallLogMultiLine sdk) { @@ -25,25 +21,10 @@ public class LogMultiLineRequestBuilder { this.request = request; return this; } - - public LogMultiLineRequestBuilder retryConfig(RetryConfig retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = Optional.of(retryConfig); - return this; - } - - public LogMultiLineRequestBuilder retryConfig(Optional retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = retryConfig; - return this; - } public LogMultiLineResponse call() throws Exception { - Optional options = Optional.of(Options.builder() - .retryConfig(retryConfig) - .build()); + return sdk.logMultiLine( - request, - options); + request); } } diff --git a/src/main/java/dev/plexapi/sdk/models/operations/MarkPlayedRequestBuilder.java b/src/main/java/dev/plexapi/sdk/models/operations/MarkPlayedRequestBuilder.java index 12162ee6..b8930877 100644 --- a/src/main/java/dev/plexapi/sdk/models/operations/MarkPlayedRequestBuilder.java +++ b/src/main/java/dev/plexapi/sdk/models/operations/MarkPlayedRequestBuilder.java @@ -4,16 +4,12 @@ package dev.plexapi.sdk.models.operations; -import dev.plexapi.sdk.utils.Options; -import dev.plexapi.sdk.utils.RetryConfig; import dev.plexapi.sdk.utils.Utils; import java.lang.Double; -import java.util.Optional; public class MarkPlayedRequestBuilder { private Double key; - private Optional retryConfig = Optional.empty(); private final SDKMethodInterfaces.MethodCallMarkPlayed sdk; public MarkPlayedRequestBuilder(SDKMethodInterfaces.MethodCallMarkPlayed sdk) { @@ -25,25 +21,10 @@ public class MarkPlayedRequestBuilder { this.key = key; return this; } - - public MarkPlayedRequestBuilder retryConfig(RetryConfig retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = Optional.of(retryConfig); - return this; - } - - public MarkPlayedRequestBuilder retryConfig(Optional retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = retryConfig; - return this; - } public MarkPlayedResponse call() throws Exception { - Optional options = Optional.of(Options.builder() - .retryConfig(retryConfig) - .build()); + return sdk.markPlayed( - key, - options); + key); } } diff --git a/src/main/java/dev/plexapi/sdk/models/operations/MarkUnplayedRequestBuilder.java b/src/main/java/dev/plexapi/sdk/models/operations/MarkUnplayedRequestBuilder.java index a4736f82..588bcb9b 100644 --- a/src/main/java/dev/plexapi/sdk/models/operations/MarkUnplayedRequestBuilder.java +++ b/src/main/java/dev/plexapi/sdk/models/operations/MarkUnplayedRequestBuilder.java @@ -4,16 +4,12 @@ package dev.plexapi.sdk.models.operations; -import dev.plexapi.sdk.utils.Options; -import dev.plexapi.sdk.utils.RetryConfig; import dev.plexapi.sdk.utils.Utils; import java.lang.Double; -import java.util.Optional; public class MarkUnplayedRequestBuilder { private Double key; - private Optional retryConfig = Optional.empty(); private final SDKMethodInterfaces.MethodCallMarkUnplayed sdk; public MarkUnplayedRequestBuilder(SDKMethodInterfaces.MethodCallMarkUnplayed sdk) { @@ -25,25 +21,10 @@ public class MarkUnplayedRequestBuilder { this.key = key; return this; } - - public MarkUnplayedRequestBuilder retryConfig(RetryConfig retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = Optional.of(retryConfig); - return this; - } - - public MarkUnplayedRequestBuilder retryConfig(Optional retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = retryConfig; - return this; - } public MarkUnplayedResponse call() throws Exception { - Optional options = Optional.of(Options.builder() - .retryConfig(retryConfig) - .build()); + return sdk.markUnplayed( - key, - options); + key); } } diff --git a/src/main/java/dev/plexapi/sdk/models/operations/PerformSearchRequestBuilder.java b/src/main/java/dev/plexapi/sdk/models/operations/PerformSearchRequestBuilder.java index a684cf5a..942bc359 100644 --- a/src/main/java/dev/plexapi/sdk/models/operations/PerformSearchRequestBuilder.java +++ b/src/main/java/dev/plexapi/sdk/models/operations/PerformSearchRequestBuilder.java @@ -6,8 +6,6 @@ package dev.plexapi.sdk.models.operations; import com.fasterxml.jackson.core.type.TypeReference; import dev.plexapi.sdk.utils.LazySingletonValue; -import dev.plexapi.sdk.utils.Options; -import dev.plexapi.sdk.utils.RetryConfig; import dev.plexapi.sdk.utils.Utils; import java.lang.Double; import java.lang.String; @@ -21,7 +19,6 @@ public class PerformSearchRequestBuilder { "limit", "3", new TypeReference>() {}); - private Optional retryConfig = Optional.empty(); private final SDKMethodInterfaces.MethodCallPerformSearch sdk; public PerformSearchRequestBuilder(SDKMethodInterfaces.MethodCallPerformSearch sdk) { @@ -57,30 +54,15 @@ public class PerformSearchRequestBuilder { this.limit = limit; return this; } - - public PerformSearchRequestBuilder retryConfig(RetryConfig retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = Optional.of(retryConfig); - return this; - } - - public PerformSearchRequestBuilder retryConfig(Optional retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = retryConfig; - return this; - } public PerformSearchResponse call() throws Exception { if (limit == null) { limit = _SINGLETON_VALUE_Limit.value(); - } Optional options = Optional.of(Options.builder() - .retryConfig(retryConfig) - .build()); + } return sdk.performSearch( query, sectionId, - limit, - options); + limit); } private static final LazySingletonValue> _SINGLETON_VALUE_Limit = diff --git a/src/main/java/dev/plexapi/sdk/models/operations/PerformVoiceSearchRequestBuilder.java b/src/main/java/dev/plexapi/sdk/models/operations/PerformVoiceSearchRequestBuilder.java index e6c11ae4..05dd0cdc 100644 --- a/src/main/java/dev/plexapi/sdk/models/operations/PerformVoiceSearchRequestBuilder.java +++ b/src/main/java/dev/plexapi/sdk/models/operations/PerformVoiceSearchRequestBuilder.java @@ -6,8 +6,6 @@ package dev.plexapi.sdk.models.operations; import com.fasterxml.jackson.core.type.TypeReference; import dev.plexapi.sdk.utils.LazySingletonValue; -import dev.plexapi.sdk.utils.Options; -import dev.plexapi.sdk.utils.RetryConfig; import dev.plexapi.sdk.utils.Utils; import java.lang.Double; import java.lang.String; @@ -21,7 +19,6 @@ public class PerformVoiceSearchRequestBuilder { "limit", "3", new TypeReference>() {}); - private Optional retryConfig = Optional.empty(); private final SDKMethodInterfaces.MethodCallPerformVoiceSearch sdk; public PerformVoiceSearchRequestBuilder(SDKMethodInterfaces.MethodCallPerformVoiceSearch sdk) { @@ -57,30 +54,15 @@ public class PerformVoiceSearchRequestBuilder { this.limit = limit; return this; } - - public PerformVoiceSearchRequestBuilder retryConfig(RetryConfig retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = Optional.of(retryConfig); - return this; - } - - public PerformVoiceSearchRequestBuilder retryConfig(Optional retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = retryConfig; - return this; - } public PerformVoiceSearchResponse call() throws Exception { if (limit == null) { limit = _SINGLETON_VALUE_Limit.value(); - } Optional options = Optional.of(Options.builder() - .retryConfig(retryConfig) - .build()); + } return sdk.performVoiceSearch( query, sectionId, - limit, - options); + limit); } private static final LazySingletonValue> _SINGLETON_VALUE_Limit = diff --git a/src/main/java/dev/plexapi/sdk/models/operations/PostUsersSignInDataRequestBuilder.java b/src/main/java/dev/plexapi/sdk/models/operations/PostUsersSignInDataRequestBuilder.java index e9a37c50..3021fda5 100644 --- a/src/main/java/dev/plexapi/sdk/models/operations/PostUsersSignInDataRequestBuilder.java +++ b/src/main/java/dev/plexapi/sdk/models/operations/PostUsersSignInDataRequestBuilder.java @@ -4,8 +4,6 @@ package dev.plexapi.sdk.models.operations; -import dev.plexapi.sdk.utils.Options; -import dev.plexapi.sdk.utils.RetryConfig; import dev.plexapi.sdk.utils.Utils; import java.lang.String; import java.util.Optional; @@ -14,7 +12,6 @@ public class PostUsersSignInDataRequestBuilder { private PostUsersSignInDataRequest request; private Optional serverURL = Optional.empty(); - private Optional retryConfig = Optional.empty(); private final SDKMethodInterfaces.MethodCallPostUsersSignInData sdk; public PostUsersSignInDataRequestBuilder(SDKMethodInterfaces.MethodCallPostUsersSignInData sdk) { @@ -38,26 +35,11 @@ public class PostUsersSignInDataRequestBuilder { this.serverURL = serverURL; return this; } - - public PostUsersSignInDataRequestBuilder retryConfig(RetryConfig retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = Optional.of(retryConfig); - return this; - } - - public PostUsersSignInDataRequestBuilder retryConfig(Optional retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = retryConfig; - return this; - } public PostUsersSignInDataResponse call() throws Exception { - Optional options = Optional.of(Options.builder() - .retryConfig(retryConfig) - .build()); + return sdk.postUsersSignInData( request, - serverURL, - options); + serverURL); } } diff --git a/src/main/java/dev/plexapi/sdk/models/operations/PostUsersSignInDataUserPlexAccount.java b/src/main/java/dev/plexapi/sdk/models/operations/PostUsersSignInDataUserPlexAccount.java index c6bb7e6c..122c071e 100644 --- a/src/main/java/dev/plexapi/sdk/models/operations/PostUsersSignInDataUserPlexAccount.java +++ b/src/main/java/dev/plexapi/sdk/models/operations/PostUsersSignInDataUserPlexAccount.java @@ -20,7 +20,6 @@ import java.lang.Long; import java.lang.Override; import java.lang.String; import java.lang.SuppressWarnings; -import java.time.OffsetDateTime; import java.util.List; import java.util.Objects; import java.util.Optional; @@ -39,19 +38,13 @@ public class PostUsersSignInDataUserPlexAccount { @JsonProperty("adsConsent") private Optional adsConsent; - /** - * Unknown - */ @JsonInclude(Include.ALWAYS) @JsonProperty("adsConsentReminderAt") - private Optional adsConsentReminderAt; + private Optional adsConsentReminderAt; - /** - * Unknown - */ @JsonInclude(Include.ALWAYS) @JsonProperty("adsConsentSetAt") - private Optional adsConsentSetAt; + private Optional adsConsentSetAt; /** * Unknown @@ -298,8 +291,8 @@ public class PostUsersSignInDataUserPlexAccount { @JsonCreator public PostUsersSignInDataUserPlexAccount( @JsonProperty("adsConsent") Optional adsConsent, - @JsonProperty("adsConsentReminderAt") Optional adsConsentReminderAt, - @JsonProperty("adsConsentSetAt") Optional adsConsentSetAt, + @JsonProperty("adsConsentReminderAt") Optional adsConsentReminderAt, + @JsonProperty("adsConsentSetAt") Optional adsConsentSetAt, @JsonProperty("anonymous") JsonNullable anonymous, @JsonProperty("authToken") String authToken, @JsonProperty("backupCodesCreated") Optional backupCodesCreated, @@ -462,19 +455,13 @@ public class PostUsersSignInDataUserPlexAccount { return adsConsent; } - /** - * Unknown - */ @JsonIgnore - public Optional adsConsentReminderAt() { + public Optional adsConsentReminderAt() { return adsConsentReminderAt; } - /** - * Unknown - */ @JsonIgnore - public Optional adsConsentSetAt() { + public Optional adsConsentSetAt() { return adsConsentSetAt; } @@ -805,37 +792,25 @@ public class PostUsersSignInDataUserPlexAccount { return this; } - /** - * Unknown - */ - public PostUsersSignInDataUserPlexAccount withAdsConsentReminderAt(OffsetDateTime adsConsentReminderAt) { + public PostUsersSignInDataUserPlexAccount withAdsConsentReminderAt(long adsConsentReminderAt) { Utils.checkNotNull(adsConsentReminderAt, "adsConsentReminderAt"); this.adsConsentReminderAt = Optional.ofNullable(adsConsentReminderAt); return this; } - /** - * Unknown - */ - public PostUsersSignInDataUserPlexAccount withAdsConsentReminderAt(Optional adsConsentReminderAt) { + public PostUsersSignInDataUserPlexAccount withAdsConsentReminderAt(Optional adsConsentReminderAt) { Utils.checkNotNull(adsConsentReminderAt, "adsConsentReminderAt"); this.adsConsentReminderAt = adsConsentReminderAt; return this; } - /** - * Unknown - */ - public PostUsersSignInDataUserPlexAccount withAdsConsentSetAt(OffsetDateTime adsConsentSetAt) { + public PostUsersSignInDataUserPlexAccount withAdsConsentSetAt(long adsConsentSetAt) { Utils.checkNotNull(adsConsentSetAt, "adsConsentSetAt"); this.adsConsentSetAt = Optional.ofNullable(adsConsentSetAt); return this; } - /** - * Unknown - */ - public PostUsersSignInDataUserPlexAccount withAdsConsentSetAt(Optional adsConsentSetAt) { + public PostUsersSignInDataUserPlexAccount withAdsConsentSetAt(Optional adsConsentSetAt) { Utils.checkNotNull(adsConsentSetAt, "adsConsentSetAt"); this.adsConsentSetAt = adsConsentSetAt; return this; @@ -1501,9 +1476,9 @@ public class PostUsersSignInDataUserPlexAccount { private Optional adsConsent = Optional.empty(); - private Optional adsConsentReminderAt = Optional.empty(); + private Optional adsConsentReminderAt = Optional.empty(); - private Optional adsConsentSetAt = Optional.empty(); + private Optional adsConsentSetAt = Optional.empty(); private JsonNullable anonymous; @@ -1608,37 +1583,25 @@ public class PostUsersSignInDataUserPlexAccount { return this; } - /** - * Unknown - */ - public Builder adsConsentReminderAt(OffsetDateTime adsConsentReminderAt) { + public Builder adsConsentReminderAt(long adsConsentReminderAt) { Utils.checkNotNull(adsConsentReminderAt, "adsConsentReminderAt"); this.adsConsentReminderAt = Optional.ofNullable(adsConsentReminderAt); return this; } - /** - * Unknown - */ - public Builder adsConsentReminderAt(Optional adsConsentReminderAt) { + public Builder adsConsentReminderAt(Optional adsConsentReminderAt) { Utils.checkNotNull(adsConsentReminderAt, "adsConsentReminderAt"); this.adsConsentReminderAt = adsConsentReminderAt; return this; } - /** - * Unknown - */ - public Builder adsConsentSetAt(OffsetDateTime adsConsentSetAt) { + public Builder adsConsentSetAt(long adsConsentSetAt) { Utils.checkNotNull(adsConsentSetAt, "adsConsentSetAt"); this.adsConsentSetAt = Optional.ofNullable(adsConsentSetAt); return this; } - /** - * Unknown - */ - public Builder adsConsentSetAt(Optional adsConsentSetAt) { + public Builder adsConsentSetAt(Optional adsConsentSetAt) { Utils.checkNotNull(adsConsentSetAt, "adsConsentSetAt"); this.adsConsentSetAt = adsConsentSetAt; return this; diff --git a/src/main/java/dev/plexapi/sdk/models/operations/SDKMethodInterfaces.java b/src/main/java/dev/plexapi/sdk/models/operations/SDKMethodInterfaces.java index 1833cfe3..b33691c7 100644 --- a/src/main/java/dev/plexapi/sdk/models/operations/SDKMethodInterfaces.java +++ b/src/main/java/dev/plexapi/sdk/models/operations/SDKMethodInterfaces.java @@ -4,7 +4,6 @@ package dev.plexapi.sdk.models.operations; -import dev.plexapi.sdk.utils.Options; import java.lang.Double; import java.lang.Exception; import java.lang.Long; @@ -15,72 +14,61 @@ public class SDKMethodInterfaces { public interface MethodCallGetServerCapabilities { - GetServerCapabilitiesResponse getServerCapabilities( - Optional options) throws Exception; + GetServerCapabilitiesResponse getServerCapabilitiesDirect() throws Exception; } public interface MethodCallGetServerPreferences { - GetServerPreferencesResponse getServerPreferences( - Optional options) throws Exception; + GetServerPreferencesResponse getServerPreferencesDirect() throws Exception; } public interface MethodCallGetAvailableClients { - GetAvailableClientsResponse getAvailableClients( - Optional options) throws Exception; + GetAvailableClientsResponse getAvailableClientsDirect() throws Exception; } public interface MethodCallGetDevices { - GetDevicesResponse getDevices( - Optional options) throws Exception; + GetDevicesResponse getDevicesDirect() throws Exception; } public interface MethodCallGetServerIdentity { - GetServerIdentityResponse getServerIdentity( - Optional options) throws Exception; + GetServerIdentityResponse getServerIdentityDirect() throws Exception; } public interface MethodCallGetMyPlexAccount { - GetMyPlexAccountResponse getMyPlexAccount( - Optional options) throws Exception; + GetMyPlexAccountResponse getMyPlexAccountDirect() throws Exception; } public interface MethodCallGetResizedPhoto { GetResizedPhotoResponse getResizedPhoto( - GetResizedPhotoRequest request, - Optional options) throws Exception; + GetResizedPhotoRequest request) throws Exception; } public interface MethodCallGetMediaProviders { GetMediaProvidersResponse getMediaProviders( - String xPlexToken, - Optional options) throws Exception; + String xPlexToken) throws Exception; } public interface MethodCallGetServerList { - GetServerListResponse getServerList( - Optional options) throws Exception; + GetServerListResponse getServerListDirect() throws Exception; } public interface MethodCallMarkPlayed { MarkPlayedResponse markPlayed( - double key, - Optional options) throws Exception; + double key) throws Exception; } public interface MethodCallMarkUnplayed { MarkUnplayedResponse markUnplayed( - double key, - Optional options) throws Exception; + double key) throws Exception; } @@ -88,108 +76,92 @@ public class SDKMethodInterfaces { UpdatePlayProgressResponse updatePlayProgress( String key, double time, - String state, - Optional options) throws Exception; + String state) throws Exception; } public interface MethodCallGetBannerImage { GetBannerImageResponse getBannerImage( - GetBannerImageRequest request, - Optional options) throws Exception; + GetBannerImageRequest request) throws Exception; } public interface MethodCallGetThumbImage { GetThumbImageResponse getThumbImage( - GetThumbImageRequest request, - Optional options) throws Exception; + GetThumbImageRequest request) throws Exception; } public interface MethodCallGetTimeline { GetTimelineResponse getTimeline( - GetTimelineRequest request, - Optional options) throws Exception; + GetTimelineRequest request) throws Exception; } public interface MethodCallStartUniversalTranscode { StartUniversalTranscodeResponse startUniversalTranscode( - StartUniversalTranscodeRequest request, - Optional options) throws Exception; + StartUniversalTranscodeRequest request) throws Exception; } public interface MethodCallGetServerActivities { - GetServerActivitiesResponse getServerActivities( - Optional options) throws Exception; + GetServerActivitiesResponse getServerActivitiesDirect() throws Exception; } public interface MethodCallCancelServerActivities { CancelServerActivitiesResponse cancelServerActivities( - String activityUUID, - Optional options) throws Exception; + String activityUUID) throws Exception; } public interface MethodCallGetButlerTasks { - GetButlerTasksResponse getButlerTasks( - Optional options) throws Exception; + GetButlerTasksResponse getButlerTasksDirect() throws Exception; } public interface MethodCallStartAllTasks { - StartAllTasksResponse startAllTasks( - Optional options) throws Exception; + StartAllTasksResponse startAllTasksDirect() throws Exception; } public interface MethodCallStopAllTasks { - StopAllTasksResponse stopAllTasks( - Optional options) throws Exception; + StopAllTasksResponse stopAllTasksDirect() throws Exception; } public interface MethodCallStartTask { StartTaskResponse startTask( - TaskName taskName, - Optional options) throws Exception; + TaskName taskName) throws Exception; } public interface MethodCallStopTask { StopTaskResponse stopTask( - PathParamTaskName taskName, - Optional options) throws Exception; + PathParamTaskName taskName) throws Exception; } public interface MethodCallGetCompanionsData { GetCompanionsDataResponse getCompanionsData( - Optional serverURL, - Optional options) throws Exception; + Optional serverURL) throws Exception; } public interface MethodCallGetUserFriends { GetUserFriendsResponse getUserFriends( - Optional serverURL, - Optional options) throws Exception; + Optional serverURL) throws Exception; } public interface MethodCallGetGeoData { GetGeoDataResponse getGeoData( - Optional serverURL, - Optional options) throws Exception; + Optional serverURL) throws Exception; } public interface MethodCallGetHomeData { - GetHomeDataResponse getHomeData( - Optional options) throws Exception; + GetHomeDataResponse getHomeDataDirect() throws Exception; } @@ -199,39 +171,34 @@ public class SDKMethodInterfaces { Optional includeRelay, Optional includeIPv6, Optional clientID, - Optional serverURL, - Optional options) throws Exception; + Optional serverURL) throws Exception; } public interface MethodCallGetPin { GetPinResponse getPin( GetPinRequest request, - Optional serverURL, - Optional options) throws Exception; + Optional serverURL) throws Exception; } public interface MethodCallGetTokenByPinId { GetTokenByPinIdResponse getTokenByPinId( GetTokenByPinIdRequest request, - Optional serverURL, - Optional options) throws Exception; + Optional serverURL) throws Exception; } public interface MethodCallGetGlobalHubs { GetGlobalHubsResponse getGlobalHubs( Optional count, - Optional onlyTransient, - Optional options) throws Exception; + Optional onlyTransient) throws Exception; } public interface MethodCallGetRecentlyAdded { GetRecentlyAddedResponse getRecentlyAdded( - GetRecentlyAddedRequest request, - Optional options) throws Exception; + GetRecentlyAddedRequest request) throws Exception; } @@ -239,8 +206,7 @@ public class SDKMethodInterfaces { GetLibraryHubsResponse getLibraryHubs( double sectionId, Optional count, - Optional onlyTransient, - Optional options) throws Exception; + Optional onlyTransient) throws Exception; } @@ -248,8 +214,7 @@ public class SDKMethodInterfaces { PerformSearchResponse performSearch( String query, Optional sectionId, - Optional limit, - Optional options) throws Exception; + Optional limit) throws Exception; } @@ -257,118 +222,102 @@ public class SDKMethodInterfaces { PerformVoiceSearchResponse performVoiceSearch( String query, Optional sectionId, - Optional limit, - Optional options) throws Exception; + Optional limit) throws Exception; } public interface MethodCallGetSearchResults { GetSearchResultsResponse getSearchResults( - String query, - Optional options) throws Exception; + String query) throws Exception; } public interface MethodCallGetFileHash { GetFileHashResponse getFileHash( String url, - Optional type, - Optional options) throws Exception; + Optional type) throws Exception; } public interface MethodCallGetRecentlyAddedLibrary { GetRecentlyAddedLibraryResponse getRecentlyAddedLibrary( - GetRecentlyAddedLibraryRequest request, - Optional options) throws Exception; + GetRecentlyAddedLibraryRequest request) throws Exception; } public interface MethodCallGetAllLibraries { - GetAllLibrariesResponse getAllLibraries( - Optional options) throws Exception; + GetAllLibrariesResponse getAllLibrariesDirect() throws Exception; } public interface MethodCallGetLibraryDetails { GetLibraryDetailsResponse getLibraryDetails( Optional includeDetails, - int sectionKey, - Optional options) throws Exception; + int sectionKey) throws Exception; } public interface MethodCallDeleteLibrary { DeleteLibraryResponse deleteLibrary( - int sectionKey, - Optional options) throws Exception; + int sectionKey) throws Exception; } public interface MethodCallGetLibraryItems { GetLibraryItemsResponse getLibraryItems( - GetLibraryItemsRequest request, - Optional options) throws Exception; + GetLibraryItemsRequest request) throws Exception; } public interface MethodCallGetRefreshLibraryMetadata { GetRefreshLibraryMetadataResponse getRefreshLibraryMetadata( Optional force, - int sectionKey, - Optional options) throws Exception; + int sectionKey) throws Exception; } public interface MethodCallGetSearchLibrary { GetSearchLibraryResponse getSearchLibrary( int sectionKey, - GetSearchLibraryQueryParamType type, - Optional options) throws Exception; + GetSearchLibraryQueryParamType type) throws Exception; } public interface MethodCallGetSearchAllLibraries { GetSearchAllLibrariesResponse getSearchAllLibraries( - GetSearchAllLibrariesRequest request, - Optional options) throws Exception; + GetSearchAllLibrariesRequest request) throws Exception; } public interface MethodCallGetMetaDataByRatingKey { GetMetaDataByRatingKeyResponse getMetaDataByRatingKey( - long ratingKey, - Optional options) throws Exception; + long ratingKey) throws Exception; } public interface MethodCallGetMetadataChildren { GetMetadataChildrenResponse getMetadataChildren( double ratingKey, - Optional includeElements, - Optional options) throws Exception; + Optional includeElements) throws Exception; } public interface MethodCallGetTopWatchedContent { GetTopWatchedContentResponse getTopWatchedContent( Optional includeGuids, - GetTopWatchedContentQueryParamType type, - Optional options) throws Exception; + GetTopWatchedContentQueryParamType type) throws Exception; } public interface MethodCallGetOnDeck { - GetOnDeckResponse getOnDeck( - Optional options) throws Exception; + GetOnDeckResponse getOnDeckDirect() throws Exception; } public interface MethodCallGetWatchList { GetWatchListResponse getWatchList( GetWatchListRequest request, - Optional serverURL, - Optional options) throws Exception; + Optional serverURL) throws Exception; } @@ -376,50 +325,43 @@ public class SDKMethodInterfaces { LogLineResponse logLine( Level level, String message, - String source, - Optional options) throws Exception; + String source) throws Exception; } public interface MethodCallLogMultiLine { LogMultiLineResponse logMultiLine( - String request, - Optional options) throws Exception; + String request) throws Exception; } public interface MethodCallEnablePaperTrail { - EnablePaperTrailResponse enablePaperTrail( - Optional options) throws Exception; + EnablePaperTrailResponse enablePaperTrailDirect() throws Exception; } public interface MethodCallCreatePlaylist { CreatePlaylistResponse createPlaylist( - CreatePlaylistRequest request, - Optional options) throws Exception; + CreatePlaylistRequest request) throws Exception; } public interface MethodCallGetPlaylists { GetPlaylistsResponse getPlaylists( Optional playlistType, - Optional smart, - Optional options) throws Exception; + Optional smart) throws Exception; } public interface MethodCallGetPlaylist { GetPlaylistResponse getPlaylist( - double playlistID, - Optional options) throws Exception; + double playlistID) throws Exception; } public interface MethodCallDeletePlaylist { DeletePlaylistResponse deletePlaylist( - double playlistID, - Optional options) throws Exception; + double playlistID) throws Exception; } @@ -427,23 +369,20 @@ public class SDKMethodInterfaces { UpdatePlaylistResponse updatePlaylist( double playlistID, Optional title, - Optional summary, - Optional options) throws Exception; + Optional summary) throws Exception; } public interface MethodCallGetPlaylistContents { GetPlaylistContentsResponse getPlaylistContents( double playlistID, - GetPlaylistContentsQueryParamType type, - Optional options) throws Exception; + GetPlaylistContentsQueryParamType type) throws Exception; } public interface MethodCallClearPlaylistContents { ClearPlaylistContentsResponse clearPlaylistContents( - double playlistID, - Optional options) throws Exception; + double playlistID) throws Exception; } @@ -451,8 +390,7 @@ public class SDKMethodInterfaces { AddPlaylistContentsResponse addPlaylistContents( double playlistID, String uri, - Optional playQueueID, - Optional options) throws Exception; + Optional playQueueID) throws Exception; } @@ -460,65 +398,56 @@ public class SDKMethodInterfaces { UploadPlaylistResponse uploadPlaylist( String path, QueryParamForce force, - long sectionID, - Optional options) throws Exception; + long sectionID) throws Exception; } public interface MethodCallGetTransientToken { GetTransientTokenResponse getTransientToken( GetTransientTokenQueryParamType type, - Scope scope, - Optional options) throws Exception; + Scope scope) throws Exception; } public interface MethodCallGetSourceConnectionInformation { GetSourceConnectionInformationResponse getSourceConnectionInformation( - String source, - Optional options) throws Exception; + String source) throws Exception; } public interface MethodCallGetTokenDetails { GetTokenDetailsResponse getTokenDetails( - Optional serverURL, - Optional options) throws Exception; + Optional serverURL) throws Exception; } public interface MethodCallPostUsersSignInData { PostUsersSignInDataResponse postUsersSignInData( PostUsersSignInDataRequest request, - Optional serverURL, - Optional options) throws Exception; + Optional serverURL) throws Exception; } public interface MethodCallGetStatistics { GetStatisticsResponse getStatistics( - Optional timespan, - Optional options) throws Exception; + Optional timespan) throws Exception; } public interface MethodCallGetResourcesStatistics { GetResourcesStatisticsResponse getResourcesStatistics( - Optional timespan, - Optional options) throws Exception; + Optional timespan) throws Exception; } public interface MethodCallGetBandwidthStatistics { GetBandwidthStatisticsResponse getBandwidthStatistics( - Optional timespan, - Optional options) throws Exception; + Optional timespan) throws Exception; } public interface MethodCallGetSessions { - GetSessionsResponse getSessions( - Optional options) throws Exception; + GetSessionsResponse getSessionsDirect() throws Exception; } @@ -527,42 +456,36 @@ public class SDKMethodInterfaces { Optional sort, Optional accountId, Optional filter, - Optional librarySectionID, - Optional options) throws Exception; + Optional librarySectionID) throws Exception; } public interface MethodCallGetTranscodeSessions { - GetTranscodeSessionsResponse getTranscodeSessions( - Optional options) throws Exception; + GetTranscodeSessionsResponse getTranscodeSessionsDirect() throws Exception; } public interface MethodCallStopTranscodeSession { StopTranscodeSessionResponse stopTranscodeSession( - String sessionKey, - Optional options) throws Exception; + String sessionKey) throws Exception; } public interface MethodCallGetUpdateStatus { - GetUpdateStatusResponse getUpdateStatus( - Optional options) throws Exception; + GetUpdateStatusResponse getUpdateStatusDirect() throws Exception; } public interface MethodCallCheckForUpdates { CheckForUpdatesResponse checkForUpdates( - Optional download, - Optional options) throws Exception; + Optional download) throws Exception; } public interface MethodCallApplyUpdates { ApplyUpdatesResponse applyUpdates( Optional tonight, - Optional skip, - Optional options) throws Exception; + Optional skip) throws Exception; } diff --git a/src/main/java/dev/plexapi/sdk/models/operations/StartAllTasksRequestBuilder.java b/src/main/java/dev/plexapi/sdk/models/operations/StartAllTasksRequestBuilder.java index 3cd24123..966a0423 100644 --- a/src/main/java/dev/plexapi/sdk/models/operations/StartAllTasksRequestBuilder.java +++ b/src/main/java/dev/plexapi/sdk/models/operations/StartAllTasksRequestBuilder.java @@ -4,37 +4,17 @@ package dev.plexapi.sdk.models.operations; -import dev.plexapi.sdk.utils.Options; -import dev.plexapi.sdk.utils.RetryConfig; -import dev.plexapi.sdk.utils.Utils; -import java.util.Optional; public class StartAllTasksRequestBuilder { - private Optional retryConfig = Optional.empty(); private final SDKMethodInterfaces.MethodCallStartAllTasks sdk; public StartAllTasksRequestBuilder(SDKMethodInterfaces.MethodCallStartAllTasks sdk) { this.sdk = sdk; } - - public StartAllTasksRequestBuilder retryConfig(RetryConfig retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = Optional.of(retryConfig); - return this; - } - - public StartAllTasksRequestBuilder retryConfig(Optional retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = retryConfig; - return this; - } public StartAllTasksResponse call() throws Exception { - Optional options = Optional.of(Options.builder() - .retryConfig(retryConfig) - .build()); - return sdk.startAllTasks( - options); + + return sdk.startAllTasksDirect(); } } diff --git a/src/main/java/dev/plexapi/sdk/models/operations/StartTaskRequestBuilder.java b/src/main/java/dev/plexapi/sdk/models/operations/StartTaskRequestBuilder.java index 8a7fc72b..5d4c7e01 100644 --- a/src/main/java/dev/plexapi/sdk/models/operations/StartTaskRequestBuilder.java +++ b/src/main/java/dev/plexapi/sdk/models/operations/StartTaskRequestBuilder.java @@ -4,15 +4,11 @@ package dev.plexapi.sdk.models.operations; -import dev.plexapi.sdk.utils.Options; -import dev.plexapi.sdk.utils.RetryConfig; import dev.plexapi.sdk.utils.Utils; -import java.util.Optional; public class StartTaskRequestBuilder { private TaskName taskName; - private Optional retryConfig = Optional.empty(); private final SDKMethodInterfaces.MethodCallStartTask sdk; public StartTaskRequestBuilder(SDKMethodInterfaces.MethodCallStartTask sdk) { @@ -24,25 +20,10 @@ public class StartTaskRequestBuilder { this.taskName = taskName; return this; } - - public StartTaskRequestBuilder retryConfig(RetryConfig retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = Optional.of(retryConfig); - return this; - } - - public StartTaskRequestBuilder retryConfig(Optional retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = retryConfig; - return this; - } public StartTaskResponse call() throws Exception { - Optional options = Optional.of(Options.builder() - .retryConfig(retryConfig) - .build()); + return sdk.startTask( - taskName, - options); + taskName); } } diff --git a/src/main/java/dev/plexapi/sdk/models/operations/StartUniversalTranscodeRequestBuilder.java b/src/main/java/dev/plexapi/sdk/models/operations/StartUniversalTranscodeRequestBuilder.java index cd3ab7dc..dadcbc18 100644 --- a/src/main/java/dev/plexapi/sdk/models/operations/StartUniversalTranscodeRequestBuilder.java +++ b/src/main/java/dev/plexapi/sdk/models/operations/StartUniversalTranscodeRequestBuilder.java @@ -4,15 +4,11 @@ package dev.plexapi.sdk.models.operations; -import dev.plexapi.sdk.utils.Options; -import dev.plexapi.sdk.utils.RetryConfig; import dev.plexapi.sdk.utils.Utils; -import java.util.Optional; public class StartUniversalTranscodeRequestBuilder { private StartUniversalTranscodeRequest request; - private Optional retryConfig = Optional.empty(); private final SDKMethodInterfaces.MethodCallStartUniversalTranscode sdk; public StartUniversalTranscodeRequestBuilder(SDKMethodInterfaces.MethodCallStartUniversalTranscode sdk) { @@ -24,25 +20,10 @@ public class StartUniversalTranscodeRequestBuilder { this.request = request; return this; } - - public StartUniversalTranscodeRequestBuilder retryConfig(RetryConfig retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = Optional.of(retryConfig); - return this; - } - - public StartUniversalTranscodeRequestBuilder retryConfig(Optional retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = retryConfig; - return this; - } public StartUniversalTranscodeResponse call() throws Exception { - Optional options = Optional.of(Options.builder() - .retryConfig(retryConfig) - .build()); + return sdk.startUniversalTranscode( - request, - options); + request); } } diff --git a/src/main/java/dev/plexapi/sdk/models/operations/StopAllTasksRequestBuilder.java b/src/main/java/dev/plexapi/sdk/models/operations/StopAllTasksRequestBuilder.java index d88cae08..f31e3f2d 100644 --- a/src/main/java/dev/plexapi/sdk/models/operations/StopAllTasksRequestBuilder.java +++ b/src/main/java/dev/plexapi/sdk/models/operations/StopAllTasksRequestBuilder.java @@ -4,37 +4,17 @@ package dev.plexapi.sdk.models.operations; -import dev.plexapi.sdk.utils.Options; -import dev.plexapi.sdk.utils.RetryConfig; -import dev.plexapi.sdk.utils.Utils; -import java.util.Optional; public class StopAllTasksRequestBuilder { - private Optional retryConfig = Optional.empty(); private final SDKMethodInterfaces.MethodCallStopAllTasks sdk; public StopAllTasksRequestBuilder(SDKMethodInterfaces.MethodCallStopAllTasks sdk) { this.sdk = sdk; } - - public StopAllTasksRequestBuilder retryConfig(RetryConfig retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = Optional.of(retryConfig); - return this; - } - - public StopAllTasksRequestBuilder retryConfig(Optional retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = retryConfig; - return this; - } public StopAllTasksResponse call() throws Exception { - Optional options = Optional.of(Options.builder() - .retryConfig(retryConfig) - .build()); - return sdk.stopAllTasks( - options); + + return sdk.stopAllTasksDirect(); } } diff --git a/src/main/java/dev/plexapi/sdk/models/operations/StopTaskRequestBuilder.java b/src/main/java/dev/plexapi/sdk/models/operations/StopTaskRequestBuilder.java index 4b2c3d25..dd143045 100644 --- a/src/main/java/dev/plexapi/sdk/models/operations/StopTaskRequestBuilder.java +++ b/src/main/java/dev/plexapi/sdk/models/operations/StopTaskRequestBuilder.java @@ -4,15 +4,11 @@ package dev.plexapi.sdk.models.operations; -import dev.plexapi.sdk.utils.Options; -import dev.plexapi.sdk.utils.RetryConfig; import dev.plexapi.sdk.utils.Utils; -import java.util.Optional; public class StopTaskRequestBuilder { private PathParamTaskName taskName; - private Optional retryConfig = Optional.empty(); private final SDKMethodInterfaces.MethodCallStopTask sdk; public StopTaskRequestBuilder(SDKMethodInterfaces.MethodCallStopTask sdk) { @@ -24,25 +20,10 @@ public class StopTaskRequestBuilder { this.taskName = taskName; return this; } - - public StopTaskRequestBuilder retryConfig(RetryConfig retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = Optional.of(retryConfig); - return this; - } - - public StopTaskRequestBuilder retryConfig(Optional retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = retryConfig; - return this; - } public StopTaskResponse call() throws Exception { - Optional options = Optional.of(Options.builder() - .retryConfig(retryConfig) - .build()); + return sdk.stopTask( - taskName, - options); + taskName); } } diff --git a/src/main/java/dev/plexapi/sdk/models/operations/StopTranscodeSessionRequestBuilder.java b/src/main/java/dev/plexapi/sdk/models/operations/StopTranscodeSessionRequestBuilder.java index 89ce5639..cf76f9c7 100644 --- a/src/main/java/dev/plexapi/sdk/models/operations/StopTranscodeSessionRequestBuilder.java +++ b/src/main/java/dev/plexapi/sdk/models/operations/StopTranscodeSessionRequestBuilder.java @@ -4,16 +4,12 @@ package dev.plexapi.sdk.models.operations; -import dev.plexapi.sdk.utils.Options; -import dev.plexapi.sdk.utils.RetryConfig; import dev.plexapi.sdk.utils.Utils; import java.lang.String; -import java.util.Optional; public class StopTranscodeSessionRequestBuilder { private String sessionKey; - private Optional retryConfig = Optional.empty(); private final SDKMethodInterfaces.MethodCallStopTranscodeSession sdk; public StopTranscodeSessionRequestBuilder(SDKMethodInterfaces.MethodCallStopTranscodeSession sdk) { @@ -25,25 +21,10 @@ public class StopTranscodeSessionRequestBuilder { this.sessionKey = sessionKey; return this; } - - public StopTranscodeSessionRequestBuilder retryConfig(RetryConfig retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = Optional.of(retryConfig); - return this; - } - - public StopTranscodeSessionRequestBuilder retryConfig(Optional retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = retryConfig; - return this; - } public StopTranscodeSessionResponse call() throws Exception { - Optional options = Optional.of(Options.builder() - .retryConfig(retryConfig) - .build()); + return sdk.stopTranscodeSession( - sessionKey, - options); + sessionKey); } } diff --git a/src/main/java/dev/plexapi/sdk/models/operations/UpdatePlayProgressRequestBuilder.java b/src/main/java/dev/plexapi/sdk/models/operations/UpdatePlayProgressRequestBuilder.java index 33bfd7cd..2eb6fb03 100644 --- a/src/main/java/dev/plexapi/sdk/models/operations/UpdatePlayProgressRequestBuilder.java +++ b/src/main/java/dev/plexapi/sdk/models/operations/UpdatePlayProgressRequestBuilder.java @@ -4,19 +4,15 @@ package dev.plexapi.sdk.models.operations; -import dev.plexapi.sdk.utils.Options; -import dev.plexapi.sdk.utils.RetryConfig; import dev.plexapi.sdk.utils.Utils; import java.lang.Double; import java.lang.String; -import java.util.Optional; public class UpdatePlayProgressRequestBuilder { private String key; private Double time; private String state; - private Optional retryConfig = Optional.empty(); private final SDKMethodInterfaces.MethodCallUpdatePlayProgress sdk; public UpdatePlayProgressRequestBuilder(SDKMethodInterfaces.MethodCallUpdatePlayProgress sdk) { @@ -40,27 +36,12 @@ public class UpdatePlayProgressRequestBuilder { this.state = state; return this; } - - public UpdatePlayProgressRequestBuilder retryConfig(RetryConfig retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = Optional.of(retryConfig); - return this; - } - - public UpdatePlayProgressRequestBuilder retryConfig(Optional retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = retryConfig; - return this; - } public UpdatePlayProgressResponse call() throws Exception { - Optional options = Optional.of(Options.builder() - .retryConfig(retryConfig) - .build()); + return sdk.updatePlayProgress( key, time, - state, - options); + state); } } diff --git a/src/main/java/dev/plexapi/sdk/models/operations/UpdatePlaylistRequestBuilder.java b/src/main/java/dev/plexapi/sdk/models/operations/UpdatePlaylistRequestBuilder.java index 933bddff..7d2b3cdd 100644 --- a/src/main/java/dev/plexapi/sdk/models/operations/UpdatePlaylistRequestBuilder.java +++ b/src/main/java/dev/plexapi/sdk/models/operations/UpdatePlaylistRequestBuilder.java @@ -4,8 +4,6 @@ package dev.plexapi.sdk.models.operations; -import dev.plexapi.sdk.utils.Options; -import dev.plexapi.sdk.utils.RetryConfig; import dev.plexapi.sdk.utils.Utils; import java.lang.Double; import java.lang.String; @@ -16,7 +14,6 @@ public class UpdatePlaylistRequestBuilder { private Double playlistID; private Optional title = Optional.empty(); private Optional summary = Optional.empty(); - private Optional retryConfig = Optional.empty(); private final SDKMethodInterfaces.MethodCallUpdatePlaylist sdk; public UpdatePlaylistRequestBuilder(SDKMethodInterfaces.MethodCallUpdatePlaylist sdk) { @@ -52,27 +49,12 @@ public class UpdatePlaylistRequestBuilder { this.summary = summary; return this; } - - public UpdatePlaylistRequestBuilder retryConfig(RetryConfig retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = Optional.of(retryConfig); - return this; - } - - public UpdatePlaylistRequestBuilder retryConfig(Optional retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = retryConfig; - return this; - } public UpdatePlaylistResponse call() throws Exception { - Optional options = Optional.of(Options.builder() - .retryConfig(retryConfig) - .build()); + return sdk.updatePlaylist( playlistID, title, - summary, - options); + summary); } } diff --git a/src/main/java/dev/plexapi/sdk/models/operations/UploadPlaylistRequestBuilder.java b/src/main/java/dev/plexapi/sdk/models/operations/UploadPlaylistRequestBuilder.java index 695c243e..2739c987 100644 --- a/src/main/java/dev/plexapi/sdk/models/operations/UploadPlaylistRequestBuilder.java +++ b/src/main/java/dev/plexapi/sdk/models/operations/UploadPlaylistRequestBuilder.java @@ -6,19 +6,15 @@ package dev.plexapi.sdk.models.operations; import com.fasterxml.jackson.core.type.TypeReference; import dev.plexapi.sdk.utils.LazySingletonValue; -import dev.plexapi.sdk.utils.Options; -import dev.plexapi.sdk.utils.RetryConfig; import dev.plexapi.sdk.utils.Utils; import java.lang.Long; import java.lang.String; -import java.util.Optional; public class UploadPlaylistRequestBuilder { private String path; private QueryParamForce force; private Long sectionID; - private Optional retryConfig = Optional.empty(); private final SDKMethodInterfaces.MethodCallUploadPlaylist sdk; public UploadPlaylistRequestBuilder(SDKMethodInterfaces.MethodCallUploadPlaylist sdk) { @@ -42,30 +38,15 @@ public class UploadPlaylistRequestBuilder { this.sectionID = sectionID; return this; } - - public UploadPlaylistRequestBuilder retryConfig(RetryConfig retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = Optional.of(retryConfig); - return this; - } - - public UploadPlaylistRequestBuilder retryConfig(Optional retryConfig) { - Utils.checkNotNull(retryConfig, "retryConfig"); - this.retryConfig = retryConfig; - return this; - } public UploadPlaylistResponse call() throws Exception { if (sectionID == null) { sectionID = _SINGLETON_VALUE_SectionID.value(); - } Optional options = Optional.of(Options.builder() - .retryConfig(retryConfig) - .build()); + } return sdk.uploadPlaylist( path, force, - sectionID, - options); + sectionID); } private static final LazySingletonValue _SINGLETON_VALUE_SectionID =