WebSocketIntegration
- class aws_cdk.aws_apigatewayv2.WebSocketIntegration(scope, id, *, integration_type, integration_uri, web_socket_api, content_handling=None, credentials_role=None, integration_method=None, passthrough_behavior=None, request_parameters=None, request_templates=None, template_selection_expression=None, timeout=None)
Bases:
Resource
The integration for an API route.
- Resource:
AWS::ApiGatewayV2::Integration
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. import aws_cdk as cdk from aws_cdk import aws_apigatewayv2 as apigatewayv2 from aws_cdk import aws_iam as iam # role: iam.Role # web_socket_api: apigatewayv2.WebSocketApi web_socket_integration = apigatewayv2.WebSocketIntegration(self, "MyWebSocketIntegration", integration_type=apigatewayv2.WebSocketIntegrationType.AWS_PROXY, integration_uri="integrationUri", web_socket_api=web_socket_api, # the properties below are optional content_handling=apigatewayv2.ContentHandling.CONVERT_TO_BINARY, credentials_role=role, integration_method="integrationMethod", passthrough_behavior=apigatewayv2.PassthroughBehavior.WHEN_NO_MATCH, request_parameters={ "request_parameters_key": "requestParameters" }, request_templates={ "request_templates_key": "requestTemplates" }, template_selection_expression="templateSelectionExpression", timeout=cdk.Duration.minutes(30) )
- Parameters:
scope (
Construct
) –id (
str
) –integration_type (
WebSocketIntegrationType
) – Integration type.integration_uri (
str
) – Integration URI.web_socket_api (
IWebSocketApi
) – The WebSocket API to which this integration should be bound.content_handling (
Optional
[ContentHandling
]) – Specifies how to handle response payload content type conversions. Default: - The response payload will be passed through from the integration response to the route response or method response without modification.credentials_role (
Optional
[IRole
]) – Specifies the IAM role required for the integration. Default: - No IAM role required.integration_method (
Optional
[str
]) – Specifies the integration’s HTTP method type. Default: - No HTTP method required.passthrough_behavior (
Optional
[PassthroughBehavior
]) – Specifies the pass-through behavior for incoming requests based on the Content-Type header in the request, and the available mapping templates specified as the requestTemplates property on the Integration resource. There are three valid values: WHEN_NO_MATCH, WHEN_NO_TEMPLATES, and NEVER. Default: - No passthrough behavior required.request_parameters (
Optional
[Mapping
[str
,str
]]) – The request parameters that API Gateway sends with the backend request. Specify request parameters as key-value pairs (string-to-string mappings), with a destination as the key and a source as the value. Default: - No request parameters required.request_templates (
Optional
[Mapping
[str
,str
]]) – A map of Apache Velocity templates that are applied on the request payload. Example:: { “application/json”: “{ "statusCode": 200 }” } Default: - No request templates required.template_selection_expression (
Optional
[str
]) – The template selection expression for the integration. Default: - No template selection expression required.timeout (
Optional
[Duration
]) – The maximum amount of time an integration will run before it returns without a response. Must be between 50 milliseconds and 29 seconds. Default: Duration.seconds(29)
Methods
- apply_removal_policy(policy)
Apply the given removal policy to this resource.
The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you’ve removed it from the CDK application or because you’ve made a change that requires the resource to be replaced.
The resource can be deleted (
RemovalPolicy.DESTROY
), or left in your AWS account for data recovery and cleanup later (RemovalPolicy.RETAIN
).- Parameters:
policy (
RemovalPolicy
) –- Return type:
None
- to_string()
Returns a string representation of this construct.
- Return type:
str
Attributes
- env
The environment this resource belongs to.
For resources that are created and managed by the CDK (generally, those created by creating new class instances like Role, Bucket, etc.), this is always the same as the environment of the stack they belong to; however, for imported resources (those obtained from static methods like fromRoleArn, fromBucketName, etc.), that might be different than the stack they were imported into.
- integration_id
Id of the integration.
- node
The tree node.
- stack
The stack in which this resource is defined.
- web_socket_api
The WebSocket API associated with this integration.
Static Methods
- classmethod is_construct(x)
Checks if
x
is a construct.Use this method instead of
instanceof
to properly detectConstruct
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 classConstruct
in each copy of theconstructs
library is seen as a different class, and an instance of one class will not test asinstanceof
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 theconstructs
library can be accidentally installed, andinstanceof
will behave unpredictably. It is safest to avoid usinginstanceof
, and using this type-testing method instead.- Parameters:
x (
Any
) – Any object.- Return type:
bool
- Returns:
true if
x
is an object created from a class which extendsConstruct
.
- classmethod is_owned_resource(construct)
Returns true if the construct was created by CDK, and false otherwise.
- Parameters:
construct (
IConstruct
) –- Return type:
bool
- classmethod is_resource(construct)
Check whether the given construct is a Resource.
- Parameters:
construct (
IConstruct
) –- Return type:
bool