Skip to content

sift_client.resources.file_attachments

CLASS DESCRIPTION
FileAttachmentsAPIAsync

High-level API for interacting with file attachments (remote files).

FileAttachmentsAPIAsync

FileAttachmentsAPIAsync(sift_client: SiftClient)

Bases: ResourceBase

High-level API for interacting with file attachments (remote files).

This class provides a Pythonic interface for managing file attachments on Sift entities like runs, assets, and test reports.

Initialize the FileAttachmentsAPIAsync.

PARAMETER DESCRIPTION
sift_client

The Sift client to use.

TYPE: SiftClient

METHOD DESCRIPTION
delete

Batch delete multiple file attachments.

download

Download a file attachment to a local path.

get

Get a file attachment by ID.

get_download_url

Get a download URL for a file attachment.

list_

List file attachments with optional filtering.

update

Update a file attachment.

upload

Upload a file attachment to a remote file.

ATTRIBUTE DESCRIPTION
client

TYPE: SiftClient

grpc_client

TYPE: GrpcClient

rest_client

TYPE: RestClient

client property

client: SiftClient

grpc_client property

grpc_client: GrpcClient

rest_client property

rest_client: RestClient

delete async

delete(
    *,
    file_attachments: list[FileAttachment | str]
    | FileAttachment
    | str,
) -> None

Batch delete multiple file attachments.

PARAMETER DESCRIPTION
file_attachments

List of FileAttachments or the IDs of the file attachments to delete (up to 1000).

TYPE: list[FileAttachment | str] | FileAttachment | str

download async

download(
    *,
    file_attachment: FileAttachment | str,
    output_path: str | Path,
) -> None

Download a file attachment to a local path.

PARAMETER DESCRIPTION
file_attachment

The FileAttachment or the ID of the file attachment to download.

TYPE: FileAttachment | str

output_path

The path to download the file attachment to.

TYPE: str | Path

get async

get(*, file_attachment_id: str) -> FileAttachment

Get a file attachment by ID.

PARAMETER DESCRIPTION
file_attachment_id

The ID of the file attachment to retrieve.

TYPE: str

RETURNS DESCRIPTION
FileAttachment

The FileAttachment.

get_download_url async

get_download_url(
    *, file_attachment: FileAttachment | str
) -> str

Get a download URL for a file attachment.

PARAMETER DESCRIPTION
file_attachment

The FileAttachment or the ID of the file attachment.

TYPE: FileAttachment | str

RETURNS DESCRIPTION
str

The download URL for the file attachment.

list_ async

list_(
    *,
    name: str | None = None,
    names: list[str] | None = None,
    name_contains: str | None = None,
    name_regex: str | Pattern | None = None,
    remote_file_ids: list[str] | None = None,
    entities: list[Run | Asset | TestReport] | None = None,
    entity_type: RemoteFileEntityType | None = None,
    entity_ids: list[str] | None = None,
    description_contains: str | None = None,
    filter_query: str | None = None,
    order_by: str | None = None,
    limit: int | None = None,
) -> list[FileAttachment]

List file attachments with optional filtering.

PARAMETER DESCRIPTION
name

Exact name of the file attachment.

TYPE: str | None DEFAULT: None

names

List of file attachment names to filter by.

TYPE: list[str] | None DEFAULT: None

name_contains

Partial name of the file attachment.

TYPE: str | None DEFAULT: None

name_regex

Regular expression to filter file attachments by name.

TYPE: str | Pattern | None DEFAULT: None

remote_file_ids

Filter to file attachments with any of these IDs.

TYPE: list[str] | None DEFAULT: None

entities

Filter to file attachments associated with these entities.

TYPE: list[Run | Asset | TestReport] | None DEFAULT: None

entity_type

Filter to file attachments associated with this entity type.

TYPE: RemoteFileEntityType | None DEFAULT: None

entity_ids

Filter to file attachments associated with these entity IDs.

TYPE: list[str] | None DEFAULT: None

description_contains

Partial description of the file attachment.

TYPE: str | None DEFAULT: None

filter_query

Explicit CEL query to filter file attachments.

TYPE: str | None DEFAULT: None

order_by

Field and direction to order results by. Note: Not supported by the backend, but it is here for API consistency.

TYPE: str | None DEFAULT: None

limit

Maximum number of file attachments to return. If None, returns all matches.

TYPE: int | None DEFAULT: None

RETURNS DESCRIPTION
list[FileAttachment]

A list of FileAttachment objects that match the filter criteria.

update async

update(
    *, file_attachment: FileAttachmentUpdate | dict
) -> FileAttachment

Update a file attachment.

PARAMETER DESCRIPTION
file_attachment

The FileAttachmentUpdate with fields to update.

TYPE: FileAttachmentUpdate | dict

RETURNS DESCRIPTION
FileAttachment

The updated FileAttachment.

upload async

upload(
    *,
    path: str | Path,
    entity: Asset | Run | TestReport,
    metadata: dict[str, Any] | None = None,
    description: str | None = None,
    organization_id: str | None = None,
) -> FileAttachment

Upload a file attachment to a remote file.

PARAMETER DESCRIPTION
path

The path to the file to upload.

TYPE: str | Path

entity

The entity that the file is attached to.

TYPE: Asset | Run | TestReport

metadata

Optional metadata for the file (e.g., video/image metadata).

TYPE: dict[str, Any] | None DEFAULT: None

description

Optional description of the file.

TYPE: str | None DEFAULT: None

organization_id

Optional organization ID.

TYPE: str | None DEFAULT: None

RETURNS DESCRIPTION
FileAttachment

The uploaded FileAttachment.