shared_links.stone 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548
  1. namespace sharing
  2. import common
  3. import files
  4. import users
  5. alias Id = files.Id
  6. alias Path = files.Path
  7. alias Rev = files.Rev
  8. alias TeamInfo = users.Team
  9. alias ReadPath = files.ReadPath
  10. #
  11. # Link Metadata definitions and route
  12. #
  13. struct GetSharedLinkMetadataArg
  14. url String
  15. "URL of the shared link."
  16. path Path?
  17. "If the shared link is to a folder, this parameter can be used to retrieve the metadata for
  18. a specific file or sub-folder in this folder. A relative path should be used."
  19. link_password String?
  20. "If the shared link has a password, this parameter can be used."
  21. example default
  22. url = "https://www.dropbox.com/s/2sn712vy1ovegw8/Prime_Numbers.txt?dl=0"
  23. path = "/Prime_Numbers.txt"
  24. union_closed RequestedVisibility
  25. "The access permission that can be requested by the caller for the shared link.
  26. Note that the final resolved visibility of the shared link takes into account other aspects,
  27. such as team and shared folder settings.
  28. Check the :type:`ResolvedVisibility` for more info on the possible resolved visibility values
  29. of shared links. "
  30. public
  31. "Anyone who has received the link can access it. No login required."
  32. team_only
  33. "Only members of the same team can
  34. access the link. Login is required."
  35. password
  36. "A link-specific password is required to access the
  37. link. Login is not required."
  38. union ResolvedVisibility extends RequestedVisibility
  39. "The actual access permissions values of shared links after taking into account user
  40. preferences and the team and shared folder settings.
  41. Check the :type:`RequestedVisibility` for more info on the possible visibility values
  42. that can be set by the shared link's owner. "
  43. team_and_password
  44. "Only members of the same team who
  45. have the link-specific password can access the link. Login is required."
  46. shared_folder_only
  47. "Only members of the shared folder containing the linked file
  48. can access the link. Login is required."
  49. union SharedLinkAccessFailureReason
  50. login_required
  51. "User is not logged in."
  52. email_verify_required
  53. "User's email is not verified."
  54. password_required
  55. "The link is password protected."
  56. team_only
  57. "Access is allowed for team members only."
  58. owner_only
  59. "Access is allowed for the shared link's owner only."
  60. struct LinkPermissions
  61. resolved_visibility ResolvedVisibility?
  62. "The current visibility of the link after considering the shared links policies of the
  63. the team (in case the link's owner is part of a team) and the shared folder (in case the
  64. linked file is part of a shared folder). This field is shown only if the caller has access
  65. to this info (the link's owner always has access to this data)."
  66. requested_visibility RequestedVisibility?
  67. "The shared link's requested visibility. This can be overridden by the team and shared
  68. folder policies. The final visibility, after considering these policies, can be found in
  69. :field:`resolved_visibility`. This is shown only if the caller is the link's
  70. owner."
  71. can_revoke Boolean
  72. "Whether the caller can revoke the shared link"
  73. revoke_failure_reason SharedLinkAccessFailureReason?
  74. "The failure reason for revoking the link. This field will only be present if the
  75. :field:`can_revoke` is :val:`false`."
  76. example default
  77. resolved_visibility = public
  78. can_revoke = false
  79. revoke_failure_reason = owner_only
  80. struct TeamMemberInfo
  81. "Information about a team member."
  82. team_info TeamInfo
  83. "Information about the member's team"
  84. display_name String
  85. "The display name of the user."
  86. member_id String?
  87. "ID of user as a member of a team. This field will only be present if the member is in the
  88. same team as current user."
  89. example default
  90. team_info = default
  91. display_name = "Roger Rabbit"
  92. member_id = "dbmid:abcd1234"
  93. struct SharedLinkMetadata
  94. "The metadata of a shared link "
  95. union
  96. file FileLinkMetadata
  97. folder FolderLinkMetadata
  98. url String
  99. "URL of the shared link."
  100. id Id?
  101. "A unique identifier for the linked file."
  102. name String
  103. "The linked file name (including extension).
  104. This never contains a slash."
  105. expires common.DropboxTimestamp?
  106. "Expiration time, if set. By default the link won't expire."
  107. path_lower String?
  108. "The lowercased full path in the user's Dropbox. This always starts with a slash.
  109. This field will only be present only if the linked file is in the authenticated user's
  110. dropbox."
  111. link_permissions LinkPermissions
  112. "The link's access permissions."
  113. team_member_info TeamMemberInfo?
  114. "The team membership information of the link's owner. This field will only be present
  115. if the link's owner is a team member."
  116. content_owner_team_info TeamInfo?
  117. "The team information of the content's owner. This field will only be present if
  118. the content's owner is a team member and the content's owner team is different from the
  119. link's owner team."
  120. example default
  121. file = default
  122. example folder_link_metadata
  123. folder = default
  124. struct FileLinkMetadata extends SharedLinkMetadata
  125. "The metadata of a file shared link "
  126. client_modified common.DropboxTimestamp
  127. "The modification time set by the desktop client
  128. when the file was added to Dropbox. Since this time is not verified
  129. (the Dropbox server stores whatever the desktop client sends up), this
  130. should only be used for display purposes (such as sorting) and not,
  131. for example, to determine if a file has changed or not."
  132. server_modified common.DropboxTimestamp
  133. "The last time the file was modified on Dropbox."
  134. rev Rev
  135. "A unique identifier for the current revision of a file. This field is
  136. the same rev as elsewhere in the API and can be used to detect changes
  137. and avoid conflicts."
  138. size UInt64
  139. "The file size in bytes."
  140. example default
  141. url = "https://www.dropbox.com/s/2sn712vy1ovegw8/Prime_Numbers.txt?dl=0"
  142. id = "id:a4ayc_80_OEAAAAAAAAAXw"
  143. name = "Prime_Numbers.txt"
  144. path_lower = "/homework/math/prime_numbers.txt"
  145. link_permissions = default
  146. team_member_info = default
  147. client_modified = "2015-05-12T15:50:38Z"
  148. server_modified = "2015-05-12T15:50:38Z"
  149. rev = "a1c10ce0dd78"
  150. size = 7212
  151. struct FolderLinkMetadata extends SharedLinkMetadata
  152. "The metadata of a folder shared link "
  153. example default
  154. url = "https://www.dropbox.com/sh/s6fvw6ol7rmqo1x/AAAgWRSbjmYDvPpDB30Sykjfa?dl=0"
  155. id = "id:a4ayc_80_OEAAAAAAAAAXw"
  156. name = "Math"
  157. path_lower = "/homework/math"
  158. team_member_info = default
  159. link_permissions = default
  160. union SharedLinkError
  161. shared_link_not_found
  162. "The shared link wasn't found."
  163. shared_link_access_denied
  164. "The caller is not allowed to access this shared link."
  165. unsupported_link_type
  166. "This type of link is not supported."
  167. route get_shared_link_metadata(GetSharedLinkMetadataArg, SharedLinkMetadata, SharedLinkError)
  168. "Get the shared link's metadata."
  169. attrs
  170. owner = "sharing"
  171. allow_app_folder_app = true
  172. #
  173. # List Shared links definitions and route
  174. #
  175. struct ListSharedLinksArg
  176. path ReadPath?
  177. "See :route:`list_shared_links` description."
  178. cursor String?
  179. "The cursor returned by your last call to :route:`list_shared_links`."
  180. direct_only Boolean?
  181. "See :route:`list_shared_links` description."
  182. example default
  183. "List all links"
  184. cursor = "ZtkX9_EHj3x7PMkVuFIhwKYXEpwpLwyxp9vMKomUhllil9q7eWiAu"
  185. example path
  186. path = "/Homework/Math"
  187. example id
  188. path = "id:a4ayc_80_OEAAAAAAAAAYa"
  189. example rev
  190. path = "rev:a1c10ce0dd78"
  191. example id_no_parent_links
  192. path = "id:a4ayc_80_OEAAAAAAAAAYa"
  193. direct_only = true
  194. struct ListSharedLinksResult
  195. links List(SharedLinkMetadata)
  196. "Shared links applicable to the path argument."
  197. has_more Boolean
  198. "Is true if there are additional shared links that have not been returned
  199. yet. Pass the cursor into :route:`list_shared_links` to retrieve them."
  200. cursor String?
  201. "Pass the cursor into :route:`list_shared_links` to obtain the additional links. Cursor is
  202. returned only if no path is given."
  203. example default
  204. links = [default]
  205. cursor = "ZtkX9_EHj3x7PMkVuFIhwKYXEpwpLwyxp9vMKomUhllil9q7eWiAu"
  206. has_more = true
  207. union ListSharedLinksError
  208. path files.LookupError
  209. reset
  210. "Indicates that the cursor has been invalidated. Call
  211. :route:`list_shared_links` to obtain a new cursor."
  212. route list_shared_links(ListSharedLinksArg, ListSharedLinksResult, ListSharedLinksError)
  213. "List shared links of this user.
  214. If no path is given, returns a list of all shared links for the current user.
  215. If a non-empty path is given, returns a list of all shared links
  216. that allow access to the given path - direct links to the given path and links to parent folders
  217. of the given path. Links to parent folders can be suppressed by setting
  218. direct_only to true."
  219. attrs
  220. owner = "sharing"
  221. allow_app_folder_app = true
  222. #
  223. # Modify shared link settings definitions and route
  224. #
  225. struct SharedLinkSettings
  226. requested_visibility RequestedVisibility?
  227. "The requested access for this shared link."
  228. link_password String?
  229. "If :field:`requested_visibility` is :field:`RequestedVisibility.password` this is needed
  230. to specify the password to access the link. "
  231. expires common.DropboxTimestamp?
  232. "Expiration time of the shared link. By default the link won't expire."
  233. example default
  234. requested_visibility = public
  235. struct ModifySharedLinkSettingsArgs
  236. url String
  237. "URL of the shared link to change its settings"
  238. settings SharedLinkSettings
  239. "Set of settings for the shared link."
  240. remove_expiration Boolean = false
  241. "If set to true, removes the expiration of the shared link."
  242. example default
  243. url = "https://www.dropbox.com/s/2sn712vy1ovegw8/Prime_Numbers.txt?dl=0"
  244. settings = default
  245. union_closed SharedLinkSettingsError
  246. invalid_settings
  247. "The given settings are invalid
  248. (for example, all attributes of the :type:`SharedLinkSettings` are empty,
  249. the requested visibility is :field:`RequestedVisibility.password` but the
  250. :field:`SharedLinkSettings.link_password` is missing, :field:`SharedLinkSettings.expires`
  251. is set to the past, etc.)"
  252. not_authorized
  253. "User is not allowed to modify the settings of this link. Note that basic
  254. users can only set :field:`RequestedVisibility.public`
  255. as the :field:`SharedLinkSettings.requested_visibility` and cannot
  256. set :field:`SharedLinkSettings.expires`"
  257. union ModifySharedLinkSettingsError extends SharedLinkError
  258. settings_error SharedLinkSettingsError
  259. "There is an error with the given settings"
  260. email_not_verified
  261. "The caller's email should be verified"
  262. route modify_shared_link_settings(ModifySharedLinkSettingsArgs, SharedLinkMetadata, ModifySharedLinkSettingsError)
  263. "Modify the shared link's settings.
  264. If the requested visibility conflict with the shared links policy of the team or the
  265. shared folder (in case the linked file is part of a shared folder) then the
  266. :field:`LinkPermissions.resolved_visibility` of the returned :type:`SharedLinkMetadata` will
  267. reflect the actual visibility of the shared link and the
  268. :field:`LinkPermissions.requested_visibility` will reflect the requested visibility."
  269. attrs
  270. owner = "adminx"
  271. allow_app_folder_app = true
  272. #
  273. # Create shared link with settings definitions and route
  274. #
  275. struct CreateSharedLinkWithSettingsArg
  276. path ReadPath
  277. "The path to be shared by the shared link"
  278. settings SharedLinkSettings?
  279. "The requested settings for the newly created shared link"
  280. example default
  281. path = "/Prime_Numbers.txt"
  282. settings = default
  283. union_closed CreateSharedLinkWithSettingsError
  284. path files.LookupError
  285. email_not_verified
  286. "User's email should be verified"
  287. shared_link_already_exists
  288. "The shared link already exists"
  289. settings_error SharedLinkSettingsError
  290. "There is an error with the given settings"
  291. access_denied
  292. "Access to the requested path is forbidden"
  293. route create_shared_link_with_settings(CreateSharedLinkWithSettingsArg, SharedLinkMetadata, CreateSharedLinkWithSettingsError)
  294. "Create a shared link with custom settings.
  295. If no settings are given then the default visibility is :field:`RequestedVisibility.public`
  296. (The resolved visibility, though, may depend on other aspects such as team and shared folder
  297. settings). "
  298. attrs
  299. owner = "sharing"
  300. allow_app_folder_app = true
  301. #
  302. # Revoke shared link
  303. #
  304. struct RevokeSharedLinkArg
  305. url String
  306. "URL of the shared link."
  307. example default
  308. url = "https://www.dropbox.com/s/2sn712vy1ovegw8/Prime_Numbers.txt?dl=0"
  309. union RevokeSharedLinkError extends SharedLinkError
  310. shared_link_malformed
  311. "Shared link is malformed."
  312. route revoke_shared_link(RevokeSharedLinkArg, Void, RevokeSharedLinkError)
  313. "Revoke a shared link.
  314. Note that even after revoking a shared link to a file, the file may be accessible if there are
  315. shared links leading to any of the file parent folders. To list all shared links that enable
  316. access to a specific file, you can use the :route:`list_shared_links` with the file as the
  317. :field:`ListSharedLinksArg.path` argument. "
  318. attrs
  319. owner = "sharing"
  320. allow_app_folder_app = true
  321. #
  322. # NSLR endpoints
  323. #
  324. union GetSharedLinkFileError extends SharedLinkError
  325. shared_link_is_directory
  326. "Directories cannot be retrieved by this endpoint."
  327. alias GetSharedLinkFileArg = GetSharedLinkMetadataArg
  328. route get_shared_link_file(GetSharedLinkFileArg, SharedLinkMetadata, GetSharedLinkFileError)
  329. "Download the shared link's file from a user's Dropbox."
  330. attrs
  331. host="content"
  332. style="download"
  333. owner = "sharing"
  334. allow_app_folder_app = true
  335. #
  336. # Depracated endpoints
  337. #
  338. union Visibility
  339. "Who can access a shared link.
  340. The most open visibility is :field:`public`.
  341. The default depends on many aspects, such as team and user
  342. preferences and shared folder settings."
  343. public
  344. "Anyone who has received the link can access it. No login required."
  345. team_only
  346. "Only members of the same team can
  347. access the link. Login is required."
  348. password
  349. "A link-specific password is required to access the
  350. link. Login is not required."
  351. team_and_password
  352. "Only members of the same team who
  353. have the link-specific password can access the link."
  354. shared_folder_only
  355. "Only members of the shared folder containing the linked file
  356. can access the link. Login is required."
  357. struct LinkMetadata
  358. "Metadata for a shared link. This can be either a
  359. :type:`PathLinkMetadata` or :type:`CollectionLinkMetadata`."
  360. union
  361. path PathLinkMetadata
  362. collection CollectionLinkMetadata
  363. url String
  364. "URL of the shared link."
  365. visibility Visibility
  366. "Who can access the link."
  367. expires common.DropboxTimestamp?
  368. "Expiration time, if set. By default the link won't expire."
  369. struct PathLinkMetadata extends LinkMetadata
  370. "Metadata for a path-based shared link."
  371. path String
  372. "Path in user's Dropbox."
  373. example default
  374. url = "https://www.dropbox.com/s/2sn712vy1ovegw8/Prime_Numbers.txt?dl=0"
  375. path = "/Homework/Math/Prime_Numbers.txt"
  376. expires = null
  377. visibility = public
  378. struct CollectionLinkMetadata extends LinkMetadata
  379. "Metadata for a collection-based shared link."
  380. example default
  381. url = "https://www.dropbox.com/sh/s6fvw6ol7rmqo1x/AAAgWRSbjmYDvPpDB30Sykjfa?dl=0"
  382. expires = null
  383. visibility = public
  384. struct GetSharedLinksArg
  385. path String?
  386. "See :route:`get_shared_links` description."
  387. example default
  388. "Get all links, including collection links"
  389. path = ""
  390. example math_homework_links
  391. "Get links giving access to /Homework/Math"
  392. path = "/Homework/Math"
  393. struct GetSharedLinksResult
  394. links List(LinkMetadata)
  395. "Shared links applicable to the path argument."
  396. union GetSharedLinksError
  397. path files.MalformedPathError
  398. route get_shared_links(GetSharedLinksArg, GetSharedLinksResult, GetSharedLinksError) deprecated by list_shared_links
  399. "Returns a list of :type:`LinkMetadata` objects for this user,
  400. including collection links.
  401. If no path is given, returns a list of all shared links for the current
  402. user, including collection links.
  403. If a non-empty path is given, returns a list of all shared links
  404. that allow access to the given path. Collection links are never
  405. returned in this case.
  406. Note that the url field in the response is never the shortened URL."
  407. attrs
  408. owner = "sharing"
  409. allow_app_folder_app = true
  410. union_closed PendingUploadMode
  411. "Flag to indicate pending upload default (for linking to not-yet-existing paths)."
  412. file
  413. "Assume pending uploads are files."
  414. folder
  415. "Assume pending uploads are folders."
  416. struct CreateSharedLinkArg
  417. path String
  418. "The path to share."
  419. short_url Boolean = false
  420. "Whether to return a shortened URL."
  421. pending_upload PendingUploadMode?
  422. "If it's okay to share a path that does not yet exist, set this to
  423. either :field:`PendingUploadMode.file` or :field:`PendingUploadMode.folder`
  424. to indicate whether to assume it's a file or folder."
  425. example default
  426. path = "/Homework/Math/Prime_Numbers.txt"
  427. union CreateSharedLinkError
  428. path files.LookupError
  429. route create_shared_link(CreateSharedLinkArg, PathLinkMetadata, CreateSharedLinkError) deprecated by create_shared_link_with_settings
  430. "Create a shared link.
  431. If a shared link already exists for the given path, that link is returned.
  432. Note that in the returned :type:`PathLinkMetadata`, the
  433. :field:`PathLinkMetadata.url` field is the shortened URL if
  434. :field:`CreateSharedLinkArg.short_url` argument is set to :val:`true`.
  435. Previously, it was technically possible to break a shared link by moving or
  436. renaming the corresponding file or folder. In the future, this will no
  437. longer be the case, so your app shouldn't rely on this behavior. Instead, if
  438. your app needs to revoke a shared link, use :route:`revoke_shared_link`."
  439. attrs
  440. owner = "sharing"
  441. allow_app_folder_app = true