/* * 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 * *

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 * *

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 getTransientToken(GetTransientTokenQueryParamType type, Scope scope) { GetTransientTokenRequest request = GetTransientTokenRequest .builder() .type(type) .scope(scope) .build(); AsyncRequestOperation operation = new GetTransientToken.Async(sdkConfiguration); return operation.doRequest(request) .thenCompose(operation::handleResponse); } /** * 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. * * @return The async call builder */ public GetSourceConnectionInformationRequestBuilder getSourceConnectionInformation() { return new GetSourceConnectionInformationRequestBuilder(sdkConfiguration); } /** * 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. * @return CompletableFuture<GetSourceConnectionInformationResponse> - The async response */ public CompletableFuture getSourceConnectionInformation(String source) { GetSourceConnectionInformationRequest request = GetSourceConnectionInformationRequest .builder() .source(source) .build(); AsyncRequestOperation operation = new GetSourceConnectionInformation.Async(sdkConfiguration); return operation.doRequest(request) .thenCompose(operation::handleResponse); } /** * Get Token Details * *

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 * *

Get the User data from the provided X-Plex-Token * * @return CompletableFuture<GetTokenDetailsResponse> - The async response */ public CompletableFuture getTokenDetailsDirect() { return getTokenDetails(Optional.empty()); } /** * Get Token Details * *

Get the User data from the provided X-Plex-Token * * @param serverURL Overrides the server URL. * @return CompletableFuture<GetTokenDetailsResponse> - The async response */ public CompletableFuture getTokenDetails(Optional serverURL) { AsyncRequestlessOperation operation = new GetTokenDetails.Async(sdkConfiguration, serverURL); return operation.doRequest() .thenCompose(operation::handleResponse); } /** * Get User Sign In Data * *

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 * *

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 postUsersSignInData(PostUsersSignInDataRequest request) { return postUsersSignInData(request, Optional.empty()); } /** * Get User Sign In Data * *

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 postUsersSignInData(PostUsersSignInDataRequest request, Optional serverURL) { AsyncRequestOperation operation = new PostUsersSignInData.Async(sdkConfiguration, serverURL); return operation.doRequest(request) .thenCompose(operation::handleResponse); } }