mirror of
https://github.com/LukeHagar/plexjava.git
synced 2025-12-06 12:37:47 +00:00
ci: regenerated with OpenAPI Doc , Speakeasy CLI 1.406.0
This commit is contained in:
@@ -47,20 +47,28 @@ 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.Optional;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* API Calls that perform operations directly against https://Plex.tv
|
||||
@@ -140,18 +148,24 @@ public class Plex implements
|
||||
* @throws Exception if the API call fails
|
||||
*/
|
||||
public GetCompanionsDataResponse getCompanionsDataDirect() throws Exception {
|
||||
return getCompanionsData(Optional.empty());
|
||||
return getCompanionsData(Optional.empty(), 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<String> serverURL) throws Exception {
|
||||
Optional<String> serverURL,
|
||||
Optional<Options> options) throws Exception {
|
||||
|
||||
if (options.isPresent()) {
|
||||
options.get().validate(Arrays.asList(Options.Option.RETRY_CONFIG));
|
||||
}
|
||||
String _baseUrl = Utils.templateUrl(GET_COMPANIONS_DATA_SERVERS[0], new HashMap<String, String>());
|
||||
if (serverURL.isPresent() && !serverURL.get().isBlank()) {
|
||||
_baseUrl = serverURL.get();
|
||||
@@ -169,45 +183,62 @@ public class Plex implements
|
||||
this.sdkConfiguration.securitySource.getSecurity());
|
||||
|
||||
HTTPClient _client = this.sdkConfiguration.defaultClient;
|
||||
HttpRequest _r =
|
||||
sdkConfiguration.hooks()
|
||||
.beforeRequest(
|
||||
new BeforeRequestContextImpl(
|
||||
"getCompanionsData",
|
||||
Optional.of(List.of()),
|
||||
sdkConfiguration.securitySource()),
|
||||
_req.build());
|
||||
HttpResponse<InputStream> _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));
|
||||
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();
|
||||
}
|
||||
List<String> _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<InputStream> _httpRes = sdkConfiguration.hooks()
|
||||
.afterSuccess(
|
||||
new AfterSuccessContextImpl(
|
||||
"getCompanionsData",
|
||||
Optional.of(List.of()),
|
||||
sdkConfiguration.securitySource()),
|
||||
_retries.run());
|
||||
String _contentType = _httpRes
|
||||
.headers()
|
||||
.firstValue("Content-Type")
|
||||
@@ -301,18 +332,24 @@ public class Plex implements
|
||||
* @throws Exception if the API call fails
|
||||
*/
|
||||
public GetUserFriendsResponse getUserFriendsDirect() throws Exception {
|
||||
return getUserFriends(Optional.empty());
|
||||
return getUserFriends(Optional.empty(), 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<String> serverURL) throws Exception {
|
||||
Optional<String> serverURL,
|
||||
Optional<Options> options) throws Exception {
|
||||
|
||||
if (options.isPresent()) {
|
||||
options.get().validate(Arrays.asList(Options.Option.RETRY_CONFIG));
|
||||
}
|
||||
String _baseUrl = Utils.templateUrl(GET_USER_FRIENDS_SERVERS[0], new HashMap<String, String>());
|
||||
if (serverURL.isPresent() && !serverURL.get().isBlank()) {
|
||||
_baseUrl = serverURL.get();
|
||||
@@ -330,45 +367,62 @@ public class Plex implements
|
||||
this.sdkConfiguration.securitySource.getSecurity());
|
||||
|
||||
HTTPClient _client = this.sdkConfiguration.defaultClient;
|
||||
HttpRequest _r =
|
||||
sdkConfiguration.hooks()
|
||||
.beforeRequest(
|
||||
new BeforeRequestContextImpl(
|
||||
"getUserFriends",
|
||||
Optional.of(List.of()),
|
||||
sdkConfiguration.securitySource()),
|
||||
_req.build());
|
||||
HttpResponse<InputStream> _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));
|
||||
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();
|
||||
}
|
||||
List<String> _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<InputStream> _httpRes = sdkConfiguration.hooks()
|
||||
.afterSuccess(
|
||||
new AfterSuccessContextImpl(
|
||||
"getUserFriends",
|
||||
Optional.of(List.of()),
|
||||
sdkConfiguration.securitySource()),
|
||||
_retries.run());
|
||||
String _contentType = _httpRes
|
||||
.headers()
|
||||
.firstValue("Content-Type")
|
||||
@@ -462,18 +516,24 @@ public class Plex implements
|
||||
* @throws Exception if the API call fails
|
||||
*/
|
||||
public GetGeoDataResponse getGeoDataDirect() throws Exception {
|
||||
return getGeoData(Optional.empty());
|
||||
return getGeoData(Optional.empty(), 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<String> serverURL) throws Exception {
|
||||
Optional<String> serverURL,
|
||||
Optional<Options> options) throws Exception {
|
||||
|
||||
if (options.isPresent()) {
|
||||
options.get().validate(Arrays.asList(Options.Option.RETRY_CONFIG));
|
||||
}
|
||||
String _baseUrl = Utils.templateUrl(GET_GEO_DATA_SERVERS[0], new HashMap<String, String>());
|
||||
if (serverURL.isPresent() && !serverURL.get().isBlank()) {
|
||||
_baseUrl = serverURL.get();
|
||||
@@ -488,45 +548,62 @@ public class Plex implements
|
||||
SDKConfiguration.USER_AGENT);
|
||||
|
||||
HTTPClient _client = this.sdkConfiguration.defaultClient;
|
||||
HttpRequest _r =
|
||||
sdkConfiguration.hooks()
|
||||
.beforeRequest(
|
||||
new BeforeRequestContextImpl(
|
||||
"getGeoData",
|
||||
Optional.of(List.of()),
|
||||
sdkConfiguration.securitySource()),
|
||||
_req.build());
|
||||
HttpResponse<InputStream> _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));
|
||||
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();
|
||||
}
|
||||
List<String> _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<InputStream> _httpRes = sdkConfiguration.hooks()
|
||||
.afterSuccess(
|
||||
new AfterSuccessContextImpl(
|
||||
"getGeoData",
|
||||
Optional.of(List.of()),
|
||||
sdkConfiguration.securitySource()),
|
||||
_retries.run());
|
||||
String _contentType = _httpRes
|
||||
.headers()
|
||||
.firstValue("Content-Type")
|
||||
@@ -620,6 +697,22 @@ 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> 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(
|
||||
@@ -635,45 +728,62 @@ public class Plex implements
|
||||
this.sdkConfiguration.securitySource.getSecurity());
|
||||
|
||||
HTTPClient _client = this.sdkConfiguration.defaultClient;
|
||||
HttpRequest _r =
|
||||
sdkConfiguration.hooks()
|
||||
.beforeRequest(
|
||||
new BeforeRequestContextImpl(
|
||||
"getHomeData",
|
||||
Optional.of(List.of()),
|
||||
sdkConfiguration.securitySource()),
|
||||
_req.build());
|
||||
HttpResponse<InputStream> _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));
|
||||
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();
|
||||
}
|
||||
List<String> _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<InputStream> _httpRes = sdkConfiguration.hooks()
|
||||
.afterSuccess(
|
||||
new AfterSuccessContextImpl(
|
||||
"getHomeData",
|
||||
Optional.of(List.of()),
|
||||
sdkConfiguration.securitySource()),
|
||||
_retries.run());
|
||||
String _contentType = _httpRes
|
||||
.headers()
|
||||
.firstValue("Content-Type")
|
||||
@@ -767,7 +877,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());
|
||||
return getServerResources(Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -778,8 +888,9 @@ public class Plex implements
|
||||
E.g: https://10-0-0-25.bbf8e10c7fa20447cacee74cd9914cde.plex.direct:32400
|
||||
|
||||
* @param includeIPv6 Include IPv6 entries in the results
|
||||
* @param clientID The unique identifier for the client application. This is used to track the client application and its usage. (UUID, serial number, or other number unique per device)
|
||||
* @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
|
||||
*/
|
||||
@@ -788,7 +899,12 @@ public class Plex implements
|
||||
Optional<? extends IncludeRelay> includeRelay,
|
||||
Optional<? extends IncludeIPv6> includeIPv6,
|
||||
Optional<String> clientID,
|
||||
Optional<String> serverURL) throws Exception {
|
||||
Optional<String> serverURL,
|
||||
Optional<Options> options) throws Exception {
|
||||
|
||||
if (options.isPresent()) {
|
||||
options.get().validate(Arrays.asList(Options.Option.RETRY_CONFIG));
|
||||
}
|
||||
GetServerResourcesRequest request =
|
||||
GetServerResourcesRequest
|
||||
.builder()
|
||||
@@ -815,50 +931,68 @@ public class Plex implements
|
||||
GetServerResourcesRequest.class,
|
||||
request,
|
||||
this.sdkConfiguration.globals));
|
||||
_req.addHeaders(Utils.getHeadersFromMetadata(request, this.sdkConfiguration.globals));
|
||||
|
||||
Utils.configureSecurity(_req,
|
||||
this.sdkConfiguration.securitySource.getSecurity());
|
||||
|
||||
HTTPClient _client = this.sdkConfiguration.defaultClient;
|
||||
HttpRequest _r =
|
||||
sdkConfiguration.hooks()
|
||||
.beforeRequest(
|
||||
new BeforeRequestContextImpl(
|
||||
"get-server-resources",
|
||||
Optional.of(List.of()),
|
||||
sdkConfiguration.securitySource()),
|
||||
_req.build());
|
||||
HttpResponse<InputStream> _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));
|
||||
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();
|
||||
}
|
||||
List<String> _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<InputStream> _httpRes = sdkConfiguration.hooks()
|
||||
.afterSuccess(
|
||||
new AfterSuccessContextImpl(
|
||||
"get-server-resources",
|
||||
Optional.of(List.of()),
|
||||
sdkConfiguration.securitySource()),
|
||||
_retries.run());
|
||||
String _contentType = _httpRes
|
||||
.headers()
|
||||
.firstValue("Content-Type")
|
||||
@@ -954,7 +1088,7 @@ public class Plex implements
|
||||
*/
|
||||
public GetPinResponse getPin(
|
||||
GetPinRequest request) throws Exception {
|
||||
return getPin(request, Optional.empty());
|
||||
return getPin(request, Optional.empty(), Optional.empty());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -962,12 +1096,18 @@ 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<String> serverURL) throws Exception {
|
||||
Optional<String> serverURL,
|
||||
Optional<Options> options) throws Exception {
|
||||
|
||||
if (options.isPresent()) {
|
||||
options.get().validate(Arrays.asList(Options.Option.RETRY_CONFIG));
|
||||
}
|
||||
String _baseUrl = Utils.templateUrl(GET_PIN_SERVERS[0], new HashMap<String, String>());
|
||||
if (serverURL.isPresent() && !serverURL.get().isBlank()) {
|
||||
_baseUrl = serverURL.get();
|
||||
@@ -985,47 +1125,65 @@ public class Plex implements
|
||||
GetPinRequest.class,
|
||||
request,
|
||||
this.sdkConfiguration.globals));
|
||||
_req.addHeaders(Utils.getHeadersFromMetadata(request, this.sdkConfiguration.globals));
|
||||
|
||||
HTTPClient _client = this.sdkConfiguration.defaultClient;
|
||||
HttpRequest _r =
|
||||
sdkConfiguration.hooks()
|
||||
.beforeRequest(
|
||||
new BeforeRequestContextImpl(
|
||||
"getPin",
|
||||
Optional.of(List.of()),
|
||||
sdkConfiguration.securitySource()),
|
||||
_req.build());
|
||||
HttpResponse<InputStream> _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));
|
||||
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();
|
||||
}
|
||||
List<String> _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<InputStream> _httpRes = sdkConfiguration.hooks()
|
||||
.afterSuccess(
|
||||
new AfterSuccessContextImpl(
|
||||
"getPin",
|
||||
Optional.of(List.of()),
|
||||
sdkConfiguration.securitySource()),
|
||||
_retries.run());
|
||||
String _contentType = _httpRes
|
||||
.headers()
|
||||
.firstValue("Content-Type")
|
||||
@@ -1105,7 +1263,7 @@ public class Plex implements
|
||||
*/
|
||||
public GetTokenByPinIdResponse getTokenByPinId(
|
||||
GetTokenByPinIdRequest request) throws Exception {
|
||||
return getTokenByPinId(request, Optional.empty());
|
||||
return getTokenByPinId(request, Optional.empty(), Optional.empty());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1113,12 +1271,18 @@ 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<String> serverURL) throws Exception {
|
||||
Optional<String> serverURL,
|
||||
Optional<Options> options) throws Exception {
|
||||
|
||||
if (options.isPresent()) {
|
||||
options.get().validate(Arrays.asList(Options.Option.RETRY_CONFIG));
|
||||
}
|
||||
String _baseUrl = Utils.templateUrl(GET_TOKEN_BY_PIN_ID_SERVERS[0], new HashMap<String, String>());
|
||||
if (serverURL.isPresent() && !serverURL.get().isBlank()) {
|
||||
_baseUrl = serverURL.get();
|
||||
@@ -1133,52 +1297,65 @@ public class Plex implements
|
||||
_req.addHeader("Accept", "application/json")
|
||||
.addHeader("user-agent",
|
||||
SDKConfiguration.USER_AGENT);
|
||||
|
||||
_req.addQueryParams(Utils.getQueryParams(
|
||||
GetTokenByPinIdRequest.class,
|
||||
request,
|
||||
this.sdkConfiguration.globals));
|
||||
_req.addHeaders(Utils.getHeadersFromMetadata(request, this.sdkConfiguration.globals));
|
||||
|
||||
HTTPClient _client = this.sdkConfiguration.defaultClient;
|
||||
HttpRequest _r =
|
||||
sdkConfiguration.hooks()
|
||||
.beforeRequest(
|
||||
new BeforeRequestContextImpl(
|
||||
"getTokenByPinId",
|
||||
Optional.of(List.of()),
|
||||
sdkConfiguration.securitySource()),
|
||||
_req.build());
|
||||
HttpResponse<InputStream> _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));
|
||||
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();
|
||||
}
|
||||
List<String> _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<InputStream> _httpRes = sdkConfiguration.hooks()
|
||||
.afterSuccess(
|
||||
new AfterSuccessContextImpl(
|
||||
"getTokenByPinId",
|
||||
Optional.of(List.of()),
|
||||
sdkConfiguration.securitySource()),
|
||||
_retries.run());
|
||||
String _contentType = _httpRes
|
||||
.headers()
|
||||
.firstValue("Content-Type")
|
||||
|
||||
Reference in New Issue
Block a user