@Generated(value="jsii-pacmak/1.74.0 (build 6d08790)", date="2023-03-22T19:35:47.540Z") 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 |
getAttrRestApiId()
The string identifier of the associated RestApi.
|
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 supported by the RestApi.
|
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 that you want to clone from.
|
java.lang.String |
getDescription()
The description of the RestApi.
|
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()
A query parameter to indicate whether to rollback the API update ( `true` ) or not ( `false` ) when a warning is encountered.
|
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()
The name of the RestApi.
|
java.lang.Object |
getParameters()
Custom header parameters as part of the request.
|
java.lang.Object |
getPolicy()
A policy document that contains the permissions for the `RestApi` resource.
|
TagManager |
getTags()
The key-value map of strings.
|
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 supported by the RestApi.
|
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 that you want to clone from.
|
void |
setDescription(java.lang.String value)
The description of the RestApi.
|
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)
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(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)
The name of the RestApi.
|
void |
setParameters(IResolvable value)
Custom header parameters as part of the request.
|
void |
setParameters(java.util.Map<java.lang.String,java.lang.String> value)
Custom header parameters as part of 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 getAttrRestApiId()
public java.lang.String getAttrRootResourceId()
protected java.util.Map<java.lang.String,java.lang.Object> getCfnProperties()
getCfnProperties
in class CfnResource
public TagManager getTags()
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.
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()
Valid values are: 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 custom authorizer.
public void setApiKeySourceType(java.lang.String value)
Valid values are: 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 custom authorizer.
public java.util.List<java.lang.String> getBinaryMediaTypes()
By default, the RestApi supports only UTF-8-encoded text payloads.
public void setBinaryMediaTypes(java.util.List<java.lang.String> value)
By default, the RestApi supports only UTF-8-encoded text payloads.
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()
The default value is false
.
public void setFailOnWarnings(java.lang.Boolean value)
The default value is false
.
public void setFailOnWarnings(IResolvable value)
The default value is false
.
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()
For example, to exclude DocumentationParts from an imported API, set ignore=documentation
as a parameters
value, as in the AWS CLI command of aws apigateway import-rest-api --parameters ignore=documentation --body 'file:///path/to/imported-api-body.json'
.
public void setParameters(IResolvable value)
For example, to exclude DocumentationParts from an imported API, set ignore=documentation
as a parameters
value, as in the AWS CLI command of aws apigateway import-rest-api --parameters ignore=documentation --body 'file:///path/to/imported-api-body.json'
.
public void setParameters(java.util.Map<java.lang.String,java.lang.String> value)
For example, to exclude DocumentationParts from an imported API, set ignore=documentation
as a parameters
value, as in the AWS CLI command of aws apigateway import-rest-api --parameters ignore=documentation --body 'file:///path/to/imported-api-body.json'
.