Class CfnRestApi
- All Implemented Interfaces:
IConstruct
,IDependable
,IInspectable
,software.amazon.jsii.JsiiSerializable
,software.constructs.IConstruct
AWS::ApiGateway::RestApi
.
The AWS::ApiGateway::RestApi
resource creates a REST API. For more information, see restapi:create in the Amazon API Gateway REST API Reference .
On January 1, 2016, the Swagger Specification was donated to the OpenAPI initiative , becoming the foundation of the OpenAPI Specification.
Example:
// The code below shows an example of how to instantiate this type. // The values are placeholders you should change. import software.amazon.awscdk.services.apigateway.*; Object body; Object policy; CfnRestApi cfnRestApi = CfnRestApi.Builder.create(this, "MyCfnRestApi") .apiKeySourceType("apiKeySourceType") .binaryMediaTypes(List.of("binaryMediaTypes")) .body(body) .bodyS3Location(S3LocationProperty.builder() .bucket("bucket") .eTag("eTag") .key("key") .version("version") .build()) .cloneFrom("cloneFrom") .description("description") .disableExecuteApiEndpoint(false) .endpointConfiguration(EndpointConfigurationProperty.builder() .types(List.of("types")) .vpcEndpointIds(List.of("vpcEndpointIds")) .build()) .failOnWarnings(false) .minimumCompressionSize(123) .mode("mode") .name("name") .parameters(Map.of( "parametersKey", "parameters")) .policy(policy) .tags(List.of(CfnTag.builder() .key("key") .value("value") .build())) .build();
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final class
A fluent builder forCfnRestApi
.static interface
TheEndpointConfiguration
property type specifies the endpoint types of a REST API.static interface
S3Location
is a property of the AWS::ApiGateway::RestApi resource that specifies the Amazon S3 location of a OpenAPI (formerly Swagger) file that defines a set of RESTful APIs in JSON or YAML.Nested classes/interfaces inherited from class software.amazon.jsii.JsiiObject
software.amazon.jsii.JsiiObject.InitializationMode
Nested classes/interfaces inherited from interface software.amazon.awscdk.core.IConstruct
IConstruct.Jsii$Default
Nested classes/interfaces inherited from interface software.constructs.IConstruct
software.constructs.IConstruct.Jsii$Default
Nested classes/interfaces inherited from interface software.amazon.awscdk.core.IInspectable
IInspectable.Jsii$Default, IInspectable.Jsii$Proxy
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
The CloudFormation resource type name for this resource class. -
Constructor Summary
ModifierConstructorDescriptionCfnRestApi
(Construct scope, String id) Create a newAWS::ApiGateway::RestApi
.CfnRestApi
(Construct scope, String id, CfnRestApiProps props) Create a newAWS::ApiGateway::RestApi
.protected
CfnRestApi
(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) protected
CfnRestApi
(software.amazon.jsii.JsiiObjectRef objRef) -
Method Summary
Modifier and TypeMethodDescriptionThe source of the API key for metering requests according to a usage plan.The string identifier of the associated RestApi.The root resource ID for aRestApi
resource, such asa0bc123d4e
.The list of binary media types supported by the RestApi.getBody()
An OpenAPI specification that defines a set of RESTful APIs in JSON format.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.The ID of the RestApi that you want to clone from.The description of the RestApi.Specifies whether clients can invoke your API by using the defaultexecute-api
endpoint.A list of the endpoint types of the API.A query parameter to indicate whether to rollback the API update (true
) or not (false
) when a warning is encountered.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.getMode()
This property applies only when you use OpenAPI to define your REST API.getName()
The name of the RestApi.Custom header parameters as part of the request.A policy document that contains the permissions for theRestApi
resource.getTags()
The key-value map of strings.void
inspect
(TreeInspector inspector) Examines the CloudFormation resource and discloses attributes.renderProperties
(Map<String, Object> props) void
setApiKeySourceType
(String value) The source of the API key for metering requests according to a usage plan.void
setBinaryMediaTypes
(List<String> value) The list of binary media types supported by the RestApi.void
An OpenAPI specification that defines a set of RESTful APIs in JSON format.void
setBodyS3Location
(IResolvable value) 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.void
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.void
setCloneFrom
(String value) The ID of the RestApi that you want to clone from.void
setDescription
(String value) The description of the RestApi.void
Specifies whether clients can invoke your API by using the defaultexecute-api
endpoint.void
Specifies whether clients can invoke your API by using the defaultexecute-api
endpoint.void
A list of the endpoint types of the API.void
A list of the endpoint types of the API.void
setFailOnWarnings
(Boolean value) A query parameter to indicate whether to rollback the API update (true
) or not (false
) when a warning is encountered.void
setFailOnWarnings
(IResolvable value) A query parameter to indicate whether to rollback the API update (true
) or not (false
) when a warning is encountered.void
setMinimumCompressionSize
(Number value) 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.void
This property applies only when you use OpenAPI to define your REST API.void
The name of the RestApi.void
setParameters
(Map<String, String> value) Custom header parameters as part of the request.void
setParameters
(IResolvable value) Custom header parameters as part of the request.void
A policy document that contains the permissions for theRestApi
resource.Methods inherited from class software.amazon.awscdk.core.CfnResource
addDeletionOverride, addDependsOn, addMetadata, addOverride, addPropertyDeletionOverride, addPropertyOverride, applyRemovalPolicy, applyRemovalPolicy, applyRemovalPolicy, getAtt, getCfnOptions, getCfnResourceType, getMetadata, getUpdatedProperites, isCfnResource, shouldSynthesize, toString, validateProperties
Methods inherited from class software.amazon.awscdk.core.CfnRefElement
getRef
Methods inherited from class software.amazon.awscdk.core.CfnElement
getCreationStack, getLogicalId, getStack, isCfnElement, overrideLogicalId
Methods inherited from class software.amazon.awscdk.core.Construct
getNode, isConstruct, onPrepare, onSynthesize, onValidate, prepare, synthesize, validate
Methods inherited from class software.amazon.jsii.JsiiObject
jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSet
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface software.amazon.jsii.JsiiSerializable
$jsii$toJson
-
Field Details
-
CFN_RESOURCE_TYPE_NAME
The CloudFormation resource type name for this resource class.
-
-
Constructor Details
-
CfnRestApi
protected CfnRestApi(software.amazon.jsii.JsiiObjectRef objRef) -
CfnRestApi
protected CfnRestApi(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) -
CfnRestApi
@Stability(Stable) public CfnRestApi(@NotNull Construct scope, @NotNull String id, @Nullable CfnRestApiProps props) Create a newAWS::ApiGateway::RestApi
.- Parameters:
scope
-- scope in which this resource is defined.
id
-- scoped id of the resource.
props
-- resource properties.
-
CfnRestApi
Create a newAWS::ApiGateway::RestApi
.- Parameters:
scope
-- scope in which this resource is defined.
id
-- scoped id of the resource.
-
-
Method Details
-
inspect
Examines the CloudFormation resource and discloses attributes.- Specified by:
inspect
in interfaceIInspectable
- Parameters:
inspector
-- tree inspector to collect and process attributes.
-
renderProperties
@Stability(Stable) @NotNull protected Map<String,Object> renderProperties(@NotNull Map<String, Object> props) - Overrides:
renderProperties
in classCfnResource
- Parameters:
props
- This parameter is required.
-
getAttrRestApiId
The string identifier of the associated RestApi. -
getAttrRootResourceId
The root resource ID for aRestApi
resource, such asa0bc123d4e
. -
getCfnProperties
- Overrides:
getCfnProperties
in classCfnResource
-
getTags
The key-value map of strings.The valid character set is [a-zA-Z+-=._:/]. The tag key can be up to 128 characters and must not start with
aws:
. The tag value can be up to 256 characters. -
getBody
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.
-
setBody
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.
-
getPolicy
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"*"
. -
setPolicy
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"*"
. -
getApiKeySourceType
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 custom authorizer. -
setApiKeySourceType
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 custom authorizer. -
getBinaryMediaTypes
The list of binary media types supported by the RestApi.By default, the RestApi supports only UTF-8-encoded text payloads.
-
setBinaryMediaTypes
The list of binary media types supported by the RestApi.By default, the RestApi supports only UTF-8-encoded text payloads.
-
getBodyS3Location
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. -
setBodyS3Location
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. -
setBodyS3Location
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. -
getCloneFrom
The ID of the RestApi that you want to clone from. -
setCloneFrom
The ID of the RestApi that you want to clone from. -
getDescription
The description of the RestApi. -
setDescription
The description of the RestApi. -
getDisableExecuteApiEndpoint
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 -
setDisableExecuteApiEndpoint
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 -
setDisableExecuteApiEndpoint
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 -
getEndpointConfiguration
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. -
setEndpointConfiguration
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. -
setEndpointConfiguration
@Stability(Stable) public void setEndpointConfiguration(@Nullable CfnRestApi.EndpointConfigurationProperty value) 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. -
getFailOnWarnings
A query parameter to indicate whether to rollback the API update (true
) or not (false
) when a warning is encountered.The default value is
false
. -
setFailOnWarnings
A query parameter to indicate whether to rollback the API update (true
) or not (false
) when a warning is encountered.The default value is
false
. -
setFailOnWarnings
A query parameter to indicate whether to rollback the API update (true
) or not (false
) when a warning is encountered.The default value is
false
. -
getMinimumCompressionSize
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.
-
setMinimumCompressionSize
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.
-
getMode
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 is merged with the existing API.If you don't specify this property, a default value is chosen. For REST APIs created before March 29, 2021, the default is
overwrite
. For REST APIs created after March 29, 2021, the new API definition takes precedence, but any container types such as endpoint configurations and binary media types are merged with the existing API.Use the default mode to define top-level
RestApi
properties in addition to using OpenAPI. Generally, it's preferred to use API Gateway's OpenAPI extensions to model these properties. -
setMode
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 is merged with the existing API.If you don't specify this property, a default value is chosen. For REST APIs created before March 29, 2021, the default is
overwrite
. For REST APIs created after March 29, 2021, the new API definition takes precedence, but any container types such as endpoint configurations and binary media types are merged with the existing API.Use the default mode to define top-level
RestApi
properties in addition to using OpenAPI. Generally, it's preferred to use API Gateway's OpenAPI extensions to model these properties. -
getName
The name of the RestApi.A name is required if the REST API is not based on an OpenAPI specification.
-
setName
The name of the RestApi.A name is required if the REST API is not based on an OpenAPI specification.
-
getParameters
Custom header parameters as part of the request.For example, to exclude DocumentationParts from an imported API, set
ignore=documentation
as aparameters
value, as in the AWS CLI command ofaws apigateway import-rest-api --parameters ignore=documentation --body 'file:///path/to/imported-api-body.json'
. -
setParameters
Custom header parameters as part of the request.For example, to exclude DocumentationParts from an imported API, set
ignore=documentation
as aparameters
value, as in the AWS CLI command ofaws apigateway import-rest-api --parameters ignore=documentation --body 'file:///path/to/imported-api-body.json'
. -
setParameters
Custom header parameters as part of the request.For example, to exclude DocumentationParts from an imported API, set
ignore=documentation
as aparameters
value, as in the AWS CLI command ofaws apigateway import-rest-api --parameters ignore=documentation --body 'file:///path/to/imported-api-body.json'
.
-