From 9ef12351d515c2a3ade7ded7b3c3b9197c936a92 Mon Sep 17 00:00:00 2001 From: carycheng Date: Sun, 28 Oct 2018 13:35:01 -0700 Subject: [PATCH 01/14] web link docs complete --- docs/web_link.md | 39 ++++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/docs/web_link.md b/docs/web_link.md index eac7ac9ed..a1fb17128 100644 --- a/docs/web_link.md +++ b/docs/web_link.md @@ -19,42 +19,51 @@ similarly to file objects. Create Web Link --------------- -Calling `folder.create_web_link(target_url, name=None, description=None)` will let you create a new web link with a specified name and description. +To create a web link object, first call `[client.folder(folder_id)]`[folder] to construct the appropriate ['Folder'][folder_class] object, and then calling [`folder.create_web_link(target_url, name=None, description=None)`][create] will let you create a new web link with a specified name and description. This method return an updated [`WebLink`][web_link_class] object populated with data from the API, leaving the original object unmodified. ```python -folder_id = '1234' -target_url = 'https://example.com' -link_name = 'Example Link' -link_description = 'This is the description' -web_link = client.folder(folder_id).create_web_link(target_url, link_name, link_description) +web_link = client.folder('12345').create_web_link('https://example.com', 'Example Link', 'This is the description') +print('WebLink url is {0} and its description is {1}'.format(web_link.url, web_link.description)) ``` +[folder]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.client.html#boxsdk.client.client.Client.Folder +[folder_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.folder.Folder +[create]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.folder.Folder.create_web_link +[web_link_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.web_link.WebLink + Get Web Link ------------ -Calling `web_link.get()` can be used to retrieve information regarding a specific weblink. +To get a web link object, first call [`client.web_link(web_link_id)`][web_link] to construct the appropriate [`WebLink`][web_link_class] object, and then calling [`web_link.get(fields=None)`][get] will return the [`WebLink`][web_link_class] object populated with data from the API, leaving the original object unmodified. ```python -web_link_id = '1234' -web_link = client.web_link(web_link_id).get() +web_link = client.web_link('12345').get() +print('WebLink id is {0} and its type is {1}'.format(web_link.id, web_link.type)) ``` +[web_link]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.client.html#boxsdk.client.client.Client.WebLink +[web_link_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.folder.Folder +[get]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.base_object.BaseObject.get + Update Web Link --------------- -Calling `web_link.update_info()` can be used to update the weblink. +To update a web link object, first call [`client.web_link(web_link_id)`][web_link] to construct the appropriate [`WebLink`][web_link_class] object, and then calling [`web_link.update_info(data)`][update_info] with a `dict` of peroperties to update on the web link. This method returns a new updated ['WebLink'][web_link_class] object, leaving the original object unmodified. ```python -web_link_update = {'url': 'https://newurl.com'} -updated_web_link = client.web_link.update_info(web_link_update) +updated_web_link = client.web_link('12345').update_info({'url': 'https://newurl.com'}) ``` +[web_link]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.client.html#boxsdk.client.client.Client.WebLink +[update_info]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.base_object.BaseObject.update_info +[web_link_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.folder.Folder + Delete Web Link --------------- -Calling `web_link.delete()` can be used to delete a specified weblink. +To delete a web link, call [`web_link.delete()`][delete] This method return `True` to indicate that th deletion was successful. ```python -web_link_id = '1234' -client.web_link(web_link_id).delete() +client.web_link('12345').delete() +print('The web link was deleted!') ``` From 4da41c5263c685a52fcd68a4b013dbc8134cafc1 Mon Sep 17 00:00:00 2001 From: carycheng Date: Sun, 28 Oct 2018 13:36:05 -0700 Subject: [PATCH 02/14] added delete link --- docs/web_link.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/web_link.md b/docs/web_link.md index a1fb17128..cc1db762f 100644 --- a/docs/web_link.md +++ b/docs/web_link.md @@ -67,3 +67,5 @@ To delete a web link, call [`web_link.delete()`][delete] This method return `Tru client.web_link('12345').delete() print('The web link was deleted!') ``` + +[delete]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.base_object.BaseObject.delete From e9210e383b1e2641b75b15c1b1242c1ed6f63417 Mon Sep 17 00:00:00 2001 From: carycheng Date: Sun, 28 Oct 2018 14:18:48 -0700 Subject: [PATCH 03/14] finished documenting webhooks endpoint --- docs/web_link.md | 10 +++++----- docs/webhook.md | 44 ++++++++++++++++++++++++++++++++------------ 2 files changed, 37 insertions(+), 17 deletions(-) diff --git a/docs/web_link.md b/docs/web_link.md index cc1db762f..fa481765b 100644 --- a/docs/web_link.md +++ b/docs/web_link.md @@ -26,7 +26,7 @@ web_link = client.folder('12345').create_web_link('https://example.com', 'Exampl print('WebLink url is {0} and its description is {1}'.format(web_link.url, web_link.description)) ``` -[folder]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.client.html#boxsdk.client.client.Client.Folder +[folder]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.client.html#boxsdk.client.client.Client.folder [folder_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.folder.Folder [create]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.folder.Folder.create_web_link [web_link_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.web_link.WebLink @@ -41,8 +41,8 @@ web_link = client.web_link('12345').get() print('WebLink id is {0} and its type is {1}'.format(web_link.id, web_link.type)) ``` -[web_link]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.client.html#boxsdk.client.client.Client.WebLink -[web_link_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.folder.Folder +[web_link]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.client.html#boxsdk.client.client.Client.web_link +[web_link_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.web_link.WebLink [get]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.base_object.BaseObject.get Update Web Link @@ -54,9 +54,9 @@ To update a web link object, first call [`client.web_link(web_link_id)`][web_lin updated_web_link = client.web_link('12345').update_info({'url': 'https://newurl.com'}) ``` -[web_link]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.client.html#boxsdk.client.client.Client.WebLink +[web_link]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.client.html#boxsdk.client.client.Client.web_link [update_info]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.base_object.BaseObject.update_info -[web_link_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.folder.Folder +[web_link_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.web_link.WebLink Delete Web Link --------------- diff --git a/docs/webhook.md b/docs/webhook.md index 7463bcef2..5ab15adfb 100644 --- a/docs/webhook.md +++ b/docs/webhook.md @@ -18,53 +18,73 @@ Webhooks enable you to attach event triggers to Box files and folders. Event tri Get Information about Webhook ----------------------------- -To retrieve information about a webhook, use `webhook.get(fields=None)` +To get a webhook object, first call [`client.webhook(webhook_id)`][webhook] to construct the appropriate [`Webhook`][webhook_class] object, and then calling [`webhook.get(fields=None)`][get] will return the [`Webhook`][webhook_class] object populated with data from the API, leaving the original object unmodified. ```python -webhook_info = client.webhook('1234').get() +webhook = client.webhook('12345').get() +print('Webhooks id is {0} and the address is {1}'.format(webhook.id, webhook.address)) ``` +[webhook]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.client.html#boxsdk.client.client.Client.webhook +[webhook_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.webhook.Webhook +[get]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.base_object.BaseObject.get + List all Webhooks ----------------- -To retrieve an iterable of all webhooks in the enterprise, use `client.get_webhooks(limit=None, marker=None, fields=None)` +To retrieve all webhooks for an enterprise, call [`client.get_webhooks(limit=None, marker=None, fields=None)`][get_webhooks]. This method returns a `BoxObjectCollection` that allows you to iterate over the [`Webhook`][webhook_class] objects in the collection. ```python webhooks = client.get_webhooks() for webhook in webhooks: - # Do something + print('The webhook id is {0} and the address is {1}'.format(webhook.id, webhook.address)) ``` +[get_webhooks]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.client.html#boxsdk.client.client.Client.get_webhooks +[webhook_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.webhook.Webhook + Create Webhook -------------- -To create a webhook on a specified target, use `client.create_webhook(target, triggers, address)` +To create a webhook object, call [`client.create_webhook(target_url, name=None, description=None)`][create] will let you create a new webhook object with the specified target url, name, and description. This method will return an updated [`Webhook`][webhook_class] object populated with data from the API, leaving the original object unmodified. -You can create a webhook on either a `file` or a `folder`. For a full list of triggers, see [here](https://developer.box.com/v2.0/reference#webhooks-v2) +You can create a webhook on either a `file` or a `folder`. For a full list of triggers, see [`here`](https://developer.box.com/v2.0/reference#webhooks-v2) ```python -folder = client.folder('1111') -created_webhook = client.create_webhook(folder, ['FILE.UPLOADED', 'FILE.PREVIEWED'], 'https://example.com') +folder = client.folder('12345') +webhook = client.create_webhook(folder, ['FILE.UPLOADED', 'FILE.PREVIEWED'], 'https://example.com') +print('Webhook id is {0} and the address is {1}'.format(webhook.id, webhook.address)) ``` +[create]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.client.html#boxsdk.client.client.Client.create_webhook +[webhook_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.webhook.Webhook + Delete Webhook -------------- -To delete a webhook, use `webhook.delete()` +To delete a webhook, call [`webhook.delete()`][delete]. This method returns `True` to indicate that the deletion was successful. ```python -client.webhook('1234').delete() +client.webhook('12345').delete() ``` +[delete]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.base_object.BaseObject.delete + + Update Webhook -------------- -To update a webhook, use `webhook.update_info(data)` +To update a webhook object, first call [`client.webhook(webhook_id)`][webhook] to construct the appropriate [`Webhook`][webhook_class] object, and then calling [`webhook.update_info(data)`][update_info] with a `dict` of properties to update on the webhook. This method returns a new updated [`Webhook`][webhook_class] object, leaving the original object unmodified. ```python update_object = { triggers: ['FILE.COPIED'], address: 'https://newexample.com', } -updated_webhook = client.webhook('1234').update_info(update_object) +webhook = client.webhook('12345').update_info(update_object) +print('Updated the webhook info for triggers: {0} and address: {1}'.format(webhook.triggers, webhook.address)) ``` + +[webhook]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.client.html#boxsdk.client.client.Client.create_webhook +[webhook_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.webhook.Webhook + From 0fa84566e553d68cf7914061c941ed87434b6d0b Mon Sep 17 00:00:00 2001 From: carycheng Date: Sun, 28 Oct 2018 15:53:29 -0700 Subject: [PATCH 04/14] added endpoint documentation for watermarking --- docs/watermarking.md | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/docs/watermarking.md b/docs/watermarking.md index dd141ef6a..2432a930a 100644 --- a/docs/watermarking.md +++ b/docs/watermarking.md @@ -17,19 +17,29 @@ The ability to watermark files and folders is represented as a sub-resource on t Get Watermark on File or Folder ------------------------------- -Calling `file.get_watermark()` will return the watermark object containing information about the watermark on the file. Or `folder.get_watermark()` will return the watermark object containing information about the watermark on the folder. +To get a watermark object, first call [`client.file(file_id)`][file]] or [`client.folder(folder_id)`][folder]] to construct the appropriate ['Folder'][folder_class] object, and then calling [`file.get_watermark()`][get] or [`folder.get_watermark()`][get] will return the [`Watermark`][watermark_class] object populated with data from the API, leaving the original object unmodified. ```python -watermark_info = client.file('1234').get_watermark() +watermark = client.file('12345').get_watermark() +print('Watermark created at {0} and modified at {1}'.format(watermark.created_at, watermark.modified_at)) ``` ```python -watermark_info = client.folder('5678').get_watermark() +watermark = client.folder('11111').get_watermark() +print('Watermark created at {0} and modified at {1}'.format(watermark.created_at, watermark.modified_at)) ``` +[file]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.client.html#boxsdk.client.client.Client.file +[file_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.file.File +[folder]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.client.html#boxsdk.client.client.Client.folder +[folder_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.folder.Folder +[get]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.base_object.BaseObject.get +[watermark_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.watermark.Watermark + Apply Watermark on File or Folder --------------------------------- +To assign a watermark on a file or folder, first call To assign a watermark on a file, use `file.apply_watermark()`. To assign a watermark on a folder, use `folder.apply_watermark()`. ```python From 320ff312859124f02f51d329d80e1ec90dfae93b Mon Sep 17 00:00:00 2001 From: carycheng Date: Mon, 29 Oct 2018 11:13:13 -0700 Subject: [PATCH 05/14] added documentation for trash endpoints --- docs/trash.md | 7 +++++-- docs/webhook.md | 8 ++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/docs/trash.md b/docs/trash.md index 41e1d82cb..d03be0c54 100644 --- a/docs/trash.md +++ b/docs/trash.md @@ -19,14 +19,17 @@ the Trash will be purged after 30 days. List Trashed Items ------------------ -To retrieve a list of all trashed items, you can use `client.trash().get__items(limit=None, offset=None, fields=None)` +To retrieve all trashed items for an enterprise, call [`client.trash().get_items(imit=None, offset=None, fields=None)`][get_trashed_items]. This method returns a `BoxObjectCollection` that allows you to iterate over the [`Trash`][trash] objects in the collection. ```python trashed_items = client.trash().get_items() for trashed_item in trashed_items: - # Do something + print('The item id is {0} and the item name is {1}'.format(trashed_item.id, trashed_item.name)) ``` +[get_trashed_item]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.trash.Trash.get_trashed_items +[trash]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.trash.Trash + Get Trashed Items ----------------- diff --git a/docs/webhook.md b/docs/webhook.md index 5ab15adfb..7345dec5d 100644 --- a/docs/webhook.md +++ b/docs/webhook.md @@ -25,7 +25,7 @@ webhook = client.webhook('12345').get() print('Webhooks id is {0} and the address is {1}'.format(webhook.id, webhook.address)) ``` -[webhook]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.client.html#boxsdk.client.client.Client.webhook +[webhook]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.client.html#boxsdk.client.Client.webhook [webhook_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.webhook.Webhook [get]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.base_object.BaseObject.get @@ -40,7 +40,7 @@ for webhook in webhooks: print('The webhook id is {0} and the address is {1}'.format(webhook.id, webhook.address)) ``` -[get_webhooks]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.client.html#boxsdk.client.client.Client.get_webhooks +[get_webhooks]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.client.html#boxsdk.client.Client.get_webhooks [webhook_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.webhook.Webhook Create Webhook @@ -56,7 +56,7 @@ webhook = client.create_webhook(folder, ['FILE.UPLOADED', 'FILE.PREVIEWED'], 'ht print('Webhook id is {0} and the address is {1}'.format(webhook.id, webhook.address)) ``` -[create]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.client.html#boxsdk.client.client.Client.create_webhook +[create]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.client.html#boxsdk.client.Client.create_webhook [webhook_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.webhook.Webhook Delete Webhook @@ -85,6 +85,6 @@ webhook = client.webhook('12345').update_info(update_object) print('Updated the webhook info for triggers: {0} and address: {1}'.format(webhook.triggers, webhook.address)) ``` -[webhook]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.client.html#boxsdk.client.client.Client.create_webhook +[webhook]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.client.html#boxsdk.client.Client.create_webhook [webhook_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.webhook.Webhook From 0cb7d048f15b854aa21bbc777d9c313ca7288038 Mon Sep 17 00:00:00 2001 From: carycheng Date: Mon, 29 Oct 2018 13:15:35 -0700 Subject: [PATCH 06/14] added documentation for trash --- docs/trash.md | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/docs/trash.md b/docs/trash.md index d03be0c54..d7a4d5b3a 100644 --- a/docs/trash.md +++ b/docs/trash.md @@ -33,11 +33,11 @@ for trashed_item in trashed_items: Get Trashed Items ----------------- -To retrieve a file, folder, weblink from the trash, use `client.trash.get_item(item, fields=None)`. +To get a trashed item, first construct a [`Folder`][folder_class], [`File`][file_class], or [`Web Link`][web_link_class]object and then calling [`client.trash().get_item(item, fields)`][get_item] with the constructed object passed in will return the ['Item'][item] object populated with data from the API, leaving the original object unmodified. ```python -file_info_to_retrieve = client.file('11111') -file_from_trash = client.trash().get_item(file_info_to_retrieve) +file_to_retrieve = client.file('11111') +file_from_trash = client.trash().get_item(file_to_retrieve) ``` ```python @@ -50,10 +50,18 @@ web_link = client.web_link('33333') web_link_from_trash = client.trash().get_item(web_link) ``` +[folder_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.folder.Folder +[file_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.file.File +[web_link_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.web_link.WebLink +[item]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.item.Item +[get_item]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.trash.Trash.get_item + + Restore Item from Trash ----------------------- -To retore a trashed item, effectively undeleting it, call `client.trash().restore_item(item, name=None, parent_folder=None, fields=None)`. + +To retore a trashed item, effectively undeleting it, first construct a [`Folder`][folder_class], [`File`][file_class], or [`Web Link`][web_link_class] object and then calling [`client.trash().restore(item, name=None, parent_folder, fields=None)`][restore_item] with the constructed [`Item`][item_class] object will let you restore the specific object from your trash. This method will return a [`Item`][item_class] object populated with data from the API, leaving the original object unmodified. ```python file_to_restore = client.file('11111') @@ -79,10 +87,15 @@ new_parent_folder = client.folder('22222') restored_file = client.trash().restore_item(file_to_restore, new_name, new_parent_folder) ``` +[folder_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.folder.Folder +[file_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.file.File +[web_link_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.web_link.WebLink +[item_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.item.Item +[restore_item]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.trash.Trash.restore_item + Permanently Delete Item ----------------------- - -To delete an item from trash, use `client.trash().permanently_delete_item(item)`. +To delete an [`Item`][item_class] object from trash, call [`client.trash().permanently_delete_item(item)`][delete]. This method returns `True` to indicate that the deletion was successful. ```python file_to_delete = client.file('11111') @@ -98,3 +111,6 @@ client.trash().permanently_delete_item(folder) web_link = client.web_link('33333') client.trash().permanently_delete_item(web_link) ``` + +[item_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.item.Item +[delete]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.trash.Trash.permanently_delete() From 22216f8ae9add7e30c8239070b6bbc4de280b1e8 Mon Sep 17 00:00:00 2001 From: carycheng Date: Mon, 29 Oct 2018 13:21:07 -0700 Subject: [PATCH 07/14] added documentation for task and trash endpoint --- docs/task.md | 3 +-- docs/trash.md | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/docs/task.md b/docs/task.md index 27fb60515..5b9c65314 100644 --- a/docs/task.md +++ b/docs/task.md @@ -1,8 +1,7 @@ Tasks ===== -Task objects represent a user-created task on a file. - +Tasks enable file-centric workflows in Box. User can create tasks on files and assign them to collaborators on Box. Get a Task's Information ------------------------ diff --git a/docs/trash.md b/docs/trash.md index d7a4d5b3a..19f29d660 100644 --- a/docs/trash.md +++ b/docs/trash.md @@ -56,11 +56,9 @@ web_link_from_trash = client.trash().get_item(web_link) [item]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.item.Item [get_item]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.trash.Trash.get_item - Restore Item from Trash ----------------------- - To retore a trashed item, effectively undeleting it, first construct a [`Folder`][folder_class], [`File`][file_class], or [`Web Link`][web_link_class] object and then calling [`client.trash().restore(item, name=None, parent_folder, fields=None)`][restore_item] with the constructed [`Item`][item_class] object will let you restore the specific object from your trash. This method will return a [`Item`][item_class] object populated with data from the API, leaving the original object unmodified. ```python @@ -95,6 +93,7 @@ restored_file = client.trash().restore_item(file_to_restore, new_name, new_paren Permanently Delete Item ----------------------- + To delete an [`Item`][item_class] object from trash, call [`client.trash().permanently_delete_item(item)`][delete]. This method returns `True` to indicate that the deletion was successful. ```python From 804ed042e3f61da14479569040b27156ed4df8bc Mon Sep 17 00:00:00 2001 From: carycheng Date: Mon, 29 Oct 2018 14:16:12 -0700 Subject: [PATCH 08/14] added print statements for trash endpoint --- docs/trash.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/docs/trash.md b/docs/trash.md index 19f29d660..3d17df58c 100644 --- a/docs/trash.md +++ b/docs/trash.md @@ -38,16 +38,19 @@ To get a trashed item, first construct a [`Folder`][folder_class], [`File`][file ```python file_to_retrieve = client.file('11111') file_from_trash = client.trash().get_item(file_to_retrieve) +print('File id is {0} and name is {1}'.format(file_from_trash.id, file_from_trash.name)) ``` ```python folder = client.folder('22222') folder_from_trash = client.trash().get_item(folder) +print('Folder id is {0} and name is {1}'.format(folder_from_trash.id, folder_from_trash.name)) ``` ```python web_link = client.web_link('33333') web_link_from_trash = client.trash().get_item(web_link) +print('Web link id is {0} and name is {1}'.format(web_link_from_trash.id, web_link_from_trash.name)) ``` [folder_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.folder.Folder @@ -64,16 +67,19 @@ To retore a trashed item, effectively undeleting it, first construct a [`Folder` ```python file_to_restore = client.file('11111') restored_file = client.trash().restore_item(file_to_restore) +print('File id is {0} and name is {1}'.format(restored_file.id, restored_file.name)) ``` ```python folder_to_restore = client.folder('22222') restored_folder = client.trash().restore_item(folder_to_restore) +print('Folder id is {0} and name is {1}'.format(restored_folder.id, restored_folder.name)) ``` ```python web_link_to_restore = client.web_link('33333') restored_web_link = client.trash().restore_item(web_link_to_restore) +print('Web link id is {0} and name is {1}'.format(restored_web_link.id, restored_web_link.name)) ``` In order to avoid conflicts, you can set a new name and new parent folder for the item you wish to restore. @@ -83,6 +89,7 @@ file_to_restore = client.file('11111') new_name = 'New File Name' new_parent_folder = client.folder('22222') restored_file = client.trash().restore_item(file_to_restore, new_name, new_parent_folder) +print('New name for file is {0} and new parent folder is {1}'.format(restored_file.name, restored_file.parent.name)) ``` [folder_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.folder.Folder @@ -99,16 +106,19 @@ To delete an [`Item`][item_class] object from trash, call [`client.trash().perma ```python file_to_delete = client.file('11111') client.trash().permanently_delete_item(file_to_delete) +print('The file was deleted from trash!') ``` ```python folder = client.folder('22222') client.trash().permanently_delete_item(folder) +print('The folder was deleted from trash!') ``` ```python web_link = client.web_link('33333') client.trash().permanently_delete_item(web_link) +print('The web link was deleted from trash!') ``` [item_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.item.Item From cb5542e3ee4463223a9c219f7cc7e73e841e3969 Mon Sep 17 00:00:00 2001 From: carycheng Date: Mon, 29 Oct 2018 15:57:11 -0700 Subject: [PATCH 09/14] assignment endpoint documentation in progress --- docs/task.md | 56 +++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 44 insertions(+), 12 deletions(-) diff --git a/docs/task.md b/docs/task.md index 5b9c65314..e8f76acf2 100644 --- a/docs/task.md +++ b/docs/task.md @@ -6,63 +6,95 @@ Tasks enable file-centric workflows in Box. User can create tasks on files and a Get a Task's Information ------------------------ -Calling `task.get(fields=None, headers=None)` will return information about the specified task. +To get a task object, first call [`client.task(task_id)`][task] to construct the appropriate [`Task`][task_class] object, and then calling [`task.get(fields=None)`][get] will return the [`Task`][task_class] object populated with data from the API, leaving the original object unmodified. ```python -task_info = client.task('1234').get() +task = client.task('12345').get() +print('Task id is {0} and the type is {1}'.format(task.id, task.type)) ``` +[task]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.client.Client.task +[task_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.task.Task +[get]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.base_object.BaseObject.get + List Tasks on File ------------------ -To retrieve all tasks for a given file use, `file.get_tasks(fields=None)`. +To retrieve all tasks on a file, call [`client.file(file_id)`][file] to create the appropriate [`File`][file_class] object. Then calling [`file.get_tasks(fields=None)`]['get_tasks'] will return a `BoxObjectCollection` that allows you to iterate over the [`Task`][task_class] objects in the collection. ```python tasks = client.file('1111').get_tasks() for task in tasks: - # Do something + print('Task id is {0} and the type is {1}'.format(task.id, task.type)) ``` +[file]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.client.Client.file +[file_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.file.File +[get_tasks]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.file.File.get_tasks() +[task_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.task.Task + Add Task to File ---------------- -To create a single task for a single user on a single file use, `file.create_task(message=None, due_at=None)` +To create a single task for a single user on a single file, call [`client.file(file_id)`][file] to construct the appropriate [`File`][file_class] object. Calling [`file.create_task(message=None, due_at=None)`][create_task] will return a newly created [`Task`][task_class] object populated with data from the API, leaving the original object unmodified. ```python message = 'Please review this' due_at = "2014-04-03T11:09:43-07:00" task = client.file('11111').create_task(message, due_at) +print('Task message is {0} and it is due at {1}'.format(task.message, task.due_at)) ``` +[file]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.client.Client.task +[file_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.file.File +[create_task]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.file.File.create_Task +[task_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.task.Task + Update Task Info ---------------- -To update the task information use, `task.update_info(data)` +To update a task object, first call [`client.task(task_id)`][task] to construct the appropriate task object, and then calling [`task.update_info(data)`][update_info] with a `dict` of properties to update on the task. This method returns a newly updated [`Task`][task_class] object, leaving the original object unmodified. ```python task_update = {'message': 'New Message', 'due_at': '2014-04-03T11:09:43-10:00',} -updated_task = client.task('1234').update_info(task_update) +updated_task = client.task('12345').update_info(task_update) +print('New task message is {1} and the new due time is {1}'.format{updated_task.message, updated_Task.due_at}) ``` +[task]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.client.Client.task +[update_info]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.base_object.BaseObject.update_info +[task_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.task.Task + Delete a Task ------------- -To delete a task, use `task.delete()` +To delete a task, first call [`client.task(task_id)`][task] to construct the appropriate task object, and then call [`task.delete()`][delete]. This method returns `True` to indicate that the deleteion was successful. ```python -client.client.task('1234').delete() +client.client.task('12345').delete() +print('The task was successfully delete!') ``` +[task]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.client.Client.task +[delete]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.base_object.BaseObject.delete + + Assign a Task -------------- -To assign a task to a user on a file, use `task.assign(assignee)` +To assign a task object, first call [`client.task(task_id)`][task] to construct the appropriate task object, then call [`client.user(user_id)`][user] to construct the appropriate user object you wish to assign the task to. Finally, calling [`task.assign(user)`][assign] will return an [`Assignment`][assignment_class] object, populated with data from the API. ```python -user = client.user('1111') -assignment = client.task('1234').assign(user) +user = client.user('11111') +assignment = client.task('12345').assign(user) +print('Assignment id is {0} and is assigned to user {1}'.format(assignment.id, assignment.assigned_to.name)) ``` +[task]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.client.Client.task +[user]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.client.Client/user +[assign]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.task.Task.assign +[assignment_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.task_assignment.TaskAssignment + Assign a Task with User Login ----------------------------- From ec39399688438c3e9b28c0d191e16184be694057 Mon Sep 17 00:00:00 2001 From: carycheng Date: Tue, 30 Oct 2018 12:42:54 -0700 Subject: [PATCH 10/14] finished documentation for task endpoint --- docs/task.md | 44 +++++++++++++++++++++++++++++++------------- 1 file changed, 31 insertions(+), 13 deletions(-) diff --git a/docs/task.md b/docs/task.md index e8f76acf2..ce0f47ac7 100644 --- a/docs/task.md +++ b/docs/task.md @@ -82,7 +82,7 @@ print('The task was successfully delete!') Assign a Task -------------- -To assign a task object, first call [`client.task(task_id)`][task] to construct the appropriate task object, then call [`client.user(user_id)`][user] to construct the appropriate user object you wish to assign the task to. Finally, calling [`task.assign(user)`][assign] will return an [`Assignment`][assignment_class] object, populated with data from the API. +To assign a task object, first call [`client.task(task_id)`][task] to construct the appropriate task object, then call [`client.user(user_id)`][user] to construct the appropriate user object you wish to assign the task to. Finally, calling [`task.assign(user)`][assign] will return an [`TaskAssignment`][assignment_class] object, populated with data from the API. ```python user = client.user('11111') @@ -98,49 +98,67 @@ print('Assignment id is {0} and is assigned to user {1}'.format(assignment.id, a Assign a Task with User Login ----------------------------- -To assign a task to a user on a file, use `task.assign_with_login(assignee_login)` +To assign a task object with a user login, first call [`client.task(task_id)`][task] to construct the appropriate task object, you can then pass in a `unicode` value representing the login of the user you wish to assign the task to. This method will return a [`Task Assignment`][assignment_class] object, populated with data from the API. ```python -assignment = client.task('1234').assign_with_login('test_user@example.com') +assignment = client.task('12345').assign_with_login('test_user@example.com') +print('Assignment id is {0} and the assignee is {1}'.format(assignment.id, assignment.assigned_to.login)) ``` +[task]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.client.Client.task +[assignment_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.task_assignment.TaskAssignment + List Task Assignments --------------------- -To retrieve all task assignments for a given task use `task.get_assignments(fields=None)` +To retrieve all assignments for an enterprise, first call [`client.task(task_id)`][task] to construct the appropriate task object. Then call ['task.get_assignments(fields=None)'][get_assignments]. This method returns a `BoxObjectCollection` that allows you to iterate over the ['Task Assignment'][assignment_class] objects in the collection. ```python -assignments = client.task('1234').get_assignments() +assignments = client.task('12345').get_assignments() for assignment in assignments: - # Do something + print('Assignment id is {0} and the assignee is {1}'.format(assignment.id, assignment.assigned_to.login)) ``` +[task]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.client.Client.task +[get_assignments]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.task.Task.get_assignments +[assignment_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.task_assignment.TaskAssignment + Get Information about Task Assignment ------------------------------------- -To retrieve information about a task assignment use, `task_assignment.get(fields=None, headers=None)` +To get a task assignment object, first call [`client.task_assignment(assignment_id)`][assignment] to construct the appropriate [`TaskAssignment`][assignment_class] object, and then calling ['task_assignment.get(fields=None)'][get] will return the [`Task Assignment`][task_assignment] object populated with data from the API. ```python -task_assignment_id = '2222' -assignment_info = client.task_assignment(task_assignment_id).get() +assignment= client.task_assignment('12345').get() +print('Assignment id is {0} and assignment type is {1}'.format(assignment.id, assignment.type)) ``` +[assignment]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.client.Client.task_assignment +[assignment_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.task_assignment.TaskAssignment +[get]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.base_object.BaseObject.get + Update Task Assignment ---------------------- -To update information about a task assignment use, `task_assignment.update_info(data)` +To update a task assignment object, first call [`client.task_assignment(assignment_id)`][assignment] to construct the appropriate [`TaskAssignment`][assignment_class] object, and then calling [`assignment.update_info(data)`][update_info] with a `dict` of properties to update on a task assignment. This method returns a newly update [`Task Assignment`][assignment_class] object, leaving the original object unmodified. ```python from boxsdk.object.task_assignment import ResolutionState updated_task = {'resolution_state': ResolutionState.APPROVED} -updated_assignment = client.task_assignment('5678').update_info(updated_task) +updated_assignment = client.task_assignment('12345').update_info(updated_task) +print('Assignment id is {0} and resolution state is {1}'.format(updated_assignment.id, updated_assignment.resolution_state)) ``` +[assignment]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.client.Client.task_assignment +[assignment_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.task_assignment.TaskAssignment +[update_info]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.base_object.BaseObject.update_info + Delete Task Assignment ---------------------- -To delete a task assignment use, `task_assignment.delete()` +To delete a task assignment, call [`task_assignment.delete()`][delete]. This method returns `True` to indicate that the deletion was successful. ```python -client.task_assignment('2222').delete() +client.task_assignment('12345').delete() +print('The task assignment was successfully delete!') ``` From b7c50cfbea21d4893f56fde41e3d4579c388040e Mon Sep 17 00:00:00 2001 From: carycheng Date: Tue, 30 Oct 2018 14:00:08 -0700 Subject: [PATCH 11/14] added documentation for retention policy endpoint --- docs/retention_policy.md | 97 +++++++++++++++++++++++++++------------- 1 file changed, 65 insertions(+), 32 deletions(-) diff --git a/docs/retention_policy.md b/docs/retention_policy.md index 63bf70abd..12cfc8aaa 100644 --- a/docs/retention_policy.md +++ b/docs/retention_policy.md @@ -22,116 +22,149 @@ A retention policy blocks permanent deletion of content for a specified amount o Create Retention Policy ----------------------- -You can call `client.create_retention_policy(policy_name, disposition_action, retention_length, can_owner_extend_retention=None, are_owners_notified=None, custom_notification_recipients=None)` to let you create a new indefinite retention policy. +To create a retention policy object, call [`client.create_retention_policy(policy_name, disposition_action, retention_length, can_owner_extend_retention=None, are_owners_notified=None, custom_notification_recipients=None)`][create_retention_policy]. This will let you create a new indefinite [`Retention Policy`][retention_policy_class] object populated with data from the API. ```python policy_name = 'Test Indefinite Policy Name' disposition_action = 'remove_retention' indefinite_retention_policy = client.create_retention_policy(policy_name, disposition_action, float('inf')) +print('Indefinite Retention Policy id is {0} and the policy name is {1}'.format(indefinite_retention_policy.id, indefinite_retention_policy.policy_name)) ``` -Alternatively, if you want to create a finite retention policy, you can do so by calling `client.create_retention_policy(policy_name, disposition_action, retention_length=5)` +Alternatively, if you want to create a finite retention policy, you can do so by calling [`client.create_retention_policy(policy_name, disposition_action, retention_length=5)`][create_retention_policy] ```python policy_name = 'Test Finite Policy Name' disposition_action = 'remove_retention' retention_length = 5 finite_retention_policy = client.create_retention_policy(policy_name=policy_name, disposition_action=disposition_action, retention_length=retention_length) +print('Finite Retention Policy is {0} and the policy name is {1}'.format(finite_retention_policy.id, finite_retention_policy.policy_name)) ``` +[create_retention_policy]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.client.html#boxsdk.client.Client.create_retention_policy +[retention_policy_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.retention_policy.RetentionPolicy + Get Retention Policy -------------------- -Calling `client.get(fields=None, headers=None)` will return a retention policy object. +To get a retention policy object, first call [`client.retention_policy(policy_id)`][retention_policy] to construct the appropriate [`Retention Policy`][retention_policy_class] object, and then calling [`retention_policy.get(fields=None)`][get] will return the [`Retention Policy`][retention_policy_class] object populated with data from the API. ```python -policy_id = '1234' -retention_policy = client.retention_policy(policy_id).get() +retention_policy = client.retention_policy('12345').get() +print('Retention Policy id is {0} and the name is {1}'.format(retention_policy.id, retention_policy.policy_name)) ``` +[retention_policy]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.client.Client.retention_policy +[retention_policy_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.client.Client.retention_policy +[get]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.base_object.BaseObject.get + Get Retention Policies ---------------------- -Calling `client.get_retention_policies(policy_name=None, policy_type=None, user=None, limit=None, marker=None, fields=None)` will return all retention policies for the enterprise. +To retrieve all retention policies for an enterprise, call [`client.get_retention_policies`][get_retention_policies]. This method returns a `BoxObjectCollection` that allows you to iterate over the [`Retention Policy`][retention_policy_class] objects in the collection. ```python retention_policies = client.get_retention_policies() for policy in retention_policies: - # Do something + print('The policy id is {0} and the name is {1}'.format(policy.id, policy.policy_name)) ``` +[get_retention_policies]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.client.Client.get_retention_policies +[retention_policy_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.retention_policy.RetentionPolicy + Update Retention Policy ----------------------- -Calling `retention_policy.update_info(data, params=None, headers=None, **kwargs)` will return the updated retention policy object. +To update a retention policy object, first call [`client.retention_policy(policy_id)`][retention_policy] to construct the appropriate [`Retention Policy`][retention_policy_class] object, and then calling [`retention_policy.update_info(data)`][update_info] with a `dict` of properties to update on the retention policy. This method returns a newly updates [`Retention Policy`][retention_policy_class] object, leaving the original object unmodified. ```python -policy_id = '1234' policy_update = {'policy_name': 'New Policy Name',} -updated_retention_policy = client.retention_policy(policy_id).update_info(policy_update) +updated_retention_policy = client.retention_policy('12345').update_info(policy_update) +print('Retention Policy id is {0} and the new policy name is {1}'.format(updated_retention_policy.id, updated_retention_policy.policy_name)) ``` +[retention_policy]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.client.Client.retention_policy +[retention_policy_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.client.Client.retention_policy +[update_info]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.base_object.BaseObject.update_info + Assign Retention Policy ----------------------- -To create a new retention policy assignment call `retention_policy.assign(assignee, fields=None)` to assign the policy to a specific enterprise, -folder, or metadata_template If assigining to an enterprise you will not have to provide the ID. +To assign a retention policy, first call [`client.retention_policy(policy_id)`][retention_policy] to construct the appropriate [`Retention Policy`][retention_policy_class] object. Then calling [`client.folder('56781')`][folder] to construct the folder you wish to assign a retention policy to. Finally calling [`retention_policy.assign(folder)`][assign] will create a new [`Retention Policy Assignment`][retention_policy_assignment_class] object populated with data from the API. ```python -policy_id = '1234' folder = client.folder('1111') -retention_policy = client.retention_policy(policy_id) -policy_assignment = retention_policy.assign(folder) +policy_assignment = client.retention_policy('12345').assign(folder) ``` +[folder]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.client.Client.folder +[retention_policy]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.client.Client.retention_policy +[retention_policy_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.retention_policy.RetentionPolicy +[retention_policy_assignment_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.retention_policy_assignment.RetentionPolicyAssignment +[assign]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.retention_policy.RetentionPolicy.assign + Get Retention Policy Assignment ------------------------------- -Calling `retention_policy_assignment.get(fields=None, headers=None)` will return the retention policy assignment object. +To get a retention policy object, first call [`client.retention_policy_assignment(assignment_id)`][retention_policy_assignment] to construct the appropriate [`Retention Policy Assignment`][retention_policy_assignment_class] object, and then calling [`retention_policy_assignment.get(fields=None)`][get] will return the [`Retention Policy Assignment`][retention_policy_assignment_class] object populated with data from the API. ```python -assignment_id = '1234' -assignment = client.retention_policy_assignment(assignment_id).get() +assignment = client.retention_policy_assignment('12345').get() +print('Assignment id is {0} and it is assigned by {1}'.format(assignment.id, assignment.assigned_by.name)) ``` +[retention_policy_assignment]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.client.Client.retention_policy_assignment +[retention_policy_assignment_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.retention_policy_assignment.RetentionPolicyAssignment +[get]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.base_object.BaseObject.get + Get Retention Policy Assignments -------------------------------- -Calling `retention_policy.assigments(assignment_type=None, limit=None, marker=None, fields=None)` will return all retention policy assignments for the enterprise. It is possible to specify maximum number of items per single reponse with -`retention_policy.assignments(limit=10)`. +To retrieve all retention policy assignments for an enterprise, first call [`client.retention_policy(policy_id)`][retention_policy] to construct the appropriate [`Retention Policy`][retention_policy_class] object. Then call [`retention_policy.assignments(assignment_type=None, limit=None, marker=None, fields=None)`][get_assignments] will return a `BoxObjectCollection` that allows you to iterate over the [`Retention Policy Assignment`][retention_policy_assignment_class] objects in the collection. ```python -policy_id = '1234' -assignments = client.retention_policy(policy_id).assignments(limit=10) +assignments = client.retention_policy('12345').assignments(limit=10) for assignment in assignments: - # Do something + print('Assignment id is {0} and it is assigned by {1}'.format(assignment.id, assignment.assigned_by.name)) ``` -Alternatively, you can also specify the `type` of assignment to retrieve with `retention_policy.assignments(assignment_type='folder')`. +Alternatively, you can also specify the `type` of assignment to retrieve with [`retention_policy.assignments(assignment_type='folder')`][get_assignments]. ```python -policy_id = '1234' -assignments = client.retention_policy(policy_id).assignments(assignment_type='folder', limit=10) +assignments = client.retention_policy('12345').assignments(assignment_type='folder', limit=10) for assignment in assignments: - # Do something + print('Assignment id is {0} and it is assigned by {1}'.format(assignment.id, assignment.assigned_by.name)) ``` +[retention_policy]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.client.Client.retention_policy +[retention_policy_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.retention_policy.RetentionPolicy +[retention_policy_assignment_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.retention_policy_assignment.RetentionPolicyAssignment +[get_assignments]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.retention_policy.assignments + Get File Version Retentions --------------------------- -Calling `client.get_file_version_retentions(target_file=None, file_version=None, policy_id=None, disposition_action=None, disposition_before=None, disposition_after=None, limit=None, marker=None, fields=None)` will return an iterable of file version retentions for the enterprise. +To retrieve all file version retentions, call [`client.get_file_version_retentions(target_file=None, file_version=None, policy_id=None, disposition_action=None, disposition_before=None, disposition_after=None, limit=None, marker=None, fields=None)`][get_file_version_retentions]. This method will return a `BoxObjectCollection` that allows you to iterate over the [`File Version Retention`][file_version_retention_class] objects in the collection. ```python retentions = client.get_file_version_retentions() for retention in retentions: - # Do something + print('The file version retention id is {0} and the data time applied at is {1}'.format(retention.id, retention.applied_at)) ``` +[get_file_version_retentions]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.client.Client.get_file_version_retentions +[file_version_rention_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.file_version_retention.FileVersionRetention + + Get Information about a File Version Retention ---------------------------------------------- -Calling `file_version_retention.get(fields=None, headers=None)` will return information about the specific file version retention. +To get a file version retention object, first call [`client.file_version_retention(retention_id)`][file_version_retention] to construct the appropriate [`File Version Retention`][file_version_retention_class] object, and then calling [`file_version_retention.get(fields=None)`][get] will return the [`File Veresion Retention`][file_version_retention] object populated with data from the API. ```python -retention_info = client.file_version_retention('1234').get() -``` \ No newline at end of file +retention_info = client.file_version_retention('12345').get() +``` + +[file_version_retention]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.client.file_version_retention +[file_version_retention_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.file_version_retention.FileVersionRetention +[get]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.base_object.BaseObject.get From 0c29a25688894abe0e44fcac0d5dfc3e6a443849 Mon Sep 17 00:00:00 2001 From: carycheng Date: Tue, 30 Oct 2018 14:00:47 -0700 Subject: [PATCH 12/14] added documentation for retention policy endpoint --- docs/retention_policy.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/retention_policy.md b/docs/retention_policy.md index 12cfc8aaa..c2781b2c9 100644 --- a/docs/retention_policy.md +++ b/docs/retention_policy.md @@ -163,6 +163,7 @@ To get a file version retention object, first call [`client.file_version_retenti ```python retention_info = client.file_version_retention('12345').get() +print('The file version retention id is {0} and the data time applied at is {1}'.format(retention.id, retention.applied_at)) ``` [file_version_retention]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.client.file_version_retention From 9d587ddc7a3907d9ce8e1e473367943d1f0bb0d1 Mon Sep 17 00:00:00 2001 From: carycheng Date: Wed, 31 Oct 2018 14:53:39 -0700 Subject: [PATCH 13/14] finished documentation for endpoints part 1 --- docs/retention_policy.md | 29 ++++++++++++----------- docs/task.md | 51 ++++++++++++++++++++++++++++------------ docs/trash.md | 2 +- docs/watermarking.md | 37 ++++++++++++++++++++++------- docs/web_link.md | 6 ++--- docs/webhook.md | 9 +++---- 6 files changed, 88 insertions(+), 46 deletions(-) diff --git a/docs/retention_policy.md b/docs/retention_policy.md index c2781b2c9..fcad89024 100644 --- a/docs/retention_policy.md +++ b/docs/retention_policy.md @@ -41,7 +41,7 @@ finite_retention_policy = client.create_retention_policy(policy_name=policy_name print('Finite Retention Policy is {0} and the policy name is {1}'.format(finite_retention_policy.id, finite_retention_policy.policy_name)) ``` -[create_retention_policy]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.client.html#boxsdk.client.Client.create_retention_policy +[create_retention_policy]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.client.html#boxsdk.client.client.Client.create_retention_policy [retention_policy_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.retention_policy.RetentionPolicy Get Retention Policy @@ -54,8 +54,8 @@ retention_policy = client.retention_policy('12345').get() print('Retention Policy id is {0} and the name is {1}'.format(retention_policy.id, retention_policy.policy_name)) ``` -[retention_policy]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.client.Client.retention_policy -[retention_policy_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.client.Client.retention_policy +[retention_policy]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.client.client.Client.retention_policy +[retention_policy_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.retention_policy.RetentionPolicy [get]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.base_object.BaseObject.get Get Retention Policies @@ -69,7 +69,7 @@ for policy in retention_policies: print('The policy id is {0} and the name is {1}'.format(policy.id, policy.policy_name)) ``` -[get_retention_policies]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.client.Client.get_retention_policies +[get_retention_policies]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.client.client.Client.get_retention_policies [retention_policy_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.retention_policy.RetentionPolicy Update Retention Policy @@ -83,22 +83,23 @@ updated_retention_policy = client.retention_policy('12345').update_info(policy_u print('Retention Policy id is {0} and the new policy name is {1}'.format(updated_retention_policy.id, updated_retention_policy.policy_name)) ``` -[retention_policy]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.client.Client.retention_policy -[retention_policy_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.client.Client.retention_policy +[retention_policy]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.client.client.Client.retention_policy +[retention_policy_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.retention_policy.RetentionPolicy [update_info]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.base_object.BaseObject.update_info Assign Retention Policy ----------------------- -To assign a retention policy, first call [`client.retention_policy(policy_id)`][retention_policy] to construct the appropriate [`Retention Policy`][retention_policy_class] object. Then calling [`client.folder('56781')`][folder] to construct the folder you wish to assign a retention policy to. Finally calling [`retention_policy.assign(folder)`][assign] will create a new [`Retention Policy Assignment`][retention_policy_assignment_class] object populated with data from the API. +To assign a retention policy, first call [`client.retention_policy(policy_id)`][retention_policy] to construct the appropriate [`Retention Policy`][retention_policy_class] object. Then calling [`client.folder('folder_id')`][folder] to construct the folder you wish to assign a retention policy to. Finally calling [`retention_policy.assign(folder)`][assign] will create a new [`Retention Policy Assignment`][retention_policy_assignment_class] object populated with data from the API. ```python folder = client.folder('1111') -policy_assignment = client.retention_policy('12345').assign(folder) +assignment = client.retention_policy('12345').assign(folder) +print('Assignment id is {0} and it is assigned by {1}'.format(assignment.id, assignment.assigned_by.name)) ``` -[folder]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.client.Client.folder -[retention_policy]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.client.Client.retention_policy +[folder]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.client.client.Client.folder +[retention_policy]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.client.client.Client.retention_policy [retention_policy_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.retention_policy.RetentionPolicy [retention_policy_assignment_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.retention_policy_assignment.RetentionPolicyAssignment [assign]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.retention_policy.RetentionPolicy.assign @@ -113,7 +114,7 @@ assignment = client.retention_policy_assignment('12345').get() print('Assignment id is {0} and it is assigned by {1}'.format(assignment.id, assignment.assigned_by.name)) ``` -[retention_policy_assignment]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.client.Client.retention_policy_assignment +[retention_policy_assignment]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.client.client.Client.retention_policy_assignment [retention_policy_assignment_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.retention_policy_assignment.RetentionPolicyAssignment [get]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.base_object.BaseObject.get @@ -136,7 +137,7 @@ for assignment in assignments: print('Assignment id is {0} and it is assigned by {1}'.format(assignment.id, assignment.assigned_by.name)) ``` -[retention_policy]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.client.Client.retention_policy +[retention_policy]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.client.client.Client.retention_policy [retention_policy_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.retention_policy.RetentionPolicy [retention_policy_assignment_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.retention_policy_assignment.RetentionPolicyAssignment [get_assignments]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.retention_policy.assignments @@ -152,7 +153,7 @@ for retention in retentions: print('The file version retention id is {0} and the data time applied at is {1}'.format(retention.id, retention.applied_at)) ``` -[get_file_version_retentions]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.client.Client.get_file_version_retentions +[get_file_version_retentions]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.client.client,Client.get_file_version_retentions [file_version_rention_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.file_version_retention.FileVersionRetention @@ -166,6 +167,6 @@ retention_info = client.file_version_retention('12345').get() print('The file version retention id is {0} and the data time applied at is {1}'.format(retention.id, retention.applied_at)) ``` -[file_version_retention]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.client.file_version_retention +[file_version_retention]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.client.client.Client.file_version_retention [file_version_retention_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.file_version_retention.FileVersionRetention [get]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.base_object.BaseObject.get diff --git a/docs/task.md b/docs/task.md index ce0f47ac7..cd3976ea6 100644 --- a/docs/task.md +++ b/docs/task.md @@ -3,6 +3,24 @@ Tasks Tasks enable file-centric workflows in Box. User can create tasks on files and assign them to collaborators on Box. + + + + +- [Get a Task's Information](#get-a-tasks-information) +- [List Tasks on File](#list-tasks-on-file) +- [Add Task to File](#add-task-to-file) +- [Update Task Info](#update-task-info) +- [Delete a Task](#delete-a-task) +- [Assign a Task](#assign-a-task) +- [Assign a Task with User Login](#assign-a-task-with-user-login) +- [List Task Assignments](#list-task-assignments) +- [Get Information about Task Assignment](#get-information-about-task-assignment) +- [Update Task Assignment](#update-task-assignment) +- [Delete Task Assignment](#delete-task-assignment) + + + Get a Task's Information ------------------------ @@ -13,7 +31,7 @@ task = client.task('12345').get() print('Task id is {0} and the type is {1}'.format(task.id, task.type)) ``` -[task]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.client.Client.task +[task]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.client.client.Client.task [task_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.task.Task [get]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.base_object.BaseObject.get @@ -28,7 +46,7 @@ for task in tasks: print('Task id is {0} and the type is {1}'.format(task.id, task.type)) ``` -[file]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.client.Client.file +[file]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.client.client.Client.file [file_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.file.File [get_tasks]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.file.File.get_tasks() [task_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.task.Task @@ -36,7 +54,7 @@ for task in tasks: Add Task to File ---------------- -To create a single task for a single user on a single file, call [`client.file(file_id)`][file] to construct the appropriate [`File`][file_class] object. Calling [`file.create_task(message=None, due_at=None)`][create_task] will return a newly created [`Task`][task_class] object populated with data from the API, leaving the original object unmodified. +To create a single task for a single user on a single file, call [`client.file(file_id)`][file] to construct the appropriate [`File`][file_class] object. Calling [`file.create_task(message=None, due_at=None)`][create_task] will return a newly created [`Task`][task_class] object populated with data from the API. ```python message = 'Please review this' @@ -45,7 +63,7 @@ task = client.file('11111').create_task(message, due_at) print('Task message is {0} and it is due at {1}'.format(task.message, task.due_at)) ``` -[file]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.client.Client.task +[file]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.client.client.Client.task [file_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.file.File [create_task]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.file.File.create_Task [task_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.task.Task @@ -61,7 +79,7 @@ updated_task = client.task('12345').update_info(task_update) print('New task message is {1} and the new due time is {1}'.format{updated_task.message, updated_Task.due_at}) ``` -[task]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.client.Client.task +[task]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.client.client.Client.task [update_info]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.base_object.BaseObject.update_info [task_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.task.Task @@ -75,14 +93,14 @@ client.client.task('12345').delete() print('The task was successfully delete!') ``` -[task]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.client.Client.task +[task]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.client.client.Client.task [delete]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.base_object.BaseObject.delete Assign a Task -------------- -To assign a task object, first call [`client.task(task_id)`][task] to construct the appropriate task object, then call [`client.user(user_id)`][user] to construct the appropriate user object you wish to assign the task to. Finally, calling [`task.assign(user)`][assign] will return an [`TaskAssignment`][assignment_class] object, populated with data from the API. +To assign a task object, first call [`client.task(task_id)`][task] to construct the appropriate task object, then call [`client.user(user_id)`][user] to construct the appropriate user object you wish to assign the task to. Finally, calling [`task.assign(user)`][assign] will return an [`Task Assignment`][assignment_class] object, populated with data from the API. ```python user = client.user('11111') @@ -90,22 +108,23 @@ assignment = client.task('12345').assign(user) print('Assignment id is {0} and is assigned to user {1}'.format(assignment.id, assignment.assigned_to.name)) ``` -[task]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.client.Client.task -[user]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.client.Client/user +[task]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.client.client.Client.task +[user]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.client.client.Client.user [assign]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.task.Task.assign [assignment_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.task_assignment.TaskAssignment Assign a Task with User Login ----------------------------- -To assign a task object with a user login, first call [`client.task(task_id)`][task] to construct the appropriate task object, you can then pass in a `unicode` value representing the login of the user you wish to assign the task to. This method will return a [`Task Assignment`][assignment_class] object, populated with data from the API. +To assign a task object with a user login, first call [`client.task(task_id)`][task] to construct the appropriate [`Task`][task_class] object, you can then pass in a `unicode` value representing the login of the user you wish to assign the task to. This method will return a [`Task Assignment`][assignment_class] object, populated with data from the API. ```python assignment = client.task('12345').assign_with_login('test_user@example.com') print('Assignment id is {0} and the assignee is {1}'.format(assignment.id, assignment.assigned_to.login)) ``` -[task]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.client.Client.task +[task]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.client.client.Client.task +[task_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.task.Task [assignment_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.task_assignment.TaskAssignment List Task Assignments @@ -119,21 +138,21 @@ for assignment in assignments: print('Assignment id is {0} and the assignee is {1}'.format(assignment.id, assignment.assigned_to.login)) ``` -[task]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.client.Client.task +[task]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.client.client.Client.task [get_assignments]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.task.Task.get_assignments [assignment_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.task_assignment.TaskAssignment Get Information about Task Assignment ------------------------------------- -To get a task assignment object, first call [`client.task_assignment(assignment_id)`][assignment] to construct the appropriate [`TaskAssignment`][assignment_class] object, and then calling ['task_assignment.get(fields=None)'][get] will return the [`Task Assignment`][task_assignment] object populated with data from the API. +To get a task assignment object, first call [`client.task_assignment(assignment_id)`][assignment] to construct the appropriate [`Task Assignment`][assignment_class] object, and then calling ['task_assignment.get(fields=None)'][get] will return the [`Task Assignment`][task_assignment] object populated with data from the API. ```python assignment= client.task_assignment('12345').get() print('Assignment id is {0} and assignment type is {1}'.format(assignment.id, assignment.type)) ``` -[assignment]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.client.Client.task_assignment +[assignment]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.client.client.Client.task_assignment [assignment_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.task_assignment.TaskAssignment [get]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.base_object.BaseObject.get @@ -149,7 +168,7 @@ updated_assignment = client.task_assignment('12345').update_info(updated_task) print('Assignment id is {0} and resolution state is {1}'.format(updated_assignment.id, updated_assignment.resolution_state)) ``` -[assignment]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.client.Client.task_assignment +[assignment]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.client.client.Client.task_assignment [assignment_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.task_assignment.TaskAssignment [update_info]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.base_object.BaseObject.update_info @@ -162,3 +181,5 @@ To delete a task assignment, call [`task_assignment.delete()`][delete]. This met client.task_assignment('12345').delete() print('The task assignment was successfully delete!') ``` + +[delete]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.base_object.BaseObject.delete diff --git a/docs/trash.md b/docs/trash.md index 3d17df58c..f23969d79 100644 --- a/docs/trash.md +++ b/docs/trash.md @@ -33,7 +33,7 @@ for trashed_item in trashed_items: Get Trashed Items ----------------- -To get a trashed item, first construct a [`Folder`][folder_class], [`File`][file_class], or [`Web Link`][web_link_class]object and then calling [`client.trash().get_item(item, fields)`][get_item] with the constructed object passed in will return the ['Item'][item] object populated with data from the API, leaving the original object unmodified. +To get a trashed item, first construct a [`Folder`][folder_class], [`File`][file_class], or [`Web Link`][web_link_class] object and then calling [`client.trash().get_item(item, fields)`][get_item] with the constructed object passed in. This method will return the ['Item'][item] object populated with data from the API. ```python file_to_retrieve = client.file('11111') diff --git a/docs/watermarking.md b/docs/watermarking.md index 2432a930a..f33a86d7c 100644 --- a/docs/watermarking.md +++ b/docs/watermarking.md @@ -17,7 +17,7 @@ The ability to watermark files and folders is represented as a sub-resource on t Get Watermark on File or Folder ------------------------------- -To get a watermark object, first call [`client.file(file_id)`][file]] or [`client.folder(folder_id)`][folder]] to construct the appropriate ['Folder'][folder_class] object, and then calling [`file.get_watermark()`][get] or [`folder.get_watermark()`][get] will return the [`Watermark`][watermark_class] object populated with data from the API, leaving the original object unmodified. +To get a watermark object, first call [`client.file(file_id)`][file] or [`client.folder(folder_id)`][folder] to construct the appropriate ['Folder'][folder_class] or ['File'][file_class] object, and then calling [`file.get_watermark()`][get_file_watermark] or [`folder.get_watermark()`][get_folder_watermark] will return the [`Watermark`][watermark_class] object populated with data from the API. ```python watermark = client.file('12345').get_watermark() @@ -33,32 +33,51 @@ print('Watermark created at {0} and modified at {1}'.format(watermark.created_at [file_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.file.File [folder]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.client.html#boxsdk.client.client.Client.folder [folder_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.folder.Folder -[get]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.base_object.BaseObject.get +[get_file_watermark]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.client.html#boxsdk.object.file.File.get_watermark() +[get_folder_watermark]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.client.html#boxsdk.object.folder.Folder.get_watermark() [watermark_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.watermark.Watermark Apply Watermark on File or Folder --------------------------------- -To assign a watermark on a file or folder, first call -To assign a watermark on a file, use `file.apply_watermark()`. To assign a watermark on a folder, use `folder.apply_watermark()`. +To assign a watermark on a file or folder, first call [`client.file(file_id)`][file]] or [`client.folder(folder_id)`][folder]] to construct the appropriate ['Folder'][folder_class] or ['File'][file_class] object, and then calling [file.apply_watermark()][apply-file-watermark] or [folder.apply_watermark()][apply-folder-watermark] will return the [`Watermark`][watermark_class] object populated with data from the API. ```python -watermark_info = client.file('1234').apply_watermark() +watermark = client.file('12345').apply_watermark() +print('Watermark created at {0} and modified at {1}'.format(watermark.created_at, watermark.modified_at)) ``` ```python -watermark_info = client.folder('5678').apply_watermark() +watermark = client.folder('11111').apply_watermark() +print('Watermark created at {0} and modified at {1}'.format(watermark.created_at, watermark.modified_at)) ``` +[file]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.client.html#boxsdk.client.client.Client.file +[file_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.file.File +[folder]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.client.html#boxsdk.client.client.Client.folder +[folder_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.folder.Folder +[apply-file-watermark]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.client.html#boxsdk.file.File.apply_watermark() +[apply_folder_watermark]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.client.html#boxsdk.folder.Folder.apply_watermark() +[watermark_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.watermark.Watermark + Remove Watermark on File or Folder ---------------------------------- -To remove watermark on a file, use `file.delete_watermark()`. To remove a watermark on a folder, use `folder.delete_watermark()` +To remove a watermark from a file or folder, first call [`client.file(file_id)`][file]] or [`client.folder(folder_id)`][folder]] to construct the appropriate ['Folder'][folder_class] or ['File'][file_class] object, and then calling [file.delete_watermark()][delete-file-watermark] or [folder.delete_watermark()][delete-folder-watermark] will return `True` to indicate that the deletion was successful. ```python -client.file('1234').delete_watermark() +client.file('12345').delete_watermark() +print('The file watermark was deleted!') ``` ```python -client.folder('5678').delete_watermark() +client.folder('11111').delete_watermark() +print('The folder watermark was deleted!') ``` + +[file]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.client.html#boxsdk.client.client.Client.file +[file_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.file.File +[folder]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.client.html#boxsdk.client.client.Client.folder +[folder_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.folder.Folder +[delete-file-watermark]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.client.html#boxsdk.file.File.delete_watermark() +[delete_folder_watermark]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.client.html#boxsdk.folder.Folder.delete_watermark() diff --git a/docs/web_link.md b/docs/web_link.md index fa481765b..7211b69c0 100644 --- a/docs/web_link.md +++ b/docs/web_link.md @@ -19,7 +19,7 @@ similarly to file objects. Create Web Link --------------- -To create a web link object, first call `[client.folder(folder_id)]`[folder] to construct the appropriate ['Folder'][folder_class] object, and then calling [`folder.create_web_link(target_url, name=None, description=None)`][create] will let you create a new web link with a specified name and description. This method return an updated [`WebLink`][web_link_class] object populated with data from the API, leaving the original object unmodified. +To create a web link object, first call [`client.folder(folder_id)`][folder] to construct the appropriate ['Folder'][folder_class] object, and then calling [`folder.create_web_link(target_url, name=None, description=None)`][create] will let you create a new web link with a specified name and description. This method return an updated [`WebLink`][web_link_class] object populated with data from the API, leaving the original object unmodified. ```python web_link = client.folder('12345').create_web_link('https://example.com', 'Example Link', 'This is the description') @@ -48,7 +48,7 @@ print('WebLink id is {0} and its type is {1}'.format(web_link.id, web_link.type) Update Web Link --------------- -To update a web link object, first call [`client.web_link(web_link_id)`][web_link] to construct the appropriate [`WebLink`][web_link_class] object, and then calling [`web_link.update_info(data)`][update_info] with a `dict` of peroperties to update on the web link. This method returns a new updated ['WebLink'][web_link_class] object, leaving the original object unmodified. +To update a web link object, first call [`client.web_link(web_link_id)`][web_link] to construct the appropriate [`WebLink`][web_link_class] object, and then calling [`web_link.update_info(data)`][update_info] with a `dict` of properties to update on the web link. This method returns a newly updated ['WebLink'][web_link_class] object, leaving the original object unmodified. ```python updated_web_link = client.web_link('12345').update_info({'url': 'https://newurl.com'}) @@ -61,7 +61,7 @@ updated_web_link = client.web_link('12345').update_info({'url': 'https://newurl. Delete Web Link --------------- -To delete a web link, call [`web_link.delete()`][delete] This method return `True` to indicate that th deletion was successful. +To delete a web link, call [`web_link.delete()`][delete]. This method returns `True` to indicate that the deletion was successful. ```python client.web_link('12345').delete() diff --git a/docs/webhook.md b/docs/webhook.md index 7345dec5d..1183b0092 100644 --- a/docs/webhook.md +++ b/docs/webhook.md @@ -18,14 +18,14 @@ Webhooks enable you to attach event triggers to Box files and folders. Event tri Get Information about Webhook ----------------------------- -To get a webhook object, first call [`client.webhook(webhook_id)`][webhook] to construct the appropriate [`Webhook`][webhook_class] object, and then calling [`webhook.get(fields=None)`][get] will return the [`Webhook`][webhook_class] object populated with data from the API, leaving the original object unmodified. +To get a webhook object, first call [`client.webhook(webhook_id)`][webhook] to construct the appropriate [`Webhook`][webhook_class] object, and then calling [`webhook.get(fields=None)`][get] will return the [`Webhook`][webhook_class] object populated with data from the API. ```python webhook = client.webhook('12345').get() print('Webhooks id is {0} and the address is {1}'.format(webhook.id, webhook.address)) ``` -[webhook]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.client.html#boxsdk.client.Client.webhook +[webhook]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.client.html#boxsdk.client.client.Client.webhook [webhook_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.webhook.Webhook [get]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.base_object.BaseObject.get @@ -40,7 +40,7 @@ for webhook in webhooks: print('The webhook id is {0} and the address is {1}'.format(webhook.id, webhook.address)) ``` -[get_webhooks]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.client.html#boxsdk.client.Client.get_webhooks +[get_webhooks]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.client.html#boxsdk.client.client.Client.get_webhooks [webhook_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.webhook.Webhook Create Webhook @@ -66,6 +66,7 @@ To delete a webhook, call [`webhook.delete()`][delete]. This method returns `Tru ```python client.webhook('12345').delete() +print('The webhook was successfully deleted!') ``` [delete]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.base_object.BaseObject.delete @@ -87,4 +88,4 @@ print('Updated the webhook info for triggers: {0} and address: {1}'.format(webho [webhook]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.client.html#boxsdk.client.Client.create_webhook [webhook_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.webhook.Webhook - +[update_info]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.base_object.BaseObject.update_info From 177b0995ba67b99e270353a9acaad0124b1165d6 Mon Sep 17 00:00:00 2001 From: carycheng Date: Wed, 31 Oct 2018 18:20:11 -0700 Subject: [PATCH 14/14] finished documentation for part one --- docs/retention_policy.md | 98 ++++++++++++++++++++++------------------ docs/task.md | 96 +++++++++++++++++++++------------------ docs/trash.md | 58 ++++++++++++------------ docs/watermarking.md | 53 ++++++++++------------ docs/web_link.md | 28 +++++++----- docs/webhook.md | 41 +++++++++++------ 6 files changed, 203 insertions(+), 171 deletions(-) diff --git a/docs/retention_policy.md b/docs/retention_policy.md index fcad89024..e960e7f5b 100644 --- a/docs/retention_policy.md +++ b/docs/retention_policy.md @@ -1,7 +1,8 @@ Retention Policies ================== -A retention policy blocks permanent deletion of content for a specified amount of time. Admins can create retention policies and then later assign them to specific folders or their entire enterprise. +A retention policy blocks permanent deletion of content for a specified amount of time. Admins can create retention +policies and then later assign them to specific folders or their entire enterprise. @@ -22,23 +23,25 @@ A retention policy blocks permanent deletion of content for a specified amount o Create Retention Policy ----------------------- -To create a retention policy object, call [`client.create_retention_policy(policy_name, disposition_action, retention_length, can_owner_extend_retention=None, are_owners_notified=None, custom_notification_recipients=None)`][create_retention_policy]. This will let you create a new indefinite [`Retention Policy`][retention_policy_class] object populated with data from the API. +To create a retention policy object, call [`client.create_retention_policy(policy_name, disposition_action, retention_length, can_owner_extend_retention=None, are_owners_notified=None, custom_notification_recipients=None)`][create_retention_policy]. This will let you create a new indefinite +[`RetentionPolicy`][retention_policy_class] object populated with data from the API. ```python policy_name = 'Test Indefinite Policy Name' disposition_action = 'remove_retention' indefinite_retention_policy = client.create_retention_policy(policy_name, disposition_action, float('inf')) -print('Indefinite Retention Policy id is {0} and the policy name is {1}'.format(indefinite_retention_policy.id, indefinite_retention_policy.policy_name)) +print('Indefinite Retention Policy ID is {0} and the policy name is {1}'.format(indefinite_retention_policy.id, indefinite_retention_policy.policy_name)) ``` -Alternatively, if you want to create a finite retention policy, you can do so by calling [`client.create_retention_policy(policy_name, disposition_action, retention_length=5)`][create_retention_policy] +Alternatively, if you want to create a finite retention policy, you can do so by calling +[`client.create_retention_policy(policy_name, disposition_action, retention_length=5)`][create_retention_policy] ```python policy_name = 'Test Finite Policy Name' disposition_action = 'remove_retention' retention_length = 5 finite_retention_policy = client.create_retention_policy(policy_name=policy_name, disposition_action=disposition_action, retention_length=retention_length) -print('Finite Retention Policy is {0} and the policy name is {1}'.format(finite_retention_policy.id, finite_retention_policy.policy_name)) +print('Finite Retention Policy ID is {0} and the policy name is {1}'.format(finite_retention_policy.id, finite_retention_policy.policy_name)) ``` [create_retention_policy]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.client.html#boxsdk.client.client.Client.create_retention_policy @@ -47,67 +50,70 @@ print('Finite Retention Policy is {0} and the policy name is {1}'.format(finite_ Get Retention Policy -------------------- -To get a retention policy object, first call [`client.retention_policy(policy_id)`][retention_policy] to construct the appropriate [`Retention Policy`][retention_policy_class] object, and then calling [`retention_policy.get(fields=None)`][get] will return the [`Retention Policy`][retention_policy_class] object populated with data from the API. +To get a retention policy object, first call [`client.retention_policy(policy_id)`][retention_policy] to construct the +appropriate [`RetentionPolicy`][retention_policy_class] object, and then calling [`retention_policy.get(fields=None)`][get] +will return the [`RetentionPolicy`][retention_policy_class] object populated with data from the API. ```python -retention_policy = client.retention_policy('12345').get() -print('Retention Policy id is {0} and the name is {1}'.format(retention_policy.id, retention_policy.policy_name)) +retention_policy = client.retention_policy(policy_id='12345').get() +print('Retention Policy ID is {0} and the name is {1}'.format(retention_policy.id, retention_policy.policy_name)) ``` -[retention_policy]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.client.client.Client.retention_policy -[retention_policy_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.retention_policy.RetentionPolicy +[retention_policy]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.client.html#boxsdk.client.client.Client.retention_policy [get]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.base_object.BaseObject.get Get Retention Policies ---------------------- -To retrieve all retention policies for an enterprise, call [`client.get_retention_policies`][get_retention_policies]. This method returns a `BoxObjectCollection` that allows you to iterate over the [`Retention Policy`][retention_policy_class] objects in the collection. +To retrieve all retention policies for an enterprise, call [`client.get_retention_policies`][get_retention_policies]. +This method returns a `BoxObjectCollection` that allows you to iterate over the +[`Retention Policy`][retention_policy_class] objects in the collection. ```python retention_policies = client.get_retention_policies() for policy in retention_policies: - print('The policy id is {0} and the name is {1}'.format(policy.id, policy.policy_name)) + print('The policy ID is {0} and the name is {1}'.format(policy.id, policy.policy_name)) ``` -[get_retention_policies]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.client.client.Client.get_retention_policies -[retention_policy_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.retention_policy.RetentionPolicy +[get_retention_policies]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.client.html#boxsdk.client.client.Client.get_retention_policies Update Retention Policy ----------------------- -To update a retention policy object, first call [`client.retention_policy(policy_id)`][retention_policy] to construct the appropriate [`Retention Policy`][retention_policy_class] object, and then calling [`retention_policy.update_info(data)`][update_info] with a `dict` of properties to update on the retention policy. This method returns a newly updates [`Retention Policy`][retention_policy_class] object, leaving the original object unmodified. +To update a retention policy object, calling [`retention_policy.update_info(data)`][update_info] with a `dict` of +properties to update on the retention policy. This method returns a newly updates +[`RetentionPolicy`][retention_policy_class] object, leaving the original object unmodified. ```python policy_update = {'policy_name': 'New Policy Name',} -updated_retention_policy = client.retention_policy('12345').update_info(policy_update) -print('Retention Policy id is {0} and the new policy name is {1}'.format(updated_retention_policy.id, updated_retention_policy.policy_name)) +updated_retention_policy = client.retention_policy(policy_id='12345').update_info(policy_update) +print('Retention Policy ID is {0} and the new policy name is {1}'.format(updated_retention_policy.id, updated_retention_policy.policy_name)) ``` -[retention_policy]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.client.client.Client.retention_policy -[retention_policy_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.retention_policy.RetentionPolicy [update_info]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.base_object.BaseObject.update_info Assign Retention Policy ----------------------- -To assign a retention policy, first call [`client.retention_policy(policy_id)`][retention_policy] to construct the appropriate [`Retention Policy`][retention_policy_class] object. Then calling [`client.folder('folder_id')`][folder] to construct the folder you wish to assign a retention policy to. Finally calling [`retention_policy.assign(folder)`][assign] will create a new [`Retention Policy Assignment`][retention_policy_assignment_class] object populated with data from the API. +To assign a retention policy, call [`retention_policy.assign(folder)`][assign] will create a new +[`RetentionPolicyAssignment`][retention_policy_assignment_class] object populated with data from the API. ```python -folder = client.folder('1111') -assignment = client.retention_policy('12345').assign(folder) -print('Assignment id is {0} and it is assigned by {1}'.format(assignment.id, assignment.assigned_by.name)) +folder = client.folder(folder_id='1111') +assignment = client.retention_policy(policy_id='12345').assign(folder) +print('Assignment ID is {0} and it is assigned by {1}'.format(assignment.id, assignment.assigned_by.name)) ``` -[folder]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.client.client.Client.folder -[retention_policy]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.client.client.Client.retention_policy -[retention_policy_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.retention_policy.RetentionPolicy [retention_policy_assignment_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.retention_policy_assignment.RetentionPolicyAssignment [assign]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.retention_policy.RetentionPolicy.assign Get Retention Policy Assignment ------------------------------- -To get a retention policy object, first call [`client.retention_policy_assignment(assignment_id)`][retention_policy_assignment] to construct the appropriate [`Retention Policy Assignment`][retention_policy_assignment_class] object, and then calling [`retention_policy_assignment.get(fields=None)`][get] will return the [`Retention Policy Assignment`][retention_policy_assignment_class] object populated with data from the API. +To get a retention policy object, first call [`client.retention_policy_assignment(assignment_id)`][retention_policy_assignment] +to construct the appropriate [`Retention Policy Assignment`][retention_policy_assignment_class] object, and then calling +[`retention_policy_assignment.get(fields=None)`][get] will return the +[`Retention Policy Assignment`][retention_policy_assignment_class] object populated with data from the API. ```python assignment = client.retention_policy_assignment('12345').get() @@ -121,52 +127,58 @@ print('Assignment id is {0} and it is assigned by {1}'.format(assignment.id, ass Get Retention Policy Assignments -------------------------------- -To retrieve all retention policy assignments for an enterprise, first call [`client.retention_policy(policy_id)`][retention_policy] to construct the appropriate [`Retention Policy`][retention_policy_class] object. Then call [`retention_policy.assignments(assignment_type=None, limit=None, marker=None, fields=None)`][get_assignments] will return a `BoxObjectCollection` that allows you to iterate over the [`Retention Policy Assignment`][retention_policy_assignment_class] objects in the collection. +To retrieve all retention policy assignments for an enterprise, call +[`retention_policy.assignments(assignment_type=None, limit=None, marker=None, fields=None)`][get_assignments] +will return a `BoxObjectCollection` that allows you to iterate over the +[`RetentionPolicyAssignment`][retention_policy_assignment_class] objects in the collection. ```python -assignments = client.retention_policy('12345').assignments(limit=10) +assignments = client.retention_policy(policy_id='12345').assignments(limit=10) for assignment in assignments: - print('Assignment id is {0} and it is assigned by {1}'.format(assignment.id, assignment.assigned_by.name)) + print('Assignment ID is {0} and it is assigned by {1}'.format(assignment.id, assignment.assigned_by.name)) ``` -Alternatively, you can also specify the `type` of assignment to retrieve with [`retention_policy.assignments(assignment_type='folder')`][get_assignments]. +Alternatively, you can also specify the `type` of assignment to retrieve with +[`retention_policy.assignments(assignment_type='folder')`][get_assignments]. ```python -assignments = client.retention_policy('12345').assignments(assignment_type='folder', limit=10) +assignments = client.retention_policy(policy_id='12345').assignments(assignment_type='folder', limit=10) for assignment in assignments: - print('Assignment id is {0} and it is assigned by {1}'.format(assignment.id, assignment.assigned_by.name)) + print('Assignment ID is {0} and it is assigned by {1}'.format(assignment.id, assignment.assigned_by.name)) ``` -[retention_policy]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.client.client.Client.retention_policy -[retention_policy_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.retention_policy.RetentionPolicy -[retention_policy_assignment_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.retention_policy_assignment.RetentionPolicyAssignment [get_assignments]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.retention_policy.assignments Get File Version Retentions --------------------------- -To retrieve all file version retentions, call [`client.get_file_version_retentions(target_file=None, file_version=None, policy_id=None, disposition_action=None, disposition_before=None, disposition_after=None, limit=None, marker=None, fields=None)`][get_file_version_retentions]. This method will return a `BoxObjectCollection` that allows you to iterate over the [`File Version Retention`][file_version_retention_class] objects in the collection. +To retrieve all file version retentions, call [`client.get_file_version_retentions(target_file=None, file_version=None, policy_id=None, disposition_action=None, disposition_before=None, disposition_after=None, limit=None, marker=None, fields=None)`][get_file_version_retentions]. This method will return a +`BoxObjectCollection` that allows you to iterate over the [`FileVersionRetention`][file_version_retention_class] +objects in the collection. ```python retentions = client.get_file_version_retentions() for retention in retentions: - print('The file version retention id is {0} and the data time applied at is {1}'.format(retention.id, retention.applied_at)) + print('The file version retention ID is {0} and the data time applied at is {1}'.format(retention.id, retention.applied_at)) ``` -[get_file_version_retentions]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.client.client,Client.get_file_version_retentions +[get_file_version_retentions]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.client.html#boxsdk.client.client,Client.get_file_version_retentions [file_version_rention_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.file_version_retention.FileVersionRetention Get Information about a File Version Retention ---------------------------------------------- -To get a file version retention object, first call [`client.file_version_retention(retention_id)`][file_version_retention] to construct the appropriate [`File Version Retention`][file_version_retention_class] object, and then calling [`file_version_retention.get(fields=None)`][get] will return the [`File Veresion Retention`][file_version_retention] object populated with data from the API. +To get a file version retention object, first call [`client.file_version_retention(retention_id)`][file_version_retention] +to construct the appropriate [`File Version Retention`][file_version_retention_class] object, and then calling +[`file_version_retention.get(fields=None)`][get] will return the [`FileVersionRetention`][file_version_retention] +object populated with data from the API. ```python -retention_info = client.file_version_retention('12345').get() -print('The file version retention id is {0} and the data time applied at is {1}'.format(retention.id, retention.applied_at)) +retention_info = client.file_version_retention(retention_id='12345').get() +print('The file version retention ID is {0} and the data time applied at is {1}'.format(retention.id, retention.applied_at)) ``` -[file_version_retention]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.client.client.Client.file_version_retention +[file_version_retention]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.client.html#boxsdk.client.client.Client.file_version_retention [file_version_retention_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.file_version_retention.FileVersionRetention [get]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.base_object.BaseObject.get diff --git a/docs/task.md b/docs/task.md index cd3976ea6..38a985a5c 100644 --- a/docs/task.md +++ b/docs/task.md @@ -24,161 +24,169 @@ Tasks enable file-centric workflows in Box. User can create tasks on files and a Get a Task's Information ------------------------ -To get a task object, first call [`client.task(task_id)`][task] to construct the appropriate [`Task`][task_class] object, and then calling [`task.get(fields=None)`][get] will return the [`Task`][task_class] object populated with data from the API, leaving the original object unmodified. +To get a task object, first call [`client.task(task_id)`][task] to construct the appropriate [`Task`][task_class] +object, and then calling [`task.get(fields=None)`][get] will return the [`Task`][task_class] object populated with data +from the API, leaving the original object unmodified. ```python -task = client.task('12345').get() -print('Task id is {0} and the type is {1}'.format(task.id, task.type)) +task = client.task(task_id='12345').get() +print('Task ID is {0} and the type is {1}'.format(task.id, task.type)) ``` -[task]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.client.client.Client.task +[task]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.client.html#boxsdk.client.client.Client.task [task_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.task.Task [get]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.base_object.BaseObject.get List Tasks on File ------------------ -To retrieve all tasks on a file, call [`client.file(file_id)`][file] to create the appropriate [`File`][file_class] object. Then calling [`file.get_tasks(fields=None)`]['get_tasks'] will return a `BoxObjectCollection` that allows you to iterate over the [`Task`][task_class] objects in the collection. +To retrieve all tasks on a file, call [`file.get_tasks(fields=None)`]['get_tasks'] will return a `BoxObjectCollection` +that allows you to iterate over the [`Task`][task_class] objects in the collection. ```python -tasks = client.file('1111').get_tasks() +tasks = client.file(file_id='11111').get_tasks() for task in tasks: - print('Task id is {0} and the type is {1}'.format(task.id, task.type)) + print('Task ID is {0} and the type is {1}'.format(task.id, task.type)) ``` -[file]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.client.client.Client.file -[file_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.file.File [get_tasks]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.file.File.get_tasks() [task_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.task.Task Add Task to File ---------------- -To create a single task for a single user on a single file, call [`client.file(file_id)`][file] to construct the appropriate [`File`][file_class] object. Calling [`file.create_task(message=None, due_at=None)`][create_task] will return a newly created [`Task`][task_class] object populated with data from the API. +To create a single task for a single user on a single file, call [`file.create_task(message=None, due_at=None)`][create_task] +will return a newly created [`Task`][task_class] object populated with data from the API. ```python message = 'Please review this' due_at = "2014-04-03T11:09:43-07:00" -task = client.file('11111').create_task(message, due_at) +task = client.file(file_id='11111').create_task(message, due_at) print('Task message is {0} and it is due at {1}'.format(task.message, task.due_at)) ``` -[file]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.client.client.Client.task -[file_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.file.File [create_task]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.file.File.create_Task -[task_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.task.Task Update Task Info ---------------- -To update a task object, first call [`client.task(task_id)`][task] to construct the appropriate task object, and then calling [`task.update_info(data)`][update_info] with a `dict` of properties to update on the task. This method returns a newly updated [`Task`][task_class] object, leaving the original object unmodified. +To update a task object, first call [`task.update_info(data)`][update_info] with a `dict` of properties to update on the +task. This method returns a newly updated [`Task`][task_class] object, leaving the original object unmodified. ```python task_update = {'message': 'New Message', 'due_at': '2014-04-03T11:09:43-10:00',} -updated_task = client.task('12345').update_info(task_update) +updated_task = client.task(task_id='12345').update_info(task_update) print('New task message is {1} and the new due time is {1}'.format{updated_task.message, updated_Task.due_at}) ``` -[task]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.client.client.Client.task [update_info]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.base_object.BaseObject.update_info [task_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.task.Task Delete a Task ------------- -To delete a task, first call [`client.task(task_id)`][task] to construct the appropriate task object, and then call [`task.delete()`][delete]. This method returns `True` to indicate that the deleteion was successful. +To delete a task, first call [`client.task(task_id)`][task] to construct the appropriate task object, and then call +[`task.delete()`][delete]. This method returns `True` to indicate that the deleteion was successful. ```python client.client.task('12345').delete() print('The task was successfully delete!') ``` -[task]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.client.client.Client.task +[task]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.client.html#boxsdk.client.client.Client.task [delete]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.base_object.BaseObject.delete Assign a Task -------------- -To assign a task object, first call [`client.task(task_id)`][task] to construct the appropriate task object, then call [`client.user(user_id)`][user] to construct the appropriate user object you wish to assign the task to. Finally, calling [`task.assign(user)`][assign] will return an [`Task Assignment`][assignment_class] object, populated with data from the API. +To assign a task object, first call [`client.task(task_id)`][task] to construct the appropriate task object, then call +[`task.assign(user)`][assign] will return an [`Task Assignment`][assignment_class] object, populated with data +from the API. ```python -user = client.user('11111') -assignment = client.task('12345').assign(user) -print('Assignment id is {0} and is assigned to user {1}'.format(assignment.id, assignment.assigned_to.name)) +user = client.user(user_id='11111') +assignment = client.task(task_id='12345').assign(user) +print('Assignment ID is {0} and is assigned to user {1}'.format(assignment.id, assignment.assigned_to.name)) ``` -[task]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.client.client.Client.task -[user]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.client.client.Client.user +[task]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.client..html#boxsdk.client.client.Client.task [assign]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.task.Task.assign [assignment_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.task_assignment.TaskAssignment Assign a Task with User Login ----------------------------- -To assign a task object with a user login, first call [`client.task(task_id)`][task] to construct the appropriate [`Task`][task_class] object, you can then pass in a `unicode` value representing the login of the user you wish to assign the task to. This method will return a [`Task Assignment`][assignment_class] object, populated with data from the API. +To assign a task object with a user login, first call [`task.assign_with_login(login)`][assign_with_login] with a +`unicode` value for user login. This method will return a [`TaskAssignment`][assignment_class] object, populated with +data from the API. ```python -assignment = client.task('12345').assign_with_login('test_user@example.com') -print('Assignment id is {0} and the assignee is {1}'.format(assignment.id, assignment.assigned_to.login)) +assignment = client.task(task_id='12345').assign_with_login('test_user@example.com') +print('Assignment ID is {0} and the assignee is {1}'.format(assignment.id, assignment.assigned_to.login)) ``` -[task]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.client.client.Client.task -[task_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.task.Task +[assign_with_login]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.task_assignment.assign_with_login [assignment_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.task_assignment.TaskAssignment List Task Assignments --------------------- -To retrieve all assignments for an enterprise, first call [`client.task(task_id)`][task] to construct the appropriate task object. Then call ['task.get_assignments(fields=None)'][get_assignments]. This method returns a `BoxObjectCollection` that allows you to iterate over the ['Task Assignment'][assignment_class] objects in the collection. +To retrieve all assignments for an enterprise, first call [`client.task(task_id)`][task] to construct the appropriate +task object. Then call ['task.get_assignments(fields=None)'][get_assignments]. This method returns a +`BoxObjectCollection` that allows you to iterate over the ['TaskAssignment'][assignment_class] objects in the +collection. ```python -assignments = client.task('12345').get_assignments() +assignments = client.task(task_id='12345').get_assignments() for assignment in assignments: - print('Assignment id is {0} and the assignee is {1}'.format(assignment.id, assignment.assigned_to.login)) + print('Assignment ID is {0} and the assignee is {1}'.format(assignment.id, assignment.assigned_to.login)) ``` -[task]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.client.client.Client.task +[task]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.client.html#boxsdk.client.client.Client.task [get_assignments]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.task.Task.get_assignments -[assignment_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.task_assignment.TaskAssignment Get Information about Task Assignment ------------------------------------- -To get a task assignment object, first call [`client.task_assignment(assignment_id)`][assignment] to construct the appropriate [`Task Assignment`][assignment_class] object, and then calling ['task_assignment.get(fields=None)'][get] will return the [`Task Assignment`][task_assignment] object populated with data from the API. +To get a task assignment object, first call [`client.task_assignment(assignment_id)`][assignment] to construct the +appropriate [`TaskAssignment`][assignment_class] object, and then calling ['task_assignment.get(fields=None)'][get] +will return the [`TaskAssignment`][task_assignment] object populated with data from the API. ```python assignment= client.task_assignment('12345').get() -print('Assignment id is {0} and assignment type is {1}'.format(assignment.id, assignment.type)) +print('Assignment ID is {0} and assignment type is {1}'.format(assignment.id, assignment.type)) ``` -[assignment]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.client.client.Client.task_assignment +[assignment]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.client.html#boxsdk.client.client.Client.task_assignment [assignment_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.task_assignment.TaskAssignment [get]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.base_object.BaseObject.get Update Task Assignment ---------------------- -To update a task assignment object, first call [`client.task_assignment(assignment_id)`][assignment] to construct the appropriate [`TaskAssignment`][assignment_class] object, and then calling [`assignment.update_info(data)`][update_info] with a `dict` of properties to update on a task assignment. This method returns a newly update [`Task Assignment`][assignment_class] object, leaving the original object unmodified. +To update a task assignment object, call [`assignment.update_info(data)`][update_info] +with a `dict` of properties to update on a task assignment. This method returns a newly update +[`TaskAssignment`][assignment_class] object, leaving the original object unmodified. ```python from boxsdk.object.task_assignment import ResolutionState updated_task = {'resolution_state': ResolutionState.APPROVED} -updated_assignment = client.task_assignment('12345').update_info(updated_task) -print('Assignment id is {0} and resolution state is {1}'.format(updated_assignment.id, updated_assignment.resolution_state)) +updated_assignment = client.task_assignment(assignment_id='12345').update_info(updated_task) +print('Assignment ID is {0} and resolution state is {1}'.format(updated_assignment.id, updated_assignment.resolution_state)) ``` -[assignment]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.client.client.Client.task_assignment [assignment_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.task_assignment.TaskAssignment [update_info]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.base_object.BaseObject.update_info Delete Task Assignment ---------------------- -To delete a task assignment, call [`task_assignment.delete()`][delete]. This method returns `True` to indicate that the deletion was successful. +To delete a task assignment, call [`task_assignment.delete()`][delete]. This method returns `True` to indicate that the +deletion was successful. ```python -client.task_assignment('12345').delete() +client.task_assignment(assignment_id='12345').delete() print('The task assignment was successfully delete!') ``` diff --git a/docs/trash.md b/docs/trash.md index f23969d79..1afa5ceb7 100644 --- a/docs/trash.md +++ b/docs/trash.md @@ -19,12 +19,14 @@ the Trash will be purged after 30 days. List Trashed Items ------------------ -To retrieve all trashed items for an enterprise, call [`client.trash().get_items(imit=None, offset=None, fields=None)`][get_trashed_items]. This method returns a `BoxObjectCollection` that allows you to iterate over the [`Trash`][trash] objects in the collection. +To retrieve all trashed items for an enterprise, call [`client.trash().get_items(imit=None, offset=None, fields=None)`][get_trashed_items]. +This method returns a `BoxObjectCollection` that allows you to iterate over the [`Trash`][trash] objects in the +collection. ```python trashed_items = client.trash().get_items() for trashed_item in trashed_items: - print('The item id is {0} and the item name is {1}'.format(trashed_item.id, trashed_item.name)) + print('The item ID is {0} and the item name is {1}'.format(trashed_item.id, trashed_item.name)) ``` [get_trashed_item]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.trash.Trash.get_trashed_items @@ -33,93 +35,91 @@ for trashed_item in trashed_items: Get Trashed Items ----------------- -To get a trashed item, first construct a [`Folder`][folder_class], [`File`][file_class], or [`Web Link`][web_link_class] object and then calling [`client.trash().get_item(item, fields)`][get_item] with the constructed object passed in. This method will return the ['Item'][item] object populated with data from the API. +To get a trashed item, call [`client.trash().get_item(item, fields)`][get_item] with the item you wish to retrieve passed in. +This method will return the ['Item'][item] object populated with data from the API. ```python -file_to_retrieve = client.file('11111') +file_to_retrieve = client.file(file_id='11111') file_from_trash = client.trash().get_item(file_to_retrieve) -print('File id is {0} and name is {1}'.format(file_from_trash.id, file_from_trash.name)) +print('File ID is {0} and name is {1}'.format(file_from_trash.id, file_from_trash.name)) ``` ```python -folder = client.folder('22222') +folder = client.folder(folder_id='22222') folder_from_trash = client.trash().get_item(folder) -print('Folder id is {0} and name is {1}'.format(folder_from_trash.id, folder_from_trash.name)) +print('Folder ID is {0} and name is {1}'.format(folder_from_trash.id, folder_from_trash.name)) ``` ```python -web_link = client.web_link('33333') +web_link = client.web_link(web_link_i='33333') web_link_from_trash = client.trash().get_item(web_link) -print('Web link id is {0} and name is {1}'.format(web_link_from_trash.id, web_link_from_trash.name)) +print('Web link ID is {0} and name is {1}'.format(web_link_from_trash.id, web_link_from_trash.name)) ``` -[folder_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.folder.Folder -[file_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.file.File -[web_link_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.web_link.WebLink [item]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.item.Item [get_item]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.trash.Trash.get_item Restore Item from Trash ----------------------- -To retore a trashed item, effectively undeleting it, first construct a [`Folder`][folder_class], [`File`][file_class], or [`Web Link`][web_link_class] object and then calling [`client.trash().restore(item, name=None, parent_folder, fields=None)`][restore_item] with the constructed [`Item`][item_class] object will let you restore the specific object from your trash. This method will return a [`Item`][item_class] object populated with data from the API, leaving the original object unmodified. +To retore a trashed item, effectively undeleting it, call [`client.trash().restore(item, name=None, parent_folder, fields=None)`][restore_item] +with the constructed [`Item`][item_class] object will let you restore the specific object from your trash. This method +will return a [`Item`][item_class] object populated with data from the API, leaving the original object unmodified. ```python -file_to_restore = client.file('11111') +file_to_restore = client.file(file_id='11111') restored_file = client.trash().restore_item(file_to_restore) -print('File id is {0} and name is {1}'.format(restored_file.id, restored_file.name)) +print('File ID is {0} and name is {1}'.format(restored_file.id, restored_file.name)) ``` ```python -folder_to_restore = client.folder('22222') +folder_to_restore = client.folder(folder_id='22222') restored_folder = client.trash().restore_item(folder_to_restore) -print('Folder id is {0} and name is {1}'.format(restored_folder.id, restored_folder.name)) +print('Folder ID is {0} and name is {1}'.format(restored_folder.id, restored_folder.name)) ``` ```python -web_link_to_restore = client.web_link('33333') +web_link_to_restore = client.web_link(web_link_id='33333') restored_web_link = client.trash().restore_item(web_link_to_restore) -print('Web link id is {0} and name is {1}'.format(restored_web_link.id, restored_web_link.name)) +print('Web link ID is {0} and name is {1}'.format(restored_web_link.id, restored_web_link.name)) ``` In order to avoid conflicts, you can set a new name and new parent folder for the item you wish to restore. ```python -file_to_restore = client.file('11111') +file_to_restore = client.file(file_id='11111') new_name = 'New File Name' -new_parent_folder = client.folder('22222') +new_parent_folder = client.folder(folder_id='22222') restored_file = client.trash().restore_item(file_to_restore, new_name, new_parent_folder) print('New name for file is {0} and new parent folder is {1}'.format(restored_file.name, restored_file.parent.name)) ``` -[folder_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.folder.Folder -[file_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.file.File -[web_link_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.web_link.WebLink [item_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.item.Item [restore_item]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.trash.Trash.restore_item Permanently Delete Item ----------------------- -To delete an [`Item`][item_class] object from trash, call [`client.trash().permanently_delete_item(item)`][delete]. This method returns `True` to indicate that the deletion was successful. +To delete an [`Item`][item_class] object from trash, call [`client.trash().permanently_delete_item(item)`][delete]. +This method returns `True` to indicate that the deletion was successful. ```python -file_to_delete = client.file('11111') +file_to_delete = client.file(file_id='11111') client.trash().permanently_delete_item(file_to_delete) print('The file was deleted from trash!') ``` ```python -folder = client.folder('22222') +folder = client.folder(folder_id='22222') client.trash().permanently_delete_item(folder) print('The folder was deleted from trash!') ``` ```python -web_link = client.web_link('33333') +web_link = client.web_link(web_link_id='33333') client.trash().permanently_delete_item(web_link) print('The web link was deleted from trash!') ``` [item_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.item.Item -[delete]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.trash.Trash.permanently_delete() +[delete]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.trash.Trash.permanently_delete diff --git a/docs/watermarking.md b/docs/watermarking.md index f33a86d7c..edafc7228 100644 --- a/docs/watermarking.md +++ b/docs/watermarking.md @@ -1,7 +1,11 @@ Watermarking ============ -The ability to watermark files and folders is represented as a sub-resource on the Files and Folders resources, respectively. You can think of the sub-resource as a "label" marking whether the file or folder is watermarked or not. If you apply a watermark label to a folder, then all files inside of it will be protected by the watermark (e.g. previews will be watermarked). However, those files' watermark sub-resource is independent from the folder that got watermarked. This allows you to watermark files and folders independently. +The ability to watermark files and folders is represented as a sub-resource on the Files and Folders resources, +respectively. You can think of the sub-resource as a "label" marking whether the file or folder is watermarked or not. +If you apply a watermark label to a folder, then all files inside of it will be protected by the watermark (e.g. +previews will be watermarked). However, those files' watermark sub-resource is independent from the folder that got +watermarked. This allows you to watermark files and folders independently. @@ -17,67 +21,60 @@ The ability to watermark files and folders is represented as a sub-resource on t Get Watermark on File or Folder ------------------------------- -To get a watermark object, first call [`client.file(file_id)`][file] or [`client.folder(folder_id)`][folder] to construct the appropriate ['Folder'][folder_class] or ['File'][file_class] object, and then calling [`file.get_watermark()`][get_file_watermark] or [`folder.get_watermark()`][get_folder_watermark] will return the [`Watermark`][watermark_class] object populated with data from the API. +To get a watermark object, call [`file.get_watermark()`][get_file_watermark] or +[`folder.get_watermark()`][get_folder_watermark] will return the [`Watermark`][watermark_class] object populated with +data from the API. ```python -watermark = client.file('12345').get_watermark() +watermark = client.file(file_id='12345').get_watermark() print('Watermark created at {0} and modified at {1}'.format(watermark.created_at, watermark.modified_at)) ``` ```python -watermark = client.folder('11111').get_watermark() +watermark = client.folder(folder_id='11111').get_watermark() print('Watermark created at {0} and modified at {1}'.format(watermark.created_at, watermark.modified_at)) ``` -[file]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.client.html#boxsdk.client.client.Client.file -[file_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.file.File -[folder]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.client.html#boxsdk.client.client.Client.folder -[folder_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.folder.Folder -[get_file_watermark]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.client.html#boxsdk.object.file.File.get_watermark() -[get_folder_watermark]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.client.html#boxsdk.object.folder.Folder.get_watermark() +[get_file_watermark]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.file.File.get_watermark() +[get_folder_watermark]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.folder.Folder.get_watermark() [watermark_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.watermark.Watermark Apply Watermark on File or Folder --------------------------------- -To assign a watermark on a file or folder, first call [`client.file(file_id)`][file]] or [`client.folder(folder_id)`][folder]] to construct the appropriate ['Folder'][folder_class] or ['File'][file_class] object, and then calling [file.apply_watermark()][apply-file-watermark] or [folder.apply_watermark()][apply-folder-watermark] will return the [`Watermark`][watermark_class] object populated with data from the API. +To assign a watermark on a file or folder, call [file.apply_watermark()][apply-file-watermark] or +[folder.apply_watermark()][apply-folder-watermark] will return the [`Watermark`][watermark_class] object populated with +data from the API. ```python -watermark = client.file('12345').apply_watermark() +watermark = client.file(file_id='12345').apply_watermark() print('Watermark created at {0} and modified at {1}'.format(watermark.created_at, watermark.modified_at)) ``` ```python -watermark = client.folder('11111').apply_watermark() +watermark = client.folder(folder_id='11111').apply_watermark() print('Watermark created at {0} and modified at {1}'.format(watermark.created_at, watermark.modified_at)) ``` -[file]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.client.html#boxsdk.client.client.Client.file -[file_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.file.File -[folder]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.client.html#boxsdk.client.client.Client.folder -[folder_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.folder.Folder -[apply-file-watermark]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.client.html#boxsdk.file.File.apply_watermark() -[apply_folder_watermark]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.client.html#boxsdk.folder.Folder.apply_watermark() +[apply-file-watermark]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.file.File.apply_watermark() +[apply_folder_watermark]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.folder.Folder.apply_watermark() [watermark_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.watermark.Watermark Remove Watermark on File or Folder ---------------------------------- -To remove a watermark from a file or folder, first call [`client.file(file_id)`][file]] or [`client.folder(folder_id)`][folder]] to construct the appropriate ['Folder'][folder_class] or ['File'][file_class] object, and then calling [file.delete_watermark()][delete-file-watermark] or [folder.delete_watermark()][delete-folder-watermark] will return `True` to indicate that the deletion was successful. +To remove a watermark from a file or folder, call [file.delete_watermark()][delete-file-watermark] or +[folder.delete_watermark()][delete-folder-watermark] will return `True` to indicate that the deletion was successful. ```python -client.file('12345').delete_watermark() +client.file(file_id='12345').delete_watermark() print('The file watermark was deleted!') ``` ```python -client.folder('11111').delete_watermark() +client.folder(folder_id='11111').delete_watermark() print('The folder watermark was deleted!') ``` -[file]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.client.html#boxsdk.client.client.Client.file -[file_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.file.File -[folder]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.client.html#boxsdk.client.client.Client.folder -[folder_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.folder.Folder -[delete-file-watermark]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.client.html#boxsdk.file.File.delete_watermark() -[delete_folder_watermark]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.client.html#boxsdk.folder.Folder.delete_watermark() +[delete-file-watermark]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.file.File.delete_watermark() +[delete_folder_watermark]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.folder.Folder.delete_watermark() diff --git a/docs/web_link.md b/docs/web_link.md index 7211b69c0..0b311cfbf 100644 --- a/docs/web_link.md +++ b/docs/web_link.md @@ -19,26 +19,28 @@ similarly to file objects. Create Web Link --------------- -To create a web link object, first call [`client.folder(folder_id)`][folder] to construct the appropriate ['Folder'][folder_class] object, and then calling [`folder.create_web_link(target_url, name=None, description=None)`][create] will let you create a new web link with a specified name and description. This method return an updated [`WebLink`][web_link_class] object populated with data from the API, leaving the original object unmodified. +To create a web link object, calling [`folder.create_web_link(target_url, name=None, description=None)`][create] +will let you create a new web link with a specified name and description. This method return an newly created [`WebLink`][web_link_class] +object populated with data from the API, leaving the original object unmodified. ```python -web_link = client.folder('12345').create_web_link('https://example.com', 'Example Link', 'This is the description') -print('WebLink url is {0} and its description is {1}'.format(web_link.url, web_link.description)) +web_link = client.folder(folder_id='12345').create_web_link('https://example.com', 'Example Link', 'This is the description') +print('Web Link url is {0} and its description is {1}'.format(web_link.url, web_link.description)) ``` -[folder]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.client.html#boxsdk.client.client.Client.folder -[folder_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.folder.Folder [create]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.folder.Folder.create_web_link [web_link_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.web_link.WebLink Get Web Link ------------ -To get a web link object, first call [`client.web_link(web_link_id)`][web_link] to construct the appropriate [`WebLink`][web_link_class] object, and then calling [`web_link.get(fields=None)`][get] will return the [`WebLink`][web_link_class] object populated with data from the API, leaving the original object unmodified. +To get a web link object, first call [`client.web_link(web_link_id)`][web_link] to construct the appropriate +[`WebLink`][web_link_class] object, and then calling [`web_link.get(fields=None)`][get] will return the +[`WebLink`][web_link_class] object populated with data from the API, leaving the original object unmodified. ```python -web_link = client.web_link('12345').get() -print('WebLink id is {0} and its type is {1}'.format(web_link.id, web_link.type)) +web_link = client.web_link(web_link_id='12345').get() +print('Web Link ID is {0} and its type is {1}'.format(web_link.id, web_link.type)) ``` [web_link]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.client.html#boxsdk.client.client.Client.web_link @@ -48,20 +50,22 @@ print('WebLink id is {0} and its type is {1}'.format(web_link.id, web_link.type) Update Web Link --------------- -To update a web link object, first call [`client.web_link(web_link_id)`][web_link] to construct the appropriate [`WebLink`][web_link_class] object, and then calling [`web_link.update_info(data)`][update_info] with a `dict` of properties to update on the web link. This method returns a newly updated ['WebLink'][web_link_class] object, leaving the original object unmodified. +To update a web link object, call [`web_link.update_info(data)`][update_info] with a `dict` of +properties to update on the web link. This method returns a newly updated ['WebLink'][web_link_class] object, leaving +the original object unmodified. ```python -updated_web_link = client.web_link('12345').update_info({'url': 'https://newurl.com'}) +updated_web_link = client.web_link(web_link_id='12345').update_info({'url': 'https://newurl.com'}) ``` -[web_link]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.client.html#boxsdk.client.client.Client.web_link [update_info]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.base_object.BaseObject.update_info [web_link_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.web_link.WebLink Delete Web Link --------------- -To delete a web link, call [`web_link.delete()`][delete]. This method returns `True` to indicate that the deletion was successful. +To delete a web link, call [`web_link.delete()`][delete]. This method returns `True` to indicate that the deletion was +successful. ```python client.web_link('12345').delete() diff --git a/docs/webhook.md b/docs/webhook.md index 1183b0092..3ab14dcbb 100644 --- a/docs/webhook.md +++ b/docs/webhook.md @@ -1,7 +1,9 @@ Webhooks ======== -Webhooks enable you to attach event triggers to Box files and folders. Event triggers monitor events on Box objects and notify your application when they occur. A webhook notifies your application by sending HTTP requests to a URL of your choosing. +Webhooks enable you to attach event triggers to Box files and folders. Event triggers monitor events on Box objects and +notify your application when they occur. A webhook notifies your application by sending HTTP requests to a URL of your +choosing. @@ -18,11 +20,13 @@ Webhooks enable you to attach event triggers to Box files and folders. Event tri Get Information about Webhook ----------------------------- -To get a webhook object, first call [`client.webhook(webhook_id)`][webhook] to construct the appropriate [`Webhook`][webhook_class] object, and then calling [`webhook.get(fields=None)`][get] will return the [`Webhook`][webhook_class] object populated with data from the API. +To get a webhook object, first call [`client.webhook(webhook_id)`][webhook] to construct the appropriate +[`Webhook`][webhook_class] object, and then calling [`webhook.get(fields=None)`][get] will return the +[`Webhook`][webhook_class] object populated with data from the API. ```python -webhook = client.webhook('12345').get() -print('Webhooks id is {0} and the address is {1}'.format(webhook.id, webhook.address)) +webhook = client.webhook(webhook_id='12345').get() +print('Webhooks ID is {0} and the address is {1}'.format(webhook.id, webhook.address)) ``` [webhook]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.client.html#boxsdk.client.client.Client.webhook @@ -32,12 +36,14 @@ print('Webhooks id is {0} and the address is {1}'.format(webhook.id, webhook.add List all Webhooks ----------------- -To retrieve all webhooks for an enterprise, call [`client.get_webhooks(limit=None, marker=None, fields=None)`][get_webhooks]. This method returns a `BoxObjectCollection` that allows you to iterate over the [`Webhook`][webhook_class] objects in the collection. +To retrieve all webhooks for an enterprise, call [`client.get_webhooks(limit=None, marker=None, fields=None)`][get_webhooks]. +This method returns a `BoxObjectCollection` that allows you to iterate over the [`Webhook`][webhook_class] objects in +the collection. ```python webhooks = client.get_webhooks() for webhook in webhooks: - print('The webhook id is {0} and the address is {1}'.format(webhook.id, webhook.address)) + print('The webhook ID is {0} and the address is {1}'.format(webhook.id, webhook.address)) ``` [get_webhooks]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.client.html#boxsdk.client.client.Client.get_webhooks @@ -46,26 +52,29 @@ for webhook in webhooks: Create Webhook -------------- -To create a webhook object, call [`client.create_webhook(target_url, name=None, description=None)`][create] will let you create a new webhook object with the specified target url, name, and description. This method will return an updated [`Webhook`][webhook_class] object populated with data from the API, leaving the original object unmodified. +To create a webhook object, call [`client.create_webhook(target_url, name=None, description=None)`][create] will let +you create a new webhook object with the specified target url, name, and description. This method will return an updated +[`Webhook`][webhook_class] object populated with data from the API, leaving the original object unmodified. You can create a webhook on either a `file` or a `folder`. For a full list of triggers, see [`here`](https://developer.box.com/v2.0/reference#webhooks-v2) ```python -folder = client.folder('12345') +folder = client.folder(folder_id='12345') webhook = client.create_webhook(folder, ['FILE.UPLOADED', 'FILE.PREVIEWED'], 'https://example.com') -print('Webhook id is {0} and the address is {1}'.format(webhook.id, webhook.address)) +print('Webhook ID is {0} and the address is {1}'.format(webhook.id, webhook.address)) ``` -[create]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.client.html#boxsdk.client.Client.create_webhook +[create]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.client.html#boxsdk.client.client.Client.create_webhook [webhook_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.webhook.Webhook Delete Webhook -------------- -To delete a webhook, call [`webhook.delete()`][delete]. This method returns `True` to indicate that the deletion was successful. +To delete a webhook, call [`webhook.delete()`][delete]. This method returns `True` to indicate that the deletion was +successful. ```python -client.webhook('12345').delete() +client.webhook(webhook_id='12345').delete() print('The webhook was successfully deleted!') ``` @@ -75,17 +84,19 @@ print('The webhook was successfully deleted!') Update Webhook -------------- -To update a webhook object, first call [`client.webhook(webhook_id)`][webhook] to construct the appropriate [`Webhook`][webhook_class] object, and then calling [`webhook.update_info(data)`][update_info] with a `dict` of properties to update on the webhook. This method returns a new updated [`Webhook`][webhook_class] object, leaving the original object unmodified. +To update a webhook object, first call [`client.webhook(webhook_id)`][webhook] to construct the appropriate [`Webhook`][webhook_class] +object, and then calling [`webhook.update_info(data)`][update_info] with a `dict` of properties to update on the +webhook. This method returns a new updated [`Webhook`][webhook_class] object, leaving the original object unmodified. ```python update_object = { triggers: ['FILE.COPIED'], address: 'https://newexample.com', } -webhook = client.webhook('12345').update_info(update_object) +webhook = client.webhook(webhook_id='12345').update_info(update_object) print('Updated the webhook info for triggers: {0} and address: {1}'.format(webhook.triggers, webhook.address)) ``` -[webhook]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.client.html#boxsdk.client.Client.create_webhook +[webhook]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.client.html#boxsdk.client.client.Client.create_webhook [webhook_class]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.webhook.Webhook [update_info]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.base_object.BaseObject.update_info