software.amazon.awssdk.services.fms.DefaultFmsAsyncClient Maven / Gradle / Ivy
Show all versions of fms Show documentation
/*
* 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.fms;
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.fms.model.AssociateAdminAccountRequest;
import software.amazon.awssdk.services.fms.model.AssociateAdminAccountResponse;
import software.amazon.awssdk.services.fms.model.DeleteAppsListRequest;
import software.amazon.awssdk.services.fms.model.DeleteAppsListResponse;
import software.amazon.awssdk.services.fms.model.DeleteNotificationChannelRequest;
import software.amazon.awssdk.services.fms.model.DeleteNotificationChannelResponse;
import software.amazon.awssdk.services.fms.model.DeletePolicyRequest;
import software.amazon.awssdk.services.fms.model.DeletePolicyResponse;
import software.amazon.awssdk.services.fms.model.DeleteProtocolsListRequest;
import software.amazon.awssdk.services.fms.model.DeleteProtocolsListResponse;
import software.amazon.awssdk.services.fms.model.DisassociateAdminAccountRequest;
import software.amazon.awssdk.services.fms.model.DisassociateAdminAccountResponse;
import software.amazon.awssdk.services.fms.model.FmsException;
import software.amazon.awssdk.services.fms.model.FmsRequest;
import software.amazon.awssdk.services.fms.model.GetAdminAccountRequest;
import software.amazon.awssdk.services.fms.model.GetAdminAccountResponse;
import software.amazon.awssdk.services.fms.model.GetAppsListRequest;
import software.amazon.awssdk.services.fms.model.GetAppsListResponse;
import software.amazon.awssdk.services.fms.model.GetComplianceDetailRequest;
import software.amazon.awssdk.services.fms.model.GetComplianceDetailResponse;
import software.amazon.awssdk.services.fms.model.GetNotificationChannelRequest;
import software.amazon.awssdk.services.fms.model.GetNotificationChannelResponse;
import software.amazon.awssdk.services.fms.model.GetPolicyRequest;
import software.amazon.awssdk.services.fms.model.GetPolicyResponse;
import software.amazon.awssdk.services.fms.model.GetProtectionStatusRequest;
import software.amazon.awssdk.services.fms.model.GetProtectionStatusResponse;
import software.amazon.awssdk.services.fms.model.GetProtocolsListRequest;
import software.amazon.awssdk.services.fms.model.GetProtocolsListResponse;
import software.amazon.awssdk.services.fms.model.GetViolationDetailsRequest;
import software.amazon.awssdk.services.fms.model.GetViolationDetailsResponse;
import software.amazon.awssdk.services.fms.model.InternalErrorException;
import software.amazon.awssdk.services.fms.model.InvalidInputException;
import software.amazon.awssdk.services.fms.model.InvalidOperationException;
import software.amazon.awssdk.services.fms.model.InvalidTypeException;
import software.amazon.awssdk.services.fms.model.LimitExceededException;
import software.amazon.awssdk.services.fms.model.ListAppsListsRequest;
import software.amazon.awssdk.services.fms.model.ListAppsListsResponse;
import software.amazon.awssdk.services.fms.model.ListComplianceStatusRequest;
import software.amazon.awssdk.services.fms.model.ListComplianceStatusResponse;
import software.amazon.awssdk.services.fms.model.ListMemberAccountsRequest;
import software.amazon.awssdk.services.fms.model.ListMemberAccountsResponse;
import software.amazon.awssdk.services.fms.model.ListPoliciesRequest;
import software.amazon.awssdk.services.fms.model.ListPoliciesResponse;
import software.amazon.awssdk.services.fms.model.ListProtocolsListsRequest;
import software.amazon.awssdk.services.fms.model.ListProtocolsListsResponse;
import software.amazon.awssdk.services.fms.model.ListTagsForResourceRequest;
import software.amazon.awssdk.services.fms.model.ListTagsForResourceResponse;
import software.amazon.awssdk.services.fms.model.PutAppsListRequest;
import software.amazon.awssdk.services.fms.model.PutAppsListResponse;
import software.amazon.awssdk.services.fms.model.PutNotificationChannelRequest;
import software.amazon.awssdk.services.fms.model.PutNotificationChannelResponse;
import software.amazon.awssdk.services.fms.model.PutPolicyRequest;
import software.amazon.awssdk.services.fms.model.PutPolicyResponse;
import software.amazon.awssdk.services.fms.model.PutProtocolsListRequest;
import software.amazon.awssdk.services.fms.model.PutProtocolsListResponse;
import software.amazon.awssdk.services.fms.model.ResourceNotFoundException;
import software.amazon.awssdk.services.fms.model.TagResourceRequest;
import software.amazon.awssdk.services.fms.model.TagResourceResponse;
import software.amazon.awssdk.services.fms.model.UntagResourceRequest;
import software.amazon.awssdk.services.fms.model.UntagResourceResponse;
import software.amazon.awssdk.services.fms.paginators.ListComplianceStatusPublisher;
import software.amazon.awssdk.services.fms.paginators.ListMemberAccountsPublisher;
import software.amazon.awssdk.services.fms.paginators.ListPoliciesPublisher;
import software.amazon.awssdk.services.fms.transform.AssociateAdminAccountRequestMarshaller;
import software.amazon.awssdk.services.fms.transform.DeleteAppsListRequestMarshaller;
import software.amazon.awssdk.services.fms.transform.DeleteNotificationChannelRequestMarshaller;
import software.amazon.awssdk.services.fms.transform.DeletePolicyRequestMarshaller;
import software.amazon.awssdk.services.fms.transform.DeleteProtocolsListRequestMarshaller;
import software.amazon.awssdk.services.fms.transform.DisassociateAdminAccountRequestMarshaller;
import software.amazon.awssdk.services.fms.transform.GetAdminAccountRequestMarshaller;
import software.amazon.awssdk.services.fms.transform.GetAppsListRequestMarshaller;
import software.amazon.awssdk.services.fms.transform.GetComplianceDetailRequestMarshaller;
import software.amazon.awssdk.services.fms.transform.GetNotificationChannelRequestMarshaller;
import software.amazon.awssdk.services.fms.transform.GetPolicyRequestMarshaller;
import software.amazon.awssdk.services.fms.transform.GetProtectionStatusRequestMarshaller;
import software.amazon.awssdk.services.fms.transform.GetProtocolsListRequestMarshaller;
import software.amazon.awssdk.services.fms.transform.GetViolationDetailsRequestMarshaller;
import software.amazon.awssdk.services.fms.transform.ListAppsListsRequestMarshaller;
import software.amazon.awssdk.services.fms.transform.ListComplianceStatusRequestMarshaller;
import software.amazon.awssdk.services.fms.transform.ListMemberAccountsRequestMarshaller;
import software.amazon.awssdk.services.fms.transform.ListPoliciesRequestMarshaller;
import software.amazon.awssdk.services.fms.transform.ListProtocolsListsRequestMarshaller;
import software.amazon.awssdk.services.fms.transform.ListTagsForResourceRequestMarshaller;
import software.amazon.awssdk.services.fms.transform.PutAppsListRequestMarshaller;
import software.amazon.awssdk.services.fms.transform.PutNotificationChannelRequestMarshaller;
import software.amazon.awssdk.services.fms.transform.PutPolicyRequestMarshaller;
import software.amazon.awssdk.services.fms.transform.PutProtocolsListRequestMarshaller;
import software.amazon.awssdk.services.fms.transform.TagResourceRequestMarshaller;
import software.amazon.awssdk.services.fms.transform.UntagResourceRequestMarshaller;
import software.amazon.awssdk.utils.CompletableFutureUtils;
/**
* Internal implementation of {@link FmsAsyncClient}.
*
* @see FmsAsyncClient#builder()
*/
@Generated("software.amazon.awssdk:codegen")
@SdkInternalApi
final class DefaultFmsAsyncClient implements FmsAsyncClient {
private static final Logger log = LoggerFactory.getLogger(DefaultFmsAsyncClient.class);
private final AsyncClientHandler clientHandler;
private final AwsJsonProtocolFactory protocolFactory;
private final SdkClientConfiguration clientConfiguration;
protected DefaultFmsAsyncClient(SdkClientConfiguration clientConfiguration) {
this.clientHandler = new AwsAsyncClientHandler(clientConfiguration);
this.clientConfiguration = clientConfiguration;
this.protocolFactory = init(AwsJsonProtocolFactory.builder()).build();
}
@Override
public final String serviceName() {
return SERVICE_NAME;
}
/**
*
* Sets the AWS Firewall Manager administrator account. AWS Firewall Manager must be associated with the master
* account of your AWS organization or associated with a member account that has the appropriate permissions. If the
* account ID that you submit is not an AWS Organizations master account, AWS Firewall Manager will set the
* appropriate permissions for the given member account.
*
*
* The account that you associate with AWS Firewall Manager is called the AWS Firewall Manager administrator
* account.
*
*
* @param associateAdminAccountRequest
* @return A Java Future containing the result of the AssociateAdminAccount operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - InvalidOperationException The operation failed because there was nothing to do or the operation
* wasn't possible. For example, you might have submitted an
AssociateAdminAccount
request for
* an account ID that was already set as the AWS Firewall Manager administrator. Or you might have tried to
* access a Region that's disabled by default, and that you need to enable for the Firewall Manager
* administrator account and for AWS Organizations before you can access it.
* - InvalidInputException The parameters of the request were invalid.
* - ResourceNotFoundException The specified resource was not found.
* - InternalErrorException The operation failed because of a system problem, even though the request was
* valid. Retry your request.
* - 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.
* - FmsException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.
*
* @sample FmsAsyncClient.AssociateAdminAccount
* @see AWS API
* Documentation
*/
@Override
public CompletableFuture associateAdminAccount(
AssociateAdminAccountRequest associateAdminAccountRequest) {
List metricPublishers = resolveMetricPublishers(clientConfiguration, associateAdminAccountRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "FMS");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "AssociateAdminAccount");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, AssociateAdminAccountResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("AssociateAdminAccount")
.withMarshaller(new AssociateAdminAccountRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withMetricCollector(apiCallMetricCollector).withInput(associateAdminAccountRequest));
AwsRequestOverrideConfiguration requestOverrideConfig = associateAdminAccountRequest.overrideConfiguration().orElse(
null);
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);
}
}
/**
*
* Permanently deletes an AWS Firewall Manager applications list.
*
*
* @param deleteAppsListRequest
* @return A Java Future containing the result of the DeleteAppsList operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - ResourceNotFoundException The specified resource was not found.
* - InvalidOperationException The operation failed because there was nothing to do or the operation
* wasn't possible. For example, you might have submitted an
AssociateAdminAccount
request for
* an account ID that was already set as the AWS Firewall Manager administrator. Or you might have tried to
* access a Region that's disabled by default, and that you need to enable for the Firewall Manager
* administrator account and for AWS Organizations before you can access it.
* - InternalErrorException The operation failed because of a system problem, even though the request was
* valid. Retry your request.
* - 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.
* - FmsException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.
*
* @sample FmsAsyncClient.DeleteAppsList
* @see AWS API
* Documentation
*/
@Override
public CompletableFuture deleteAppsList(DeleteAppsListRequest deleteAppsListRequest) {
List metricPublishers = resolveMetricPublishers(clientConfiguration, deleteAppsListRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "FMS");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "DeleteAppsList");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, DeleteAppsListResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("DeleteAppsList")
.withMarshaller(new DeleteAppsListRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withMetricCollector(apiCallMetricCollector).withInput(deleteAppsListRequest));
AwsRequestOverrideConfiguration requestOverrideConfig = deleteAppsListRequest.overrideConfiguration().orElse(null);
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 an AWS Firewall Manager association with the IAM role and the Amazon Simple Notification Service (SNS)
* topic that is used to record AWS Firewall Manager SNS logs.
*
*
* @param deleteNotificationChannelRequest
* @return A Java Future containing the result of the DeleteNotificationChannel operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - ResourceNotFoundException The specified resource was not found.
* - InvalidOperationException The operation failed because there was nothing to do or the operation
* wasn't possible. For example, you might have submitted an
AssociateAdminAccount
request for
* an account ID that was already set as the AWS Firewall Manager administrator. Or you might have tried to
* access a Region that's disabled by default, and that you need to enable for the Firewall Manager
* administrator account and for AWS Organizations before you can access it.
* - InternalErrorException The operation failed because of a system problem, even though the request was
* valid. Retry your request.
* - 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.
* - FmsException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.
*
* @sample FmsAsyncClient.DeleteNotificationChannel
* @see AWS
* API Documentation
*/
@Override
public CompletableFuture deleteNotificationChannel(
DeleteNotificationChannelRequest deleteNotificationChannelRequest) {
List metricPublishers = resolveMetricPublishers(clientConfiguration, deleteNotificationChannelRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "FMS");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "DeleteNotificationChannel");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, DeleteNotificationChannelResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("DeleteNotificationChannel")
.withMarshaller(new DeleteNotificationChannelRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withMetricCollector(apiCallMetricCollector).withInput(deleteNotificationChannelRequest));
AwsRequestOverrideConfiguration requestOverrideConfig = deleteNotificationChannelRequest.overrideConfiguration()
.orElse(null);
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);
}
}
/**
*
* Permanently deletes an AWS Firewall Manager policy.
*
*
* @param deletePolicyRequest
* @return A Java Future containing the result of the DeletePolicy operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - ResourceNotFoundException The specified resource was not found.
* - InvalidOperationException The operation failed because there was nothing to do or the operation
* wasn't possible. For example, you might have submitted an
AssociateAdminAccount
request for
* an account ID that was already set as the AWS Firewall Manager administrator. Or you might have tried to
* access a Region that's disabled by default, and that you need to enable for the Firewall Manager
* administrator account and for AWS Organizations before you can access it.
* - InternalErrorException The operation failed because of a system problem, even though the request was
* valid. Retry your request.
* - InvalidInputException The parameters of the request were invalid.
* - LimitExceededException The operation exceeds a resource limit, for example, the maximum number of
*
policy
objects that you can create for an AWS account. For more information, see Firewall Manager Limits
* in the AWS WAF Developer Guide.
* - 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.
* - FmsException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.
*
* @sample FmsAsyncClient.DeletePolicy
* @see AWS API
* Documentation
*/
@Override
public CompletableFuture deletePolicy(DeletePolicyRequest deletePolicyRequest) {
List metricPublishers = resolveMetricPublishers(clientConfiguration, deletePolicyRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "FMS");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "DeletePolicy");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
DeletePolicyResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("DeletePolicy").withMarshaller(new DeletePolicyRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withMetricCollector(apiCallMetricCollector).withInput(deletePolicyRequest));
AwsRequestOverrideConfiguration requestOverrideConfig = deletePolicyRequest.overrideConfiguration().orElse(null);
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);
}
}
/**
*
* Permanently deletes an AWS Firewall Manager protocols list.
*
*
* @param deleteProtocolsListRequest
* @return A Java Future containing the result of the DeleteProtocolsList operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - ResourceNotFoundException The specified resource was not found.
* - InvalidOperationException The operation failed because there was nothing to do or the operation
* wasn't possible. For example, you might have submitted an
AssociateAdminAccount
request for
* an account ID that was already set as the AWS Firewall Manager administrator. Or you might have tried to
* access a Region that's disabled by default, and that you need to enable for the Firewall Manager
* administrator account and for AWS Organizations before you can access it.
* - InternalErrorException The operation failed because of a system problem, even though the request was
* valid. Retry your request.
* - 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.
* - FmsException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.
*
* @sample FmsAsyncClient.DeleteProtocolsList
* @see AWS API
* Documentation
*/
@Override
public CompletableFuture deleteProtocolsList(
DeleteProtocolsListRequest deleteProtocolsListRequest) {
List metricPublishers = resolveMetricPublishers(clientConfiguration, deleteProtocolsListRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "FMS");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "DeleteProtocolsList");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, DeleteProtocolsListResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("DeleteProtocolsList")
.withMarshaller(new DeleteProtocolsListRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withMetricCollector(apiCallMetricCollector).withInput(deleteProtocolsListRequest));
AwsRequestOverrideConfiguration requestOverrideConfig = deleteProtocolsListRequest.overrideConfiguration().orElse(
null);
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 the account that has been set as the AWS Firewall Manager administrator account. To set a different
* account as the administrator account, you must submit an AssociateAdminAccount
request.
*
*
* @param disassociateAdminAccountRequest
* @return A Java Future containing the result of the DisassociateAdminAccount operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - InvalidOperationException The operation failed because there was nothing to do or the operation
* wasn't possible. For example, you might have submitted an
AssociateAdminAccount
request for
* an account ID that was already set as the AWS Firewall Manager administrator. Or you might have tried to
* access a Region that's disabled by default, and that you need to enable for the Firewall Manager
* administrator account and for AWS Organizations before you can access it.
* - ResourceNotFoundException The specified resource was not found.
* - InternalErrorException The operation failed because of a system problem, even though the request was
* valid. Retry your request.
* - 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.
* - FmsException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.
*
* @sample FmsAsyncClient.DisassociateAdminAccount
* @see AWS
* API Documentation
*/
@Override
public CompletableFuture disassociateAdminAccount(
DisassociateAdminAccountRequest disassociateAdminAccountRequest) {
List metricPublishers = resolveMetricPublishers(clientConfiguration, disassociateAdminAccountRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "FMS");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "DisassociateAdminAccount");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, DisassociateAdminAccountResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("DisassociateAdminAccount")
.withMarshaller(new DisassociateAdminAccountRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withMetricCollector(apiCallMetricCollector).withInput(disassociateAdminAccountRequest));
AwsRequestOverrideConfiguration requestOverrideConfig = disassociateAdminAccountRequest.overrideConfiguration()
.orElse(null);
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);
}
}
/**
*
* Returns the AWS Organizations master account that is associated with AWS Firewall Manager as the AWS Firewall
* Manager administrator.
*
*
* @param getAdminAccountRequest
* @return A Java Future containing the result of the GetAdminAccount operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - InvalidOperationException The operation failed because there was nothing to do or the operation
* wasn't possible. For example, you might have submitted an
AssociateAdminAccount
request for
* an account ID that was already set as the AWS Firewall Manager administrator. Or you might have tried to
* access a Region that's disabled by default, and that you need to enable for the Firewall Manager
* administrator account and for AWS Organizations before you can access it.
* - ResourceNotFoundException The specified resource was not found.
* - InternalErrorException The operation failed because of a system problem, even though the request was
* valid. Retry your request.
* - 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.
* - FmsException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.
*
* @sample FmsAsyncClient.GetAdminAccount
* @see AWS API
* Documentation
*/
@Override
public CompletableFuture getAdminAccount(GetAdminAccountRequest getAdminAccountRequest) {
List metricPublishers = resolveMetricPublishers(clientConfiguration, getAdminAccountRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "FMS");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetAdminAccount");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, GetAdminAccountResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("GetAdminAccount")
.withMarshaller(new GetAdminAccountRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withMetricCollector(apiCallMetricCollector).withInput(getAdminAccountRequest));
AwsRequestOverrideConfiguration requestOverrideConfig = getAdminAccountRequest.overrideConfiguration().orElse(null);
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);
}
}
/**
*
* Returns information about the specified AWS Firewall Manager applications list.
*
*
* @param getAppsListRequest
* @return A Java Future containing the result of the GetAppsList operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - ResourceNotFoundException The specified resource was not found.
* - InvalidOperationException The operation failed because there was nothing to do or the operation
* wasn't possible. For example, you might have submitted an
AssociateAdminAccount
request for
* an account ID that was already set as the AWS Firewall Manager administrator. Or you might have tried to
* access a Region that's disabled by default, and that you need to enable for the Firewall Manager
* administrator account and for AWS Organizations before you can access it.
* - InternalErrorException The operation failed because of a system problem, even though the request was
* valid. Retry your request.
* - 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.
* - FmsException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.
*
* @sample FmsAsyncClient.GetAppsList
* @see AWS API
* Documentation
*/
@Override
public CompletableFuture getAppsList(GetAppsListRequest getAppsListRequest) {
List metricPublishers = resolveMetricPublishers(clientConfiguration, getAppsListRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "FMS");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetAppsList");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
GetAppsListResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("GetAppsList").withMarshaller(new GetAppsListRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withMetricCollector(apiCallMetricCollector).withInput(getAppsListRequest));
AwsRequestOverrideConfiguration requestOverrideConfig = getAppsListRequest.overrideConfiguration().orElse(null);
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);
}
}
/**
*
* Returns detailed compliance information about the specified member account. Details include resources that are in
* and out of compliance with the specified policy. Resources are considered noncompliant for AWS WAF and Shield
* Advanced policies if the specified policy has not been applied to them. Resources are considered noncompliant for
* security group policies if they are in scope of the policy, they violate one or more of the policy rules, and
* remediation is disabled or not possible. Resources are considered noncompliant for Network Firewall policies if a
* firewall is missing in the VPC, if the firewall endpoint isn't set up in an expected Availability Zone and
* subnet, if a subnet created by the Firewall Manager doesn't have the expected route table, and for modifications
* to a firewall policy that violate the Firewall Manager policy's rules.
*
*
* @param getComplianceDetailRequest
* @return A Java Future containing the result of the GetComplianceDetail operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - ResourceNotFoundException The specified resource was not found.
* - InternalErrorException The operation failed because of a system problem, even though the request was
* valid. Retry your request.
* - InvalidInputException The parameters of the request were invalid.
* - InvalidOperationException The operation failed because there was nothing to do or the operation
* wasn't possible. For example, you might have submitted an
AssociateAdminAccount
request for
* an account ID that was already set as the AWS Firewall Manager administrator. Or you might have tried to
* access a Region that's disabled by default, and that you need to enable for the Firewall Manager
* administrator account and for AWS Organizations before you can access it.
* - 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.
* - FmsException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.
*
* @sample FmsAsyncClient.GetComplianceDetail
* @see AWS API
* Documentation
*/
@Override
public CompletableFuture getComplianceDetail(
GetComplianceDetailRequest getComplianceDetailRequest) {
List metricPublishers = resolveMetricPublishers(clientConfiguration, getComplianceDetailRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "FMS");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetComplianceDetail");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, GetComplianceDetailResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("GetComplianceDetail")
.withMarshaller(new GetComplianceDetailRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withMetricCollector(apiCallMetricCollector).withInput(getComplianceDetailRequest));
AwsRequestOverrideConfiguration requestOverrideConfig = getComplianceDetailRequest.overrideConfiguration().orElse(
null);
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);
}
}
/**
*
* Information about the Amazon Simple Notification Service (SNS) topic that is used to record AWS Firewall Manager
* SNS logs.
*
*
* @param getNotificationChannelRequest
* @return A Java Future containing the result of the GetNotificationChannel operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - ResourceNotFoundException The specified resource was not found.
* - InvalidOperationException The operation failed because there was nothing to do or the operation
* wasn't possible. For example, you might have submitted an
AssociateAdminAccount
request for
* an account ID that was already set as the AWS Firewall Manager administrator. Or you might have tried to
* access a Region that's disabled by default, and that you need to enable for the Firewall Manager
* administrator account and for AWS Organizations before you can access it.
* - InternalErrorException The operation failed because of a system problem, even though the request was
* valid. Retry your request.
* - 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.
* - FmsException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.
*
* @sample FmsAsyncClient.GetNotificationChannel
* @see AWS API
* Documentation
*/
@Override
public CompletableFuture getNotificationChannel(
GetNotificationChannelRequest getNotificationChannelRequest) {
List metricPublishers = resolveMetricPublishers(clientConfiguration, getNotificationChannelRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "FMS");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetNotificationChannel");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, GetNotificationChannelResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("GetNotificationChannel")
.withMarshaller(new GetNotificationChannelRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withMetricCollector(apiCallMetricCollector).withInput(getNotificationChannelRequest));
AwsRequestOverrideConfiguration requestOverrideConfig = getNotificationChannelRequest.overrideConfiguration().orElse(
null);
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);
}
}
/**
*
* Returns information about the specified AWS Firewall Manager policy.
*
*
* @param getPolicyRequest
* @return A Java Future containing the result of the GetPolicy operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - ResourceNotFoundException The specified resource was not found.
* - InvalidOperationException The operation failed because there was nothing to do or the operation
* wasn't possible. For example, you might have submitted an
AssociateAdminAccount
request for
* an account ID that was already set as the AWS Firewall Manager administrator. Or you might have tried to
* access a Region that's disabled by default, and that you need to enable for the Firewall Manager
* administrator account and for AWS Organizations before you can access it.
* - InternalErrorException The operation failed because of a system problem, even though the request was
* valid. Retry your request.
* - InvalidTypeException The value of the
Type
parameter is invalid.
* - 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.
* - FmsException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.
*
* @sample FmsAsyncClient.GetPolicy
* @see AWS API
* Documentation
*/
@Override
public CompletableFuture getPolicy(GetPolicyRequest getPolicyRequest) {
List metricPublishers = resolveMetricPublishers(clientConfiguration, getPolicyRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "FMS");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetPolicy");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
GetPolicyResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams().withOperationName("GetPolicy")
.withMarshaller(new GetPolicyRequestMarshaller(protocolFactory)).withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler).withMetricCollector(apiCallMetricCollector)
.withInput(getPolicyRequest));
AwsRequestOverrideConfiguration requestOverrideConfig = getPolicyRequest.overrideConfiguration().orElse(null);
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);
}
}
/**
*
* If you created a Shield Advanced policy, returns policy-level attack summary information in the event of a
* potential DDoS attack. Other policy types are currently unsupported.
*
*
* @param getProtectionStatusRequest
* @return A Java Future containing the result of the GetProtectionStatus operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - InvalidInputException The parameters of the request were invalid.
* - ResourceNotFoundException The specified resource was not found.
* - InternalErrorException The operation failed because of a system problem, even though the request was
* valid. Retry your request.
* - 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.
* - FmsException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.
*
* @sample FmsAsyncClient.GetProtectionStatus
* @see AWS API
* Documentation
*/
@Override
public CompletableFuture getProtectionStatus(
GetProtectionStatusRequest getProtectionStatusRequest) {
List metricPublishers = resolveMetricPublishers(clientConfiguration, getProtectionStatusRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "FMS");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetProtectionStatus");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, GetProtectionStatusResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("GetProtectionStatus")
.withMarshaller(new GetProtectionStatusRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withMetricCollector(apiCallMetricCollector).withInput(getProtectionStatusRequest));
AwsRequestOverrideConfiguration requestOverrideConfig = getProtectionStatusRequest.overrideConfiguration().orElse(
null);
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);
}
}
/**
*
* Returns information about the specified AWS Firewall Manager protocols list.
*
*
* @param getProtocolsListRequest
* @return A Java Future containing the result of the GetProtocolsList operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - ResourceNotFoundException The specified resource was not found.
* - InvalidOperationException The operation failed because there was nothing to do or the operation
* wasn't possible. For example, you might have submitted an
AssociateAdminAccount
request for
* an account ID that was already set as the AWS Firewall Manager administrator. Or you might have tried to
* access a Region that's disabled by default, and that you need to enable for the Firewall Manager
* administrator account and for AWS Organizations before you can access it.
* - InternalErrorException The operation failed because of a system problem, even though the request was
* valid. Retry your request.
* - 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.
* - FmsException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.
*
* @sample FmsAsyncClient.GetProtocolsList
* @see AWS API
* Documentation
*/
@Override
public CompletableFuture getProtocolsList(GetProtocolsListRequest getProtocolsListRequest) {
List metricPublishers = resolveMetricPublishers(clientConfiguration, getProtocolsListRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "FMS");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetProtocolsList");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, GetProtocolsListResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("GetProtocolsList")
.withMarshaller(new GetProtocolsListRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withMetricCollector(apiCallMetricCollector).withInput(getProtocolsListRequest));
AwsRequestOverrideConfiguration requestOverrideConfig = getProtocolsListRequest.overrideConfiguration().orElse(null);
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 violations for a resource based on the specified AWS Firewall Manager policy and AWS account.
*
*
* @param getViolationDetailsRequest
* @return A Java Future containing the result of the GetViolationDetails operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - ResourceNotFoundException The specified resource was not found.
* - InvalidInputException The parameters of the request were invalid.
* - InternalErrorException The operation failed because of a system problem, even though the request was
* valid. Retry your request.
* - 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.
* - FmsException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.
*
* @sample FmsAsyncClient.GetViolationDetails
* @see AWS API
* Documentation
*/
@Override
public CompletableFuture getViolationDetails(
GetViolationDetailsRequest getViolationDetailsRequest) {
List metricPublishers = resolveMetricPublishers(clientConfiguration, getViolationDetailsRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "FMS");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetViolationDetails");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, GetViolationDetailsResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("GetViolationDetails")
.withMarshaller(new GetViolationDetailsRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withMetricCollector(apiCallMetricCollector).withInput(getViolationDetailsRequest));
AwsRequestOverrideConfiguration requestOverrideConfig = getViolationDetailsRequest.overrideConfiguration().orElse(
null);
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);
}
}
/**
*
* Returns an array of AppsListDataSummary
objects.
*
*
* @param listAppsListsRequest
* @return A Java Future containing the result of the ListAppsLists operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - ResourceNotFoundException The specified resource was not found.
* - InvalidOperationException The operation failed because there was nothing to do or the operation
* wasn't possible. For example, you might have submitted an
AssociateAdminAccount
request for
* an account ID that was already set as the AWS Firewall Manager administrator. Or you might have tried to
* access a Region that's disabled by default, and that you need to enable for the Firewall Manager
* administrator account and for AWS Organizations before you can access it.
* - LimitExceededException The operation exceeds a resource limit, for example, the maximum number of
*
policy
objects that you can create for an AWS account. For more information, see Firewall Manager Limits
* in the AWS WAF Developer Guide.
* - InternalErrorException The operation failed because of a system problem, even though the request was
* valid. Retry your request.
* - 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.
* - FmsException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.
*
* @sample FmsAsyncClient.ListAppsLists
* @see AWS API
* Documentation
*/
@Override
public CompletableFuture listAppsLists(ListAppsListsRequest listAppsListsRequest) {
List metricPublishers = resolveMetricPublishers(clientConfiguration, listAppsListsRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "FMS");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ListAppsLists");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
ListAppsListsResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("ListAppsLists")
.withMarshaller(new ListAppsListsRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withMetricCollector(apiCallMetricCollector).withInput(listAppsListsRequest));
AwsRequestOverrideConfiguration requestOverrideConfig = listAppsListsRequest.overrideConfiguration().orElse(null);
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);
}
}
/**
*
* Returns an array of PolicyComplianceStatus
objects. Use PolicyComplianceStatus
to get a
* summary of which member accounts are protected by the specified policy.
*
*
* @param listComplianceStatusRequest
* @return A Java Future containing the result of the ListComplianceStatus operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - ResourceNotFoundException The specified resource was not found.
* - InternalErrorException The operation failed because of a system problem, even though the request was
* valid. Retry your request.
* - 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.
* - FmsException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.
*
* @sample FmsAsyncClient.ListComplianceStatus
* @see AWS API
* Documentation
*/
@Override
public CompletableFuture listComplianceStatus(
ListComplianceStatusRequest listComplianceStatusRequest) {
List metricPublishers = resolveMetricPublishers(clientConfiguration, listComplianceStatusRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "FMS");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ListComplianceStatus");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, ListComplianceStatusResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("ListComplianceStatus")
.withMarshaller(new ListComplianceStatusRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withMetricCollector(apiCallMetricCollector).withInput(listComplianceStatusRequest));
AwsRequestOverrideConfiguration requestOverrideConfig = listComplianceStatusRequest.overrideConfiguration().orElse(
null);
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);
}
}
/**
*
* Returns an array of PolicyComplianceStatus
objects. Use PolicyComplianceStatus
to get a
* summary of which member accounts are protected by the specified policy.
*
*
*
* This is a variant of
* {@link #listComplianceStatus(software.amazon.awssdk.services.fms.model.ListComplianceStatusRequest)} 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.fms.paginators.ListComplianceStatusPublisher publisher = client.listComplianceStatusPaginator(request);
* CompletableFuture future = publisher.subscribe(res -> { // Do something with the response });
* future.get();
* }
*
*
* 2) Using a custom subscriber
*
*
* {@code
* software.amazon.awssdk.services.fms.paginators.ListComplianceStatusPublisher publisher = client.listComplianceStatusPaginator(request);
* publisher.subscribe(new Subscriber() {
*
* public void onSubscribe(org.reactivestreams.Subscriber subscription) { //... };
*
*
* public void onNext(software.amazon.awssdk.services.fms.model.ListComplianceStatusResponse 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 #listComplianceStatus(software.amazon.awssdk.services.fms.model.ListComplianceStatusRequest)}
* operation.
*
*
* @param listComplianceStatusRequest
* @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.
*
* - ResourceNotFoundException The specified resource was not found.
* - InternalErrorException The operation failed because of a system problem, even though the request was
* valid. Retry your request.
* - 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.
* - FmsException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.
*
* @sample FmsAsyncClient.ListComplianceStatus
* @see AWS API
* Documentation
*/
public ListComplianceStatusPublisher listComplianceStatusPaginator(ListComplianceStatusRequest listComplianceStatusRequest) {
return new ListComplianceStatusPublisher(this, applyPaginatorUserAgent(listComplianceStatusRequest));
}
/**
*
* Returns a MemberAccounts
object that lists the member accounts in the administrator's AWS
* organization.
*
*
* The ListMemberAccounts
must be submitted by the account that is set as the AWS Firewall Manager
* administrator.
*
*
* @param listMemberAccountsRequest
* @return A Java Future containing the result of the ListMemberAccounts operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - ResourceNotFoundException The specified resource was not found.
* - InternalErrorException The operation failed because of a system problem, even though the request was
* valid. Retry your request.
* - 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.
* - FmsException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.
*
* @sample FmsAsyncClient.ListMemberAccounts
* @see AWS API
* Documentation
*/
@Override
public CompletableFuture listMemberAccounts(ListMemberAccountsRequest listMemberAccountsRequest) {
List metricPublishers = resolveMetricPublishers(clientConfiguration, listMemberAccountsRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "FMS");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ListMemberAccounts");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, ListMemberAccountsResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("ListMemberAccounts")
.withMarshaller(new ListMemberAccountsRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withMetricCollector(apiCallMetricCollector).withInput(listMemberAccountsRequest));
AwsRequestOverrideConfiguration requestOverrideConfig = listMemberAccountsRequest.overrideConfiguration()
.orElse(null);
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);
}
}
/**
*
* Returns a MemberAccounts
object that lists the member accounts in the administrator's AWS
* organization.
*
*
* The ListMemberAccounts
must be submitted by the account that is set as the AWS Firewall Manager
* administrator.
*
*
*
* This is a variant of
* {@link #listMemberAccounts(software.amazon.awssdk.services.fms.model.ListMemberAccountsRequest)} 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.fms.paginators.ListMemberAccountsPublisher publisher = client.listMemberAccountsPaginator(request);
* CompletableFuture future = publisher.subscribe(res -> { // Do something with the response });
* future.get();
* }
*
*
* 2) Using a custom subscriber
*
*
* {@code
* software.amazon.awssdk.services.fms.paginators.ListMemberAccountsPublisher publisher = client.listMemberAccountsPaginator(request);
* publisher.subscribe(new Subscriber() {
*
* public void onSubscribe(org.reactivestreams.Subscriber subscription) { //... };
*
*
* public void onNext(software.amazon.awssdk.services.fms.model.ListMemberAccountsResponse 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 #listMemberAccounts(software.amazon.awssdk.services.fms.model.ListMemberAccountsRequest)} operation.
*
*
* @param listMemberAccountsRequest
* @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.
*
* - ResourceNotFoundException The specified resource was not found.
* - InternalErrorException The operation failed because of a system problem, even though the request was
* valid. Retry your request.
* - 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.
* - FmsException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.
*
* @sample FmsAsyncClient.ListMemberAccounts
* @see AWS API
* Documentation
*/
public ListMemberAccountsPublisher listMemberAccountsPaginator(ListMemberAccountsRequest listMemberAccountsRequest) {
return new ListMemberAccountsPublisher(this, applyPaginatorUserAgent(listMemberAccountsRequest));
}
/**
*
* Returns an array of PolicySummary
objects.
*
*
* @param listPoliciesRequest
* @return A Java Future containing the result of the ListPolicies operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - ResourceNotFoundException The specified resource was not found.
* - InvalidOperationException The operation failed because there was nothing to do or the operation
* wasn't possible. For example, you might have submitted an
AssociateAdminAccount
request for
* an account ID that was already set as the AWS Firewall Manager administrator. Or you might have tried to
* access a Region that's disabled by default, and that you need to enable for the Firewall Manager
* administrator account and for AWS Organizations before you can access it.
* - LimitExceededException The operation exceeds a resource limit, for example, the maximum number of
*
policy
objects that you can create for an AWS account. For more information, see Firewall Manager Limits
* in the AWS WAF Developer Guide.
* - InternalErrorException The operation failed because of a system problem, even though the request was
* valid. Retry your request.
* - 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.
* - FmsException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.
*
* @sample FmsAsyncClient.ListPolicies
* @see AWS API
* Documentation
*/
@Override
public CompletableFuture listPolicies(ListPoliciesRequest listPoliciesRequest) {
List metricPublishers = resolveMetricPublishers(clientConfiguration, listPoliciesRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "FMS");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ListPolicies");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
ListPoliciesResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("ListPolicies").withMarshaller(new ListPoliciesRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withMetricCollector(apiCallMetricCollector).withInput(listPoliciesRequest));
AwsRequestOverrideConfiguration requestOverrideConfig = listPoliciesRequest.overrideConfiguration().orElse(null);
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);
}
}
/**
*
* Returns an array of PolicySummary
objects.
*
*
*
* This is a variant of {@link #listPolicies(software.amazon.awssdk.services.fms.model.ListPoliciesRequest)}
* 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.fms.paginators.ListPoliciesPublisher publisher = client.listPoliciesPaginator(request);
* CompletableFuture future = publisher.subscribe(res -> { // Do something with the response });
* future.get();
* }
*
*
* 2) Using a custom subscriber
*
*
* {@code
* software.amazon.awssdk.services.fms.paginators.ListPoliciesPublisher publisher = client.listPoliciesPaginator(request);
* publisher.subscribe(new Subscriber() {
*
* public void onSubscribe(org.reactivestreams.Subscriber subscription) { //... };
*
*
* public void onNext(software.amazon.awssdk.services.fms.model.ListPoliciesResponse 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 #listPolicies(software.amazon.awssdk.services.fms.model.ListPoliciesRequest)} operation.
*
*
* @param listPoliciesRequest
* @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.
*
* - ResourceNotFoundException The specified resource was not found.
* - InvalidOperationException The operation failed because there was nothing to do or the operation
* wasn't possible. For example, you might have submitted an
AssociateAdminAccount
request for
* an account ID that was already set as the AWS Firewall Manager administrator. Or you might have tried to
* access a Region that's disabled by default, and that you need to enable for the Firewall Manager
* administrator account and for AWS Organizations before you can access it.
* - LimitExceededException The operation exceeds a resource limit, for example, the maximum number of
*
policy
objects that you can create for an AWS account. For more information, see Firewall Manager Limits
* in the AWS WAF Developer Guide.
* - InternalErrorException The operation failed because of a system problem, even though the request was
* valid. Retry your request.
* - 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.
* - FmsException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.
*
* @sample FmsAsyncClient.ListPolicies
* @see AWS API
* Documentation
*/
public ListPoliciesPublisher listPoliciesPaginator(ListPoliciesRequest listPoliciesRequest) {
return new ListPoliciesPublisher(this, applyPaginatorUserAgent(listPoliciesRequest));
}
/**
*
* Returns an array of ProtocolsListDataSummary
objects.
*
*
* @param listProtocolsListsRequest
* @return A Java Future containing the result of the ListProtocolsLists operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - ResourceNotFoundException The specified resource was not found.
* - InvalidOperationException The operation failed because there was nothing to do or the operation
* wasn't possible. For example, you might have submitted an
AssociateAdminAccount
request for
* an account ID that was already set as the AWS Firewall Manager administrator. Or you might have tried to
* access a Region that's disabled by default, and that you need to enable for the Firewall Manager
* administrator account and for AWS Organizations before you can access it.
* - InternalErrorException The operation failed because of a system problem, even though the request was
* valid. Retry your request.
* - 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.
* - FmsException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.
*
* @sample FmsAsyncClient.ListProtocolsLists
* @see AWS API
* Documentation
*/
@Override
public CompletableFuture listProtocolsLists(ListProtocolsListsRequest listProtocolsListsRequest) {
List metricPublishers = resolveMetricPublishers(clientConfiguration, listProtocolsListsRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "FMS");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ListProtocolsLists");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, ListProtocolsListsResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("ListProtocolsLists")
.withMarshaller(new ListProtocolsListsRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withMetricCollector(apiCallMetricCollector).withInput(listProtocolsListsRequest));
AwsRequestOverrideConfiguration requestOverrideConfig = listProtocolsListsRequest.overrideConfiguration()
.orElse(null);
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 list of tags for the specified AWS 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.
*
* - ResourceNotFoundException The specified resource was not found.
* - InvalidOperationException The operation failed because there was nothing to do or the operation
* wasn't possible. For example, you might have submitted an
AssociateAdminAccount
request for
* an account ID that was already set as the AWS Firewall Manager administrator. Or you might have tried to
* access a Region that's disabled by default, and that you need to enable for the Firewall Manager
* administrator account and for AWS Organizations before you can access it.
* - InternalErrorException The operation failed because of a system problem, even though the request was
* valid. Retry your request.
* - InvalidInputException The parameters of the request were invalid.
* - 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.
* - FmsException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.
*
* @sample FmsAsyncClient.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, "FMS");
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));
AwsRequestOverrideConfiguration requestOverrideConfig = listTagsForResourceRequest.overrideConfiguration().orElse(
null);
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 an AWS Firewall Manager applications list.
*
*
* @param putAppsListRequest
* @return A Java Future containing the result of the PutAppsList operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - ResourceNotFoundException The specified resource was not found.
* - InvalidOperationException The operation failed because there was nothing to do or the operation
* wasn't possible. For example, you might have submitted an
AssociateAdminAccount
request for
* an account ID that was already set as the AWS Firewall Manager administrator. Or you might have tried to
* access a Region that's disabled by default, and that you need to enable for the Firewall Manager
* administrator account and for AWS Organizations before you can access it.
* - InvalidInputException The parameters of the request were invalid.
* - LimitExceededException The operation exceeds a resource limit, for example, the maximum number of
*
policy
objects that you can create for an AWS account. For more information, see Firewall Manager Limits
* in the AWS WAF Developer Guide.
* - InternalErrorException The operation failed because of a system problem, even though the request was
* valid. Retry your request.
* - 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.
* - FmsException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.
*
* @sample FmsAsyncClient.PutAppsList
* @see AWS API
* Documentation
*/
@Override
public CompletableFuture putAppsList(PutAppsListRequest putAppsListRequest) {
List metricPublishers = resolveMetricPublishers(clientConfiguration, putAppsListRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "FMS");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "PutAppsList");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
PutAppsListResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("PutAppsList").withMarshaller(new PutAppsListRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withMetricCollector(apiCallMetricCollector).withInput(putAppsListRequest));
AwsRequestOverrideConfiguration requestOverrideConfig = putAppsListRequest.overrideConfiguration().orElse(null);
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);
}
}
/**
*
* Designates the IAM role and Amazon Simple Notification Service (SNS) topic that AWS Firewall Manager uses to
* record SNS logs.
*
*
* To perform this action outside of the console, you must configure the SNS topic to allow the Firewall Manager
* role AWSServiceRoleForFMS
to publish SNS logs. For more information, see Firewall Manager
* required permissions for API actions in the AWS Firewall Manager Developer Guide.
*
*
* @param putNotificationChannelRequest
* @return A Java Future containing the result of the PutNotificationChannel operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - ResourceNotFoundException The specified resource was not found.
* - InvalidOperationException The operation failed because there was nothing to do or the operation
* wasn't possible. For example, you might have submitted an
AssociateAdminAccount
request for
* an account ID that was already set as the AWS Firewall Manager administrator. Or you might have tried to
* access a Region that's disabled by default, and that you need to enable for the Firewall Manager
* administrator account and for AWS Organizations before you can access it.
* - InternalErrorException The operation failed because of a system problem, even though the request was
* valid. Retry your request.
* - 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.
* - FmsException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.
*
* @sample FmsAsyncClient.PutNotificationChannel
* @see AWS API
* Documentation
*/
@Override
public CompletableFuture putNotificationChannel(
PutNotificationChannelRequest putNotificationChannelRequest) {
List metricPublishers = resolveMetricPublishers(clientConfiguration, putNotificationChannelRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "FMS");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "PutNotificationChannel");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, PutNotificationChannelResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("PutNotificationChannel")
.withMarshaller(new PutNotificationChannelRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withMetricCollector(apiCallMetricCollector).withInput(putNotificationChannelRequest));
AwsRequestOverrideConfiguration requestOverrideConfig = putNotificationChannelRequest.overrideConfiguration().orElse(
null);
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 an AWS Firewall Manager policy.
*
*
* Firewall Manager provides the following types of policies:
*
*
* -
*
* An AWS WAF policy (type WAFV2), which defines rule groups to run first in the corresponding AWS WAF web ACL and
* rule groups to run last in the web ACL.
*
*
* -
*
* An AWS WAF Classic policy (type WAF), which defines a rule group.
*
*
* -
*
* A Shield Advanced policy, which applies Shield Advanced protection to specified accounts and resources.
*
*
* -
*
* A security group policy, which manages VPC security groups across your AWS organization.
*
*
* -
*
* An AWS Network Firewall policy, which provides firewall rules to filter network traffic in specified Amazon VPCs.
*
*
*
*
* Each policy is specific to one of the types. If you want to enforce more than one policy type across accounts,
* create multiple policies. You can create multiple policies for each type.
*
*
* You must be subscribed to Shield Advanced to create a Shield Advanced policy. For more information about
* subscribing to Shield Advanced, see CreateSubscription.
*
*
* @param putPolicyRequest
* @return A Java Future containing the result of the PutPolicy operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - ResourceNotFoundException The specified resource was not found.
* - InvalidOperationException The operation failed because there was nothing to do or the operation
* wasn't possible. For example, you might have submitted an
AssociateAdminAccount
request for
* an account ID that was already set as the AWS Firewall Manager administrator. Or you might have tried to
* access a Region that's disabled by default, and that you need to enable for the Firewall Manager
* administrator account and for AWS Organizations before you can access it.
* - InvalidInputException The parameters of the request were invalid.
* - LimitExceededException The operation exceeds a resource limit, for example, the maximum number of
*
policy
objects that you can create for an AWS account. For more information, see Firewall Manager Limits
* in the AWS WAF Developer Guide.
* - InternalErrorException The operation failed because of a system problem, even though the request was
* valid. Retry your request.
* - InvalidTypeException The value of the
Type
parameter is invalid.
* - 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.
* - FmsException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.
*
* @sample FmsAsyncClient.PutPolicy
* @see AWS API
* Documentation
*/
@Override
public CompletableFuture putPolicy(PutPolicyRequest putPolicyRequest) {
List metricPublishers = resolveMetricPublishers(clientConfiguration, putPolicyRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "FMS");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "PutPolicy");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
PutPolicyResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams().withOperationName("PutPolicy")
.withMarshaller(new PutPolicyRequestMarshaller(protocolFactory)).withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler).withMetricCollector(apiCallMetricCollector)
.withInput(putPolicyRequest));
AwsRequestOverrideConfiguration requestOverrideConfig = putPolicyRequest.overrideConfiguration().orElse(null);
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 an AWS Firewall Manager protocols list.
*
*
* @param putProtocolsListRequest
* @return A Java Future containing the result of the PutProtocolsList operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - ResourceNotFoundException The specified resource was not found.
* - InvalidOperationException The operation failed because there was nothing to do or the operation
* wasn't possible. For example, you might have submitted an
AssociateAdminAccount
request for
* an account ID that was already set as the AWS Firewall Manager administrator. Or you might have tried to
* access a Region that's disabled by default, and that you need to enable for the Firewall Manager
* administrator account and for AWS Organizations before you can access it.
* - InvalidInputException The parameters of the request were invalid.
* - LimitExceededException The operation exceeds a resource limit, for example, the maximum number of
*
policy
objects that you can create for an AWS account. For more information, see Firewall Manager Limits
* in the AWS WAF Developer Guide.
* - InternalErrorException The operation failed because of a system problem, even though the request was
* valid. Retry your request.
* - 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.
* - FmsException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.
*
* @sample FmsAsyncClient.PutProtocolsList
* @see AWS API
* Documentation
*/
@Override
public CompletableFuture putProtocolsList(PutProtocolsListRequest putProtocolsListRequest) {
List metricPublishers = resolveMetricPublishers(clientConfiguration, putProtocolsListRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "FMS");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "PutProtocolsList");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, PutProtocolsListResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("PutProtocolsList")
.withMarshaller(new PutProtocolsListRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withMetricCollector(apiCallMetricCollector).withInput(putProtocolsListRequest));
AwsRequestOverrideConfiguration requestOverrideConfig = putProtocolsListRequest.overrideConfiguration().orElse(null);
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);
}
}
/**
*
* Adds one or more tags to an AWS 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.
*
* - ResourceNotFoundException The specified resource was not found.
* - InvalidOperationException The operation failed because there was nothing to do or the operation
* wasn't possible. For example, you might have submitted an
AssociateAdminAccount
request for
* an account ID that was already set as the AWS Firewall Manager administrator. Or you might have tried to
* access a Region that's disabled by default, and that you need to enable for the Firewall Manager
* administrator account and for AWS Organizations before you can access it.
* - InternalErrorException The operation failed because of a system problem, even though the request was
* valid. Retry your request.
* - InvalidInputException The parameters of the request were invalid.
* - LimitExceededException The operation exceeds a resource limit, for example, the maximum number of
*
policy
objects that you can create for an AWS account. For more information, see Firewall Manager Limits
* in the AWS WAF Developer Guide.
* - 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.
* - FmsException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.
*
* @sample FmsAsyncClient.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, "FMS");
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));
AwsRequestOverrideConfiguration requestOverrideConfig = tagResourceRequest.overrideConfiguration().orElse(null);
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 one or more tags from an AWS 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.
*
* - ResourceNotFoundException The specified resource was not found.
* - InvalidOperationException The operation failed because there was nothing to do or the operation
* wasn't possible. For example, you might have submitted an
AssociateAdminAccount
request for
* an account ID that was already set as the AWS Firewall Manager administrator. Or you might have tried to
* access a Region that's disabled by default, and that you need to enable for the Firewall Manager
* administrator account and for AWS Organizations before you can access it.
* - InternalErrorException The operation failed because of a system problem, even though the request was
* valid. Retry your request.
* - InvalidInputException The parameters of the request were invalid.
* - 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.
* - FmsException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
* of this type.
*
* @sample FmsAsyncClient.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, "FMS");
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));
AwsRequestOverrideConfiguration requestOverrideConfig = untagResourceRequest.overrideConfiguration().orElse(null);
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(FmsException::builder)
.protocol(AwsJsonProtocol.AWS_JSON)
.protocolVersion("1.1")
.registerModeledException(
ExceptionMetadata.builder().errorCode("InvalidOperationException")
.exceptionBuilderSupplier(InvalidOperationException::builder).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("ResourceNotFoundException")
.exceptionBuilderSupplier(ResourceNotFoundException::builder).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("InvalidInputException")
.exceptionBuilderSupplier(InvalidInputException::builder).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("InternalErrorException")
.exceptionBuilderSupplier(InternalErrorException::builder).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("LimitExceededException")
.exceptionBuilderSupplier(LimitExceededException::builder).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("InvalidTypeException")
.exceptionBuilderSupplier(InvalidTypeException::builder).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);
}
}