Experimental
@aws-cdk/integ-tests-alpha is an experimental (alpha) package: its API may change in any release, without a major version bump.
AwsApiCall
Construct that creates a custom resource that will perform a query using the AWS SDK.
Example
declare const stack: Stack;
new AwsApiCall(stack, 'MyAssertion', {
service: 'SQS',
api: 'receiveMessage',
parameters: {
QueueUrl: 'url',
},
});
# stack: Stack
AwsApiCall(stack, "MyAssertion",
service="SQS",
api="receiveMessage",
parameters={
"QueueUrl": "url"
}
)
Stack stack;
AwsApiCall.Builder.create(stack, "MyAssertion")
.service("SQS")
.api("receiveMessage")
.parameters(Map.of(
"QueueUrl", "url"))
.build();
// Install: dotnet add package Amazon.CDK.IntegTests.Alpha
Stack stack;
new AwsApiCall(stack, "MyAssertion", new AwsApiCallProps {
Service = "SQS",
Api = "receiveMessage",
Parameters = new Dictionary<string, string> {
{ "QueueUrl", "url" }
}
});
// Install: go get github.com/aws/aws-cdk-go/awscdkintegtestsalpha/v2
var stack Stack
awscdkintegtestsalpha.NewAwsApiCall(stack, jsii.String("MyAssertion"), &AwsApiCallProps{
Service: jsii.String("SQS"),
Api: jsii.String("receiveMessage"),
Parameters: map[string]*string{
"QueueUrl": jsii.String("url"),
},
})
Initializer
new AwsApiCall(scope: Construct, id: string, props: AwsApiCallProps)
AwsApiCall(scope: Construct, id: str, props: AwsApiCallProps)
new AwsApiCall(Construct scope, String id, AwsApiCallProps props)
new AwsApiCall(Construct scope, string id, AwsApiCallProps props)
NewAwsApiCall(Scope Construct, Id *string, Props AwsApiCallProps)
Construct Props
outputPathsstring[]output_pathstyping.List[str]outputPathsList<String>OutputPathsstring[]OutputPaths*[]*string= return all data#Use this to limit the data returned by the custom resource if working with API calls that could potentially result in custom response objects exceeding the hard limit of 4096 bytes.
providerLogLevelApplicationLogLevelprovider_log_levelApplicationLogLevelproviderLogLevelApplicationLogLevelProviderLogLevelApplicationLogLevelProviderLogLevelApplicationLogLevel= ApplicationLogLevel.FATAL#Properties
providerAssertionsProviderproviderAssertionsProviderproviderAssertionsProviderProviderAssertionsProviderProviderAssertionsProviderrequired#This can be used to add additional IAM policies the provider role policy
waiterProviderAssertionsProviderwaiter_providerAssertionsProviderwaiterProviderAssertionsProviderWaiterProviderAssertionsProviderWaiterProviderAssertionsProvider#This can be used to add additional IAM policies the provider role policy
example
declare const apiCall: AwsApiCall;
apiCall.waiterProvider?.addToRolePolicy({
Effect: 'Allow',
Action: ['s3:GetObject'],
Resource: ['*'],
});
Methods
assertAtPath(path: string, expected: ExpectedResult): IApiCalldef assert_at_path(self, path: str, expected: ExpectedResult) -> IApiCallpublic IApiCall assertAtPath(String path, ExpectedResult expected)public IApiCall AssertAtPath(string path, ExpectedResult expected)func AssertAtPath(Path *string, Expected ExpectedResult) IApiCall#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
expect(expected: ExpectedResult): IApiCalldef expect(self, expected: ExpectedResult) -> IApiCallpublic IApiCall expect(ExpectedResult expected)public IApiCall Expect(ExpectedResult expected)func Expect(Expected ExpectedResult) IApiCall#getAtt(attributeName: string): Referencedef get_att(self, attribute_name: str) -> Referencepublic Reference getAtt(String attributeName)public Reference GetAtt(string attributeName)func GetAtt(AttributeName *string) Reference#Attributes are returned from the custom resource provider through the Data map where the key is the attribute name.
getAttString(attributeName: string): stringdef get_att_string(self, attribute_name: str) -> strpublic String getAttString(String attributeName)public string GetAttString(string attributeName)func GetAttString(AttributeName *string) *string#Attributes are returned from the custom resource provider through the Data map where the key is the attribute name.
isConstruct(x: any): boolean@staticmethod def is_construct(x: Any) -> boolpublic static Boolean isConstruct(Object x)public static bool IsConstruct(object x)func IsConstruct(X interface{}) *boolstatic#notes · 1 parameter · returns
Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.
Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.
Parameters
xxxxX— Any object.
Returns: true if x is an object created from a class which extends Construct.
next(next: IApiCall): IApiCalldef next(self, next: IApiCall) -> IApiCallpublic IApiCall next(IApiCall next)public IApiCall Next(IApiCall next)func Next(Next IApiCall) IApiCall#Returns the IApiCall provided as next
toString(): stringdef to_string(self, ) -> strpublic String toString()public string ToString()func ToString() *string#waitForAssertions(options?: WaiterStateMachineOptions): IApiCalldef wait_for_assertions(self, options: typing.Optional[WaiterStateMachineOptions] = None) -> IApiCallpublic IApiCall waitForAssertions(WaiterStateMachineOptions options)public IApiCall WaitForAssertions(WaiterStateMachineOptions? options = null)func WaitForAssertions(Options WaiterStateMachineOptions) IApiCall#If no expected response is specified then it will wait for the IApiCall to return a success
with(...mixins: IMixin[]): IConstructdef with(self, mixins: IMixin) -> IConstructpublic IConstruct with(IMixin mixins)public IConstruct With(IMixin mixins)func With(Mixins IMixin) IConstruct#Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited. Use multiple with() calls if subsequent mixins should apply to added constructs.
1 parameter · returns
Parameters
mixinsmixinsmixinsmixinsMixins— The mixins to apply.
Returns: This construct for chaining