@Generated(value="jsii-pacmak/1.67.0 (build 2c027f5)", date="2022-09-19T20:26:36.130Z") @Stability(value=Stable) 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.
|
software.amazon.jsii.JsiiObject.InitializationModeIInspectable.Jsii$Default, IInspectable.Jsii$Proxy| Modifier and Type | Field and Description |
|---|---|
static String |
CFN_RESOURCE_TYPE_NAME
The CloudFormation resource type name for this resource class.
|
| Modifier | Constructor and Description |
|---|---|
|
CfnRestApi(software.constructs.Construct scope,
String id)
Create a new `AWS::ApiGateway::RestApi`.
|
|
CfnRestApi(software.constructs.Construct scope,
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 |
|---|---|
String |
getApiKeySourceType()
The source of the API key for metering requests according to a usage plan.
|
String |
getAttrRootResourceId()
The root resource ID for a `RestApi` resource, such as `a0bc123d4e` .
|
List<String> |
getBinaryMediaTypes()
The list of binary media types that are supported by the `RestApi` resource.
|
Object |
getBody()
An OpenAPI specification that defines a set of RESTful APIs in JSON format.
|
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 Map<String,Object> |
getCfnProperties() |
String |
getCloneFrom()
The ID of the `RestApi` resource that you want to clone.
|
String |
getDescription()
A description of the `RestApi` resource.
|
Object |
getDisableExecuteApiEndpoint()
Specifies whether clients can invoke your API by using the default `execute-api` endpoint.
|
Object |
getEndpointConfiguration()
A list of the endpoint types of the API.
|
Object |
getFailOnWarnings()
Indicates whether to roll back the resource if a warning occurs while API Gateway is creating the `RestApi` resource.
|
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.
|
String |
getMode()
This property applies only when you use OpenAPI to define your REST API.
|
String |
getName()
A name for the `RestApi` resource.
|
Object |
getParameters()
Custom header parameters for the request.
|
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 Map<String,Object> |
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 that are supported by the `RestApi` resource.
|
void |
setBody(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(String value)
The ID of the `RestApi` resource that you want to clone.
|
void |
setDescription(String value)
A description of the `RestApi` resource.
|
void |
setDisableExecuteApiEndpoint(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(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(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(String value)
This property applies only when you use OpenAPI to define your REST API.
|
void |
setName(String value)
A name for the `RestApi` resource.
|
void |
setParameters(IResolvable value)
Custom header parameters for the request.
|
void |
setParameters(Map<String,String> value)
Custom header parameters for the request.
|
void |
setPolicy(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, getUpdatedProperties, isCfnResource, shouldSynthesize, toString, validatePropertiesgetRefgetCreationStack, getLogicalId, getStack, isCfnElement, overrideLogicalIdjsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSet@Stability(value=Stable) public static final String CFN_RESOURCE_TYPE_NAME
protected CfnRestApi(software.amazon.jsii.JsiiObjectRef objRef)
protected CfnRestApi(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
@Stability(value=Stable)
public CfnRestApi(@NotNull
software.constructs.Construct scope,
@NotNull
String id,
@Nullable
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.@Stability(value=Stable)
public CfnRestApi(@NotNull
software.constructs.Construct scope,
@NotNull
String id)
scope - - scope in which this resource is defined. This parameter is required.id - - scoped id of the resource. This parameter is required.@Stability(value=Stable)
public void inspect(@NotNull
TreeInspector inspector)
inspect in interface IInspectableinspector - - tree inspector to collect and process attributes. This parameter is required.@Stability(value=Stable) @NotNull protected Map<String,Object> renderProperties(@NotNull Map<String,Object> props)
renderProperties in class CfnResourceprops - This parameter is required.@Stability(value=Stable) @NotNull public String getAttrRootResourceId()
@Stability(value=Stable) @NotNull protected Map<String,Object> getCfnProperties()
getCfnProperties in class CfnResource@Stability(value=Stable) @NotNull public TagManager getTags()
@Stability(value=Stable) @NotNull public Object getBody()
For YAML templates, you can also provide the specification in YAML format.
@Stability(value=Stable)
public void setBody(@NotNull
Object value)
For YAML templates, you can also provide the specification in YAML format.
@Stability(value=Stable) @NotNull public Object getPolicy()
To set the ARN for the policy, use the !Join intrinsic function with "" as delimiter and values of "execute-api:/" and "*" .
@Stability(value=Stable)
public void setPolicy(@NotNull
Object value)
To set the ARN for the policy, use the !Join intrinsic function with "" as delimiter and values of "execute-api:/" and "*" .
@Stability(value=Stable) @Nullable public 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.@Stability(value=Stable)
public void setApiKeySourceType(@Nullable
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.@Stability(value=Stable) @Nullable public List<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 .
@Stability(value=Stable)
public void setBinaryMediaTypes(@Nullable
List<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 .
@Stability(value=Stable) @Nullable public Object getBodyS3Location()
@Stability(value=Stable)
public void setBodyS3Location(@Nullable
CfnRestApi.S3LocationProperty value)
@Stability(value=Stable)
public void setBodyS3Location(@Nullable
IResolvable value)
@Stability(value=Stable) @Nullable public String getCloneFrom()
@Stability(value=Stable)
public void setCloneFrom(@Nullable
String value)
@Stability(value=Stable) @Nullable public String getDescription()
@Stability(value=Stable)
public void setDescription(@Nullable
String value)
@Stability(value=Stable) @Nullable public 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.
@Stability(value=Stable)
public void setDisableExecuteApiEndpoint(@Nullable
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.
@Stability(value=Stable)
public void setDisableExecuteApiEndpoint(@Nullable
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.
@Stability(value=Stable) @Nullable public Object getEndpointConfiguration()
Use this property when creating an API. When importing an existing API, specify the endpoint configuration types using the Parameters property.
@Stability(value=Stable)
public void setEndpointConfiguration(@Nullable
CfnRestApi.EndpointConfigurationProperty value)
Use this property when creating an API. When importing an existing API, specify the endpoint configuration types using the Parameters property.
@Stability(value=Stable)
public void setEndpointConfiguration(@Nullable
IResolvable value)
Use this property when creating an API. When importing an existing API, specify the endpoint configuration types using the Parameters property.
@Stability(value=Stable) @Nullable public Object getFailOnWarnings()
@Stability(value=Stable)
public void setFailOnWarnings(@Nullable
Boolean value)
@Stability(value=Stable)
public void setFailOnWarnings(@Nullable
IResolvable value)
@Stability(value=Stable) @Nullable public 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.
@Stability(value=Stable)
public void setMinimumCompressionSize(@Nullable
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.
@Stability(value=Stable) @Nullable public 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 .
@Stability(value=Stable)
public void setMode(@Nullable
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 .
@Stability(value=Stable) @Nullable public String getName()
@Stability(value=Stable)
public void setName(@Nullable
String value)
@Stability(value=Stable) @Nullable public Object getParameters()
@Stability(value=Stable)
public void setParameters(@Nullable
IResolvable value)
Copyright © 2022. All rights reserved.