rbtools.api.resource.mixins¶
Mixins for API resources.
Added in version 6.0: This was moved from rbtools.api.resource.
Classes
A mixin for resources that implement an upload_attachment method. |
|
A mixin for uploading diffs to a resource. |
|
Mixin for resources that implement a get_patch method. |
|
Mixin for resources that implement an upload_screenshot method. |
- class rbtools.api.resource.mixins.AttachmentUploadMixin[source]¶
Bases:
objectA mixin for resources that implement an upload_attachment method.
Added in version 6.0.
- __annotations_cache__ = {}¶
- __firstlineno__ = 23¶
- __static_attributes__ = ()¶
- upload_attachment(filename: str, content: bytes, caption: str | None = None, attachment_history: str | None = None, **kwargs: QueryArgs) HttpRequest[source]¶
Upload a new attachment.
- Parameters:
filename (
str) – The name of the file.content (
bytes) – The content of the file to upload.caption (
str, optional) – The caption to set on the file attachment.attachment_history (
str, optional) – The ID of the FileAttachmentHistory to add this attachment to.**kwargs (
dictofrbtools.api.request.QueryArgs) – Query arguments to include with the request.
- Returns:
The newly-created file attachment.
- Return type:
FileAttachmentItemResource
- class rbtools.api.resource.mixins.DiffUploaderMixin[source]¶
Bases:
objectA mixin for uploading diffs to a resource.
- __annotations_cache__ = {}¶
- __firstlineno__ = 74¶
- __static_attributes__ = ()¶
- prepare_upload_diff_request(diff: bytes, parent_diff: bytes | None = None, base_dir: str | None = None, base_commit_id: str | None = None, **kwargs: QueryArgs) HttpRequest[source]¶
Create a request that can be used to upload a diff.
The diff and parent_diff arguments should be strings containing the diff output.
- Parameters:
diff (
bytes) – The diff content.parent_diff (
bytes, optional) – The parent diff content, if present.base_dir (
str, optional) – The base directory for the diff, if present.base_commit_id (
str, optional) – The ID of the commit that the diff is against, if present.**kwargs (
dictofrbtools.api.request.QueryArgs) – Query arguments to include with the request.
- Returns:
The API request.
- Return type:
- class rbtools.api.resource.mixins.GetPatchMixin[source]¶
Bases:
objectMixin for resources that implement a get_patch method.
Added in version 4.2.
- __annotations_cache__ = {}¶
- __firstlineno__ = 126¶
- __static_attributes__ = ()¶
- get_patch(**kwargs: QueryArgs) HttpRequest[source]¶
Retrieve the diff file contents.
- Parameters:
**kwargs (
dictofrbtools.api.request.QueryArgs) – Query arguments to include with the request.- Returns:
A resource containing the patch. The patch data will be in the
dataattribute.- Return type:
rbtools.api.resource.ItemResource
- class rbtools.api.resource.mixins.ScreenshotUploadMixin[source]¶
Bases:
objectMixin for resources that implement an upload_screenshot method.
Added in version 6.0.
- __annotations_cache__ = {}¶
- __firstlineno__ = 154¶
- __static_attributes__ = ()¶
- upload_screenshot(filename: str, content: bytes, caption: str | None = None, **kwargs: QueryArgs) HttpRequest[source]¶
Upload a new screenshot.
The content argument should contain the body of the screenshot to be uploaded, in string format.
- Parameters:
- Returns:
rbtools.api.resource.ScreenshotItemResource or rbtools.api.resource.DraftScreenshotItemResource: The newly-created screenshot.