/* * Copyright 2018-2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with * the License. A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions * and limitations under the License. */ package com.amazonaws.services.wafv2; import org.w3c.dom.*; import java.net.*; import java.util.*; import javax.annotation.Generated; import org.apache.commons.logging.*; import com.amazonaws.*; import com.amazonaws.annotation.SdkInternalApi; import com.amazonaws.auth.*; import com.amazonaws.handlers.*; import com.amazonaws.http.*; import com.amazonaws.internal.*; import com.amazonaws.internal.auth.*; import com.amazonaws.metrics.*; import com.amazonaws.regions.*; import com.amazonaws.transform.*; import com.amazonaws.util.*; import com.amazonaws.protocol.json.*; import com.amazonaws.util.AWSRequestMetrics.Field; import com.amazonaws.annotation.ThreadSafe; import com.amazonaws.client.AwsSyncClientParams; import com.amazonaws.client.builder.AdvancedConfig; import com.amazonaws.services.wafv2.AWSWAFV2ClientBuilder; import com.amazonaws.AmazonServiceException; import com.amazonaws.services.wafv2.model.*; import com.amazonaws.services.wafv2.model.transform.*; /** * Client for accessing WAFV2. All service calls made using this client are blocking, and will not return until the * service call completes. *

* WAF *

* This is the latest version of the WAF API, released in November, 2019. The names of the entities that you use * to access this API, like endpoints and namespaces, all have the versioning information added, like "V2" or "v2", to * distinguish from the prior version. We recommend migrating your resources to this version, because it has a number of * significant improvements. *

*

* If you used WAF prior to this release, you can't use this WAFV2 API to access any WAF resources that you created * before. You can access your old rules, web ACLs, and other WAF resources only through the WAF Classic APIs. The WAF * Classic APIs have retained the prior names, endpoints, and namespaces. *

*

* For information, including how to migrate your WAF resources to this version, see the WAF Developer Guide. *

* *

* WAF is a web application firewall that lets you monitor the HTTP and HTTPS requests that are forwarded to an Amazon * CloudFront distribution, Amazon API Gateway REST API, Application Load Balancer, AppSync GraphQL API, Amazon Cognito * user pool, App Runner service, or Amazon Web Services Verified Access instance. WAF also lets you control access to * your content, to protect the Amazon Web Services resource that WAF is monitoring. Based on conditions that you * specify, such as the IP addresses that requests originate from or the values of query strings, the protected resource * responds to requests with either the requested content, an HTTP 403 status code (Forbidden), or with a custom * response. *

*

* This API guide is for developers who need detailed information about WAF API actions, data types, and errors. For * detailed information about WAF features and guidance for configuring and using WAF, see the WAF Developer Guide. *

*

* You can make calls using the endpoints listed in WAF * endpoints and quotas. *

* *

* Alternatively, you can use one of the Amazon Web Services SDKs to access an API that's tailored to the programming * language or platform that you're using. For more information, see Amazon * Web Services SDKs. *

*

* We currently provide two versions of the WAF API: this API and the prior versions, the classic WAF APIs. This new API * provides the same functionality as the older versions, with the following major improvements: *

* */ @ThreadSafe @Generated("com.amazonaws:aws-java-sdk-code-generator") public class AWSWAFV2Client extends AmazonWebServiceClient implements AWSWAFV2 { /** Provider for AWS credentials. */ private final AWSCredentialsProvider awsCredentialsProvider; private static final Log log = LogFactory.getLog(AWSWAFV2.class); /** Default signing name for the service. */ private static final String DEFAULT_SIGNING_NAME = "wafv2"; /** Client configuration factory providing ClientConfigurations tailored to this client */ protected static final ClientConfigurationFactory configFactory = new ClientConfigurationFactory(); private final AdvancedConfig advancedConfig; private static final com.amazonaws.protocol.json.SdkJsonProtocolFactory protocolFactory = new com.amazonaws.protocol.json.SdkJsonProtocolFactory( new JsonClientMetadata() .withProtocolVersion("1.1") .withSupportsCbor(false) .withSupportsIon(false) .addErrorMetadata( new JsonErrorShapeMetadata().withErrorCode("WAFLimitsExceededException").withExceptionUnmarshaller( com.amazonaws.services.wafv2.model.transform.WAFLimitsExceededExceptionUnmarshaller.getInstance())) .addErrorMetadata( new JsonErrorShapeMetadata().withErrorCode("WAFAssociatedItemException").withExceptionUnmarshaller( com.amazonaws.services.wafv2.model.transform.WAFAssociatedItemExceptionUnmarshaller.getInstance())) .addErrorMetadata( new JsonErrorShapeMetadata().withErrorCode("WAFInvalidPermissionPolicyException").withExceptionUnmarshaller( com.amazonaws.services.wafv2.model.transform.WAFInvalidPermissionPolicyExceptionUnmarshaller.getInstance())) .addErrorMetadata( new JsonErrorShapeMetadata().withErrorCode("WAFDuplicateItemException").withExceptionUnmarshaller( com.amazonaws.services.wafv2.model.transform.WAFDuplicateItemExceptionUnmarshaller.getInstance())) .addErrorMetadata( new JsonErrorShapeMetadata().withErrorCode("WAFInvalidParameterException").withExceptionUnmarshaller( com.amazonaws.services.wafv2.model.transform.WAFInvalidParameterExceptionUnmarshaller.getInstance())) .addErrorMetadata( new JsonErrorShapeMetadata().withErrorCode("WAFTagOperationException").withExceptionUnmarshaller( com.amazonaws.services.wafv2.model.transform.WAFTagOperationExceptionUnmarshaller.getInstance())) .addErrorMetadata( new JsonErrorShapeMetadata().withErrorCode("WAFTagOperationInternalErrorException").withExceptionUnmarshaller( com.amazonaws.services.wafv2.model.transform.WAFTagOperationInternalErrorExceptionUnmarshaller.getInstance())) .addErrorMetadata( new JsonErrorShapeMetadata().withErrorCode("WAFSubscriptionNotFoundException").withExceptionUnmarshaller( com.amazonaws.services.wafv2.model.transform.WAFSubscriptionNotFoundExceptionUnmarshaller.getInstance())) .addErrorMetadata( new JsonErrorShapeMetadata().withErrorCode("WAFInvalidResourceException").withExceptionUnmarshaller( com.amazonaws.services.wafv2.model.transform.WAFInvalidResourceExceptionUnmarshaller.getInstance())) .addErrorMetadata( new JsonErrorShapeMetadata().withErrorCode("WAFOptimisticLockException").withExceptionUnmarshaller( com.amazonaws.services.wafv2.model.transform.WAFOptimisticLockExceptionUnmarshaller.getInstance())) .addErrorMetadata( new JsonErrorShapeMetadata().withErrorCode("WAFLogDestinationPermissionIssueException").withExceptionUnmarshaller( com.amazonaws.services.wafv2.model.transform.WAFLogDestinationPermissionIssueExceptionUnmarshaller.getInstance())) .addErrorMetadata( new JsonErrorShapeMetadata().withErrorCode("WAFNonexistentItemException").withExceptionUnmarshaller( com.amazonaws.services.wafv2.model.transform.WAFNonexistentItemExceptionUnmarshaller.getInstance())) .addErrorMetadata( new JsonErrorShapeMetadata().withErrorCode("WAFConfigurationWarningException").withExceptionUnmarshaller( com.amazonaws.services.wafv2.model.transform.WAFConfigurationWarningExceptionUnmarshaller.getInstance())) .addErrorMetadata( new JsonErrorShapeMetadata().withErrorCode("WAFServiceLinkedRoleErrorException").withExceptionUnmarshaller( com.amazonaws.services.wafv2.model.transform.WAFServiceLinkedRoleErrorExceptionUnmarshaller.getInstance())) .addErrorMetadata( new JsonErrorShapeMetadata().withErrorCode("WAFInternalErrorException").withExceptionUnmarshaller( com.amazonaws.services.wafv2.model.transform.WAFInternalErrorExceptionUnmarshaller.getInstance())) .addErrorMetadata( new JsonErrorShapeMetadata().withErrorCode("WAFInvalidOperationException").withExceptionUnmarshaller( com.amazonaws.services.wafv2.model.transform.WAFInvalidOperationExceptionUnmarshaller.getInstance())) .addErrorMetadata( new JsonErrorShapeMetadata().withErrorCode("WAFUnsupportedAggregateKeyTypeException").withExceptionUnmarshaller( com.amazonaws.services.wafv2.model.transform.WAFUnsupportedAggregateKeyTypeExceptionUnmarshaller.getInstance())) .addErrorMetadata( new JsonErrorShapeMetadata().withErrorCode("WAFExpiredManagedRuleGroupVersionException").withExceptionUnmarshaller( com.amazonaws.services.wafv2.model.transform.WAFExpiredManagedRuleGroupVersionExceptionUnmarshaller.getInstance())) .addErrorMetadata( new JsonErrorShapeMetadata().withErrorCode("WAFUnavailableEntityException").withExceptionUnmarshaller( com.amazonaws.services.wafv2.model.transform.WAFUnavailableEntityExceptionUnmarshaller.getInstance())) .withBaseServiceExceptionClass(com.amazonaws.services.wafv2.model.AWSWAFV2Exception.class)); public static AWSWAFV2ClientBuilder builder() { return AWSWAFV2ClientBuilder.standard(); } /** * Constructs a new client to invoke service methods on WAFV2 using the specified parameters. * *

* All service calls made using this new client object are blocking, and will not return until the service call * completes. * * @param clientParams * Object providing client parameters. */ AWSWAFV2Client(AwsSyncClientParams clientParams) { this(clientParams, false); } /** * Constructs a new client to invoke service methods on WAFV2 using the specified parameters. * *

* All service calls made using this new client object are blocking, and will not return until the service call * completes. * * @param clientParams * Object providing client parameters. */ AWSWAFV2Client(AwsSyncClientParams clientParams, boolean endpointDiscoveryEnabled) { super(clientParams); this.awsCredentialsProvider = clientParams.getCredentialsProvider(); this.advancedConfig = clientParams.getAdvancedConfig(); init(); } private void init() { setServiceNameIntern(DEFAULT_SIGNING_NAME); setEndpointPrefix(ENDPOINT_PREFIX); // calling this.setEndPoint(...) will also modify the signer accordingly setEndpoint("wafv2.us-east-1.amazonaws.com"); HandlerChainFactory chainFactory = new HandlerChainFactory(); requestHandler2s.addAll(chainFactory.newRequestHandlerChain("/com/amazonaws/services/wafv2/request.handlers")); requestHandler2s.addAll(chainFactory.newRequestHandler2Chain("/com/amazonaws/services/wafv2/request.handler2s")); requestHandler2s.addAll(chainFactory.getGlobalHandlers()); } /** *

* Associates a web ACL with a regional application resource, to protect the resource. A regional application can be * an Application Load Balancer (ALB), an Amazon API Gateway REST API, an AppSync GraphQL API, an Amazon Cognito * user pool, an App Runner service, or an Amazon Web Services Verified Access instance. *

*

* For Amazon CloudFront, don't use this call. Instead, use your CloudFront distribution configuration. To associate * a web ACL, in the CloudFront call UpdateDistribution, set the web ACL ID to the Amazon Resource Name * (ARN) of the web ACL. For information, see UpdateDistribution in the Amazon CloudFront Developer Guide. *

*

* When you make changes to web ACLs or web ACL components, like rules and rule groups, WAF propagates the changes * everywhere that the web ACL and its components are stored and used. Your changes are applied within seconds, but * there might be a brief period of inconsistency when the changes have arrived in some places and not in others. * So, for example, if you change a rule action setting, the action might be the old action in one area and the new * action in another area. Or if you add an IP address to an IP set used in a blocking rule, the new address might * briefly be blocked in one area while still allowed in another. This temporary inconsistency can occur when you * first associate a web ACL with an Amazon Web Services resource and when you change a web ACL that is already * associated with a resource. Generally, any inconsistencies of this type last only a few seconds. *

* * @param associateWebACLRequest * @return Result of the AssociateWebACL operation returned by the service. * @throws WAFInternalErrorException * Your request is valid, but WAF couldn’t perform the operation because of a system problem. Retry your * request. * @throws WAFInvalidParameterException * The operation failed because WAF didn't recognize a parameter in the request. For example:

*