CfnRestApiProps¶
-
class
aws_cdk.aws_apigateway.
CfnRestApiProps
(*, api_key_source_type=None, binary_media_types=None, body=None, body_s3_location=None, clone_from=None, description=None, disable_execute_api_endpoint=None, endpoint_configuration=None, fail_on_warnings=None, minimum_compression_size=None, mode=None, name=None, parameters=None, policy=None, tags=None)¶ Bases:
object
Properties for defining a
CfnRestApi
.- Parameters
api_key_source_type (
Optional
[str
]) – The source of the API key for metering requests according to a usage plan. Valid values are:. -HEADER
to read the API key from theX-API-Key
header of a request. -AUTHORIZER
to read the API key from theUsageIdentifierKey
from a Lambda authorizer.binary_media_types (
Optional
[Sequence
[str
]]) – The list of binary media types that are supported by theRestApi
resource. Use~1
instead of/
in the media types, for exampleimage~1png
orapplication~1octet-stream
. By default,RestApi
supports only UTF-8-encoded text payloads. Duplicates are not allowed. For more information, see Enable Support for Binary Payloads in API Gateway in the API Gateway Developer Guide .body (
Optional
[Any
]) – An OpenAPI specification that defines a set of RESTful APIs in JSON format. For YAML templates, you can also provide the specification in YAML format.body_s3_location (
Union
[IResolvable
,S3LocationProperty
,Dict
[str
,Any
],None
]) – The Amazon Simple Storage Service (Amazon S3) location that points to an OpenAPI file, which defines a set of RESTful APIs in JSON or YAML format.clone_from (
Optional
[str
]) – The ID of theRestApi
resource that you want to clone.description (
Optional
[str
]) – A description of theRestApi
resource.disable_execute_api_endpoint (
Union
[bool
,IResolvable
,None
]) – Specifies whether clients can invoke your API by using the defaultexecute-api
endpoint. By default, clients can invoke your API with the default https://{api_id}.execute-api.{region}.amazonaws.com endpoint. To require that clients use a custom domain name to invoke your API, disable the default endpoint.endpoint_configuration (
Union
[IResolvable
,EndpointConfigurationProperty
,Dict
[str
,Any
],None
]) – A list of the endpoint types of the API. Use this property when creating an API. When importing an existing API, specify the endpoint configuration types using theParameters
property.fail_on_warnings (
Union
[bool
,IResolvable
,None
]) – Indicates whether to roll back the resource if a warning occurs while API Gateway is creating theRestApi
resource.minimum_compression_size (
Union
[int
,float
,None
]) – A nullable integer that is used to enable compression (with non-negative between 0 and 10485760 (10M) bytes, inclusive) or disable compression (with a null value) on an API. When compression is enabled, compression or decompression is not applied on the payload if the payload size is smaller than this value. Setting it to zero allows compression for any payload size.mode (
Optional
[str
]) – This property applies only when you use OpenAPI to define your REST API. TheMode
determines how API Gateway handles resource updates. Valid values areoverwrite
ormerge
. Foroverwrite
, the new API definition replaces the existing one. The existing API identifier remains unchanged. Formerge
, the new API definition takes precedence, but any container types such as endpoint configurations and binary media types are merged with the existing API. Usemerge
to define top-levelRestApi
properties in addition to using OpenAPI. Generally, it’s preferred to use API Gateway’s OpenAPI extensions to model these properties. If you don’t specify this property, a default value is chosen. For REST APIs created before March 29, 2021, the default isoverwrite
. Otherwise, the default value ismerge
.name (
Optional
[str
]) – A name for theRestApi
resource.parameters (
Union
[IResolvable
,Mapping
[str
,str
],None
]) – Custom header parameters for the request.policy (
Optional
[Any
]) – A policy document that contains the permissions for theRestApi
resource. To set the ARN for the policy, use the!Join
intrinsic function with""
as delimiter and values of"execute-api:/"
and"*"
.tags (
Optional
[Sequence
[Union
[CfnTag
,Dict
[str
,Any
]]]]) – An array of arbitrary tags (key-value pairs) to associate with the API.
- Link
http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-restapi.html
- 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.aws_apigateway as apigateway # body: Any # policy: Any cfn_rest_api_props = apigateway.CfnRestApiProps( api_key_source_type="apiKeySourceType", binary_media_types=["binaryMediaTypes"], body=body, body_s3_location=apigateway.CfnRestApi.S3LocationProperty( bucket="bucket", e_tag="eTag", key="key", version="version" ), clone_from="cloneFrom", description="description", disable_execute_api_endpoint=False, endpoint_configuration=apigateway.CfnRestApi.EndpointConfigurationProperty( types=["types"], vpc_endpoint_ids=["vpcEndpointIds"] ), fail_on_warnings=False, minimum_compression_size=123, mode="mode", name="name", parameters={ "parameters_key": "parameters" }, policy=policy, tags=[CfnTag( key="key", value="value" )] )
Attributes
-
api_key_source_type
¶ .
HEADER
to read the API key from theX-API-Key
header of a request.AUTHORIZER
to read the API key from theUsageIdentifierKey
from a Lambda authorizer.
- Link
- Type
The source of the API key for metering requests according to a usage plan. Valid values are
- Return type
Optional
[str
]
-
binary_media_types
¶ The list of binary media types that are supported by the
RestApi
resource.Use
~1
instead of/
in the media types, for exampleimage~1png
orapplication~1octet-stream
. By default,RestApi
supports only UTF-8-encoded text payloads. Duplicates are not allowed. For more information, see Enable Support for Binary Payloads in API Gateway in the API Gateway Developer Guide .- Link
- Return type
Optional
[List
[str
]]
-
body
¶ An OpenAPI specification that defines a set of RESTful APIs in JSON format.
For YAML templates, you can also provide the specification in YAML format.
-
body_s3_location
¶ The Amazon Simple Storage Service (Amazon S3) location that points to an OpenAPI file, which defines a set of RESTful APIs in JSON or YAML format.
-
clone_from
¶ The ID of the
RestApi
resource that you want to clone.
-
description
¶ A description of the
RestApi
resource.
-
disable_execute_api_endpoint
¶ Specifies whether clients can invoke your API by using the default
execute-api
endpoint.By default, clients can invoke your API with the default https://{api_id}.execute-api.{region}.amazonaws.com endpoint. To require that clients use a custom domain name to invoke your API, disable the default endpoint.
-
endpoint_configuration
¶ A list of the endpoint types of the API.
Use this property when creating an API. When importing an existing API, specify the endpoint configuration types using the
Parameters
property.
-
fail_on_warnings
¶ Indicates whether to roll back the resource if a warning occurs while API Gateway is creating the
RestApi
resource.- Link
- Return type
Union
[bool
,IResolvable
,None
]
-
minimum_compression_size
¶ A nullable integer that is used to enable compression (with non-negative between 0 and 10485760 (10M) bytes, inclusive) or disable compression (with a null value) on an API.
When compression is enabled, compression or decompression is not applied on the payload if the payload size is smaller than this value. Setting it to zero allows compression for any payload size.
- Link
- Return type
Union
[int
,float
,None
]
-
mode
¶ This property applies only when you use OpenAPI to define your REST API.
The
Mode
determines how API Gateway handles resource updates.Valid values are
overwrite
ormerge
.For
overwrite
, the new API definition replaces the existing one. The existing API identifier remains unchanged.For
merge
, the new API definition takes precedence, but any container types such as endpoint configurations and binary media types are merged with the existing API. Usemerge
to define top-levelRestApi
properties in addition to using OpenAPI. Generally, it’s preferred to use API Gateway’s OpenAPI extensions to model these properties.If you don’t specify this property, a default value is chosen. For REST APIs created before March 29, 2021, the default is
overwrite
. Otherwise, the default value ismerge
.
-
name
¶ A name for the
RestApi
resource.
-
parameters
¶ Custom header parameters for the request.
- Link
- Return type
Union
[IResolvable
,Mapping
[str
,str
],None
]
-
policy
¶ A policy document that contains the permissions for the
RestApi
resource.To set the ARN for the policy, use the
!Join
intrinsic function with""
as delimiter and values of"execute-api:/"
and"*"
.
An array of arbitrary tags (key-value pairs) to associate with the API.
- Link
- Return type
Optional
[List
[CfnTag
]]