mirror of
https://github.com/LukeHagar/plexjava.git
synced 2025-12-06 12:37:47 +00:00
198 lines
8.2 KiB
Java
198 lines
8.2 KiB
Java
/*
|
|
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
*/
|
|
package dev.plexapi.sdk;
|
|
|
|
import static dev.plexapi.sdk.operations.Operations.AsyncRequestOperation;
|
|
import static dev.plexapi.sdk.operations.Operations.AsyncRequestlessOperation;
|
|
|
|
import dev.plexapi.sdk.models.operations.GetSourceConnectionInformationRequest;
|
|
import dev.plexapi.sdk.models.operations.GetTransientTokenQueryParamType;
|
|
import dev.plexapi.sdk.models.operations.GetTransientTokenRequest;
|
|
import dev.plexapi.sdk.models.operations.PostUsersSignInDataRequest;
|
|
import dev.plexapi.sdk.models.operations.Scope;
|
|
import dev.plexapi.sdk.models.operations.async.GetSourceConnectionInformationRequestBuilder;
|
|
import dev.plexapi.sdk.models.operations.async.GetSourceConnectionInformationResponse;
|
|
import dev.plexapi.sdk.models.operations.async.GetTokenDetailsRequestBuilder;
|
|
import dev.plexapi.sdk.models.operations.async.GetTokenDetailsResponse;
|
|
import dev.plexapi.sdk.models.operations.async.GetTransientTokenRequestBuilder;
|
|
import dev.plexapi.sdk.models.operations.async.GetTransientTokenResponse;
|
|
import dev.plexapi.sdk.models.operations.async.PostUsersSignInDataRequestBuilder;
|
|
import dev.plexapi.sdk.models.operations.async.PostUsersSignInDataResponse;
|
|
import dev.plexapi.sdk.operations.GetSourceConnectionInformation;
|
|
import dev.plexapi.sdk.operations.GetTokenDetails;
|
|
import dev.plexapi.sdk.operations.GetTransientToken;
|
|
import dev.plexapi.sdk.operations.PostUsersSignInData;
|
|
import java.lang.String;
|
|
import java.util.Optional;
|
|
import java.util.concurrent.CompletableFuture;
|
|
|
|
/**
|
|
* API Calls regarding authentication for Plex Media Server
|
|
*/
|
|
public class AsyncAuthentication {
|
|
private final SDKConfiguration sdkConfiguration;
|
|
private final Authentication syncSDK;
|
|
|
|
AsyncAuthentication(Authentication syncSDK, SDKConfiguration sdkConfiguration) {
|
|
this.sdkConfiguration = sdkConfiguration;
|
|
this.syncSDK = syncSDK;
|
|
}
|
|
|
|
/**
|
|
* Switches to the sync SDK.
|
|
*
|
|
* @return The sync SDK
|
|
*/
|
|
public Authentication sync() {
|
|
return syncSDK;
|
|
}
|
|
|
|
|
|
/**
|
|
* Get a Transient Token
|
|
*
|
|
* <p>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.
|
|
*
|
|
* @return The async call builder
|
|
*/
|
|
public GetTransientTokenRequestBuilder getTransientToken() {
|
|
return new GetTransientTokenRequestBuilder(sdkConfiguration);
|
|
}
|
|
|
|
/**
|
|
* Get a Transient Token
|
|
*
|
|
* <p>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.
|
|
* @return CompletableFuture<GetTransientTokenResponse> - The async response
|
|
*/
|
|
public CompletableFuture<GetTransientTokenResponse> getTransientToken(GetTransientTokenQueryParamType type, Scope scope) {
|
|
GetTransientTokenRequest request =
|
|
GetTransientTokenRequest
|
|
.builder()
|
|
.type(type)
|
|
.scope(scope)
|
|
.build();
|
|
AsyncRequestOperation<GetTransientTokenRequest, GetTransientTokenResponse> operation
|
|
= new GetTransientToken.Async(sdkConfiguration);
|
|
return operation.doRequest(request)
|
|
.thenCompose(operation::handleResponse);
|
|
}
|
|
|
|
|
|
/**
|
|
* Get Source Connection Information
|
|
*
|
|
* <p>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.
|
|
*
|
|
* @return The async call builder
|
|
*/
|
|
public GetSourceConnectionInformationRequestBuilder getSourceConnectionInformation() {
|
|
return new GetSourceConnectionInformationRequestBuilder(sdkConfiguration);
|
|
}
|
|
|
|
/**
|
|
* Get Source Connection Information
|
|
*
|
|
* <p>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.
|
|
* @return CompletableFuture<GetSourceConnectionInformationResponse> - The async response
|
|
*/
|
|
public CompletableFuture<GetSourceConnectionInformationResponse> getSourceConnectionInformation(String source) {
|
|
GetSourceConnectionInformationRequest request =
|
|
GetSourceConnectionInformationRequest
|
|
.builder()
|
|
.source(source)
|
|
.build();
|
|
AsyncRequestOperation<GetSourceConnectionInformationRequest, GetSourceConnectionInformationResponse> operation
|
|
= new GetSourceConnectionInformation.Async(sdkConfiguration);
|
|
return operation.doRequest(request)
|
|
.thenCompose(operation::handleResponse);
|
|
}
|
|
|
|
|
|
/**
|
|
* Get Token Details
|
|
*
|
|
* <p>Get the User data from the provided X-Plex-Token
|
|
*
|
|
* @return The async call builder
|
|
*/
|
|
public GetTokenDetailsRequestBuilder getTokenDetails() {
|
|
return new GetTokenDetailsRequestBuilder(sdkConfiguration);
|
|
}
|
|
|
|
/**
|
|
* Get Token Details
|
|
*
|
|
* <p>Get the User data from the provided X-Plex-Token
|
|
*
|
|
* @return CompletableFuture<GetTokenDetailsResponse> - The async response
|
|
*/
|
|
public CompletableFuture<GetTokenDetailsResponse> getTokenDetailsDirect() {
|
|
return getTokenDetails(Optional.empty());
|
|
}
|
|
|
|
/**
|
|
* Get Token Details
|
|
*
|
|
* <p>Get the User data from the provided X-Plex-Token
|
|
*
|
|
* @param serverURL Overrides the server URL.
|
|
* @return CompletableFuture<GetTokenDetailsResponse> - The async response
|
|
*/
|
|
public CompletableFuture<GetTokenDetailsResponse> getTokenDetails(Optional<String> serverURL) {
|
|
AsyncRequestlessOperation<GetTokenDetailsResponse> operation
|
|
= new GetTokenDetails.Async(sdkConfiguration, serverURL);
|
|
return operation.doRequest()
|
|
.thenCompose(operation::handleResponse);
|
|
}
|
|
|
|
|
|
/**
|
|
* Get User Sign In Data
|
|
*
|
|
* <p>Sign in user with username and password and return user data with Plex authentication token
|
|
*
|
|
* @return The async call builder
|
|
*/
|
|
public PostUsersSignInDataRequestBuilder postUsersSignInData() {
|
|
return new PostUsersSignInDataRequestBuilder(sdkConfiguration);
|
|
}
|
|
|
|
/**
|
|
* Get User Sign In Data
|
|
*
|
|
* <p>Sign in user with username and password and return user data with Plex authentication token
|
|
*
|
|
* @param request The request object containing all the parameters for the API call.
|
|
* @return CompletableFuture<PostUsersSignInDataResponse> - The async response
|
|
*/
|
|
public CompletableFuture<PostUsersSignInDataResponse> postUsersSignInData(PostUsersSignInDataRequest request) {
|
|
return postUsersSignInData(request, Optional.empty());
|
|
}
|
|
|
|
/**
|
|
* Get User Sign In Data
|
|
*
|
|
* <p>Sign in user with username and password and return user data with Plex authentication token
|
|
*
|
|
* @param request The request object containing all the parameters for the API call.
|
|
* @param serverURL Overrides the server URL.
|
|
* @return CompletableFuture<PostUsersSignInDataResponse> - The async response
|
|
*/
|
|
public CompletableFuture<PostUsersSignInDataResponse> postUsersSignInData(PostUsersSignInDataRequest request, Optional<String> serverURL) {
|
|
AsyncRequestOperation<PostUsersSignInDataRequest, PostUsersSignInDataResponse> operation
|
|
= new PostUsersSignInData.Async(sdkConfiguration, serverURL);
|
|
return operation.doRequest(request)
|
|
.thenCompose(operation::handleResponse);
|
|
}
|
|
|
|
}
|