createRoute method

Future<CreateRouteResult> createRoute({
  1. required String apiId,
  2. required String routeKey,
  3. bool? apiKeyRequired,
  4. List<String>? authorizationScopes,
  5. AuthorizationType? authorizationType,
  6. String? authorizerId,
  7. String? modelSelectionExpression,
  8. String? operationName,
  9. Map<String, String>? requestModels,
  10. Map<String, ParameterConstraints>? requestParameters,
  11. String? routeResponseSelectionExpression,
  12. String? target,
})

Creates a Route for an API.

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

Parameter apiId : The API identifier.

Parameter routeKey : The route key for the route.

Parameter apiKeyRequired : Specifies whether an API key is required for the route. Supported only for WebSocket APIs.

Parameter authorizationScopes : The authorization scopes supported by this route.

Parameter authorizationType : The authorization type for the route. For WebSocket APIs, valid values are NONE for open access, AWS_IAM for using AWS IAM permissions, and CUSTOM for using a Lambda authorizer For HTTP APIs, valid values are NONE for open access, JWT for using JSON Web Tokens, AWS_IAM for using AWS IAM permissions, and CUSTOM for using a Lambda authorizer.

Parameter authorizerId : The identifier of the Authorizer resource to be associated with this route. The authorizer identifier is generated by API Gateway when you created the authorizer.

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

Parameter operationName : The operation name for the route.

Parameter requestModels : The request models for the route. Supported only for WebSocket APIs.

Parameter requestParameters : The request parameters for the route. Supported only for WebSocket APIs.

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

Parameter target : The target for the route.

Implementation

Future<CreateRouteResult> createRoute({
  required String apiId,
  required String routeKey,
  bool? apiKeyRequired,
  List<String>? authorizationScopes,
  AuthorizationType? authorizationType,
  String? authorizerId,
  String? modelSelectionExpression,
  String? operationName,
  Map<String, String>? requestModels,
  Map<String, ParameterConstraints>? requestParameters,
  String? routeResponseSelectionExpression,
  String? target,
}) async {
  ArgumentError.checkNotNull(apiId, 'apiId');
  ArgumentError.checkNotNull(routeKey, 'routeKey');
  final $payload = <String, dynamic>{
    'routeKey': routeKey,
    if (apiKeyRequired != null) 'apiKeyRequired': apiKeyRequired,
    if (authorizationScopes != null)
      'authorizationScopes': authorizationScopes,
    if (authorizationType != null)
      'authorizationType': authorizationType.toValue(),
    if (authorizerId != null) 'authorizerId': authorizerId,
    if (modelSelectionExpression != null)
      'modelSelectionExpression': modelSelectionExpression,
    if (operationName != null) 'operationName': operationName,
    if (requestModels != null) 'requestModels': requestModels,
    if (requestParameters != null) 'requestParameters': requestParameters,
    if (routeResponseSelectionExpression != null)
      'routeResponseSelectionExpression': routeResponseSelectionExpression,
    if (target != null) 'target': target,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri: '/v2/apis/${Uri.encodeComponent(apiId)}/routes',
    exceptionFnMap: _exceptionFns,
  );
  return CreateRouteResult.fromJson(response);
}