Skip to content

Commit 2e0799e

Browse files
sirosenada-globus
andauthored
Create a 'Transfer and Share' example (#10)
* Create a 'Transfer and Share' example This is based on prior art in several other example sources, most notably the 'transfer_share' trigger script example. In this case, the flow is kept inentionally simple, but it does include checking the destination collection type. * Update transfer_examples/transfer_share/README.adoc Co-authored-by: Ada <107940310+ada-globus@users.noreply.github.com> --------- Co-authored-by: Ada <107940310+ada-globus@users.noreply.github.com>
1 parent c289ac1 commit 2e0799e

File tree

5 files changed

+233
-0
lines changed

5 files changed

+233
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# configuration for conversion to docs.globus.org
2+
title: 'Transfer and Share Files'
3+
short_description: |
4+
Copy data to a Guest Collection and create a new read-only permission to
5+
allow a user or group to read the data from that location.
6+
7+
example_dir: 'transfer_share'
8+
index_source:
9+
copy: "README.adoc"
10+
append_source_blocks: true
11+
12+
menu_weight: 150
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
= Transfer and Share Files
2+
3+
== Description
4+
5+
Move and share files by transferring them to a Guest Collection.
6+
7+
The source directory or file will be copied, and then a new permission will be
8+
created on the destination to give read-only access to a user or group.
9+
10+
== Highlights
11+
12+
This **flow** verifies that the destination is a Guest Collection before starting the data transfer.
13+
This ensures that it will be possible to create a permission on the destination later in the **flow**.
14+
In `GetDestinationInfo`, the **flow** collects metadata about the collection, and in `CheckDestinationCollectionType`, it dispatches over that information.
15+
The **flow** jumps to a `Fail` state, `FailBadDestinationCollectionType`, if the check does not pass.
16+
17+
The input schema in this example also demonstrates how to accept **collection** and **principal** types.
18+
The `"format": "globus-collection"` annotation ensures that `source` and `destination` are treated as **collection**s when using guided **flow** input in the Globus Web App.
19+
`"format": "globus-principal"` does the same for users and groups.
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
{
2+
"Comment": "Transfer files to a guest collection and set permissions.",
3+
"StartAt": "GetDestinationInfo",
4+
"States": {
5+
"GetDestinationInfo": {
6+
"Type": "Action",
7+
"ActionUrl": "https://transfer.actions.globus.org/collection_info",
8+
"Parameters": {
9+
"endpoint_id.$": "$.destination.id"
10+
},
11+
"ResultPath": "$.DestinationInfo",
12+
"Next": "CheckDestinationCollectionType"
13+
},
14+
"CheckDestinationCollectionType": {
15+
"Type": "Choice",
16+
"Choices": [
17+
{
18+
"Or": [
19+
{
20+
"Variable": "$.DestinationInfo.details.entity_type",
21+
"StringEquals": "GCP_guest_collection"
22+
},
23+
{
24+
"Variable": "$.DestinationInfo.details.entity_type",
25+
"StringEquals": "GCSv5_guest_collection"
26+
}
27+
],
28+
"Next": "TransferFiles"
29+
}
30+
],
31+
"Default": "FailBadDestinationCollectionType"
32+
},
33+
"TransferFiles": {
34+
"Type": "Action",
35+
"ActionUrl": "https://transfer.actions.globus.org/transfer",
36+
"Parameters": {
37+
"source_endpoint.$": "$.source.id",
38+
"destination_endpoint.$": "$.destination.id",
39+
"DATA": [
40+
{
41+
"DATA_TYPE": "transfer_item",
42+
"source_path.$": "$.source.path",
43+
"destination_path.$": "$.destination.path"
44+
}
45+
]
46+
},
47+
"ResultPath": "$.TransferFiles",
48+
"Next": "SetPermission"
49+
},
50+
"SetPermission": {
51+
"Comment": "Grant read permission on the data to a Globus user or group",
52+
"Type": "Action",
53+
"ActionUrl": "https://transfer.actions.globus.org/manage_permission",
54+
"Parameters": {
55+
"endpoint_id.$": "$.destination.id",
56+
"path.$": "$.destination.path",
57+
"operation": "CREATE",
58+
"permissions": "r",
59+
"principal_type.$": "$.principal.type",
60+
"principal.$": "$.principal.id"
61+
},
62+
"ResultPath": "$.SetPermission",
63+
"End": true
64+
},
65+
"FailBadDestinationCollectionType": {
66+
"Comment": "Fail due to an incorrect destination collection type.",
67+
"Type": "Fail",
68+
"Cause": "NonGuestDestinationCollection",
69+
"Error": "The destination collection is not a guest collection, which is a requirement for this flow."
70+
}
71+
}
72+
}
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
{
2+
"type": "object",
3+
"additionalProperties": false,
4+
"required": [
5+
"source",
6+
"destination",
7+
"principal"
8+
],
9+
"propertyOrder": [
10+
"source",
11+
"destination",
12+
"principal"
13+
],
14+
"properties": {
15+
"source": {
16+
"title": "Source",
17+
"type": "object",
18+
"format": "globus-collection",
19+
"additionalProperties": false,
20+
"required": [
21+
"id",
22+
"path"
23+
],
24+
"properties": {
25+
"id": {
26+
"type": "string",
27+
"format": "uuid"
28+
},
29+
"path": {
30+
"type": "string"
31+
}
32+
}
33+
},
34+
"destination": {
35+
"title": "Destination",
36+
"type": "object",
37+
"format": "globus-collection",
38+
"additionalProperties": false,
39+
"required": [
40+
"id",
41+
"path"
42+
],
43+
"properties": {
44+
"id": {
45+
"type": "string",
46+
"format": "uuid"
47+
},
48+
"path": {
49+
"type": "string"
50+
}
51+
}
52+
},
53+
"principal": {
54+
"type": "object",
55+
"format": "globus-principal",
56+
"title": "User or Group",
57+
"oneOf": [
58+
{
59+
"$ref": "#/definitions/identity-principal"
60+
},
61+
{
62+
"$ref": "#/definitions/group-principal"
63+
}
64+
]
65+
}
66+
},
67+
"definitions": {
68+
"group-principal": {
69+
"properties": {
70+
"id": {
71+
"type": "string",
72+
"format": "uuid"
73+
},
74+
"type": {
75+
"type": "string",
76+
"enum": [
77+
"group"
78+
]
79+
},
80+
"urn": {
81+
"type": "string",
82+
"pattern": "^urn:globus:groups:id:[0-9a-fA-F-]{36}$"
83+
}
84+
},
85+
"required": [
86+
"id",
87+
"type"
88+
],
89+
"additionalProperties": false
90+
},
91+
"identity-principal": {
92+
"properties": {
93+
"id": {
94+
"type": "string",
95+
"format": "uuid"
96+
},
97+
"type": {
98+
"type": "string",
99+
"enum": [
100+
"identity"
101+
]
102+
},
103+
"urn": {
104+
"type": "string",
105+
"pattern": "^urn:globus:auth:identity:[0-9a-fA-F-]{36}$"
106+
}
107+
},
108+
"required": [
109+
"id",
110+
"type"
111+
],
112+
"additionalProperties": false
113+
}
114+
}
115+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"source": {
3+
"id": "6c54cade-bde5-45c1-bdea-f4bd71dba2cc",
4+
"path": "/~/source-directory"
5+
},
6+
"destination": {
7+
"id": "31ce9ba0-176d-45a5-add3-f37d233ba47d",
8+
"path": "/~/destination-directory"
9+
},
10+
"principal": {
11+
"id": "46bd0f56-e24f-11e5-a510-131bef46955c",
12+
"type": "identity",
13+
"urn": "urn:globus:auth:identity:46bd0f56-e24f-11e5-a510-131bef46955c"
14+
}
15+
}

0 commit comments

Comments
 (0)