test_function¶
Operation¶
test_function
¶
test_function(request: TestFunctionInput | TestFunctionInputDict | None = None, /, *, plugins: list[Plugin] | None = None, **kwargs: Unpack[TestFunctionInputDict]) -> TestFunctionOutput
Tests a CloudFront function.
To test a function, you provide an event object that represents an HTTP request or response that your CloudFront distribution could receive in production. CloudFront runs the function, passing it the event object that you provided, and returns the function's result (the modified event object) in the response. The response also contains function logs and error messages, if any exist. For more information about testing functions, see Testing functions in the Amazon CloudFront Developer Guide.
To test a function, you provide the function's name and version (ETag
value) along with the event object. To get the function's name and
version, you can use ListFunctions and DescribeFunction.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
TestFunctionInput | TestFunctionInputDict | None
|
The input as a model or dictionary. Pass this or keyword arguments, not both. |
None
|
plugins
|
list[Plugin] | None
|
A list of callables that modify the configuration dynamically. Changes made by these plugins only apply for the duration of the operation execution and will not affect any other operation invocations. |
None
|
**kwargs
|
Unpack[TestFunctionInputDict]
|
The input fields as keyword arguments. |
{}
|
Returns:
| Type | Description |
|---|---|
TestFunctionOutput
|
An instance of |
test_function
async
¶
test_function(request: TestFunctionInput | TestFunctionInputDict | None = None, /, *, plugins: list[Plugin] | None = None, **kwargs: Unpack[TestFunctionInputDict]) -> TestFunctionOutput
Tests a CloudFront function.
To test a function, you provide an event object that represents an HTTP request or response that your CloudFront distribution could receive in production. CloudFront runs the function, passing it the event object that you provided, and returns the function's result (the modified event object) in the response. The response also contains function logs and error messages, if any exist. For more information about testing functions, see Testing functions in the Amazon CloudFront Developer Guide.
To test a function, you provide the function's name and version (ETag
value) along with the event object. To get the function's name and
version, you can use ListFunctions and DescribeFunction.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
TestFunctionInput | TestFunctionInputDict | None
|
The input as a model or dictionary. Pass this or keyword arguments, not both. |
None
|
plugins
|
list[Plugin] | None
|
A list of callables that modify the configuration dynamically. Changes made by these plugins only apply for the duration of the operation execution and will not affect any other operation invocations. |
None
|
**kwargs
|
Unpack[TestFunctionInputDict]
|
The input fields as keyword arguments. |
{}
|
Returns:
| Type | Description |
|---|---|
TestFunctionOutput
|
An instance of |
Input¶
Pass the input as keyword arguments, a positional dictionary, or a positional model object. Pass plugins separately as a keyword argument.
TestFunctionInputDict
¶
Bases: TypedDict
Dictionary form of TestFunctionInput.
Attributes¶
event_object
instance-attribute
¶
The event object to test the function with. For more information about the structure of the event object, see Testing functions in the Amazon CloudFront Developer Guide.
if_match
instance-attribute
¶
The current version (ETag value) of the function that you are testing,
which you can get using DescribeFunction.
TestFunctionInput
dataclass
¶
Bases: _SerdeShape
Dataclass for TestFunctionInput structure.
Attributes¶
event_object
class-attribute
instance-attribute
¶
event_object: bytes | None = ...
The event object to test the function with. For more information about the structure of the event object, see Testing functions in the Amazon CloudFront Developer Guide.
if_match
class-attribute
instance-attribute
¶
if_match: str | None = ...
The current version (ETag value) of the function that you are testing,
which you can get using DescribeFunction.
Output¶
TestFunctionOutput
dataclass
¶
Bases: _SerdeShape
Dataclass for TestFunctionOutput structure.
Attributes¶
response_metadata
class-attribute
instance-attribute
¶
Metadata about the response that produced this output. Use this to recover the request identifiers a service's support team needs in order to investigate a call. Members of the metadata are individually optional.
test_result
class-attribute
instance-attribute
¶
test_result: TestResult | None = ...
An object that represents the result of running the function with the provided event object.