createWorkflow method

Future<CreateWorkflowResponse> createWorkflow({
  1. required List<WorkflowStep> steps,
  2. String? description,
  3. List<WorkflowStep>? onExceptionSteps,
  4. List<Tag>? tags,
})

Allows you to create a workflow with specified steps and step details the workflow invokes after file transfer completes. After creating a workflow, you can associate the workflow created with any transfer servers by specifying the workflow-details field in CreateServer and UpdateServer operations.

May throw AccessDeniedException. May throw InternalServiceError. May throw InvalidRequestException. May throw ResourceExistsException. May throw ServiceUnavailableException. May throw ThrottlingException.

Parameter steps : Specifies the details for the steps that are in the specified workflow.

The TYPE specifies which of the following actions is being taken for this step.

  • COPY - Copy the file to another location.
  • CUSTOM - Perform a custom step with an Lambda function target.
  • DECRYPT - Decrypt a file that was encrypted before it was uploaded.
  • DELETE - Delete the file.
  • TAG - Add a tag to the file.
For file location, you specify either the Amazon S3 bucket and key, or the Amazon EFS file system ID and path.

Parameter description : A textual description for the workflow.

Parameter onExceptionSteps : Specifies the steps (actions) to take if errors are encountered during execution of the workflow.

Parameter tags : Key-value pairs that can be used to group and search for workflows. Tags are metadata attached to workflows for any purpose.

Implementation

Future<CreateWorkflowResponse> createWorkflow({
  required List<WorkflowStep> steps,
  String? description,
  List<WorkflowStep>? onExceptionSteps,
  List<Tag>? tags,
}) async {
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'TransferService.CreateWorkflow'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'Steps': steps,
      if (description != null) 'Description': description,
      if (onExceptionSteps != null) 'OnExceptionSteps': onExceptionSteps,
      if (tags != null) 'Tags': tags,
    },
  );

  return CreateWorkflowResponse.fromJson(jsonResponse.body);
}