Skip to content

AsyncOperator

The async equivalent of Operator.

AsyncOperator is the entry point for all async APIs.

See Also

Operator

capability() #

Get all capabilities of this operator.

Returns:

Type Description
Capability

The capability of the operator.

check() #

Check if the operator is able to work correctly.

Returns:

Type Description
coroutine

An awaitable that completes when the check is finished.

Raises:

Type Description
Exception

If the operator is not able to work correctly.

copy(source, target) #

Copy a file from one path to another.

Parameters:

Name Type Description Default
source str

The path to the source file.

required
target str

The path to the target file.

required

Returns:

Type Description
coroutine

An awaitable that completes when the copy is finished.

create_dir(path) #

Create a directory at the given path.

Notes

To indicate that a path is a directory, it must end with a /. This operation is always recursive, like mkdir -p.

Parameters:

Name Type Description Default
path str

The path to the directory.

required

Returns:

Type Description
coroutine

An awaitable that completes when the directory is created.

delete(path) #

Delete a file at the given path.

Notes

This operation will not return an error if the path does not exist.

Parameters:

Name Type Description Default
path str

The path to the file.

required

Returns:

Type Description
coroutine

An awaitable that completes when the file is deleted.

exists(path) #

Check if a path exists.

Parameters:

Name Type Description Default
path str

The path to check.

required

Returns:

Type Description
coroutine

An awaitable that returns True if the path exists, False otherwise.

layer(layer) #

Add a new layer to the operator.

Parameters:

Name Type Description Default
layer Layer

The layer to add.

required

Returns:

Type Description
AsyncOperator

A new operator with the layer added.

list(path, *, limit=None, start_after=None, recursive=None, versions=None, deleted=None) #

List entries in the given directory.

Parameters:

Name Type Description Default
path str

The path to the directory.

required
limit int

The maximum number of entries to return.

None
start_after str

The entry to start after.

None
recursive bool

Whether to list recursively.

None
versions bool

Whether to list versions.

None
deleted bool

Whether to list deleted entries.

None

Returns:

Type Description
coroutine

An awaitable that returns an async iterator over the entries.

open(path, mode, **kwargs) #

Open an async file-like object for the given path.

The returning async file-like object is a context manager.

Parameters:

Name Type Description Default
path str

The path to the file.

required
mode str

The mode to open the file in. Only "rb" and "wb" are supported.

required
**kwargs dict

Additional options for the underlying reader or writer.

{}

Returns:

Type Description
coroutine

An awaitable that returns a file-like object.

presign_delete(path, expire_second) #

Create a presigned request for a delete operation.

Parameters:

Name Type Description Default
path str

The path of the object to delete.

required
expire_second int

The number of seconds until the presigned URL expires.

required

Returns:

Type Description
coroutine

An awaitable that returns a presigned request object.

presign_read(path, expire_second) #

Create a presigned request for a read operation.

Parameters:

Name Type Description Default
path str

The path of the object to read.

required
expire_second int

The number of seconds until the presigned URL expires.

required

Returns:

Type Description
coroutine

An awaitable that returns a presigned request object.

presign_stat(path, expire_second) #

Create a presigned request for a stat operation.

Parameters:

Name Type Description Default
path str

The path of the object to stat.

required
expire_second int

The number of seconds until the presigned URL expires.

required

Returns:

Type Description
coroutine

An awaitable that returns a presigned request object.

presign_write(path, expire_second) #

Create a presigned request for a write operation.

Parameters:

Name Type Description Default
path str

The path of the object to write to.

required
expire_second int

The number of seconds until the presigned URL expires.

required

Returns:

Type Description
coroutine

An awaitable that returns a presigned request object.

read(path, *, version=None, concurrent=None, chunk=None, gap=None, offset=None, prefetch=None, size=None, if_match=None, if_none_match=None, if_modified_since=None, if_unmodified_since=None, content_type=None, cache_control=None, content_disposition=None) #

Read the entire contents of a file at the given path.

Parameters:

Name Type Description Default
path str

The path to the file.

required
version str

The version of the file.

None
concurrent int

The number of concurrent readers.

None
chunk int

The size of each chunk.

None
gap int

The gap between each chunk.

None
offset int

The offset of the file.

None
prefetch int

The number of bytes to prefetch.

None
size int

The size of the file.

None
if_match str

The ETag of the file.

None
if_none_match str

The ETag of the file.

None
if_modified_since str

The last modified time of the file.

None
if_unmodified_since str

The last modified time of the file.

None
content_type str

The content type of the file.

None
cache_control str

The cache control of the file.

None
content_disposition str

The content disposition of the file.

None

Returns:

Type Description
coroutine

An awaitable that returns the contents of the file as bytes.

remove_all(path) #

Recursively remove all files and directories at the given path.

Parameters:

Name Type Description Default
path str

The path to remove.

required

Returns:

Type Description
coroutine

An awaitable that completes when the removal is finished.

rename(source, target) #

Rename (move) a file from one path to another.

Parameters:

Name Type Description Default
source str

The path to the source file.

required
target str

The path to the target file.

required

Returns:

Type Description
coroutine

An awaitable that completes when the rename is finished.

stat(path, *, version=None, if_match=None, if_none_match=None, if_modified_since=None, if_unmodified_since=None, content_type=None, cache_control=None, content_disposition=None) #

Get the metadata of a file at the given path.

Parameters:

Name Type Description Default
path str

The path to the file.

required
version str

The version of the file.

None
if_match str

The ETag of the file.

None
if_none_match str

The ETag of the file.

None
if_modified_since datetime

The last modified time of the file.

None
if_unmodified_since datetime

The last modified time of the file.

None
content_type str

The content type of the file.

None
cache_control str

The cache control of the file.

None
content_disposition str

The content disposition of the file.

None

Returns:

Type Description
coroutine

An awaitable that returns the metadata of the file.

to_operator() #

Create a new blocking Operator from this async operator.

Returns:

Type Description
Operator

The blocking operator.

write(path, bs, *, append=None, chunk=None, concurrent=None, cache_control=None, content_type=None, content_disposition=None, content_encoding=None, if_match=None, if_none_match=None, if_not_exists=None, user_metadata=None) #

Write bytes to a file at the given path.

This function will create a file if it does not exist, and will overwrite its contents if it does.

Parameters:

Name Type Description Default
path str

The path to the file.

required
bs bytes

The contents to write to the file.

required
append bool

Whether to append to the file instead of overwriting it.

None
chunk int

The chunk size to use when writing the file.

None
concurrent int

The number of concurrent requests to make when writing the file.

None
cache_control str

The cache control header to set on the file.

None
content_type str

The content type header to set on the file.

None
content_disposition str

The content disposition header to set on the file.

None
content_encoding str

The content encoding header to set on the file.

None
if_match str

The ETag to match when writing the file.

None
if_none_match str

The ETag to not match when writing the file.

None
if_not_exists bool

Whether to fail if the file already exists.

None
user_metadata dict

The user metadata to set on the file.

None

Returns:

Type Description
coroutine

An awaitable that completes when the write is finished.