Documentation

YaDisk object

class yadisk_async.YaDisk(id: str = '', secret: str = '', token: str = '', default_args: dict[str, Any] | None = None)[source]

Implements access to Yandex.Disk REST API.

Note

Do not forget to call YaDisk.close or use the async with statement to close all the connections. Otherwise, you may get a warning.

In the original library this is handled in the destructor, but since aiohttp.ClientSession.close is a coroutine function the same cannot be done here, so you have to do it explicitly.

Parameters:
  • id – application ID

  • secret – application secret password

  • token – application token

  • default_argsdict or None, default arguments for methods. Can be used to set the default timeout, headers, etc.

Variables:
  • idstr, application ID

  • secretstr, application secret password

  • tokenstr, application token

  • default_argsdict, default arguments for methods. Can be used to set the default timeout, headers, etc.

The following exceptions may be raised by most API requests:

Raises:
async check_token(token: str | None = None, /, **kwargs) bool[source]

Check whether the token is valid.

Parameters:
  • token – token to check, equivalent to self.token if None

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Returns:

bool

clear_session_cache() None[source]

Clears the session cache. Unused sessions will NOT be closed.

async close() None[source]

Closes all sessions and clears the session cache. Do not call this method while there are other active threads using this object.

This method can also be called implicitly by using the async with statement.

async copy(src_path: str, dst_path: str, /, **kwargs) ResourceLinkObject | OperationLinkObject[source]

Copy src_path to dst_path. If the operation is performed asynchronously, returns the link to the operation, otherwise, returns the link to the newly created resource.

Parameters:
  • src_path – source path

  • dst_path – destination path

  • overwrite – if True the destination path can be overwritten, otherwise, an error will be raised

  • force_async – forces the operation to be executed asynchronously

  • fields – list of keys to be included in the response

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

ResourceLinkObject or OperationLinkObject

async download(src_path: str, path_or_file: str | bytes | IO[bytes] | BinaryAsyncFileLike, /, **kwargs) ResourceLinkObject[source]

Download the file.

Parameters:
  • src_path – source path

  • path_or_file – destination path or file-like object

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

ResourceLinkObject, link to the source resource

Download the file from the link.

Parameters:
  • link – download link

  • file_or_path – destination path or file-like object

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

async download_public(public_key: str, file_or_path: str | bytes | IO, /, **kwargs) PublicResourceLinkObject[source]

Download the public resource.

Parameters:
  • public_key – public key or public URL of the resource

  • file_or_path – destination path or file-like object

  • path – relative path to the resource within the public folder

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

PublicResourceLinkObject

async exists(path: str, /, **kwargs) bool[source]

Check whether path exists.

Parameters:
  • path – path to the resource

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:

ForbiddenError – application doesn’t have enough rights for this request

Returns:

bool

get_auth_url(**kwargs) str[source]

Get authentication URL for the user to go to.

Parameters:
  • type – response type (“code” to get the confirmation code or “token” to get the token automatically)

  • device_id – unique device ID, must be between 6 and 50 characters

  • device_name – device name, should not be longer than 100 characters

  • display – indicates whether to use lightweight layout, values other than “popup” are ignored

  • login_hint – username or email for the account the token is being requested for

  • scope – list of permissions for the application

  • optional_scope – list of optional permissions for the application

  • force_confirm – if True, user will be required to confirm access to the account even if the user has already granted access for the application

  • state – The state string, which Yandex.OAuth returns without any changes (<= 1024 characters)

Returns:

authentication URL

get_code_url(**kwargs) str[source]

Get the URL for the user to get the confirmation code. The confirmation code can later be used to get the token.

Parameters:
  • device_id – unique device ID, must be between 6 and 50 characters

  • device_name – device name, should not be longer than 100 characters

  • display – indicates whether to use lightweight layout, values other than “popup” are ignored

  • login_hint – username or email for the account the token is being requested for

  • scope – list of permissions for the application

  • optional_scope – list of optional permissions for the application

  • force_confirm – if True, user will be required to confirm access to the account even if the user has already granted access for the application

  • state – The state string, which Yandex.OAuth returns without any changes (<= 1024 characters)

Returns:

authentication URL

async get_disk_info(**kwargs) DiskInfoObject[source]

Get disk information.

Parameters:
  • fields – list of keys to be included in the response

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:

ForbiddenError – application doesn’t have enough rights for this request

Returns:

DiskInfoObject

Get a download link for a file (or a directory).

Parameters:
  • path – path to the resource

  • fields – list of keys to be included in the response

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

str

async get_files(**kwargs) AsyncGenerator[ResourceObject, None][source]

Get a flat list of all files (that doesn’t include directories).

Parameters:
  • offset – offset from the beginning of the list

  • limit – number of list elements to be included

  • media_type – type of files to include in the list

  • sortstr, field to be used as a key to sort children resources

  • preview_size – size of the file preview

  • preview_cropbool, cut the preview to the size specified in the preview_size

  • fields – list of keys to be included in the response

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:

ForbiddenError – application doesn’t have enough rights for this request

Returns:

generator of ResourceObject

async get_last_uploaded(**kwargs) AsyncGenerator[ResourceObject, None][source]

Get the list of latest uploaded files sorted by upload date.

Parameters:
  • limit – maximum number of elements in the list

  • media_type – type of files to include in the list

  • preview_size – size of the file preview

  • preview_cropbool, cut the preview to the size specified in the preview_size

  • fields – list of keys to be included in the response

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:

ForbiddenError – application doesn’t have enough rights for this request

Returns:

generator of ResourceObject

async get_meta(path: str, /, **kwargs) ResourceObject[source]

Get meta information about a file/directory.

Parameters:
  • path – path to the resource

  • limit – number of children resources to be included in the response

  • offset – number of children resources to be skipped in the response

  • preview_size – size of the file preview

  • preview_cropbool, cut the preview to the size specified in the preview_size

  • sortstr, field to be used as a key to sort children resources

  • fields – list of keys to be included in the response

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

ResourceObject

async get_operation_status(operation_id, **kwargs)[source]

Get operation status.

Parameters:
  • operation_id – ID of the operation or a link

  • fields – list of keys to be included in the response

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:

OperationNotFoundError – requested operation was not found

Returns:

str

Get a download link for a public resource.

Parameters:
  • public_key – public key or public URL of the resource

  • path – relative path to the resource within the public folder

  • fields – list of keys to be included in the response

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

str

async get_public_meta(public_key: str, /, **kwargs) PublicResourceObject[source]

Get meta-information about a public resource.

Parameters:
  • public_key – public key or public URL of the resource

  • path – relative path to a resource in a public folder. By specifying the key of the published folder in public_key, you can request metainformation for any resource in the folder.

  • offset – offset from the beginning of the list of nested resources

  • limit – maximum number of nested elements to be included in the list

  • sortstr, field to be used as a key to sort children resources

  • preview_size – file preview size

  • preview_cropbool, allow preview crop

  • fields – list of keys to be included in the response

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

PublicResourceObject

async get_public_resources(**kwargs) PublicResourcesListObject[source]

Get a list of public resources.

Parameters:
  • offset – offset from the beginning of the list

  • limit – maximum number of elements in the list

  • preview_size – size of the file preview

  • preview_cropbool, cut the preview to the size specified in the preview_size

  • type – filter based on type of resources (“file” or “dir”)

  • fields – list of keys to be included in the response

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:

ForbiddenError – application doesn’t have enough rights for this request

Returns:

PublicResourcesListObject

async get_public_type(public_key: str, /, **kwargs) str[source]

Get public resource type.

Parameters:
  • public_key – public key or public URL of the resource

  • path – relative path to the resource within the public folder

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

“file” or “dir”

get_session(token: str | None = None) SessionWithHeaders[source]

Like YaDisk.make_session but cached.

Returns:

aiohttp.ClientSession, different instances for different threads

async get_token(code: str, /, **kwargs) TokenObject[source]

Get a new token.

Parameters:
  • code – confirmation code

  • device_id – unique device ID (between 6 and 50 characters)

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:

BadRequestError – invalid or expired code, application ID or secret

Returns:

TokenObject

async get_trash_meta(path: str, /, **kwargs) TrashResourceObject[source]

Get meta information about a trash resource.

Parameters:
  • path – path to the trash resource

  • limit – number of children resources to be included in the response

  • offset – number of children resources to be skipped in the response

  • preview_size – size of the file preview

  • preview_cropbool, cut the preview to the size specified in the preview_size

  • sortstr, field to be used as a key to sort children resources

  • fields – list of keys to be included in the response

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

TrashResourceObject

async get_trash_type(path: str, /, **kwargs) str[source]

Get trash resource type.

Parameters:
  • path – path to the trash resource

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

“file” or “dir”

async get_type(path: str, /, **kwargs) str[source]

Get resource type.

Parameters:
  • path – path to the resource

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

“file” or “dir”

Get a link to upload the file using the PUT request.

Parameters:
  • path – destination path

  • overwritebool, determines whether to overwrite the destination

  • fields – list of keys to be included in the response

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

str

async is_dir(path: str, /, **kwargs) bool[source]

Check whether path is a directory.

Parameters:
  • path – path to the resource

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:

ForbiddenError – application doesn’t have enough rights for this request

Returns:

True if path is a directory, False otherwise (even if it doesn’t exist)

async is_file(path: str, /, **kwargs) bool[source]

Check whether path is a file.

Parameters:
  • path – path to the resource

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:

ForbiddenError – application doesn’t have enough rights for this request

Returns:

True if path is a file, False otherwise (even if it doesn’t exist)

async is_public_dir(public_key: str, /, **kwargs) bool[source]

Check whether public_key is a public directory.

Parameters:
  • public_key – public key or public URL of the resource

  • path – relative path to the resource within the public folder

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:

ForbiddenError – application doesn’t have enough rights for this request

Returns:

True if public_key is a directory, False otherwise (even if it doesn’t exist)

async is_public_file(public_key: str, /, **kwargs) bool[source]

Check whether public_key is a public file.

Parameters:
  • public_key – public key or public URL of the resource

  • path – relative path to the resource within the public folder

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:

ForbiddenError – application doesn’t have enough rights for this request

Returns:

True if public_key is a file, False otherwise (even if it doesn’t exist)

async is_trash_dir(path: str, /, **kwargs) bool[source]

Check whether path is a trash directory.

Parameters:
  • path – path to the trash resource

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:

ForbiddenError – application doesn’t have enough rights for this request

Returns:

True if path is a directory, False otherwise (even if it doesn’t exist)

async is_trash_file(path: str, /, **kwargs) bool[source]

Check whether path is a trash file.

Parameters:
  • path – path to the trash resource

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:

ForbiddenError – application doesn’t have enough rights for this request

Returns:

True if path is a directory, False otherwise (even if it doesn’t exist)

async listdir(path: str, /, **kwargs) AsyncGenerator[ResourceObject, None][source]

Get contents of path.

Parameters:
  • path – path to the directory

  • limit – number of children resources to be included in the response

  • offset – number of children resources to be skipped in the response

  • preview_size – size of the file preview

  • preview_cropbool, cut the preview to the size specified in the preview_size

  • fields – list of keys to be included in the response

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

generator of ResourceObject

make_session(token: str | None = None) SessionWithHeaders[source]

Prepares aiohttp.ClientSession object with headers needed for API.

Parameters:

token – application token, equivalent to self.token if None

Returns:

aiohttp.ClientSession

async mkdir(path: str, /, **kwargs) ResourceLinkObject[source]

Create a new directory.

Parameters:
  • path – path to the directory to be created

  • fields – list of keys to be included in the response

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

ResourceLinkObject

async move(src_path: str, dst_path: str, /, **kwargs) OperationLinkObject | ResourceLinkObject[source]

Move src_path to dst_path.

Parameters:
  • src_path – source path to be moved

  • dst_path – destination path

  • overwritebool, determines whether to overwrite the destination

  • force_async – forces the operation to be executed asynchronously

  • fields – list of keys to be included in the response

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

ResourceLinkObject or OperationLinkObject

async patch(path: str, properties: dict, /, **kwargs) ResourceObject[source]

Update custom properties of a resource.

Parameters:
  • path – path to the resource

  • propertiesdict, custom properties to update

  • fields – list of keys to be included in the response

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

ResourceObject

async public_exists(public_key: str, /, **kwargs) bool[source]

Check whether the public resource exists.

Parameters:
  • public_key – public key or public URL of the resource

  • path – relative path to the resource within the public folder

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:

ForbiddenError – application doesn’t have enough rights for this request

Returns:

bool

async public_listdir(public_key: str, /, **kwargs) AsyncGenerator[PublicResourceObject, None][source]

Get contents of a public directory.

Parameters:
  • public_key – public key or public URL of the resource

  • path – relative path to the resource in the public folder. By specifying the key of the published folder in public_key, you can request contents of any nested folder.

  • limit – number of children resources to be included in the response

  • offset – number of children resources to be skipped in the response

  • preview_size – size of the file preview

  • preview_cropbool, cut the preview to the size specified in the preview_size

  • fields – list of keys to be included in the response

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

generator of PublicResourceObject

async publish(path: str, /, **kwargs) ResourceLinkObject[source]

Make a resource public.

Parameters:
  • path – path to the resource to be published

  • fields – list of keys to be included in the response

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

ResourceLinkObject, link to the resource

async refresh_token(refresh_token: str, /, **kwargs) TokenObject[source]

Refresh an existing token.

Parameters:
  • refresh_token – the refresh token that was received with the token

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:

BadRequestError – invalid or expired refresh token, application ID or secret

Returns:

TokenObject

async remove(path: str, /, **kwargs) OperationLinkObject | None[source]

Remove the resource.

Parameters:
  • path – path to the resource to be removed

  • permanently – if True, the resource will be removed permanently, otherwise, it will be just moved to the trash

  • md5str, MD5 hash of the file to remove

  • force_async – forces the operation to be executed asynchronously

  • fields – list of keys to be included in the response

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

OperationLinkObject if the operation is performed asynchronously, None otherwise

async remove_trash(path: str, /, **kwargs) OperationLinkObject | None[source]

Remove a trash resource.

Parameters:
  • path – path to the trash resource to be deleted

  • force_async – forces the operation to be executed asynchronously

  • fields – list of keys to be included in the response

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

OperationLinkObject if the operation is performed asynchronously, None otherwise

async rename(src_path: str, new_name: str, /, **kwargs) ResourceLinkObject | OperationLinkObject[source]

Rename src_path to have filename new_name. Does the same as move() but changes only the filename.

Parameters:
  • src_path – source path to be moved

  • new_name – target filename to rename to

  • overwritebool, determines whether to overwrite the destination

  • force_async – forces the operation to be executed asynchronously

  • fields – list of keys to be included in the response

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

ResourceLinkObject or OperationLinkObject

async restore_trash(path: str, dst_path: str | None = None, /, **kwargs) ResourceLinkObject | OperationLinkObject[source]

Restore a trash resource. Returns a link to the newly created resource or a link to the asynchronous operation.

Parameters:
  • path – path to the trash resource to restore

  • dst_path – destination path

  • overwritebool, determines whether the destination can be overwritten

  • force_async – forces the operation to be executed asynchronously

  • fields – list of keys to be included in the response

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

ResourceLinkObject or OperationLinkObject

async revoke_token(token: str | None = None, /, **kwargs) TokenRevokeStatusObject[source]

Revoke the token.

Parameters:
  • token – token to revoke, equivalent to self.token if None

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:

BadRequestError – token cannot be revoked (not bound to this application, etc.)

Returns:

TokenRevokeStatusObject

async save_to_disk(public_key: str, /, **kwargs) ResourceLinkObject | OperationLinkObject[source]

Saves a public resource to the disk. Returns the link to the operation if it’s performed asynchronously, or a link to the resource otherwise.

Parameters:
  • public_key – public key or public URL of the resource

  • name – filename of the saved resource

  • path – path to the copied resource in the public folder

  • save_path – path to the destination directory (downloads directory by default)

  • force_async – forces the operation to be executed asynchronously

  • fields – list of keys to be included in the response

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

ResourceLinkObject or OperationLinkObject

async trash_exists(path: str, /, **kwargs) bool[source]

Check whether the trash resource at path exists.

Parameters:
  • path – path to the trash resource

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:

ForbiddenError – application doesn’t have enough rights for this request

Returns:

bool

async trash_listdir(path: str, /, **kwargs) AsyncGenerator[TrashResourceObject, None][source]

Get contents of a trash resource.

Parameters:
  • path – path to the directory in the trash bin

  • limit – number of children resources to be included in the response

  • offset – number of children resources to be skipped in the response

  • preview_size – size of the file preview

  • preview_cropbool, cut the preview to the size specified in the preview_size

  • fields – list of keys to be included in the response

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

generator of TrashResourceObject

async unpublish(path: str, /, **kwargs) ResourceLinkObject[source]

Make a public resource private.

Parameters:
  • path – path to the resource to be unpublished

  • fields – list of keys to be included in the response

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

ResourceLinkObject

async upload(path_or_file: str | bytes | IO | AsyncFileLike | Callable[[], AsyncIterable[bytes]], dst_path: str, /, **kwargs) ResourceLinkObject[source]

Upload a file to disk.

Parameters:
  • path_or_file – path, file-like object or an async generator function to be uploaded

  • dst_path – destination path

  • overwrite – if True, the resource will be overwritten if it already exists, an error will be raised otherwise

  • fields – list of keys to be included in the response

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

ResourceLinkObject, link to the destination resource

Upload a file to disk using an upload link.

Parameters:
  • file_or_path – path, file-like object or an async generator function to be uploaded

  • link – upload link

  • overwrite – if True, the resource will be overwritten if it already exists, an error will be raised otherwise

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:

InsufficientStorageError – cannot upload file due to lack of storage space

async upload_url(url: str, path: str, /, **kwargs) OperationLinkObject[source]

Upload a file from URL.

Parameters:
  • url – source URL

  • path – destination path

  • disable_redirectsbool, forbid redirects

  • fields – list of keys to be included in the response

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

OperationLinkObject, link to the asynchronous operation

General parameters

Almost all methods of YaDisk (the ones that accept **kwargs) accept some additional arguments:

  • n_retries - int, maximum number of retries for a request

  • retry_interval - float, delay between retries (in seconds)

  • headers - dict or None, additional request headers

aiohttp parameters like timeout, proxies, etc. are also accepted (see aiohttp.request()).

This also applies to low-level functions and API request objects as well.

Settings

The following settings can be accessed and changed at runtime in yadisk_async.settings module:

  • DEFAULT_TIMEOUT - aiohttp.ClientTimeout, default timeout for requests.

  • DEFAULT_N_RETRIES - int, default number of retries

  • DEFAULT_RETRY_INTERVAL - float, default retry interval

  • DEFAULT_UPLOAD_TIMEOUT - analogous to DEFAULT_TIMEOUT but for upload function

  • DEFAULT_UPLOAD_RETRY_INTERVAL - analogous to DEFAULT_RETRY_INTERVAL but for upload function

Exceptions

Aside from the exceptions listed below, API requests can also raise exceptions in aiohttp.

exception yadisk_async.exceptions.BadGatewayError(error_type=None, msg='', response=None)[source]

Bases: RetriableYaDiskError

Thrown when the server returns code 502

exception yadisk_async.exceptions.BadRequestError(error_type=None, msg='', response=None)[source]

Bases: YaDiskError

Thrown when the server returns code 400.

exception yadisk_async.exceptions.ConflictError(error_type=None, msg='', response=None)[source]

Bases: YaDiskError

Thrown when the server returns code 409.

exception yadisk_async.exceptions.DirectoryExistsError(error_type=None, msg='', response=None)[source]

Bases: PathExistsError

Thrown when the directory already exists.

exception yadisk_async.exceptions.FieldValidationError(error_type=None, msg='', response=None)[source]

Bases: BadRequestError

Thrown when the request contains fields with invalid data.

exception yadisk_async.exceptions.ForbiddenError(error_type=None, msg='', response=None)[source]

Bases: YaDiskError

Thrown when the server returns code 403.

exception yadisk_async.exceptions.GatewayTimeoutError(error_type=None, msg='', response=None)[source]

Bases: RetriableYaDiskError

Thrown when the server returns code 504

exception yadisk_async.exceptions.InsufficientStorageError(error_type=None, msg='', response=None)[source]

Bases: YaDiskError

Thrown when the server returns code 507.

exception yadisk_async.exceptions.InternalServerError(error_type=None, msg='', response=None)[source]

Bases: RetriableYaDiskError

Thrown when the server returns code 500.

exception yadisk_async.exceptions.InvalidResponseError(error_type=None, msg='', response=None)[source]

Bases: YaDiskError

Thrown when Yandex.Disk did not return a JSON response or if it’s invalid.

exception yadisk_async.exceptions.LockedError(error_type=None, msg='', response=None)[source]

Bases: YaDiskError

Thrown when the server returns code 423.

exception yadisk_async.exceptions.MD5DifferError(error_type=None, msg='', response=None)[source]

Bases: ConflictError

Thrown when the MD5 hash of the file to be deleted doesn’t match with the actual one.

exception yadisk_async.exceptions.NotAcceptableError(error_type=None, msg='', response=None)[source]

Bases: YaDiskError

Thrown when the server returns code 406.

exception yadisk_async.exceptions.NotFoundError(error_type=None, msg='', response=None)[source]

Bases: YaDiskError

Thrown when the server returns code 404.

exception yadisk_async.exceptions.OperationNotFoundError(error_type=None, msg='', response=None)[source]

Bases: NotFoundError

Thrown by get_operation_status() when the operation doesn’t exist.

exception yadisk_async.exceptions.ParentNotFoundError(error_type=None, msg='', response=None)[source]

Bases: ConflictError

Thrown by mkdir, upload, etc. when the parent directory doesn’t exist.

exception yadisk_async.exceptions.PathExistsError(error_type=None, msg='', response=None)[source]

Bases: ConflictError

Thrown when the requested path already exists.

exception yadisk_async.exceptions.PathNotFoundError(error_type=None, msg='', response=None)[source]

Bases: NotFoundError

Thrown when the requested path does not exist.

exception yadisk_async.exceptions.PayloadTooLargeError(error_type=None, msg='', response=None)[source]

Bases: YaDiskError

Thrown when the server returns code 413.

exception yadisk_async.exceptions.ResourceIsLockedError(error_type=None, msg='', response=None)[source]

Bases: LockedError

Thrown when the resource is locked by another operation.

exception yadisk_async.exceptions.RetriableYaDiskError(error_type=None, msg='', response=None)[source]

Bases: YaDiskError

Thrown when there was an error but it would make sense to retry the request.

exception yadisk_async.exceptions.TooManyRequestsError(error_type=None, msg='', response=None)[source]

Bases: YaDiskError

Thrown when the server returns code 429.

exception yadisk_async.exceptions.UnauthorizedError(error_type=None, msg='', response=None)[source]

Bases: YaDiskError

Thrown when the server returns code 401.

exception yadisk_async.exceptions.UnavailableError(error_type=None, msg='', response=None)[source]

Bases: RetriableYaDiskError

Thrown when the server returns code 503.

exception yadisk_async.exceptions.UnknownYaDiskError(msg='', response=None)[source]

Bases: RetriableYaDiskError

Thrown when the request failed but the response does not contain any error info.

exception yadisk_async.exceptions.UnsupportedMediaError(error_type=None, msg='', response=None)[source]

Bases: YaDiskError

Thrown when the server returns code 415.

exception yadisk_async.exceptions.UploadTrafficLimitExceededError(error_type=None, msg='', response=None)[source]

Bases: LockedError

Thrown when upload limit has been exceeded.

exception yadisk_async.exceptions.WrongResourceTypeError(msg='')[source]

Bases: YaDiskError

Thrown when the resource was expected to be of different type (e.g., file instead of directory).

exception yadisk_async.exceptions.YaDiskError(error_type=None, msg='', response=None)[source]

Bases: Exception

Base class for all exceptions in this library.

Variables:
Parameters:
  • error_typestr, unique error code as returned by API

  • msgstr, exception message

  • response – an instance of aiohttp.ClientResponse

Objects

class yadisk_async.objects.YaDiskObject(field_types: dict | None = None, yadisk: YaDisk | None = None)[source]

Base class for all objects mirroring the ones returned by Yandex.Disk REST API. It must have a fixed number of fields, each field must have a type. It also supports subscripting and access of fields through the . operator.

Parameters:
  • field_typesdict or None

  • yadiskYaDisk or None, YaDisk object

import_fields(source_dict: dict | None) None[source]

Set all the fields of the object to the values in source_dict. All the other fields are ignored

Parameters:

source_dictdict or None (nothing will be done in that case)

remove_alias(alias: str) None[source]

Remove an alias.

Parameters:

aliasstr

remove_field(field: str) None[source]

Remove field.

Parameters:

fieldstr

set_alias(alias: str, name: str) None[source]

Set an alias.

Parameters:
  • aliasstr, alias to add

  • namestr, field name

set_field_type(field: str, type: Callable) None[source]

Set field type.

Parameters:
  • fieldstr

  • type – type or factory

set_field_types(field_types: dict) None[source]

Set the field types of the object

Parameters:

field_typesdict, where keys are the field names and values are types (or factories)

class yadisk_async.objects.ErrorObject(error=None)[source]

Bases: YaDiskObject

Mirrors Yandex.Disk REST API error object.

Parameters:

errordict or None

Variables:
  • messagestr, human-readable error message

  • descriptionstr, technical error description

  • errorstr, error code

class yadisk_async.objects.auth.TokenObject(token: dict | None = None, yadisk: YaDisk | None = None)[source]

Bases: YaDiskObject

Token object.

Parameters:
  • tokendict or None

  • yadiskYaDisk or None, YaDisk object

Variables:
  • access_tokenstr, token string

  • refresh_tokenstr, the refresh-token

  • token_typestr, type of the token

  • expires_inint, amount of time before the token expires

class yadisk_async.objects.auth.TokenRevokeStatusObject(token_revoke_status: dict | None = None, yadisk: YaDisk | None = None)[source]

Bases: YaDiskObject

Result of token revocation request.

Parameters:
  • token_revoke_statusdict or None

  • yadiskYaDisk or None, YaDisk object

Variables:

statusstr, status of the operation

class yadisk_async.objects.disk.DiskInfoObject(disk_info: dict | None = None, yadisk: YaDisk | None = None)[source]

Bases: YaDiskObject

Disk information object.

Parameters:
  • disk_infodict or None

  • yadiskYaDisk or None, YaDisk object

Variables:
  • max_file_sizeint, maximum supported file size (bytes)

  • paid_max_file_sizeint, maximum supported file size for a paid account (bytes)

  • unlimited_autoupload_enabledbool, tells whether unlimited autoupload from mobile devices is enabled

  • total_spaceint, total disk size (bytes)

  • trash_sizeint, amount of space used by trash (bytes), part of used_space

  • is_paidbool, tells if the account is paid or not

  • used_spaceint, amount of space used (bytes)

  • system_foldersSystemFoldersObject, paths to the system folders

  • userUserObject, owner of the disk

  • revisionint, current revision of Yandex.Disk

class yadisk_async.objects.disk.SystemFoldersObject(system_folders: dict | None = None, yadisk: YaDisk | None = None)[source]

Bases: YaDiskObject

Object, containing paths to system folders.

Parameters:
  • system_foldersdict or None

  • yadiskYaDisk or None, YaDisk object

Variables:
  • odnoklassnikistr, path to the Odnoklassniki folder

  • googlestr, path to the Google+ folder

  • instagramstr, path to the Instagram folder

  • vkontaktestr, path to the VKontakte folder

  • attachstr, path to the mail attachments folder

  • mailrustr, path to the My World folder

  • downloadsstr, path to the Downloads folder

  • applicationsstr path to the Applications folder

  • facebookstr, path to the Facebook folder

  • socialstr, path to the social networks folder

  • messengerstr, path to the Messenger Files folder

  • calendarstr, path to the Meeting Materials folder

  • photostreamstr, path to the camera folder

  • screenshotsstr, path to the screenshot folder

  • scansstr, path to the Scans folder

class yadisk_async.objects.disk.UserObject(user: dict | None = None, yadisk: YaDisk | None = None)[source]

Bases: YaDiskObject

User object.

Parameters:
  • userdict or None

  • yadiskYaDisk or None, YaDisk object

Variables:
  • countrystr, user’s country

  • loginstr, user’s login

  • display_namestr, user’s display name

  • uidstr, user’s UID

class yadisk_async.objects.disk.UserPublicInfoObject(public_user_info: dict | None = None, yadisk: YaDisk | None = None)[source]

Bases: UserObject

Public user information object. Inherits from UserObject for compatibility.

Parameters:
  • public_user_infodict or None

  • yadiskYaDisk or None, YaDisk object

Variables:
  • loginstr, user’s login

  • display_namestr, user’s display name

  • uidstr, user’s UID

class yadisk_async.objects.resources.CommentIDsObject(comment_ids: dict | None = None, yadisk: YaDisk | None = None)[source]

Bases: YaDiskObject

Comment IDs object.

Parameters:
  • comment_idsdict or None

  • yadiskYaDisk or None, YaDisk object

Variables:
  • private_resourcestr, comment ID for private resources

  • public_resourcestr, comment ID for public resources

class yadisk_async.objects.resources.EXIFObject(exif: dict | None = None, yadisk: YaDisk | None = None)[source]

Bases: YaDiskObject

EXIF metadata object.

Parameters:
  • exifdict or None

  • yadiskYaDisk or None, YaDisk object

Variables:

date_timedatetime.datetime, capture date

class yadisk_async.objects.resources.FilesResourceListObject(files_resource_list: dict | None = None, yadisk: YaDisk | None = None)[source]

Bases: YaDiskObject

Flat list of files.

Parameters:
  • files_resource_listdict or None

  • yadiskYaDisk or None, YaDisk object

Variables:
  • itemslist, flat list of files (ResourceObject)

  • limitint, maximum number of elements in the list

  • offsetint, offset from the beginning of the list

class yadisk_async.objects.resources.LastUploadedResourceListObject(last_uploaded_resources_list: dict | None = None, yadisk: YaDisk | None = None)[source]

Bases: YaDiskObject

List of last uploaded resources.

Parameters:
  • last_uploaded_resources_listdict or None

  • yadiskYaDisk or None, YaDisk object

Variables:
  • itemslist, list of resources (ResourceObject)

  • limitint, maximum number of elements in the list

class yadisk_async.objects.resources.LinkObject(link: dict | None = None, yadisk: YaDisk | None = None)[source]

Bases: YaDiskObject

Link object.

Parameters:
  • linkdict or None

  • yadiskYaDisk or None, YaDisk object

Variables:
  • hrefstr, link URL

  • methodstr, HTTP method

  • templatedbool, tells whether the URL is templated

class yadisk_async.objects.resources.OperationLinkObject(link: dict | None = None, yadisk: YaDisk | None = None)[source]

Bases: LinkObject

Operation link object.

Parameters:
  • linkdict or None

  • yadiskYaDisk or None, YaDisk object

Variables:
  • hrefstr, link URL

  • methodstr, HTTP method

  • templatedbool, tells whether the URL is templated

async get_status(**kwargs) str[source]

Get operation status.

Parameters:
  • fields – list of keys to be included in the response

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:

OperationNotFoundError – requested operation was not found

Returns:

str

class yadisk_async.objects.resources.PublicResourceLinkObject(link: dict | None = None, yadisk: YaDisk | None = None)[source]

Bases: LinkObject, ResourceObjectMethodsMixin

Public resource link object.

Parameters:
  • linkdict or None

  • yadiskYaDisk or None, YaDisk object

Variables:
  • hrefstr, link URL

  • methodstr, HTTP method

  • templatedbool, tells whether the URL is templated

  • public_keystr, public key of the resource

  • public_urlstr, public URL of the resource

async copy(*args, **kwargs) ResourceLinkObject | OperationLinkObject

Copy resource to dst_path. If the operation is performed asynchronously, returns the link to the operation, otherwise, returns the link to the newly created resource.

This method takes 1 or 2 positional arguments:

  1. copy(dst_path, /, **kwargs)

  2. copy(relative_path, dst_path, /, **kwargs)

Parameters:
  • src_pathstr or None, source path relative to the resource

  • dst_path – destination path

  • overwrite – if True the destination path can be overwritten, otherwise, an error will be raised

  • force_async – forces the operation to be executed asynchronously

  • fields – list of keys to be included in the response

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

ResourceLinkObject or OperationLinkObject

async download(*args, **kwargs) ResourceLinkObject

Download the file. This method takes 1 or 2 positional arguments:

  1. download(dst_path_or_file, /, **kwargs)

  2. download(relative_path, dst_path_or_file, /, **kwargs)

If relative_path is empty or None (or not specified) this method will try to use the file attribute as a download link.

Parameters:
  • relative_pathstr or None, source path relative to the resource

  • dst_path_or_file – destination path or file-like object

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

ResourceLinkObject, link to the source resource

async exists(relative_path: str | None = None, /, **kwargs) bool

Check whether resource exists.

Parameters:
  • relative_pathstr or None, relative path from the resource

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:

ForbiddenError – application doesn’t have enough rights for this request

Returns:

bool

Get a download link for a file (or a directory).

Parameters:
  • relative_pathstr or None, path relative to the resource

  • fields – list of keys to be included in the response

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

str

async get_meta(relative_path: str | None = None, /, **kwargs) ResourceObject

Get meta information about a file/directory.

Parameters:
  • relative_pathstr or None, relative path from resource

  • limit – number of children resources to be included in the response

  • offset – number of children resources to be skipped in the response

  • preview_size – size of the file preview

  • preview_cropbool, cut the preview to the size specified in the preview_size

  • sortstr, field to be used as a key to sort children resources

  • fields – list of keys to be included in the response

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

ResourceObject

async get_public_meta(**kwargs) PublicResourceObject

Get meta-information about a public resource.

Parameters:
  • path – relative path to a resource in a public folder.

  • offset – offset from the beginning of the list of nested resources

  • limit – maximum number of nested elements to be included in the list

  • sortstr, field to be used as a key to sort children resources

  • preview_size – file preview size

  • preview_cropbool, allow preview crop

  • fields – list of keys to be included in the response

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

PublicResourceObject

async get_type(relative_path: str | None = None, /, **kwargs) str

Get resource type.

Parameters:
  • relative_path – relative path from the resource

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

“file” or “dir”

Get a link to upload the file using the PUT request.

Parameters:
  • relative_pathstr or None, relative path to the resource

  • overwritebool, determines whether to overwrite the destination

  • fields – list of keys to be included in the response

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

str

async is_dir(relative_path: str | None = None, /, **kwargs) bool

Check whether resource is a directory.

Parameters:
  • relative_path – relative path from the resource

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:

ForbiddenError – application doesn’t have enough rights for this request

Returns:

True if path is a directory, False otherwise (even if it doesn’t exist)

async is_file(relative_path: str | None = None, /, **kwargs) bool

Check whether resource is a file.

Parameters:
  • relative_path – relative path from the resource

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:

ForbiddenError – application doesn’t have enough rights for this request

Returns:

True if path is a file, False otherwise (even if it doesn’t exist)

async listdir(relative_path: str | None = None, /, **kwargs) AsyncGenerator[ResourceObject, None]

Get contents of the resource.

Parameters:
  • relative_path – relative path from resource

  • limit – number of children resources to be included in the response

  • offset – number of children resources to be skipped in the response

  • preview_size – size of the file preview

  • preview_cropbool, cut the preview to the size specified in the preview_size

  • fields – list of keys to be included in the response

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

generator of ResourceObject

async mkdir(relative_path: str | None = None, /, **kwargs) ResourceLinkObject

Create a new directory.

Parameters:
  • relative_pathstr or None, relative path to the directory to be created

  • fields – list of keys to be included in the response

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

ResourceLinkObject

async move(*args, **kwargs) ResourceLinkObject | OperationLinkObject

Move resource to dst_path. This method takes 1 or 2 positional arguments:

  1. move(dst_path, /, **kwargs)

  2. move(relative_path, dst_path, /, **kwargs)

Parameters:
  • relative_pathstr or None, source path to be moved relative to the resource

  • dst_path – destination path

  • overwritebool, determines whether to overwrite the destination

  • force_async – forces the operation to be executed asynchronously

  • fields – list of keys to be included in the response

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

ResourceLinkObject or OperationLinkObject

async patch(*args, **kwargs) ResourceObject

Update custom properties of a resource. This method takes 1 or 2 positional arguments:

  1. patch(properties, /, **kwargs)

  2. patch(relative_path, properties, /, **kwargs)

Parameters:
  • relative_pathstr or None, path relative to the resource

  • propertiesdict, custom properties to update

  • fields – list of keys to be included in the response

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

ResourceObject

async public_listdir(**kwargs) AsyncGenerator[PublicResourceObject, None]

Get contents of a public directory.

Parameters:
  • path – relative path to the resource in the public folder.

  • limit – number of children resources to be included in the response

  • offset – number of children resources to be skipped in the response

  • preview_size – size of the file preview

  • preview_cropbool, cut the preview to the size specified in the preview_size

  • fields – list of keys to be included in the response

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

generator of PublicResourceObject

async publish(relative_path: str | None = None, /, **kwargs) ResourceLinkObject

Make a resource public.

Parameters:
  • relative_pathstr or None, relative path to the resource to be published

  • fields – list of keys to be included in the response

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

ResourceLinkObject, link to the resource

async remove(relative_path: str | None = None, /, **kwargs) OperationLinkObject | None

Remove the resource.

Parameters:
  • relative_pathstr or None, relative path to the resource to be removed

  • permanently – if True, the resource will be removed permanently, otherwise, it will be just moved to the trash

  • md5str, MD5 hash of the file to remove

  • force_async – forces the operation to be executed asynchronously

  • fields – list of keys to be included in the response

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

OperationLinkObject if the operation is performed asynchronously, None otherwise

async rename(*args, **kwargs) ResourceLinkObject | OperationLinkObject

Rename src_path to have filename new_name. Does the same as move() but changes only the filename.

Parameters:
  • relative_pathstr or None, source path to be renamed relative to the resource

  • new_name – target filename to rename to

  • overwritebool, determines whether to overwrite the destination

  • force_async – forces the operation to be executed asynchronously

  • fields – list of keys to be included in the response

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

ResourceLinkObject or OperationLinkObject

async unpublish(relative_path: str | None = None, /, **kwargs) ResourceLinkObject

Make a public resource private.

Parameters:
  • relative_pathstr or None, relative path to the resource to be unpublished

  • fields – list of keys to be included in the response

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

ResourceLinkObject

async upload(path_or_file: str | bytes | IO | AsyncFileLike | Callable[[], AsyncIterable[bytes]], relative_path: str | None = None, /, **kwargs) ResourceLinkObject

Upload a file to disk.

Parameters:
  • path_or_file – path, file-like object or an async generator function to be uploaded

  • relative_pathstr or None, destination path relative to the resource

  • overwrite – if True, the resource will be overwritten if it already exists, an error will be raised otherwise

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

ResourceLinkObject, link to the destination resource

async upload_url(url: str, relative_path: str | None = None, /, **kwargs) OperationLinkObject

Upload a file from URL.

Parameters:
  • url – source URL

  • relative_pathstr or None, destination path relative to the resource

  • disable_redirectsbool, forbid redirects

  • fields – list of keys to be included in the response

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

OperationLinkObject, link to the asynchronous operation

class yadisk_async.objects.resources.PublicResourceListObject(public_resource_list: dict | None = None, yadisk: YaDisk | None = None)[source]

Bases: ResourceListObject

List of public resources.

Parameters:
  • public_resource_listdict or None

  • yadiskYaDisk or None, YaDisk object

Variables:
  • sortstr, sort type

  • itemslist, list of resources (ResourceObject)

  • limitint, maximum number of elements in the list

  • offsetint, offset from the beginning of the list

  • pathstr, path to the directory that contains the elements of the list

  • totalint, number of elements in the list

  • public_keystr, public key of the resource

class yadisk_async.objects.resources.PublicResourceObject(public_resource=None, yadisk=None)[source]

Bases: ResourceObject

Public resource object.

Parameters:
  • resourcedict or None

  • yadiskYaDisk or None, YaDisk object

Variables:
  • antivirus_statusstr, antivirus check status

  • filestr, download URL

  • sizeint, file size

  • public_keystr, public resource key

  • sha256str, SHA256 hash

  • md5str, MD5 hash

  • embeddedPublicResourceObject, list of nested resources

  • namestr, filename

  • exifEXIFObject, EXIF metadata

  • resource_idstr, resource ID

  • custom_propertiesdict, custom resource properties

  • public_urlstr, public URL

  • shareShareInfoObject, shared folder information

  • modifieddatetime.datetime, date of last modification

  • createddatetime.datetime, date of creation

  • photoslice_timedatetime.datetime, photo/video creation date

  • mime_typestr, MIME type

  • pathstr, path to the resource

  • previewstr, file preview URL

  • comment_idsCommentIDsObject, comment IDs

  • typestr, type (“file” or “dir”)

  • media_typestr, file type as determined by Yandex.Disk

  • revisionint, Yandex.Disk revision at the time of last modification

  • view_countint, number of times the public resource was viewed

  • ownerUserPublicInfoObject, owner of the public resource

async copy(*args, **kwargs) ResourceLinkObject | OperationLinkObject

Copy resource to dst_path. If the operation is performed asynchronously, returns the link to the operation, otherwise, returns the link to the newly created resource.

This method takes 1 or 2 positional arguments:

  1. copy(dst_path, /, **kwargs)

  2. copy(relative_path, dst_path, /, **kwargs)

Parameters:
  • src_pathstr or None, source path relative to the resource

  • dst_path – destination path

  • overwrite – if True the destination path can be overwritten, otherwise, an error will be raised

  • force_async – forces the operation to be executed asynchronously

  • fields – list of keys to be included in the response

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

ResourceLinkObject or OperationLinkObject

async download(*args, **kwargs) ResourceLinkObject

Download the file. This method takes 1 or 2 positional arguments:

  1. download(dst_path_or_file, /, **kwargs)

  2. download(relative_path, dst_path_or_file, /, **kwargs)

If relative_path is empty or None (or not specified) this method will try to use the file attribute as a download link.

Parameters:
  • relative_pathstr or None, source path relative to the resource

  • dst_path_or_file – destination path or file-like object

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

ResourceLinkObject, link to the source resource

async exists(relative_path: str | None = None, /, **kwargs) bool

Check whether resource exists.

Parameters:
  • relative_pathstr or None, relative path from the resource

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:

ForbiddenError – application doesn’t have enough rights for this request

Returns:

bool

Get a download link for a file (or a directory).

Parameters:
  • relative_pathstr or None, path relative to the resource

  • fields – list of keys to be included in the response

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

str

async get_meta(relative_path: str | None = None, /, **kwargs) ResourceObject

Get meta information about a file/directory.

Parameters:
  • relative_pathstr or None, relative path from resource

  • limit – number of children resources to be included in the response

  • offset – number of children resources to be skipped in the response

  • preview_size – size of the file preview

  • preview_cropbool, cut the preview to the size specified in the preview_size

  • sortstr, field to be used as a key to sort children resources

  • fields – list of keys to be included in the response

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

ResourceObject

async get_public_meta(**kwargs) PublicResourceObject

Get meta-information about a public resource.

Parameters:
  • path – relative path to a resource in a public folder.

  • offset – offset from the beginning of the list of nested resources

  • limit – maximum number of nested elements to be included in the list

  • sortstr, field to be used as a key to sort children resources

  • preview_size – file preview size

  • preview_cropbool, allow preview crop

  • fields – list of keys to be included in the response

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

PublicResourceObject

async get_type(relative_path: str | None = None, /, **kwargs) str

Get resource type.

Parameters:
  • relative_path – relative path from the resource

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

“file” or “dir”

Get a link to upload the file using the PUT request.

Parameters:
  • relative_pathstr or None, relative path to the resource

  • overwritebool, determines whether to overwrite the destination

  • fields – list of keys to be included in the response

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

str

async is_dir(relative_path: str | None = None, /, **kwargs) bool

Check whether resource is a directory.

Parameters:
  • relative_path – relative path from the resource

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:

ForbiddenError – application doesn’t have enough rights for this request

Returns:

True if path is a directory, False otherwise (even if it doesn’t exist)

async is_file(relative_path: str | None = None, /, **kwargs) bool

Check whether resource is a file.

Parameters:
  • relative_path – relative path from the resource

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:

ForbiddenError – application doesn’t have enough rights for this request

Returns:

True if path is a file, False otherwise (even if it doesn’t exist)

async listdir(relative_path: str | None = None, /, **kwargs) AsyncGenerator[ResourceObject, None]

Get contents of the resource.

Parameters:
  • relative_path – relative path from resource

  • limit – number of children resources to be included in the response

  • offset – number of children resources to be skipped in the response

  • preview_size – size of the file preview

  • preview_cropbool, cut the preview to the size specified in the preview_size

  • fields – list of keys to be included in the response

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

generator of ResourceObject

async mkdir(relative_path: str | None = None, /, **kwargs) ResourceLinkObject

Create a new directory.

Parameters:
  • relative_pathstr or None, relative path to the directory to be created

  • fields – list of keys to be included in the response

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

ResourceLinkObject

async move(*args, **kwargs) ResourceLinkObject | OperationLinkObject

Move resource to dst_path. This method takes 1 or 2 positional arguments:

  1. move(dst_path, /, **kwargs)

  2. move(relative_path, dst_path, /, **kwargs)

Parameters:
  • relative_pathstr or None, source path to be moved relative to the resource

  • dst_path – destination path

  • overwritebool, determines whether to overwrite the destination

  • force_async – forces the operation to be executed asynchronously

  • fields – list of keys to be included in the response

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

ResourceLinkObject or OperationLinkObject

async patch(*args, **kwargs) ResourceObject

Update custom properties of a resource. This method takes 1 or 2 positional arguments:

  1. patch(properties, /, **kwargs)

  2. patch(relative_path, properties, /, **kwargs)

Parameters:
  • relative_pathstr or None, path relative to the resource

  • propertiesdict, custom properties to update

  • fields – list of keys to be included in the response

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

ResourceObject

async public_listdir(**kwargs) AsyncGenerator[PublicResourceObject, None]

Get contents of a public directory.

Parameters:
  • path – relative path to the resource in the public folder.

  • limit – number of children resources to be included in the response

  • offset – number of children resources to be skipped in the response

  • preview_size – size of the file preview

  • preview_cropbool, cut the preview to the size specified in the preview_size

  • fields – list of keys to be included in the response

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

generator of PublicResourceObject

async publish(relative_path: str | None = None, /, **kwargs) ResourceLinkObject

Make a resource public.

Parameters:
  • relative_pathstr or None, relative path to the resource to be published

  • fields – list of keys to be included in the response

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

ResourceLinkObject, link to the resource

async remove(relative_path: str | None = None, /, **kwargs) OperationLinkObject | None

Remove the resource.

Parameters:
  • relative_pathstr or None, relative path to the resource to be removed

  • permanently – if True, the resource will be removed permanently, otherwise, it will be just moved to the trash

  • md5str, MD5 hash of the file to remove

  • force_async – forces the operation to be executed asynchronously

  • fields – list of keys to be included in the response

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

OperationLinkObject if the operation is performed asynchronously, None otherwise

async rename(*args, **kwargs) ResourceLinkObject | OperationLinkObject

Rename src_path to have filename new_name. Does the same as move() but changes only the filename.

Parameters:
  • relative_pathstr or None, source path to be renamed relative to the resource

  • new_name – target filename to rename to

  • overwritebool, determines whether to overwrite the destination

  • force_async – forces the operation to be executed asynchronously

  • fields – list of keys to be included in the response

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

ResourceLinkObject or OperationLinkObject

async unpublish(relative_path: str | None = None, /, **kwargs) ResourceLinkObject

Make a public resource private.

Parameters:
  • relative_pathstr or None, relative path to the resource to be unpublished

  • fields – list of keys to be included in the response

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

ResourceLinkObject

async upload(path_or_file: str | bytes | IO | AsyncFileLike | Callable[[], AsyncIterable[bytes]], relative_path: str | None = None, /, **kwargs) ResourceLinkObject

Upload a file to disk.

Parameters:
  • path_or_file – path, file-like object or an async generator function to be uploaded

  • relative_pathstr or None, destination path relative to the resource

  • overwrite – if True, the resource will be overwritten if it already exists, an error will be raised otherwise

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

ResourceLinkObject, link to the destination resource

async upload_url(url: str, relative_path: str | None = None, /, **kwargs) OperationLinkObject

Upload a file from URL.

Parameters:
  • url – source URL

  • relative_pathstr or None, destination path relative to the resource

  • disable_redirectsbool, forbid redirects

  • fields – list of keys to be included in the response

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

OperationLinkObject, link to the asynchronous operation

class yadisk_async.objects.resources.PublicResourcesListObject(public_resources_list: dict | None = None, yadisk: YaDisk | None = None)[source]

Bases: YaDiskObject

List of public resources.

Parameters:
  • public_resources_listdict or None

  • yadiskYaDisk or None, YaDisk object

Variables:
  • itemslist, list of public resources (PublicResourceObject)

  • typestr, resource type to filter by

  • limitint, maximum number of elements in the list

  • offsetint, offset from the beginning of the list

class yadisk_async.objects.resources.ResourceDownloadLinkObject(link: dict | None = None, yadisk: YaDisk | None = None)[source]

Bases: LinkObject

Resource download link.

Parameters:
  • linkdict or None

  • yadiskYaDisk or None, YaDisk object

Variables:
  • hrefstr, link URL

  • methodstr, HTTP method

  • templatedbool, tells whether the URL is templated

class yadisk_async.objects.resources.ResourceLinkObject(link: dict | None = None, yadisk: YaDisk | None = None)[source]

Bases: LinkObject, ResourceObjectMethodsMixin

Resource link object.

Parameters:
  • linkdict or None

  • yadiskYaDisk or None, YaDisk object

Variables:
  • hrefstr, link URL

  • methodstr, HTTP method

  • templatedbool, tells whether the URL is templated

  • pathstr, path to the resource

async copy(*args, **kwargs) ResourceLinkObject | OperationLinkObject

Copy resource to dst_path. If the operation is performed asynchronously, returns the link to the operation, otherwise, returns the link to the newly created resource.

This method takes 1 or 2 positional arguments:

  1. copy(dst_path, /, **kwargs)

  2. copy(relative_path, dst_path, /, **kwargs)

Parameters:
  • src_pathstr or None, source path relative to the resource

  • dst_path – destination path

  • overwrite – if True the destination path can be overwritten, otherwise, an error will be raised

  • force_async – forces the operation to be executed asynchronously

  • fields – list of keys to be included in the response

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

ResourceLinkObject or OperationLinkObject

async download(*args, **kwargs) ResourceLinkObject

Download the file. This method takes 1 or 2 positional arguments:

  1. download(dst_path_or_file, /, **kwargs)

  2. download(relative_path, dst_path_or_file, /, **kwargs)

If relative_path is empty or None (or not specified) this method will try to use the file attribute as a download link.

Parameters:
  • relative_pathstr or None, source path relative to the resource

  • dst_path_or_file – destination path or file-like object

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

ResourceLinkObject, link to the source resource

async exists(relative_path: str | None = None, /, **kwargs) bool

Check whether resource exists.

Parameters:
  • relative_pathstr or None, relative path from the resource

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:

ForbiddenError – application doesn’t have enough rights for this request

Returns:

bool

Get a download link for a file (or a directory).

Parameters:
  • relative_pathstr or None, path relative to the resource

  • fields – list of keys to be included in the response

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

str

async get_meta(relative_path: str | None = None, /, **kwargs) ResourceObject

Get meta information about a file/directory.

Parameters:
  • relative_pathstr or None, relative path from resource

  • limit – number of children resources to be included in the response

  • offset – number of children resources to be skipped in the response

  • preview_size – size of the file preview

  • preview_cropbool, cut the preview to the size specified in the preview_size

  • sortstr, field to be used as a key to sort children resources

  • fields – list of keys to be included in the response

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

ResourceObject

async get_public_meta(**kwargs) PublicResourceObject

Get meta-information about a public resource.

Parameters:
  • path – relative path to a resource in a public folder.

  • offset – offset from the beginning of the list of nested resources

  • limit – maximum number of nested elements to be included in the list

  • sortstr, field to be used as a key to sort children resources

  • preview_size – file preview size

  • preview_cropbool, allow preview crop

  • fields – list of keys to be included in the response

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

PublicResourceObject

async get_type(relative_path: str | None = None, /, **kwargs) str

Get resource type.

Parameters:
  • relative_path – relative path from the resource

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

“file” or “dir”

Get a link to upload the file using the PUT request.

Parameters:
  • relative_pathstr or None, relative path to the resource

  • overwritebool, determines whether to overwrite the destination

  • fields – list of keys to be included in the response

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

str

async is_dir(relative_path: str | None = None, /, **kwargs) bool

Check whether resource is a directory.

Parameters:
  • relative_path – relative path from the resource

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:

ForbiddenError – application doesn’t have enough rights for this request

Returns:

True if path is a directory, False otherwise (even if it doesn’t exist)

async is_file(relative_path: str | None = None, /, **kwargs) bool

Check whether resource is a file.

Parameters:
  • relative_path – relative path from the resource

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:

ForbiddenError – application doesn’t have enough rights for this request

Returns:

True if path is a file, False otherwise (even if it doesn’t exist)

async listdir(relative_path: str | None = None, /, **kwargs) AsyncGenerator[ResourceObject, None]

Get contents of the resource.

Parameters:
  • relative_path – relative path from resource

  • limit – number of children resources to be included in the response

  • offset – number of children resources to be skipped in the response

  • preview_size – size of the file preview

  • preview_cropbool, cut the preview to the size specified in the preview_size

  • fields – list of keys to be included in the response

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

generator of ResourceObject

async mkdir(relative_path: str | None = None, /, **kwargs) ResourceLinkObject

Create a new directory.

Parameters:
  • relative_pathstr or None, relative path to the directory to be created

  • fields – list of keys to be included in the response

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

ResourceLinkObject

async move(*args, **kwargs) ResourceLinkObject | OperationLinkObject

Move resource to dst_path. This method takes 1 or 2 positional arguments:

  1. move(dst_path, /, **kwargs)

  2. move(relative_path, dst_path, /, **kwargs)

Parameters:
  • relative_pathstr or None, source path to be moved relative to the resource

  • dst_path – destination path

  • overwritebool, determines whether to overwrite the destination

  • force_async – forces the operation to be executed asynchronously

  • fields – list of keys to be included in the response

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

ResourceLinkObject or OperationLinkObject

async patch(*args, **kwargs) ResourceObject

Update custom properties of a resource. This method takes 1 or 2 positional arguments:

  1. patch(properties, /, **kwargs)

  2. patch(relative_path, properties, /, **kwargs)

Parameters:
  • relative_pathstr or None, path relative to the resource

  • propertiesdict, custom properties to update

  • fields – list of keys to be included in the response

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

ResourceObject

async public_listdir(**kwargs) AsyncGenerator[PublicResourceObject, None]

Get contents of a public directory.

Parameters:
  • path – relative path to the resource in the public folder.

  • limit – number of children resources to be included in the response

  • offset – number of children resources to be skipped in the response

  • preview_size – size of the file preview

  • preview_cropbool, cut the preview to the size specified in the preview_size

  • fields – list of keys to be included in the response

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

generator of PublicResourceObject

async publish(relative_path: str | None = None, /, **kwargs) ResourceLinkObject

Make a resource public.

Parameters:
  • relative_pathstr or None, relative path to the resource to be published

  • fields – list of keys to be included in the response

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

ResourceLinkObject, link to the resource

async remove(relative_path: str | None = None, /, **kwargs) OperationLinkObject | None

Remove the resource.

Parameters:
  • relative_pathstr or None, relative path to the resource to be removed

  • permanently – if True, the resource will be removed permanently, otherwise, it will be just moved to the trash

  • md5str, MD5 hash of the file to remove

  • force_async – forces the operation to be executed asynchronously

  • fields – list of keys to be included in the response

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

OperationLinkObject if the operation is performed asynchronously, None otherwise

async rename(*args, **kwargs) ResourceLinkObject | OperationLinkObject

Rename src_path to have filename new_name. Does the same as move() but changes only the filename.

Parameters:
  • relative_pathstr or None, source path to be renamed relative to the resource

  • new_name – target filename to rename to

  • overwritebool, determines whether to overwrite the destination

  • force_async – forces the operation to be executed asynchronously

  • fields – list of keys to be included in the response

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

ResourceLinkObject or OperationLinkObject

async unpublish(relative_path: str | None = None, /, **kwargs) ResourceLinkObject

Make a public resource private.

Parameters:
  • relative_pathstr or None, relative path to the resource to be unpublished

  • fields – list of keys to be included in the response

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

ResourceLinkObject

async upload(path_or_file: str | bytes | IO | AsyncFileLike | Callable[[], AsyncIterable[bytes]], relative_path: str | None = None, /, **kwargs) ResourceLinkObject

Upload a file to disk.

Parameters:
  • path_or_file – path, file-like object or an async generator function to be uploaded

  • relative_pathstr or None, destination path relative to the resource

  • overwrite – if True, the resource will be overwritten if it already exists, an error will be raised otherwise

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

ResourceLinkObject, link to the destination resource

async upload_url(url: str, relative_path: str | None = None, /, **kwargs) OperationLinkObject

Upload a file from URL.

Parameters:
  • url – source URL

  • relative_pathstr or None, destination path relative to the resource

  • disable_redirectsbool, forbid redirects

  • fields – list of keys to be included in the response

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

OperationLinkObject, link to the asynchronous operation

class yadisk_async.objects.resources.ResourceListObject(resource_list: dict | None = None, yadisk: YaDisk | None = None)[source]

Bases: YaDiskObject

List of resources.

Parameters:
  • resource_listdict or None

  • yadiskYaDisk or None, YaDisk object

Variables:
  • sortstr, sort type

  • itemslist, list of resources (ResourceObject)

  • limitint, maximum number of elements in the list

  • offsetint, offset from the beginning of the list

  • pathstr, path to the directory that contains the elements of the list

  • totalint, number of elements in the list

class yadisk_async.objects.resources.ResourceObject(resource: dict | None = None, yadisk: YaDisk | None = None)[source]

Bases: YaDiskObject, ResourceObjectMethodsMixin

Resource object.

Parameters:
  • resourcedict or None

  • yadiskYaDisk or None, YaDisk object

Variables:
  • antivirus_statusstr, antivirus check status

  • filestr, download URL

  • sizeint, file size

  • public_keystr, public resource key

  • sha256str, SHA256 hash

  • md5str, MD5 hash

  • embeddedResourceListObject, list of nested resources

  • namestr, filename

  • exifEXIFObject, EXIF metadata

  • resource_idstr, resource ID

  • custom_propertiesdict, custom resource properties

  • public_urlstr, public URL

  • shareShareInfoObject, shared folder information

  • modifieddatetime.datetime, date of last modification

  • createddatetime.datetime, date of creation

  • photoslice_timedatetime.datetime, photo/video creation date

  • mime_typestr, MIME type

  • pathstr, path to the resource

  • previewstr, file preview URL

  • comment_idsCommentIDsObject, comment IDs

  • typestr, type (“file” or “dir”)

  • media_typestr, file type as determined by Yandex.Disk

  • revisionint, Yandex.Disk revision at the time of last modification

async copy(*args, **kwargs) ResourceLinkObject | OperationLinkObject

Copy resource to dst_path. If the operation is performed asynchronously, returns the link to the operation, otherwise, returns the link to the newly created resource.

This method takes 1 or 2 positional arguments:

  1. copy(dst_path, /, **kwargs)

  2. copy(relative_path, dst_path, /, **kwargs)

Parameters:
  • src_pathstr or None, source path relative to the resource

  • dst_path – destination path

  • overwrite – if True the destination path can be overwritten, otherwise, an error will be raised

  • force_async – forces the operation to be executed asynchronously

  • fields – list of keys to be included in the response

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

ResourceLinkObject or OperationLinkObject

async download(*args, **kwargs) ResourceLinkObject

Download the file. This method takes 1 or 2 positional arguments:

  1. download(dst_path_or_file, /, **kwargs)

  2. download(relative_path, dst_path_or_file, /, **kwargs)

If relative_path is empty or None (or not specified) this method will try to use the file attribute as a download link.

Parameters:
  • relative_pathstr or None, source path relative to the resource

  • dst_path_or_file – destination path or file-like object

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

ResourceLinkObject, link to the source resource

async exists(relative_path: str | None = None, /, **kwargs) bool

Check whether resource exists.

Parameters:
  • relative_pathstr or None, relative path from the resource

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:

ForbiddenError – application doesn’t have enough rights for this request

Returns:

bool

Get a download link for a file (or a directory).

Parameters:
  • relative_pathstr or None, path relative to the resource

  • fields – list of keys to be included in the response

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

str

async get_meta(relative_path: str | None = None, /, **kwargs) ResourceObject

Get meta information about a file/directory.

Parameters:
  • relative_pathstr or None, relative path from resource

  • limit – number of children resources to be included in the response

  • offset – number of children resources to be skipped in the response

  • preview_size – size of the file preview

  • preview_cropbool, cut the preview to the size specified in the preview_size

  • sortstr, field to be used as a key to sort children resources

  • fields – list of keys to be included in the response

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

ResourceObject

async get_public_meta(**kwargs) PublicResourceObject

Get meta-information about a public resource.

Parameters:
  • path – relative path to a resource in a public folder.

  • offset – offset from the beginning of the list of nested resources

  • limit – maximum number of nested elements to be included in the list

  • sortstr, field to be used as a key to sort children resources

  • preview_size – file preview size

  • preview_cropbool, allow preview crop

  • fields – list of keys to be included in the response

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

PublicResourceObject

async get_type(relative_path: str | None = None, /, **kwargs) str

Get resource type.

Parameters:
  • relative_path – relative path from the resource

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

“file” or “dir”

Get a link to upload the file using the PUT request.

Parameters:
  • relative_pathstr or None, relative path to the resource

  • overwritebool, determines whether to overwrite the destination

  • fields – list of keys to be included in the response

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

str

async is_dir(relative_path: str | None = None, /, **kwargs) bool

Check whether resource is a directory.

Parameters:
  • relative_path – relative path from the resource

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:

ForbiddenError – application doesn’t have enough rights for this request

Returns:

True if path is a directory, False otherwise (even if it doesn’t exist)

async is_file(relative_path: str | None = None, /, **kwargs) bool

Check whether resource is a file.

Parameters:
  • relative_path – relative path from the resource

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:

ForbiddenError – application doesn’t have enough rights for this request

Returns:

True if path is a file, False otherwise (even if it doesn’t exist)

async listdir(relative_path: str | None = None, /, **kwargs) AsyncGenerator[ResourceObject, None]

Get contents of the resource.

Parameters:
  • relative_path – relative path from resource

  • limit – number of children resources to be included in the response

  • offset – number of children resources to be skipped in the response

  • preview_size – size of the file preview

  • preview_cropbool, cut the preview to the size specified in the preview_size

  • fields – list of keys to be included in the response

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

generator of ResourceObject

async mkdir(relative_path: str | None = None, /, **kwargs) ResourceLinkObject

Create a new directory.

Parameters:
  • relative_pathstr or None, relative path to the directory to be created

  • fields – list of keys to be included in the response

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

ResourceLinkObject

async move(*args, **kwargs) ResourceLinkObject | OperationLinkObject

Move resource to dst_path. This method takes 1 or 2 positional arguments:

  1. move(dst_path, /, **kwargs)

  2. move(relative_path, dst_path, /, **kwargs)

Parameters:
  • relative_pathstr or None, source path to be moved relative to the resource

  • dst_path – destination path

  • overwritebool, determines whether to overwrite the destination

  • force_async – forces the operation to be executed asynchronously

  • fields – list of keys to be included in the response

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

ResourceLinkObject or OperationLinkObject

async patch(*args, **kwargs) ResourceObject

Update custom properties of a resource. This method takes 1 or 2 positional arguments:

  1. patch(properties, /, **kwargs)

  2. patch(relative_path, properties, /, **kwargs)

Parameters:
  • relative_pathstr or None, path relative to the resource

  • propertiesdict, custom properties to update

  • fields – list of keys to be included in the response

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

ResourceObject

async public_listdir(**kwargs) AsyncGenerator[PublicResourceObject, None]

Get contents of a public directory.

Parameters:
  • path – relative path to the resource in the public folder.

  • limit – number of children resources to be included in the response

  • offset – number of children resources to be skipped in the response

  • preview_size – size of the file preview

  • preview_cropbool, cut the preview to the size specified in the preview_size

  • fields – list of keys to be included in the response

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

generator of PublicResourceObject

async publish(relative_path: str | None = None, /, **kwargs) ResourceLinkObject

Make a resource public.

Parameters:
  • relative_pathstr or None, relative path to the resource to be published

  • fields – list of keys to be included in the response

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

ResourceLinkObject, link to the resource

async remove(relative_path: str | None = None, /, **kwargs) OperationLinkObject | None

Remove the resource.

Parameters:
  • relative_pathstr or None, relative path to the resource to be removed

  • permanently – if True, the resource will be removed permanently, otherwise, it will be just moved to the trash

  • md5str, MD5 hash of the file to remove

  • force_async – forces the operation to be executed asynchronously

  • fields – list of keys to be included in the response

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

OperationLinkObject if the operation is performed asynchronously, None otherwise

async rename(*args, **kwargs) ResourceLinkObject | OperationLinkObject

Rename src_path to have filename new_name. Does the same as move() but changes only the filename.

Parameters:
  • relative_pathstr or None, source path to be renamed relative to the resource

  • new_name – target filename to rename to

  • overwritebool, determines whether to overwrite the destination

  • force_async – forces the operation to be executed asynchronously

  • fields – list of keys to be included in the response

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

ResourceLinkObject or OperationLinkObject

async unpublish(relative_path: str | None = None, /, **kwargs) ResourceLinkObject

Make a public resource private.

Parameters:
  • relative_pathstr or None, relative path to the resource to be unpublished

  • fields – list of keys to be included in the response

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

ResourceLinkObject

async upload(path_or_file: str | bytes | IO | AsyncFileLike | Callable[[], AsyncIterable[bytes]], relative_path: str | None = None, /, **kwargs) ResourceLinkObject

Upload a file to disk.

Parameters:
  • path_or_file – path, file-like object or an async generator function to be uploaded

  • relative_pathstr or None, destination path relative to the resource

  • overwrite – if True, the resource will be overwritten if it already exists, an error will be raised otherwise

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

ResourceLinkObject, link to the destination resource

async upload_url(url: str, relative_path: str | None = None, /, **kwargs) OperationLinkObject

Upload a file from URL.

Parameters:
  • url – source URL

  • relative_pathstr or None, destination path relative to the resource

  • disable_redirectsbool, forbid redirects

  • fields – list of keys to be included in the response

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

OperationLinkObject, link to the asynchronous operation

class yadisk_async.objects.resources.ResourceUploadLinkObject(resource_upload_link: dict | None = None, yadisk: YaDisk | None = None)[source]

Bases: LinkObject

Resource upload link.

Parameters:
  • resource_upload_linkdict or None

  • yadiskYaDisk or None, YaDisk object

Variables:
  • operation_idstr, ID of the upload operation

  • hrefstr, link URL

  • methodstr, HTTP method

  • templatedbool, tells whether the URL is templated

class yadisk_async.objects.resources.ShareInfoObject(share_info: dict | None = None, yadisk: YaDisk | None = None)[source]

Bases: YaDiskObject

Shared folder information object.

Parameters:
  • share_infodict or None

  • yadiskYaDisk or None, YaDisk object

Variables:
  • is_rootbool, tells whether the folder is root

  • is_ownedbool, tells whether the user is the owner of this directory

  • rightsstr, access rights

class yadisk_async.objects.resources.TrashResourceListObject(trash_resource_list: dict | None = None, yadisk: YaDisk | None = None)[source]

Bases: ResourceListObject

List of trash resources.

Parameters:
  • trash_resource_listdict or None

  • yadiskYaDisk or None, YaDisk object

Variables:
  • sortstr, sort type

  • itemslist, list of resources (TrashResourceObject)

  • limitint, maximum number of elements in the list

  • offsetint, offset from the beginning of the list

  • pathstr, path to the directory that contains the elements of the list

  • totalint, number of elements in the list

class yadisk_async.objects.resources.TrashResourceObject(trash_resource: dict | None = None, yadisk: YaDisk | None = None)[source]

Bases: ResourceObject

Trash resource object.

Parameters:
  • trash_resourcedict or None

  • yadiskYaDisk or None, YaDisk object

Variables:
  • antivirus_statusstr, antivirus check status

  • filestr, download URL

  • sizeint, file size

  • public_keystr, public resource key

  • sha256str, SHA256 hash

  • md5str, MD5 hash

  • embeddedTrashResourceListObject, list of nested resources

  • namestr, filename

  • exifEXIFObject, EXIF metadata

  • resource_idstr, resource ID

  • custom_propertiesdict, custom resource properties

  • public_urlstr, public URL

  • shareShareInfoObject, shared folder information

  • modifieddatetime.datetime, date of last modification

  • createddatetime.datetime, date of creation

  • photoslice_timedatetime.datetime, photo/video creation date

  • mime_typestr, MIME type

  • pathstr, path to the resource

  • previewstr, file preview URL

  • comment_idsCommentIDsObject, comment IDs

  • typestr, type (“file” or “dir”)

  • media_typestr, file type as determined by Yandex.Disk

  • revisionint, Yandex.Disk revision at the time of last modification

  • origin_pathstr, original path

  • deleteddatetime.datetime, date of deletion

async exists(relative_path: str | None = None, /, **kwargs) bool[source]

Check whether the trash resource exists.

Parameters:
  • relative_pathstr or None, relative path to the trash resource

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:

ForbiddenError – application doesn’t have enough rights for this request

Returns:

bool

async get_meta(relative_path: str | None = None, /, **kwargs) TrashResourceObject[source]

Get meta information about a trash resource.

Parameters:
  • relative_pathstr or None, relative path to the trash resource

  • limit – number of children resources to be included in the response

  • offset – number of children resources to be skipped in the response

  • preview_size – size of the file preview

  • preview_cropbool, cut the preview to the size specified in the preview_size

  • sortstr, field to be used as a key to sort children resources

  • fields – list of keys to be included in the response

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

TrashResourceObject

async get_type(relative_path: str | None = None, /, **kwargs) str[source]

Get trash resource type.

Parameters:
  • relative_pathstr or None, relative path to the trash resource

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

“file” or “dir”

async is_dir(relative_path: str | None = None, /, **kwargs) bool[source]

Check whether resource is a trash directory.

Parameters:
  • relative_pathstr or None, relative path to the trash resource

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:

ForbiddenError – application doesn’t have enough rights for this request

Returns:

True if path is a directory, False otherwise (even if it doesn’t exist)

async is_file(relative_path: str | None = None, /, **kwargs) bool[source]

Check whether resource is a trash file.

Parameters:
  • relative_pathstr or None, relative path to the trash resource

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:

ForbiddenError – application doesn’t have enough rights for this request

Returns:

True if path is a file, False otherwise (even if it doesn’t exist)

async listdir(relative_path: str | None = None, /, **kwargs) AsyncGenerator[TrashResourceObject, None][source]

Get contents of a trash resource.

Parameters:
  • relative_pathstr or None, relative path to the directory in the trash bin

  • limit – number of children resources to be included in the response

  • offset – number of children resources to be skipped in the response

  • preview_size – size of the file preview

  • preview_cropbool, cut the preview to the size specified in the preview_size

  • fields – list of keys to be included in the response

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

generator of TrashResourceObject

async patch(*args, **kwargs)[source]

Update custom properties of a resource. This method takes 1 or 2 positional arguments:

  1. patch(properties, /, **kwargs)

  2. patch(relative_path, properties, /, **kwargs)

Parameters:
  • relative_pathstr or None, path relative to the resource

  • propertiesdict, custom properties to update

  • fields – list of keys to be included in the response

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

ResourceObject

async remove(relative_path: str | None = None, /, **kwargs) OperationLinkObject | None[source]

Remove a trash resource.

Parameters:
  • relative_pathstr or None, relative path to the trash resource to be deleted

  • force_async – forces the operation to be executed asynchronously

  • fields – list of keys to be included in the response

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

OperationLinkObject if the operation is performed asynchronously, None otherwise

async restore(dst_path: str, /, **kwargs) ResourceLinkObject | OperationLinkObject[source]
async restore(relative_path: str | None, dst_path: str, /, **kwargs) ResourceLinkObject | OperationLinkObject

Restore a trash resource. Returns a link to the newly created resource or a link to the asynchronous operation.

This method takes 1 or 2 positional arguments:

  1. restore(dst_path, /, **kwargs)

  2. restore(relative_path=None, dst_path, /, **kwargs)

Parameters:
  • relative_pathstr or None, relative path to the trash resource to be restored

  • dst_path – destination path

  • overwritebool, determines whether the destination can be overwritten

  • force_async – forces the operation to be executed asynchronously

  • fields – list of keys to be included in the response

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

Raises:
Returns:

ResourceLinkObject or OperationLinkObject

class yadisk_async.objects.operations.OperationStatusObject(operation_status: dict | None = None, yadisk: YaDisk | None = None)[source]

Bases: YaDiskObject

Operation status object.

Parameters:
  • operation_statusdict or None

  • yadiskYaDisk or None, YaDisk object

Variables:
  • typestr, type of the operation

  • statusstr, status of the operation

  • operation_idstr, ID of the operation

  • linkLinkObject, link to the operation

  • datadict, other information about the operation

Low-level API

Utilities

async yadisk_async.utils.auto_retry(func: Callable[[], T | Awaitable[T]], n_retries: int | None = None, retry_interval: int | float | None = None) T[source]

Attempt to perform a request with automatic retries. A retry is triggered by aiohttp.ClientError or RetriableYaDiskError.

Parameters:
  • func – function to run, must not require any arguments

  • n_retriesint, maximum number of retries

  • retry_intervalint or float, delay between retries (in seconds)

Returns:

return value of func()

async yadisk_async.utils.get_exception(response: ClientResponse) YaDiskError[source]

Get an exception instance based on response, assuming the request has failed.

Parameters:

response – an instance of aiohttp.ClientResponse

Returns:

an exception instance, subclass of YaDiskError

API request objects

class yadisk_async.api.APIRequest(session: ClientSession, args: dict, **kwargs)[source]

Base class for all API requests.

Parameters:
  • session – an instance of aiohttp.ClientSession

  • argsdict of arguments, that will be passed to process_args

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

  • kwargs – other arguments for aiohttp.ClientSession.request

Variables:
  • urlstr, request URL

  • methodstr, request method

  • content_typestr, Content-Type header (“application/x-www-form-urlencoded” by default)

  • timeoutfloat or aiohttp.ClientTimeout, request timeout

  • n_retriesint, maximum number of retries

  • success_codeslist-like, list of response codes that indicate request’s success

  • retry_intervalfloat, delay between retries in seconds

async process(**kwargs) T[source]

Process the response.

Returns:

depends on self.process_json()

process_json(js: dict | None, **kwargs) T[source]

Process the JSON response.

Parameters:
  • jsdict, JSON response

  • kwargs – extra arguments (optional)

Returns:

processed response, can be anything

async send() ClientResponse[source]

Actually send the request

Returns:

aiohttp.ClientResponse (self.response)

class yadisk_async.api.auth.GetTokenRequest(session: aiohttp.ClientSession, code: str, client_id: str, client_secret: str, device_id: str | None = None, device_name: str | None = None, **kwargs)[source]

Bases: APIRequest

A request to get the token.

Parameters:
  • session – an instance of aiohttp.ClientSession with prepared headers

  • code – confirmation code

  • client_id – application ID

  • client_secret – application secret password

  • device_id – unique device ID (between 6 and 50 characters)

Returns:

TokenObject

process_json(js: dict | None) TokenObject[source]

Process the JSON response.

Parameters:
  • jsdict, JSON response

  • kwargs – extra arguments (optional)

Returns:

processed response, can be anything

class yadisk_async.api.auth.RefreshTokenRequest(session: aiohttp.ClientSession, refresh_token: str, client_id: str, client_secret: str, **kwargs)[source]

Bases: APIRequest

A request to refresh an existing token.

Parameters:
  • session – an instance of aiohttp.ClientSession with prepared headers

  • refresh_token – the refresh token that was received with the original token

  • client_id – application ID

  • client_secret – application secret password

Returns:

TokenObject

process_json(js: dict | None) TokenObject[source]

Process the JSON response.

Parameters:
  • jsdict, JSON response

  • kwargs – extra arguments (optional)

Returns:

processed response, can be anything

class yadisk_async.api.auth.RevokeTokenRequest(session: aiohttp.ClientSession, token: str, client_id: str, client_secret: str, **kwargs)[source]

Bases: APIRequest

A request to revoke the token.

Parameters:
  • session – an instance of aiohttp.ClientSession with prepared headers

  • token – the token to be revoked

  • client_id – application ID

  • client_secret – application secret password

Returns:

TokenRevokeStatusObject

process_json(js: dict | None) TokenRevokeStatusObject[source]

Process the JSON response.

Parameters:
  • jsdict, JSON response

  • kwargs – extra arguments (optional)

Returns:

processed response, can be anything

class yadisk_async.api.disk.DiskInfoRequest(session: aiohttp.ClientSession, fields: Iterable[str] | None = None, **kwargs)[source]

Bases: APIRequest

A request to get disk information.

Parameters:
  • session – an instance of aiohttp.ClientSession with prepared headers

  • fields – list of keys to be included in the response

Returns:

DiskInfoObject

process_json(js: dict | None) DiskInfoObject[source]

Process the JSON response.

Parameters:
  • jsdict, JSON response

  • kwargs – extra arguments (optional)

Returns:

processed response, can be anything

class yadisk_async.api.resources.CopyRequest(session: aiohttp.ClientSession, src_path: str, dst_path: str, overwrite: bool = False, force_async: bool = False, fields: Iterable[str] | None = None, **kwargs)[source]

Bases: APIRequest

A request to copy a file or a directory.

Parameters:
  • session – an instance of aiohttp.ClientSession with prepared headers

  • src_path – source path

  • dst_path – destination path

  • overwrite – if True the destination path can be overwritten, otherwise, an error will be raised

  • force_async – forces the operation to be executed asynchronously

  • fields – list of keys to be included in the response

Returns:

ResourceLinkObject or OperationLinkObject

process_json(js: dict | None, yadisk: YaDisk | None = None) OperationLinkObject | ResourceLinkObject[source]

Process the JSON response.

Parameters:
  • jsdict, JSON response

  • kwargs – extra arguments (optional)

Returns:

processed response, can be anything

class yadisk_async.api.resources.DeleteRequest(session: aiohttp.ClientSession, path: str, permanently: bool = False, md5: str | None = None, force_async: bool = False, fields: Iterable[str] | None = None, **kwargs)[source]

Bases: APIRequest

A request to delete a file or a directory.

Parameters:
  • session – an instance of aiohttp.ClientSession with prepared headers

  • path – path to the resource to be removed

  • permanently – if True, the resource will be removed permanently, otherwise, it will be just moved to the trash

  • force_async – forces the operation to be executed asynchronously

  • md5str, MD5 hash of the file to remove

  • fields – list of keys to be included in the response

Returns:

OperationLinkObject or None

process_json(js: dict | None, yadisk: YaDisk | None = None) OperationLinkObject | None[source]

Process the JSON response.

Parameters:
  • jsdict, JSON response

  • kwargs – extra arguments (optional)

Returns:

processed response, can be anything

class yadisk_async.api.resources.DeleteTrashRequest(session: aiohttp.ClientSession, path: str | None = None, force_async: bool = False, fields: Iterable[str] | None = None, **kwargs)[source]

Bases: APIRequest

A request to delete a trash resource.

Parameters:
  • session – an instance of aiohttp.ClientSession with prepared headers

  • path – path to the trash resource to be deleted

  • force_async – forces the operation to be executed asynchronously

  • fields – list of keys to be included in the response

Returns:

OperationLinkObject or None

process_json(js: dict | None, yadisk: YaDisk | None = None) OperationLinkObject | None[source]

Process the JSON response.

Parameters:
  • jsdict, JSON response

  • kwargs – extra arguments (optional)

Returns:

processed response, can be anything

class yadisk_async.api.resources.FilesRequest(session: aiohttp.ClientSession, offset: int = 0, limit: int = 20, media_type: str | Iterable[str] | None = None, preview_size: str | None = None, preview_crop: bool | None = None, sort: str | None = None, fields: Iterable[str] | None = None, **kwargs)[source]

Bases: APIRequest

A request to get a flat list of all files (that doesn’t include directories).

Parameters:
  • session – an instance of aiohttp.ClientSession with prepared headers

  • offset – offset from the beginning of the list

  • limit – number of list elements to be included

  • media_type – type of files to include in the list

  • sortstr, field to be used as a key to sort children resources

  • preview_size – size of the file preview

  • preview_cropbool, cut the preview to the size specified in the preview_size

  • fields – list of keys to be included in the response

Returns:

FilesResourceListObject

process_json(js: dict | None, yadisk: YaDisk | None = None) FilesResourceListObject[source]

Process the JSON response.

Parameters:
  • jsdict, JSON response

  • kwargs – extra arguments (optional)

Returns:

processed response, can be anything

class yadisk_async.api.resources.GetDownloadLinkRequest(session: aiohttp.ClientSession, path: str, fields: Iterable[str] | None = None, **kwargs)[source]

Bases: APIRequest

A request to get a download link to a resource.

Parameters:
  • session – an instance of aiohttp.ClientSession with prepared headers

  • path – path to the resource to be downloaded

  • fields – list of keys to be included in the response

Returns:

ResourceDownloadLinkObject

process_json(js: dict | None, yadisk: YaDisk | None = None) ResourceDownloadLinkObject[source]

Process the JSON response.

Parameters:
  • jsdict, JSON response

  • kwargs – extra arguments (optional)

Returns:

processed response, can be anything

class yadisk_async.api.resources.GetMetaRequest(session: aiohttp.ClientSession, path: str, limit: int | None = None, offset: int | None = None, preview_size: str | None = None, preview_crop: bool | None = None, sort: str | None = None, fields: Iterable[str] | None = None, **kwargs)[source]

Bases: APIRequest

A request to get meta-information about a resource.

Parameters:
  • session – an instance of aiohttp.ClientSession with prepared headers

  • path – path to the resource

  • limit – number of children resources to be included in the response

  • offset – number of children resources to be skipped in the response

  • preview_size – size of the file preview

  • preview_cropbool, cut the preview to the size specified in the preview_size

  • sortstr, field to be used as a key to sort children resources

  • fields – list of keys to be included in the response

Returns:

ResourceObject

process_json(js: dict | None, yadisk: YaDisk | None = None) ResourceObject[source]

Process the JSON response.

Parameters:
  • jsdict, JSON response

  • kwargs – extra arguments (optional)

Returns:

processed response, can be anything

class yadisk_async.api.resources.GetPublicDownloadLinkRequest(session: aiohttp.ClientSession, public_key: str, path: str | None = None, fields: Iterable[str] | None = None, **kwargs)[source]

Bases: APIRequest

A request to get a download link for a public resource.

Parameters:
  • session – an instance of aiohttp.ClientSession with prepared headers

  • public_key – public key or public URL of the resource

  • path – relative path to the resource within the public folder

  • fields – list of keys to be included in the response

Returns:

ResourceDownloadLinkObject

process_json(js: dict | None, yadisk: YaDisk | None = None) ResourceDownloadLinkObject[source]

Process the JSON response.

Parameters:
  • jsdict, JSON response

  • kwargs – extra arguments (optional)

Returns:

processed response, can be anything

class yadisk_async.api.resources.GetPublicMetaRequest(session: aiohttp.ClientSession, public_key: str, offset: int = 0, limit: int = 20, path: str | None = None, sort: str | None = None, preview_size: str | None = None, preview_crop: bool | None = None, fields: Iterable[str] | None = None, **kwargs)[source]

Bases: APIRequest

A request to get meta-information about a public resource.

Parameters:
  • session – an instance of aiohttp.ClientSession with prepared headers

  • public_key – public key or public URL of the resource

  • path – relative path to a resource in a public folder. By specifying the key of the published folder in public_key, you can request metainformation for any resource in the folder.

  • offset – offset from the beginning of the list of nested resources

  • limit – maximum number of nested elements to be included in the list

  • sortstr, field to be used as a key to sort children resources

  • preview_size – file preview size

  • preview_cropbool, allow preview crop

  • fields – list of keys to be included in the response

Returns:

PublicResourceObject

process_json(js: dict | None, yadisk: YaDisk | None = None) PublicResourceObject[source]

Process the JSON response.

Parameters:
  • jsdict, JSON response

  • kwargs – extra arguments (optional)

Returns:

processed response, can be anything

class yadisk_async.api.resources.GetPublicResourcesRequest(session: aiohttp.ClientSession, offset: int = 0, limit: int = 20, preview_size: str | None = None, preview_crop: bool | None = None, type: str | None = None, fields: Iterable[str] | None = None, **kwargs)[source]

Bases: APIRequest

A request to get a list of public resources.

Parameters:
  • session – an instance of aiohttp.ClientSession with prepared headers

  • offset – offset from the beginning of the list

  • limit – maximum number of elements in the list

  • preview_size – size of the file preview

  • preview_cropbool, cut the preview to the size specified in the preview_size

  • type – filter based on type of resources (“file” or “dir”)

  • fields – list of keys to be included in the response

Returns:

PublicResourcesListObject

process_json(js: dict | None, yadisk: YaDisk | None = None) PublicResourcesListObject[source]

Process the JSON response.

Parameters:
  • jsdict, JSON response

  • kwargs – extra arguments (optional)

Returns:

processed response, can be anything

class yadisk_async.api.resources.GetTrashRequest(session: aiohttp.ClientSession, path: str, offset: int = 0, limit: int = 20, sort: str | None = None, preview_size: str | None = None, preview_crop: bool | None = None, fields: Iterable[str] | None = None, **kwargs)[source]

Bases: APIRequest

A request to get meta-information about a trash resource.

Parameters:
  • path – path to the trash resource

  • limit – number of children resources to be included in the response

  • offset – number of children resources to be skipped in the response

  • preview_size – size of the file preview

  • preview_cropbool, cut the preview to the size specified in the preview_size

  • sortstr, field to be used as a key to sort children resources

  • fields – list of keys to be included in the response

Returns:

TrashResourceObject

process_json(js: dict | None, yadisk: YaDisk | None = None) TrashResourceObject[source]

Process the JSON response.

Parameters:
  • jsdict, JSON response

  • kwargs – extra arguments (optional)

Returns:

processed response, can be anything

class yadisk_async.api.resources.GetUploadLinkRequest(session: aiohttp.ClientSession, path: str, overwrite: bool = False, fields: Iterable[str] | None = None, **kwargs)[source]

Bases: APIRequest

A request to get an upload link.

Parameters:
  • session – an instance of aiohttp.ClientSession with prepared headers

  • path – path to be uploaded at

  • overwritebool, determines whether to overwrite the destination

  • fields – list of keys to be included in the response

Returns:

ResourceUploadLinkObject

process_json(js: dict | None, yadisk: YaDisk | None = None) ResourceUploadLinkObject[source]

Process the JSON response.

Parameters:
  • jsdict, JSON response

  • kwargs – extra arguments (optional)

Returns:

processed response, can be anything

class yadisk_async.api.resources.LastUploadedRequest(session: aiohttp.ClientSession, limit: int = 20, media_type: str | Iterable[str] | None = None, preview_size: str | None = None, preview_crop: bool | None = None, fields: Iterable[str] | None = None, **kwargs)[source]

Bases: APIRequest

A request to get the list of latest uploaded files sorted by upload date.

Parameters:
  • session – an instance of aiohttp.ClientSession with prepared headers

  • limit – maximum number of elements in the list

  • media_type – type of files to include in the list

  • preview_size – size of the file preview

  • preview_cropbool, cut the preview to the size specified in the preview_size

  • fields – list of keys to be included in the response

Returns:

LastUploadedResourceListObject

process_json(js: dict | None, yadisk: YaDisk | None = None) LastUploadedResourceListObject[source]

Process the JSON response.

Parameters:
  • jsdict, JSON response

  • kwargs – extra arguments (optional)

Returns:

processed response, can be anything

class yadisk_async.api.resources.MkdirRequest(session: aiohttp.ClientSession, path: str, fields: Iterable[str] | None = None, **kwargs)[source]

Bases: APIRequest

A request to create a new directory.

Parameters:
  • path – path to the directory to be created

  • fields – list of keys to be included in the response

Returns:

ResourceLinkObject

process_json(js: dict | None, yadisk: YaDisk | None = None) ResourceLinkObject[source]

Process the JSON response.

Parameters:
  • jsdict, JSON response

  • kwargs – extra arguments (optional)

Returns:

processed response, can be anything

class yadisk_async.api.resources.MoveRequest(session: aiohttp.ClientSession, src_path: str, dst_path: str, force_async: bool = False, overwrite: bool = False, fields: Iterable[str] | None = None, **kwargs)[source]

Bases: APIRequest

A request to move a resource.

Parameters:
  • session – an instance of aiohttp.ClientSession with prepared headers

  • src_path – source path to be moved

  • dst_path – destination path

  • force_async – forces the operation to be executed asynchronously

  • overwritebool, determines whether to overwrite the destination

  • fields – list of keys to be included in the response

Returns:

OperationLinkObject or ResourceLinkObject

process_json(js: dict | None, yadisk: YaDisk | None = None) OperationLinkObject | ResourceLinkObject[source]

Process the JSON response.

Parameters:
  • jsdict, JSON response

  • kwargs – extra arguments (optional)

Returns:

processed response, can be anything

class yadisk_async.api.resources.PatchRequest(session: aiohttp.ClientSession, path: str, properties: dict, fields: Iterable[str] | None = None, **kwargs)[source]

Bases: APIRequest

A request to update custom properties of a resource.

Parameters:
  • session – an instance of aiohttp.ClientSession with prepared headers

  • path – path to the resource

  • propertiesdict, custom properties to update

  • fields – list of keys to be included in the response

Returns:

ResourceObject

process_json(js: dict | None, yadisk: YaDisk | None = None) ResourceObject[source]

Process the JSON response.

Parameters:
  • jsdict, JSON response

  • kwargs – extra arguments (optional)

Returns:

processed response, can be anything

class yadisk_async.api.resources.PublishRequest(session: aiohttp.ClientSession, path: str, fields: Iterable[str] | None = None, **kwargs)[source]

Bases: APIRequest

A request to make a resource public.

Parameters:
  • session – an instance of aiohttp.ClientSession with prepared headers

  • path – path to the resource to be published

  • fields – list of keys to be included in the response

Returns:

ResourceLinkObject

process_json(js: dict | None, yadisk: YaDisk | None = None) ResourceLinkObject[source]

Process the JSON response.

Parameters:
  • jsdict, JSON response

  • kwargs – extra arguments (optional)

Returns:

processed response, can be anything

class yadisk_async.api.resources.RestoreTrashRequest(session: aiohttp.ClientSession, path: str, dst_path: str | None = None, force_async: bool = False, overwrite: bool = False, fields: Iterable[str] | None = None, **kwargs)[source]

Bases: APIRequest

A request to restore trash.

Parameters:
  • session – an instance of aiohttp.ClientSession with prepared headers

  • path – path to the trash resource to be restored

  • dst_path – destination path

  • force_async – forces the operation to be executed asynchronously

  • overwritebool, determines whether the destination can be overwritten

  • fields – list of keys to be included in the response

Returns:

ResourceLinkObject or OperationLinkObject

process_json(js: dict | None, yadisk: YaDisk | None = None) OperationLinkObject | ResourceLinkObject[source]

Process the JSON response.

Parameters:
  • jsdict, JSON response

  • kwargs – extra arguments (optional)

Returns:

processed response, can be anything

class yadisk_async.api.resources.SaveToDiskRequest(session: aiohttp.ClientSession, public_key: str, name: str | None = None, path: str | None = None, save_path: str | None = None, force_async: bool = False, fields: Iterable[str] | None = None, **kwargs)[source]

Bases: APIRequest

A request to save a public resource to the disk.

Parameters:
  • session – an instance of aiohttp.ClientSession with prepared headers

  • public_key – public key or public URL of the resource

  • name – filename of the saved resource

  • path – path to the copied resource in the public folder

  • save_path – path to the destination directory (downloads directory by default)

  • force_async – forces the operation to be executed asynchronously

  • fields – list of keys to be included in the response

Returns:

ResourceLinkObject or OperationLinkObject

process_json(js: dict | None, yadisk: YaDisk | None = None) OperationLinkObject | ResourceLinkObject[source]

Process the JSON response.

Parameters:
  • jsdict, JSON response

  • kwargs – extra arguments (optional)

Returns:

processed response, can be anything

class yadisk_async.api.resources.UnpublishRequest(session: aiohttp.ClientSession, path: str, fields: Iterable[str] | None = None, **kwargs)[source]

Bases: APIRequest

A request to make a public resource private.

Parameters:
  • session – an instance of aiohttp.ClientSession with prepared headers

  • path – path to the resource to be unpublished

  • fields – list of keys to be included in the response

Returns:

ResourceLinkObject

process_json(js: dict | None, yadisk: YaDisk | None = None) ResourceLinkObject[source]

Process the JSON response.

Parameters:
  • jsdict, JSON response

  • kwargs – extra arguments (optional)

Returns:

processed response, can be anything

class yadisk_async.api.resources.UploadURLRequest(session: aiohttp.ClientSession, url: str, path: str, disable_redirects: bool = False, fields: Iterable[str] | None = None, **kwargs)[source]

Bases: APIRequest

A request to upload a file from URL.

Parameters:
  • session – an instance of aiohttp.ClientSession with prepared headers

  • url – source URL

  • path – destination path

  • disable_redirectsbool, forbid redirects

  • fields – list of keys to be included in the response

Returns:

OperationLinkObject

process_json(js: dict | None, yadisk: YaDisk | None = None) OperationLinkObject[source]

Process the JSON response.

Parameters:
  • jsdict, JSON response

  • kwargs – extra arguments (optional)

Returns:

processed response, can be anything

class yadisk_async.api.operations.GetOperationStatusRequest(session: aiohttp.ClientSession, operation_id: str, fields: Iterable[str] | None = None, **kwargs)[source]

Bases: APIRequest

A request to get operation status.

Parameters:
  • session – an instance of aiohttp.ClientSession with prepared headers

  • operation_id – operation ID or link

  • fields – list of keys to be included in the response

Returns:

OperationStatusObject

process_json(js: dict | None) OperationStatusObject[source]

Process the JSON response.

Parameters:
  • jsdict, JSON response

  • kwargs – extra arguments (optional)

Returns:

processed response, can be anything