createRouteResponse method

Future<CreateRouteResponseResponse> createRouteResponse({
  1. required String apiId,
  2. required String routeId,
  3. required String routeResponseKey,
  4. String? modelSelectionExpression,
  5. Map<String, String>? responseModels,
  6. Map<String, ParameterConstraints>? responseParameters,
})

Creates a RouteResponse for a Route.

May throw NotFoundException. May throw TooManyRequestsException. May throw BadRequestException. May throw ConflictException.

Parameter apiId : The API identifier.

Parameter routeId : The route ID.

Parameter routeResponseKey : The route response key.

Parameter modelSelectionExpression : The model selection expression for the route response. Supported only for WebSocket APIs.

Parameter responseModels : The response models for the route response.

Parameter responseParameters : The route response parameters.

Implementation

Future<CreateRouteResponseResponse> createRouteResponse({
  required String apiId,
  required String routeId,
  required String routeResponseKey,
  String? modelSelectionExpression,
  Map<String, String>? responseModels,
  Map<String, ParameterConstraints>? responseParameters,
}) async {
  ArgumentError.checkNotNull(apiId, 'apiId');
  ArgumentError.checkNotNull(routeId, 'routeId');
  ArgumentError.checkNotNull(routeResponseKey, 'routeResponseKey');
  final $payload = <String, dynamic>{
    'routeResponseKey': routeResponseKey,
    if (modelSelectionExpression != null)
      'modelSelectionExpression': modelSelectionExpression,
    if (responseModels != null) 'responseModels': responseModels,
    if (responseParameters != null) 'responseParameters': responseParameters,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri:
        '/v2/apis/${Uri.encodeComponent(apiId)}/routes/${Uri.encodeComponent(routeId)}/routeresponses',
    exceptionFnMap: _exceptionFns,
  );
  return CreateRouteResponseResponse.fromJson(response);
}