IApiCall
- class aws_cdk.integ_tests_alpha.IApiCall(*args, **kwargs)
Bases:
IConstruct
,Protocol
(experimental) Represents an ApiCall.
- Stability:
experimental
Methods
- assert_at_path(path, expected)
(experimental) Assert that the ExpectedResult is equal to the result of the AwsApiCall at the given path.
Providing a path will filter the output of the initial API call.
For example the SQS.receiveMessage api response would look like:
If you wanted to assert the value of
Body
you could do- Parameters:
path (
str
) –expected (
ExpectedResult
) –
- Stability:
experimental
- Return type:
Example:
# integ: IntegTest actual = { "Messages": [{ "MessageId": "", "ReceiptHandle": "", "MD5OfBody": "", "Body": "hello", "Attributes": {}, "MD5OfMessageAttributes": {}, "MessageAttributes": {} }] } message = integ.assertions.aws_api_call("SQS", "receiveMessage") message.assert_at_path("Messages.0.Body", ExpectedResult.string_like_regexp("hello"))
- expect(expected)
(experimental) Assert that the ExpectedResult is equal to the result of the AwsApiCall.
- Parameters:
expected (
ExpectedResult
) –- Stability:
experimental
- Return type:
Example:
# integ: IntegTest invoke = integ.assertions.invoke_function( function_name="my-func" ) invoke.expect(ExpectedResult.object_like({"Payload": "OK"}))
- get_att(attribute_name)
(experimental) Returns the value of an attribute of the custom resource of an arbitrary type.
Attributes are returned from the custom resource provider through the
Data
map where the key is the attribute name.- Parameters:
attribute_name (
str
) – the name of the attribute.- Return type:
- Returns:
a token for
Fn::GetAtt
. UseToken.asXxx
to encode the returnedReference
as a specific type or use the conveniencegetAttString
for string attributes.- Stability:
experimental
- get_att_string(attribute_name)
(experimental) Returns the value of an attribute of the custom resource of type string.
Attributes are returned from the custom resource provider through the
Data
map where the key is the attribute name.- Parameters:
attribute_name (
str
) – the name of the attribute.- Return type:
str
- Returns:
a token for
Fn::GetAtt
encoded as a string.- Stability:
experimental
- next(next)
(experimental) Allows you to chain IApiCalls. This adds an explicit dependency betweent the two resources.
Returns the IApiCall provided as
next
Example:
# first: IApiCall # second: IApiCall first.next(second)
- wait_for_assertions(*, backoff_rate=None, interval=None, total_timeout=None)
(experimental) Wait for the IApiCall to return the expected response.
If no expected response is specified then it will wait for the IApiCall to return a success
- Parameters:
backoff_rate (
Union
[int
,float
,None
]) – (experimental) Backoff between attempts. This is the multiplier by which the retry interval increases after each retry attempt. By default there is no backoff. Each retry will wait the amount of time specified byinterval
. Default: 1 (no backoff)interval (
Optional
[Duration
]) – (experimental) The interval (number of seconds) to wait between attempts. Default: Duration.seconds(5)total_timeout (
Optional
[Duration
]) – (experimental) The total time that the state machine will wait for a successful response. Default: Duration.minutes(30)
- Stability:
experimental
- Return type:
Example:
# integ: IntegTest # execution_arn: str integ.assertions.aws_api_call("StepFunctions", "describeExecution", { "execution_arn": execution_arn }).wait_for_assertions()
Attributes
- node
The tree node.
- provider
(experimental) access the AssertionsProvider.
This can be used to add additional IAM policies the the provider role policy
- Stability:
experimental
Example:
# api_call: AwsApiCall api_call.provider.add_to_role_policy({ "Effect": "Allow", "Action": ["s3:GetObject"], "Resource": ["*"] })