synology_apm_repo.sdk.storage.s3 module

S3Store — an ObjectStore implementation for S3-compatible object storage.

aioboto3/botocore are imported lazily, inside __init__ and each method: storage/__init__.py imports this module unconditionally and their import graph is large.

The aiohttp-based client is created on first use; S3Store.close (called by Session.close()) must release it or the connector leaks. Every client gets _with_default_timeouts’ interactive-friendly config.

class synology_apm_repo.sdk.storage.s3.S3StoreDescriptor(bucket, client_kwargs)

Bases: object

Picklable recipe for rebuilding an equivalent S3Store.

bucket: str
client_kwargs: dict[str, object]
build()
class synology_apm_repo.sdk.storage.s3.S3Store(bucket, *, client=None, **client_kwargs)

Bases: AsyncClosing

An S3 (or S3-compatible — MinIO, Synology C2, …) bucket, addressed by "/"-separated paths relative to the bucket root.

client, if given, is an already-entered async client used as-is and not closed here. Otherwise one is built on first use from client_kwargs (region_name, endpoint_url, aws_access_key_id/aws_secret_access_key, …), passed to aioboto3.Session().client("s3", ...).

descriptor()

How a worker process rebuilds this store; None for one built on an injected client, which has no picklable recipe.

async close()

Release the aiohttp connector of a client this store created (an injected one is left alone). Safe to call more than once.

async read(path, offset=0, length=None)
async size(path)
async exists(path)

True for an object exactly at path or a “directory” (a prefix with at least one object under it). layout.py relies on the latter: db/@data are only prefixes here.

async listdir(path)

Immediate entries under path, each object with its Size from the list responses; a common prefix has no size. An absent prefix and an empty one are indistinguishable, so both return [] rather than raising NotFoundError.

async synology_apm_repo.sdk.storage.s3.list_buckets(**client_kwargs)

Every bucket visible to these credentials (S3Store is scoped to one bucket). Uses a transient client, closed before returning.

Parameters:

**client_kwargs (Any) – What a caller would pass to S3Store.

Returns:

Bucket names, sorted.

Raises:
Return type:

list[str]