Creates an API key that contains a set of token domains.
API keys are required for the integration of the CAPTCHA API in your JavaScript client applications. The API lets you customize the placement and characteristics of the CAPTCHA puzzle for your end users. For more information about the CAPTCHA JavaScript integration, see WAF client application integration in the WAF Developer Guide.
You can use a single key for up to 5 domains. After you generate a key, you can copy it for use in your JavaScript integration.
Parameters:
-
scope
(Scope)
–
Specifies whether this is for a global resource type, such as a Amazon CloudFront distribution. For an Amplify application, use CLOUDFRONT.
To work with CloudFront, you must also specify the Region US East (N. Virginia) as follows:
-
CLI - Specify the Region when you use the CloudFront scope: --scope=CLOUDFRONT --region=us-east-1.
-
API and SDKs - For all calls, use the Region endpoint us-east-1.
-
token_domains
(APIKeyTokenDomains)
–
The client application domains that you want to use this API key for.
Example JSON: "TokenDomains": ["abc.com", "store.abc.com"]
Public suffixes aren't allowed. For example, you can't use gov.au or co.uk as token domains.
Raises:
-
WAFInternalErrorException
–
Your request is valid, but WAF couldn’t perform the operation because of a system problem. Retry your request.
-
WAFInvalidOperationException
–
The operation isn't valid.
-
WAFInvalidParameterException
–
The operation failed because WAF didn't recognize a parameter in the request. For example:
-
You specified a parameter name or value that isn't valid.
-
Your nested statement isn't valid. You might have tried to nest a statement that can’t be nested.
-
You tried to update a WebACL with a DefaultAction that isn't among the types available at DefaultAction.
-
Your request references an ARN that is malformed, or corresponds to a resource with which a web ACL can't be associated.
-
WAFLimitsExceededException
–
WAF couldn’t perform the operation because you exceeded your resource limit. For example, the maximum number of WebACL objects that you can create for an Amazon Web Services account. For more information, see WAF quotas in the WAF Developer Guide.
-
UnknownServiceError
–
The service returned an error code this client does not model.
Source code in docs_src/capo_wafv2/_services/wafv2.py
| def create_api_key(
self,
scope: "capo_wafv2.types.scope.Scope",
token_domains: "capo_wafv2.types.api_key_token_domains.APIKeyTokenDomains",
*,
config_overrides: Optional[WAFV2ClientConfig] = None,
) -> "capo_wafv2.types.create_api_key_response.CreateAPIKeyResponse":
"""<p>Creates an API key that contains a set of token domains.</p> <p>API keys are required for the integration of the CAPTCHA API in your JavaScript client applications. The API lets you customize the placement and characteristics of the CAPTCHA puzzle for your end users. For more information about the CAPTCHA JavaScript integration, see <a href="https://docs.aws.amazon.com/waf/latest/developerguide/waf-application-integration.html">WAF client application integration</a> in the <i>WAF Developer Guide</i>.</p> <p>You can use a single key for up to 5 domains. After you generate a key, you can copy it for use in your JavaScript integration. </p>
Args:
scope: <p>Specifies whether this is for a global resource type, such as a Amazon CloudFront distribution. For an Amplify application, use <code>CLOUDFRONT</code>.</p> <p>To work with CloudFront, you must also specify the Region US East (N. Virginia) as follows: </p> <ul> <li> <p>CLI - Specify the Region when you use the CloudFront scope: <code>--scope=CLOUDFRONT --region=us-east-1</code>. </p> </li> <li> <p>API and SDKs - For all calls, use the Region endpoint us-east-1. </p> </li> </ul>
token_domains: <p>The client application domains that you want to use this API key for. </p> <p>Example JSON: <code>"TokenDomains": ["abc.com", "store.abc.com"]</code> </p> <p>Public suffixes aren't allowed. For example, you can't use <code>gov.au</code> or <code>co.uk</code> as token domains.</p>
Raises:
capo_wafv2.errors.waf_internal_error_exception.WAFInternalErrorException: <p>Your request is valid, but WAF couldn’t perform the operation because of a system problem. Retry your request. </p>
capo_wafv2.errors.waf_invalid_operation_exception.WAFInvalidOperationException: <p>The operation isn't valid. </p>
capo_wafv2.errors.waf_invalid_parameter_exception.WAFInvalidParameterException: <p>The operation failed because WAF didn't recognize a parameter in the request. For example: </p> <ul> <li> <p>You specified a parameter name or value that isn't valid.</p> </li> <li> <p>Your nested statement isn't valid. You might have tried to nest a statement that can’t be nested. </p> </li> <li> <p>You tried to update a <code>WebACL</code> with a <code>DefaultAction</code> that isn't among the types available at <a>DefaultAction</a>.</p> </li> <li> <p>Your request references an ARN that is malformed, or corresponds to a resource with which a web ACL can't be associated.</p> </li> </ul>
capo_wafv2.errors.waf_limits_exceeded_exception.WAFLimitsExceededException: <p>WAF couldn’t perform the operation because you exceeded your resource limit. For example, the maximum number of <code>WebACL</code> objects that you can create for an Amazon Web Services account. For more information, see <a href="https://docs.aws.amazon.com/waf/latest/developerguide/limits.html">WAF quotas</a> in the <i>WAF Developer Guide</i>.</p>
capo_wafv2.errors.UnknownServiceError: The service returned an error code this client does not model.
"""
def _handler(
req: "OperationRequest[capo_wafv2.types.create_api_key_request.CreateAPIKeyRequest]",
) -> OperationResponse[
"capo_wafv2.types.create_api_key_response.CreateAPIKeyResponse"
]:
import capo_wafv2._operations.awswaf_20190729.create_api_key
output, http_response = (
capo_wafv2._operations.awswaf_20190729.create_api_key.create_api_key(
req.options, req.input
)
)
return OperationResponse(output=output, response=http_response)
interceptors_, options_ = self.operation_options(
config_overrides, OperationLogging("CreateAPIKey")
)
input_: capo_wafv2.types.create_api_key_request.CreateAPIKeyRequest = {
"scope": scope,
"token_domains": token_domains,
}
response = execute_pipeline(
OperationRequest(input=input_, options=options_),
handler=_handler,
interceptors=list(interceptors_),
)
response.response.close()
return response.output
|