Resource-Specific Functionality¶
The API provides extra functionality specific to a number of a resources.
Root List Resource Functionality¶
The Root List Resource provides a set of uri-templates
which
can be used to retrieve a specific resource without traversing the resource
tree. Each uri-template consists of a key
and a uri-template
. For
examples, please see the Root List Resource page.
The API client allows the templates to be used through method calls on the
root resource. For each uri-template
, a method named get_<name>
will
be created. This method will take keyword arguments which will be used
to replace the fields in the uri-template
. We will use the following
uri-template
as an example.
"files": "http://reviews.example.com/api/review-requests/{review_request_id}/diffs/{diff_revision}/files/"
To use this uri-template
, the get_files()
method would be
called. For example, you could retrieve a specific
File Diff List Resource using the following code:
files = root.get_files(review_request_id=1, diff_revision=1)
Diff List Resource Functionality¶
The resource object for a Diff List Resource provides the following additional methods.
- DiffListResource.upload_diff(diff, parent_diff=None, base_dir=None)¶
Upload a diff contained in
diff
with the optionalparent_diff
and optionalbase_dir
.
Diff Resource Functionality¶
The resource object for a Diff Resource provides the following additional methods.
- DiffResource.get_patch()¶
Retrieve the actual contents of the uploaded diff.
File Diff Resource Functionality¶
The resource object for a File Diff Resource provides the following additional methods.
- FileDiffResource.get_patch()¶
Retrieve the actual contents of the uploaded diff for this file.
- FileDiffResource.get_diff_data()¶
Retrieves the actual raw diff data for the file. For more information about what this contains, see the File Diff Resource documentation.
File Attachment List Resource Functionality¶
The resource object for a File Attachment List Resource provides the following additional methods.
- FileAttachmentListResource.upload_attachment(filename, content, caption=None, attachment_history=None)¶
Uploads a new attachment containing
content
, namedfilename
, with the optionalcaption
and optionalattachment_history
.
Draft File Attachment List Resource Functionality¶
The resource object for a Draft File Attachment List Resource provides the following additional methods.
- DraftFileAttachmentListResource.upload_attachment(filename, content, caption=None, attachment_history=None)¶
Uploads a new attachment containing
content
, namedfilename
, with the optionalcaption
and optionalattachment_history
.
Screenshot List Resource Functionality¶
The resource object for a Screenshot List Resource provides the following additional methods.
- ScreenshotListResource.upload_attachment(filename, content, caption=None)¶
Uploads a new screenshot contained in
content
, namedfilename
, with the optionalcaption
.
Draft Screenshot List Resource Functionality¶
The resource object for a Draft Screenshot List Resource provides the following additional methods.
- DraftScreenshotListResource.upload_attachment(filename, content, caption=None)¶
Uploads a new screenshot contained in
content
, namedfilename
, with the optionalcaption
.
Review Request Resource Functionality¶
The resource object for a Review Request Resource provides the following additional methods.
- ReviewRequestResource.get_or_create_draft(**kwargs)¶
Retrieve the review request’s draft resource. If the draft does not exist it will be created and retrieved.