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:
objectPicklable recipe for rebuilding an equivalent
S3Store.- build()¶
- class synology_apm_repo.sdk.storage.s3.S3Store(bucket, *, client=None, **client_kwargs)¶
Bases:
AsyncClosingAn 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 fromclient_kwargs(region_name,endpoint_url,aws_access_key_id/aws_secret_access_key, …), passed toaioboto3.Session().client("s3", ...).- descriptor()¶
How a worker process rebuilds this store;
Nonefor one built on an injectedclient, which has no picklable recipe.
- async close()¶
Release the
aiohttpconnector 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)¶
Truefor an object exactly atpathor a “directory” (a prefix with at least one object under it).layout.pyrelies on the latter:db/@dataare only prefixes here.
- async listdir(path)¶
Immediate entries under
path, each object with itsSizefrom the list responses; a common prefix has no size. An absent prefix and an empty one are indistinguishable, so both return[]rather than raisingNotFoundError.
- async synology_apm_repo.sdk.storage.s3.list_buckets(**client_kwargs)¶
Every bucket visible to these credentials (
S3Storeis 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:
PermissionDeniedError – The credentials lack account-level list permission.
StorageBackendError – The request failed otherwise.
- Return type: