createTask method

Future<CreateTaskResponse> createTask({
  1. required String destinationLocationArn,
  2. required String sourceLocationArn,
  3. String? cloudWatchLogGroupArn,
  4. List<FilterRule>? excludes,
  5. String? name,
  6. Options? options,
  7. TaskSchedule? schedule,
  8. List<TagListEntry>? tags,
})

Creates a task. A task is a set of two locations (source and destination) and a set of Options that you use to control the behavior of a task. If you don't specify Options when you create a task, AWS DataSync populates them with service defaults.

When you create a task, it first enters the CREATING state. During CREATING AWS DataSync attempts to mount the on-premises Network File System (NFS) location. The task transitions to the AVAILABLE state without waiting for the AWS location to become mounted. If required, AWS DataSync mounts the AWS location before each task execution.

If an agent that is associated with a source (NFS) location goes offline, the task transitions to the UNAVAILABLE status. If the status of the task remains in the CREATING status for more than a few minutes, it means that your agent might be having trouble mounting the source NFS file system. Check the task's ErrorCode and ErrorDetail. Mount issues are often caused by either a misconfigured firewall or a mistyped NFS server hostname.

May throw InvalidRequestException. May throw InternalException.

Parameter destinationLocationArn : The Amazon Resource Name (ARN) of an AWS storage resource's location.

Parameter sourceLocationArn : The Amazon Resource Name (ARN) of the source location for the task.

Parameter cloudWatchLogGroupArn : The Amazon Resource Name (ARN) of the Amazon CloudWatch log group that is used to monitor and log events in the task.

Parameter excludes : A list of filter rules that determines which files to exclude from a task. The list should contain a single filter string that consists of the patterns to exclude. The patterns are delimited by "|" (that is, a pipe), for example, "/folder1|/folder2".

Parameter name : The name of a task. This value is a text reference that is used to identify the task in the console.

Parameter options : The set of configuration options that control the behavior of a single execution of the task that occurs when you call StartTaskExecution. You can configure these options to preserve metadata such as user ID (UID) and group ID (GID), file permissions, data integrity verification, and so on.

For each individual task execution, you can override these options by specifying the OverrideOptions before starting the task execution. For more information, see the operation.

Parameter schedule : Specifies a schedule used to periodically transfer files from a source to a destination location. The schedule should be specified in UTC time. For more information, see task-scheduling.

Parameter tags : The key-value pair that represents the tag that you want to add to the resource. The value can be an empty string.

Implementation

Future<CreateTaskResponse> createTask({
  required String destinationLocationArn,
  required String sourceLocationArn,
  String? cloudWatchLogGroupArn,
  List<FilterRule>? excludes,
  String? name,
  Options? options,
  TaskSchedule? schedule,
  List<TagListEntry>? tags,
}) async {
  ArgumentError.checkNotNull(
      destinationLocationArn, 'destinationLocationArn');
  _s.validateStringLength(
    'destinationLocationArn',
    destinationLocationArn,
    0,
    128,
    isRequired: true,
  );
  ArgumentError.checkNotNull(sourceLocationArn, 'sourceLocationArn');
  _s.validateStringLength(
    'sourceLocationArn',
    sourceLocationArn,
    0,
    128,
    isRequired: true,
  );
  _s.validateStringLength(
    'cloudWatchLogGroupArn',
    cloudWatchLogGroupArn,
    0,
    562,
  );
  _s.validateStringLength(
    'name',
    name,
    1,
    256,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'FmrsService.CreateTask'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'DestinationLocationArn': destinationLocationArn,
      'SourceLocationArn': sourceLocationArn,
      if (cloudWatchLogGroupArn != null)
        'CloudWatchLogGroupArn': cloudWatchLogGroupArn,
      if (excludes != null) 'Excludes': excludes,
      if (name != null) 'Name': name,
      if (options != null) 'Options': options,
      if (schedule != null) 'Schedule': schedule,
      if (tags != null) 'Tags': tags,
    },
  );

  return CreateTaskResponse.fromJson(jsonResponse.body);
}