createReplicationJob method

Future<CreateReplicationJobResponse> createReplicationJob({
  1. required DateTime seedReplicationTime,
  2. required String serverId,
  3. String? description,
  4. bool? encrypted,
  5. int? frequency,
  6. String? kmsKeyId,
  7. LicenseType? licenseType,
  8. int? numberOfRecentAmisToKeep,
  9. String? roleName,
  10. bool? runOnce,
})

Creates a replication job. The replication job schedules periodic replication runs to replicate your server to AWS. Each replication run creates an Amazon Machine Image (AMI).

May throw InvalidParameterException. May throw MissingRequiredParameterException. May throw UnauthorizedOperationException. May throw OperationNotPermittedException. May throw ServerCannotBeReplicatedException. May throw ReplicationJobAlreadyExistsException. May throw NoConnectorsAvailableException. May throw InternalError. May throw TemporarilyUnavailableException.

Parameter seedReplicationTime : The seed replication time.

Parameter serverId : The ID of the server.

Parameter description : The description of the replication job.

Parameter encrypted : Indicates whether the replication job produces encrypted AMIs.

Parameter frequency : The time between consecutive replication runs, in hours.

Parameter kmsKeyId : The ID of the KMS key for replication jobs that produce encrypted AMIs. This value can be any of the following:

  • KMS key ID
  • KMS key alias
  • ARN referring to the KMS key ID
  • ARN referring to the KMS key alias
If encrypted is true but a KMS key ID is not specified, the customer's default KMS key for Amazon EBS is used.

Parameter licenseType : The license type to be used for the AMI created by a successful replication run.

Parameter numberOfRecentAmisToKeep : The maximum number of SMS-created AMIs to retain. The oldest is deleted after the maximum number is reached and a new AMI is created.

Parameter roleName : The name of the IAM role to be used by the AWS SMS.

Parameter runOnce : Indicates whether to run the replication job one time.

Implementation

Future<CreateReplicationJobResponse> createReplicationJob({
  required DateTime seedReplicationTime,
  required String serverId,
  String? description,
  bool? encrypted,
  int? frequency,
  String? kmsKeyId,
  LicenseType? licenseType,
  int? numberOfRecentAmisToKeep,
  String? roleName,
  bool? runOnce,
}) async {
  ArgumentError.checkNotNull(seedReplicationTime, 'seedReplicationTime');
  ArgumentError.checkNotNull(serverId, 'serverId');
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target':
        'AWSServerMigrationService_V2016_10_24.CreateReplicationJob'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'seedReplicationTime': unixTimestampToJson(seedReplicationTime),
      'serverId': serverId,
      if (description != null) 'description': description,
      if (encrypted != null) 'encrypted': encrypted,
      if (frequency != null) 'frequency': frequency,
      if (kmsKeyId != null) 'kmsKeyId': kmsKeyId,
      if (licenseType != null) 'licenseType': licenseType.toValue(),
      if (numberOfRecentAmisToKeep != null)
        'numberOfRecentAmisToKeep': numberOfRecentAmisToKeep,
      if (roleName != null) 'roleName': roleName,
      if (runOnce != null) 'runOnce': runOnce,
    },
  );

  return CreateReplicationJobResponse.fromJson(jsonResponse.body);
}