createRestApi method

Future<RestApi> createRestApi({
  1. required String name,
  2. ApiKeySourceType? apiKeySource,
  3. List<String>? binaryMediaTypes,
  4. String? cloneFrom,
  5. String? description,
  6. bool? disableExecuteApiEndpoint,
  7. EndpointAccessMode? endpointAccessMode,
  8. EndpointConfiguration? endpointConfiguration,
  9. int? minimumCompressionSize,
  10. String? policy,
  11. SecurityPolicy? securityPolicy,
  12. Map<String, String>? tags,
  13. String? version,
})

Creates a new RestApi resource.

May throw BadRequestException. May throw ConflictException. May throw LimitExceededException. May throw TooManyRequestsException. May throw UnauthorizedException.

Parameter name : The name of the RestApi.

Parameter apiKeySource : The source of the API key for metering requests according to a usage plan. 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.

Parameter binaryMediaTypes : The list of binary media types supported by the RestApi. By default, the RestApi supports only UTF-8-encoded text payloads.

Parameter cloneFrom : The ID of the RestApi that you want to clone from.

Parameter description : The description of the RestApi.

Parameter disableExecuteApiEndpoint : Specifies whether clients can invoke your API by using the default execute-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

Parameter endpointAccessMode : The endpoint access mode of the RestApi. Only available for RestApis that use security policies that start with SecurityPolicy_.

Parameter endpointConfiguration : The endpoint configuration of this RestApi showing the endpoint types and IP address types of the API.

Parameter minimumCompressionSize : 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.

Parameter policy : A stringified JSON policy document that applies to this RestApi regardless of the caller and Method configuration.

Parameter securityPolicy : The Transport Layer Security (TLS) version + cipher suite for this RestApi.

Parameter tags : 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.

Parameter version : A version identifier for the API.

Implementation

Future<RestApi> createRestApi({
  required String name,
  ApiKeySourceType? apiKeySource,
  List<String>? binaryMediaTypes,
  String? cloneFrom,
  String? description,
  bool? disableExecuteApiEndpoint,
  EndpointAccessMode? endpointAccessMode,
  EndpointConfiguration? endpointConfiguration,
  int? minimumCompressionSize,
  String? policy,
  SecurityPolicy? securityPolicy,
  Map<String, String>? tags,
  String? version,
}) async {
  final $payload = <String, dynamic>{
    'name': name,
    if (apiKeySource != null) 'apiKeySource': apiKeySource.value,
    if (binaryMediaTypes != null) 'binaryMediaTypes': binaryMediaTypes,
    if (cloneFrom != null) 'cloneFrom': cloneFrom,
    if (description != null) 'description': description,
    if (disableExecuteApiEndpoint != null)
      'disableExecuteApiEndpoint': disableExecuteApiEndpoint,
    if (endpointAccessMode != null)
      'endpointAccessMode': endpointAccessMode.value,
    if (endpointConfiguration != null)
      'endpointConfiguration': endpointConfiguration,
    if (minimumCompressionSize != null)
      'minimumCompressionSize': minimumCompressionSize,
    if (policy != null) 'policy': policy,
    if (securityPolicy != null) 'securityPolicy': securityPolicy.value,
    if (tags != null) 'tags': tags,
    if (version != null) 'version': version,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri: '/restapis',
    exceptionFnMap: _exceptionFns,
  );
  return RestApi.fromJson(response);
}