diff --git a/docs/retention_policy.md b/docs/retention_policy.md index 63bf70abd..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,116 +23,162 @@ 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 +[`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)) ``` -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 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 +[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 [`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 -policy_id = '1234' -retention_policy = client.retention_policy(policy_id).get() +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.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 ---------------------- -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.client.html#boxsdk.client.client.Client.get_retention_policies + 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, 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_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(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)) ``` +[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, call [`retention_policy.assign(folder)`][assign] will create a new +[`RetentionPolicyAssignment`][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) +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)) ``` +[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.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, 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 -policy_id = '1234' -assignments = client.retention_policy(policy_id).assignments(limit=10) +assignments = client.retention_policy(policy_id='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(policy_id='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)) ``` +[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 [`FileVersionRetention`][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.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 ---------------------------------------------- -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 [`FileVersionRetention`][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(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.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 27fb60515..38a985a5c 100644 --- a/docs/task.md +++ b/docs/task.md @@ -1,115 +1,193 @@ 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](#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 ------------------------ -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(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.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 for a given file use, `file.get_tasks(fields=None)`. +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: - # Do something + print('Task ID is {0} and the type is {1}'.format(task.id, task.type)) ``` +[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 [`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)) ``` +[create_task]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.file.File.create_Task + Update Task Info ---------------- -To update the task information use, `task.update_info(data)` +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('1234').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}) ``` +[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.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 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 +[`task.assign(user)`][assign] will return an [`Task Assignment`][assignment_class] object, populated with data +from the API. ```python -user = client.user('1111') -assignment = client.task('1234').assign(user) +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.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 to a user on a file, use `task.assign_with_login(assignee_login)` +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('1234').assign_with_login('test_user@example.com') +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)) ``` +[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 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 ['TaskAssignment'][assignment_class] objects in the +collection. ```python -assignments = client.task('1234').get_assignments() +assignments = client.task(task_id='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.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 + 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 [`TaskAssignment`][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.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 information about a task assignment use, `task_assignment.update_info(data)` +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('5678').update_info(updated_task) +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_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(assignment_id='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 41e1d82cb..1afa5ceb7 100644 --- a/docs/trash.md +++ b/docs/trash.md @@ -19,79 +19,107 @@ 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 ----------------- -To retrieve a file, folder, weblink from the trash, use `client.trash.get_item(item, fields=None)`. +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_info_to_retrieve = client.file('11111') -file_from_trash = client.trash().get_item(file_info_to_retrieve) +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)) ``` ```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)) ``` ```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)) ``` +[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, 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)) ``` ```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)) ``` ```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)) ``` 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)) ``` +[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') +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 diff --git a/docs/watermarking.md b/docs/watermarking.md index dd141ef6a..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,38 +21,60 @@ 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, 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_info = client.file('1234').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_info = client.folder('5678').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)) ``` +[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, use `file.apply_watermark()`. To assign a watermark on a folder, use `folder.apply_watermark()`. +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_info = client.file('1234').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_info = client.folder('5678').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)) ``` +[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 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, 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('1234').delete_watermark() +client.file(file_id='12345').delete_watermark() +print('The file watermark was deleted!') ``` ```python -client.folder('5678').delete_watermark() +client.folder(folder_id='11111').delete_watermark() +print('The folder watermark was deleted!') ``` + +[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 eac7ac9ed..0b311cfbf 100644 --- a/docs/web_link.md +++ b/docs/web_link.md @@ -19,42 +19,57 @@ 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, 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 -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(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)) ``` +[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(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 +[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 --------------- -Calling `web_link.update_info()` can be used to update the weblink. +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 -web_link_update = {'url': 'https://newurl.com'} -updated_web_link = client.web_link.update_info(web_link_update) +updated_web_link = client.web_link(web_link_id='12345').update_info({'url': 'https://newurl.com'}) ``` +[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 --------------- -Calling `web_link.delete()` can be used to delete a specified weblink. +To delete a web link, call [`web_link.delete()`][delete]. This method returns `True` to indicate that the 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!') ``` + +[delete]: https://box-python-sdk.readthedocs.io/en/latest/boxsdk.object.html#boxsdk.object.base_object.BaseObject.delete diff --git a/docs/webhook.md b/docs/webhook.md index 7463bcef2..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,53 +20,83 @@ 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. ```python -webhook_info = client.webhook('1234').get() +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 +[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(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)) ``` +[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(webhook_id='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 + + 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(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.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