Skip to main content

FileAPIClient

GitHub source

FileAPIClient

evo.files.client.FileAPIClient

__init__​

__init__(environment: Environment, connector: APIConnector) -> None

Parameters:

NameTypeDescriptionDefault
environmentEnvironmentThe environment objectrequired
connectorAPIConnectorThe connector object.required

get_service_health async​

get_service_health(check_type: HealthCheckType = HealthCheckType.FULL) -> ServiceHealth

Get the health of the file service.

Parameters:

NameTypeDescriptionDefault
check_typeHealthCheckTypeThe type of health check to perform.FULL

Returns:

TypeDescription
ServiceHealthA ServiceHealth object.

Raises:

TypeDescription
EvoAPIExceptionIf the API returns an unexpected status code.
ClientValueErrorIf the response is not a valid service health check response.

list_files async​

list_files(offset: int = 0, limit: int = 5000, name: str | None = None, deleted: bool = False) -> Page[FileMetadata]

List up to limit files in the workspace, starting at offset.

The files will be the latest version of the file. If there are no files starting at offset, the page will be empty.

Parameters:

NameTypeDescriptionDefault
offsetintThe number of files to skip before listing.0
limitintMax number of files to list.5000
namestr | NoneFilter files by name.None
deletedboolOnly include deleted files in the listing.False

Returns:

TypeDescription
Page[FileMetadata]A page of all files from the query.

list_all_files async​

list_all_files(limit_per_request: int = 5000, name: str | None = None, deleted: bool = False) -> list[FileMetadata]

List all files in the workspace.

This method makes multiple calls to the list_files endpoint until all files have been listed.

Parameters:

NameTypeDescriptionDefault
limit_per_requestintThe maximum number of files to list in one request.5000
namestr | NoneFilter files by name.None
deletedboolOnly include deleted files in the listing.False

Returns:

TypeDescription
list[FileMetadata]A list of all files in the workspace.

get_file_by_path async​

get_file_by_path(path: str, version_id: str | None = None) -> FileMetadata

Get a file by its path.

Parameters:

NameTypeDescriptionDefault
pathstrThe path to the file.required
version_idstr | NoneID of the desired file version. By default, the response will return the latest version.None

Returns:

TypeDescription
FileMetadataA FileMetadata representation of the file on the service.

get_file_by_id async​

get_file_by_id(file_id: UUID, version_id: str | None = None, deleted: bool = False) -> FileMetadata

Get a file by its ID.

Parameters:

NameTypeDescriptionDefault
file_idUUIDUUID of a filerequired
version_idstr | NoneID of the desired file version. By default, the response will return the latest version.None
deletedboolOptional flag to include deleted files.False

Returns:

TypeDescription
FileMetadataA FileMetadata representation of the file on the service

list_versions_by_path async​

list_versions_by_path(path: str) -> list[FileVersion]

List the versions of a file by path.

Parameters:

NameTypeDescriptionDefault
pathstrThe path to the file.required

Returns:

TypeDescription
list[FileVersion]A sorted list of file versions. The latest version is the first element of the list.

list_versions_by_id async​

list_versions_by_id(file_id: UUID, deleted: bool = False) -> list[FileVersion]

List the versions of a file by ID

Parameters:

NameTypeDescriptionDefault
file_idUUIDUUID of the file.required
deletedboolOptional flag to include deleted files.False

Returns:

TypeDescription
list[FileVersion]A sorted list of file versions. The latest version is the first element of the list.

prepare_download_by_path async​

prepare_download_by_path(path: str, version_id: str | None = None) -> FileAPIDownload

Prepares a file for download by path.

Parameters:

NameTypeDescriptionDefault
pathstrPath to the file.required
version_idstr | NoneVersions of the file.None

Returns:

TypeDescription
FileAPIDownloadA FileAPIDownload object.

prepare_download_by_id async​

prepare_download_by_id(file_id: UUID, version_id: str | None = None, deleted: bool = False) -> FileAPIDownload

Prepares a file for download by ID.

Parameters:

NameTypeDescriptionDefault
file_idUUIDUUID of the file.required
version_idstr | NoneVersion of the file.None
deletedboolOptional flag to include deleted files.False

Returns:

TypeDescription
FileAPIDownloadA FileAPIDownload object.

prepare_upload_by_path async​

prepare_upload_by_path(path: str) -> FileAPIUpload

Prepares a file for upload by path. If the file already exists, a new version will be created.

Parameters:

NameTypeDescriptionDefault
pathstrPath the file is being uploaded to.required

Returns:

TypeDescription
FileAPIUploadA FileAPIUpload object.

prepare_upload_by_id async​

prepare_upload_by_id(file_id: UUID) -> FileAPIUpload

Prepares a file for upload by ID. The file_id must be the ID of an existing file, for which a new version will be created.

Parameters:

NameTypeDescriptionDefault
file_idUUIDUUID of the file.required

Returns:

TypeDescription
FileAPIUploadA FileAPIUpload object.

restore_file_by_id async​

restore_file_by_id(file_id: UUID) -> FileMetadata | None

Restore a deleted file by ID.

Parameters:

NameTypeDescriptionDefault
file_idUUIDUUID of the file.required

Returns:

TypeDescription
FileMetadata | NoneFileMetadata if the file path changed during restore (HTTP 303), None if the file was restored without path change (HTTP 204).

delete_file_by_path async​

delete_file_by_path(path: str) -> None

Deletes a file by path.

Parameters:

NameTypeDescriptionDefault
pathstrPath of the file to delete.required

delete_file_by_id async​

delete_file_by_id(file_id: UUID) -> None

Deletes a file by ID.

Parameters:

NameTypeDescriptionDefault
file_idUUIDUUID of the file to delete.required

Was this page helpful?