|
| 1 | +{ |
| 2 | + "StartAt": "List", |
| 3 | + "States": { |
| 4 | + "List": { |
| 5 | + "Comment": "As an improvement, it may be worthwhile to first verify that $.source.path is a directory. This can be accomplished with two states -- an 'Action' state that calls 'stat', and a 'Choice' state that confirms the type is a 'dir'.", |
| 6 | + "Type": "Action", |
| 7 | + "ActionUrl": "https://transfer.actions.globus.org/ls", |
| 8 | + "Parameters": { |
| 9 | + "endpoint_id.$": "$.source.id", |
| 10 | + "path.$": "$.source.path", |
| 11 | + "limit": 100 |
| 12 | + }, |
| 13 | + "ResultPath": "$.ls_results", |
| 14 | + "Next": "CheckIfDone" |
| 15 | + }, |
| 16 | + "CheckIfDone": { |
| 17 | + "Comment": "This is the gatekeeper for looping. This will continue to loop until all files and directories have been transferred and deleted.", |
| 18 | + "Type": "Choice", |
| 19 | + "Choices": [ |
| 20 | + { |
| 21 | + "Variable": "$.ls_results.details.total", |
| 22 | + "NumericEquals": 0, |
| 23 | + "Next": "Done" |
| 24 | + } |
| 25 | + ], |
| 26 | + "Default": "PrepareTransferDATA" |
| 27 | + }, |
| 28 | + "Done": { |
| 29 | + "Type": "Pass", |
| 30 | + "End": true |
| 31 | + }, |
| 32 | + "PrepareTransferDATA": { |
| 33 | + "Type": "ExpressionEval", |
| 34 | + "ResultPath": "$.transformations", |
| 35 | + "Next": "Transfer", |
| 36 | + "Parameters": { |
| 37 | + "transfer_DATA.=": "[{'source_path': source.path.rstrip('/') + '/' + item.name, 'destination_path': destination.path.rstrip('/') + '/' + item.name} for item in ls_results.details.DATA]" |
| 38 | + } |
| 39 | + }, |
| 40 | + "Transfer": { |
| 41 | + "Comment": "Some validation may need to be added to verify that the items were transferred. This can be accomplished using a Choice state that looks at values in the $.transfer_results object.", |
| 42 | + "Type": "Action", |
| 43 | + "ActionUrl": "https://transfer.actions.globus.org/transfer", |
| 44 | + "ResultPath": "$.transfer_results", |
| 45 | + "Next": "PrepareDeleteDATA", |
| 46 | + "Parameters": { |
| 47 | + "DATA.$": "$.transformations.transfer_DATA", |
| 48 | + "source_endpoint.$": "$.source.id", |
| 49 | + "destination_endpoint.$": "$.destination.id" |
| 50 | + } |
| 51 | + }, |
| 52 | + "PrepareDeleteDATA": { |
| 53 | + "Type": "ExpressionEval", |
| 54 | + "ResultPath": "$.transformations", |
| 55 | + "Next": "Delete", |
| 56 | + "Parameters": { |
| 57 | + "delete_DATA.=": "[{'path': source.path.rstrip('/') + '/' + item.name} for item in ls_results.details.DATA]" |
| 58 | + } |
| 59 | + }, |
| 60 | + "Delete": { |
| 61 | + "Comment": "Some validation may need to be added to verify that the items were deleted. This can be accomplished using a Choice state that looks at values in the $.delete_results object. The delete task may also benefit from some options like 'ignore_missing'.", |
| 62 | + "Type": "Action", |
| 63 | + "ActionUrl": "https://transfer.actions.globus.org/delete", |
| 64 | + "ResultPath": "$.delete_results", |
| 65 | + "Next": "List", |
| 66 | + "Parameters": { |
| 67 | + "DATA.$": "$.transformations.delete_DATA", |
| 68 | + "endpoint.$": "$.source.id" |
| 69 | + } |
| 70 | + } |
| 71 | + } |
| 72 | +} |
0 commit comments