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
Nested ClassesModifier and TypeClassDescriptionstatic final classA fluent builder forCfnRestApi.static interfaceTheEndpointConfigurationproperty type specifies the endpoint types of a REST API.static interfaceS3Locationis 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.InitializationModeNested classes/interfaces inherited from interface software.amazon.awscdk.core.IConstruct
IConstruct.Jsii$DefaultNested classes/interfaces inherited from interface software.constructs.IConstruct
software.constructs.IConstruct.Jsii$DefaultNested classes/interfaces inherited from interface software.amazon.awscdk.core.IInspectable
IInspectable.Jsii$Default, IInspectable.Jsii$Proxy -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe CloudFormation resource type name for this resource class. -
Constructor Summary
ConstructorsModifierConstructorDescriptionCfnRestApi(Construct scope, String id) Create a newAWS::ApiGateway::RestApi.CfnRestApi(Construct scope, String id, CfnRestApiProps props) Create a newAWS::ApiGateway::RestApi.protectedCfnRestApi(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) protectedCfnRestApi(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 aRestApiresource, 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-apiendpoint.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 theRestApiresource.getTags()The key-value map of strings.voidinspect(TreeInspector inspector) Examines the CloudFormation resource and discloses attributes.renderProperties(Map<String, Object> props) voidsetApiKeySourceType(String value) The source of the API key for metering requests according to a usage plan.voidsetBinaryMediaTypes(List<String> value) The list of binary media types supported by the RestApi.voidAn OpenAPI specification that defines a set of RESTful APIs in JSON format.voidsetBodyS3Location(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.voidThe 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.voidsetCloneFrom(String value) The ID of the RestApi that you want to clone from.voidsetDescription(String value) The description of the RestApi.voidSpecifies whether clients can invoke your API by using the defaultexecute-apiendpoint.voidSpecifies whether clients can invoke your API by using the defaultexecute-apiendpoint.voidA list of the endpoint types of the API.voidA list of the endpoint types of the API.voidsetFailOnWarnings(Boolean value) A query parameter to indicate whether to rollback the API update (true) or not (false) when a warning is encountered.voidsetFailOnWarnings(IResolvable value) A query parameter to indicate whether to rollback the API update (true) or not (false) when a warning is encountered.voidsetMinimumCompressionSize(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.voidThis property applies only when you use OpenAPI to define your REST API.voidThe name of the RestApi.voidsetParameters(Map<String, String> value) Custom header parameters as part of the request.voidsetParameters(IResolvable value) Custom header parameters as part of the request.voidA policy document that contains the permissions for theRestApiresource.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, validatePropertiesMethods inherited from class software.amazon.awscdk.core.CfnRefElement
getRefMethods inherited from class software.amazon.awscdk.core.CfnElement
getCreationStack, getLogicalId, getStack, isCfnElement, overrideLogicalIdMethods inherited from class software.amazon.awscdk.core.Construct
getNode, isConstruct, onPrepare, onSynthesize, onValidate, prepare, synthesize, validateMethods inherited from class software.amazon.jsii.JsiiObject
jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSetMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods 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:
inspectin 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:
renderPropertiesin classCfnResource- Parameters:
props- This parameter is required.
-
getAttrRestApiId
The string identifier of the associated RestApi. -
getAttrRootResourceId
The root resource ID for aRestApiresource, such asa0bc123d4e. -
getCfnProperties
- Overrides:
getCfnPropertiesin 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 theRestApiresource.To set the ARN for the policy, use the
!Joinintrinsic function with""as delimiter and values of"execute-api:/"and"*". -
setPolicy
A policy document that contains the permissions for theRestApiresource.To set the ARN for the policy, use the
!Joinintrinsic 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:
HEADERto read the API key from theX-API-Keyheader of a request.AUTHORIZERto read the API key from theUsageIdentifierKeyfrom a custom authorizer. -
setApiKeySourceType
The source of the API key for metering requests according to a usage plan.Valid values are:
HEADERto read the API key from theX-API-Keyheader of a request.AUTHORIZERto read the API key from theUsageIdentifierKeyfrom 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-apiendpoint.By default, clients can invoke your API with the default
https://{api_id}.execute-api.{region}.amazonaws.com.rproxy.govskope.caendpoint. 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-apiendpoint.By default, clients can invoke your API with the default
https://{api_id}.execute-api.{region}.amazonaws.com.rproxy.govskope.caendpoint. 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-apiendpoint.By default, clients can invoke your API with the default
https://{api_id}.execute-api.{region}.amazonaws.com.rproxy.govskope.caendpoint. 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
Parametersproperty. -
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
Parametersproperty. -
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
Parametersproperty. -
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
Modedetermines how API Gateway handles resource updates.Valid values are
overwriteormerge.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
RestApiproperties 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
Modedetermines how API Gateway handles resource updates.Valid values are
overwriteormerge.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
RestApiproperties 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=documentationas aparametersvalue, 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=documentationas aparametersvalue, 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=documentationas aparametersvalue, as in the AWS CLI command ofaws apigateway import-rest-api --parameters ignore=documentation --body 'file:///path/to/imported-api-body.json'.
-