Synchronous API

class yadisk.Client(id: str = '', secret: str = '', token: str = '', *, default_args: dict[str, Any] | None = None, session: Session | Literal['httpx'] | Literal['pycurl'] | Literal['requests'] | None = None, open_file: Callable[[str | bytes, Literal['rb', 'wb']], BinaryIO] | None = None, session_factory: Callable[[], Session] | None = None)[source]

Implements access to Yandex.Disk REST API (provides synchronous API).

HTTP client implementation can be specified using the session parameter. RequestsSession is used by default. For other options, see Available Session Implementations.

Almost all methods of Client (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 Session subclasses (Available Session Implementations).

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.

  • session

    None, str or an instance of Session. If session is a string, the appropriate session class will be imported, it must be one of the following values:

  • open_fileNone or a function that opens a file for reading or writing (open() by default)

  • session_factory – kept for compatibility, callable that returns an instance of Session

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.

  • session – current session (Session instance)

  • open_file – function that opens a file for reading or writing (open() by default)

The following exceptions may be raised by most API requests:

Raises:
close() None[source]

Closes the session. Do not call this method while there are other active threads using this object.

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

yadisk.YaDisk

alias of Client

Authentication

Client.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 tuple, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

  • retry_ontuple, additional exception classes to retry on

  • requests_argsdict, additional parameters for RequestsSession

  • httpx_argsdict, additional parameters for HTTPXSession

  • curl_optionsdict, additional options for PycURLSession

  • kwargs – any other parameters, accepted by Session.send_request()

Returns:

bool

Client.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

  • scopestr, list of permissions for the application

  • optional_scopestr, 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_verifier value using one of the two possible transformations (plain or S256)

  • code_challenge_method – specifies what function was used to transform the code_verifier value to code_challenge, allowed values are "plain" and "S256" (recommended). If "S256" is used, code_challenge must be produced by hashing the code_verifier value and encoding it to base64

Raises:

ValueError – invalid arguments were passed

Returns:

authentication URL

Client.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

  • scopestr, list of permissions for the application

  • optional_scopestr, 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_verifier value using one of the two possible transformations (plain or S256)

  • code_challenge_method – specifies what function was used to transform the code_verifier value to code_challenge, allowed values are "plain" and "S256" (recommended). If "S256" is used, code_challenge must be produced by hashing the code_verifier value and encoding it to base64

Raises:

ValueError – invalid arguments were passed

Returns:

authentication URL

Client.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 the device_code for the token using the Client.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

  • scopestr, list of permissions for the application

  • optional_scopestr, list of optional permissions for the application

  • timeoutfloat or tuple, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

  • retry_ontuple, additional exception classes to retry on

  • requests_argsdict, additional parameters for RequestsSession

  • httpx_argsdict, additional parameters for HTTPXSession

  • curl_optionsdict, additional options for PycURLSession

  • kwargs – any other parameters, accepted by Session.send_request()

Raises:
Returns:

DeviceCodeObject containing user_code and device_code

Client.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)

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

  • code_verifierstr, verifier code, used with the PKCE authorization flow

  • timeoutfloat or tuple, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

  • retry_ontuple, additional exception classes to retry on

  • requests_argsdict, additional parameters for RequestsSession

  • httpx_argsdict, additional parameters for HTTPXSession

  • curl_optionsdict, additional options for PycURLSession

  • kwargs – any other parameters, accepted by Session.send_request()

Raises:
Returns:

TokenObject

Client.get_token_from_device_code(device_code: str, /, **kwargs) TokenObject[source]

Get a new token from a device code, previously obtained with Client.get_device_code().

Parameters:
  • device_code – device code, obtained from Client.get_device_code()

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

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

  • timeoutfloat or tuple, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

  • retry_ontuple, additional exception classes to retry on

  • requests_argsdict, additional parameters for RequestsSession

  • httpx_argsdict, additional parameters for HTTPXSession

  • curl_optionsdict, additional options for PycURLSession

  • kwargs – any other parameters, accepted by Session.send_request()

Raises:
Returns:

TokenObject

Client.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 tuple, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

  • retry_ontuple, additional exception classes to retry on

  • requests_argsdict, additional parameters for RequestsSession

  • httpx_argsdict, additional parameters for HTTPXSession

  • curl_optionsdict, additional options for PycURLSession

  • kwargs – any other parameters, accepted by Session.send_request()

Raises:
Returns:

TokenObject

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

Revoke the token.

Parameters:
  • token – token to revoke

  • timeoutfloat or tuple, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

  • retry_ontuple, additional exception classes to retry on

  • requests_argsdict, additional parameters for RequestsSession

  • httpx_argsdict, additional parameters for HTTPXSession

  • curl_optionsdict, additional options for PycURLSession

  • kwargs – any other parameters, accepted by Session.send_request()

Raises:
Returns:

TokenRevokeStatusObject

Disk Info

Client.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

  • timeoutfloat or tuple, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

  • retry_ontuple, additional exception classes to retry on

  • requests_argsdict, additional parameters for RequestsSession

  • httpx_argsdict, additional parameters for HTTPXSession

  • curl_optionsdict, additional options for PycURLSession

  • kwargs – 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:

DiskInfoObject

Metadata About Files

Client.get_meta(path: str, /, **kwargs) SyncResourceObject[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 tuple, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

  • retry_ontuple, additional exception classes to retry on

  • requests_argsdict, additional parameters for RequestsSession

  • httpx_argsdict, additional parameters for HTTPXSession

  • curl_optionsdict, additional options for PycURLSession

  • kwargs – any other parameters, accepted by Session.send_request()

Raises:

More info about this request:

Returns:

SyncResourceObject

Client.listdir(path: str, /, **kwargs) Generator[SyncResourceObject, None, None][source]

Get contents of path.

Parameters:
  • path – path to the directory

  • max_itemsint 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_cropbool, cut the preview to the size specified in the preview_size

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

  • timeoutfloat or tuple, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

  • retry_ontuple, additional exception classes to retry on

  • requests_argsdict, additional parameters for RequestsSession

  • httpx_argsdict, additional parameters for HTTPXSession

  • curl_optionsdict, additional options for PycURLSession

  • kwargs – any other parameters, accepted by Session.send_request()

Raises:
Returns:

generator of ResourceObject

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

Check whether path exists.

Parameters:
  • path – path to the resource

  • timeoutfloat or tuple, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

  • retry_ontuple, additional exception classes to retry on

  • requests_argsdict, additional parameters for RequestsSession

  • httpx_argsdict, additional parameters for HTTPXSession

  • curl_optionsdict, additional options for PycURLSession

  • kwargs – any other parameters, accepted by Session.send_request()

Raises:

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

Returns:

bool

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

Get resource type.

Parameters:
  • path – path to the resource

  • timeoutfloat or tuple, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

  • retry_ontuple, additional exception classes to retry on

  • requests_argsdict, additional parameters for RequestsSession

  • httpx_argsdict, additional parameters for HTTPXSession

  • curl_optionsdict, additional options for PycURLSession

  • kwargs – any other parameters, accepted by Session.send_request()

Raises:
Returns:

“file” or “dir”

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

Check whether path is a file.

Parameters:
  • path – path to the resource

  • timeoutfloat or tuple, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

  • retry_ontuple, additional exception classes to retry on

  • requests_argsdict, additional parameters for RequestsSession

  • httpx_argsdict, additional parameters for HTTPXSession

  • curl_optionsdict, additional options for PycURLSession

  • kwargs – 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)

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

Check whether path is a directory.

Parameters:
  • path – path to the resource

  • timeoutfloat or tuple, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

  • retry_ontuple, additional exception classes to retry on

  • requests_argsdict, additional parameters for RequestsSession

  • httpx_argsdict, additional parameters for HTTPXSession

  • curl_optionsdict, additional options for PycURLSession

  • kwargs – 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)

Client.get_files(*, max_items: int | None = None, **kwargs) Generator[SyncResourceObject, None, None][source]

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

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

  • max_itemsint 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

  • 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 tuple, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

  • retry_ontuple, additional exception classes to retry on

  • requests_argsdict, additional parameters for RequestsSession

  • httpx_argsdict, additional parameters for HTTPXSession

  • curl_optionsdict, additional options for PycURLSession

  • kwargs – 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:

generator of ResourceObject

Client.get_last_uploaded(**kwargs) list[SyncResourceObject][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 tuple, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

  • retry_ontuple, additional exception classes to retry on

  • requests_argsdict, additional parameters for RequestsSession

  • httpx_argsdict, additional parameters for HTTPXSession

  • curl_optionsdict, additional options for PycURLSession

  • kwargs – 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:

generator of ResourceObject

Uploading Files

Client.upload(file_or_path: str | bytes | BinaryIO | Callable[[], Iterator[bytes]], dst_path: str, /, **kwargs) SyncResourceLinkObject[source]

Upload a file to disk.

Parameters:
  • file_or_path – path, file-like object to be uploaded or a function that returns an iterator (or generator)

  • dst_path – destination path

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

  • spoof_user_agentbool, 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

  • timeoutfloat or tuple, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

  • retry_ontuple, additional exception classes to retry on

  • requests_argsdict, additional parameters for RequestsSession

  • httpx_argsdict, additional parameters for HTTPXSession

  • curl_optionsdict, additional options for PycURLSession

  • kwargs – any other parameters, accepted by Session.send_request()

Raises:
Returns:

SyncResourceLinkObject, link to the destination resource

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

Parameters:
  • path – destination path

  • overwritebool, determines whether to overwrite the destination

  • spoof_user_agentbool, 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

  • timeoutfloat or tuple, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

  • retry_ontuple, additional exception classes to retry on

  • requests_argsdict, additional parameters for RequestsSession

  • httpx_argsdict, additional parameters for HTTPXSession

  • curl_optionsdict, additional options for PycURLSession

  • kwargs – any other parameters, accepted by Session.send_request()

Raises:

More info about this request:

Returns:

str

Get a link to upload the file using the PUT request. This is similar to Client.get_upload_link(), except it returns an instance of ResourceUploadLinkObject which also contains an asynchronous operation ID.

Parameters:
  • path – destination path

  • overwritebool, determines whether to overwrite the destination

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

  • spoof_user_agentbool, 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

  • timeoutfloat or tuple, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

  • retry_ontuple, additional exception classes to retry on

  • requests_argsdict, additional parameters for RequestsSession

  • httpx_argsdict, additional parameters for HTTPXSession

  • curl_optionsdict, additional options for PycURLSession

  • kwargs – any other parameters, accepted by Session.send_request()

Raises:
Returns:

ResourceUploadLinkObject

Upload a file to disk using an upload link.

Parameters:
  • file_or_path – path, file-like object to be uploaded or a function that returns an iterator (or generator)

  • link – upload link

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

  • timeoutfloat or tuple, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

  • retry_ontuple, additional exception classes to retry on

  • requests_argsdict, additional parameters for RequestsSession

  • httpx_argsdict, additional parameters for HTTPXSession

  • curl_optionsdict, additional options for PycURLSession

  • kwargs – any other parameters, accepted by Session.send_request()

Raises:

InsufficientStorageError – cannot upload file due to lack of storage space

Client.upload_url(url: str, path: str, /, **kwargs) SyncOperationLinkObject[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

  • waitbool, if True, the method will wait until the asynchronous operation is completed

  • poll_intervalfloat, interval in seconds between subsequent operation status queries

  • poll_timeoutfloat or None, total polling timeout (None means no timeout), if this timeout is exceeded, an exception is raised

  • timeoutfloat or tuple, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

  • retry_ontuple, additional exception classes to retry on

  • requests_argsdict, additional parameters for RequestsSession

  • httpx_argsdict, additional parameters for HTTPXSession

  • curl_optionsdict, additional options for PycURLSession

  • kwargs – any other parameters, accepted by Session.send_request()

Raises:

More info about this request:

Returns:

SyncOperationLinkObject, link to the asynchronous operation

Downloading Files

Client.download(src_path: str, file_or_path: str | bytes | BinaryIO, /, **kwargs) SyncResourceLinkObject[source]

Download the file.

Parameters:
  • src_path – source path

  • file_or_path – destination path or file-like object

  • timeoutfloat or tuple, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

  • retry_ontuple, additional exception classes to retry on

  • requests_argsdict, additional parameters for RequestsSession

  • httpx_argsdict, additional parameters for HTTPXSession

  • curl_optionsdict, additional options for PycURLSession

  • kwargs – any other parameters, accepted by Session.send_request()

Raises:
Returns:

SyncResourceLinkObject, link to the source resource

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

Parameters:
  • path – path to the resource

  • timeoutfloat or tuple, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

  • retry_ontuple, additional exception classes to retry on

  • requests_argsdict, additional parameters for RequestsSession

  • httpx_argsdict, additional parameters for HTTPXSession

  • curl_optionsdict, additional options for PycURLSession

  • kwargs – any other parameters, accepted by Session.send_request()

Raises:

More info about this request:

Returns:

str

Download the file from the link.

Parameters:
  • link – download link

  • file_or_path – destination path or file-like object

  • timeoutfloat or tuple, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

  • retry_ontuple, additional exception classes to retry on

  • requests_argsdict, additional parameters for RequestsSession

  • httpx_argsdict, additional parameters for HTTPXSession

  • curl_optionsdict, additional options for PycURLSession

  • kwargs – any other parameters, accepted by Session.send_request()

File Operations

Creating Directories

Client.mkdir(path: str, /, **kwargs) SyncResourceLinkObject[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 tuple, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

  • retry_ontuple, additional exception classes to retry on

  • requests_argsdict, additional parameters for RequestsSession

  • httpx_argsdict, additional parameters for HTTPXSession

  • curl_optionsdict, additional options for PycURLSession

  • kwargs – any other parameters, accepted by Session.send_request()

Raises:

More info about this request:

Returns:

SyncResourceLinkObject

Client.makedirs(path: str, /, **kwargs) SyncResourceLinkObject[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

  • timeoutfloat or tuple, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

  • retry_ontuple, additional exception classes to retry on

  • requests_argsdict, additional parameters for RequestsSession

  • httpx_argsdict, additional parameters for HTTPXSession

  • curl_optionsdict, additional options for PycURLSession

  • kwargs – any other parameters, accepted by Session.send_request()

Raises:
Returns:

SyncResourceLinkObject

Removing Files

Client.remove(path: str, /, **kwargs) SyncOperationLinkObject | 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

  • waitbool, if True, the method will wait until the asynchronous operation is completed

  • poll_intervalfloat, interval in seconds between subsequent operation status queries

  • poll_timeoutfloat or None, total polling timeout (None means no timeout), if this timeout is exceeded, an exception is raised

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

  • timeoutfloat or tuple, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

  • retry_ontuple, additional exception classes to retry on

  • requests_argsdict, additional parameters for RequestsSession

  • httpx_argsdict, additional parameters for HTTPXSession

  • curl_optionsdict, additional options for PycURLSession

  • kwargs – any other parameters, accepted by Session.send_request()

Raises:

More info about this request:

Returns:

SyncOperationLinkObject if the operation is performed asynchronously, None otherwise

Copying Files

Client.copy(src_path: str, dst_path: str, /, **kwargs) SyncResourceLinkObject | SyncOperationLinkObject[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

  • waitbool, if True, the method will wait until the asynchronous operation is completed

  • poll_intervalfloat, interval in seconds between subsequent operation status queries

  • poll_timeoutfloat or None, total polling timeout (None means no timeout), if this timeout is exceeded, an exception is raised

  • timeoutfloat or tuple, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

  • retry_ontuple, additional exception classes to retry on

  • requests_argsdict, additional parameters for RequestsSession

  • httpx_argsdict, additional parameters for HTTPXSession

  • curl_optionsdict, additional options for PycURLSession

  • kwargs – any other parameters, accepted by Session.send_request()

Raises:

More info about this request:

Returns:

SyncResourceLinkObject or SyncOperationLinkObject

Moving Files

Client.move(src_path: str, dst_path: str, /, **kwargs) SyncResourceLinkObject | SyncOperationLinkObject[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

  • waitbool, if True, the method will wait until the asynchronous operation is completed

  • poll_intervalfloat, interval in seconds between subsequent operation status queries

  • poll_timeoutfloat or None, total polling timeout (None means no timeout), if this timeout is exceeded, an exception is raised

  • timeoutfloat or tuple, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

  • retry_ontuple, additional exception classes to retry on

  • requests_argsdict, additional parameters for RequestsSession

  • httpx_argsdict, additional parameters for HTTPXSession

  • curl_optionsdict, additional options for PycURLSession

  • kwargs – any other parameters, accepted by Session.send_request()

Raises:

More info about this request:

Returns:

SyncResourceLinkObject or SyncOperationLinkObject

Client.rename(src_path: str, new_name: str, /, **kwargs) SyncResourceLinkObject | SyncOperationLinkObject[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

  • waitbool, if True, the method will wait until the asynchronous operation is completed

  • poll_intervalfloat, interval in seconds between subsequent operation status queries

  • poll_timeoutfloat or None, total polling timeout (None means no timeout), if this timeout is exceeded, an exception is raised

  • timeoutfloat or tuple, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

  • retry_ontuple, additional exception classes to retry on

  • requests_argsdict, additional parameters for RequestsSession

  • httpx_argsdict, additional parameters for HTTPXSession

  • curl_optionsdict, additional options for PycURLSession

  • kwargs – any other parameters, accepted by Session.send_request()

Raises:
Returns:

SyncResourceLinkObject or SyncOperationLinkObject

Setting Custom Properties

Client.patch(path: str, properties: dict, /, **kwargs) SyncResourceObject[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 tuple, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

  • retry_ontuple, additional exception classes to retry on

  • requests_argsdict, additional parameters for RequestsSession

  • httpx_argsdict, additional parameters for HTTPXSession

  • curl_optionsdict, additional options for PycURLSession

  • kwargs – any other parameters, accepted by Session.send_request()

Raises:

More info about this request:

Returns:

ResourceObject

Public Files

Publishing/Unpublishing Files

Client.publish(path: str, /, **kwargs) SyncResourceLinkObject[source]

Make a resource public.

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

  • allow_address_accessbool, specifies the request format, i.e. with personal access settings (when set to True) or without

  • public_settingsPublicSettings or None, public access settings for the resource

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

  • timeoutfloat or tuple, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

  • retry_ontuple, additional exception classes to retry on

  • requests_argsdict, additional parameters for RequestsSession

  • httpx_argsdict, additional parameters for HTTPXSession

  • curl_optionsdict, additional options for PycURLSession

  • kwargs – any other parameters, accepted by Session.send_request()

Raises:

More info about this request:

Returns:

SyncResourceLinkObject, link to the resource

Client.unpublish(path: str, /, **kwargs) SyncResourceLinkObject[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 tuple, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

  • retry_ontuple, additional exception classes to retry on

  • requests_argsdict, additional parameters for RequestsSession

  • httpx_argsdict, additional parameters for HTTPXSession

  • curl_optionsdict, additional options for PycURLSession

  • kwargs – any other parameters, accepted by Session.send_request()

Raises:

More info about this request:

Returns:

SyncResourceLinkObject

Metadata About Public Files

Client.get_public_meta(public_key: str, /, **kwargs) SyncPublicResourceObject[source]

Get meta-information about a public resource.

Parameters:
  • public_key – public key or public URL of the public 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 tuple, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

  • retry_ontuple, additional exception classes to retry on

  • requests_argsdict, additional parameters for RequestsSession

  • httpx_argsdict, additional parameters for HTTPXSession

  • curl_optionsdict, additional options for PycURLSession

  • kwargs – any other parameters, accepted by Session.send_request()

Raises:

More info about this request:

Returns:

SyncPublicResourceObject

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

Get public resource type.

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

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

  • timeoutfloat or tuple, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

  • retry_ontuple, additional exception classes to retry on

  • requests_argsdict, additional parameters for RequestsSession

  • httpx_argsdict, additional parameters for HTTPXSession

  • curl_optionsdict, additional options for PycURLSession

  • kwargs – any other parameters, accepted by Session.send_request()

Raises:
Returns:

“file” or “dir”

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

Check whether the public resource is a public directory.

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

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

  • timeoutfloat or tuple, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

  • retry_ontuple, additional exception classes to retry on

  • requests_argsdict, additional parameters for RequestsSession

  • httpx_argsdict, additional parameters for HTTPXSession

  • curl_optionsdict, additional options for PycURLSession

  • kwargs – 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)

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

Check whether the public resource is a public file.

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

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

  • timeoutfloat or tuple, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

  • retry_ontuple, additional exception classes to retry on

  • requests_argsdict, additional parameters for RequestsSession

  • httpx_argsdict, additional parameters for HTTPXSession

  • curl_optionsdict, additional options for PycURLSession

  • kwargs – 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)

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

Check whether the public resource exists.

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

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

  • timeoutfloat or tuple, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

  • retry_ontuple, additional exception classes to retry on

  • requests_argsdict, additional parameters for RequestsSession

  • httpx_argsdict, additional parameters for HTTPXSession

  • curl_optionsdict, additional options for PycURLSession

  • kwargs – any other parameters, accepted by Session.send_request()

Raises:

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

Returns:

bool

Downloading Public Files

Get a download link for a public resource.

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

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

  • timeoutfloat or tuple, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

  • retry_ontuple, additional exception classes to retry on

  • requests_argsdict, additional parameters for RequestsSession

  • httpx_argsdict, additional parameters for HTTPXSession

  • curl_optionsdict, additional options for PycURLSession

  • kwargs – any other parameters, accepted by Session.send_request()

Raises:

More info about this request:

Returns:

str

Client.download_public(public_key: str, file_or_path: str | bytes | BinaryIO, /, **kwargs) SyncPublicResourceLinkObject[source]

Download the public resource.

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

  • file_or_path – destination path or file-like object

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

  • timeoutfloat or tuple, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

  • retry_ontuple, additional exception classes to retry on

  • requests_argsdict, additional parameters for RequestsSession

  • httpx_argsdict, additional parameters for HTTPXSession

  • curl_optionsdict, additional options for PycURLSession

  • kwargs – any other parameters, accepted by Session.send_request()

Raises:
Returns:

SyncPublicResourceLinkObject

Saving Public Resources to Disk

Client.save_to_disk(public_key: str, /, **kwargs) SyncResourceLinkObject | SyncOperationLinkObject[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 public 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

  • waitbool, if True, the method will wait until the asynchronous operation is completed

  • poll_intervalfloat, interval in seconds between subsequent operation status queries

  • poll_timeoutfloat or None, total polling timeout (None means no timeout), if this timeout is exceeded, an exception is raised

  • timeoutfloat or tuple, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

  • retry_ontuple, additional exception classes to retry on

  • requests_argsdict, additional parameters for RequestsSession

  • httpx_argsdict, additional parameters for HTTPXSession

  • curl_optionsdict, additional options for PycURLSession

  • kwargs – any other parameters, accepted by Session.send_request()

Raises:

More info about this request:

Returns:

SyncResourceLinkObject or SyncOperationLinkObject

Listing Public Files

Client.get_public_resources(**kwargs) SyncPublicResourcesListObject[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 tuple, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

  • retry_ontuple, additional exception classes to retry on

  • requests_argsdict, additional parameters for RequestsSession

  • httpx_argsdict, additional parameters for HTTPXSession

  • curl_optionsdict, additional options for PycURLSession

  • kwargs – 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:

SyncPublicResourcesListObject

Client.get_all_public_resources(*, max_items: int | None = None, **kwargs) Generator[SyncPublicResourceObject, None, None][source]

Get a list of all public resources.

Parameters:
  • max_itemsint 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_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 tuple, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

  • retry_ontuple, additional exception classes to retry on

  • requests_argsdict, additional parameters for RequestsSession

  • httpx_argsdict, additional parameters for HTTPXSession

  • curl_optionsdict, additional options for PycURLSession

  • kwargs – 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:

generator of SyncPublicResourceObject

Public Access Settings

Client.get_public_settings(path: str, /, **kwargs) PublicSettingsObject[source]

Get public settings of a resource.

Parameters:
  • path – path to the resource

  • allow_address_accessbool, specifies the request format, i.e. with personal access settings (when set to True) or without

  • timeoutfloat or tuple, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

  • retry_ontuple, additional exception classes to retry on

  • requests_argsdict, additional parameters for RequestsSession

  • httpx_argsdict, additional parameters for HTTPXSession

  • curl_optionsdict, additional options for PycURLSession

  • kwargs – any other parameters, accepted by Session.send_request()

Raises:

More info about this request:

Returns:

PublicSettingsObject

Client.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

  • timeoutfloat or tuple, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

  • retry_ontuple, additional exception classes to retry on

  • requests_argsdict, additional parameters for RequestsSession

  • httpx_argsdict, additional parameters for HTTPXSession

  • curl_optionsdict, additional options for PycURLSession

  • kwargs – any other parameters, accepted by Session.send_request()

Raises:

More info about this request:

Returns:

PublicAvailableSettingsObject

Client.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_settingsPublicSettings, public access settings for the resource

  • timeoutfloat or tuple, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

  • retry_ontuple, additional exception classes to retry on

  • requests_argsdict, additional parameters for RequestsSession

  • httpx_argsdict, additional parameters for HTTPXSession

  • curl_optionsdict, additional options for PycURLSession

  • kwargs – any other parameters, accepted by Session.send_request()

Raises:

More info about this request:

Returns:

None

Trash

Client.get_trash_meta(path: str, /, **kwargs) SyncTrashResourceObject[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 tuple, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

  • retry_ontuple, additional exception classes to retry on

  • requests_argsdict, additional parameters for RequestsSession

  • httpx_argsdict, additional parameters for HTTPXSession

  • curl_optionsdict, additional options for PycURLSession

  • kwargs – any other parameters, accepted by Session.send_request()

Raises:

More info about this request:

Returns:

SyncTrashResourceObject

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

Check whether the trash resource at path exists.

Parameters:
  • path – path to the trash resource

  • timeoutfloat or tuple, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

  • retry_ontuple, additional exception classes to retry on

  • requests_argsdict, additional parameters for RequestsSession

  • httpx_argsdict, additional parameters for HTTPXSession

  • curl_optionsdict, additional options for PycURLSession

  • kwargs – any other parameters, accepted by Session.send_request()

Raises:

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

Returns:

bool

Client.restore_trash(path: str, /, dst_path: str | None = None, **kwargs) SyncResourceLinkObject | SyncOperationLinkObject[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 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

  • waitbool, if True, the method will wait until the asynchronous operation is completed

  • poll_intervalfloat, interval in seconds between subsequent operation status queries

  • poll_timeoutfloat or None, total polling timeout (None means no timeout), if this timeout is exceeded, an exception is raised

  • timeoutfloat or tuple, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

  • retry_ontuple, additional exception classes to retry on

  • requests_argsdict, additional parameters for RequestsSession

  • httpx_argsdict, additional parameters for HTTPXSession

  • curl_optionsdict, additional options for PycURLSession

  • kwargs – any other parameters, accepted by Session.send_request()

Raises:

More info about this request:

Returns:

SyncResourceLinkObject or SyncOperationLinkObject

Client.remove_trash(path: str, /, **kwargs) SyncOperationLinkObject | 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

  • waitbool, if True, the method will wait until the asynchronous operation is completed

  • poll_intervalfloat, interval in seconds between subsequent operation status queries

  • poll_timeoutfloat or None, total polling timeout (None means no timeout), if this timeout is exceeded, an exception is raised

  • timeoutfloat or tuple, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

  • retry_ontuple, additional exception classes to retry on

  • requests_argsdict, additional parameters for RequestsSession

  • httpx_argsdict, additional parameters for HTTPXSession

  • curl_optionsdict, additional options for PycURLSession

  • kwargs – any other parameters, accepted by Session.send_request()

Raises:

More info about this request:

Returns:

SyncOperationLinkObject if the operation is performed asynchronously, None otherwise

Client.trash_listdir(path: str, /, **kwargs) Generator[SyncTrashResourceObject, None, None][source]

Get contents of a trash resource.

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

  • max_itemsint 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_cropbool, cut the preview to the size specified in the preview_size

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

  • timeoutfloat or tuple, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

  • retry_ontuple, additional exception classes to retry on

  • requests_argsdict, additional parameters for RequestsSession

  • httpx_argsdict, additional parameters for HTTPXSession

  • curl_optionsdict, additional options for PycURLSession

  • kwargs – any other parameters, accepted by Session.send_request()

Raises:
Returns:

generator of SyncTrashResourceObject

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

Get trash resource type.

Parameters:
  • path – path to the trash resource

  • timeoutfloat or tuple, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

  • retry_ontuple, additional exception classes to retry on

  • requests_argsdict, additional parameters for RequestsSession

  • httpx_argsdict, additional parameters for HTTPXSession

  • curl_optionsdict, additional options for PycURLSession

  • kwargs – any other parameters, accepted by Session.send_request()

Raises:
Returns:

“file” or “dir”

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

Check whether path is a trash directory.

Parameters:
  • path – path to the trash resource

  • timeoutfloat or tuple, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

  • retry_ontuple, additional exception classes to retry on

  • requests_argsdict, additional parameters for RequestsSession

  • httpx_argsdict, additional parameters for HTTPXSession

  • curl_optionsdict, additional options for PycURLSession

  • kwargs – 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)

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

Check whether path is a trash file.

Parameters:
  • path – path to the trash resource

  • timeoutfloat or tuple, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

  • retry_ontuple, additional exception classes to retry on

  • requests_argsdict, additional parameters for RequestsSession

  • httpx_argsdict, additional parameters for HTTPXSession

  • curl_optionsdict, additional options for PycURLSession

  • kwargs – 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)

Checking Operation Status

Client.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

  • timeoutfloat or tuple, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

  • retry_ontuple, additional exception classes to retry on

  • requests_argsdict, additional parameters for RequestsSession

  • httpx_argsdict, additional parameters for HTTPXSession

  • curl_optionsdict, additional options for PycURLSession

  • kwargs – 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

Client.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 time.sleep.

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

  • poll_intervalfloat, interval in seconds between subsequent operation status queries

  • poll_timeoutfloat or None, total polling timeout (None means no timeout), if this timeout is exceeded, an exception is raised

  • timeoutfloat or tuple, request timeout

  • headersdict or None, additional request headers

  • n_retriesint, maximum number of retries

  • retry_interval – delay between retries in seconds

  • retry_ontuple, additional exception classes to retry on

  • requests_argsdict, additional parameters for RequestsSession

  • httpx_argsdict, additional parameters for HTTPXSession

  • curl_optionsdict, additional options for PycURLSession

  • kwargs – any other parameters, accepted by Session.send_request()

Raises: