Skip to content

Latest commit

 

History

History
79 lines (58 loc) · 3.81 KB

file_request.md

File metadata and controls

79 lines (58 loc) · 3.81 KB

File Requests

File request objects represent a file request associated with a folder.

Get a File Request's Information

To get a file request object, first call client.file_request(file_request_id) to construct the appropriate FileRequest object, and then calling file_request.get(*, fields=None, headers=None, **kwargs) will return the FileRequest object populated with data from the API, leaving the original object unmodified.

file_request = client.file_request(file_request_id='123456').get()
print(f'File request {file_request.id} on folder {file_request.folder.name}')

Copy a File Request's Information

To copy a file request, first call client.file_request(file_request_id) to construct the appropriate FileRequest object, and then calling file_request.copy(folder, description=None, title=None, expires_at=None, require_description=None, require_email=None, status=None). It will return the FileRequest object populated with data new created file request from the API.

file_request = client.file_request(file_request_id='123456')
folder = client.folder(folder_id='123456789')
new_file_request = file_request.copy(folder=folder, title="Copied file request")

Update a File Request's Information

To update a file request object, call file_request.update_info(data=file_request_update) with a dict of properties to update on the file request. This method returns a newly updated FileRequest object, leaving the original object unmodified.

from boxsdk.object.file_request import StatusState
update_data = {
    "description": 'Updated description', 
    "is_email_required": True,
    "status": StatusState.ACTIVE
}
file_request.update_info(data=update_data)

Delete a File Request

To delete a file request, call file_request.delete(), it deletes a file request permanently.

file_request = client.file_request(file_request_id='123456')
file_request.delete()