| 1 |
from __future__ import annotations |
| 2 |
|
| 3 |
import typing as t |
| 4 |
import uuid |
| 5 |
|
| 6 |
TWO_HOP_TRANSFER_FLOW_ID = "24bc4997-b483-4c25-a19c-64b0afc00743" |
| 7 |
TWO_HOP_TRANSFER_FLOW_OWNER_ID = "b44bddda-d274-11e5-978a-9f15789a8150" |
| 8 |
|
| 9 |
FLOW_ID = str(uuid.uuid1()) |
| 10 |
RUN_ID = str(uuid.uuid1()) |
| 11 |
USER1 = f"urn:globus:auth:identity:{uuid.uuid1()}" |
| 12 |
USER2 = f"urn:globus:auth:identity:{uuid.uuid1()}" |
| 13 |
GROUP = f"urn:globus:groups:id:{uuid.uuid1()}" |
| 14 |
RUN_MANAGER_PRINCIPAL = f"urn:globus:auth:identity:{str(uuid.uuid1())}" |
| 15 |
RUN_MONITOR_PRINCIPAL = f"urn:globus:auth:identity:{str(uuid.uuid1())}" |
| 16 |
|
| 17 |
TWO_HOP_TRANSFER_FLOW_USER_SCOPE = ( |
| 18 |
"https://auth.globus.org/scopes/" |
| 19 |
+ TWO_HOP_TRANSFER_FLOW_ID |
| 20 |
+ "/flow_" |
| 21 |
+ TWO_HOP_TRANSFER_FLOW_ID.replace("-", "_") |
| 22 |
+ "_user" |
| 23 |
) |
| 24 |
|
| 25 |
TWO_HOP_TRANSFER_FLOW_DEFINITION = { |
| 26 |
"States": { |
| 27 |
"Transfer1": { |
| 28 |
"Next": "Transfer2", |
| 29 |
"Type": "Action", |
| 30 |
"Comment": "Initial Transfer from Campus to DMZ", |
| 31 |
"ActionUrl": "https://actions.globus.org/transfer/transfer", |
| 32 |
"Parameters": { |
| 33 |
"transfer_items": [ |
| 34 |
{ |
| 35 |
"recursive": True, |
| 36 |
"source_path.$": "$.source_path", |
| 37 |
"destination_path.$": "$.staging_path", |
| 38 |
} |
| 39 |
], |
| 40 |
"source_endpoint_id.$": "$.source_endpoint_id", |
| 41 |
"destination_endpoint_id.$": "$.staging_endpoint_id", |
| 42 |
}, |
| 43 |
"ResultPath": "$.Transfer1Result", |
| 44 |
"ActionScope": ( |
| 45 |
"https://auth.globus.org/scopes/actions.globus.org/transfer/transfer" |
| 46 |
), |
| 47 |
}, |
| 48 |
"Transfer2": { |
| 49 |
"End": True, |
| 50 |
"Type": "Action", |
| 51 |
"Comment": "Transfer from DMZ to dataset repository", |
| 52 |
"ActionUrl": "https://actions.globus.org/transfer/transfer", |
| 53 |
"Parameters": { |
| 54 |
"transfer_items": [ |
| 55 |
{ |
| 56 |
"recursive": True, |
| 57 |
"source_path.$": "$.staging_path", |
| 58 |
"destination_path.$": "$.destination_path", |
| 59 |
} |
| 60 |
], |
| 61 |
"source_endpoint_id.$": "$.staging_endpoint_id", |
| 62 |
"destination_endpoint_id.$": "$.destination_endpoint_id", |
| 63 |
}, |
| 64 |
"ResultPath": "$.Transfer2Result", |
| 65 |
"ActionScope": ( |
| 66 |
"https://auth.globus.org/scopes/actions.globus.org/transfer/transfer" |
| 67 |
), |
| 68 |
}, |
| 69 |
}, |
| 70 |
"Comment": "Two step transfer", |
| 71 |
"StartAt": "Transfer1", |
| 72 |
} |
| 73 |
TWO_HOP_TRANSFER_FLOW_DOC = { |
| 74 |
"id": TWO_HOP_TRANSFER_FLOW_ID, |
| 75 |
"definition": TWO_HOP_TRANSFER_FLOW_DEFINITION, |
| 76 |
"input_schema": { |
| 77 |
"type": "object", |
| 78 |
"required": [ |
| 79 |
"source_endpoint_id", |
| 80 |
"source_path", |
| 81 |
"staging_endpoint_id", |
| 82 |
"staging_path", |
| 83 |
"destination_endpoint_id", |
| 84 |
"destination_path", |
| 85 |
], |
| 86 |
"properties": { |
| 87 |
"source_path": {"type": "string"}, |
| 88 |
"staging_path": {"type": "string"}, |
| 89 |
"destination_path": {"type": "string"}, |
| 90 |
"source_endpoint_id": {"type": "string"}, |
| 91 |
"staging_endpoint_id": {"type": "string"}, |
| 92 |
"destination_endpoint_id": {"type": "string"}, |
| 93 |
}, |
| 94 |
"additionalProperties": False, |
| 95 |
}, |
| 96 |
"globus_auth_scope": TWO_HOP_TRANSFER_FLOW_USER_SCOPE, |
| 97 |
"synchronous": False, |
| 98 |
"log_supported": True, |
| 99 |
"types": ["Action"], |
| 100 |
"api_version": "1.0", |
| 101 |
"title": "Multi Step Transfer", |
| 102 |
"subtitle": "", |
| 103 |
"description": "", |
| 104 |
"keywords": ["two", "hop", "transfer"], |
| 105 |
"principal_urn": f"urn:globus:auth:identity:{TWO_HOP_TRANSFER_FLOW_ID}", |
| 106 |
"globus_auth_username": f"{TWO_HOP_TRANSFER_FLOW_ID}@clients.auth.globus.org", |
| 107 |
"created_at": "2020-09-01T17:59:20.711845+00:00", |
| 108 |
"updated_at": "2020-09-01T17:59:20.711845+00:00", |
| 109 |
"user_role": "flow_starter", |
| 110 |
"created_by": f"urn:globus:auth:identity:{TWO_HOP_TRANSFER_FLOW_OWNER_ID}", |
| 111 |
"visible_to": [], |
| 112 |
"runnable_by": [], |
| 113 |
"administered_by": [], |
| 114 |
"action_url": f"https://flows.globus.org/flows/{TWO_HOP_TRANSFER_FLOW_ID}", |
| 115 |
"flow_url": f"https://flows.globus.org/flows/{TWO_HOP_TRANSFER_FLOW_ID}", |
| 116 |
"flow_owner": f"urn:globus:auth:identity:{TWO_HOP_TRANSFER_FLOW_OWNER_ID}", |
| 117 |
"flow_viewers": [ |
| 118 |
"public", |
| 119 |
"urn:globus:auth:identity:51abb9ce-6e05-4ab1-9a09-9c524313827c", |
| 120 |
], |
| 121 |
"flow_starters": [ |
| 122 |
"all_authenticated_users", |
| 123 |
"urn:globus:auth:identity:d0a15d1b-28f5-42de-9463-b8b6540421b6", |
| 124 |
], |
| 125 |
"flow_administrators": [ |
| 126 |
"urn:globus:auth:identity:05d29dab-bd26-4510-9290-468972e8ac01" |
| 127 |
], |
| 128 |
"run_managers": [RUN_MANAGER_PRINCIPAL], |
| 129 |
"run_monitors": [RUN_MONITOR_PRINCIPAL], |
| 130 |
} |
| 131 |
|
| 132 |
TWO_HOP_TRANSFER_RUN_ID = "36ad9f9a-ad29-488f-beb4-c22ab729643a" |
| 133 |
TWO_HOP_TRANSFER_RUN: dict[str, t.Any] = { |
| 134 |
"run_id": TWO_HOP_TRANSFER_RUN_ID, |
| 135 |
"flow_id": TWO_HOP_TRANSFER_FLOW_ID, |
| 136 |
"flow_title": TWO_HOP_TRANSFER_FLOW_DOC["title"], |
| 137 |
"flow_last_updated": "2020-09-01T17:59:20.711845+00:00", |
| 138 |
"start_time": "2020-09-12T15:00:20.711845+00:00", |
| 139 |
"status": "ACTIVE", |
| 140 |
"display_status": "ACTIVE", |
| 141 |
"details": { |
| 142 |
"code": "FlowStarting", |
| 143 |
"description": "The Flow is starting execution", |
| 144 |
"details": { |
| 145 |
"input": { |
| 146 |
"source_endpoint_id": "7e1b8ec7-a606-4c23-96c7-a2d930a3a55f", |
| 147 |
"source_path": "/path/to/the/source/dir", |
| 148 |
"staging_endpoint_id": "d5049dd6-ce9c-4f9e-853f-c25069f369f8", |
| 149 |
"staging_path": "/path/to/the/staging/dir", |
| 150 |
"destination_endpoint_id": "f3bd0daf-be5a-4df8-b53f-76b932113b7c", |
| 151 |
"destination_path": "/path/to/the/dest/dir", |
| 152 |
} |
| 153 |
}, |
| 154 |
}, |
| 155 |
"run_owner": TWO_HOP_TRANSFER_FLOW_DOC["flow_owner"], |
| 156 |
"run_managers": ["urn:globus:auth:identity:7d6064ef-5368-473a-b15b-e99c3561aa9b"], |
| 157 |
"run_monitors": [ |
| 158 |
"urn:globus:auth:identity:58cf49f4-06ea-4b76-934c-d5c9f6c3ea9d", |
| 159 |
"urn:globus:auth:identity:57088a17-d5cb-4cfa-871a-c5cce48f2aec", |
| 160 |
], |
| 161 |
"user_role": "run_owner", |
| 162 |
"label": "Transfer all of these files!", |
| 163 |
"tags": [ |
| 164 |
"my-transfer-run", |
| 165 |
"jazz-fans", |
| 166 |
], |
| 167 |
"search": {"task_id": "20ba91a8-eb90-470a-9477-2ad68808b276"}, |
| 168 |
} |
| 169 |
|
| 170 |
FLOW_SCOPE_SUFFIX = f'flow_{FLOW_ID.replace("-", "_")}_user' |
| 171 |
FLOW_SCOPE = f"https://auth.globus.org/scopes/{FLOW_ID}/{FLOW_SCOPE_SUFFIX}" |
| 172 |
FLOW_DESCRIPTION = { |
| 173 |
"created_at": "2023-04-11T20:00:06.524930+00:00", |
| 174 |
"flow_owner": USER1, |
| 175 |
"created_by": USER1, |
| 176 |
"description": "This flow does some pretty cool stuff", |
| 177 |
"globus_auth_scope": FLOW_SCOPE, |
| 178 |
"id": FLOW_ID, |
| 179 |
"keywords": ["cool"], |
| 180 |
"subtitle": "My Cool Subtitle", |
| 181 |
"title": "My Cool Flow", |
| 182 |
"updated_at": "2023-04-11T20:00:06.524930+00:00", |
| 183 |
} |
| 184 |
RUN_DETAILS = { |
| 185 |
"code": "FlowSucceeded", |
| 186 |
"description": "The Flow run reached a successful completion state", |
| 187 |
"output": { |
| 188 |
"HelloResult": { |
| 189 |
"action_id": "6RxDm1JOQnG2", |
| 190 |
"completion_time": "2023-04-11T20:01:22.340594+00:00", |
| 191 |
"creator_id": USER1, |
| 192 |
"details": {"Hello": "World", "hello": "foo"}, |
| 193 |
"display_status": "SUCCEEDED", |
| 194 |
"label": "My Cool Run", |
| 195 |
"manage_by": [USER2], |
| 196 |
"monitor_by": [GROUP], |
| 197 |
"release_after": None, |
| 198 |
"start_time": "2023-04-11T20:01:19.660251+00:00", |
| 199 |
"state_name": "RunHelloWorld", |
| 200 |
"status": "SUCCEEDED", |
| 201 |
}, |
| 202 |
"input": {"echo_string": "foo", "sleep": 2}, |
| 203 |
}, |
| 204 |
} |
| 205 |
RUN = { |
| 206 |
"run_id": RUN_ID, |
| 207 |
"action_id": RUN_ID, |
| 208 |
"completion_time": "2023-04-11T20:01:22.917000+00:00", |
| 209 |
"created_by": USER1, |
| 210 |
"details": RUN_DETAILS, |
| 211 |
"display_status": "SUCCEEDED", |
| 212 |
"flow_id": FLOW_ID, |
| 213 |
"flow_last_updated": "2023-04-11T20:00:06.524930+00:00", |
| 214 |
"flow_title": "My Cool Flow", |
| 215 |
"label": "My Cool Run", |
| 216 |
"manage_by": [USER2], |
| 217 |
"monitor_by": [GROUP], |
| 218 |
"run_managers": [USER2], |
| 219 |
"run_monitors": [GROUP], |
| 220 |
"run_owner": USER1, |
| 221 |
"start_time": "2023-04-11T20:01:18.040416+00:00", |
| 222 |
"status": "SUCCEEDED", |
| 223 |
"tags": ["cool", "my"], |
| 224 |
"user_role": "run_owner", |
| 225 |
} |