sharing_files.stone 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659
  1. namespace sharing
  2. import common
  3. import files
  4. import users
  5. alias PathOrId = String(pattern="((\/|id:).*|nspath:[0-9]+:.*)|ns:[0-9]+(/.*)?", min_length=1)
  6. alias FileId = String(pattern="id:.*", min_length=1)
  7. ###########################################
  8. # Generic route error related definitions #
  9. ###########################################
  10. union SharingUserError
  11. "User account had a problem preventing this action."
  12. email_unverified
  13. "The current user must verify the account e-mail address before performing this action."
  14. union SharingFileAccessError
  15. "User could not access this file."
  16. no_permission
  17. "Current user does not have sufficient privileges to perform the desired action."
  18. invalid_file
  19. "File specified was not found."
  20. is_folder
  21. "A folder can't be shared this way. Use folder sharing or a shared link instead."
  22. inside_public_folder
  23. "A file inside a public folder can't be shared this way. Use a public link instead."
  24. inside_osx_package
  25. "A Mac OS X package can't be shared this way. Use a shared link instead."
  26. union FileErrorResult
  27. file_not_found_error files.Id
  28. "File specified by id was not found."
  29. invalid_file_action_error files.Id
  30. "User does not have permission to take the specified action on the file."
  31. permission_denied_error files.Id
  32. "User does not have permission to access file specified by file.Id."
  33. #############################################
  34. # File metadata and permissions definitions #
  35. #############################################
  36. union FileAction
  37. "Sharing actions that may be taken on files."
  38. disable_viewer_info
  39. "Disable viewer information on the file."
  40. edit_contents
  41. "Change or edit contents of the file."
  42. enable_viewer_info
  43. "Enable viewer information on the file."
  44. invite_viewer
  45. "Add a member with view permissions."
  46. invite_viewer_no_comment
  47. "Add a member with view permissions but no comment permissions."
  48. unshare
  49. "Stop sharing this file."
  50. relinquish_membership
  51. "Relinquish one's own membership to the file."
  52. share_link
  53. "This action is deprecated. Use create_link instead."
  54. create_link
  55. "Create a shared link to the file."
  56. example default
  57. edit_contents = null
  58. struct FilePermission
  59. "Whether the user is allowed to take the sharing action on the file."
  60. action FileAction
  61. "The action that the user may wish to take on the file."
  62. allow Boolean
  63. "True if the user is allowed to take the action."
  64. reason PermissionDeniedReason?
  65. "The reason why the user is denied the permission. Not present if the action
  66. is allowed."
  67. example default
  68. action = edit_contents
  69. allow = false
  70. reason = user_not_same_team_as_owner
  71. struct SharedFileMetadata
  72. "Properties of the shared file."
  73. access_type AccessLevel?
  74. "The current user's access level for this shared file."
  75. id FileId
  76. "The ID of the file."
  77. expected_link_metadata ExpectedSharedContentLinkMetadata?
  78. "The expected metadata of the link associated for the file when it is first shared.
  79. Absent if the link already exists. This is for an unreleased feature so it may not be
  80. returned yet."
  81. link_metadata SharedContentLinkMetadata?
  82. "The metadata of the link associated for the file. This is for an unreleased feature so
  83. it may not be returned yet."
  84. name String
  85. "The name of this file."
  86. owner_team users.Team?
  87. "The team that owns the file. This field is not present if the file
  88. is not owned by a team."
  89. parent_shared_folder_id common.SharedFolderId?
  90. "The ID of the parent shared folder. This field is present only if the
  91. file is contained within a shared folder."
  92. path_display String?
  93. "The cased path to be used for display purposes only. In rare instances
  94. the casing will not correctly match the user's filesystem, but this
  95. behavior will match the path provided in the Core API v1.
  96. Absent for unmounted files."
  97. path_lower String?
  98. "The lower-case full path of this file. Absent for unmounted files."
  99. permissions List(FilePermission)?
  100. "The sharing permissions that requesting user has on this file. This
  101. corresponds to the entries given in :field:`GetFileMetadataBatchArg.actions`
  102. or :field:`GetFileMetadataArg.actions`."
  103. policy FolderPolicy
  104. "Policies governing this shared file."
  105. preview_url String
  106. "URL for displaying a web preview of the shared file."
  107. time_invited common.DropboxTimestamp?
  108. "Timestamp indicating when the current user was invited to this shared file. If the user was
  109. not invited to the shared file, the timestamp will indicate when the user was invited to the
  110. parent shared folder. This value may be absent."
  111. example default
  112. policy = default
  113. permissions = []
  114. owner_team = default
  115. preview_url = "https://www.dropbox.com/scl/fi/fir9vjelf"
  116. path_lower = "/dir/file.txt"
  117. path_display = "/dir/file.txt"
  118. name = "file.txt"
  119. id = "id:3kmLmQFnf1AAAAAAAAAAAw"
  120. time_invited = "2016-01-20T00:00:00Z"
  121. access_type = viewer
  122. union ViewerInfoPolicy
  123. enabled
  124. "Viewer information is available on this file."
  125. disabled
  126. "Viewer information is disabled on this file."
  127. ##################################
  128. # File membership mutation types #
  129. ##################################
  130. struct FileMemberActionResult
  131. "Per-member result for :route:`add_file_member` or :route:`change_file_member_access`."
  132. member MemberSelector
  133. "One of specified input members."
  134. result FileMemberActionIndividualResult
  135. "The outcome of the action on this member."
  136. union_closed FileMemberActionIndividualResult
  137. success AccessLevel?
  138. "Member was successfully removed from this file. If AccessLevel is given,
  139. the member still has access via a parent shared folder."
  140. member_error FileMemberActionError
  141. "User was not able to perform this action."
  142. example default
  143. success = null
  144. union FileMemberRemoveActionResult
  145. success MemberAccessLevelResult
  146. "Member was successfully removed from this file."
  147. member_error FileMemberActionError
  148. "User was not able to remove this member."
  149. union AddFileMemberError
  150. "Errors for :route:`add_file_member`."
  151. user_error SharingUserError
  152. access_error SharingFileAccessError
  153. rate_limit
  154. "The user has reached the rate limit for invitations."
  155. invalid_comment
  156. "The custom message did not pass comment permissions checks."
  157. union RemoveFileMemberError
  158. "Errors for :route:`remove_file_member_2`."
  159. user_error SharingUserError
  160. access_error SharingFileAccessError
  161. no_explicit_access MemberAccessLevelResult
  162. "This member does not have explicit access to the file and therefore cannot be removed.
  163. The return value is the access that a user might have to the file from a parent folder."
  164. union FileMemberActionError
  165. invalid_member
  166. "Specified member was not found."
  167. no_permission
  168. "User does not have permission to perform this action on this member."
  169. access_error SharingFileAccessError
  170. "Specified file was invalid or user does not have access."
  171. no_explicit_access MemberAccessLevelResult
  172. "The action cannot be completed because the target member does not have explicit access
  173. to the file. The return value is the access that the member has to the file from a parent folder."
  174. #####################
  175. # Route Definitions #
  176. #####################
  177. route add_file_member(AddFileMemberArgs, List(FileMemberActionResult), AddFileMemberError)
  178. "Adds specified members to a file."
  179. attrs
  180. owner = "sharing"
  181. allow_app_folder_app = true
  182. struct AddFileMemberArgs
  183. "Arguments for :route:`add_file_member`."
  184. file PathOrId
  185. "File to which to add members."
  186. members List(MemberSelector)
  187. "Members to add. Note that even an email address is given, this
  188. may result in a user being directy added to the membership if that
  189. email is the user's main account email."
  190. custom_message String?
  191. "Message to send to added members in their invitation."
  192. quiet Boolean = false
  193. "Whether added members should be notified via device notifications of
  194. their invitation."
  195. access_level AccessLevel = viewer
  196. "AccessLevel union object, describing what access level we want to give new members."
  197. add_message_as_comment Boolean = false
  198. "If the custom message should be added as a comment on the file."
  199. example default
  200. file = "id:3kmLmQFnf1AAAAAAAAAAAw"
  201. members = [default]
  202. custom_message = "This is a custom message about ACME.doc"
  203. quiet = false
  204. access_level = viewer
  205. # --
  206. route change_file_member_access(ChangeFileMemberAccessArgs, FileMemberActionResult, FileMemberActionError) deprecated by update_file_member
  207. "Identical to update_file_member but with less information returned."
  208. attrs
  209. owner = "sharing"
  210. allow_app_folder_app = true
  211. struct ChangeFileMemberAccessArgs
  212. "Arguments for :route:`change_file_member_access`."
  213. file PathOrId
  214. "File for which we are changing a member's access."
  215. member MemberSelector
  216. "The member whose access we are changing."
  217. access_level AccessLevel
  218. "The new access level for the member."
  219. example default
  220. file = "id:3kmLmQFnf1AAAAAAAAAAAw"
  221. member = default
  222. access_level = viewer
  223. struct UpdateFileMemberArgs extends ChangeFileMemberAccessArgs
  224. "Arguments for :route:`update_file_member`."
  225. example default
  226. file = "id:3kmLmQFnf1AAAAAAAAAAAw"
  227. member = default
  228. access_level = viewer
  229. route update_file_member(UpdateFileMemberArgs, MemberAccessLevelResult, FileMemberActionError)
  230. "Changes a member's access on a shared file."
  231. attrs
  232. owner = "sharing"
  233. allow_app_folder_app = true
  234. # --
  235. route get_file_metadata(GetFileMetadataArg, SharedFileMetadata, GetFileMetadataError)
  236. "Returns shared file metadata."
  237. attrs
  238. owner = "sharing"
  239. api_group = "truelink-alpha"
  240. allow_app_folder_app = true
  241. struct GetFileMetadataArg
  242. "Arguments of :route:`get_file_metadata`."
  243. file PathOrId
  244. "The file to query."
  245. actions List(FileAction)?
  246. "A list of `FileAction`s corresponding to `FilePermission`s that should appear in the
  247. response's :field:`SharedFileMetadata.permissions` field describing the actions the
  248. authenticated user can perform on the file."
  249. example default
  250. file = "id:3kmLmQFnf1AAAAAAAAAAAw"
  251. actions = []
  252. union GetFileMetadataError
  253. "Error result for :route:`get_file_metadata`."
  254. user_error SharingUserError
  255. access_error SharingFileAccessError
  256. # --
  257. route get_file_metadata/batch(GetFileMetadataBatchArg, List(GetFileMetadataBatchResult), SharingUserError)
  258. "Returns shared file metadata."
  259. attrs
  260. owner = "sharing"
  261. allow_app_folder_app = true
  262. struct GetFileMetadataBatchArg
  263. "Arguments of :route:`get_file_metadata/batch`."
  264. files List(PathOrId, max_items=100)
  265. "The files to query."
  266. actions List(FileAction)?
  267. "A list of `FileAction`s corresponding to `FilePermission`s that should appear in the
  268. response's :field:`SharedFileMetadata.permissions` field describing the actions the
  269. authenticated user can perform on the file."
  270. example default
  271. files = ["id:3kmLmQFnf1AAAAAAAAAAAw","id:VvTaJu2VZzAAAAAAAAAADQ"]
  272. actions = []
  273. struct GetFileMetadataBatchResult
  274. "Per file results of :route:`get_file_metadata/batch`."
  275. file PathOrId
  276. "This is the input file identifier corresponding to one of
  277. :field:`GetFileMetadataBatchArg.files`."
  278. result GetFileMetadataIndividualResult
  279. "The result for this particular file."
  280. example default
  281. file = "id:3kmLmQFnf1AAAAAAAAAAAw"
  282. result = default
  283. example file_error
  284. file = "id:3kmLmQFnf1AAAAAAAAAAAw"
  285. result = file_error
  286. union GetFileMetadataIndividualResult
  287. metadata SharedFileMetadata
  288. "The result for this file if it was successful."
  289. access_error SharingFileAccessError
  290. "The result for this file if it was an error."
  291. example default
  292. metadata = default
  293. example file_error
  294. access_error = invalid_file
  295. # --
  296. route list_file_members(ListFileMembersArg, SharedFileMembers, ListFileMembersError)
  297. "Use to obtain the members who have been invited to a file, both inherited
  298. and uninherited members."
  299. attrs
  300. owner = "sharing"
  301. allow_app_folder_app = true
  302. struct ListFileMembersArg
  303. "Arguments for :route:`list_file_members`."
  304. file PathOrId
  305. "The file for which you want to see members."
  306. actions List(MemberAction)?
  307. "The actions for which to return permissions on a member."
  308. include_inherited Boolean = true
  309. "Whether to include members who only have access from a parent shared folder."
  310. limit UInt32(min_value=1, max_value=300) = 100
  311. "Number of members to return max per query. Defaults to 100 if no limit is specified."
  312. example default
  313. file = "id:3kmLmQFnf1AAAAAAAAAAAw"
  314. struct SharedFileMembers
  315. "Shared file user, group, and invitee membership.
  316. Used for the results of :route:`list_file_members` and
  317. :route:`list_file_members/continue`, and used as part of the results
  318. for :route:`list_file_members/batch`."
  319. users List(UserMembershipInfo)
  320. "The list of user members of the shared file."
  321. groups List(GroupMembershipInfo)
  322. "The list of group members of the shared file."
  323. invitees List(InviteeMembershipInfo)
  324. "The list of invited members of a file, but have not logged in and
  325. claimed this."
  326. cursor String?
  327. "Present if there are additional shared file members that have not been returned yet. Pass
  328. the cursor into :route:`list_file_members/continue` to list additional members."
  329. example default
  330. users = [default]
  331. groups = [default]
  332. invitees = [default]
  333. union ListFileMembersError
  334. "Error for :route:`list_file_members`."
  335. user_error SharingUserError
  336. access_error SharingFileAccessError
  337. # --
  338. route list_file_members/batch(ListFileMembersBatchArg, List(ListFileMembersBatchResult), SharingUserError)
  339. "Get members of multiple files at once. The arguments
  340. to this route are more limited, and the limit on query result size per file
  341. is more strict. To customize the results more, use the individual file
  342. endpoint.
  343. Inherited users and groups are not included in the result, and permissions are not
  344. returned for this endpoint."
  345. attrs
  346. owner = "sharing"
  347. allow_app_folder_app = true
  348. struct ListFileMembersBatchArg
  349. "Arguments for :route:`list_file_members/batch`."
  350. files List(PathOrId, max_items=100)
  351. "Files for which to return members."
  352. limit UInt32(max_value=20) = 10
  353. "Number of members to return max per query. Defaults to 10 if no limit is specified."
  354. example default
  355. files = ["id:3kmLmQFnf1AAAAAAAAAAAw","id:VvTaJu2VZzAAAAAAAAAADQ"]
  356. limit = 10
  357. struct ListFileMembersBatchResult
  358. "Per-file result for :route:`list_file_members/batch`."
  359. file PathOrId
  360. "This is the input file identifier, whether an ID or a path."
  361. result ListFileMembersIndividualResult
  362. "The result for this particular file."
  363. example default
  364. file = "id:3kmLmQFnf1AAAAAAAAAAAw"
  365. result = default
  366. example member_error
  367. file = "id:3kmLmQFnf1AAAAAAAAAAAw"
  368. result = file_error
  369. struct ListFileMembersCountResult
  370. members SharedFileMembers
  371. "A list of members on this file."
  372. member_count UInt32
  373. "The number of members on this file. This does not include inherited members."
  374. example default
  375. members = default
  376. member_count = 3
  377. union ListFileMembersIndividualResult
  378. result ListFileMembersCountResult
  379. "The results of the query for this file if it was successful."
  380. access_error SharingFileAccessError
  381. "The result of the query for this file if it was an error."
  382. example default
  383. result = default
  384. example file_error
  385. access_error = invalid_file
  386. # --
  387. route list_file_members/continue(ListFileMembersContinueArg, SharedFileMembers, ListFileMembersContinueError)
  388. "Once a cursor has been retrieved from :route:`list_file_members` or
  389. :route:`list_file_members/batch`, use this to paginate through all shared
  390. file members."
  391. attrs
  392. owner = "sharing"
  393. allow_app_folder_app = true
  394. struct ListFileMembersContinueArg
  395. "Arguments for :route:`list_file_members/continue`."
  396. cursor String
  397. "The cursor returned by your last call to :route:`list_file_members`,
  398. :route:`list_file_members/continue`, or :route:`list_file_members/batch`."
  399. example default
  400. cursor = "ZtkX9_EHj3x7PMkVuFIhwKYXEpwpLwyxp9vMKomUhllil9q7eWiAu"
  401. union ListFileMembersContinueError
  402. "Error for :route:`list_file_members/continue`."
  403. user_error SharingUserError
  404. access_error SharingFileAccessError
  405. invalid_cursor
  406. ":field:`ListFileMembersContinueArg.cursor` is invalid."
  407. # --
  408. route list_received_files(ListFilesArg, ListFilesResult, SharingUserError)
  409. "Returns a list of all files shared with current user.
  410. Does not include files the user has received via shared folders, and does
  411. not include unclaimed invitations."
  412. attrs
  413. owner = "sharing"
  414. allow_app_folder_app = true
  415. struct ListFilesArg
  416. "Arguments for :route:`list_received_files`."
  417. limit UInt32(min_value=1, max_value=300) = 100
  418. "Number of files to return max per query. Defaults to 100 if no limit
  419. is specified."
  420. actions List(FileAction)?
  421. "A list of `FileAction`s corresponding to `FilePermission`s that should appear in the
  422. response's :field:`SharedFileMetadata.permissions` field describing the actions the
  423. authenticated user can perform on the file."
  424. example default
  425. limit = 100
  426. actions = []
  427. struct ListFilesResult
  428. "Success results for :route:`list_received_files`."
  429. entries List(SharedFileMetadata)
  430. "Information about the files shared with current user."
  431. cursor String?
  432. "Cursor used to obtain additional shared files."
  433. example default
  434. entries = [default]
  435. cursor = "AzJJbGlzdF90eXBdofe9c3RPbGlzdGFyZ3NfYnlfZ2lkMRhcbric7Rdog9cmV2aXNpb24H3Qf6o1fkHxQ"
  436. # --
  437. route list_received_files/continue (ListFilesContinueArg, ListFilesResult, ListFilesContinueError)
  438. "Get more results with a cursor from :route:`list_received_files`."
  439. attrs
  440. owner = "sharing"
  441. allow_app_folder_app = true
  442. struct ListFilesContinueArg
  443. "Arguments for :route:`list_received_files/continue`."
  444. cursor String
  445. "Cursor in :field:`ListFilesResult.cursor`."
  446. example default
  447. cursor = "AzJJbGlzdF90eXBdofe9c3RPbGlzdGFyZ3NfYnlfZ2lkMRhcbric7Rdog9emfGRlc2MCRWxpbWl0BGRId"
  448. union ListFilesContinueError
  449. "Error results for :route:`list_received_files/continue`."
  450. user_error SharingUserError
  451. "User account had a problem."
  452. invalid_cursor
  453. ":field:`ListFilesContinueArg.cursor` is invalid."
  454. # --
  455. route remove_file_member(RemoveFileMemberArg, FileMemberActionIndividualResult, RemoveFileMemberError) deprecated by remove_file_member_2
  456. "Identical to remove_file_member_2 but with less information returned."
  457. attrs
  458. owner = "sharing"
  459. allow_app_folder_app = true
  460. route remove_file_member_2(RemoveFileMemberArg, FileMemberRemoveActionResult, RemoveFileMemberError)
  461. "Removes a specified member from the file."
  462. attrs
  463. owner = "sharing"
  464. allow_app_folder_app = true
  465. struct RemoveFileMemberArg
  466. "Arguments for :route:`remove_file_member_2`."
  467. file PathOrId
  468. "File from which to remove members."
  469. member MemberSelector
  470. "Member to remove from this file. Note that even if an email is
  471. specified, it may result in the removal of a user (not an invitee) if
  472. the user's main account corresponds to that email address."
  473. example default
  474. file = "id:3kmLmQFnf1AAAAAAAAAAAw"
  475. member = default
  476. # --
  477. route relinquish_file_membership(RelinquishFileMembershipArg, Void, RelinquishFileMembershipError)
  478. "The current user relinquishes their membership in the designated file.
  479. Note that the current user may still have inherited access to this file
  480. through the parent folder.
  481. Apps must have full Dropbox access to use this endpoint."
  482. attrs
  483. owner = "sharing"
  484. allow_app_folder_app = true
  485. struct RelinquishFileMembershipArg
  486. file PathOrId
  487. "The path or id for the file."
  488. example default
  489. file = "id:3kmLmQFnf1AAAAAAAAAAAw"
  490. union RelinquishFileMembershipError
  491. access_error SharingFileAccessError
  492. group_access
  493. "The current user has access to the shared file via a group. You can't relinquish
  494. membership to a file shared via groups."
  495. no_permission
  496. "The current user does not have permission to perform this action."
  497. # --
  498. route unshare_file(UnshareFileArg, Void, UnshareFileError)
  499. "Remove all members from this file. Does not remove inherited members."
  500. attrs
  501. owner = "sharing"
  502. api_group = "truelink-alpha"
  503. allow_app_folder_app = true
  504. struct UnshareFileArg
  505. "Arguments for :route:`unshare_file`."
  506. file PathOrId
  507. "The file to unshare."
  508. example default
  509. file = "id:3kmLmQFnf1AAAAAAAAAAAw"
  510. union UnshareFileError
  511. "Error result for :route:`unshare_file`."
  512. user_error SharingUserError
  513. access_error SharingFileAccessError
  514. example default
  515. user_error = email_unverified