/*
* Copyright 2018-2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
* the License. A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
* and limitations under the License.
*/
package com.amazonaws.services.ivsrealtime;
import javax.annotation.Generated;
import com.amazonaws.services.ivsrealtime.model.*;
import com.amazonaws.client.AwsAsyncClientParams;
import com.amazonaws.annotation.ThreadSafe;
import java.util.concurrent.ExecutorService;
/**
* Client for accessing ivsrealtime asynchronously. Each asynchronous method will return a Java Future object
* representing the asynchronous operation; overloads which accept an {@code AsyncHandler} can be used to receive
* notification when an asynchronous operation completes.
*
*
* Introduction
*
*
* The Amazon Interactive Video Service (IVS) stage API is REST compatible, using a standard HTTP API and an AWS
* EventBridge event stream for responses. JSON is used for both requests and responses, including errors.
*
*
* Terminology:
*
*
* -
*
* The IVS stage API sometimes is referred to as the IVS RealTime API.
*
*
* -
*
* A participant token is an authorization token used to publish/subscribe to a stage.
*
*
* -
*
* A participant object represents participants (people) in the stage and contains information about them. When a
* token is created, it includes a participant ID; when a participant uses that token to join a stage, the participant
* is associated with that participant ID There is a 1:1 mapping between participant tokens and participants.
*
*
*
*
* Resources
*
*
* The following resources contain information about your IVS live stream (see Getting Started with Amazon IVS):
*
*
*
* Tagging
*
*
* A tag is a metadata label that you assign to an AWS resource. A tag comprises a key and a value,
* both set by you. For example, you might set a tag as topic:nature
to label a particular video category.
* See Tagging AWS Resources for more
* information, including restrictions that apply to tags and "Tag naming limits and requirements"; Amazon IVS stages
* has no service-specific constraints beyond what is documented there.
*
*
* Tags can help you identify and organize your AWS resources. For example, you can use the same tag for different
* resources to indicate that they are related. You can also use tags to manage access (see Access Tags).
*
*
* The Amazon IVS stage API has these tag-related endpoints: TagResource, UntagResource, and
* ListTagsForResource. The following resource supports tagging: Stage.
*
*
* At most 50 tags can be applied to a resource.
*
*
* Stages Endpoints
*
*
* -
*
* CreateParticipantToken — Creates an additional token for a specified stage. This can be done after stage
* creation or when tokens expire.
*
*
* -
*
* CreateStage — Creates a new stage (and optionally participant tokens).
*
*
* -
*
* DeleteStage — Shuts down and deletes the specified stage (disconnecting all participants).
*
*
* -
*
* DisconnectParticipant — Disconnects a specified participant and revokes the participant permanently from a
* specified stage.
*
*
* -
*
* GetParticipant — Gets information about the specified participant token.
*
*
* -
*
* GetStage — Gets information for the specified stage.
*
*
* -
*
* GetStageSession — Gets information for the specified stage session.
*
*
* -
*
* ListParticipantEvents — Lists events for a specified participant that occurred during a specified stage
* session.
*
*
* -
*
* ListParticipants — Lists all participants in a specified stage session.
*
*
* -
*
* ListStages — Gets summary information about all stages in your account, in the AWS region where the API
* request is processed.
*
*
* -
*
* ListStageSessions — Gets all sessions for a specified stage.
*
*
* -
*
* UpdateStage — Updates a stage’s configuration.
*
*
*
*
* Tags Endpoints
*
*
* -
*
* ListTagsForResource — Gets information about AWS tags for the specified ARN.
*
*
* -
*
* TagResource — Adds or updates tags for the AWS resource with the specified ARN.
*
*
* -
*
* UntagResource — Removes tags from the resource with the specified ARN.
*
*
*
*/
@ThreadSafe
@Generated("com.amazonaws:aws-java-sdk-code-generator")
public class AmazonIVSRealTimeAsyncClient extends AmazonIVSRealTimeClient implements AmazonIVSRealTimeAsync {
private static final int DEFAULT_THREAD_POOL_SIZE = 50;
private final java.util.concurrent.ExecutorService executorService;
public static AmazonIVSRealTimeAsyncClientBuilder asyncBuilder() {
return AmazonIVSRealTimeAsyncClientBuilder.standard();
}
/**
* Constructs a new asynchronous client to invoke service methods on ivsrealtime using the specified parameters.
*
* @param asyncClientParams
* Object providing client parameters.
*/
AmazonIVSRealTimeAsyncClient(AwsAsyncClientParams asyncClientParams) {
this(asyncClientParams, false);
}
/**
* Constructs a new asynchronous client to invoke service methods on ivsrealtime using the specified parameters.
*
* @param asyncClientParams
* Object providing client parameters.
* @param endpointDiscoveryEnabled
* true will enable endpoint discovery if the service supports it.
*/
AmazonIVSRealTimeAsyncClient(AwsAsyncClientParams asyncClientParams, boolean endpointDiscoveryEnabled) {
super(asyncClientParams, endpointDiscoveryEnabled);
this.executorService = asyncClientParams.getExecutor();
}
/**
* Returns the executor service used by this client to execute async requests.
*
* @return The executor service used by this client to execute async requests.
*/
public ExecutorService getExecutorService() {
return executorService;
}
@Override
public java.util.concurrent.Future createParticipantTokenAsync(CreateParticipantTokenRequest request) {
return createParticipantTokenAsync(request, null);
}
@Override
public java.util.concurrent.Future createParticipantTokenAsync(final CreateParticipantTokenRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final CreateParticipantTokenRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public CreateParticipantTokenResult call() throws Exception {
CreateParticipantTokenResult result = null;
try {
result = executeCreateParticipantToken(finalRequest);
} catch (Exception ex) {
if (asyncHandler != null) {
asyncHandler.onError(ex);
}
throw ex;
}
if (asyncHandler != null) {
asyncHandler.onSuccess(finalRequest, result);
}
return result;
}
});
}
@Override
public java.util.concurrent.Future createStageAsync(CreateStageRequest request) {
return createStageAsync(request, null);
}
@Override
public java.util.concurrent.Future createStageAsync(final CreateStageRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final CreateStageRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public CreateStageResult call() throws Exception {
CreateStageResult result = null;
try {
result = executeCreateStage(finalRequest);
} catch (Exception ex) {
if (asyncHandler != null) {
asyncHandler.onError(ex);
}
throw ex;
}
if (asyncHandler != null) {
asyncHandler.onSuccess(finalRequest, result);
}
return result;
}
});
}
@Override
public java.util.concurrent.Future deleteStageAsync(DeleteStageRequest request) {
return deleteStageAsync(request, null);
}
@Override
public java.util.concurrent.Future deleteStageAsync(final DeleteStageRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final DeleteStageRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public DeleteStageResult call() throws Exception {
DeleteStageResult result = null;
try {
result = executeDeleteStage(finalRequest);
} catch (Exception ex) {
if (asyncHandler != null) {
asyncHandler.onError(ex);
}
throw ex;
}
if (asyncHandler != null) {
asyncHandler.onSuccess(finalRequest, result);
}
return result;
}
});
}
@Override
public java.util.concurrent.Future disconnectParticipantAsync(DisconnectParticipantRequest request) {
return disconnectParticipantAsync(request, null);
}
@Override
public java.util.concurrent.Future disconnectParticipantAsync(final DisconnectParticipantRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final DisconnectParticipantRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public DisconnectParticipantResult call() throws Exception {
DisconnectParticipantResult result = null;
try {
result = executeDisconnectParticipant(finalRequest);
} catch (Exception ex) {
if (asyncHandler != null) {
asyncHandler.onError(ex);
}
throw ex;
}
if (asyncHandler != null) {
asyncHandler.onSuccess(finalRequest, result);
}
return result;
}
});
}
@Override
public java.util.concurrent.Future getParticipantAsync(GetParticipantRequest request) {
return getParticipantAsync(request, null);
}
@Override
public java.util.concurrent.Future getParticipantAsync(final GetParticipantRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final GetParticipantRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public GetParticipantResult call() throws Exception {
GetParticipantResult result = null;
try {
result = executeGetParticipant(finalRequest);
} catch (Exception ex) {
if (asyncHandler != null) {
asyncHandler.onError(ex);
}
throw ex;
}
if (asyncHandler != null) {
asyncHandler.onSuccess(finalRequest, result);
}
return result;
}
});
}
@Override
public java.util.concurrent.Future getStageAsync(GetStageRequest request) {
return getStageAsync(request, null);
}
@Override
public java.util.concurrent.Future getStageAsync(final GetStageRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final GetStageRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public GetStageResult call() throws Exception {
GetStageResult result = null;
try {
result = executeGetStage(finalRequest);
} catch (Exception ex) {
if (asyncHandler != null) {
asyncHandler.onError(ex);
}
throw ex;
}
if (asyncHandler != null) {
asyncHandler.onSuccess(finalRequest, result);
}
return result;
}
});
}
@Override
public java.util.concurrent.Future getStageSessionAsync(GetStageSessionRequest request) {
return getStageSessionAsync(request, null);
}
@Override
public java.util.concurrent.Future getStageSessionAsync(final GetStageSessionRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final GetStageSessionRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public GetStageSessionResult call() throws Exception {
GetStageSessionResult result = null;
try {
result = executeGetStageSession(finalRequest);
} catch (Exception ex) {
if (asyncHandler != null) {
asyncHandler.onError(ex);
}
throw ex;
}
if (asyncHandler != null) {
asyncHandler.onSuccess(finalRequest, result);
}
return result;
}
});
}
@Override
public java.util.concurrent.Future listParticipantEventsAsync(ListParticipantEventsRequest request) {
return listParticipantEventsAsync(request, null);
}
@Override
public java.util.concurrent.Future listParticipantEventsAsync(final ListParticipantEventsRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final ListParticipantEventsRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public ListParticipantEventsResult call() throws Exception {
ListParticipantEventsResult result = null;
try {
result = executeListParticipantEvents(finalRequest);
} catch (Exception ex) {
if (asyncHandler != null) {
asyncHandler.onError(ex);
}
throw ex;
}
if (asyncHandler != null) {
asyncHandler.onSuccess(finalRequest, result);
}
return result;
}
});
}
@Override
public java.util.concurrent.Future listParticipantsAsync(ListParticipantsRequest request) {
return listParticipantsAsync(request, null);
}
@Override
public java.util.concurrent.Future listParticipantsAsync(final ListParticipantsRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final ListParticipantsRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public ListParticipantsResult call() throws Exception {
ListParticipantsResult result = null;
try {
result = executeListParticipants(finalRequest);
} catch (Exception ex) {
if (asyncHandler != null) {
asyncHandler.onError(ex);
}
throw ex;
}
if (asyncHandler != null) {
asyncHandler.onSuccess(finalRequest, result);
}
return result;
}
});
}
@Override
public java.util.concurrent.Future listStageSessionsAsync(ListStageSessionsRequest request) {
return listStageSessionsAsync(request, null);
}
@Override
public java.util.concurrent.Future listStageSessionsAsync(final ListStageSessionsRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final ListStageSessionsRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public ListStageSessionsResult call() throws Exception {
ListStageSessionsResult result = null;
try {
result = executeListStageSessions(finalRequest);
} catch (Exception ex) {
if (asyncHandler != null) {
asyncHandler.onError(ex);
}
throw ex;
}
if (asyncHandler != null) {
asyncHandler.onSuccess(finalRequest, result);
}
return result;
}
});
}
@Override
public java.util.concurrent.Future listStagesAsync(ListStagesRequest request) {
return listStagesAsync(request, null);
}
@Override
public java.util.concurrent.Future listStagesAsync(final ListStagesRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final ListStagesRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public ListStagesResult call() throws Exception {
ListStagesResult result = null;
try {
result = executeListStages(finalRequest);
} catch (Exception ex) {
if (asyncHandler != null) {
asyncHandler.onError(ex);
}
throw ex;
}
if (asyncHandler != null) {
asyncHandler.onSuccess(finalRequest, result);
}
return result;
}
});
}
@Override
public java.util.concurrent.Future listTagsForResourceAsync(ListTagsForResourceRequest request) {
return listTagsForResourceAsync(request, null);
}
@Override
public java.util.concurrent.Future listTagsForResourceAsync(final ListTagsForResourceRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final ListTagsForResourceRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public ListTagsForResourceResult call() throws Exception {
ListTagsForResourceResult result = null;
try {
result = executeListTagsForResource(finalRequest);
} catch (Exception ex) {
if (asyncHandler != null) {
asyncHandler.onError(ex);
}
throw ex;
}
if (asyncHandler != null) {
asyncHandler.onSuccess(finalRequest, result);
}
return result;
}
});
}
@Override
public java.util.concurrent.Future tagResourceAsync(TagResourceRequest request) {
return tagResourceAsync(request, null);
}
@Override
public java.util.concurrent.Future tagResourceAsync(final TagResourceRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final TagResourceRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public TagResourceResult call() throws Exception {
TagResourceResult result = null;
try {
result = executeTagResource(finalRequest);
} catch (Exception ex) {
if (asyncHandler != null) {
asyncHandler.onError(ex);
}
throw ex;
}
if (asyncHandler != null) {
asyncHandler.onSuccess(finalRequest, result);
}
return result;
}
});
}
@Override
public java.util.concurrent.Future untagResourceAsync(UntagResourceRequest request) {
return untagResourceAsync(request, null);
}
@Override
public java.util.concurrent.Future untagResourceAsync(final UntagResourceRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final UntagResourceRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public UntagResourceResult call() throws Exception {
UntagResourceResult result = null;
try {
result = executeUntagResource(finalRequest);
} catch (Exception ex) {
if (asyncHandler != null) {
asyncHandler.onError(ex);
}
throw ex;
}
if (asyncHandler != null) {
asyncHandler.onSuccess(finalRequest, result);
}
return result;
}
});
}
@Override
public java.util.concurrent.Future updateStageAsync(UpdateStageRequest request) {
return updateStageAsync(request, null);
}
@Override
public java.util.concurrent.Future updateStageAsync(final UpdateStageRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final UpdateStageRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public UpdateStageResult call() throws Exception {
UpdateStageResult result = null;
try {
result = executeUpdateStage(finalRequest);
} catch (Exception ex) {
if (asyncHandler != null) {
asyncHandler.onError(ex);
}
throw ex;
}
if (asyncHandler != null) {
asyncHandler.onSuccess(finalRequest, result);
}
return result;
}
});
}
/**
* Shuts down the client, releasing all managed resources. This includes forcibly terminating all pending
* asynchronous service calls. Clients who wish to give pending asynchronous service calls time to complete should
* call {@code getExecutorService().shutdown()} followed by {@code getExecutorService().awaitTermination()} prior to
* calling this method.
*/
@Override
public void shutdown() {
super.shutdown();
executorService.shutdownNow();
}
}