/* * 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.connectparticipant; import javax.annotation.Generated; import com.amazonaws.services.connectparticipant.model.*; import com.amazonaws.client.AwsAsyncClientParams; import com.amazonaws.annotation.ThreadSafe; import java.util.concurrent.ExecutorService; /** * Client for accessing Amazon Connect Participant 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. *

*

* Amazon Connect is an easy-to-use omnichannel cloud contact center service that enables companies of any size to * deliver superior customer service at a lower cost. Amazon Connect communications capabilities make it easy for * companies to deliver personalized interactions across communication channels, including chat. *

*

* Use the Amazon Connect Participant Service to manage participants (for example, agents, customers, and managers * listening in), and to send messages and events within a chat contact. The APIs in the service enable the following: * sending chat messages, attachment sharing, managing a participant's connection state and message events, and * retrieving chat transcripts. *

*/ @ThreadSafe @Generated("com.amazonaws:aws-java-sdk-code-generator") public class AmazonConnectParticipantAsyncClient extends AmazonConnectParticipantClient implements AmazonConnectParticipantAsync { private static final int DEFAULT_THREAD_POOL_SIZE = 50; private final java.util.concurrent.ExecutorService executorService; public static AmazonConnectParticipantAsyncClientBuilder asyncBuilder() { return AmazonConnectParticipantAsyncClientBuilder.standard(); } /** * Constructs a new asynchronous client to invoke service methods on Amazon Connect Participant using the specified * parameters. * * @param asyncClientParams * Object providing client parameters. */ AmazonConnectParticipantAsyncClient(AwsAsyncClientParams asyncClientParams) { this(asyncClientParams, false); } /** * Constructs a new asynchronous client to invoke service methods on Amazon Connect Participant using the specified * parameters. * * @param asyncClientParams * Object providing client parameters. * @param endpointDiscoveryEnabled * true will enable endpoint discovery if the service supports it. */ AmazonConnectParticipantAsyncClient(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 completeAttachmentUploadAsync(CompleteAttachmentUploadRequest request) { return completeAttachmentUploadAsync(request, null); } @Override public java.util.concurrent.Future completeAttachmentUploadAsync(final CompleteAttachmentUploadRequest request, final com.amazonaws.handlers.AsyncHandler asyncHandler) { final CompleteAttachmentUploadRequest finalRequest = beforeClientExecution(request); return executorService.submit(new java.util.concurrent.Callable() { @Override public CompleteAttachmentUploadResult call() throws Exception { CompleteAttachmentUploadResult result = null; try { result = executeCompleteAttachmentUpload(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 createParticipantConnectionAsync(CreateParticipantConnectionRequest request) { return createParticipantConnectionAsync(request, null); } @Override public java.util.concurrent.Future createParticipantConnectionAsync(final CreateParticipantConnectionRequest request, final com.amazonaws.handlers.AsyncHandler asyncHandler) { final CreateParticipantConnectionRequest finalRequest = beforeClientExecution(request); return executorService.submit(new java.util.concurrent.Callable() { @Override public CreateParticipantConnectionResult call() throws Exception { CreateParticipantConnectionResult result = null; try { result = executeCreateParticipantConnection(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 getAttachmentAsync(GetAttachmentRequest request) { return getAttachmentAsync(request, null); } @Override public java.util.concurrent.Future getAttachmentAsync(final GetAttachmentRequest request, final com.amazonaws.handlers.AsyncHandler asyncHandler) { final GetAttachmentRequest finalRequest = beforeClientExecution(request); return executorService.submit(new java.util.concurrent.Callable() { @Override public GetAttachmentResult call() throws Exception { GetAttachmentResult result = null; try { result = executeGetAttachment(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 getTranscriptAsync(GetTranscriptRequest request) { return getTranscriptAsync(request, null); } @Override public java.util.concurrent.Future getTranscriptAsync(final GetTranscriptRequest request, final com.amazonaws.handlers.AsyncHandler asyncHandler) { final GetTranscriptRequest finalRequest = beforeClientExecution(request); return executorService.submit(new java.util.concurrent.Callable() { @Override public GetTranscriptResult call() throws Exception { GetTranscriptResult result = null; try { result = executeGetTranscript(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 sendEventAsync(SendEventRequest request) { return sendEventAsync(request, null); } @Override public java.util.concurrent.Future sendEventAsync(final SendEventRequest request, final com.amazonaws.handlers.AsyncHandler asyncHandler) { final SendEventRequest finalRequest = beforeClientExecution(request); return executorService.submit(new java.util.concurrent.Callable() { @Override public SendEventResult call() throws Exception { SendEventResult result = null; try { result = executeSendEvent(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 sendMessageAsync(SendMessageRequest request) { return sendMessageAsync(request, null); } @Override public java.util.concurrent.Future sendMessageAsync(final SendMessageRequest request, final com.amazonaws.handlers.AsyncHandler asyncHandler) { final SendMessageRequest finalRequest = beforeClientExecution(request); return executorService.submit(new java.util.concurrent.Callable() { @Override public SendMessageResult call() throws Exception { SendMessageResult result = null; try { result = executeSendMessage(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 startAttachmentUploadAsync(StartAttachmentUploadRequest request) { return startAttachmentUploadAsync(request, null); } @Override public java.util.concurrent.Future startAttachmentUploadAsync(final StartAttachmentUploadRequest request, final com.amazonaws.handlers.AsyncHandler asyncHandler) { final StartAttachmentUploadRequest finalRequest = beforeClientExecution(request); return executorService.submit(new java.util.concurrent.Callable() { @Override public StartAttachmentUploadResult call() throws Exception { StartAttachmentUploadResult result = null; try { result = executeStartAttachmentUpload(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(); } }