putGatewayResponse method

Future<GatewayResponse> putGatewayResponse({
  1. required GatewayResponseType responseType,
  2. required String restApiId,
  3. Map<String, String>? responseParameters,
  4. Map<String, String>? responseTemplates,
  5. String? statusCode,
})

Creates a customization of a GatewayResponse of a specified response type and status code on the given RestApi.

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

Parameter responseType : Required The response type of the associated GatewayResponse. Valid values are

  • ACCESS_DENIED
  • API_CONFIGURATION_ERROR
  • AUTHORIZER_FAILURE
  • AUTHORIZER_CONFIGURATION_ERROR
  • BAD_REQUEST_PARAMETERS
  • BAD_REQUEST_BODY
  • DEFAULT_4XX
  • DEFAULT_5XX
  • EXPIRED_TOKEN
  • INVALID_SIGNATURE
  • INTEGRATION_FAILURE
  • INTEGRATION_TIMEOUT
  • INVALID_API_KEY
  • MISSING_AUTHENTICATION_TOKEN
  • QUOTA_EXCEEDED
  • REQUEST_TOO_LARGE
  • RESOURCE_NOT_FOUND
  • THROTTLED
  • UNAUTHORIZED
  • UNSUPPORTED_MEDIA_TYPE

Parameter restApiId : Required The string identifier of the associated RestApi.

Parameter responseParameters :

Response parameters (paths, query strings and headers) of the GatewayResponse as a string-to-string map of key-value pairs.

Parameter responseTemplates :

Response templates of the GatewayResponse as a string-to-string map of key-value pairs.

Parameter statusCode : The HTTP status code of the GatewayResponse.

Implementation

Future<GatewayResponse> putGatewayResponse({
  required GatewayResponseType responseType,
  required String restApiId,
  Map<String, String>? responseParameters,
  Map<String, String>? responseTemplates,
  String? statusCode,
}) async {
  ArgumentError.checkNotNull(responseType, 'responseType');
  ArgumentError.checkNotNull(restApiId, 'restApiId');
  final $payload = <String, dynamic>{
    if (responseParameters != null) 'responseParameters': responseParameters,
    if (responseTemplates != null) 'responseTemplates': responseTemplates,
    if (statusCode != null) 'statusCode': statusCode,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'PUT',
    requestUri:
        '/restapis/${Uri.encodeComponent(restApiId)}/gatewayresponses/${Uri.encodeComponent(responseType.toValue())}',
    exceptionFnMap: _exceptionFns,
  );
  return GatewayResponse.fromJson(response);
}