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. EndpointConfiguration? endpointConfiguration,
  8. int? minimumCompressionSize,
  9. String? policy,
  10. Map<String, String>? tags,
  11. String? version,
})

Creates a new RestApi resource.

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

Parameter name : Required 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 endpointConfiguration : The endpoint configuration of this RestApi showing the endpoint 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 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,
  EndpointConfiguration? endpointConfiguration,
  int? minimumCompressionSize,
  String? policy,
  Map<String, String>? tags,
  String? version,
}) async {
  ArgumentError.checkNotNull(name, 'name');
  final $payload = <String, dynamic>{
    'name': name,
    if (apiKeySource != null) 'apiKeySource': apiKeySource.toValue(),
    if (binaryMediaTypes != null) 'binaryMediaTypes': binaryMediaTypes,
    if (cloneFrom != null) 'cloneFrom': cloneFrom,
    if (description != null) 'description': description,
    if (disableExecuteApiEndpoint != null)
      'disableExecuteApiEndpoint': disableExecuteApiEndpoint,
    if (endpointConfiguration != null)
      'endpointConfiguration': endpointConfiguration,
    if (minimumCompressionSize != null)
      'minimumCompressionSize': minimumCompressionSize,
    if (policy != null) 'policy': policy,
    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);
}