test_function
async
¶
test_function(
name: FunctionName,
if_match: string,
event_object: FunctionEventObject,
*,
config_overrides: Optional[AsyncCloudFrontClientConfig] = None,
stage: Optional[FunctionStage] = None,
) -> TestFunctionResult
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(FunctionName) –The name of the function that you are testing.
-
if_match(string) –The current version (
ETagvalue) of the function that you are testing, which you can get usingDescribeFunction. -
stage(Optional[FunctionStage], default:None) –The stage of the function that you are testing, either
DEVELOPMENTorLIVE. -
event_object(FunctionEventObject) –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.
Raises:
-
InvalidArgument–An argument is invalid.
-
InvalidIfMatchVersion–The
If-Matchversion is missing or not valid. -
NoSuchFunctionExists–The function does not exist.
-
TestFunctionFailed–The CloudFront function failed.
-
UnsupportedOperation–This operation is not supported in this Amazon Web Services Region.
-
UnknownServiceError–The service returned an error code this client does not model.
Source code in docs_src/capo_cloudfront/_services/async_cloud_front.py
8841 8842 8843 8844 8845 8846 8847 8848 8849 8850 8851 8852 8853 8854 8855 8856 8857 8858 8859 8860 8861 8862 8863 8864 8865 8866 8867 8868 8869 8870 8871 8872 8873 8874 8875 8876 8877 8878 8879 8880 8881 8882 8883 8884 8885 8886 8887 8888 8889 8890 8891 8892 8893 8894 8895 8896 8897 8898 8899 8900 8901 8902 8903 8904 8905 8906 8907 8908 8909 8910 8911 8912 8913 8914 8915 8916 | |