com.amazonaws.services.detective.AmazonDetectiveAsyncClient Maven / Gradle / Ivy
/*
* Copyright 2015-2020 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.detective;
import javax.annotation.Generated;
import com.amazonaws.services.detective.model.*;
import com.amazonaws.client.AwsAsyncClientParams;
import com.amazonaws.annotation.ThreadSafe;
import java.util.concurrent.ExecutorService;
/**
* Client for accessing Amazon Detective 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.
*
*
* Detective uses machine learning and purpose-built visualizations to help you analyze and investigate security issues
* across your Amazon Web Services (AWS) workloads. Detective automatically extracts time-based events such as login
* attempts, API calls, and network traffic from AWS CloudTrail and Amazon Virtual Private Cloud (Amazon VPC) flow logs.
* It also extracts findings detected by Amazon GuardDuty.
*
*
* The Detective API primarily supports the creation and management of behavior graphs. A behavior graph contains the
* extracted data from a set of member accounts, and is created and managed by a master account.
*
*
* Every behavior graph is specific to a Region. You can only use the API to manage graphs that belong to the Region
* that is associated with the currently selected endpoint.
*
*
* A Detective master account can use the Detective API to do the following:
*
*
* -
*
* Enable and disable Detective. Enabling Detective creates a new behavior graph.
*
*
* -
*
* View the list of member accounts in a behavior graph.
*
*
* -
*
* Add member accounts to a behavior graph.
*
*
* -
*
* Remove member accounts from a behavior graph.
*
*
*
*
* A member account can use the Detective API to do the following:
*
*
* -
*
* View the list of behavior graphs that they are invited to.
*
*
* -
*
* Accept an invitation to contribute to a behavior graph.
*
*
* -
*
* Decline an invitation to contribute to a behavior graph.
*
*
* -
*
* Remove their account from a behavior graph.
*
*
*
*
* All API actions are logged as CloudTrail events. See Logging Detective API
* Calls with CloudTrail.
*
*/
@ThreadSafe
@Generated("com.amazonaws:aws-java-sdk-code-generator")
public class AmazonDetectiveAsyncClient extends AmazonDetectiveClient implements AmazonDetectiveAsync {
private static final int DEFAULT_THREAD_POOL_SIZE = 50;
private final java.util.concurrent.ExecutorService executorService;
public static AmazonDetectiveAsyncClientBuilder asyncBuilder() {
return AmazonDetectiveAsyncClientBuilder.standard();
}
/**
* Constructs a new asynchronous client to invoke service methods on Amazon Detective using the specified
* parameters.
*
* @param asyncClientParams
* Object providing client parameters.
*/
AmazonDetectiveAsyncClient(AwsAsyncClientParams asyncClientParams) {
this(asyncClientParams, false);
}
/**
* Constructs a new asynchronous client to invoke service methods on Amazon Detective using the specified
* parameters.
*
* @param asyncClientParams
* Object providing client parameters.
* @param endpointDiscoveryEnabled
* true will enable endpoint discovery if the service supports it.
*/
AmazonDetectiveAsyncClient(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 acceptInvitationAsync(AcceptInvitationRequest request) {
return acceptInvitationAsync(request, null);
}
@Override
public java.util.concurrent.Future acceptInvitationAsync(final AcceptInvitationRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final AcceptInvitationRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public AcceptInvitationResult call() throws Exception {
AcceptInvitationResult result = null;
try {
result = executeAcceptInvitation(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 createGraphAsync(CreateGraphRequest request) {
return createGraphAsync(request, null);
}
@Override
public java.util.concurrent.Future createGraphAsync(final CreateGraphRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final CreateGraphRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public CreateGraphResult call() throws Exception {
CreateGraphResult result = null;
try {
result = executeCreateGraph(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 createMembersAsync(CreateMembersRequest request) {
return createMembersAsync(request, null);
}
@Override
public java.util.concurrent.Future createMembersAsync(final CreateMembersRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final CreateMembersRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public CreateMembersResult call() throws Exception {
CreateMembersResult result = null;
try {
result = executeCreateMembers(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 deleteGraphAsync(DeleteGraphRequest request) {
return deleteGraphAsync(request, null);
}
@Override
public java.util.concurrent.Future deleteGraphAsync(final DeleteGraphRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final DeleteGraphRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public DeleteGraphResult call() throws Exception {
DeleteGraphResult result = null;
try {
result = executeDeleteGraph(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 deleteMembersAsync(DeleteMembersRequest request) {
return deleteMembersAsync(request, null);
}
@Override
public java.util.concurrent.Future deleteMembersAsync(final DeleteMembersRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final DeleteMembersRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public DeleteMembersResult call() throws Exception {
DeleteMembersResult result = null;
try {
result = executeDeleteMembers(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 disassociateMembershipAsync(DisassociateMembershipRequest request) {
return disassociateMembershipAsync(request, null);
}
@Override
public java.util.concurrent.Future disassociateMembershipAsync(final DisassociateMembershipRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final DisassociateMembershipRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public DisassociateMembershipResult call() throws Exception {
DisassociateMembershipResult result = null;
try {
result = executeDisassociateMembership(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 getMembersAsync(GetMembersRequest request) {
return getMembersAsync(request, null);
}
@Override
public java.util.concurrent.Future getMembersAsync(final GetMembersRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final GetMembersRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public GetMembersResult call() throws Exception {
GetMembersResult result = null;
try {
result = executeGetMembers(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 listGraphsAsync(ListGraphsRequest request) {
return listGraphsAsync(request, null);
}
@Override
public java.util.concurrent.Future listGraphsAsync(final ListGraphsRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final ListGraphsRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public ListGraphsResult call() throws Exception {
ListGraphsResult result = null;
try {
result = executeListGraphs(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 listInvitationsAsync(ListInvitationsRequest request) {
return listInvitationsAsync(request, null);
}
@Override
public java.util.concurrent.Future listInvitationsAsync(final ListInvitationsRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final ListInvitationsRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public ListInvitationsResult call() throws Exception {
ListInvitationsResult result = null;
try {
result = executeListInvitations(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 listMembersAsync(ListMembersRequest request) {
return listMembersAsync(request, null);
}
@Override
public java.util.concurrent.Future listMembersAsync(final ListMembersRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final ListMembersRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public ListMembersResult call() throws Exception {
ListMembersResult result = null;
try {
result = executeListMembers(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 rejectInvitationAsync(RejectInvitationRequest request) {
return rejectInvitationAsync(request, null);
}
@Override
public java.util.concurrent.Future rejectInvitationAsync(final RejectInvitationRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final RejectInvitationRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public RejectInvitationResult call() throws Exception {
RejectInvitationResult result = null;
try {
result = executeRejectInvitation(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 startMonitoringMemberAsync(StartMonitoringMemberRequest request) {
return startMonitoringMemberAsync(request, null);
}
@Override
public java.util.concurrent.Future startMonitoringMemberAsync(final StartMonitoringMemberRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final StartMonitoringMemberRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public StartMonitoringMemberResult call() throws Exception {
StartMonitoringMemberResult result = null;
try {
result = executeStartMonitoringMember(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();
}
}