createDeployment method

Future<CreateDeploymentResponse> createDeployment({
  1. required String applicationId,
  2. required int applicationVersion,
  3. required String environmentId,
  4. String? clientToken,
})

Creates and starts a deployment to deploy an application into a runtime environment.

May throw AccessDeniedException. May throw ConflictException. May throw InternalServerException. May throw ResourceNotFoundException. May throw ServiceQuotaExceededException. May throw ThrottlingException. May throw ValidationException.

Parameter applicationId : The application identifier.

Parameter applicationVersion : The version of the application to deploy.

Parameter environmentId : The identifier of the runtime environment where you want to deploy this application.

Parameter clientToken : Unique, case-sensitive identifier you provide to ensure the idempotency of the request to create a deployment. The service generates the clientToken when the API call is triggered. The token expires after one hour, so if you retry the API within this timeframe with the same clientToken, you will get the same response. The service also handles deleting the clientToken after it expires.

Implementation

Future<CreateDeploymentResponse> createDeployment({
  required String applicationId,
  required int applicationVersion,
  required String environmentId,
  String? clientToken,
}) async {
  _s.validateNumRange(
    'applicationVersion',
    applicationVersion,
    1,
    1152921504606846976,
    isRequired: true,
  );
  final $payload = <String, dynamic>{
    'applicationVersion': applicationVersion,
    'environmentId': environmentId,
    'clientToken': clientToken ?? _s.generateIdempotencyToken(),
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri:
        '/applications/${Uri.encodeComponent(applicationId)}/deployments',
    exceptionFnMap: _exceptionFns,
  );
  return CreateDeploymentResponse.fromJson(response);
}