mirror of
https://github.com/LukeHagar/plexjava.git
synced 2025-12-07 12:37:45 +00:00
ci: regenerated with OpenAPI Doc , Speakeasy CLI 1.615.2
This commit is contained in:
@@ -3,46 +3,38 @@
|
||||
*/
|
||||
package dev.plexapi.sdk;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import dev.plexapi.sdk.models.errors.GetTimelineBadRequest;
|
||||
import dev.plexapi.sdk.models.errors.GetTimelineUnauthorized;
|
||||
import dev.plexapi.sdk.models.errors.SDKError;
|
||||
import dev.plexapi.sdk.models.errors.StartUniversalTranscodeBadRequest;
|
||||
import dev.plexapi.sdk.models.errors.StartUniversalTranscodeUnauthorized;
|
||||
import static dev.plexapi.sdk.operations.Operations.RequestOperation;
|
||||
|
||||
import dev.plexapi.sdk.models.operations.GetTimelineRequest;
|
||||
import dev.plexapi.sdk.models.operations.GetTimelineRequestBuilder;
|
||||
import dev.plexapi.sdk.models.operations.GetTimelineResponse;
|
||||
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.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.Utils;
|
||||
import java.io.InputStream;
|
||||
import dev.plexapi.sdk.operations.GetTimeline;
|
||||
import dev.plexapi.sdk.operations.StartUniversalTranscode;
|
||||
import java.lang.Exception;
|
||||
import java.lang.String;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpResponse;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* API Calls that perform operations with Plex Media Server Videos
|
||||
*/
|
||||
public class Video implements
|
||||
MethodCallGetTimeline,
|
||||
MethodCallStartUniversalTranscode {
|
||||
|
||||
public class Video {
|
||||
private final SDKConfiguration sdkConfiguration;
|
||||
private final AsyncVideo asyncSDK;
|
||||
|
||||
Video(SDKConfiguration sdkConfiguration) {
|
||||
this.sdkConfiguration = sdkConfiguration;
|
||||
this.asyncSDK = new AsyncVideo(this, sdkConfiguration);
|
||||
}
|
||||
|
||||
/**
|
||||
* Switches to the async SDK.
|
||||
*
|
||||
* @return The async SDK
|
||||
*/
|
||||
public AsyncVideo async() {
|
||||
return asyncSDK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the timeline for a media item
|
||||
@@ -52,7 +44,7 @@ public class Video implements
|
||||
* @return The call builder
|
||||
*/
|
||||
public GetTimelineRequestBuilder getTimeline() {
|
||||
return new GetTimelineRequestBuilder(this);
|
||||
return new GetTimelineRequestBuilder(sdkConfiguration);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -60,153 +52,16 @@ public class Video implements
|
||||
*
|
||||
* <p>Get the timeline for a media item
|
||||
*
|
||||
* @param request The request object containing all of the parameters for the API call.
|
||||
* @param request The request object containing all the parameters for the API call.
|
||||
* @return The response from the API call
|
||||
* @throws Exception if the API call fails
|
||||
*/
|
||||
public GetTimelineResponse getTimeline(
|
||||
GetTimelineRequest request) throws Exception {
|
||||
String _baseUrl = Utils.templateUrl(
|
||||
this.sdkConfiguration.serverUrl(), this.sdkConfiguration.getServerVariableDefaults());
|
||||
String _url = Utils.generateURL(
|
||||
_baseUrl,
|
||||
"/:/timeline");
|
||||
|
||||
HTTPRequest _req = new HTTPRequest(_url, "GET");
|
||||
_req.addHeader("Accept", "application/json")
|
||||
.addHeader("user-agent",
|
||||
SDKConfiguration.USER_AGENT);
|
||||
|
||||
_req.addQueryParams(Utils.getQueryParams(
|
||||
GetTimelineRequest.class,
|
||||
request,
|
||||
null));
|
||||
|
||||
Optional<SecuritySource> _hookSecuritySource = Optional.of(this.sdkConfiguration.securitySource());
|
||||
Utils.configureSecurity(_req,
|
||||
this.sdkConfiguration.securitySource().getSecurity());
|
||||
HTTPClient _client = this.sdkConfiguration.client();
|
||||
HttpRequest _r =
|
||||
sdkConfiguration.hooks()
|
||||
.beforeRequest(
|
||||
new BeforeRequestContextImpl(
|
||||
this.sdkConfiguration,
|
||||
_baseUrl,
|
||||
"getTimeline",
|
||||
Optional.of(List.of()),
|
||||
_hookSecuritySource),
|
||||
_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(
|
||||
this.sdkConfiguration,
|
||||
_baseUrl,
|
||||
"getTimeline",
|
||||
Optional.of(List.of()),
|
||||
_hookSecuritySource),
|
||||
Optional.of(_httpRes),
|
||||
Optional.empty());
|
||||
} else {
|
||||
_httpRes = sdkConfiguration.hooks()
|
||||
.afterSuccess(
|
||||
new AfterSuccessContextImpl(
|
||||
this.sdkConfiguration,
|
||||
_baseUrl,
|
||||
"getTimeline",
|
||||
Optional.of(List.of()),
|
||||
_hookSecuritySource),
|
||||
_httpRes);
|
||||
}
|
||||
} catch (Exception _e) {
|
||||
_httpRes = sdkConfiguration.hooks()
|
||||
.afterError(
|
||||
new AfterErrorContextImpl(
|
||||
this.sdkConfiguration,
|
||||
_baseUrl,
|
||||
"getTimeline",
|
||||
Optional.of(List.of()),
|
||||
_hookSecuritySource),
|
||||
Optional.empty(),
|
||||
Optional.of(_e));
|
||||
}
|
||||
String _contentType = _httpRes
|
||||
.headers()
|
||||
.firstValue("Content-Type")
|
||||
.orElse("application/octet-stream");
|
||||
GetTimelineResponse.Builder _resBuilder =
|
||||
GetTimelineResponse
|
||||
.builder()
|
||||
.contentType(_contentType)
|
||||
.statusCode(_httpRes.statusCode())
|
||||
.rawResponse(_httpRes);
|
||||
|
||||
GetTimelineResponse _res = _resBuilder.build();
|
||||
|
||||
if (Utils.statusCodeMatches(_httpRes.statusCode(), "200")) {
|
||||
// no content
|
||||
return _res;
|
||||
}
|
||||
if (Utils.statusCodeMatches(_httpRes.statusCode(), "400")) {
|
||||
if (Utils.contentTypeMatches(_contentType, "application/json")) {
|
||||
GetTimelineBadRequest _out = Utils.mapper().readValue(
|
||||
Utils.toUtf8AndClose(_httpRes.body()),
|
||||
new TypeReference<GetTimelineBadRequest>() {});
|
||||
_out.withRawResponse(Optional.ofNullable(_httpRes));
|
||||
|
||||
throw _out;
|
||||
} else {
|
||||
throw new SDKError(
|
||||
_httpRes,
|
||||
_httpRes.statusCode(),
|
||||
"Unexpected content-type received: " + _contentType,
|
||||
Utils.extractByteArrayFromBody(_httpRes));
|
||||
}
|
||||
}
|
||||
if (Utils.statusCodeMatches(_httpRes.statusCode(), "401")) {
|
||||
if (Utils.contentTypeMatches(_contentType, "application/json")) {
|
||||
GetTimelineUnauthorized _out = Utils.mapper().readValue(
|
||||
Utils.toUtf8AndClose(_httpRes.body()),
|
||||
new TypeReference<GetTimelineUnauthorized>() {});
|
||||
_out.withRawResponse(Optional.ofNullable(_httpRes));
|
||||
|
||||
throw _out;
|
||||
} else {
|
||||
throw new SDKError(
|
||||
_httpRes,
|
||||
_httpRes.statusCode(),
|
||||
"Unexpected content-type received: " + _contentType,
|
||||
Utils.extractByteArrayFromBody(_httpRes));
|
||||
}
|
||||
}
|
||||
if (Utils.statusCodeMatches(_httpRes.statusCode(), "4XX")) {
|
||||
// no content
|
||||
throw new SDKError(
|
||||
_httpRes,
|
||||
_httpRes.statusCode(),
|
||||
"API error occurred",
|
||||
Utils.extractByteArrayFromBody(_httpRes));
|
||||
}
|
||||
if (Utils.statusCodeMatches(_httpRes.statusCode(), "5XX")) {
|
||||
// no content
|
||||
throw new SDKError(
|
||||
_httpRes,
|
||||
_httpRes.statusCode(),
|
||||
"API error occurred",
|
||||
Utils.extractByteArrayFromBody(_httpRes));
|
||||
}
|
||||
throw new SDKError(
|
||||
_httpRes,
|
||||
_httpRes.statusCode(),
|
||||
"Unexpected status code received: " + _httpRes.statusCode(),
|
||||
Utils.extractByteArrayFromBody(_httpRes));
|
||||
public GetTimelineResponse getTimeline(GetTimelineRequest request) throws Exception {
|
||||
RequestOperation<GetTimelineRequest, GetTimelineResponse> operation
|
||||
= new GetTimeline.Sync(sdkConfiguration);
|
||||
return operation.handleResponse(operation.doRequest(request));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Start Universal Transcode
|
||||
*
|
||||
@@ -215,7 +70,7 @@ public class Video implements
|
||||
* @return The call builder
|
||||
*/
|
||||
public StartUniversalTranscodeRequestBuilder startUniversalTranscode() {
|
||||
return new StartUniversalTranscodeRequestBuilder(this);
|
||||
return new StartUniversalTranscodeRequestBuilder(sdkConfiguration);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -223,149 +78,14 @@ public class Video implements
|
||||
*
|
||||
* <p>Begin a Universal Transcode Session
|
||||
*
|
||||
* @param request The request object containing all of the parameters for the API call.
|
||||
* @param request The request object containing all the parameters for the API call.
|
||||
* @return The response from the API call
|
||||
* @throws Exception if the API call fails
|
||||
*/
|
||||
public StartUniversalTranscodeResponse startUniversalTranscode(
|
||||
StartUniversalTranscodeRequest request) throws Exception {
|
||||
String _baseUrl = Utils.templateUrl(
|
||||
this.sdkConfiguration.serverUrl(), this.sdkConfiguration.getServerVariableDefaults());
|
||||
String _url = Utils.generateURL(
|
||||
_baseUrl,
|
||||
"/video/:/transcode/universal/start.mpd");
|
||||
|
||||
HTTPRequest _req = new HTTPRequest(_url, "GET");
|
||||
_req.addHeader("Accept", "application/json")
|
||||
.addHeader("user-agent",
|
||||
SDKConfiguration.USER_AGENT);
|
||||
|
||||
_req.addQueryParams(Utils.getQueryParams(
|
||||
StartUniversalTranscodeRequest.class,
|
||||
request,
|
||||
null));
|
||||
|
||||
Optional<SecuritySource> _hookSecuritySource = Optional.of(this.sdkConfiguration.securitySource());
|
||||
Utils.configureSecurity(_req,
|
||||
this.sdkConfiguration.securitySource().getSecurity());
|
||||
HTTPClient _client = this.sdkConfiguration.client();
|
||||
HttpRequest _r =
|
||||
sdkConfiguration.hooks()
|
||||
.beforeRequest(
|
||||
new BeforeRequestContextImpl(
|
||||
this.sdkConfiguration,
|
||||
_baseUrl,
|
||||
"startUniversalTranscode",
|
||||
Optional.of(List.of()),
|
||||
_hookSecuritySource),
|
||||
_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(
|
||||
this.sdkConfiguration,
|
||||
_baseUrl,
|
||||
"startUniversalTranscode",
|
||||
Optional.of(List.of()),
|
||||
_hookSecuritySource),
|
||||
Optional.of(_httpRes),
|
||||
Optional.empty());
|
||||
} else {
|
||||
_httpRes = sdkConfiguration.hooks()
|
||||
.afterSuccess(
|
||||
new AfterSuccessContextImpl(
|
||||
this.sdkConfiguration,
|
||||
_baseUrl,
|
||||
"startUniversalTranscode",
|
||||
Optional.of(List.of()),
|
||||
_hookSecuritySource),
|
||||
_httpRes);
|
||||
}
|
||||
} catch (Exception _e) {
|
||||
_httpRes = sdkConfiguration.hooks()
|
||||
.afterError(
|
||||
new AfterErrorContextImpl(
|
||||
this.sdkConfiguration,
|
||||
_baseUrl,
|
||||
"startUniversalTranscode",
|
||||
Optional.of(List.of()),
|
||||
_hookSecuritySource),
|
||||
Optional.empty(),
|
||||
Optional.of(_e));
|
||||
}
|
||||
String _contentType = _httpRes
|
||||
.headers()
|
||||
.firstValue("Content-Type")
|
||||
.orElse("application/octet-stream");
|
||||
StartUniversalTranscodeResponse.Builder _resBuilder =
|
||||
StartUniversalTranscodeResponse
|
||||
.builder()
|
||||
.contentType(_contentType)
|
||||
.statusCode(_httpRes.statusCode())
|
||||
.rawResponse(_httpRes);
|
||||
|
||||
StartUniversalTranscodeResponse _res = _resBuilder.build();
|
||||
|
||||
if (Utils.statusCodeMatches(_httpRes.statusCode(), "200")) {
|
||||
// no content
|
||||
return _res;
|
||||
}
|
||||
if (Utils.statusCodeMatches(_httpRes.statusCode(), "400")) {
|
||||
if (Utils.contentTypeMatches(_contentType, "application/json")) {
|
||||
StartUniversalTranscodeBadRequest _out = Utils.mapper().readValue(
|
||||
Utils.toUtf8AndClose(_httpRes.body()),
|
||||
new TypeReference<StartUniversalTranscodeBadRequest>() {});
|
||||
_out.withRawResponse(Optional.ofNullable(_httpRes));
|
||||
|
||||
throw _out;
|
||||
} else {
|
||||
throw new SDKError(
|
||||
_httpRes,
|
||||
_httpRes.statusCode(),
|
||||
"Unexpected content-type received: " + _contentType,
|
||||
Utils.extractByteArrayFromBody(_httpRes));
|
||||
}
|
||||
}
|
||||
if (Utils.statusCodeMatches(_httpRes.statusCode(), "401")) {
|
||||
if (Utils.contentTypeMatches(_contentType, "application/json")) {
|
||||
StartUniversalTranscodeUnauthorized _out = Utils.mapper().readValue(
|
||||
Utils.toUtf8AndClose(_httpRes.body()),
|
||||
new TypeReference<StartUniversalTranscodeUnauthorized>() {});
|
||||
_out.withRawResponse(Optional.ofNullable(_httpRes));
|
||||
|
||||
throw _out;
|
||||
} else {
|
||||
throw new SDKError(
|
||||
_httpRes,
|
||||
_httpRes.statusCode(),
|
||||
"Unexpected content-type received: " + _contentType,
|
||||
Utils.extractByteArrayFromBody(_httpRes));
|
||||
}
|
||||
}
|
||||
if (Utils.statusCodeMatches(_httpRes.statusCode(), "4XX")) {
|
||||
// no content
|
||||
throw new SDKError(
|
||||
_httpRes,
|
||||
_httpRes.statusCode(),
|
||||
"API error occurred",
|
||||
Utils.extractByteArrayFromBody(_httpRes));
|
||||
}
|
||||
if (Utils.statusCodeMatches(_httpRes.statusCode(), "5XX")) {
|
||||
// no content
|
||||
throw new SDKError(
|
||||
_httpRes,
|
||||
_httpRes.statusCode(),
|
||||
"API error occurred",
|
||||
Utils.extractByteArrayFromBody(_httpRes));
|
||||
}
|
||||
throw new SDKError(
|
||||
_httpRes,
|
||||
_httpRes.statusCode(),
|
||||
"Unexpected status code received: " + _httpRes.statusCode(),
|
||||
Utils.extractByteArrayFromBody(_httpRes));
|
||||
public StartUniversalTranscodeResponse startUniversalTranscode(StartUniversalTranscodeRequest request) throws Exception {
|
||||
RequestOperation<StartUniversalTranscodeRequest, StartUniversalTranscodeResponse> operation
|
||||
= new StartUniversalTranscode.Sync(sdkConfiguration);
|
||||
return operation.handleResponse(operation.doRequest(request));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user