createStage method

Future<CreateStageResponse> createStage({
  1. required String apiId,
  2. required String stageName,
  3. AccessLogSettings? accessLogSettings,
  4. bool? autoDeploy,
  5. String? clientCertificateId,
  6. RouteSettings? defaultRouteSettings,
  7. String? deploymentId,
  8. String? description,
  9. Map<String, RouteSettings>? routeSettings,
  10. Map<String, String>? stageVariables,
  11. Map<String, String>? tags,
})

Creates a Stage for an API.

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

Parameter apiId : The API identifier.

Parameter stageName : The name of the stage.

Parameter accessLogSettings : Settings for logging access in this stage.

Parameter autoDeploy : Specifies whether updates to an API automatically trigger a new deployment. The default value is false.

Parameter clientCertificateId : The identifier of a client certificate for a Stage. Supported only for WebSocket APIs.

Parameter defaultRouteSettings : The default route settings for the stage.

Parameter deploymentId : The deployment identifier of the API stage.

Parameter description : The description for the API stage.

Parameter routeSettings : Route settings for the stage, by routeKey.

Parameter stageVariables : A map that defines the stage variables for a Stage. Variable names can have alphanumeric and underscore characters, and the values must match A-Za-z0-9-._~:/?#&amp;=,+.

Parameter tags : The collection of tags. Each tag element is associated with a given resource.

Implementation

Future<CreateStageResponse> createStage({
  required String apiId,
  required String stageName,
  AccessLogSettings? accessLogSettings,
  bool? autoDeploy,
  String? clientCertificateId,
  RouteSettings? defaultRouteSettings,
  String? deploymentId,
  String? description,
  Map<String, RouteSettings>? routeSettings,
  Map<String, String>? stageVariables,
  Map<String, String>? tags,
}) async {
  ArgumentError.checkNotNull(apiId, 'apiId');
  ArgumentError.checkNotNull(stageName, 'stageName');
  final $payload = <String, dynamic>{
    'stageName': stageName,
    if (accessLogSettings != null) 'accessLogSettings': accessLogSettings,
    if (autoDeploy != null) 'autoDeploy': autoDeploy,
    if (clientCertificateId != null)
      'clientCertificateId': clientCertificateId,
    if (defaultRouteSettings != null)
      'defaultRouteSettings': defaultRouteSettings,
    if (deploymentId != null) 'deploymentId': deploymentId,
    if (description != null) 'description': description,
    if (routeSettings != null) 'routeSettings': routeSettings,
    if (stageVariables != null) 'stageVariables': stageVariables,
    if (tags != null) 'tags': tags,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri: '/v2/apis/${Uri.encodeComponent(apiId)}/stages',
    exceptionFnMap: _exceptionFns,
  );
  return CreateStageResponse.fromJson(response);
}