|
| 1 | +namespace files |
| 2 | + |
| 3 | +import common |
| 4 | +import async |
| 5 | + |
| 6 | +alias TagText = String(min_length=1, max_length=32, pattern="[A-Za-z0-9\_]+") |
| 7 | + |
| 8 | +union Tag |
| 9 | + "Tag that can be added in multiple ways." |
| 10 | + |
| 11 | + user_generated_tag UserGeneratedTag |
| 12 | + "Tag generated by the user." |
| 13 | + |
| 14 | + example default |
| 15 | + user_generated_tag = default |
| 16 | + |
| 17 | + |
| 18 | +union BaseError |
| 19 | + unknown |
| 20 | + "Action failed." |
| 21 | + transient |
| 22 | + "Action failed. Try again." |
| 23 | + input_validation |
| 24 | + "Action failed due to wrong params." |
| 25 | + cancelled |
| 26 | + "Action cancelled." |
| 27 | + |
| 28 | +struct UserGeneratedTag |
| 29 | + tag_text TagText |
| 30 | + |
| 31 | + example default |
| 32 | + tag_text = "my_tag" |
| 33 | + |
| 34 | + |
| 35 | + |
| 36 | +union BaseTagError extends BaseError |
| 37 | + feature_not_supported |
| 38 | + "Tags are not turned on for your team. Please turn on the feature." |
| 39 | + |
| 40 | + path_not_found |
| 41 | + "Path not found." |
| 42 | + |
| 43 | + |
| 44 | +##################################### |
| 45 | +# Add Tag to an item |
| 46 | +##################################### |
| 47 | +struct AddTagArg |
| 48 | + path Path |
| 49 | + "Path to the item to be tagged." |
| 50 | + |
| 51 | + tag_text TagText |
| 52 | + "The value of the tag to add." |
| 53 | + |
| 54 | + example default |
| 55 | + path = "/Prime_Numbers.txt" |
| 56 | + tag_text = "MyTag" |
| 57 | + |
| 58 | +union AddTagError extends BaseTagError |
| 59 | + too_many_tags |
| 60 | + "Item already has max supported tags." |
| 61 | + |
| 62 | +route tags/add(AddTagArg, Void, AddTagError) |
| 63 | + "Add a tag to an item. A tag is a string. No more than 20 tags can be added to a given item." |
| 64 | + |
| 65 | + attrs |
| 66 | + auth = "user" |
| 67 | + is_preview = true |
| 68 | + scope = "files.metadata.write" |
| 69 | + |
| 70 | + |
| 71 | +##################################### |
| 72 | +# Remove Tag from a item |
| 73 | +##################################### |
| 74 | + |
| 75 | +struct RemoveTagArg |
| 76 | + path Path |
| 77 | + "Path to the item to tag." |
| 78 | + |
| 79 | + tag_text TagText |
| 80 | + "The tag to remove." |
| 81 | + |
| 82 | + example default |
| 83 | + path = "/Prime_Numbers.txt" |
| 84 | + tag_text = "MyTag" |
| 85 | + |
| 86 | +union RemoveTagError extends BaseTagError |
| 87 | + tag_not_exists_for_this_path |
| 88 | + "That tag doesn't exist at this path." |
| 89 | + |
| 90 | +route tags/remove(RemoveTagArg, Void, RemoveTagError) |
| 91 | + "Remove a tag from an item." |
| 92 | + |
| 93 | + attrs |
| 94 | + auth = "user" |
| 95 | + is_preview = true |
| 96 | + scope = "files.metadata.write" |
| 97 | + |
| 98 | +############################################### |
| 99 | +# Get tags by item |
| 100 | +############################################### |
| 101 | +struct GetTagsArg |
| 102 | + paths List(Path) |
| 103 | + "Path to the items." |
| 104 | + |
| 105 | + example default |
| 106 | + paths = ["/Prime_Numbers.txt"] |
| 107 | + |
| 108 | +struct PathToTags |
| 109 | + path Path |
| 110 | + "Path of the item." |
| 111 | + tags List(Tag) |
| 112 | + "Tags assigned to this item." |
| 113 | + example default |
| 114 | + path = "/Prime_Numbers.txt" |
| 115 | + tags = [default] |
| 116 | + |
| 117 | +struct GetTagsResult |
| 118 | + paths_to_tags List(PathToTags) |
| 119 | + "List of paths and their corresponding tags." |
| 120 | + |
| 121 | + example default |
| 122 | + paths_to_tags = [default] |
| 123 | + |
| 124 | +route tags/get(GetTagsArg, GetTagsResult, BaseTagError) |
| 125 | + "Get list of tags assigned to items." |
| 126 | + |
| 127 | + attrs |
| 128 | + auth = "user" |
| 129 | + is_preview = true |
| 130 | + scope = "files.metadata.read" |
0 commit comments