@Generated(value="jsii-pacmak/1.63.2 (build a8a8833)", date="2022-08-09T19:16:41.959Z") public class CfnRestApi extends CfnResource implements IInspectable
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();
Modifier and Type | Class and Description |
---|---|
static class |
CfnRestApi.Builder
A fluent builder for
CfnRestApi . |
static interface |
CfnRestApi.EndpointConfigurationProperty
The `EndpointConfiguration` property type specifies the endpoint types of a REST API.
|
static interface |
CfnRestApi.S3LocationProperty
`S3Location` is a property of the [AWS::ApiGateway::RestApi](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-restapi.html) resource that specifies the Amazon S3 location of a OpenAPI (formerly Swagger) file that defines a set of RESTful APIs in JSON or YAML.
|
IInspectable.Jsii$Default, IInspectable.Jsii$Proxy
IConstruct.Jsii$Default
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
CFN_RESOURCE_TYPE_NAME
The CloudFormation resource type name for this resource class.
|
Modifier | Constructor and Description |
---|---|
|
CfnRestApi(Construct scope,
java.lang.String id)
Create a new `AWS::ApiGateway::RestApi`.
|
|
CfnRestApi(Construct scope,
java.lang.String id,
CfnRestApiProps props)
Create a new `AWS::ApiGateway::RestApi`.
|
protected |
CfnRestApi(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) |
protected |
CfnRestApi(software.amazon.jsii.JsiiObjectRef objRef) |
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getApiKeySourceType()
The source of the API key for metering requests according to a usage plan.
|
java.lang.String |
getAttrRootResourceId()
The root resource ID for a `RestApi` resource, such as `a0bc123d4e` .
|
java.util.List<java.lang.String> |
getBinaryMediaTypes()
The list of binary media types that are supported by the `RestApi` resource.
|
java.lang.Object |
getBody()
An OpenAPI specification that defines a set of RESTful APIs in JSON format.
|
java.lang.Object |
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.
|
protected java.util.Map<java.lang.String,java.lang.Object> |
getCfnProperties() |
java.lang.String |
getCloneFrom()
The ID of the `RestApi` resource that you want to clone.
|
java.lang.String |
getDescription()
A description of the `RestApi` resource.
|
java.lang.Object |
getDisableExecuteApiEndpoint()
Specifies whether clients can invoke your API by using the default `execute-api` endpoint.
|
java.lang.Object |
getEndpointConfiguration()
A list of the endpoint types of the API.
|
java.lang.Object |
getFailOnWarnings()
Indicates whether to roll back the resource if a warning occurs while API Gateway is creating the `RestApi` resource.
|
java.lang.Number |
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.
|
java.lang.String |
getMode()
This property applies only when you use OpenAPI to define your REST API.
|
java.lang.String |
getName()
A name for the `RestApi` resource.
|
java.lang.Object |
getParameters()
Custom header parameters for the request.
|
java.lang.Object |
getPolicy()
A policy document that contains the permissions for the `RestApi` resource.
|
TagManager |
getTags()
An array of arbitrary tags (key-value pairs) to associate with the API.
|
void |
inspect(TreeInspector inspector)
Examines the CloudFormation resource and discloses attributes.
|
protected java.util.Map<java.lang.String,java.lang.Object> |
renderProperties(java.util.Map<java.lang.String,java.lang.Object> props) |
void |
setApiKeySourceType(java.lang.String value)
The source of the API key for metering requests according to a usage plan.
|
void |
setBinaryMediaTypes(java.util.List<java.lang.String> value)
The list of binary media types that are supported by the `RestApi` resource.
|
void |
setBody(java.lang.Object value)
An OpenAPI specification that defines a set of RESTful APIs in JSON format.
|
void |
setBodyS3Location(CfnRestApi.S3LocationProperty 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 |
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 |
setCloneFrom(java.lang.String value)
The ID of the `RestApi` resource that you want to clone.
|
void |
setDescription(java.lang.String value)
A description of the `RestApi` resource.
|
void |
setDisableExecuteApiEndpoint(java.lang.Boolean value)
Specifies whether clients can invoke your API by using the default `execute-api` endpoint.
|
void |
setDisableExecuteApiEndpoint(IResolvable value)
Specifies whether clients can invoke your API by using the default `execute-api` endpoint.
|
void |
setEndpointConfiguration(CfnRestApi.EndpointConfigurationProperty value)
A list of the endpoint types of the API.
|
void |
setEndpointConfiguration(IResolvable value)
A list of the endpoint types of the API.
|
void |
setFailOnWarnings(java.lang.Boolean value)
Indicates whether to roll back the resource if a warning occurs while API Gateway is creating the `RestApi` resource.
|
void |
setFailOnWarnings(IResolvable value)
Indicates whether to roll back the resource if a warning occurs while API Gateway is creating the `RestApi` resource.
|
void |
setMinimumCompressionSize(java.lang.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 |
setMode(java.lang.String value)
This property applies only when you use OpenAPI to define your REST API.
|
void |
setName(java.lang.String value)
A name for the `RestApi` resource.
|
void |
setParameters(IResolvable value)
Custom header parameters for the request.
|
void |
setParameters(java.util.Map<java.lang.String,java.lang.String> value)
Custom header parameters for the request.
|
void |
setPolicy(java.lang.Object value)
A policy document that contains the permissions for the `RestApi` resource.
|
addDeletionOverride, addDependsOn, addMetadata, addOverride, addPropertyDeletionOverride, addPropertyOverride, applyRemovalPolicy, applyRemovalPolicy, applyRemovalPolicy, getAtt, getCfnOptions, getCfnResourceType, getMetadata, getUpdatedProperites, isCfnResource, shouldSynthesize, toString, validateProperties
getRef
getCreationStack, getLogicalId, getStack, isCfnElement, overrideLogicalId
getNode, isConstruct, onPrepare, onSynthesize, onValidate, prepare, synthesize, validate
public static final java.lang.String CFN_RESOURCE_TYPE_NAME
protected CfnRestApi(software.amazon.jsii.JsiiObjectRef objRef)
protected CfnRestApi(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
public CfnRestApi(Construct scope, java.lang.String id, CfnRestApiProps props)
scope
- - scope in which this resource is defined. This parameter is required.id
- - scoped id of the resource. This parameter is required.props
- - resource properties.public CfnRestApi(Construct scope, java.lang.String id)
scope
- - scope in which this resource is defined. This parameter is required.id
- - scoped id of the resource. This parameter is required.public void inspect(TreeInspector inspector)
inspect
in interface IInspectable
inspector
- - tree inspector to collect and process attributes. This parameter is required.protected java.util.Map<java.lang.String,java.lang.Object> renderProperties(java.util.Map<java.lang.String,java.lang.Object> props)
renderProperties
in class CfnResource
props
- This parameter is required.public java.lang.String getAttrRootResourceId()
protected java.util.Map<java.lang.String,java.lang.Object> getCfnProperties()
getCfnProperties
in class CfnResource
public TagManager getTags()
public java.lang.Object getBody()
For YAML templates, you can also provide the specification in YAML format.
public void setBody(java.lang.Object value)
For YAML templates, you can also provide the specification in YAML format.
public java.lang.Object getPolicy()
To set the ARN for the policy, use the !Join
intrinsic function with ""
as delimiter and values of "execute-api:/"
and "*"
.
public void setPolicy(java.lang.Object value)
To set the ARN for the policy, use the !Join
intrinsic function with ""
as delimiter and values of "execute-api:/"
and "*"
.
public java.lang.String getApiKeySourceType()
HEADER
to read the API key from the X-API-Key
header of a request.AUTHORIZER
to read the API key from the UsageIdentifierKey
from a Lambda authorizer.public void setApiKeySourceType(java.lang.String value)
HEADER
to read the API key from the X-API-Key
header of a request.AUTHORIZER
to read the API key from the UsageIdentifierKey
from a Lambda authorizer.public java.util.List<java.lang.String> getBinaryMediaTypes()
Use ~1
instead of /
in the media types, for example image~1png
or application~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 .
public void setBinaryMediaTypes(java.util.List<java.lang.String> value)
Use ~1
instead of /
in the media types, for example image~1png
or application~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 .
public java.lang.Object getBodyS3Location()
public void setBodyS3Location(IResolvable value)
public void setBodyS3Location(CfnRestApi.S3LocationProperty value)
public java.lang.String getCloneFrom()
public void setCloneFrom(java.lang.String value)
public java.lang.String getDescription()
public void setDescription(java.lang.String value)
public java.lang.Object getDisableExecuteApiEndpoint()
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.
public void setDisableExecuteApiEndpoint(java.lang.Boolean value)
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.
public void setDisableExecuteApiEndpoint(IResolvable value)
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.
public java.lang.Object getEndpointConfiguration()
Use this property when creating an API. When importing an existing API, specify the endpoint configuration types using the Parameters
property.
public void setEndpointConfiguration(IResolvable value)
Use this property when creating an API. When importing an existing API, specify the endpoint configuration types using the Parameters
property.
public void setEndpointConfiguration(CfnRestApi.EndpointConfigurationProperty value)
Use this property when creating an API. When importing an existing API, specify the endpoint configuration types using the Parameters
property.
public java.lang.Object getFailOnWarnings()
public void setFailOnWarnings(java.lang.Boolean value)
public void setFailOnWarnings(IResolvable value)
public java.lang.Number getMinimumCompressionSize()
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.
public void setMinimumCompressionSize(java.lang.Number value)
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.
public java.lang.String getMode()
The Mode
determines how API Gateway handles resource updates.
Valid values are overwrite
or merge
.
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. Use merge
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.
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 is merge
.
public void setMode(java.lang.String value)
The Mode
determines how API Gateway handles resource updates.
Valid values are overwrite
or merge
.
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. Use merge
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.
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 is merge
.
public java.lang.String getName()
public void setName(java.lang.String value)
public java.lang.Object getParameters()
public void setParameters(IResolvable value)
public void setParameters(java.util.Map<java.lang.String,java.lang.String> value)