CfnMethodPropsMixin
- class aws_cdk.mixins_preview.aws_apigateway.mixins.CfnMethodPropsMixin(props, *, strategy=None)
Bases:
MixinThe
AWS::ApiGateway::Methodresource creates API Gateway methods that define the parameters and body that clients must send in their requests.- See:
http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-method.html
- CloudformationResource:
AWS::ApiGateway::Method
- Mixin:
true
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. from aws_cdk.mixins_preview import mixins from aws_cdk.mixins_preview.aws_apigateway import mixins as apigateway_mixins cfn_method_props_mixin = apigateway_mixins.CfnMethodPropsMixin(apigateway_mixins.CfnMethodMixinProps( api_key_required=False, authorization_scopes=["authorizationScopes"], authorization_type="authorizationType", authorizer_id="authorizerId", http_method="httpMethod", integration=apigateway_mixins.CfnMethodPropsMixin.IntegrationProperty( cache_key_parameters=["cacheKeyParameters"], cache_namespace="cacheNamespace", connection_id="connectionId", connection_type="connectionType", content_handling="contentHandling", credentials="credentials", integration_http_method="integrationHttpMethod", integration_responses=[apigateway_mixins.CfnMethodPropsMixin.IntegrationResponseProperty( content_handling="contentHandling", response_parameters={ "response_parameters_key": "responseParameters" }, response_templates={ "response_templates_key": "responseTemplates" }, selection_pattern="selectionPattern", status_code="statusCode" )], integration_target="integrationTarget", passthrough_behavior="passthroughBehavior", request_parameters={ "request_parameters_key": "requestParameters" }, request_templates={ "request_templates_key": "requestTemplates" }, response_transfer_mode="responseTransferMode", timeout_in_millis=123, type="type", uri="uri" ), method_responses=[apigateway_mixins.CfnMethodPropsMixin.MethodResponseProperty( response_models={ "response_models_key": "responseModels" }, response_parameters={ "response_parameters_key": False }, status_code="statusCode" )], operation_name="operationName", request_models={ "request_models_key": "requestModels" }, request_parameters={ "request_parameters_key": False }, request_validator_id="requestValidatorId", resource_id="resourceId", rest_api_id="restApiId" ), strategy=mixins.PropertyMergeStrategy.OVERRIDE )
Create a mixin to apply properties to
AWS::ApiGateway::Method.- Parameters:
props (
Union[CfnMethodMixinProps,Dict[str,Any]]) – L1 properties to apply.strategy (
Optional[PropertyMergeStrategy]) – (experimental) Strategy for merging nested properties. Default: - PropertyMergeStrategy.MERGE
Methods
- apply_to(construct)
Apply the mixin properties to the construct.
- Parameters:
construct (
IConstruct)- Return type:
- supports(construct)
Check if this mixin supports the given construct.
- Parameters:
construct (
IConstruct)- Return type:
bool
Attributes
- CFN_PROPERTY_KEYS = ['apiKeyRequired', 'authorizationScopes', 'authorizationType', 'authorizerId', 'httpMethod', 'integration', 'methodResponses', 'operationName', 'requestModels', 'requestParameters', 'requestValidatorId', 'resourceId', 'restApiId']
Static Methods
- classmethod is_mixin(x)
(experimental) Checks if
xis a Mixin.- Parameters:
x (
Any) – Any object.- Return type:
bool- Returns:
true if
xis an object created from a class which extendsMixin.- Stability:
experimental
IntegrationProperty
- class CfnMethodPropsMixin.IntegrationProperty(*, cache_key_parameters=None, cache_namespace=None, connection_id=None, connection_type=None, content_handling=None, credentials=None, integration_http_method=None, integration_responses=None, integration_target=None, passthrough_behavior=None, request_parameters=None, request_templates=None, response_transfer_mode=None, timeout_in_millis=None, type=None, uri=None)
Bases:
objectIntegrationis a property of the AWS::ApiGateway::Method resource that specifies information about the target backend that a method calls.- Parameters:
cache_key_parameters (
Optional[Sequence[str]]) – A list of request parameters whose values API Gateway caches. To be valid values forcacheKeyParameters, these parameters must also be specified for MethodrequestParameters.cache_namespace (
Optional[str]) – Specifies a group of related cached parameters. By default, API Gateway uses the resource ID as thecacheNamespace. You can specify the samecacheNamespaceacross resources to return the same cached data for requests to different resources.connection_id (
Optional[str]) – The ID of the VpcLink used for the integration whenconnectionType=VPC_LINKand undefined, otherwise.connection_type (
Optional[str]) – The type of the network connection to the integration endpoint. The valid value isINTERNETfor connections through the public routable internet orVPC_LINKfor private connections between API Gateway and a network load balancer in a VPC. The default value isINTERNET.content_handling (
Optional[str]) – Specifies how to handle request payload content type conversions. Supported values areCONVERT_TO_BINARYandCONVERT_TO_TEXT, with the following behaviors: If this property is not defined, the request payload will be passed through from the method request to integration request without modification, provided that thepassthroughBehavioris configured to support payload pass-through.credentials (
Optional[str]) – Specifies the credentials required for the integration, if any. For AWS integrations, three options are available. To specify an IAM Role for API Gateway to assume, use the role’s Amazon Resource Name (ARN). To require that the caller’s identity be passed through from the request, specify the stringarn:aws:iam::\*:user/\*. To use resource-based permissions on supported AWS services, specify null.integration_http_method (
Optional[str]) – Specifies the integration’s HTTP method type. For the Type property, if you specifyMOCK, this property is optional. For Lambda integrations, you must set the integration method toPOST. For all other types, you must specify this property.integration_responses (
Union[IResolvable,Sequence[Union[IResolvable,IntegrationResponseProperty,Dict[str,Any]]],None]) – Specifies the integration’s responses.integration_target (
Optional[str]) – The ALB or NLB listener to send the request to. Only supported for private integrations that use VPC links V2.passthrough_behavior (
Optional[str]) – Specifies how the method request body of an unmapped content type will be passed through the integration request to the back end without transformation. A content type is unmapped if no mapping template is defined in the integration or the content type does not match any of the mapped content types, as specified inrequestTemplates. The valid value is one of the following:WHEN_NO_MATCH: passes the method request body through the integration request to the back end without transformation when the method request content type does not match any content type associated with the mapping templates defined in the integration request.WHEN_NO_TEMPLATES: passes the method request body through the integration request to the back end without transformation when no mapping template is defined in the integration request. If a template is defined when this option is selected, the method request of an unmapped content-type will be rejected with an HTTP 415 Unsupported Media Type response.NEVER: rejects the method request with an HTTP 415 Unsupported Media Type response when either the method request content type does not match any content type associated with the mapping templates defined in the integration request or no mapping template is defined in the integration request.request_parameters (
Union[Mapping[str,str],IResolvable,None]) – A key-value map specifying request parameters that are passed from the method request to the back end. The key is an integration request parameter name and the associated value is a method request parameter value or static value that must be enclosed within single quotes and pre-encoded as required by the back end. The method request parameter value must match the pattern ofmethod.request.{location}.{name}, wherelocationisquerystring,path, orheaderandnamemust be a valid and unique method request parameter name.request_templates (
Union[Mapping[str,str],IResolvable,None]) – Represents a map of Velocity templates that are applied on the request payload based on the value of the Content-Type header sent by the client. The content type value is the key in this map, and the template (as a String) is the value.response_transfer_mode (
Optional[str]) – The response transfer mode of the integration. UseSTREAMto have API Gateway stream response your back to you or useBUFFEREDto have API Gateway wait to receive the complete response before beginning transmission. Default: - “BUFFERED”timeout_in_millis (
Union[int,float,None]) – Custom timeout between 50 and 29,000 milliseconds. The default value is 29,000 milliseconds or 29 seconds. You can increase the default value to longer than 29 seconds for Regional or private APIs only.type (
Optional[str]) – Specifies an API method integration type. The valid value is one of the following:. For the HTTP and HTTP proxy integrations, each integration can specify a protocol (http/https), port and path. Standard 80 and 443 ports are supported as well as custom ports above 1024. An HTTP or HTTP proxy integration with aconnectionTypeofVPC_LINKis referred to as a private integration and uses a VpcLink to connect API Gateway to a network load balancer of a VPC.uri (
Optional[str]) – Specifies Uniform Resource Identifier (URI) of the integration endpoint. ForHTTPorHTTP_PROXYintegrations, the URI must be a fully formed, encoded HTTP(S) URL according to the RFC-3986 specification for standard integrations. IfconnectionTypeisVPC_LINKspecify the Network Load Balancer DNS name. ForAWSorAWS_PROXYintegrations, the URI is of the formarn:aws:apigateway:{region}:{subdomain.service|service}:path|action/{service_api}. Here, {Region} is the API Gateway region (e.g., us-east-1); {service} is the name of the integrated AWS service (e.g., s3); and {subdomain} is a designated subdomain supported by certain AWS service for fast host-name lookup. action can be used for an AWS service action-based API, using an Action={name}&{p1}={v1}&p2={v2}… query string. The ensuing {service_api} refers to a supported action {name} plus any required input parameters. Alternatively, path can be used for an AWS service path-based API. The ensuing service_api refers to the path to an AWS service resource, including the region of the integrated AWS service, if applicable. For example, for integration with the S3 API of GetObject, the uri can be eitherarn:aws:apigateway:us-west-2:s3:action/GetObject&Bucket={bucket}&Key={key}orarn:aws:apigateway:us-west-2:s3:path/{bucket}/{key}
- See:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. from aws_cdk.mixins_preview.aws_apigateway import mixins as apigateway_mixins integration_property = apigateway_mixins.CfnMethodPropsMixin.IntegrationProperty( cache_key_parameters=["cacheKeyParameters"], cache_namespace="cacheNamespace", connection_id="connectionId", connection_type="connectionType", content_handling="contentHandling", credentials="credentials", integration_http_method="integrationHttpMethod", integration_responses=[apigateway_mixins.CfnMethodPropsMixin.IntegrationResponseProperty( content_handling="contentHandling", response_parameters={ "response_parameters_key": "responseParameters" }, response_templates={ "response_templates_key": "responseTemplates" }, selection_pattern="selectionPattern", status_code="statusCode" )], integration_target="integrationTarget", passthrough_behavior="passthroughBehavior", request_parameters={ "request_parameters_key": "requestParameters" }, request_templates={ "request_templates_key": "requestTemplates" }, response_transfer_mode="responseTransferMode", timeout_in_millis=123, type="type", uri="uri" )
Attributes
- cache_key_parameters
A list of request parameters whose values API Gateway caches.
To be valid values for
cacheKeyParameters, these parameters must also be specified for MethodrequestParameters.
- cache_namespace
Specifies a group of related cached parameters.
By default, API Gateway uses the resource ID as the
cacheNamespace. You can specify the samecacheNamespaceacross resources to return the same cached data for requests to different resources.
- connection_id
The ID of the VpcLink used for the integration when
connectionType=VPC_LINKand undefined, otherwise.
- connection_type
The type of the network connection to the integration endpoint.
The valid value is
INTERNETfor connections through the public routable internet orVPC_LINKfor private connections between API Gateway and a network load balancer in a VPC. The default value isINTERNET.
- content_handling
Specifies how to handle request payload content type conversions.
Supported values are
CONVERT_TO_BINARYandCONVERT_TO_TEXT, with the following behaviors:If this property is not defined, the request payload will be passed through from the method request to integration request without modification, provided that the
passthroughBehavioris configured to support payload pass-through.
- credentials
Specifies the credentials required for the integration, if any.
For AWS integrations, three options are available. To specify an IAM Role for API Gateway to assume, use the role’s Amazon Resource Name (ARN). To require that the caller’s identity be passed through from the request, specify the string
arn:aws:iam::\*:user/\*. To use resource-based permissions on supported AWS services, specify null.
- integration_http_method
Specifies the integration’s HTTP method type.
For the Type property, if you specify
MOCK, this property is optional. For Lambda integrations, you must set the integration method toPOST. For all other types, you must specify this property.
- integration_responses
Specifies the integration’s responses.
- integration_target
The ALB or NLB listener to send the request to.
Only supported for private integrations that use VPC links V2.
- passthrough_behavior
Specifies how the method request body of an unmapped content type will be passed through the integration request to the back end without transformation.
A content type is unmapped if no mapping template is defined in the integration or the content type does not match any of the mapped content types, as specified in
requestTemplates. The valid value is one of the following:WHEN_NO_MATCH: passes the method request body through the integration request to the back end without transformation when the method request content type does not match any content type associated with the mapping templates defined in the integration request.WHEN_NO_TEMPLATES: passes the method request body through the integration request to the back end without transformation when no mapping template is defined in the integration request. If a template is defined when this option is selected, the method request of an unmapped content-type will be rejected with an HTTP 415 Unsupported Media Type response.NEVER: rejects the method request with an HTTP 415 Unsupported Media Type response when either the method request content type does not match any content type associated with the mapping templates defined in the integration request or no mapping template is defined in the integration request.
- request_parameters
A key-value map specifying request parameters that are passed from the method request to the back end.
The key is an integration request parameter name and the associated value is a method request parameter value or static value that must be enclosed within single quotes and pre-encoded as required by the back end. The method request parameter value must match the pattern of
method.request.{location}.{name}, wherelocationisquerystring,path, orheaderandnamemust be a valid and unique method request parameter name.
- request_templates
Represents a map of Velocity templates that are applied on the request payload based on the value of the Content-Type header sent by the client.
The content type value is the key in this map, and the template (as a String) is the value.
- response_transfer_mode
The response transfer mode of the integration.
Use
STREAMto have API Gateway stream response your back to you or useBUFFEREDto have API Gateway wait to receive the complete response before beginning transmission.
- timeout_in_millis
Custom timeout between 50 and 29,000 milliseconds.
The default value is 29,000 milliseconds or 29 seconds. You can increase the default value to longer than 29 seconds for Regional or private APIs only.
- type
.
For the HTTP and HTTP proxy integrations, each integration can specify a protocol (
http/https), port and path. Standard 80 and 443 ports are supported as well as custom ports above 1024. An HTTP or HTTP proxy integration with aconnectionTypeofVPC_LINKis referred to as a private integration and uses a VpcLink to connect API Gateway to a network load balancer of a VPC.- See:
- Type:
Specifies an API method integration type. The valid value is one of the following
- uri
Specifies Uniform Resource Identifier (URI) of the integration endpoint.
For
HTTPorHTTP_PROXYintegrations, the URI must be a fully formed, encoded HTTP(S) URL according to the RFC-3986 specification for standard integrations. IfconnectionTypeisVPC_LINKspecify the Network Load Balancer DNS name. ForAWSorAWS_PROXYintegrations, the URI is of the formarn:aws:apigateway:{region}:{subdomain.service|service}:path|action/{service_api}. Here, {Region} is the API Gateway region (e.g., us-east-1); {service} is the name of the integrated AWS service (e.g., s3); and {subdomain} is a designated subdomain supported by certain AWS service for fast host-name lookup. action can be used for an AWS service action-based API, using an Action={name}&{p1}={v1}&p2={v2}… query string. The ensuing {service_api} refers to a supported action {name} plus any required input parameters. Alternatively, path can be used for an AWS service path-based API. The ensuing service_api refers to the path to an AWS service resource, including the region of the integrated AWS service, if applicable. For example, for integration with the S3 API of GetObject, the uri can be eitherarn:aws:apigateway:us-west-2:s3:action/GetObject&Bucket={bucket}&Key={key}orarn:aws:apigateway:us-west-2:s3:path/{bucket}/{key}
IntegrationResponseProperty
- class CfnMethodPropsMixin.IntegrationResponseProperty(*, content_handling=None, response_parameters=None, response_templates=None, selection_pattern=None, status_code=None)
Bases:
objectIntegrationResponseis a property of the Amazon API Gateway Method Integration property type that specifies the response that API Gateway sends after a method’s backend finishes processing a request.- Parameters:
content_handling (
Optional[str]) – Specifies how to handle response payload content type conversions. Supported values areCONVERT_TO_BINARYandCONVERT_TO_TEXT, with the following behaviors: If this property is not defined, the response payload will be passed through from the integration response to the method response without modification.response_parameters (
Union[Mapping[str,str],IResolvable,None]) – A key-value map specifying response parameters that are passed to the method response from the back end. The key is a method response header parameter name and the mapped value is an integration response header value, a static value enclosed within a pair of single quotes, or a JSON expression from the integration response body. The mapping key must match the pattern ofmethod.response.header.{name}, wherenameis a valid and unique header name. The mapped non-static value must match the pattern ofintegration.response.header.{name}orintegration.response.body.{JSON-expression}, wherenameis a valid and unique response header name andJSON-expressionis a valid JSON expression without the$prefix.response_templates (
Union[Mapping[str,str],IResolvable,None]) – Specifies the templates used to transform the integration response body. Response templates are represented as a key/value map, with a content-type as the key and a template as the value.selection_pattern (
Optional[str]) – Specifies the regular expression (regex) pattern used to choose an integration response based on the response from the back end. For example, if the success response returns nothing and the error response returns some string, you could use the.+regex to match error response. However, make sure that the error response does not contain any newline (\n) character in such cases. If the back end is an AWS Lambda function, the AWS Lambda function error header is matched. For all other HTTP and AWS back ends, the HTTP status code is matched.status_code (
Optional[str]) – Specifies the status code that is used to map the integration response to an existing MethodResponse.
- See:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. from aws_cdk.mixins_preview.aws_apigateway import mixins as apigateway_mixins integration_response_property = apigateway_mixins.CfnMethodPropsMixin.IntegrationResponseProperty( content_handling="contentHandling", response_parameters={ "response_parameters_key": "responseParameters" }, response_templates={ "response_templates_key": "responseTemplates" }, selection_pattern="selectionPattern", status_code="statusCode" )
Attributes
- content_handling
Specifies how to handle response payload content type conversions.
Supported values are
CONVERT_TO_BINARYandCONVERT_TO_TEXT, with the following behaviors:If this property is not defined, the response payload will be passed through from the integration response to the method response without modification.
- response_parameters
A key-value map specifying response parameters that are passed to the method response from the back end.
The key is a method response header parameter name and the mapped value is an integration response header value, a static value enclosed within a pair of single quotes, or a JSON expression from the integration response body. The mapping key must match the pattern of
method.response.header.{name}, wherenameis a valid and unique header name. The mapped non-static value must match the pattern ofintegration.response.header.{name}orintegration.response.body.{JSON-expression}, wherenameis a valid and unique response header name andJSON-expressionis a valid JSON expression without the$prefix.
- response_templates
Specifies the templates used to transform the integration response body.
Response templates are represented as a key/value map, with a content-type as the key and a template as the value.
- selection_pattern
Specifies the regular expression (regex) pattern used to choose an integration response based on the response from the back end.
For example, if the success response returns nothing and the error response returns some string, you could use the
.+regex to match error response. However, make sure that the error response does not contain any newline (\n) character in such cases. If the back end is an AWS Lambda function, the AWS Lambda function error header is matched. For all other HTTP and AWS back ends, the HTTP status code is matched.
- status_code
Specifies the status code that is used to map the integration response to an existing MethodResponse.
MethodResponseProperty
- class CfnMethodPropsMixin.MethodResponseProperty(*, response_models=None, response_parameters=None, status_code=None)
Bases:
objectRepresents a method response of a given HTTP status code returned to the client.
The method response is passed from the back end through the associated integration response that can be transformed using a mapping template.
- Parameters:
response_models (
Union[Mapping[str,str],IResolvable,None]) – Specifies the Model resources used for the response’s content-type. Response models are represented as a key/value map, with a content-type as the key and a Model name as the value.response_parameters (
Union[IResolvable,Mapping[str,Union[bool,IResolvable]],None]) – A key-value map specifying required or optional response parameters that API Gateway can send back to the caller. A key defines a method response header and the value specifies whether the associated method response header is required or not. The expression of the key must match the patternmethod.response.header.{name}, wherenameis a valid and unique header name. API Gateway passes certain integration response data to the method response headers specified here according to the mapping you prescribe in the API’s IntegrationResponse. The integration response data that can be mapped include an integration response header expressed inintegration.response.header.{name}, a static value enclosed within a pair of single quotes (e.g.,'application/json'), or a JSON expression from the back-end response payload in the form ofintegration.response.body.{JSON-expression}, whereJSON-expressionis a valid JSON expression without the$prefix.)status_code (
Optional[str]) – The method response’s status code.
- See:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. from aws_cdk.mixins_preview.aws_apigateway import mixins as apigateway_mixins method_response_property = apigateway_mixins.CfnMethodPropsMixin.MethodResponseProperty( response_models={ "response_models_key": "responseModels" }, response_parameters={ "response_parameters_key": False }, status_code="statusCode" )
Attributes
- response_models
Specifies the Model resources used for the response’s content-type.
Response models are represented as a key/value map, with a content-type as the key and a Model name as the value.
- response_parameters
A key-value map specifying required or optional response parameters that API Gateway can send back to the caller.
A key defines a method response header and the value specifies whether the associated method response header is required or not. The expression of the key must match the pattern
method.response.header.{name}, wherenameis a valid and unique header name. API Gateway passes certain integration response data to the method response headers specified here according to the mapping you prescribe in the API’s IntegrationResponse. The integration response data that can be mapped include an integration response header expressed inintegration.response.header.{name}, a static value enclosed within a pair of single quotes (e.g.,'application/json'), or a JSON expression from the back-end response payload in the form ofintegration.response.body.{JSON-expression}, whereJSON-expressionis a valid JSON expression without the$prefix.)
- status_code
The method response’s status code.