
software.amazon.awssdk.services.inspector2.DefaultInspector2AsyncClient Maven / Gradle / Ivy
/*
* Copyright 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 software.amazon.awssdk.services.inspector2;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.function.Consumer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.annotations.SdkInternalApi;
import software.amazon.awssdk.awscore.AwsRequestOverrideConfiguration;
import software.amazon.awssdk.awscore.client.handler.AwsAsyncClientHandler;
import software.amazon.awssdk.awscore.exception.AwsServiceException;
import software.amazon.awssdk.core.ApiName;
import software.amazon.awssdk.core.RequestOverrideConfiguration;
import software.amazon.awssdk.core.client.config.SdkClientConfiguration;
import software.amazon.awssdk.core.client.config.SdkClientOption;
import software.amazon.awssdk.core.client.handler.AsyncClientHandler;
import software.amazon.awssdk.core.client.handler.ClientExecutionParams;
import software.amazon.awssdk.core.http.HttpResponseHandler;
import software.amazon.awssdk.core.metrics.CoreMetric;
import software.amazon.awssdk.core.util.VersionInfo;
import software.amazon.awssdk.metrics.MetricCollector;
import software.amazon.awssdk.metrics.MetricPublisher;
import software.amazon.awssdk.metrics.NoOpMetricCollector;
import software.amazon.awssdk.protocols.core.ExceptionMetadata;
import software.amazon.awssdk.protocols.json.AwsJsonProtocol;
import software.amazon.awssdk.protocols.json.AwsJsonProtocolFactory;
import software.amazon.awssdk.protocols.json.BaseAwsJsonProtocolFactory;
import software.amazon.awssdk.protocols.json.JsonOperationMetadata;
import software.amazon.awssdk.services.inspector2.model.AccessDeniedException;
import software.amazon.awssdk.services.inspector2.model.AssociateMemberRequest;
import software.amazon.awssdk.services.inspector2.model.AssociateMemberResponse;
import software.amazon.awssdk.services.inspector2.model.BadRequestException;
import software.amazon.awssdk.services.inspector2.model.BatchGetAccountStatusRequest;
import software.amazon.awssdk.services.inspector2.model.BatchGetAccountStatusResponse;
import software.amazon.awssdk.services.inspector2.model.BatchGetFreeTrialInfoRequest;
import software.amazon.awssdk.services.inspector2.model.BatchGetFreeTrialInfoResponse;
import software.amazon.awssdk.services.inspector2.model.CancelFindingsReportRequest;
import software.amazon.awssdk.services.inspector2.model.CancelFindingsReportResponse;
import software.amazon.awssdk.services.inspector2.model.ConflictException;
import software.amazon.awssdk.services.inspector2.model.CreateFilterRequest;
import software.amazon.awssdk.services.inspector2.model.CreateFilterResponse;
import software.amazon.awssdk.services.inspector2.model.CreateFindingsReportRequest;
import software.amazon.awssdk.services.inspector2.model.CreateFindingsReportResponse;
import software.amazon.awssdk.services.inspector2.model.DeleteFilterRequest;
import software.amazon.awssdk.services.inspector2.model.DeleteFilterResponse;
import software.amazon.awssdk.services.inspector2.model.DescribeOrganizationConfigurationRequest;
import software.amazon.awssdk.services.inspector2.model.DescribeOrganizationConfigurationResponse;
import software.amazon.awssdk.services.inspector2.model.DisableDelegatedAdminAccountRequest;
import software.amazon.awssdk.services.inspector2.model.DisableDelegatedAdminAccountResponse;
import software.amazon.awssdk.services.inspector2.model.DisableRequest;
import software.amazon.awssdk.services.inspector2.model.DisableResponse;
import software.amazon.awssdk.services.inspector2.model.DisassociateMemberRequest;
import software.amazon.awssdk.services.inspector2.model.DisassociateMemberResponse;
import software.amazon.awssdk.services.inspector2.model.EnableDelegatedAdminAccountRequest;
import software.amazon.awssdk.services.inspector2.model.EnableDelegatedAdminAccountResponse;
import software.amazon.awssdk.services.inspector2.model.EnableRequest;
import software.amazon.awssdk.services.inspector2.model.EnableResponse;
import software.amazon.awssdk.services.inspector2.model.GetConfigurationRequest;
import software.amazon.awssdk.services.inspector2.model.GetConfigurationResponse;
import software.amazon.awssdk.services.inspector2.model.GetDelegatedAdminAccountRequest;
import software.amazon.awssdk.services.inspector2.model.GetDelegatedAdminAccountResponse;
import software.amazon.awssdk.services.inspector2.model.GetFindingsReportStatusRequest;
import software.amazon.awssdk.services.inspector2.model.GetFindingsReportStatusResponse;
import software.amazon.awssdk.services.inspector2.model.GetMemberRequest;
import software.amazon.awssdk.services.inspector2.model.GetMemberResponse;
import software.amazon.awssdk.services.inspector2.model.Inspector2Exception;
import software.amazon.awssdk.services.inspector2.model.Inspector2Request;
import software.amazon.awssdk.services.inspector2.model.InternalServerException;
import software.amazon.awssdk.services.inspector2.model.ListAccountPermissionsRequest;
import software.amazon.awssdk.services.inspector2.model.ListAccountPermissionsResponse;
import software.amazon.awssdk.services.inspector2.model.ListCoverageRequest;
import software.amazon.awssdk.services.inspector2.model.ListCoverageResponse;
import software.amazon.awssdk.services.inspector2.model.ListCoverageStatisticsRequest;
import software.amazon.awssdk.services.inspector2.model.ListCoverageStatisticsResponse;
import software.amazon.awssdk.services.inspector2.model.ListDelegatedAdminAccountsRequest;
import software.amazon.awssdk.services.inspector2.model.ListDelegatedAdminAccountsResponse;
import software.amazon.awssdk.services.inspector2.model.ListFiltersRequest;
import software.amazon.awssdk.services.inspector2.model.ListFiltersResponse;
import software.amazon.awssdk.services.inspector2.model.ListFindingAggregationsRequest;
import software.amazon.awssdk.services.inspector2.model.ListFindingAggregationsResponse;
import software.amazon.awssdk.services.inspector2.model.ListFindingsRequest;
import software.amazon.awssdk.services.inspector2.model.ListFindingsResponse;
import software.amazon.awssdk.services.inspector2.model.ListMembersRequest;
import software.amazon.awssdk.services.inspector2.model.ListMembersResponse;
import software.amazon.awssdk.services.inspector2.model.ListTagsForResourceRequest;
import software.amazon.awssdk.services.inspector2.model.ListTagsForResourceResponse;
import software.amazon.awssdk.services.inspector2.model.ListUsageTotalsRequest;
import software.amazon.awssdk.services.inspector2.model.ListUsageTotalsResponse;
import software.amazon.awssdk.services.inspector2.model.ResourceNotFoundException;
import software.amazon.awssdk.services.inspector2.model.ServiceQuotaExceededException;
import software.amazon.awssdk.services.inspector2.model.TagResourceRequest;
import software.amazon.awssdk.services.inspector2.model.TagResourceResponse;
import software.amazon.awssdk.services.inspector2.model.ThrottlingException;
import software.amazon.awssdk.services.inspector2.model.UntagResourceRequest;
import software.amazon.awssdk.services.inspector2.model.UntagResourceResponse;
import software.amazon.awssdk.services.inspector2.model.UpdateConfigurationRequest;
import software.amazon.awssdk.services.inspector2.model.UpdateConfigurationResponse;
import software.amazon.awssdk.services.inspector2.model.UpdateFilterRequest;
import software.amazon.awssdk.services.inspector2.model.UpdateFilterResponse;
import software.amazon.awssdk.services.inspector2.model.UpdateOrganizationConfigurationRequest;
import software.amazon.awssdk.services.inspector2.model.UpdateOrganizationConfigurationResponse;
import software.amazon.awssdk.services.inspector2.model.ValidationException;
import software.amazon.awssdk.services.inspector2.paginators.ListAccountPermissionsPublisher;
import software.amazon.awssdk.services.inspector2.paginators.ListCoveragePublisher;
import software.amazon.awssdk.services.inspector2.paginators.ListCoverageStatisticsPublisher;
import software.amazon.awssdk.services.inspector2.paginators.ListDelegatedAdminAccountsPublisher;
import software.amazon.awssdk.services.inspector2.paginators.ListFiltersPublisher;
import software.amazon.awssdk.services.inspector2.paginators.ListFindingAggregationsPublisher;
import software.amazon.awssdk.services.inspector2.paginators.ListFindingsPublisher;
import software.amazon.awssdk.services.inspector2.paginators.ListMembersPublisher;
import software.amazon.awssdk.services.inspector2.paginators.ListUsageTotalsPublisher;
import software.amazon.awssdk.services.inspector2.transform.AssociateMemberRequestMarshaller;
import software.amazon.awssdk.services.inspector2.transform.BatchGetAccountStatusRequestMarshaller;
import software.amazon.awssdk.services.inspector2.transform.BatchGetFreeTrialInfoRequestMarshaller;
import software.amazon.awssdk.services.inspector2.transform.CancelFindingsReportRequestMarshaller;
import software.amazon.awssdk.services.inspector2.transform.CreateFilterRequestMarshaller;
import software.amazon.awssdk.services.inspector2.transform.CreateFindingsReportRequestMarshaller;
import software.amazon.awssdk.services.inspector2.transform.DeleteFilterRequestMarshaller;
import software.amazon.awssdk.services.inspector2.transform.DescribeOrganizationConfigurationRequestMarshaller;
import software.amazon.awssdk.services.inspector2.transform.DisableDelegatedAdminAccountRequestMarshaller;
import software.amazon.awssdk.services.inspector2.transform.DisableRequestMarshaller;
import software.amazon.awssdk.services.inspector2.transform.DisassociateMemberRequestMarshaller;
import software.amazon.awssdk.services.inspector2.transform.EnableDelegatedAdminAccountRequestMarshaller;
import software.amazon.awssdk.services.inspector2.transform.EnableRequestMarshaller;
import software.amazon.awssdk.services.inspector2.transform.GetConfigurationRequestMarshaller;
import software.amazon.awssdk.services.inspector2.transform.GetDelegatedAdminAccountRequestMarshaller;
import software.amazon.awssdk.services.inspector2.transform.GetFindingsReportStatusRequestMarshaller;
import software.amazon.awssdk.services.inspector2.transform.GetMemberRequestMarshaller;
import software.amazon.awssdk.services.inspector2.transform.ListAccountPermissionsRequestMarshaller;
import software.amazon.awssdk.services.inspector2.transform.ListCoverageRequestMarshaller;
import software.amazon.awssdk.services.inspector2.transform.ListCoverageStatisticsRequestMarshaller;
import software.amazon.awssdk.services.inspector2.transform.ListDelegatedAdminAccountsRequestMarshaller;
import software.amazon.awssdk.services.inspector2.transform.ListFiltersRequestMarshaller;
import software.amazon.awssdk.services.inspector2.transform.ListFindingAggregationsRequestMarshaller;
import software.amazon.awssdk.services.inspector2.transform.ListFindingsRequestMarshaller;
import software.amazon.awssdk.services.inspector2.transform.ListMembersRequestMarshaller;
import software.amazon.awssdk.services.inspector2.transform.ListTagsForResourceRequestMarshaller;
import software.amazon.awssdk.services.inspector2.transform.ListUsageTotalsRequestMarshaller;
import software.amazon.awssdk.services.inspector2.transform.TagResourceRequestMarshaller;
import software.amazon.awssdk.services.inspector2.transform.UntagResourceRequestMarshaller;
import software.amazon.awssdk.services.inspector2.transform.UpdateConfigurationRequestMarshaller;
import software.amazon.awssdk.services.inspector2.transform.UpdateFilterRequestMarshaller;
import software.amazon.awssdk.services.inspector2.transform.UpdateOrganizationConfigurationRequestMarshaller;
import software.amazon.awssdk.utils.CompletableFutureUtils;
/**
* Internal implementation of {@link Inspector2AsyncClient}.
*
* @see Inspector2AsyncClient#builder()
*/
@Generated("software.amazon.awssdk:codegen")
@SdkInternalApi
final class DefaultInspector2AsyncClient implements Inspector2AsyncClient {
private static final Logger log = LoggerFactory.getLogger(DefaultInspector2AsyncClient.class);
private final AsyncClientHandler clientHandler;
private final AwsJsonProtocolFactory protocolFactory;
private final SdkClientConfiguration clientConfiguration;
protected DefaultInspector2AsyncClient(SdkClientConfiguration clientConfiguration) {
this.clientHandler = new AwsAsyncClientHandler(clientConfiguration);
this.clientConfiguration = clientConfiguration;
this.protocolFactory = init(AwsJsonProtocolFactory.builder()).build();
}
@Override
public final String serviceName() {
return SERVICE_NAME;
}
/**
*
* Associates an Amazon Web Services account with an Amazon Inspector delegated administrator.
*
*
* @param associateMemberRequest
* @return A Java Future containing the result of the AssociateMember operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - ValidationException The request has failed validation due to missing required fields or having
* invalid inputs.
* - AccessDeniedException You do not have sufficient access to perform this action.
* - ThrottlingException The limit on the number of requests per second was exceeded.
* - InternalServerException The request has failed due to an internal failure of the Amazon Inspector
* service.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - Inspector2Exception Base class for all service exceptions. Unknown exceptions will be thrown as an
* instance of this type.
*
* @sample Inspector2AsyncClient.AssociateMember
* @see AWS
* API Documentation
*/
@Override
public CompletableFuture associateMember(AssociateMemberRequest associateMemberRequest) {
List metricPublishers = resolveMetricPublishers(clientConfiguration, associateMemberRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Inspector2");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "AssociateMember");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, AssociateMemberResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("AssociateMember")
.withMarshaller(new AssociateMemberRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withMetricCollector(apiCallMetricCollector).withInput(associateMemberRequest));
CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Retrieves the Amazon Inspector status of multiple Amazon Web Services accounts within your environment.
*
*
* @param batchGetAccountStatusRequest
* @return A Java Future containing the result of the BatchGetAccountStatus operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - ValidationException The request has failed validation due to missing required fields or having
* invalid inputs.
* - AccessDeniedException You do not have sufficient access to perform this action.
* - ResourceNotFoundException The operation tried to access an invalid resource. Make sure the resource
* is specified correctly.
* - ThrottlingException The limit on the number of requests per second was exceeded.
* - InternalServerException The request has failed due to an internal failure of the Amazon Inspector
* service.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - Inspector2Exception Base class for all service exceptions. Unknown exceptions will be thrown as an
* instance of this type.
*
* @sample Inspector2AsyncClient.BatchGetAccountStatus
* @see AWS API Documentation
*/
@Override
public CompletableFuture batchGetAccountStatus(
BatchGetAccountStatusRequest batchGetAccountStatusRequest) {
List metricPublishers = resolveMetricPublishers(clientConfiguration, batchGetAccountStatusRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Inspector2");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "BatchGetAccountStatus");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, BatchGetAccountStatusResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("BatchGetAccountStatus")
.withMarshaller(new BatchGetAccountStatusRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withMetricCollector(apiCallMetricCollector).withInput(batchGetAccountStatusRequest));
CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Gets free trial status for multiple Amazon Web Services accounts.
*
*
* @param batchGetFreeTrialInfoRequest
* @return A Java Future containing the result of the BatchGetFreeTrialInfo operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - ValidationException The request has failed validation due to missing required fields or having
* invalid inputs.
* - AccessDeniedException You do not have sufficient access to perform this action.
* - ThrottlingException The limit on the number of requests per second was exceeded.
* - InternalServerException The request has failed due to an internal failure of the Amazon Inspector
* service.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - Inspector2Exception Base class for all service exceptions. Unknown exceptions will be thrown as an
* instance of this type.
*
* @sample Inspector2AsyncClient.BatchGetFreeTrialInfo
* @see AWS API Documentation
*/
@Override
public CompletableFuture batchGetFreeTrialInfo(
BatchGetFreeTrialInfoRequest batchGetFreeTrialInfoRequest) {
List metricPublishers = resolveMetricPublishers(clientConfiguration, batchGetFreeTrialInfoRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Inspector2");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "BatchGetFreeTrialInfo");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, BatchGetFreeTrialInfoResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("BatchGetFreeTrialInfo")
.withMarshaller(new BatchGetFreeTrialInfoRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withMetricCollector(apiCallMetricCollector).withInput(batchGetFreeTrialInfoRequest));
CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Cancels the given findings report.
*
*
* @param cancelFindingsReportRequest
* @return A Java Future containing the result of the CancelFindingsReport operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - ValidationException The request has failed validation due to missing required fields or having
* invalid inputs.
* - AccessDeniedException You do not have sufficient access to perform this action.
* - ResourceNotFoundException The operation tried to access an invalid resource. Make sure the resource
* is specified correctly.
* - ThrottlingException The limit on the number of requests per second was exceeded.
* - InternalServerException The request has failed due to an internal failure of the Amazon Inspector
* service.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - Inspector2Exception Base class for all service exceptions. Unknown exceptions will be thrown as an
* instance of this type.
*
* @sample Inspector2AsyncClient.CancelFindingsReport
* @see AWS API Documentation
*/
@Override
public CompletableFuture cancelFindingsReport(
CancelFindingsReportRequest cancelFindingsReportRequest) {
List metricPublishers = resolveMetricPublishers(clientConfiguration, cancelFindingsReportRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Inspector2");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "CancelFindingsReport");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, CancelFindingsReportResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("CancelFindingsReport")
.withMarshaller(new CancelFindingsReportRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withMetricCollector(apiCallMetricCollector).withInput(cancelFindingsReportRequest));
CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Creates a filter resource using specified filter criteria.
*
*
* @param createFilterRequest
* @return A Java Future containing the result of the CreateFilter operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - ServiceQuotaExceededException You have exceeded your service quota. To perform the requested action,
* remove some of the relevant resources, or use Service Quotas to request a service quota increase.
* - BadRequestException One or more tags submitted as part of the request is not valid.
* - ValidationException The request has failed validation due to missing required fields or having
* invalid inputs.
* - AccessDeniedException You do not have sufficient access to perform this action.
* - ThrottlingException The limit on the number of requests per second was exceeded.
* - InternalServerException The request has failed due to an internal failure of the Amazon Inspector
* service.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - Inspector2Exception Base class for all service exceptions. Unknown exceptions will be thrown as an
* instance of this type.
*
* @sample Inspector2AsyncClient.CreateFilter
* @see AWS API
* Documentation
*/
@Override
public CompletableFuture createFilter(CreateFilterRequest createFilterRequest) {
List metricPublishers = resolveMetricPublishers(clientConfiguration, createFilterRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Inspector2");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "CreateFilter");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
CreateFilterResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("CreateFilter").withMarshaller(new CreateFilterRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withMetricCollector(apiCallMetricCollector).withInput(createFilterRequest));
CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Creates a finding report.
*
*
* @param createFindingsReportRequest
* @return A Java Future containing the result of the CreateFindingsReport operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - ValidationException The request has failed validation due to missing required fields or having
* invalid inputs.
* - AccessDeniedException You do not have sufficient access to perform this action.
* - ResourceNotFoundException The operation tried to access an invalid resource. Make sure the resource
* is specified correctly.
* - ThrottlingException The limit on the number of requests per second was exceeded.
* - InternalServerException The request has failed due to an internal failure of the Amazon Inspector
* service.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - Inspector2Exception Base class for all service exceptions. Unknown exceptions will be thrown as an
* instance of this type.
*
* @sample Inspector2AsyncClient.CreateFindingsReport
* @see AWS API Documentation
*/
@Override
public CompletableFuture createFindingsReport(
CreateFindingsReportRequest createFindingsReportRequest) {
List metricPublishers = resolveMetricPublishers(clientConfiguration, createFindingsReportRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Inspector2");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "CreateFindingsReport");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, CreateFindingsReportResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("CreateFindingsReport")
.withMarshaller(new CreateFindingsReportRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withMetricCollector(apiCallMetricCollector).withInput(createFindingsReportRequest));
CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Deletes a filter resource.
*
*
* @param deleteFilterRequest
* @return A Java Future containing the result of the DeleteFilter operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - ValidationException The request has failed validation due to missing required fields or having
* invalid inputs.
* - AccessDeniedException You do not have sufficient access to perform this action.
* - ResourceNotFoundException The operation tried to access an invalid resource. Make sure the resource
* is specified correctly.
* - ThrottlingException The limit on the number of requests per second was exceeded.
* - InternalServerException The request has failed due to an internal failure of the Amazon Inspector
* service.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - Inspector2Exception Base class for all service exceptions. Unknown exceptions will be thrown as an
* instance of this type.
*
* @sample Inspector2AsyncClient.DeleteFilter
* @see AWS API
* Documentation
*/
@Override
public CompletableFuture deleteFilter(DeleteFilterRequest deleteFilterRequest) {
List metricPublishers = resolveMetricPublishers(clientConfiguration, deleteFilterRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Inspector2");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "DeleteFilter");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
DeleteFilterResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("DeleteFilter").withMarshaller(new DeleteFilterRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withMetricCollector(apiCallMetricCollector).withInput(deleteFilterRequest));
CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Describe Amazon Inspector configuration settings for an Amazon Web Services organization.
*
*
* @param describeOrganizationConfigurationRequest
* @return A Java Future containing the result of the DescribeOrganizationConfiguration operation returned by the
* service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - ValidationException The request has failed validation due to missing required fields or having
* invalid inputs.
* - AccessDeniedException You do not have sufficient access to perform this action.
* - ThrottlingException The limit on the number of requests per second was exceeded.
* - InternalServerException The request has failed due to an internal failure of the Amazon Inspector
* service.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - Inspector2Exception Base class for all service exceptions. Unknown exceptions will be thrown as an
* instance of this type.
*
* @sample Inspector2AsyncClient.DescribeOrganizationConfiguration
* @see AWS API Documentation
*/
@Override
public CompletableFuture describeOrganizationConfiguration(
DescribeOrganizationConfigurationRequest describeOrganizationConfigurationRequest) {
List metricPublishers = resolveMetricPublishers(clientConfiguration,
describeOrganizationConfigurationRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Inspector2");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "DescribeOrganizationConfiguration");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory
.createResponseHandler(operationMetadata, DescribeOrganizationConfigurationResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("DescribeOrganizationConfiguration")
.withMarshaller(new DescribeOrganizationConfigurationRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withMetricCollector(apiCallMetricCollector).withInput(describeOrganizationConfigurationRequest));
CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Disables Amazon Inspector scans for one or more Amazon Web Services accounts. Disabling all scan types in an
* account disables the Amazon Inspector service.
*
*
* @param disableRequest
* @return A Java Future containing the result of the Disable operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - ValidationException The request has failed validation due to missing required fields or having
* invalid inputs.
* - AccessDeniedException You do not have sufficient access to perform this action.
* - ResourceNotFoundException The operation tried to access an invalid resource. Make sure the resource
* is specified correctly.
* - ThrottlingException The limit on the number of requests per second was exceeded.
* - InternalServerException The request has failed due to an internal failure of the Amazon Inspector
* service.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - Inspector2Exception Base class for all service exceptions. Unknown exceptions will be thrown as an
* instance of this type.
*
* @sample Inspector2AsyncClient.Disable
* @see AWS API
* Documentation
*/
@Override
public CompletableFuture disable(DisableRequest disableRequest) {
List metricPublishers = resolveMetricPublishers(clientConfiguration, disableRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Inspector2");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "Disable");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
DisableResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams().withOperationName("Disable")
.withMarshaller(new DisableRequestMarshaller(protocolFactory)).withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler).withMetricCollector(apiCallMetricCollector)
.withInput(disableRequest));
CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Disables the Amazon Inspector delegated administrator for your organization.
*
*
* @param disableDelegatedAdminAccountRequest
* @return A Java Future containing the result of the DisableDelegatedAdminAccount operation returned by the
* service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - ConflictException A conflict occurred.
* - ValidationException The request has failed validation due to missing required fields or having
* invalid inputs.
* - AccessDeniedException You do not have sufficient access to perform this action.
* - ResourceNotFoundException The operation tried to access an invalid resource. Make sure the resource
* is specified correctly.
* - ThrottlingException The limit on the number of requests per second was exceeded.
* - InternalServerException The request has failed due to an internal failure of the Amazon Inspector
* service.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - Inspector2Exception Base class for all service exceptions. Unknown exceptions will be thrown as an
* instance of this type.
*
* @sample Inspector2AsyncClient.DisableDelegatedAdminAccount
* @see AWS API Documentation
*/
@Override
public CompletableFuture disableDelegatedAdminAccount(
DisableDelegatedAdminAccountRequest disableDelegatedAdminAccountRequest) {
List metricPublishers = resolveMetricPublishers(clientConfiguration, disableDelegatedAdminAccountRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Inspector2");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "DisableDelegatedAdminAccount");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, DisableDelegatedAdminAccountResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("DisableDelegatedAdminAccount")
.withMarshaller(new DisableDelegatedAdminAccountRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withMetricCollector(apiCallMetricCollector).withInput(disableDelegatedAdminAccountRequest));
CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Disassociates a member account from an Amazon Inspector delegated administrator.
*
*
* @param disassociateMemberRequest
* @return A Java Future containing the result of the DisassociateMember operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - ValidationException The request has failed validation due to missing required fields or having
* invalid inputs.
* - AccessDeniedException You do not have sufficient access to perform this action.
* - ThrottlingException The limit on the number of requests per second was exceeded.
* - InternalServerException The request has failed due to an internal failure of the Amazon Inspector
* service.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - Inspector2Exception Base class for all service exceptions. Unknown exceptions will be thrown as an
* instance of this type.
*
* @sample Inspector2AsyncClient.DisassociateMember
* @see AWS
* API Documentation
*/
@Override
public CompletableFuture disassociateMember(DisassociateMemberRequest disassociateMemberRequest) {
List metricPublishers = resolveMetricPublishers(clientConfiguration, disassociateMemberRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Inspector2");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "DisassociateMember");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, DisassociateMemberResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("DisassociateMember")
.withMarshaller(new DisassociateMemberRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withMetricCollector(apiCallMetricCollector).withInput(disassociateMemberRequest));
CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Enables Amazon Inspector scans for one or more Amazon Web Services accounts.
*
*
* @param enableRequest
* @return A Java Future containing the result of the Enable operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - ValidationException The request has failed validation due to missing required fields or having
* invalid inputs.
* - AccessDeniedException You do not have sufficient access to perform this action.
* - ResourceNotFoundException The operation tried to access an invalid resource. Make sure the resource
* is specified correctly.
* - ThrottlingException The limit on the number of requests per second was exceeded.
* - InternalServerException The request has failed due to an internal failure of the Amazon Inspector
* service.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - Inspector2Exception Base class for all service exceptions. Unknown exceptions will be thrown as an
* instance of this type.
*
* @sample Inspector2AsyncClient.Enable
* @see AWS API
* Documentation
*/
@Override
public CompletableFuture enable(EnableRequest enableRequest) {
List metricPublishers = resolveMetricPublishers(clientConfiguration, enableRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Inspector2");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "Enable");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
EnableResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams().withOperationName("Enable")
.withMarshaller(new EnableRequestMarshaller(protocolFactory)).withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler).withMetricCollector(apiCallMetricCollector)
.withInput(enableRequest));
CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Enables the Amazon Inspector delegated administrator for your Organizations organization.
*
*
* @param enableDelegatedAdminAccountRequest
* @return A Java Future containing the result of the EnableDelegatedAdminAccount operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - ConflictException A conflict occurred.
* - ValidationException The request has failed validation due to missing required fields or having
* invalid inputs.
* - AccessDeniedException You do not have sufficient access to perform this action.
* - ResourceNotFoundException The operation tried to access an invalid resource. Make sure the resource
* is specified correctly.
* - ThrottlingException The limit on the number of requests per second was exceeded.
* - InternalServerException The request has failed due to an internal failure of the Amazon Inspector
* service.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - Inspector2Exception Base class for all service exceptions. Unknown exceptions will be thrown as an
* instance of this type.
*
* @sample Inspector2AsyncClient.EnableDelegatedAdminAccount
* @see AWS API Documentation
*/
@Override
public CompletableFuture enableDelegatedAdminAccount(
EnableDelegatedAdminAccountRequest enableDelegatedAdminAccountRequest) {
List metricPublishers = resolveMetricPublishers(clientConfiguration, enableDelegatedAdminAccountRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Inspector2");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "EnableDelegatedAdminAccount");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, EnableDelegatedAdminAccountResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("EnableDelegatedAdminAccount")
.withMarshaller(new EnableDelegatedAdminAccountRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withMetricCollector(apiCallMetricCollector).withInput(enableDelegatedAdminAccountRequest));
CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Retrieves setting configurations for Inspector scans.
*
*
* @param getConfigurationRequest
* @return A Java Future containing the result of the GetConfiguration operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - ResourceNotFoundException The operation tried to access an invalid resource. Make sure the resource
* is specified correctly.
* - ThrottlingException The limit on the number of requests per second was exceeded.
* - InternalServerException The request has failed due to an internal failure of the Amazon Inspector
* service.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - Inspector2Exception Base class for all service exceptions. Unknown exceptions will be thrown as an
* instance of this type.
*
* @sample Inspector2AsyncClient.GetConfiguration
* @see AWS
* API Documentation
*/
@Override
public CompletableFuture getConfiguration(GetConfigurationRequest getConfigurationRequest) {
List metricPublishers = resolveMetricPublishers(clientConfiguration, getConfigurationRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Inspector2");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetConfiguration");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, GetConfigurationResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("GetConfiguration")
.withMarshaller(new GetConfigurationRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withMetricCollector(apiCallMetricCollector).withInput(getConfigurationRequest));
CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Retrieves information about the Amazon Inspector delegated administrator for your organization.
*
*
* @param getDelegatedAdminAccountRequest
* @return A Java Future containing the result of the GetDelegatedAdminAccount operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - AccessDeniedException You do not have sufficient access to perform this action.
* - ValidationException The request has failed validation due to missing required fields or having
* invalid inputs.
* - ResourceNotFoundException The operation tried to access an invalid resource. Make sure the resource
* is specified correctly.
* - ThrottlingException The limit on the number of requests per second was exceeded.
* - InternalServerException The request has failed due to an internal failure of the Amazon Inspector
* service.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - Inspector2Exception Base class for all service exceptions. Unknown exceptions will be thrown as an
* instance of this type.
*
* @sample Inspector2AsyncClient.GetDelegatedAdminAccount
* @see AWS API Documentation
*/
@Override
public CompletableFuture getDelegatedAdminAccount(
GetDelegatedAdminAccountRequest getDelegatedAdminAccountRequest) {
List metricPublishers = resolveMetricPublishers(clientConfiguration, getDelegatedAdminAccountRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Inspector2");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetDelegatedAdminAccount");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, GetDelegatedAdminAccountResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("GetDelegatedAdminAccount")
.withMarshaller(new GetDelegatedAdminAccountRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withMetricCollector(apiCallMetricCollector).withInput(getDelegatedAdminAccountRequest));
CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Gets the status of a findings report.
*
*
* @param getFindingsReportStatusRequest
* @return A Java Future containing the result of the GetFindingsReportStatus operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - ValidationException The request has failed validation due to missing required fields or having
* invalid inputs.
* - AccessDeniedException You do not have sufficient access to perform this action.
* - ResourceNotFoundException The operation tried to access an invalid resource. Make sure the resource
* is specified correctly.
* - ThrottlingException The limit on the number of requests per second was exceeded.
* - InternalServerException The request has failed due to an internal failure of the Amazon Inspector
* service.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - Inspector2Exception Base class for all service exceptions. Unknown exceptions will be thrown as an
* instance of this type.
*
* @sample Inspector2AsyncClient.GetFindingsReportStatus
* @see AWS API Documentation
*/
@Override
public CompletableFuture getFindingsReportStatus(
GetFindingsReportStatusRequest getFindingsReportStatusRequest) {
List metricPublishers = resolveMetricPublishers(clientConfiguration, getFindingsReportStatusRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Inspector2");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetFindingsReportStatus");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, GetFindingsReportStatusResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("GetFindingsReportStatus")
.withMarshaller(new GetFindingsReportStatusRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withMetricCollector(apiCallMetricCollector).withInput(getFindingsReportStatusRequest));
CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Gets member information for your organization.
*
*
* @param getMemberRequest
* @return A Java Future containing the result of the GetMember operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - ValidationException The request has failed validation due to missing required fields or having
* invalid inputs.
* - AccessDeniedException You do not have sufficient access to perform this action.
* - ResourceNotFoundException The operation tried to access an invalid resource. Make sure the resource
* is specified correctly.
* - ThrottlingException The limit on the number of requests per second was exceeded.
* - InternalServerException The request has failed due to an internal failure of the Amazon Inspector
* service.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - Inspector2Exception Base class for all service exceptions. Unknown exceptions will be thrown as an
* instance of this type.
*
* @sample Inspector2AsyncClient.GetMember
* @see AWS API
* Documentation
*/
@Override
public CompletableFuture getMember(GetMemberRequest getMemberRequest) {
List metricPublishers = resolveMetricPublishers(clientConfiguration, getMemberRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Inspector2");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetMember");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
GetMemberResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams().withOperationName("GetMember")
.withMarshaller(new GetMemberRequestMarshaller(protocolFactory)).withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler).withMetricCollector(apiCallMetricCollector)
.withInput(getMemberRequest));
CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Lists the permissions an account has to configure Amazon Inspector.
*
*
* @param listAccountPermissionsRequest
* @return A Java Future containing the result of the ListAccountPermissions operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - ValidationException The request has failed validation due to missing required fields or having
* invalid inputs.
* - AccessDeniedException You do not have sufficient access to perform this action.
* - ThrottlingException The limit on the number of requests per second was exceeded.
* - InternalServerException The request has failed due to an internal failure of the Amazon Inspector
* service.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - Inspector2Exception Base class for all service exceptions. Unknown exceptions will be thrown as an
* instance of this type.
*
* @sample Inspector2AsyncClient.ListAccountPermissions
* @see AWS API Documentation
*/
@Override
public CompletableFuture listAccountPermissions(
ListAccountPermissionsRequest listAccountPermissionsRequest) {
List metricPublishers = resolveMetricPublishers(clientConfiguration, listAccountPermissionsRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Inspector2");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ListAccountPermissions");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, ListAccountPermissionsResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("ListAccountPermissions")
.withMarshaller(new ListAccountPermissionsRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withMetricCollector(apiCallMetricCollector).withInput(listAccountPermissionsRequest));
CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Lists the permissions an account has to configure Amazon Inspector.
*
*
*
* This is a variant of
* {@link #listAccountPermissions(software.amazon.awssdk.services.inspector2.model.ListAccountPermissionsRequest)}
* operation. The return type is a custom publisher that can be subscribed to request a stream of response pages.
* SDK will internally handle making service calls for you.
*
*
* When the operation is called, an instance of this class is returned. At this point, no service calls are made yet
* and so there is no guarantee that the request is valid. If there are errors in your request, you will see the
* failures only after you start streaming the data. The subscribe method should be called as a request to start
* streaming data. For more info, see
* {@link org.reactivestreams.Publisher#subscribe(org.reactivestreams.Subscriber)}. Each call to the subscribe
* method will result in a new {@link org.reactivestreams.Subscription} i.e., a new contract to stream data from the
* starting request.
*
*
*
* The following are few ways to use the response class:
*
* 1) Using the subscribe helper method
*
*
* {@code
* software.amazon.awssdk.services.inspector2.paginators.ListAccountPermissionsPublisher publisher = client.listAccountPermissionsPaginator(request);
* CompletableFuture future = publisher.subscribe(res -> { // Do something with the response });
* future.get();
* }
*
*
* 2) Using a custom subscriber
*
*
* {@code
* software.amazon.awssdk.services.inspector2.paginators.ListAccountPermissionsPublisher publisher = client.listAccountPermissionsPaginator(request);
* publisher.subscribe(new Subscriber() {
*
* public void onSubscribe(org.reactivestreams.Subscriber subscription) { //... };
*
*
* public void onNext(software.amazon.awssdk.services.inspector2.model.ListAccountPermissionsResponse response) { //... };
* });}
*
*
* As the response is a publisher, it can work well with third party reactive streams implementations like RxJava2.
*
* Please notice that the configuration of maxResults won't limit the number of results you get with the
* paginator. It only limits the number of results in each page.
*
*
* Note: If you prefer to have control on service calls, use the
* {@link #listAccountPermissions(software.amazon.awssdk.services.inspector2.model.ListAccountPermissionsRequest)}
* operation.
*
*
* @param listAccountPermissionsRequest
* @return A custom publisher that can be subscribed to request a stream of response pages.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - ValidationException The request has failed validation due to missing required fields or having
* invalid inputs.
* - AccessDeniedException You do not have sufficient access to perform this action.
* - ThrottlingException The limit on the number of requests per second was exceeded.
* - InternalServerException The request has failed due to an internal failure of the Amazon Inspector
* service.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - Inspector2Exception Base class for all service exceptions. Unknown exceptions will be thrown as an
* instance of this type.
*
* @sample Inspector2AsyncClient.ListAccountPermissions
* @see AWS API Documentation
*/
public ListAccountPermissionsPublisher listAccountPermissionsPaginator(
ListAccountPermissionsRequest listAccountPermissionsRequest) {
return new ListAccountPermissionsPublisher(this, applyPaginatorUserAgent(listAccountPermissionsRequest));
}
/**
*
* Lists coverage details for you environment.
*
*
* @param listCoverageRequest
* @return A Java Future containing the result of the ListCoverage operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - ValidationException The request has failed validation due to missing required fields or having
* invalid inputs.
* - ThrottlingException The limit on the number of requests per second was exceeded.
* - InternalServerException The request has failed due to an internal failure of the Amazon Inspector
* service.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - Inspector2Exception Base class for all service exceptions. Unknown exceptions will be thrown as an
* instance of this type.
*
* @sample Inspector2AsyncClient.ListCoverage
* @see AWS API
* Documentation
*/
@Override
public CompletableFuture listCoverage(ListCoverageRequest listCoverageRequest) {
List metricPublishers = resolveMetricPublishers(clientConfiguration, listCoverageRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Inspector2");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ListCoverage");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
ListCoverageResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("ListCoverage").withMarshaller(new ListCoverageRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withMetricCollector(apiCallMetricCollector).withInput(listCoverageRequest));
CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Lists coverage details for you environment.
*
*
*
* This is a variant of {@link #listCoverage(software.amazon.awssdk.services.inspector2.model.ListCoverageRequest)}
* operation. The return type is a custom publisher that can be subscribed to request a stream of response pages.
* SDK will internally handle making service calls for you.
*
*
* When the operation is called, an instance of this class is returned. At this point, no service calls are made yet
* and so there is no guarantee that the request is valid. If there are errors in your request, you will see the
* failures only after you start streaming the data. The subscribe method should be called as a request to start
* streaming data. For more info, see
* {@link org.reactivestreams.Publisher#subscribe(org.reactivestreams.Subscriber)}. Each call to the subscribe
* method will result in a new {@link org.reactivestreams.Subscription} i.e., a new contract to stream data from the
* starting request.
*
*
*
* The following are few ways to use the response class:
*
* 1) Using the subscribe helper method
*
*
* {@code
* software.amazon.awssdk.services.inspector2.paginators.ListCoveragePublisher publisher = client.listCoveragePaginator(request);
* CompletableFuture future = publisher.subscribe(res -> { // Do something with the response });
* future.get();
* }
*
*
* 2) Using a custom subscriber
*
*
* {@code
* software.amazon.awssdk.services.inspector2.paginators.ListCoveragePublisher publisher = client.listCoveragePaginator(request);
* publisher.subscribe(new Subscriber() {
*
* public void onSubscribe(org.reactivestreams.Subscriber subscription) { //... };
*
*
* public void onNext(software.amazon.awssdk.services.inspector2.model.ListCoverageResponse response) { //... };
* });}
*
*
* As the response is a publisher, it can work well with third party reactive streams implementations like RxJava2.
*
* Please notice that the configuration of maxResults won't limit the number of results you get with the
* paginator. It only limits the number of results in each page.
*
*
* Note: If you prefer to have control on service calls, use the
* {@link #listCoverage(software.amazon.awssdk.services.inspector2.model.ListCoverageRequest)} operation.
*
*
* @param listCoverageRequest
* @return A custom publisher that can be subscribed to request a stream of response pages.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - ValidationException The request has failed validation due to missing required fields or having
* invalid inputs.
* - ThrottlingException The limit on the number of requests per second was exceeded.
* - InternalServerException The request has failed due to an internal failure of the Amazon Inspector
* service.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - Inspector2Exception Base class for all service exceptions. Unknown exceptions will be thrown as an
* instance of this type.
*
* @sample Inspector2AsyncClient.ListCoverage
* @see AWS API
* Documentation
*/
public ListCoveragePublisher listCoveragePaginator(ListCoverageRequest listCoverageRequest) {
return new ListCoveragePublisher(this, applyPaginatorUserAgent(listCoverageRequest));
}
/**
*
* Lists Amazon Inspector coverage statistics for your environment.
*
*
* @param listCoverageStatisticsRequest
* @return A Java Future containing the result of the ListCoverageStatistics operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - ValidationException The request has failed validation due to missing required fields or having
* invalid inputs.
* - ThrottlingException The limit on the number of requests per second was exceeded.
* - InternalServerException The request has failed due to an internal failure of the Amazon Inspector
* service.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - Inspector2Exception Base class for all service exceptions. Unknown exceptions will be thrown as an
* instance of this type.
*
* @sample Inspector2AsyncClient.ListCoverageStatistics
* @see AWS API Documentation
*/
@Override
public CompletableFuture listCoverageStatistics(
ListCoverageStatisticsRequest listCoverageStatisticsRequest) {
List metricPublishers = resolveMetricPublishers(clientConfiguration, listCoverageStatisticsRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Inspector2");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ListCoverageStatistics");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, ListCoverageStatisticsResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("ListCoverageStatistics")
.withMarshaller(new ListCoverageStatisticsRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withMetricCollector(apiCallMetricCollector).withInput(listCoverageStatisticsRequest));
CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Lists Amazon Inspector coverage statistics for your environment.
*
*
*
* This is a variant of
* {@link #listCoverageStatistics(software.amazon.awssdk.services.inspector2.model.ListCoverageStatisticsRequest)}
* operation. The return type is a custom publisher that can be subscribed to request a stream of response pages.
* SDK will internally handle making service calls for you.
*
*
* When the operation is called, an instance of this class is returned. At this point, no service calls are made yet
* and so there is no guarantee that the request is valid. If there are errors in your request, you will see the
* failures only after you start streaming the data. The subscribe method should be called as a request to start
* streaming data. For more info, see
* {@link org.reactivestreams.Publisher#subscribe(org.reactivestreams.Subscriber)}. Each call to the subscribe
* method will result in a new {@link org.reactivestreams.Subscription} i.e., a new contract to stream data from the
* starting request.
*
*
*
* The following are few ways to use the response class:
*
* 1) Using the subscribe helper method
*
*
* {@code
* software.amazon.awssdk.services.inspector2.paginators.ListCoverageStatisticsPublisher publisher = client.listCoverageStatisticsPaginator(request);
* CompletableFuture future = publisher.subscribe(res -> { // Do something with the response });
* future.get();
* }
*
*
* 2) Using a custom subscriber
*
*
* {@code
* software.amazon.awssdk.services.inspector2.paginators.ListCoverageStatisticsPublisher publisher = client.listCoverageStatisticsPaginator(request);
* publisher.subscribe(new Subscriber() {
*
* public void onSubscribe(org.reactivestreams.Subscriber subscription) { //... };
*
*
* public void onNext(software.amazon.awssdk.services.inspector2.model.ListCoverageStatisticsResponse response) { //... };
* });}
*
*
* As the response is a publisher, it can work well with third party reactive streams implementations like RxJava2.
*
* Please notice that the configuration of null won't limit the number of results you get with the paginator. It
* only limits the number of results in each page.
*
*
* Note: If you prefer to have control on service calls, use the
* {@link #listCoverageStatistics(software.amazon.awssdk.services.inspector2.model.ListCoverageStatisticsRequest)}
* operation.
*
*
* @param listCoverageStatisticsRequest
* @return A custom publisher that can be subscribed to request a stream of response pages.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - ValidationException The request has failed validation due to missing required fields or having
* invalid inputs.
* - ThrottlingException The limit on the number of requests per second was exceeded.
* - InternalServerException The request has failed due to an internal failure of the Amazon Inspector
* service.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - Inspector2Exception Base class for all service exceptions. Unknown exceptions will be thrown as an
* instance of this type.
*
* @sample Inspector2AsyncClient.ListCoverageStatistics
* @see AWS API Documentation
*/
public ListCoverageStatisticsPublisher listCoverageStatisticsPaginator(
ListCoverageStatisticsRequest listCoverageStatisticsRequest) {
return new ListCoverageStatisticsPublisher(this, applyPaginatorUserAgent(listCoverageStatisticsRequest));
}
/**
*
* Lists information about the Amazon Inspector delegated administrator of your organization.
*
*
* @param listDelegatedAdminAccountsRequest
* @return A Java Future containing the result of the ListDelegatedAdminAccounts operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - ValidationException The request has failed validation due to missing required fields or having
* invalid inputs.
* - AccessDeniedException You do not have sufficient access to perform this action.
* - ThrottlingException The limit on the number of requests per second was exceeded.
* - InternalServerException The request has failed due to an internal failure of the Amazon Inspector
* service.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - Inspector2Exception Base class for all service exceptions. Unknown exceptions will be thrown as an
* instance of this type.
*
* @sample Inspector2AsyncClient.ListDelegatedAdminAccounts
* @see AWS API Documentation
*/
@Override
public CompletableFuture listDelegatedAdminAccounts(
ListDelegatedAdminAccountsRequest listDelegatedAdminAccountsRequest) {
List metricPublishers = resolveMetricPublishers(clientConfiguration, listDelegatedAdminAccountsRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Inspector2");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ListDelegatedAdminAccounts");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, ListDelegatedAdminAccountsResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("ListDelegatedAdminAccounts")
.withMarshaller(new ListDelegatedAdminAccountsRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withMetricCollector(apiCallMetricCollector).withInput(listDelegatedAdminAccountsRequest));
CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Lists information about the Amazon Inspector delegated administrator of your organization.
*
*
*
* This is a variant of
* {@link #listDelegatedAdminAccounts(software.amazon.awssdk.services.inspector2.model.ListDelegatedAdminAccountsRequest)}
* operation. The return type is a custom publisher that can be subscribed to request a stream of response pages.
* SDK will internally handle making service calls for you.
*
*
* When the operation is called, an instance of this class is returned. At this point, no service calls are made yet
* and so there is no guarantee that the request is valid. If there are errors in your request, you will see the
* failures only after you start streaming the data. The subscribe method should be called as a request to start
* streaming data. For more info, see
* {@link org.reactivestreams.Publisher#subscribe(org.reactivestreams.Subscriber)}. Each call to the subscribe
* method will result in a new {@link org.reactivestreams.Subscription} i.e., a new contract to stream data from the
* starting request.
*
*
*
* The following are few ways to use the response class:
*
* 1) Using the subscribe helper method
*
*
* {@code
* software.amazon.awssdk.services.inspector2.paginators.ListDelegatedAdminAccountsPublisher publisher = client.listDelegatedAdminAccountsPaginator(request);
* CompletableFuture future = publisher.subscribe(res -> { // Do something with the response });
* future.get();
* }
*
*
* 2) Using a custom subscriber
*
*
* {@code
* software.amazon.awssdk.services.inspector2.paginators.ListDelegatedAdminAccountsPublisher publisher = client.listDelegatedAdminAccountsPaginator(request);
* publisher.subscribe(new Subscriber() {
*
* public void onSubscribe(org.reactivestreams.Subscriber subscription) { //... };
*
*
* public void onNext(software.amazon.awssdk.services.inspector2.model.ListDelegatedAdminAccountsResponse response) { //... };
* });}
*
*
* As the response is a publisher, it can work well with third party reactive streams implementations like RxJava2.
*
* Please notice that the configuration of maxResults won't limit the number of results you get with the
* paginator. It only limits the number of results in each page.
*
*
* Note: If you prefer to have control on service calls, use the
* {@link #listDelegatedAdminAccounts(software.amazon.awssdk.services.inspector2.model.ListDelegatedAdminAccountsRequest)}
* operation.
*
*
* @param listDelegatedAdminAccountsRequest
* @return A custom publisher that can be subscribed to request a stream of response pages.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - ValidationException The request has failed validation due to missing required fields or having
* invalid inputs.
* - AccessDeniedException You do not have sufficient access to perform this action.
* - ThrottlingException The limit on the number of requests per second was exceeded.
* - InternalServerException The request has failed due to an internal failure of the Amazon Inspector
* service.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - Inspector2Exception Base class for all service exceptions. Unknown exceptions will be thrown as an
* instance of this type.
*
* @sample Inspector2AsyncClient.ListDelegatedAdminAccounts
* @see AWS API Documentation
*/
public ListDelegatedAdminAccountsPublisher listDelegatedAdminAccountsPaginator(
ListDelegatedAdminAccountsRequest listDelegatedAdminAccountsRequest) {
return new ListDelegatedAdminAccountsPublisher(this, applyPaginatorUserAgent(listDelegatedAdminAccountsRequest));
}
/**
*
* Lists the filters associated with your account.
*
*
* @param listFiltersRequest
* @return A Java Future containing the result of the ListFilters operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - ValidationException The request has failed validation due to missing required fields or having
* invalid inputs.
* - AccessDeniedException You do not have sufficient access to perform this action.
* - ThrottlingException The limit on the number of requests per second was exceeded.
* - InternalServerException The request has failed due to an internal failure of the Amazon Inspector
* service.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - Inspector2Exception Base class for all service exceptions. Unknown exceptions will be thrown as an
* instance of this type.
*
* @sample Inspector2AsyncClient.ListFilters
* @see AWS API
* Documentation
*/
@Override
public CompletableFuture listFilters(ListFiltersRequest listFiltersRequest) {
List metricPublishers = resolveMetricPublishers(clientConfiguration, listFiltersRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Inspector2");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ListFilters");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
ListFiltersResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("ListFilters").withMarshaller(new ListFiltersRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withMetricCollector(apiCallMetricCollector).withInput(listFiltersRequest));
CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Lists the filters associated with your account.
*
*
*
* This is a variant of {@link #listFilters(software.amazon.awssdk.services.inspector2.model.ListFiltersRequest)}
* operation. The return type is a custom publisher that can be subscribed to request a stream of response pages.
* SDK will internally handle making service calls for you.
*
*
* When the operation is called, an instance of this class is returned. At this point, no service calls are made yet
* and so there is no guarantee that the request is valid. If there are errors in your request, you will see the
* failures only after you start streaming the data. The subscribe method should be called as a request to start
* streaming data. For more info, see
* {@link org.reactivestreams.Publisher#subscribe(org.reactivestreams.Subscriber)}. Each call to the subscribe
* method will result in a new {@link org.reactivestreams.Subscription} i.e., a new contract to stream data from the
* starting request.
*
*
*
* The following are few ways to use the response class:
*
* 1) Using the subscribe helper method
*
*
* {@code
* software.amazon.awssdk.services.inspector2.paginators.ListFiltersPublisher publisher = client.listFiltersPaginator(request);
* CompletableFuture future = publisher.subscribe(res -> { // Do something with the response });
* future.get();
* }
*
*
* 2) Using a custom subscriber
*
*
* {@code
* software.amazon.awssdk.services.inspector2.paginators.ListFiltersPublisher publisher = client.listFiltersPaginator(request);
* publisher.subscribe(new Subscriber() {
*
* public void onSubscribe(org.reactivestreams.Subscriber subscription) { //... };
*
*
* public void onNext(software.amazon.awssdk.services.inspector2.model.ListFiltersResponse response) { //... };
* });}
*
*
* As the response is a publisher, it can work well with third party reactive streams implementations like RxJava2.
*
* Please notice that the configuration of maxResults won't limit the number of results you get with the
* paginator. It only limits the number of results in each page.
*
*
* Note: If you prefer to have control on service calls, use the
* {@link #listFilters(software.amazon.awssdk.services.inspector2.model.ListFiltersRequest)} operation.
*
*
* @param listFiltersRequest
* @return A custom publisher that can be subscribed to request a stream of response pages.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - ValidationException The request has failed validation due to missing required fields or having
* invalid inputs.
* - AccessDeniedException You do not have sufficient access to perform this action.
* - ThrottlingException The limit on the number of requests per second was exceeded.
* - InternalServerException The request has failed due to an internal failure of the Amazon Inspector
* service.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - Inspector2Exception Base class for all service exceptions. Unknown exceptions will be thrown as an
* instance of this type.
*
* @sample Inspector2AsyncClient.ListFilters
* @see AWS API
* Documentation
*/
public ListFiltersPublisher listFiltersPaginator(ListFiltersRequest listFiltersRequest) {
return new ListFiltersPublisher(this, applyPaginatorUserAgent(listFiltersRequest));
}
/**
*
* Lists aggregated finding data for your environment based on specific criteria.
*
*
* @param listFindingAggregationsRequest
* @return A Java Future containing the result of the ListFindingAggregations operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - ValidationException The request has failed validation due to missing required fields or having
* invalid inputs.
* - ThrottlingException The limit on the number of requests per second was exceeded.
* - InternalServerException The request has failed due to an internal failure of the Amazon Inspector
* service.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - Inspector2Exception Base class for all service exceptions. Unknown exceptions will be thrown as an
* instance of this type.
*
* @sample Inspector2AsyncClient.ListFindingAggregations
* @see AWS API Documentation
*/
@Override
public CompletableFuture listFindingAggregations(
ListFindingAggregationsRequest listFindingAggregationsRequest) {
List metricPublishers = resolveMetricPublishers(clientConfiguration, listFindingAggregationsRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Inspector2");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ListFindingAggregations");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, ListFindingAggregationsResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("ListFindingAggregations")
.withMarshaller(new ListFindingAggregationsRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withMetricCollector(apiCallMetricCollector).withInput(listFindingAggregationsRequest));
CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Lists aggregated finding data for your environment based on specific criteria.
*
*
*
* This is a variant of
* {@link #listFindingAggregations(software.amazon.awssdk.services.inspector2.model.ListFindingAggregationsRequest)}
* operation. The return type is a custom publisher that can be subscribed to request a stream of response pages.
* SDK will internally handle making service calls for you.
*
*
* When the operation is called, an instance of this class is returned. At this point, no service calls are made yet
* and so there is no guarantee that the request is valid. If there are errors in your request, you will see the
* failures only after you start streaming the data. The subscribe method should be called as a request to start
* streaming data. For more info, see
* {@link org.reactivestreams.Publisher#subscribe(org.reactivestreams.Subscriber)}. Each call to the subscribe
* method will result in a new {@link org.reactivestreams.Subscription} i.e., a new contract to stream data from the
* starting request.
*
*
*
* The following are few ways to use the response class:
*
* 1) Using the subscribe helper method
*
*
* {@code
* software.amazon.awssdk.services.inspector2.paginators.ListFindingAggregationsPublisher publisher = client.listFindingAggregationsPaginator(request);
* CompletableFuture future = publisher.subscribe(res -> { // Do something with the response });
* future.get();
* }
*
*
* 2) Using a custom subscriber
*
*
* {@code
* software.amazon.awssdk.services.inspector2.paginators.ListFindingAggregationsPublisher publisher = client.listFindingAggregationsPaginator(request);
* publisher.subscribe(new Subscriber() {
*
* public void onSubscribe(org.reactivestreams.Subscriber subscription) { //... };
*
*
* public void onNext(software.amazon.awssdk.services.inspector2.model.ListFindingAggregationsResponse response) { //... };
* });}
*
*
* As the response is a publisher, it can work well with third party reactive streams implementations like RxJava2.
*
* Please notice that the configuration of maxResults won't limit the number of results you get with the
* paginator. It only limits the number of results in each page.
*
*
* Note: If you prefer to have control on service calls, use the
* {@link #listFindingAggregations(software.amazon.awssdk.services.inspector2.model.ListFindingAggregationsRequest)}
* operation.
*
*
* @param listFindingAggregationsRequest
* @return A custom publisher that can be subscribed to request a stream of response pages.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - ValidationException The request has failed validation due to missing required fields or having
* invalid inputs.
* - ThrottlingException The limit on the number of requests per second was exceeded.
* - InternalServerException The request has failed due to an internal failure of the Amazon Inspector
* service.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - Inspector2Exception Base class for all service exceptions. Unknown exceptions will be thrown as an
* instance of this type.
*
* @sample Inspector2AsyncClient.ListFindingAggregations
* @see AWS API Documentation
*/
public ListFindingAggregationsPublisher listFindingAggregationsPaginator(
ListFindingAggregationsRequest listFindingAggregationsRequest) {
return new ListFindingAggregationsPublisher(this, applyPaginatorUserAgent(listFindingAggregationsRequest));
}
/**
*
* Lists findings for your environment.
*
*
* @param listFindingsRequest
* @return A Java Future containing the result of the ListFindings operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - ValidationException The request has failed validation due to missing required fields or having
* invalid inputs.
* - ThrottlingException The limit on the number of requests per second was exceeded.
* - InternalServerException The request has failed due to an internal failure of the Amazon Inspector
* service.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - Inspector2Exception Base class for all service exceptions. Unknown exceptions will be thrown as an
* instance of this type.
*
* @sample Inspector2AsyncClient.ListFindings
* @see AWS API
* Documentation
*/
@Override
public CompletableFuture listFindings(ListFindingsRequest listFindingsRequest) {
List metricPublishers = resolveMetricPublishers(clientConfiguration, listFindingsRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Inspector2");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ListFindings");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
ListFindingsResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("ListFindings").withMarshaller(new ListFindingsRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withMetricCollector(apiCallMetricCollector).withInput(listFindingsRequest));
CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Lists findings for your environment.
*
*
*
* This is a variant of {@link #listFindings(software.amazon.awssdk.services.inspector2.model.ListFindingsRequest)}
* operation. The return type is a custom publisher that can be subscribed to request a stream of response pages.
* SDK will internally handle making service calls for you.
*
*
* When the operation is called, an instance of this class is returned. At this point, no service calls are made yet
* and so there is no guarantee that the request is valid. If there are errors in your request, you will see the
* failures only after you start streaming the data. The subscribe method should be called as a request to start
* streaming data. For more info, see
* {@link org.reactivestreams.Publisher#subscribe(org.reactivestreams.Subscriber)}. Each call to the subscribe
* method will result in a new {@link org.reactivestreams.Subscription} i.e., a new contract to stream data from the
* starting request.
*
*
*
* The following are few ways to use the response class:
*
* 1) Using the subscribe helper method
*
*
* {@code
* software.amazon.awssdk.services.inspector2.paginators.ListFindingsPublisher publisher = client.listFindingsPaginator(request);
* CompletableFuture future = publisher.subscribe(res -> { // Do something with the response });
* future.get();
* }
*
*
* 2) Using a custom subscriber
*
*
* {@code
* software.amazon.awssdk.services.inspector2.paginators.ListFindingsPublisher publisher = client.listFindingsPaginator(request);
* publisher.subscribe(new Subscriber() {
*
* public void onSubscribe(org.reactivestreams.Subscriber subscription) { //... };
*
*
* public void onNext(software.amazon.awssdk.services.inspector2.model.ListFindingsResponse response) { //... };
* });}
*
*
* As the response is a publisher, it can work well with third party reactive streams implementations like RxJava2.
*
* Please notice that the configuration of maxResults won't limit the number of results you get with the
* paginator. It only limits the number of results in each page.
*
*
* Note: If you prefer to have control on service calls, use the
* {@link #listFindings(software.amazon.awssdk.services.inspector2.model.ListFindingsRequest)} operation.
*
*
* @param listFindingsRequest
* @return A custom publisher that can be subscribed to request a stream of response pages.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - ValidationException The request has failed validation due to missing required fields or having
* invalid inputs.
* - ThrottlingException The limit on the number of requests per second was exceeded.
* - InternalServerException The request has failed due to an internal failure of the Amazon Inspector
* service.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - Inspector2Exception Base class for all service exceptions. Unknown exceptions will be thrown as an
* instance of this type.
*
* @sample Inspector2AsyncClient.ListFindings
* @see AWS API
* Documentation
*/
public ListFindingsPublisher listFindingsPaginator(ListFindingsRequest listFindingsRequest) {
return new ListFindingsPublisher(this, applyPaginatorUserAgent(listFindingsRequest));
}
/**
*
* List members associated with the Amazon Inspector delegated administrator for your organization.
*
*
* @param listMembersRequest
* @return A Java Future containing the result of the ListMembers operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - ValidationException The request has failed validation due to missing required fields or having
* invalid inputs.
* - AccessDeniedException You do not have sufficient access to perform this action.
* - ThrottlingException The limit on the number of requests per second was exceeded.
* - InternalServerException The request has failed due to an internal failure of the Amazon Inspector
* service.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - Inspector2Exception Base class for all service exceptions. Unknown exceptions will be thrown as an
* instance of this type.
*
* @sample Inspector2AsyncClient.ListMembers
* @see AWS API
* Documentation
*/
@Override
public CompletableFuture listMembers(ListMembersRequest listMembersRequest) {
List metricPublishers = resolveMetricPublishers(clientConfiguration, listMembersRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Inspector2");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ListMembers");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
ListMembersResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("ListMembers").withMarshaller(new ListMembersRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withMetricCollector(apiCallMetricCollector).withInput(listMembersRequest));
CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* List members associated with the Amazon Inspector delegated administrator for your organization.
*
*
*
* This is a variant of {@link #listMembers(software.amazon.awssdk.services.inspector2.model.ListMembersRequest)}
* operation. The return type is a custom publisher that can be subscribed to request a stream of response pages.
* SDK will internally handle making service calls for you.
*
*
* When the operation is called, an instance of this class is returned. At this point, no service calls are made yet
* and so there is no guarantee that the request is valid. If there are errors in your request, you will see the
* failures only after you start streaming the data. The subscribe method should be called as a request to start
* streaming data. For more info, see
* {@link org.reactivestreams.Publisher#subscribe(org.reactivestreams.Subscriber)}. Each call to the subscribe
* method will result in a new {@link org.reactivestreams.Subscription} i.e., a new contract to stream data from the
* starting request.
*
*
*
* The following are few ways to use the response class:
*
* 1) Using the subscribe helper method
*
*
* {@code
* software.amazon.awssdk.services.inspector2.paginators.ListMembersPublisher publisher = client.listMembersPaginator(request);
* CompletableFuture future = publisher.subscribe(res -> { // Do something with the response });
* future.get();
* }
*
*
* 2) Using a custom subscriber
*
*
* {@code
* software.amazon.awssdk.services.inspector2.paginators.ListMembersPublisher publisher = client.listMembersPaginator(request);
* publisher.subscribe(new Subscriber() {
*
* public void onSubscribe(org.reactivestreams.Subscriber subscription) { //... };
*
*
* public void onNext(software.amazon.awssdk.services.inspector2.model.ListMembersResponse response) { //... };
* });}
*
*
* As the response is a publisher, it can work well with third party reactive streams implementations like RxJava2.
*
* Please notice that the configuration of maxResults won't limit the number of results you get with the
* paginator. It only limits the number of results in each page.
*
*
* Note: If you prefer to have control on service calls, use the
* {@link #listMembers(software.amazon.awssdk.services.inspector2.model.ListMembersRequest)} operation.
*
*
* @param listMembersRequest
* @return A custom publisher that can be subscribed to request a stream of response pages.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - ValidationException The request has failed validation due to missing required fields or having
* invalid inputs.
* - AccessDeniedException You do not have sufficient access to perform this action.
* - ThrottlingException The limit on the number of requests per second was exceeded.
* - InternalServerException The request has failed due to an internal failure of the Amazon Inspector
* service.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - Inspector2Exception Base class for all service exceptions. Unknown exceptions will be thrown as an
* instance of this type.
*
* @sample Inspector2AsyncClient.ListMembers
* @see AWS API
* Documentation
*/
public ListMembersPublisher listMembersPaginator(ListMembersRequest listMembersRequest) {
return new ListMembersPublisher(this, applyPaginatorUserAgent(listMembersRequest));
}
/**
*
* Lists all tags attached to a given resource.
*
*
* @param listTagsForResourceRequest
* @return A Java Future containing the result of the ListTagsForResource operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - ValidationException The request has failed validation due to missing required fields or having
* invalid inputs.
* - ResourceNotFoundException The operation tried to access an invalid resource. Make sure the resource
* is specified correctly.
* - ThrottlingException The limit on the number of requests per second was exceeded.
* - InternalServerException The request has failed due to an internal failure of the Amazon Inspector
* service.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - Inspector2Exception Base class for all service exceptions. Unknown exceptions will be thrown as an
* instance of this type.
*
* @sample Inspector2AsyncClient.ListTagsForResource
* @see AWS API Documentation
*/
@Override
public CompletableFuture listTagsForResource(
ListTagsForResourceRequest listTagsForResourceRequest) {
List metricPublishers = resolveMetricPublishers(clientConfiguration, listTagsForResourceRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Inspector2");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ListTagsForResource");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, ListTagsForResourceResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("ListTagsForResource")
.withMarshaller(new ListTagsForResourceRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withMetricCollector(apiCallMetricCollector).withInput(listTagsForResourceRequest));
CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Lists the Amazon Inspector usage totals over the last 30 days.
*
*
* @param listUsageTotalsRequest
* @return A Java Future containing the result of the ListUsageTotals operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - ValidationException The request has failed validation due to missing required fields or having
* invalid inputs.
* - AccessDeniedException You do not have sufficient access to perform this action.
* - ThrottlingException The limit on the number of requests per second was exceeded.
* - InternalServerException The request has failed due to an internal failure of the Amazon Inspector
* service.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - Inspector2Exception Base class for all service exceptions. Unknown exceptions will be thrown as an
* instance of this type.
*
* @sample Inspector2AsyncClient.ListUsageTotals
* @see AWS
* API Documentation
*/
@Override
public CompletableFuture listUsageTotals(ListUsageTotalsRequest listUsageTotalsRequest) {
List metricPublishers = resolveMetricPublishers(clientConfiguration, listUsageTotalsRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Inspector2");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ListUsageTotals");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, ListUsageTotalsResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("ListUsageTotals")
.withMarshaller(new ListUsageTotalsRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withMetricCollector(apiCallMetricCollector).withInput(listUsageTotalsRequest));
CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Lists the Amazon Inspector usage totals over the last 30 days.
*
*
*
* This is a variant of
* {@link #listUsageTotals(software.amazon.awssdk.services.inspector2.model.ListUsageTotalsRequest)} operation. The
* return type is a custom publisher that can be subscribed to request a stream of response pages. SDK will
* internally handle making service calls for you.
*
*
* When the operation is called, an instance of this class is returned. At this point, no service calls are made yet
* and so there is no guarantee that the request is valid. If there are errors in your request, you will see the
* failures only after you start streaming the data. The subscribe method should be called as a request to start
* streaming data. For more info, see
* {@link org.reactivestreams.Publisher#subscribe(org.reactivestreams.Subscriber)}. Each call to the subscribe
* method will result in a new {@link org.reactivestreams.Subscription} i.e., a new contract to stream data from the
* starting request.
*
*
*
* The following are few ways to use the response class:
*
* 1) Using the subscribe helper method
*
*
* {@code
* software.amazon.awssdk.services.inspector2.paginators.ListUsageTotalsPublisher publisher = client.listUsageTotalsPaginator(request);
* CompletableFuture future = publisher.subscribe(res -> { // Do something with the response });
* future.get();
* }
*
*
* 2) Using a custom subscriber
*
*
* {@code
* software.amazon.awssdk.services.inspector2.paginators.ListUsageTotalsPublisher publisher = client.listUsageTotalsPaginator(request);
* publisher.subscribe(new Subscriber() {
*
* public void onSubscribe(org.reactivestreams.Subscriber subscription) { //... };
*
*
* public void onNext(software.amazon.awssdk.services.inspector2.model.ListUsageTotalsResponse response) { //... };
* });}
*
*
* As the response is a publisher, it can work well with third party reactive streams implementations like RxJava2.
*
* Please notice that the configuration of maxResults won't limit the number of results you get with the
* paginator. It only limits the number of results in each page.
*
*
* Note: If you prefer to have control on service calls, use the
* {@link #listUsageTotals(software.amazon.awssdk.services.inspector2.model.ListUsageTotalsRequest)} operation.
*
*
* @param listUsageTotalsRequest
* @return A custom publisher that can be subscribed to request a stream of response pages.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - ValidationException The request has failed validation due to missing required fields or having
* invalid inputs.
* - AccessDeniedException You do not have sufficient access to perform this action.
* - ThrottlingException The limit on the number of requests per second was exceeded.
* - InternalServerException The request has failed due to an internal failure of the Amazon Inspector
* service.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - Inspector2Exception Base class for all service exceptions. Unknown exceptions will be thrown as an
* instance of this type.
*
* @sample Inspector2AsyncClient.ListUsageTotals
* @see AWS
* API Documentation
*/
public ListUsageTotalsPublisher listUsageTotalsPaginator(ListUsageTotalsRequest listUsageTotalsRequest) {
return new ListUsageTotalsPublisher(this, applyPaginatorUserAgent(listUsageTotalsRequest));
}
/**
*
* Adds tags to a resource.
*
*
* @param tagResourceRequest
* @return A Java Future containing the result of the TagResource operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - BadRequestException One or more tags submitted as part of the request is not valid.
* - ValidationException The request has failed validation due to missing required fields or having
* invalid inputs.
* - ResourceNotFoundException The operation tried to access an invalid resource. Make sure the resource
* is specified correctly.
* - ThrottlingException The limit on the number of requests per second was exceeded.
* - InternalServerException The request has failed due to an internal failure of the Amazon Inspector
* service.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - Inspector2Exception Base class for all service exceptions. Unknown exceptions will be thrown as an
* instance of this type.
*
* @sample Inspector2AsyncClient.TagResource
* @see AWS API
* Documentation
*/
@Override
public CompletableFuture tagResource(TagResourceRequest tagResourceRequest) {
List metricPublishers = resolveMetricPublishers(clientConfiguration, tagResourceRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Inspector2");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "TagResource");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
TagResourceResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("TagResource").withMarshaller(new TagResourceRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withMetricCollector(apiCallMetricCollector).withInput(tagResourceRequest));
CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Removes tags from a resource.
*
*
* @param untagResourceRequest
* @return A Java Future containing the result of the UntagResource operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - ValidationException The request has failed validation due to missing required fields or having
* invalid inputs.
* - ResourceNotFoundException The operation tried to access an invalid resource. Make sure the resource
* is specified correctly.
* - ThrottlingException The limit on the number of requests per second was exceeded.
* - InternalServerException The request has failed due to an internal failure of the Amazon Inspector
* service.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - Inspector2Exception Base class for all service exceptions. Unknown exceptions will be thrown as an
* instance of this type.
*
* @sample Inspector2AsyncClient.UntagResource
* @see AWS API
* Documentation
*/
@Override
public CompletableFuture untagResource(UntagResourceRequest untagResourceRequest) {
List metricPublishers = resolveMetricPublishers(clientConfiguration, untagResourceRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Inspector2");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "UntagResource");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
UntagResourceResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("UntagResource")
.withMarshaller(new UntagResourceRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withMetricCollector(apiCallMetricCollector).withInput(untagResourceRequest));
CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Updates setting configurations for your Amazon Inspector account. When you use this API as an Amazon Inspector
* delegated administrator this updates the setting for all accounts you manage. Member accounts in an organization
* cannot update this setting.
*
*
* @param updateConfigurationRequest
* @return A Java Future containing the result of the UpdateConfiguration operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - ValidationException The request has failed validation due to missing required fields or having
* invalid inputs.
* - AccessDeniedException You do not have sufficient access to perform this action.
* - ThrottlingException The limit on the number of requests per second was exceeded.
* - InternalServerException The request has failed due to an internal failure of the Amazon Inspector
* service.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - Inspector2Exception Base class for all service exceptions. Unknown exceptions will be thrown as an
* instance of this type.
*
* @sample Inspector2AsyncClient.UpdateConfiguration
* @see AWS API Documentation
*/
@Override
public CompletableFuture updateConfiguration(
UpdateConfigurationRequest updateConfigurationRequest) {
List metricPublishers = resolveMetricPublishers(clientConfiguration, updateConfigurationRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Inspector2");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "UpdateConfiguration");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, UpdateConfigurationResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("UpdateConfiguration")
.withMarshaller(new UpdateConfigurationRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withMetricCollector(apiCallMetricCollector).withInput(updateConfigurationRequest));
CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Specifies the action that is to be applied to the findings that match the filter.
*
*
* @param updateFilterRequest
* @return A Java Future containing the result of the UpdateFilter operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - ValidationException The request has failed validation due to missing required fields or having
* invalid inputs.
* - AccessDeniedException You do not have sufficient access to perform this action.
* - ResourceNotFoundException The operation tried to access an invalid resource. Make sure the resource
* is specified correctly.
* - ThrottlingException The limit on the number of requests per second was exceeded.
* - InternalServerException The request has failed due to an internal failure of the Amazon Inspector
* service.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - Inspector2Exception Base class for all service exceptions. Unknown exceptions will be thrown as an
* instance of this type.
*
* @sample Inspector2AsyncClient.UpdateFilter
* @see AWS API
* Documentation
*/
@Override
public CompletableFuture updateFilter(UpdateFilterRequest updateFilterRequest) {
List metricPublishers = resolveMetricPublishers(clientConfiguration, updateFilterRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Inspector2");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "UpdateFilter");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
UpdateFilterResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("UpdateFilter").withMarshaller(new UpdateFilterRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withMetricCollector(apiCallMetricCollector).withInput(updateFilterRequest));
CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Updates the configurations for your Amazon Inspector organization.
*
*
* @param updateOrganizationConfigurationRequest
* @return A Java Future containing the result of the UpdateOrganizationConfiguration operation returned by the
* service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - AccessDeniedException You do not have sufficient access to perform this action.
* - ValidationException The request has failed validation due to missing required fields or having
* invalid inputs.
* - ThrottlingException The limit on the number of requests per second was exceeded.
* - InternalServerException The request has failed due to an internal failure of the Amazon Inspector
* service.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - Inspector2Exception Base class for all service exceptions. Unknown exceptions will be thrown as an
* instance of this type.
*
* @sample Inspector2AsyncClient.UpdateOrganizationConfiguration
* @see AWS API Documentation
*/
@Override
public CompletableFuture updateOrganizationConfiguration(
UpdateOrganizationConfigurationRequest updateOrganizationConfigurationRequest) {
List metricPublishers = resolveMetricPublishers(clientConfiguration,
updateOrganizationConfigurationRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Inspector2");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "UpdateOrganizationConfiguration");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, UpdateOrganizationConfigurationResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("UpdateOrganizationConfiguration")
.withMarshaller(new UpdateOrganizationConfigurationRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withMetricCollector(apiCallMetricCollector).withInput(updateOrganizationConfigurationRequest));
CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
@Override
public void close() {
clientHandler.close();
}
private > T init(T builder) {
return builder
.clientConfiguration(clientConfiguration)
.defaultServiceExceptionSupplier(Inspector2Exception::builder)
.protocol(AwsJsonProtocol.REST_JSON)
.protocolVersion("1.1")
.registerModeledException(
ExceptionMetadata.builder().errorCode("ServiceQuotaExceededException")
.exceptionBuilderSupplier(ServiceQuotaExceededException::builder).httpStatusCode(402).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("InternalServerException")
.exceptionBuilderSupplier(InternalServerException::builder).httpStatusCode(500).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("ResourceNotFoundException")
.exceptionBuilderSupplier(ResourceNotFoundException::builder).httpStatusCode(404).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("ValidationException")
.exceptionBuilderSupplier(ValidationException::builder).httpStatusCode(400).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("ThrottlingException")
.exceptionBuilderSupplier(ThrottlingException::builder).httpStatusCode(429).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("AccessDeniedException")
.exceptionBuilderSupplier(AccessDeniedException::builder).httpStatusCode(403).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("ConflictException")
.exceptionBuilderSupplier(ConflictException::builder).httpStatusCode(409).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("BadRequestException")
.exceptionBuilderSupplier(BadRequestException::builder).httpStatusCode(400).build());
}
private static List resolveMetricPublishers(SdkClientConfiguration clientConfiguration,
RequestOverrideConfiguration requestOverrideConfiguration) {
List publishers = null;
if (requestOverrideConfiguration != null) {
publishers = requestOverrideConfiguration.metricPublishers();
}
if (publishers == null || publishers.isEmpty()) {
publishers = clientConfiguration.option(SdkClientOption.METRIC_PUBLISHERS);
}
if (publishers == null) {
publishers = Collections.emptyList();
}
return publishers;
}
private T applyPaginatorUserAgent(T request) {
Consumer userAgentApplier = b -> b.addApiName(ApiName.builder()
.version(VersionInfo.SDK_VERSION).name("PAGINATED").build());
AwsRequestOverrideConfiguration overrideConfiguration = request.overrideConfiguration()
.map(c -> c.toBuilder().applyMutation(userAgentApplier).build())
.orElse((AwsRequestOverrideConfiguration.builder().applyMutation(userAgentApplier).build()));
return (T) request.toBuilder().overrideConfiguration(overrideConfiguration).build();
}
private HttpResponseHandler createErrorResponseHandler(BaseAwsJsonProtocolFactory protocolFactory,
JsonOperationMetadata operationMetadata) {
return protocolFactory.createErrorResponseHandler(operationMetadata);
}
}