Asynchronous API
- class yadisk.AsyncClient(id: str = '', secret: str = '', token: str = '', *, default_args: dict[str, Any] | None = None, session: AsyncSession | Literal['aiohttp'] | Literal['httpx'] | None = None, open_file: Callable[[str | bytes, Literal['rb', 'wb']], Awaitable[BinaryAsyncFileLike]] | Callable[[str | bytes, Literal['rb', 'wb']], Awaitable[BinaryIO]] | None = None, session_factory: Callable[[], AsyncSession] | None = None)[source]
Implements access to Yandex.Disk REST API (provides asynchronous API).
HTTP client implementation can be specified using the
sessionparameter.AsyncHTTPXSessionis used by default. For other options, see Available Session Implementations.Almost all methods of
AsyncClient(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
timeout - tuple (
(<connect timeout>, <read timeout>)) or float (specifies both connect and read timeout), request timeout (in seconds)
Additional parameters, specific to a given HTTP client library can also be passed, see documentation for specific
AsyncSessionsubclasses (Available Session Implementations).Note
Do not forget to call
AsyncClient.closeor use the async with statement to close all the connections. Otherwise, you may get a warning.In
Clientthis is handled in the destructor, but sinceAsyncClient.closeis 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_args – dict or None, default arguments for methods. Can be used to set the default timeout, headers, etc.
session –
None, str or an instance of
AsyncSession. Ifsessionis a string, the appropriate session class will be imported, it must be one of the following values:"aiohttp"-AIOHTTPSession"httpx"-AsyncHTTPXSession
open_file – None or an async function that opens a file for reading or writing (
aiofiles.open()by default)session_factory – kept for compatibility, callable that returns an instance of
AsyncSession
- Variables:
id – str, application ID
secret – str, application secret password
token – str, application token
default_args – dict, default arguments for methods. Can be used to set the default timeout, headers, etc.
session – current session (
AsyncSessioninstance)open_file – async function that opens a file for reading or writing (
aiofiles.open()by default)
The following exceptions may be raised by most API requests:
- Raises:
RequestError – HTTP client raised an exception while making a request
BadRequestError – server returned HTTP code 400
FieldValidationError – request contains fields with invalid data
UnauthorizedError – server returned HTTP code 401
ForbiddenError – server returned HTTP code 403
NotAcceptableError – server returned HTTP code 406
ConflictError – server returned HTTP code 409
PayloadTooLargeError – server returned code 413
UnsupportedMediaError – server returned HTTP code 415
LockedError – server returned HTTP code 423
TooManyRequestsError – server returned HTTP code 429
InternalServerError – server returned HTTP code 500
BadGatewayError – server returned HTTP code 502
UnavailableError – server returned HTTP code 503
GatewayTimeoutError – server returned HTTP code 504
InsufficientStorageError – server returned HTTP code 509
UnknownYaDiskError – other unknown error
- yadisk.AsyncYaDisk
alias of
AsyncClient
Authentication
- async AsyncClient.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
timeout – float, tuple or None, request timeout
headers – dict or None, additional request headers
n_retries – int, maximum number of retries
retry_interval – delay between retries in seconds
retry_on – tuple, additional exception classes to retry on
aiohttp_args – dict, additional parameters for
AIOHTTPSessionhttpx_args – dict, additional parameters for
AsyncHTTPXSessionkwargs – any other parameters, accepted by
Session.send_request()
- Returns:
bool
- AsyncClient.get_auth_url(type: Literal['code', 'token'], device_id: str | None = None, device_name: str | None = None, redirect_uri: str | None = None, login_hint: str | None = None, scope: str | None = None, optional_scope: str | None = None, force_confirm: bool = True, state: str | None = None, code_challenge: str | None = None, code_challenge_method: Literal['plain'] | Literal['S256'] | None = None, display: None = None) str[source]
Get authentication URL for the user to go to. This method doesn’t send any HTTP requests and merely constructs the URL.
- 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
redirect_uri – the URL to redirect the user to after they allow access to the app, by default, the first redirect URI specified in the app settings is used
display – doesn’t do anything, kept for compatibility
login_hint – username or email for the account the token is being requested for
scope – str, list of permissions for the application
optional_scope – str, 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)
code_challenge – string derived from the generated
code_verifiervalue using one of the two possible transformations (plain or S256)code_challenge_method – specifies what function was used to transform the
code_verifiervalue tocode_challenge, allowed values are"plain"and"S256"(recommended). If"S256"is used,code_challengemust be produced by hashing thecode_verifiervalue and encoding it to base64
- Raises:
ValueError – invalid arguments were passed
- Returns:
authentication URL
- AsyncClient.get_code_url(device_id: str | None = None, device_name: str | None = None, redirect_uri: str | None = None, login_hint: str | None = None, scope: str | None = None, optional_scope: str | None = None, force_confirm: bool = True, state: str | None = None, code_challenge: str | None = None, code_challenge_method: Literal['plain'] | Literal['S256'] | None = None, display: None = None) str[source]
Get the URL for the user to get the confirmation code. The confirmation code can later be used to get the token. This method doesn’t send any HTTP requests and merely constructs the URL.
- Parameters:
device_id – unique device ID, must be between 6 and 50 characters
device_name – device name, should not be longer than 100 characters
redirect_uri – the URL to redirect the user to after they allow access to the app, by default, the first redirect URI specified in the app settings is used
display – doesn’t do anything, kept for compatibility
login_hint – username or email for the account the token is being requested for
scope – str, list of permissions for the application
optional_scope – str, 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)
code_challenge – string derived from the generated
code_verifiervalue using one of the two possible transformations (plain or S256)code_challenge_method – specifies what function was used to transform the
code_verifiervalue tocode_challenge, allowed values are"plain"and"S256"(recommended). If"S256"is used,code_challengemust be produced by hashing thecode_verifiervalue and encoding it to base64
- Raises:
ValueError – invalid arguments were passed
- Returns:
authentication URL
- async AsyncClient.get_device_code(**kwargs) DeviceCodeObject[source]
This request is used for authorization using the Yandex OAuth page. In this case the user must enter the verification code (
user_code) in the browser on the Yandex OAuth page. After the user has entered the code on the OAuth page, the application can exchange thedevice_codefor the token using theAsyncClient.get_token_from_device_code().- Parameters:
device_id – unique device ID (between 6 and 50 characters)
device_name – device name, should not be longer than 100 characters
scope – str, list of permissions for the application
optional_scope – str, list of optional permissions for the application
timeout – float, tuple or None, request timeout
headers – dict or None, additional request headers
n_retries – int, maximum number of retries
retry_interval – delay between retries in seconds
retry_on – tuple, additional exception classes to retry on
aiohttp_args – dict, additional parameters for
AIOHTTPSessionhttpx_args – dict, additional parameters for
AsyncHTTPXSessionkwargs – any other parameters, accepted by
Session.send_request()
- Raises:
InvalidClientError – invalid client ID or client secret
BadRequestError – invalid request parameters
- Returns:
DeviceCodeObjectcontaininguser_codeanddevice_code
- async AsyncClient.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)
code_verifier – str, verifier code, used with the PKCE authorization flow
timeout – float, tuple or None, request timeout
headers – dict or None, additional request headers
n_retries – int, maximum number of retries
retry_interval – delay between retries in seconds
retry_on – tuple, additional exception classes to retry on
aiohttp_args – dict, additional parameters for
AIOHTTPSessionhttpx_args – dict, additional parameters for
AsyncHTTPXSessionkwargs – any other parameters, accepted by
Session.send_request()
- Raises:
BadVerificationCodeError – confirmation code has invalid format
InvalidGrantError – invalid or expired confirmation code
InvalidClientError – invalid client ID or client secret
BadRequestError – invalid request parameters
- Returns:
- async AsyncClient.get_token_from_device_code(device_code: str, /, **kwargs) TokenObject[source]
Get a new token from a device code, previously obtained with
AsyncClient.get_device_code().- Parameters:
device_code – device code, obtained from
AsyncClient.get_device_code()device_id – unique device ID (between 6 and 50 characters)
device_name – device name, should not be longer than 100 characters
code_verifier – str, verifier code, used with the PKCE authorization flow
timeout – float or tuple, request timeout
headers – dict or None, additional request headers
n_retries – int, maximum number of retries
retry_interval – delay between retries in seconds
retry_on – tuple, additional exception classes to retry on
aiohttp_args – dict, additional parameters for
AIOHTTPSessionhttpx_args – dict, additional parameters for
AsyncHTTPXSessionkwargs – any other parameters, accepted by
Session.send_request()
- Raises:
AuthorizationPendingError – user has not authorized the application yet
BadVerificationCodeError –
device_codehas invalid formatInvalidGrantError – invalid or expired
device_codeInvalidClientError – invalid client ID or client secret
BadRequestError – invalid request parameters
- Returns:
- async AsyncClient.refresh_token(refresh_token: str, /, **kwargs) TokenObject[source]
Refresh an existing token.
- Parameters:
refresh_token – the refresh token that was received with the token
timeout – float, tuple or None, request timeout
headers – dict or None, additional request headers
n_retries – int, maximum number of retries
retry_interval – delay between retries in seconds
retry_on – tuple, additional exception classes to retry on
aiohttp_args – dict, additional parameters for
AIOHTTPSessionhttpx_args – dict, additional parameters for
AsyncHTTPXSessionkwargs – any other parameters, accepted by
Session.send_request()
- Raises:
InvalidGrantError – invalid or expired refresh token or it doesn’t belong to this application
InvalidClientError – invalid client ID or client secret
BadRequestError – invalid request parameters
- Returns:
- async AsyncClient.revoke_token(token: str | None = None, /, **kwargs) TokenRevokeStatusObject[source]
Revoke the token.
- Parameters:
token – token to revoke, equivalent to self.token if None
timeout – float, tuple or None, request timeout
headers – dict or None, additional request headers
n_retries – int, maximum number of retries
retry_interval – delay between retries in seconds
retry_on – tuple, additional exception classes to retry on
aiohttp_args – dict, additional parameters for
AIOHTTPSessionhttpx_args – dict, additional parameters for
AsyncHTTPXSessionkwargs – any other parameters, accepted by
Session.send_request()
- Raises:
InvalidGrantError – specified token doesn’t belong to this application
InvalidClientError – invalid client ID or client secret
UnsupportedTokenTypeError – token could not be revoked because it doesn’t have a
device_idBadRequestError – invalid request parameters
- Returns:
Disk Info
- async AsyncClient.get_disk_info(**kwargs) DiskInfoObject[source]
Get disk information.
- Parameters:
extra_fields – list of additional keys to be included in the response
fields – list of keys to be included in the response
timeout – float, tuple or None, request timeout
headers – dict or None, additional request headers
n_retries – int, maximum number of retries
retry_interval – delay between retries in seconds
retry_on – tuple, additional exception classes to retry on
aiohttp_args – dict, additional parameters for
AIOHTTPSessionhttpx_args – dict, additional parameters for
AsyncHTTPXSessionkwargs – any other parameters, accepted by
Session.send_request()
- Raises:
ForbiddenError – application doesn’t have enough rights for this request
More info about this request:
- Returns:
Metadata About Files
- async AsyncClient.get_meta(path: str, /, **kwargs) AsyncResourceObject[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_crop – bool, cut the preview to the size specified in the preview_size
sort – str, field to be used as a key to sort children resources
fields – list of keys to be included in the response
timeout – float, tuple or None, request timeout
headers – dict or None, additional request headers
n_retries – int, maximum number of retries
retry_interval – delay between retries in seconds
retry_on – tuple, additional exception classes to retry on
aiohttp_args – dict, additional parameters for
AIOHTTPSessionhttpx_args – dict, additional parameters for
AsyncHTTPXSessionkwargs – any other parameters, accepted by
Session.send_request()
- Raises:
PathNotFoundError – resource was not found on Disk
ForbiddenError – application doesn’t have enough rights for this request
- Returns:
- async AsyncClient.listdir(path: str, /, **kwargs) AsyncGenerator[AsyncResourceObject, None][source]
Get contents of path.
- Parameters:
path – path to the directory
max_items – int or None, maximum number of returned items (None means unlimited)
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_crop – bool, cut the preview to the size specified in the preview_size
fields – list of keys to be included in the response
timeout – float, tuple or None, request timeout
headers – dict or None, additional request headers
n_retries – int, maximum number of retries
retry_interval – delay between retries in seconds
retry_on – tuple, additional exception classes to retry on
aiohttp_args – dict, additional parameters for
AIOHTTPSessionhttpx_args – dict, additional parameters for
AsyncHTTPXSessionkwargs – any other parameters, accepted by
Session.send_request()
- Raises:
PathNotFoundError – resource was not found on Disk
ForbiddenError – application doesn’t have enough rights for this request
WrongResourceTypeError – resource is not a directory
- Returns:
async generator of
AsyncResourceObject
- async AsyncClient.exists(path: str, /, **kwargs) bool[source]
Check whether path exists.
- Parameters:
path – path to the resource
timeout – float, tuple or None, request timeout
headers – dict or None, additional request headers
n_retries – int, maximum number of retries
retry_interval – delay between retries in seconds
retry_on – tuple, additional exception classes to retry on
aiohttp_args – dict, additional parameters for
AIOHTTPSessionhttpx_args – dict, additional parameters for
AsyncHTTPXSessionkwargs – any other parameters, accepted by
Session.send_request()
- Raises:
ForbiddenError – application doesn’t have enough rights for this request
- Returns:
bool
- async AsyncClient.get_type(path: str, /, **kwargs) str[source]
Get resource type.
- Parameters:
path – path to the resource
timeout – float, tuple or None, request timeout
headers – dict or None, additional request headers
n_retries – int, maximum number of retries
retry_interval – delay between retries in seconds
retry_on – tuple, additional exception classes to retry on
aiohttp_args – dict, additional parameters for
AIOHTTPSessionhttpx_args – dict, additional parameters for
AsyncHTTPXSessionkwargs – any other parameters, accepted by
Session.send_request()
- Raises:
PathNotFoundError – resource was not found on Disk
ForbiddenError – application doesn’t have enough rights for this request
- Returns:
“file” or “dir”
- async AsyncClient.is_file(path: str, /, **kwargs) bool[source]
Check whether path is a file.
- Parameters:
path – path to the resource
timeout – float, tuple or None, request timeout
headers – dict or None, additional request headers
n_retries – int, maximum number of retries
retry_interval – delay between retries in seconds
retry_on – tuple, additional exception classes to retry on
aiohttp_args – dict, additional parameters for
AIOHTTPSessionhttpx_args – dict, additional parameters for
AsyncHTTPXSessionkwargs – any other parameters, accepted by
Session.send_request()
- 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 AsyncClient.is_dir(path: str, /, **kwargs) bool[source]
Check whether path is a directory.
- Parameters:
path – path to the resource
timeout – float, tuple or None, request timeout
headers – dict or None, additional request headers
n_retries – int, maximum number of retries
retry_interval – delay between retries in seconds
retry_on – tuple, additional exception classes to retry on
aiohttp_args – dict, additional parameters for
AIOHTTPSessionhttpx_args – dict, additional parameters for
AsyncHTTPXSessionkwargs – any other parameters, accepted by
Session.send_request()
- 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 AsyncClient.get_files(*, max_items: int | None = None, **kwargs) AsyncGenerator[AsyncResourceObject, None][source]
Get a flat list of all files (that doesn’t include directories).
- Parameters:
offset – offset from the beginning of the list
max_items – int or None, maximum number of returned items (None means unlimited)
limit – number of list elements to be included in each response
media_type – type of files to include in the list
sort – str, field to be used as a key to sort children resources
preview_size – size of the file preview
preview_crop – bool, cut the preview to the size specified in the preview_size
fields – list of keys to be included in the response
timeout – float, tuple or None, request timeout
headers – dict or None, additional request headers
n_retries – int, maximum number of retries
retry_interval – delay between retries in seconds
retry_on – tuple, additional exception classes to retry on
aiohttp_args – dict, additional parameters for
AIOHTTPSessionhttpx_args – dict, additional parameters for
AsyncHTTPXSessionkwargs – any other parameters, accepted by
Session.send_request()
- Raises:
ForbiddenError – application doesn’t have enough rights for this request
More info about this request:
- Returns:
async generator of
AsyncResourceObject
- async AsyncClient.get_last_uploaded(**kwargs) list[AsyncResourceObject][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_crop – bool, cut the preview to the size specified in the preview_size
fields – list of keys to be included in the response
timeout – float, tuple or None, request timeout
headers – dict or None, additional request headers
n_retries – int, maximum number of retries
retry_interval – delay between retries in seconds
retry_on – tuple, additional exception classes to retry on
aiohttp_args – dict, additional parameters for
AIOHTTPSessionhttpx_args – dict, additional parameters for
AsyncHTTPXSessionkwargs – any other parameters, accepted by
Session.send_request()
- Raises:
ForbiddenError – application doesn’t have enough rights for this request
More info about this request:
- Returns:
async generator of
AsyncResourceObject
Uploading Files
- async AsyncClient.upload(path_or_file: str | bytes | BinaryIO | AsyncFileLike | Callable[[], AsyncIterator[bytes]], dst_path: str, /, **kwargs) AsyncResourceLinkObject[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
spoof_user_agent – bool, if True (default), the User-Agent header will be set to a special value, which should allow bypassing of Yandex.Disk’s upload speed limit
timeout – float, tuple or None, request timeout
headers – dict or None, additional request headers
n_retries – int, maximum number of retries
retry_interval – delay between retries in seconds
retry_on – tuple, additional exception classes to retry on
aiohttp_args – dict, additional parameters for
AIOHTTPSessionhttpx_args – dict, additional parameters for
AsyncHTTPXSessionkwargs – any other parameters, accepted by
Session.send_request()
- Raises:
ParentNotFoundError – parent directory doesn’t exist
PathExistsError – destination path already exists
InsufficientStorageError – cannot upload file due to lack of storage space
ForbiddenError – application doesn’t have enough rights for this request
ResourceIsLockedError – resource is locked by another request
UploadTrafficLimitExceededError – upload limit has been exceeded
- Returns:
AsyncResourceLinkObject, link to the destination resource
- async AsyncClient.get_upload_link(path: str, /, spoof_user_agent: bool = True, **kwargs) str[source]
Get a link to upload the file using the PUT request.
- Parameters:
path – destination path
overwrite – bool, determines whether to overwrite the destination
spoof_user_agent – bool, if True (default), the User-Agent header will be set to a special value, which should allow bypassing of Yandex.Disk’s upload speed limit
timeout – float, tuple or None, request timeout
headers – dict or None, additional request headers
n_retries – int, maximum number of retries
retry_interval – delay between retries in seconds
retry_on – tuple, additional exception classes to retry on
aiohttp_args – dict, additional parameters for
AIOHTTPSessionhttpx_args – dict, additional parameters for
AsyncHTTPXSessionkwargs – any other parameters, accepted by
Session.send_request()
- Raises:
ParentNotFoundError – parent directory doesn’t exist
PathExistsError – destination path already exists
ForbiddenError – application doesn’t have enough rights for this request
ResourceIsLockedError – resource is locked by another request
InsufficientStorageError – cannot upload file due to lack of storage space
UploadTrafficLimitExceededError – upload limit has been exceeded
More info about this request:
- Returns:
str
- async AsyncClient.get_upload_link_object(path: str, /, spoof_user_agent: bool = True, **kwargs) ResourceUploadLinkObject[source]
Get a link to upload the file using the PUT request. This is similar to
AsyncClient.get_upload_link(), except it returns an instance ofResourceUploadLinkObjectwhich also contains an asynchronous operation ID.- Parameters:
path – destination path
overwrite – bool, determines whether to overwrite the destination
fields – list of keys to be included in the response
spoof_user_agent – bool, if True (default), the User-Agent header will be set to a special value, which should allow bypassing of Yandex.Disk’s upload speed limit
timeout – float or tuple, request timeout
headers – dict or None, additional request headers
n_retries – int, maximum number of retries
retry_interval – delay between retries in seconds
retry_on – tuple, additional exception classes to retry on
aiohttp_args – dict, additional parameters for
AIOHTTPSessionhttpx_args – dict, additional parameters for
AsyncHTTPXSessionkwargs – any other parameters, accepted by
Session.send_request()
- Raises:
ParentNotFoundError – parent directory doesn’t exist
PathExistsError – destination path already exists
ForbiddenError – application doesn’t have enough rights for this request
ResourceIsLockedError – resource is locked by another request
InsufficientStorageError – cannot upload file due to lack of storage space
UploadTrafficLimitExceededError – upload limit has been exceeded
- Returns:
- async AsyncClient.upload_by_link(file_or_path: str | bytes | BinaryIO | AsyncFileLike | Callable[[], AsyncIterator[bytes]], link: str, /, **kwargs) None[source]
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
timeout – float, tuple or None, request timeout
headers – dict or None, additional request headers
n_retries – int, maximum number of retries
retry_interval – delay between retries in seconds
retry_on – tuple, additional exception classes to retry on
aiohttp_args – dict, additional parameters for
AIOHTTPSessionhttpx_args – dict, additional parameters for
AsyncHTTPXSessionkwargs – any other parameters, accepted by
Session.send_request()
- Raises:
InsufficientStorageError – cannot upload file due to lack of storage space
- async AsyncClient.upload_url(url: str, path: str, /, **kwargs) AsyncOperationLinkObject[source]
Upload a file from URL.
- Parameters:
url – source URL
path – destination path
disable_redirects – bool, forbid redirects
fields – list of keys to be included in the response
wait – bool, if
True, the method will wait until the asynchronous operation is completedpoll_interval – float, interval in seconds between subsequent operation status queries
poll_timeout – float or None, total polling timeout (None means no timeout), if this timeout is exceeded, an exception is raised
timeout – float, tuple or None, request timeout
headers – dict or None, additional request headers
n_retries – int, maximum number of retries
retry_interval – delay between retries in seconds
retry_on – tuple, additional exception classes to retry on
aiohttp_args – dict, additional parameters for
AIOHTTPSessionhttpx_args – dict, additional parameters for
AsyncHTTPXSessionkwargs – any other parameters, accepted by
Session.send_request()
- Raises:
ParentNotFoundError – parent directory doesn’t exist
PathExistsError – destination path already exists
InsufficientStorageError – cannot upload file due to lack of storage space
ForbiddenError – application doesn’t have enough rights for this request
ResourceIsLockedError – resource is locked by another request
UploadTrafficLimitExceededError – upload limit has been exceeded
OperationNotFoundError – requested operation was not found
AsyncOperationFailedError – requested operation failed
AsyncOperationPollingTimeoutError – requested operation did not complete in specified time (when poll_timeout is not None)
More info about this request:
- Returns:
AsyncOperationLinkObject, link to the asynchronous operation
Downloading Files
- async AsyncClient.download(src_path: str, path_or_file: str | bytes | BinaryIO | BinaryAsyncFileLike, /, **kwargs) AsyncResourceLinkObject[source]
Download the file.
- Parameters:
src_path – source path
path_or_file – destination path or file-like object
timeout – float, tuple or None, request timeout
headers – dict or None, additional request headers
n_retries – int, maximum number of retries
retry_interval – delay between retries in seconds
retry_on – tuple, additional exception classes to retry on
aiohttp_args – dict, additional parameters for
AIOHTTPSessionhttpx_args – dict, additional parameters for
AsyncHTTPXSessionkwargs – any other parameters, accepted by
Session.send_request()
- Raises:
PathNotFoundError – resource was not found on Disk
ForbiddenError – application doesn’t have enough rights for this request
ResourceIsLockedError – resource is locked by another request
- Returns:
AsyncResourceLinkObject, link to the source resource
- async AsyncClient.get_download_link(path: str, /, **kwargs) str[source]
Get a download link for a file (or a directory).
- Parameters:
path – path to the resource
timeout – float, tuple or None, request timeout
headers – dict or None, additional request headers
n_retries – int, maximum number of retries
retry_interval – delay between retries in seconds
retry_on – tuple, additional exception classes to retry on
aiohttp_args – dict, additional parameters for
AIOHTTPSessionhttpx_args – dict, additional parameters for
AsyncHTTPXSessionkwargs – any other parameters, accepted by
Session.send_request()
- Raises:
PathNotFoundError – resource was not found on Disk
ForbiddenError – application doesn’t have enough rights for this request
ResourceIsLockedError – resource is locked by another request
More info about this request:
- Returns:
str
- async AsyncClient.download_by_link(link: str, file_or_path: str | bytes | BinaryIO | BinaryAsyncFileLike, /, **kwargs) None[source]
Download the file from the link.
- Parameters:
link – download link
file_or_path – destination path or file-like object
timeout – float, tuple or None, request timeout
headers – dict or None, additional request headers
n_retries – int, maximum number of retries
retry_interval – delay between retries in seconds
retry_on – tuple, additional exception classes to retry on
aiohttp_args – dict, additional parameters for
AIOHTTPSessionhttpx_args – dict, additional parameters for
AsyncHTTPXSessionkwargs – any other parameters, accepted by
Session.send_request()
File Operations
Creating Directories
- async AsyncClient.mkdir(path: str, /, **kwargs) AsyncResourceLinkObject[source]
Create a new directory.
- Parameters:
path – path to the directory to be created
fields – list of keys to be included in the response
timeout – float, tuple or None, request timeout
headers – dict or None, additional request headers
n_retries – int, maximum number of retries
retry_interval – delay between retries in seconds
retry_on – tuple, additional exception classes to retry on
aiohttp_args – dict, additional parameters for
AIOHTTPSessionhttpx_args – dict, additional parameters for
AsyncHTTPXSessionkwargs – any other parameters, accepted by
Session.send_request()
- Raises:
ParentNotFoundError – parent directory doesn’t exist
DirectoryExistsError – destination path already exists
InsufficientStorageError – cannot create directory due to lack of storage space
ForbiddenError – application doesn’t have enough rights for this request
ResourceIsLockedError – resource is locked by another request
More info about this request:
- Returns:
- async AsyncClient.makedirs(path: str, /, **kwargs) AsyncResourceLinkObject[source]
Create a new directory at path. If its parent directory doesn’t exist it will also be created recursively.
- Parameters:
path – path to the directory to be created
fields – list of keys to be included in the response
timeout – float, tuple or None, request timeout
headers – dict or None, additional request headers
n_retries – int, maximum number of retries
retry_interval – delay between retries in seconds
retry_on – tuple, additional exception classes to retry on
aiohttp_args – dict, additional parameters for
AIOHTTPSessionhttpx_args – dict, additional parameters for
AsyncHTTPXSessionkwargs – any other parameters, accepted by
Session.send_request()
- Raises:
DirectoryExistsError – destination path already exists
InsufficientStorageError – cannot create directory due to lack of storage space
ForbiddenError – application doesn’t have enough rights for this request
ResourceIsLockedError – resource is locked by another request
- Returns:
Removing Files
- async AsyncClient.remove(path: str, /, **kwargs) AsyncOperationLinkObject | 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
md5 – str, 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
wait – bool, if
True, the method will wait until the asynchronous operation is completedpoll_interval – float, interval in seconds between subsequent operation status queries
poll_timeout – float or None, total polling timeout (None means no timeout), if this timeout is exceeded, an exception is raised
timeout – float, tuple or None, request timeout
headers – dict or None, additional request headers
n_retries – int, maximum number of retries
retry_interval – delay between retries in seconds
retry_on – tuple, additional exception classes to retry on
aiohttp_args – dict, additional parameters for
AIOHTTPSessionhttpx_args – dict, additional parameters for
AsyncHTTPXSessionkwargs – any other parameters, accepted by
Session.send_request()
- Raises:
PathNotFoundError – resource was not found on Disk
ForbiddenError – application doesn’t have enough rights for this request
BadRequestError – MD5 check is only available for files
ResourceIsLockedError – resource is locked by another request
OperationNotFoundError – requested operation was not found
AsyncOperationFailedError – requested operation failed
AsyncOperationPollingTimeoutError – requested operation did not complete in specified time (when poll_timeout is not None)
More info about this request:
- Returns:
AsyncOperationLinkObjectif the operation is performed asynchronously, None otherwise
Copying Files
- async AsyncClient.copy(src_path: str, dst_path: str, /, **kwargs) AsyncResourceLinkObject | AsyncOperationLinkObject[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
wait – bool, if
True, the method will wait until the asynchronous operation is completedpoll_interval – float, interval in seconds between subsequent operation status queries
poll_timeout – float or None, total polling timeout (None means no timeout), if this timeout is exceeded, an exception is raised
timeout – float, tuple or None, request timeout
headers – dict or None, additional request headers
n_retries – int, maximum number of retries
retry_interval – delay between retries in seconds
retry_on – tuple, additional exception classes to retry on
aiohttp_args – dict, additional parameters for
AIOHTTPSessionhttpx_args – dict, additional parameters for
AsyncHTTPXSessionkwargs – any other parameters, accepted by
Session.send_request()
- Raises:
PathNotFoundError – resource was not found on Disk
PathExistsError – destination path already exists
ForbiddenError – application doesn’t have enough rights for this request
InsufficientStorageError – cannot complete request due to lack of storage space
ResourceIsLockedError – resource is locked by another request
UploadTrafficLimitExceededError – upload limit has been exceeded
OperationNotFoundError – requested operation was not found
AsyncOperationFailedError – requested operation failed
AsyncOperationPollingTimeoutError – requested operation did not complete in specified time (when poll_timeout is not None)
More info about this request:
- Returns:
Moving Files
- async AsyncClient.move(src_path: str, dst_path: str, /, **kwargs) AsyncOperationLinkObject | AsyncResourceLinkObject[source]
Move src_path to dst_path.
- Parameters:
src_path – source path to be moved
dst_path – destination path
overwrite – bool, 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
wait – bool, if
True, the method will wait until the asynchronous operation is completedpoll_interval – float, interval in seconds between subsequent operation status queries
poll_timeout – float or None, total polling timeout (None means no timeout), if this timeout is exceeded, an exception is raised
timeout – float, tuple or None, request timeout
headers – dict or None, additional request headers
n_retries – int, maximum number of retries
retry_interval – delay between retries in seconds
retry_on – tuple, additional exception classes to retry on
aiohttp_args – dict, additional parameters for
AIOHTTPSessionhttpx_args – dict, additional parameters for
AsyncHTTPXSessionkwargs – any other parameters, accepted by
Session.send_request()
- Raises:
PathNotFoundError – resource was not found on Disk
PathExistsError – destination path already exists
ForbiddenError – application doesn’t have enough rights for this request
ResourceIsLockedError – resource is locked by another request
OperationNotFoundError – requested operation was not found
AsyncOperationFailedError – requested operation failed
AsyncOperationPollingTimeoutError – requested operation did not complete in specified time (when poll_timeout is not None)
More info about this request:
- Returns:
- async AsyncClient.rename(src_path: str, new_name: str, /, **kwargs) AsyncResourceLinkObject | AsyncOperationLinkObject[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
overwrite – bool, 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
wait – bool, if
True, the method will wait until the asynchronous operation is completedpoll_interval – float, interval in seconds between subsequent operation status queries
poll_timeout – float or None, total polling timeout (None means no timeout), if this timeout is exceeded, an exception is raised
timeout – float, tuple or None, request timeout
headers – dict or None, additional request headers
n_retries – int, maximum number of retries
retry_interval – delay between retries in seconds
retry_on – tuple, additional exception classes to retry on
aiohttp_args – dict, additional parameters for
AIOHTTPSessionhttpx_args – dict, additional parameters for
AsyncHTTPXSessionkwargs – any other parameters, accepted by
Session.send_request()
- Raises:
PathNotFoundError – resource was not found on Disk
PathExistsError – destination path already exists
ForbiddenError – application doesn’t have enough rights for this request
ResourceIsLockedError – resource is locked by another request
ValueError – new_name is not a valid filename or src_path is root
OperationNotFoundError – requested operation was not found
AsyncOperationFailedError – requested operation failed
AsyncOperationPollingTimeoutError – requested operation did not complete in specified time (when poll_timeout is not None)
- Returns:
Setting Custom Properties
- async AsyncClient.patch(path: str, properties: dict, /, **kwargs) AsyncResourceObject[source]
Update custom properties of a resource.
- Parameters:
path – path to the resource
properties – dict, custom properties to update
fields – list of keys to be included in the response
timeout – float, tuple or None, request timeout
headers – dict or None, additional request headers
n_retries – int, maximum number of retries
retry_interval – delay between retries in seconds
retry_on – tuple, additional exception classes to retry on
aiohttp_args – dict, additional parameters for
AIOHTTPSessionhttpx_args – dict, additional parameters for
AsyncHTTPXSessionkwargs – any other parameters, accepted by
Session.send_request()
- Raises:
PathNotFoundError – resource was not found on Disk
ForbiddenError – application doesn’t have enough rights for this request
ResourceIsLockedError – resource is locked by another request
More info about this request:
- Returns:
Public Files
Publishing/Unpublishing Files
- async AsyncClient.publish(path: str, /, **kwargs) AsyncResourceLinkObject[source]
Make a resource public.
- Parameters:
path – path to the resource to be published
allow_address_access – bool, specifies the request format, i.e. with personal access settings (when set to True) or without
public_settings –
PublicSettingsor None, public access settings for the resourcefields – list of keys to be included in the response
timeout – float, tuple or None, request timeout
headers – dict or None, additional request headers
n_retries – int, maximum number of retries
retry_interval – delay between retries in seconds
retry_on – tuple, additional exception classes to retry on
aiohttp_args – dict, additional parameters for
AIOHTTPSessionhttpx_args – dict, additional parameters for
AsyncHTTPXSessionkwargs – any other parameters, accepted by
Session.send_request()
- Raises:
PathNotFoundError – resource was not found on Disk
ForbiddenError – application doesn’t have enough rights for this request
ResourceIsLockedError – resource is locked by another request
More info about this request:
- Returns:
AsyncResourceLinkObject, link to the resource
- async AsyncClient.unpublish(path: str, /, **kwargs) AsyncResourceLinkObject[source]
Make a public resource private.
- Parameters:
path – path to the resource to be unpublished
allow_address_access – bool, specifies the request format, i.e. with personal access settings (when set to True) or without
fields – list of keys to be included in the response
timeout – float, tuple or None, request timeout
headers – dict or None, additional request headers
n_retries – int, maximum number of retries
retry_interval – delay between retries in seconds
retry_on – tuple, additional exception classes to retry on
aiohttp_args – dict, additional parameters for
AIOHTTPSessionhttpx_args – dict, additional parameters for
AsyncHTTPXSessionkwargs – any other parameters, accepted by
Session.send_request()
- Raises:
PathNotFoundError – resource was not found on Disk
ForbiddenError – application doesn’t have enough rights for this request
ResourceIsLockedError – resource is locked by another request
More info about this request:
- Returns:
Metadata About Public Files
- async AsyncClient.get_public_meta(public_key: str, /, **kwargs) AsyncPublicResourceObject[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
sort – str, field to be used as a key to sort children resources
preview_size – file preview size
preview_crop – bool, allow preview crop
fields – list of keys to be included in the response
timeout – float, tuple or None, request timeout
headers – dict or None, additional request headers
n_retries – int, maximum number of retries
retry_interval – delay between retries in seconds
retry_on – tuple, additional exception classes to retry on
aiohttp_args – dict, additional parameters for
AIOHTTPSessionhttpx_args – dict, additional parameters for
AsyncHTTPXSessionkwargs – any other parameters, accepted by
Session.send_request()
- Raises:
PathNotFoundError – resource was not found on Disk
ForbiddenError – application doesn’t have enough rights for this request
More info about this request:
- Returns:
- async AsyncClient.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
timeout – float, tuple or None, request timeout
headers – dict or None, additional request headers
n_retries – int, maximum number of retries
retry_interval – delay between retries in seconds
retry_on – tuple, additional exception classes to retry on
aiohttp_args – dict, additional parameters for
AIOHTTPSessionhttpx_args – dict, additional parameters for
AsyncHTTPXSessionkwargs – any other parameters, accepted by
Session.send_request()
- Raises:
PathNotFoundError – resource was not found on Disk
ForbiddenError – application doesn’t have enough rights for this request
- Returns:
“file” or “dir”
- async AsyncClient.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
timeout – float, tuple or None, request timeout
headers – dict or None, additional request headers
n_retries – int, maximum number of retries
retry_interval – delay between retries in seconds
retry_on – tuple, additional exception classes to retry on
aiohttp_args – dict, additional parameters for
AIOHTTPSessionhttpx_args – dict, additional parameters for
AsyncHTTPXSessionkwargs – any other parameters, accepted by
Session.send_request()
- 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 AsyncClient.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
timeout – float, tuple or None, request timeout
headers – dict or None, additional request headers
n_retries – int, maximum number of retries
retry_interval – delay between retries in seconds
retry_on – tuple, additional exception classes to retry on
aiohttp_args – dict, additional parameters for
AIOHTTPSessionhttpx_args – dict, additional parameters for
AsyncHTTPXSessionkwargs – any other parameters, accepted by
Session.send_request()
- 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 AsyncClient.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
timeout – float, tuple or None, request timeout
headers – dict or None, additional request headers
n_retries – int, maximum number of retries
retry_interval – delay between retries in seconds
retry_on – tuple, additional exception classes to retry on
aiohttp_args – dict, additional parameters for
AIOHTTPSessionhttpx_args – dict, additional parameters for
AsyncHTTPXSessionkwargs – any other parameters, accepted by
Session.send_request()
- Raises:
ForbiddenError – application doesn’t have enough rights for this request
- Returns:
bool
Downloading Public Files
- async AsyncClient.get_public_download_link(public_key: str, /, **kwargs) str[source]
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
timeout – float, tuple or None, request timeout
headers – dict or None, additional request headers
n_retries – int, maximum number of retries
retry_interval – delay between retries in seconds
retry_on – tuple, additional exception classes to retry on
aiohttp_args – dict, additional parameters for
AIOHTTPSessionhttpx_args – dict, additional parameters for
AsyncHTTPXSessionkwargs – any other parameters, accepted by
Session.send_request()
- Raises:
PathNotFoundError – resource was not found on Disk
ForbiddenError – application doesn’t have enough rights for this request
ResourceIsLockedError – resource is locked by another request
More info about this request:
- Returns:
str
- async AsyncClient.download_public(public_key: str, file_or_path: str | bytes | BinaryIO | BinaryAsyncFileLike, /, **kwargs) AsyncPublicResourceLinkObject[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
timeout – float, tuple or None, request timeout
headers – dict or None, additional request headers
n_retries – int, maximum number of retries
retry_interval – delay between retries in seconds
retry_on – tuple, additional exception classes to retry on
aiohttp_args – dict, additional parameters for
AIOHTTPSessionhttpx_args – dict, additional parameters for
AsyncHTTPXSessionkwargs – any other parameters, accepted by
Session.send_request()
- Raises:
PathNotFoundError – resource was not found on Disk
ForbiddenError – application doesn’t have enough rights for this request
ResourceIsLockedError – resource is locked by another request
- Returns:
Saving Public Resources to Disk
- async AsyncClient.save_to_disk(public_key: str, /, **kwargs) AsyncResourceLinkObject | AsyncOperationLinkObject[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
wait – bool, if
True, the method will wait until the asynchronous operation is completedpoll_interval – float, interval in seconds between subsequent operation status queries
poll_timeout – float or None, total polling timeout (None means no timeout), if this timeout is exceeded, an exception is raised
timeout – float, tuple or None, request timeout
headers – dict or None, additional request headers
n_retries – int, maximum number of retries
retry_interval – delay between retries in seconds
retry_on – tuple, additional exception classes to retry on
aiohttp_args – dict, additional parameters for
AIOHTTPSessionhttpx_args – dict, additional parameters for
AsyncHTTPXSessionkwargs – any other parameters, accepted by
Session.send_request()
- Raises:
PathNotFoundError – resource was not found on Disk
ForbiddenError – application doesn’t have enough rights for this request
ResourceIsLockedError – resource is locked by another request
InsufficientStorageError – cannot upload file due to lack of storage space
UploadTrafficLimitExceededError – upload limit has been exceeded
OperationNotFoundError – requested operation was not found
AsyncOperationFailedError – requested operation failed
AsyncOperationPollingTimeoutError – requested operation did not complete in specified time (when poll_timeout is not None)
More info about this request:
- Returns:
Listing Public Files
- async AsyncClient.get_public_resources(**kwargs) AsyncPublicResourcesListObject[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_crop – bool, 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
timeout – float, tuple or None, request timeout
headers – dict or None, additional request headers
n_retries – int, maximum number of retries
retry_interval – delay between retries in seconds
retry_on – tuple, additional exception classes to retry on
aiohttp_args – dict, additional parameters for
AIOHTTPSessionhttpx_args – dict, additional parameters for
AsyncHTTPXSessionkwargs – any other parameters, accepted by
Session.send_request()
- Raises:
ForbiddenError – application doesn’t have enough rights for this request
More info about this request:
- Returns:
- async AsyncClient.get_all_public_resources(*, max_items: int | None = None, **kwargs) AsyncGenerator[AsyncPublicResourceObject, None][source]
Get a list of all public resources.
- Parameters:
max_items – int or None, maximum number of returned items (None means unlimited)
offset – offset from the beginning of the list
limit – maximum number of elements in the list
preview_size – size of the file preview
preview_crop – bool, 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
timeout – float or tuple, request timeout
headers – dict or None, additional request headers
n_retries – int, maximum number of retries
retry_interval – delay between retries in seconds
retry_on – tuple, additional exception classes to retry on
requests_args – dict, additional parameters for
RequestsSessionhttpx_args – dict, additional parameters for
HTTPXSessioncurl_options – dict, additional options for
PycURLSessionkwargs – any other parameters, accepted by
Session.send_request()
- Raises:
ForbiddenError – application doesn’t have enough rights for this request
More info about this request:
- Returns:
async generator of
AsyncPublicResourceObject
Public Access Settings
- async AsyncClient.get_public_settings(path: str, /, **kwargs) PublicSettingsObject[source]
Get public settings of a resource.
- Parameters:
path – path to the resource
allow_address_access – bool, specifies the request format, i.e. with personal access settings (when set to True) or without
timeout – float or tuple, request timeout
headers – dict or None, additional request headers
n_retries – int, maximum number of retries
retry_interval – delay between retries in seconds
retry_on – tuple, additional exception classes to retry on
aiohttp_args – dict, additional parameters for
AIOHTTPSessionhttpx_args – dict, additional parameters for
AsyncHTTPXSessionkwargs – any other parameters, accepted by
Session.send_request()
- Raises:
PathNotFoundError – resource was not found on Disk
ForbiddenError – application doesn’t have enough rights for this request
ResourceIsLockedError – resource is locked by another request
More info about this request:
- Returns:
- async AsyncClient.get_public_available_settings(path: str, /, **kwargs) PublicAvailableSettingsObject[source]
Get public settings of a shared resource for the current OAuth token owner.
- Parameters:
path – path to the resource
timeout – float or tuple, request timeout
headers – dict or None, additional request headers
n_retries – int, maximum number of retries
retry_interval – delay between retries in seconds
retry_on – tuple, additional exception classes to retry on
aiohttp_args – dict, additional parameters for
AIOHTTPSessionhttpx_args – dict, additional parameters for
AsyncHTTPXSessionkwargs – any other parameters, accepted by
Session.send_request()
- Raises:
PathNotFoundError – resource was not found on Disk
ForbiddenError – application doesn’t have enough rights for this request
ResourceIsLockedError – resource is locked by another request
More info about this request:
- Returns:
- async AsyncClient.update_public_settings(path: str, public_settings: PublicSettings, /, **kwargs) None[source]
Update public settings of a shared resource.
- Parameters:
path – path to the resource
public_settings –
PublicSettings, public access settings for the resourcetimeout – float or tuple, request timeout
headers – dict or None, additional request headers
n_retries – int, maximum number of retries
retry_interval – delay between retries in seconds
retry_on – tuple, additional exception classes to retry on
aiohttp_args – dict, additional parameters for
AIOHTTPSessionhttpx_args – dict, additional parameters for
AsyncHTTPXSessionkwargs – any other parameters, accepted by
Session.send_request()
- Raises:
PathNotFoundError – resource was not found on Disk
ForbiddenError – application doesn’t have enough rights for this request
ResourceIsLockedError – resource is locked by another request
More info about this request:
- Returns:
None
Trash
- async AsyncClient.get_trash_meta(path: str, /, **kwargs) AsyncTrashResourceObject[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_crop – bool, cut the preview to the size specified in the preview_size
sort – str, field to be used as a key to sort children resources
fields – list of keys to be included in the response
timeout – float, tuple or None, request timeout
headers – dict or None, additional request headers
n_retries – int, maximum number of retries
retry_interval – delay between retries in seconds
retry_on – tuple, additional exception classes to retry on
aiohttp_args – dict, additional parameters for
AIOHTTPSessionhttpx_args – dict, additional parameters for
AsyncHTTPXSessionkwargs – any other parameters, accepted by
Session.send_request()
- Raises:
PathNotFoundError – resource was not found on Disk
ForbiddenError – application doesn’t have enough rights for this request
More info about this request:
- Returns:
- async AsyncClient.trash_exists(path: str, /, **kwargs) bool[source]
Check whether the trash resource at path exists.
- Parameters:
path – path to the trash resource
timeout – float, tuple or None, request timeout
headers – dict or None, additional request headers
n_retries – int, maximum number of retries
retry_interval – delay between retries in seconds
retry_on – tuple, additional exception classes to retry on
aiohttp_args – dict, additional parameters for
AIOHTTPSessionhttpx_args – dict, additional parameters for
AsyncHTTPXSessionkwargs – any other parameters, accepted by
Session.send_request()
- Raises:
ForbiddenError – application doesn’t have enough rights for this request
- Returns:
bool
- async AsyncClient.restore_trash(path: str, dst_path: str | None = None, **kwargs) AsyncResourceLinkObject | AsyncOperationLinkObject[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
overwrite – bool, 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
wait – bool, if
True, the method will wait until the asynchronous operation is completedpoll_interval – float, interval in seconds between subsequent operation status queries
poll_timeout – float or None, total polling timeout (None means no timeout), if this timeout is exceeded, an exception is raised
timeout – float, tuple or None, request timeout
headers – dict or None, additional request headers
n_retries – int, maximum number of retries
retry_interval – delay between retries in seconds
retry_on – tuple, additional exception classes to retry on
aiohttp_args – dict, additional parameters for
AIOHTTPSessionhttpx_args – dict, additional parameters for
AsyncHTTPXSessionkwargs – any other parameters, accepted by
Session.send_request()
- Raises:
PathNotFoundError – resource was not found on Disk
PathExistsError – destination path already exists
ForbiddenError – application doesn’t have enough rights for this request
ResourceIsLockedError – resource is locked by another request
OperationNotFoundError – requested operation was not found
AsyncOperationFailedError – requested operation failed
AsyncOperationPollingTimeoutError – requested operation did not complete in specified time (when poll_timeout is not None)
More info about this request:
- Returns:
- async AsyncClient.remove_trash(path: str, /, **kwargs) AsyncOperationLinkObject | 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
wait – bool, if
True, the method will wait until the asynchronous operation is completedpoll_interval – float, interval in seconds between subsequent operation status queries
poll_timeout – float or None, total polling timeout (None means no timeout), if this timeout is exceeded, an exception is raised
timeout – float, tuple or None, request timeout
headers – dict or None, additional request headers
n_retries – int, maximum number of retries
retry_interval – delay between retries in seconds
retry_on – tuple, additional exception classes to retry on
aiohttp_args – dict, additional parameters for
AIOHTTPSessionhttpx_args – dict, additional parameters for
AsyncHTTPXSessionkwargs – any other parameters, accepted by
Session.send_request()
- Raises:
PathNotFoundError – resource was not found on Disk
ForbiddenError – application doesn’t have enough rights for this request
ResourceIsLockedError – resource is locked by another request
OperationNotFoundError – requested operation was not found
AsyncOperationFailedError – requested operation failed
AsyncOperationPollingTimeoutError – requested operation did not complete in specified time (when poll_timeout is not None)
More info about this request:
- Returns:
AsyncOperationLinkObjectif the operation is performed asynchronously, None otherwise
- async AsyncClient.trash_listdir(path: str, /, **kwargs) AsyncGenerator[AsyncTrashResourceObject, None][source]
Get contents of a trash resource.
- Parameters:
path – path to the directory in the trash bin
max_items – int or None, maximum number of returned items (None means unlimited)
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_crop – bool, cut the preview to the size specified in the preview_size
fields – list of keys to be included in the response
timeout – float, tuple or None, request timeout
headers – dict or None, additional request headers
n_retries – int, maximum number of retries
retry_interval – delay between retries in seconds
retry_on – tuple, additional exception classes to retry on
aiohttp_args – dict, additional parameters for
AIOHTTPSessionhttpx_args – dict, additional parameters for
AsyncHTTPXSessionkwargs – any other parameters, accepted by
Session.send_request()
- Raises:
PathNotFoundError – resource was not found on Disk
ForbiddenError – application doesn’t have enough rights for this request
WrongResourceTypeError – resource is not a directory
- Returns:
async generator of
AsyncTrashResourceObject
- async AsyncClient.get_trash_type(path: str, /, **kwargs) str[source]
Get trash resource type.
- Parameters:
path – path to the trash resource
timeout – float, tuple or None, request timeout
headers – dict or None, additional request headers
n_retries – int, maximum number of retries
retry_interval – delay between retries in seconds
retry_on – tuple, additional exception classes to retry on
aiohttp_args – dict, additional parameters for
AIOHTTPSessionhttpx_args – dict, additional parameters for
AsyncHTTPXSessionkwargs – any other parameters, accepted by
Session.send_request()
- Raises:
PathNotFoundError – resource was not found on Disk
ForbiddenError – application doesn’t have enough rights for this request
- Returns:
“file” or “dir”
- async AsyncClient.is_trash_dir(path: str, /, **kwargs) bool[source]
Check whether path is a trash directory.
- Parameters:
path – path to the trash resource
timeout – float, tuple or None, request timeout
headers – dict or None, additional request headers
n_retries – int, maximum number of retries
retry_interval – delay between retries in seconds
retry_on – tuple, additional exception classes to retry on
aiohttp_args – dict, additional parameters for
AIOHTTPSessionhttpx_args – dict, additional parameters for
AsyncHTTPXSessionkwargs – any other parameters, accepted by
Session.send_request()
- 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 AsyncClient.is_trash_file(path: str, /, **kwargs) bool[source]
Check whether path is a trash file.
- Parameters:
path – path to the trash resource
timeout – float, tuple or None, request timeout
headers – dict or None, additional request headers
n_retries – int, maximum number of retries
retry_interval – delay between retries in seconds
retry_on – tuple, additional exception classes to retry on
aiohttp_args – dict, additional parameters for
AIOHTTPSessionhttpx_args – dict, additional parameters for
AsyncHTTPXSessionkwargs – any other parameters, accepted by
Session.send_request()
- 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)
Checking Operation Status
- async AsyncClient.get_operation_status(operation_id: str, /, **kwargs) Literal['in-progress', 'success', 'failed'][source]
Get operation status.
- Parameters:
operation_id – ID of the operation or a link
timeout – float, tuple or None, request timeout
headers – dict or None, additional request headers
n_retries – int, maximum number of retries
retry_interval – delay between retries in seconds
retry_on – tuple, additional exception classes to retry on
aiohttp_args – dict, additional parameters for
AIOHTTPSessionhttpx_args – dict, additional parameters for
AsyncHTTPXSessionkwargs – any other parameters, accepted by
Session.send_request()
- Raises:
OperationNotFoundError – requested operation was not found
More info about this request:
- Returns:
str,
"in-progress"indicates that the operation is currently running,"success"indicates that the operation was successful,"failed"means that the operation failed
- async AsyncClient.wait_for_operation(operation_id: str, /, *, poll_interval: float = 1.0, poll_timeout: float | None = None, **kwargs) None[source]
Wait until an operation is completed. If the operation fails, an exception is raised. Waiting is performed by calling
asyncio.sleep.- Parameters:
operation_id – ID of the operation or a link
poll_interval – float, interval in seconds between subsequent operation status queries
poll_timeout – float or None, total polling timeout (None means no timeout), if this timeout is exceeded, an exception is raised
timeout – float or tuple, request timeout
headers – dict or None, additional request headers
n_retries – int, maximum number of retries
retry_interval – delay between retries in seconds
retry_on – tuple, additional exception classes to retry on
aiohttp_args – dict, additional parameters for
AIOHTTPSessionhttpx_args – dict, additional parameters for
AsyncHTTPXSessionkwargs – any other parameters, accepted by
Session.send_request()
- Raises:
OperationNotFoundError – requested operation was not found
AsyncOperationFailedError – requested operation failed
AsyncOperationPollingTimeoutError – requested operation did not complete in specified time (when poll_timeout is not None)