> built 2026-11-24 01:13 UTC from 617983e (master) · s3dol 1.0.5. Details: build_info.json

# index.html.md

<!-- generated by epythet -->

# s3dol

s3 (through boto3) with a simple (dict-like or list-like) interface

To install:	`pip install s3dol`

[Documentation](https://i2mint.github.io/s3dol/)

## Quick start

```python
import s3dol

s = s3dol.s3_store("my-bucket")  # MutableMapping[str, bytes]
s["hello.txt"] = b"world"
s["hello.txt"]  # b'world'
list(s)
"hello.txt" in s
del s["hello.txt"]

s = s3dol.s3_store("my-bucket", prefix="logs/")  # scoped to a prefix
s = s3dol.s3_store("open-data", anon=True)  # public bucket, no credentials
s = s3dol.s3_store("b", preset="minio", endpoint_url="http://localhost:9000")
```

Starting from nothing (the default never creates a bucket from a typo):

```python
s = s3dol.s3_store("brand-new-bucket", on_missing_bucket="create")
```

**Big objects go through the same interface** — no `upload_multipart` method:

```python
s["video.mp4"] = s3dol.Filepath("/tmp/video.mp4")  # streamed, multipart above 8 MiB
s["stream.bin"] = s3dol.Chunks(chunk_iterator)  # never fully in memory
```

**Keyed capabilities are stores you index**, not methods (a `dol` key wrapper
hands a method the *unmapped* key — so s3dol has none):

```python
s3dol.handles(s)["video.mp4"].read(offset=0, length=1024)  # ranged read
s3dol.handles(s)["video.mp4"].url(expires_in=3600)  # presigned URL
s3dol.urls(s)["video.mp4"]  # ...or directly
s3dol.info(s)["video.mp4"].size  # one HeadObject
```

Everything else is a free function taking the store first:

```python
s3dol.sub(s, "folder/")
s3dol.prefixes(s)
s3dol.delete_many(s, ["a", "b"])
s3dol.delete_bucket(endpoint, "name", force=True)
```

**Test without a cloud** — no network, no docker, no moto:

```python
from s3dol.testing import mock_s3, run_conformance


def test_my_service():
    assert MediaService(mock_s3(data={"a.mp4": b"..."})).play("a.mp4")
```

`run_conformance(make_store)` is exported too: run the same laws against your
own store (or a sibling `*dol` package’s).

## Heads-up: v1 is coming — run `s3dol.diagnose()` now

A major, behaviour-clarifying v1 is in progress
(design: [`misc/docs/architecture.md`]() and the ADRs in
[`misc/docs/decisions/`]()). Today’s `S3Store` will keep
working through a compatibility shim, but a few v0 behaviours were bugs
(e.g. an explicit `endpoint_url=` being silently dropped whenever
`AWS_ACCESS_KEY_ID`/`AWS_SECRET_ACCESS_KEY` are exported) and v1 fixes them —
which can *move where your data goes*.

Before upgrading to v1, run the diagnosis with the same arguments you pass
`S3Store` today, in the environment you deploy in:

```python
import s3dol

s3dol.diagnose(bucket_name="my-bucket", endpoint_url="...", path="...")
```

It prints what resolves (endpoint, region, signing, credential *source* — never
a secret), where each value came from, and a **v0-vs-v1 divergence table**
telling you whether the upgrade changes anything for your call. It never
raises; a failing resolution is part of the report.

## Set up credentials

Recommended prerequisite to make getting started easier but not required.

### Option 1: [Environment Variables](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-envvars.html)

```default
export AWS_ACCESS_KEY_ID=AKIAIOSFODNN7EXAMPLE
export AWS_SECRET_ACCESS_KEY=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
export AWS_DEFAULT_REGION=us-west-2
```

### Option 2: [Configure Default Profile in Credentials File](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-files.html)

Add credentails in `~/.aws/credentials`

```default
[default]
aws_access_key_id = AKIAIOSFODNN7EXAMPLE
aws_secret_access_key = wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
```

### Option 3: [Configure Default Profile with AWS CLI](https://docs.aws.amazon.com/cli/latest/reference/configure/)

[Install AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html)

```bash
brew instal awscli
```

Set credentails with CLI

```bash
aws configure
AWS Access Key ID [None]: AKIAIOSFODNN7EXAMPLE
AWS Secret Access Key [None]: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
Default region name [None]: us-west-2
Default output format [None]:
```

<p class="epythet-aggregates">This documentation as a single file: <a href="s3dol.md">s3dol.md</a> (Markdown, for agents).</p>


# _autosummary/s3dol.base.html.md

# s3dol.base

Layer B — close-to-metal stores over one bucket or one endpoint.

Design record: `misc/docs/architecture.md` (the contract tables) on
ADR-0001 (layering; the prefix lives HERE, in the leaf), ADR-0004 (one error
seam), ADR-0005 (write domain / strategies), ADR-0006 (prefix arithmetic and
key validity), ADR-0008 (`__len__` absent by design), ADR-0010 (bucket policy),
ADR-0011 (**no key-taking public methods** — one guarded exception, `url_for`),
ADR-0012 (connection).

The class triads mirror `dol.filesys` and `azuredol`:

```default
BucketCollection   -> BucketReader   -> BucketStore     (keys: object keys)
EndpointCollection -> EndpointReader -> EndpointStore   (keys: bucket names)
ObjectHandle                                            (not a Mapping)
```

Reader-only classes are *real classes* (a type checker catches
`reader[k] = v`; a read-scoped credential never even attempts a write) —
`dol.mk_read_only` is non-functional on a dol store (verified, ADR-0001).

**The rule for what may join a class here: nothing that takes a key**
(ADR-0011 D1). `dol` wrappers hand any non-dunder method the outer, unmapped
key, and the standard escape (`wrapped_self`) is itself silently wrong when
nothing references the wrapper. Keyed capabilities are sibling stores
(`s3dol.handles(store)[k]` — `capabilities.py`); per-object richness lives on
[`ObjectHandle`](_autosummary/s3dol.base.html.md#s3dol.base.ObjectHandle) (key bound at construction); everything else is a free
function taking the store first. The single exception is
[`BucketReader.url_for()`](_autosummary/s3dol.base.html.md#s3dol.base.BucketReader.url_for), kept for `dol.SupportsUrlFor`, guarded to be
correct-or-loud (D3b). A reflective conformance test enforces the rule (D5).

### Module Attributes

| [`MAX_KEY_BYTES`](_autosummary/s3dol.base.html.md#s3dol.base.MAX_KEY_BYTES)       | S3's real limit is 1024 **UTF-8 bytes** (enforced client-side so moto and AWS agree — moto accepts longer keys; ADR-0006 §4).   |
|----------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------|
| [`MAX_PRESIGN_EXPIRES`](_autosummary/s3dol.base.html.md#s3dol.base.MAX_PRESIGN_EXPIRES) | SigV4's presigned-URL lifetime cap (botocore does not enforce it).                                                              |

### Functions

| [`clamp_expires_in`](_autosummary/s3dol.base.html.md#s3dol.base.clamp_expires_in)(expires_in)   | Clamp to SigV4's 604800 s cap, warning.   |
|---------------------------------------------------------------------------------|-------------------------------------------|

### Classes

| [`BucketCollection`](_autosummary/s3dol.base.html.md#s3dol.base.BucketCollection)(bucket, \*[, connection, ...])    | Keys of one bucket (under the prefix).                                                                                                                                                                                                        |
|-----------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [`BucketReader`](_autosummary/s3dol.base.html.md#s3dol.base.BucketReader)(bucket, \*[, connection, ...])        |                                                                                                                                                                                                                                               |
| [`BucketStore`](_autosummary/s3dol.base.html.md#s3dol.base.BucketStore)(bucket, \*[, connection, prefix, ...]) |                                                                                                                                                                                                                                               |
| [`EndpointCollection`](_autosummary/s3dol.base.html.md#s3dol.base.EndpointCollection)([connection])                   | Bucket names at one endpoint.                                                                                                                                                                                                                 |
| [`EndpointReader`](_autosummary/s3dol.base.html.md#s3dol.base.EndpointReader)([connection])                       |                                                                                                                                                                                                                                               |
| [`EndpointStore`](_autosummary/s3dol.base.html.md#s3dol.base.EndpointStore)([connection])                        |                                                                                                                                                                                                                                               |
| [`ObjectHandle`](_autosummary/s3dol.base.html.md#s3dol.base.ObjectHandle)(bucket, key, \*[, connection])        | One object, key bound **at construction** — which is what makes it immune to the delegation trap (a key codec over the store cannot corrupt a key that was resolved before the handle existed; ADR-0011 D1, following `azuredol.BlobHandle`). |
| [`ObjectInfo`](_autosummary/s3dol.base.html.md#s3dol.base.ObjectInfo)(key[, size, last_modified, etag, ...])  | Object metadata — from `HeadObject` or from a LIST row (which already carries size/mtime/etag/storage class that v0 threw away; ADR-0009).                                                                                                    |
| [`S3Profiles`](_autosummary/s3dol.base.html.md#s3dol.base.S3Profiles)(\*[, bucket_kwargs, readonly])          | AWS **profile** names -> endpoint stores (the v0 `S3Dol`, renamed — its keys are verifiably profile names, never endpoints; ADR-0007 §1).                                                                                                     |

### Exceptions

| [`ObjectNotFoundForDelete`](_autosummary/s3dol.base.html.md#s3dol.base.ObjectNotFoundForDelete)   | Raised by `strict_delete=True` deletes of absent keys.   |
|----------------------------------------------------------------------------|----------------------------------------------------------|

### *class* s3dol.base.BucketCollection(bucket, , connection=None, prefix='', delimiter='/', reads=None, writes=None, on_missing_bucket='assume', strict_delete=False)

Bases: `_BucketBase`, `Collection`

Keys of one bucket (under the prefix). `Collection` only —
iteration and membership, no reads.

### *class* s3dol.base.BucketReader(bucket, , connection=None, prefix='', delimiter='/', reads=None, writes=None, on_missing_bucket='assume', strict_delete=False)

Bases: [`BucketCollection`](_autosummary/s3dol.base.html.md#s3dol.base.BucketCollection), `KvReader`

+ `__getitem__` -> bytes (or the read strategy’s value type).

#### url_for(k, , expires_in=3600, client_method='get_object', \*\*params)

Presigned URL for `k` — **the one keyed method** (ADR-0011 D3b),
kept solely because `dol.SupportsUrlFor` requires a *method* and
`dol.content_url` reaches it by `getattr`. The canonical form is
`s3dol.urls(store)[k]`.

Guarded to be correct-or-loud, never silently wrong:

- **unwrapped store**: `k` is a key in this store’s own key space,
  so the URL addresses `self._id_of_key(k)`. Correct, and this is
  also the contract `dol.content_url` calls under — it resolves the
  key through the *outer* layers and stops at the layer owning
  `url_for`, “because that layer applies its own”
  (`dol/content.py`);
- **this leaf has ever been wrapped**: **raises**. Two call paths then
  reach this one signature with *different key domains* and nothing
  distinguishes them: `dol.content_url` hands over a key already
  mapped through the wrapper layers, while a direct
  `wrapped.url_for(k)` (delegation) hands over the raw outer key.
  Applying `_id_of_key` is right for the first and wrong for the
  second; re-resolving through the chain is right for the second and
  double-transforms the first. Since a wrong presigned URL addresses a
  *different real object*, the only honest answer is refusal, naming
  the sibling store — which is correct by construction because it goes
  through `__getitem__` (ADR-0011 D2/D3b, and see the note below);
- **anonymous connection**: returns `None` (`SupportsUrlFor` is
  `Optional[str]`; raising would turn a public-bucket streaming
  fallback into a 500 — ADR-0012 D5). The check reads the built
  client’s signature version, never `spec.anon`.

#### NOTE
This refusal is a *finding*, not a limitation we chose.
ADR-0011 D3b expected a guarded method to serve both paths; it
cannot, on a leaf that owns its prefix. Reported upstream on
dol#86/#83 as evidence that a keyed capability *method* is
unfixable in the general case, and that the sibling-store form is
the only one correct by construction.

* **Return type:**
  [`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]

### *class* s3dol.base.BucketStore(bucket, , connection=None, prefix='', delimiter='/', reads=None, writes=None, on_missing_bucket='assume', strict_delete=False)

Bases: [`BucketReader`](_autosummary/s3dol.base.html.md#s3dol.base.BucketReader), `KvPersister`

+ `__setitem__` / `__delitem__`. The user-facing read-write store.

#### pop(k) → v, remove specified key and return the corresponding value.

If key is not found, d is returned if given, otherwise KeyError is raised.

#### setdefault(k) → D.get(k,d), also set D[k]=d if k not in D

#### update(other=(), , \*\*kwargs)

If E present and has a .keys() method, does:     for k in E.keys(): D[k] = E[k]
If E present and lacks .keys() method, does:     for (k, v) in E: D[k] = v
In either case, this is followed by: for k, v in F.items(): D[k] = v

* **Return type:**
  [`None`](https://docs.python.org/3/builtins/constants.html#None)

### *class* s3dol.base.EndpointCollection(connection=None, \*\*bucket_kwargs)

Bases: `_EndpointBase`, `Collection`

Bucket names at one endpoint.

### *class* s3dol.base.EndpointReader(connection=None, \*\*bucket_kwargs)

Bases: [`EndpointCollection`](_autosummary/s3dol.base.html.md#s3dol.base.EndpointCollection), `KvReader`

+ `__getitem__` -> [`BucketReader`](_autosummary/s3dol.base.html.md#s3dol.base.BucketReader).

### *class* s3dol.base.EndpointStore(connection=None, \*\*bucket_kwargs)

Bases: [`EndpointReader`](_autosummary/s3dol.base.html.md#s3dol.base.EndpointReader), `KvPersister`

+ bucket creation/deletion. `del endpoint[name]` refuses a non-empty
  bucket; the explicit cascading form is the free function
  `s3dol.delete_bucket(endpoint, name, force=True)` (ADR-0010 §3 as
  amended by ADR-0011 D4 — a public keyed destructive *method* is the shape
  the family census found destroying wrong data).

### s3dol.base.MAX_KEY_BYTES *= 1024*

S3’s real limit is 1024 **UTF-8 bytes** (enforced client-side so moto and
AWS agree — moto accepts longer keys; ADR-0006 §4).

### s3dol.base.MAX_PRESIGN_EXPIRES *= 604800*

SigV4’s presigned-URL lifetime cap (botocore does not enforce it).

### *class* s3dol.base.ObjectHandle(bucket, key, , connection=None)

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

One object, key bound **at construction** — which is what makes it
immune to the delegation trap (a key codec over the store cannot corrupt a
key that was resolved before the handle existed; ADR-0011 D1, following
`azuredol.BlobHandle`). This is where ranged reads, streaming,
download-to-disk, metadata and presigned URLs live.

#### download_to(path)

Download to disk (never fully in memory). Accepts a path or
[`Filepath`](_autosummary/s3dol.values.html.md#s3dol.values.Filepath); returns the path written.

* **Return type:**
  [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)

#### info()

One `HeadObject` -> [`ObjectInfo`](_autosummary/s3dol.base.html.md#s3dol.base.ObjectInfo).

* **Return type:**
  [`ObjectInfo`](_autosummary/s3dol.base.html.md#s3dol.base.ObjectInfo)

#### read(, offset=None, length=None)

The object’s bytes; a ranged read when `offset`/`length` given.

* **Return type:**
  [`bytes`](https://docs.python.org/3/builtins/stdtypes.html#bytes)

#### restore(days=1, , tier='Standard')

Request restoration of an archived (Glacier) object.

* **Return type:**
  [`None`](https://docs.python.org/3/builtins/constants.html#None)

#### stream(, chunk_size=8388608)

Lazy chunk iterator over the body.

* **Return type:**
  [`Iterator`](https://docs.python.org/3/library/typing.html#typing.Iterator)[[`bytes`](https://docs.python.org/3/builtins/stdtypes.html#bytes)]

#### url(, expires_in=3600, client_method='get_object', \*\*params)

Presigned URL. Always SigV4; `None` when anonymous; capped at
SigV4’s 604800 s; warns when the signing credential expires sooner
(the URL cannot outlive it).

* **Return type:**
  [`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]

#### write(value)

Write the object (same value domain as `store[k] = v`).

* **Return type:**
  [`None`](https://docs.python.org/3/builtins/constants.html#None)

### *class* s3dol.base.ObjectInfo(key, size=None, last_modified=None, etag=None, content_type=None, storage_class=None, restore_status=None, version_id=None)

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

Object metadata — from `HeadObject` or from a LIST row (which already
carries size/mtime/etag/storage class that v0 threw away; ADR-0009).

### *exception* s3dol.base.ObjectNotFoundForDelete

Bases: [`S3Error`](_autosummary/s3dol.errors.html.md#s3dol.errors.S3Error), [`KeyError`](https://docs.python.org/3/builtins/exceptions.html#KeyError)

Raised by `strict_delete=True` deletes of absent keys.

### *class* s3dol.base.S3Profiles(, bucket_kwargs=None, readonly=False)

Bases: `KvReader`

AWS **profile** names -> endpoint stores (the v0 `S3Dol`, renamed —
its keys are verifiably profile names, never endpoints; ADR-0007 §1).

```pycon
>>> # S3Profiles()['prod']  ->  EndpointStore over the 'prod' profile
```

### s3dol.base.clamp_expires_in(expires_in)

Clamp to SigV4’s 604800 s cap, warning. botocore does not enforce it —
it just signs a URL that fails after 7 days.

* **Return type:**
  [`int`](https://docs.python.org/3/builtins/functions.html#int)


# _autosummary/s3dol.capabilities.html.md

# s3dol.capabilities

Keyed capabilities as sibling stores; non-keyed operations as free
functions (ADR-0011 D2/D3/D4).

A keyed capability is a Layer B `KvReader` over the **same key space** whose
`__getitem__` returns the capability:

```default
BucketStore                     k -> bytes
BucketHandles  s3dol.handles(s) k -> ObjectHandle
BucketUrls     s3dol.urls(s)    k -> presigned URL (str) | None
BucketInfo     s3dol.info(s)    k -> ObjectInfo (one HeadObject per key)
BucketListedInfo  s3dol.listed_info(s)  k -> ObjectInfo (one LIST, a snapshot)
```

`__getitem__` is the one thing `dol` maps correctly at every wrapper depth,
so sibling stores are correct *by construction*: no `inner_most_key`, no
`wrapped_self`, no guard — immune to both the lost-reference hole (D1a) and
the non-`Store`-layer hole (D3a), the only form in ADR-0011 that is.

**The cost, stated plainly** (D2): a user who wraps the data store must wrap
the sibling in parallel:

```default
s = s3_store('bucket', prefix='p/')
h = s3dol.handles(s)
c = KeyCodecs.prefixed('x/')      # a user-applied key codec
s2, h2 = c(s), c(h)               # wrap BOTH
h2['f']                           # -> handle on 'p/x/f'; correct at any depth
```

The accessors therefore derive a sibling from an **unwrapped** store and
**raise** on a wrapped one, naming that remedy — s3dol will not guess a user’s
codec chain (that is dol#10).

Free functions (D3) resolve keys with the store held as an argument (alive, so
no weakref registry is consulted). Per D3a they are *more* reliable than
methods, not reliable: a hand-rolled non-`Store` passthrough layer in the
chain can still defeat the resolution — no docstring here claims “correct at
any wrapper depth”; only the sibling stores may claim that.

### Module Attributes

| [`DELETE_MANY_CHUNK`](_autosummary/s3dol.capabilities.html.md#s3dol.capabilities.DELETE_MANY_CHUNK)   | AWS's DeleteObjects cap.   |
|----------------------------------------------------------------------|----------------------------|

### Functions

| [`delete_bucket`](_autosummary/s3dol.capabilities.html.md#s3dol.capabilities.delete_bucket)(endpoint, name, \*[, force])   | Delete bucket `name`.                                                                                                                                                                                                   |
|-----------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [`delete_many`](_autosummary/s3dol.capabilities.html.md#s3dol.capabilities.delete_many)(store, keys)                     | Bulk delete (ADR-0010 §2; a free function per ADR-0011 D4 — keyed + destructive + delegated is the census's data-destroying shape).                                                                                     |
| [`handles`](_autosummary/s3dol.capabilities.html.md#s3dol.capabilities.handles)(store)                               | The sibling store of `ObjectHandle`s: `handles(s)[k]`.                                                                                                                                                                  |
| [`info`](_autosummary/s3dol.capabilities.html.md#s3dol.capabilities.info)(store)                                  | The sibling store of `ObjectInfo`: `info(s)[k]`.                                                                                                                                                                        |
| [`listed_info`](_autosummary/s3dol.capabilities.html.md#s3dol.capabilities.listed_info)(store)                           | The sibling store of `ObjectInfo` built from one paginated LIST: `listed_info(s)[k]` (a lazy snapshot; see [`BucketListedInfo`](_autosummary/s3dol.capabilities.html.md#s3dol.capabilities.BucketListedInfo)).                                          |
| [`prefixes`](_autosummary/s3dol.capabilities.html.md#s3dol.capabilities.prefixes)(store)                              | The 'directories' one level under the store's scope, \*\*relative to the caller's key space\*\* — one `ListObjectsV2(Delimiter='/')` reading `CommonPrefixes` (which v0 parsed and then called from nowhere; ADR-0009). |
| [`sub`](_autosummary/s3dol.capabilities.html.md#s3dol.capabilities.sub)(store, prefix)                           | A store scoped to `prefix`, **in the caller's key space** (D3).                                                                                                                                                         |
| [`urls`](_autosummary/s3dol.capabilities.html.md#s3dol.capabilities.urls)(store, \*[, expires_in, client_method]) | The sibling store of presigned URLs: `urls(s)[k]`.                                                                                                                                                                      |

### Classes

| [`BucketHandles`](_autosummary/s3dol.capabilities.html.md#s3dol.capabilities.BucketHandles)(bucket, \*[, connection, ...])      | `k -> ObjectHandle` (key bound at construction; zero round-trips).     |
|----------------------------------------------------------------------------------------------------|------------------------------------------------------------------------|
| [`BucketInfo`](_autosummary/s3dol.capabilities.html.md#s3dol.capabilities.BucketInfo)(bucket, \*[, connection, prefix, ...]) | `k -> ObjectInfo` (one `HeadObject`).                                  |
| [`BucketListedInfo`](_autosummary/s3dol.capabilities.html.md#s3dol.capabilities.BucketListedInfo)(bucket, \*[, connection, ...])   | `k -> ObjectInfo` from the listing rows, not one `HeadObject` per key. |
| [`BucketUrls`](_autosummary/s3dol.capabilities.html.md#s3dol.capabilities.BucketUrls)(\*args[, expires_in, client_method])   | `k -> presigned URL` (zero object requests; `None` when anonymous).    |

### *class* s3dol.capabilities.BucketHandles(bucket, , connection=None, prefix='', delimiter='/', reads=None, writes=None, on_missing_bucket='assume', strict_delete=False)

Bases: [`BucketCollection`](_autosummary/s3dol.base.html.md#s3dol.base.BucketCollection), `KvReader`

`k -> ObjectHandle` (key bound at construction; zero round-trips).

### *class* s3dol.capabilities.BucketInfo(bucket, , connection=None, prefix='', delimiter='/', reads=None, writes=None, on_missing_bucket='assume', strict_delete=False)

Bases: [`BucketCollection`](_autosummary/s3dol.base.html.md#s3dol.base.BucketCollection), `KvReader`

`k -> ObjectInfo` (one `HeadObject`).

### *class* s3dol.capabilities.BucketListedInfo(bucket, , connection=None, prefix='', delimiter='/', reads=None, writes=None, on_missing_bucket='assume', strict_delete=False)

Bases: [`BucketCollection`](_autosummary/s3dol.base.html.md#s3dol.base.BucketCollection), `KvReader`

`k -> ObjectInfo` from the listing rows, not one `HeadObject` per key.

The first access (a lookup or an iteration) pages through `ListObjectsV2`
once and keeps `{key: ObjectInfo}` (`size`, `last_modified`, `etag`,
`storage_class`; `content_type` and the other HEAD-only fields stay
`None`). It is **lazy and a snapshot**: later writes are not seen; make a
new `listed_info(store)` to refresh. A whole-bucket ETag comparison costs
one LIST per 1000 keys.

### *class* s3dol.capabilities.BucketUrls(\*args, expires_in=3600, client_method='get_object', \*\*kwargs)

Bases: [`BucketCollection`](_autosummary/s3dol.base.html.md#s3dol.base.BucketCollection), `KvReader`

`k -> presigned URL` (zero object requests; `None` when anonymous).
The canonical spelling of what `url_for` shims (ADR-0011 D3b).

### s3dol.capabilities.DELETE_MANY_CHUNK *= 1000*

AWS’s DeleteObjects cap. moto accepts 1001, so tier 2 can never catch a
missing chunker (ADR-0010 §2) — hence the constant is also unit-tested.

### s3dol.capabilities.delete_bucket(endpoint, name, , force=False)

Delete bucket `name`. Refuses a non-empty bucket unless
`force=True`, in which case the cascade **paginates** — v0 listed one
page, deleted ≤1000 objects, then failed: a partial, non-idempotent
destruction (ADR-0010 §3). A free function, not a method (ADR-0011 D4).

* **Return type:**
  [`None`](https://docs.python.org/3/builtins/constants.html#None)

### s3dol.capabilities.delete_many(store, keys)

Bulk delete (ADR-0010 §2; a free function per ADR-0011 D4 — keyed +
destructive + delegated is the census’s data-destroying shape).

Chunks at 1000 (AWS’s cap), parses the `Errors` list out of the HTTP
200 response, and on partial failure raises one `S3PartialFailure`
carrying `.succeeded` and `.failures`. Absent keys are reported by S3
as `Deleted` — this function does **not** distinguish them (same
idempotency as `del store[k]`).

Keys are the *caller’s* keys: with the store held as an argument the
chain is resolved via `dol.inner_most_key` (alive store — no weakref
hole). Validate-the-target caveat (D4): the first argument must be an
s3dol store or a dol wrapper over one.

* **Return type:**
  [`None`](https://docs.python.org/3/builtins/constants.html#None)

### s3dol.capabilities.handles(store)

The sibling store of `ObjectHandle`s: `handles(s)[k]`.

* **Return type:**
  [`BucketHandles`](_autosummary/s3dol.capabilities.html.md#s3dol.capabilities.BucketHandles)

### s3dol.capabilities.info(store)

The sibling store of `ObjectInfo`: `info(s)[k]`.

* **Return type:**
  [`BucketInfo`](_autosummary/s3dol.capabilities.html.md#s3dol.capabilities.BucketInfo)

### s3dol.capabilities.listed_info(store)

The sibling store of `ObjectInfo` built from one paginated LIST:
`listed_info(s)[k]` (a lazy snapshot; see [`BucketListedInfo`](_autosummary/s3dol.capabilities.html.md#s3dol.capabilities.BucketListedInfo)).

* **Return type:**
  [`BucketListedInfo`](_autosummary/s3dol.capabilities.html.md#s3dol.capabilities.BucketListedInfo)

### s3dol.capabilities.prefixes(store)

The ‘directories’ one level under the store’s scope, \*\*relative to the
caller’s key space\*\* — one `ListObjectsV2(Delimiter='/')` reading
`CommonPrefixes` (which v0 parsed and then called from nowhere;
ADR-0009). Through a dol wrapper chain, the listing is rooted at the
caller’s scope (each prefix layer’s contribution) and results are mapped
back **outward** (`_key_of_id` per layer, innermost first — the inverse
walk `dol` does not provide; ADR-0011 D3). A wrapper whose codec cannot
express the scope raises — loud, not wrong.

* **Return type:**
  [`list`](https://docs.python.org/3/builtins/stdtypes.html#list)

### s3dol.capabilities.sub(store, prefix)

A store scoped to `prefix`, **in the caller’s key space** (D3).

Two branches, deliberately different (each documented in the ADR):

- **unwrapped s3dol store**: `leaf._with(prefix=...)` — cheap, keeps
  server-side prefix pushdown, returns the same class;
- **dol-wrapped store**: composes `Pipe(filt_iter.prefixes(p),
  KeyCodecs.prefixed(p))` over the *outer* store (filter FIRST — the only
  safe composition, ADR-0006 §1), which preserves the user’s codecs but
  loses pushdown (a full scan filtered client-side; D8 closed this: the
  cheap path is the unwrapped branch) and returns a different type.

### s3dol.capabilities.urls(store, , expires_in=3600, client_method='get_object')

The sibling store of presigned URLs: `urls(s)[k]`.

* **Return type:**
  [`BucketUrls`](_autosummary/s3dol.capabilities.html.md#s3dol.capabilities.BucketUrls)


# _autosummary/s3dol.connection.html.md

# s3dol.connection

`S3Connection` — the credential + endpoint SSOT, and the pure resolver.

Design record: `misc/docs/decisions/0012-credential-and-endpoint-resolution.md`
(all of it) on top of `0002-boto3-as-engine.md` (lazy boto3) and
`0003-provider-presets-and-capabilities.md` (presets, SigV4 mandate).

The two sentences the module follows from (ADR-0012):

1. **A preset is the caller’s explicit endpoint, spelled by name.** It sits
   exactly where `endpoint_url=` sits — above every environment and
   config-file channel. s3dol owns two rungs of the endpoint ladder, not six.
2. \*\*A `Config` value s3dol does not set is a channel it leaves open to the
   user.\*\* Every field is a ladder with a documented bottom, and “the row makes
   no claim” is spelled by *omitting the key*, never by passing `None`.

Structure:

- [`S3Connection`](_autosummary/s3dol.connection.html.md#s3dol.connection.S3Connection) — a frozen, picklable spec. No live objects, no
  escape hatch for one. Construction performs no I/O and imports no boto3.
- [`resolve()`](_autosummary/s3dol.connection.html.md#s3dol.connection.resolve) — a **pure** function `(spec, environ, aws_config) ->
  Resolution` where every field carries its provenance. Tier-1 tests cover
  the whole ladder with a fake environ dict and zero I/O.
- [`load_aws_config()`](_autosummary/s3dol.connection.html.md#s3dol.connection.load_aws_config) — the separate, *named impure* loader for the
  aws-config rungs; pass it (or its result) to [`resolve()`](_autosummary/s3dol.connection.html.md#s3dol.connection.resolve).
- Credential shapes (ADR-0012 D5) — normalised in `__post_init__` to small
  frozen, picklable providers; live botocore objects are rejected with
  shape-specific messages.

```pycon
>>> spec = S3Connection(endpoint_url='http://localhost:9000',
...                     credentials=('AKIAEXAMPLE', 'sEkR3tVALUE'))
>>> res = resolve(spec, {})
>>> res.endpoint_url.value, res.endpoint_url.source
('http://localhost:9000', 'endpoint_url=')
>>> res.signature_version.value  # never left to botocore (ADR-0003 §4)
's3v4'
>>> 'sEkR3tVALUE' in repr(spec)  # secrets never in repr (ADR-0012 D1)
False
```

### Functions

| [`load_aws_config`](_autosummary/s3dol.connection.html.md#s3dol.connection.load_aws_config)()                    | The named, *impure* aws-config loader (ADR-0012 D2): loads the shared config via botocore (~16 ms — never on the common path; pass this function as a thunk and [`resolve()`](_autosummary/s3dol.connection.html.md#s3dol.connection.resolve) calls it only if a rung needs it), scrubbed of anything credential-shaped.   |
|---------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [`normalize_credentials`](_autosummary/s3dol.connection.html.md#s3dol.connection.normalize_credentials)(value)         | Normalise every accepted credential shape; reject the rest, each with its own message (ADR-0012 D5).                                                                                                                                                                                                    |
| [`resolve`](_autosummary/s3dol.connection.html.md#s3dol.connection.resolve)(spec, environ[, aws_config]) | Pure resolution: no `os.environ`, no disk, no network (ADR-0012 D2).                                                                                                                                                                                                                                    |

### Classes

| [`CallableCredentials`](_autosummary/s3dol.connection.html.md#s3dol.connection.CallableCredentials)(fetch)                       | A picklable zero-arg callable returning a mapping with keys `access_key`/`secret_key` (aliases: `key`/`secret`), optional `token`, optional `expires_at`/`expiry_time` (ISO 8601).    |
|---------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [`CredentialProvider`](_autosummary/s3dol.connection.html.md#s3dol.connection.CredentialProvider)()                             | Base of s3dol's picklable credential specs.                                                                                                                                           |
| [`ProfileCredentials`](_autosummary/s3dol.connection.html.md#s3dol.connection.ProfileCredentials)(profile)                      | Credentials from a named profile — *credentials only*; the profile's other config is not selected by this (that is what `profile=` on the connection is for).                         |
| [`Resolution`](_autosummary/s3dol.connection.html.md#s3dol.connection.Resolution)(endpoint_url, region_name, ...)       | The result of [`resolve()`](_autosummary/s3dol.connection.html.md#s3dol.connection.resolve) — everything `diagnose()` prints and everything client-build consumes.                                       |
| [`S3Connection`](_autosummary/s3dol.connection.html.md#s3dol.connection.S3Connection)([preset, endpoint_url, ...])        | A frozen, picklable connection spec.                                                                                                                                                  |
| [`Sourced`](_autosummary/s3dol.connection.html.md#s3dol.connection.Sourced)(value, source[, passed])                 | A resolved value, where it came from, and whether s3dol passes it to botocore explicitly (`passed=False` == the key is omitted so the channel below stays open — "omit, never None"). |
| [`StaticCredentials`](_autosummary/s3dol.connection.html.md#s3dol.connection.StaticCredentials)(access_key, secret_key[, ...]) | An explicit key pair (optionally a session token).                                                                                                                                    |

### *class* s3dol.connection.CallableCredentials(fetch)

Bases: [`CredentialProvider`](_autosummary/s3dol.connection.html.md#s3dol.connection.CredentialProvider)

A picklable zero-arg callable returning a mapping with keys
`access_key`/`secret_key` (aliases: `key`/`secret`), optional
`token`, optional `expires_at`/`expiry_time` (ISO 8601). With an
expiry, credentials are refreshable — the callable is re-invoked by
botocore’s refresh machinery (advisory 900 s / mandatory 600 s before
expiry).

#### provenance()

A label for diagnose() — never a credential value.

* **Return type:**
  [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)

### *class* s3dol.connection.CredentialProvider

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

Base of s3dol’s picklable credential specs.

Subclasses are small frozen dataclasses that *describe* how to obtain
credentials; nothing live is held (nothing live pickles — measured, ADR-0012
D5). At client-build time each is adapted into a botocore provider and
**replaces** botocore’s resolver via
`session.register_component('credential_provider', ...)` — never
prepended (silent fallthrough) and never `insert_before` (raises when a
profile is set).

#### provenance()

A label for diagnose() — never a credential value.

* **Return type:**
  [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)

### *class* s3dol.connection.ProfileCredentials(profile)

Bases: [`CredentialProvider`](_autosummary/s3dol.connection.html.md#s3dol.connection.CredentialProvider)

Credentials from a named profile — *credentials only*; the profile’s
other config is not selected by this (that is what `profile=` on the
connection is for). Rebuilds live, still-refreshable credentials after
unpickling (a frozen dataclass holding only a profile name round-trips).

#### provenance()

A label for diagnose() — never a credential value.

* **Return type:**
  [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)

### *class* s3dol.connection.Resolution(endpoint_url, region_name, signature_version, addressing_style, checksum, payload_signing_enabled, verify, preset, preset_source, credential_provenance, capabilities, environ_consulted, notes)

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

The result of [`resolve()`](_autosummary/s3dol.connection.html.md#s3dol.connection.resolve) — everything `diagnose()` prints and
everything client-build consumes. Carries provenance labels, never a
credential value.

#### environ_consulted *: [tuple](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[tuple](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[str](https://docs.python.org/3/builtins/stdtypes.html#str), [Optional](https://docs.python.org/3/library/typing.html#typing.Optional)[[str](https://docs.python.org/3/builtins/stdtypes.html#str)]], ...]*

The non-secret environment keys consulted, with their values.

#### notes *: [tuple](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[tuple](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[type](https://docs.python.org/3/builtins/functions.html#type), [str](https://docs.python.org/3/builtins/stdtypes.html#str)], ...]*

Collected (warning class, message) pairs. resolve() never emits them —
the impure caller decides (client build warns; diagnose prints rows).

### *class* s3dol.connection.S3Connection(preset=None, endpoint_url=None, region_name=None, profile=None, credentials=None, anon=False, signature_version='s3v4', addressing_style=None, checksum=None, payload_signing_enabled=None, verify=None, client_kwargs=(), deny_means_absent=False)

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

A frozen, picklable connection spec. No live objects — ever.

Construction performs no I/O and does not import boto3 (ADR-0002); the
client is built lazily, once, under a per-instance lock (CPython ≥3.12
removed `cached_property`’s lock deliberately — measured: 8 racing
threads → 8 clients without one).

`__post_init__` is the only door: every normalisation and contradiction
check happens here, so a bad shape dies at construction with a message,
not later inside botocore.

```pycon
>>> S3Connection(anon=True, profile='prod')
Traceback (most recent call last):
...
s3dol.errors.ConfigurationError: ...
```

#### *property* client

The boto3 S3 client — built lazily, once, under the lock.

#### *property* presign_client

The client presigned URLs are generated with.

For most providers this is [`client`](_autosummary/s3dol.connection.html.md#s3dol.connection.S3Connection.client). Two providers genuinely
need different config for presigning than for the API (ADR-0003 §1):
Hetzner presigns virtual-hosted while the API is path-style; R2
presigns only on the S3 API domain. When the resolved preset carries
`presign_endpoint_url`/`presign_addressing_style`, a second client
is built (lazily, once, under the same lock) from the merged config.

#### resolution(environ=None, aws_config=<function load_aws_config>)

Resolve against the real environment by default (a thin impure
wrapper over the pure [`resolve()`](_autosummary/s3dol.connection.html.md#s3dol.connection.resolve)).

* **Return type:**
  [`Resolution`](_autosummary/s3dol.connection.html.md#s3dol.connection.Resolution)

### *class* s3dol.connection.Sourced(value, source, passed=False)

Bases: [`NamedTuple`](https://docs.python.org/3/library/typing.html#typing.NamedTuple)

A resolved value, where it came from, and whether s3dol passes it to
botocore explicitly (`passed=False` == the key is omitted so the channel
below stays open — “omit, never None”).

#### passed *: [bool](https://docs.python.org/3/builtins/functions.html#bool)*

Alias for field number 2

#### source *: [str](https://docs.python.org/3/builtins/stdtypes.html#str)*

Alias for field number 1

#### value *: [Any](https://docs.python.org/3/library/typing.html#typing.Any)*

Alias for field number 0

### *class* s3dol.connection.StaticCredentials(access_key, secret_key, token=None)

Bases: [`CredentialProvider`](_autosummary/s3dol.connection.html.md#s3dol.connection.CredentialProvider)

An explicit key pair (optionally a session token).

#### NOTE
a *static* token expires and cannot refresh — prefer `profile=` or
a callable provider for STS/SSO. Pickling this object carries the secret
(that is what “explicit credentials” means); its repr does not.

#### provenance()

A label for diagnose() — never a credential value.

* **Return type:**
  [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)

### s3dol.connection.load_aws_config()

The named, *impure* aws-config loader (ADR-0012 D2): loads the shared
config via botocore (~16 ms — never on the common path; pass this function
as a thunk and [`resolve()`](_autosummary/s3dol.connection.html.md#s3dol.connection.resolve) calls it only if a rung needs it), scrubbed
of anything credential-shaped.

* **Return type:**
  [`Mapping`](https://docs.python.org/3/library/typing.html#typing.Mapping)

### s3dol.connection.normalize_credentials(value)

Normalise every accepted credential shape; reject the rest, each with
its own message (ADR-0012 D5). The only door is `S3Connection.__post_init__`.

```pycon
>>> normalize_credentials(None) is None
True
>>> normalize_credentials('prod')
ProfileCredentials(profile='prod')
>>> normalize_credentials(('AKIAXX', 'sec'))
StaticCredentials(access_key='AKIA'…, secret_key=***)
```

* **Return type:**
  [`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`CredentialProvider`](_autosummary/s3dol.connection.html.md#s3dol.connection.CredentialProvider)]

### s3dol.connection.resolve(spec, environ, aws_config=None)

Pure resolution: no `os.environ`, no disk, no network (ADR-0012 D2).

`environ` is a plain mapping (pass `os.environ` at real call sites,
a dict in tests). `aws_config` is a pre-loaded, credential-scrubbed
config mapping, or a thunk for one ([`load_aws_config()`](_autosummary/s3dol.connection.html.md#s3dol.connection.load_aws_config)) — called only
if a rung needs it.

* **Return type:**
  [`Resolution`](_autosummary/s3dol.connection.html.md#s3dol.connection.Resolution)


# _autosummary/s3dol.errors.html.md

# s3dol.errors

The s3dol error taxonomy and the single error-translation seam.

Design record: `misc/docs/decisions/0004-error-taxonomy.md` (the taxonomy, the
`(operation, code, status)` classification, the 403 policy, `ObjectArchived`)
and `misc/docs/decisions/0012-credential-and-endpoint-resolution.md` (the
`ConfigurationError` tree and the `S3DolWarning` tree).

Three rules govern this module:

1. **One seam.** [`translate_s3_errors()`](_autosummary/s3dol.errors.html.md#s3dol.errors.translate_s3_errors) is the only place in the package
   that catches botocore exceptions. Everything else propagates.
2. \*\*Auth, config and transport errors are never translated to `KeyError`.\*\*
   A missing permission must not look like a missing key.
3. \*\*Classification keys on `(operation, code, status)`, never on exception
   type.\*\* HEAD responses have no body, so botocore’s modelled exceptions
   (`client.exceptions.NoSuchKey` …) never fire for them.

Everything classification-related here is pure: [`classify_client_error()`](_autosummary/s3dol.errors.html.md#s3dol.errors.classify_client_error)
takes plain values (or a synthesized `ClientError`) and touches no network,
so the bulk of error tests are tier-1 unit tests — including body-less HEAD
errors, which moto cannot produce.

```pycon
>>> classify_client_error('GetObject', 'NoSuchKey', 404).kind
'object_absent'
>>> classify_client_error('HeadObject', '404', 404).kind  # HEAD is ambiguous
'ambiguous_head'
>>> classify_client_error('GetObject', 'AccessDenied', 403).kind
'access_denied'
```

### Module Attributes

| [`KINDS`](_autosummary/s3dol.errors.html.md#s3dol.errors.KINDS)         | Kinds a classified error can be.                                           |
|----------------------------------------------------------------|----------------------------------------------------------------------------|
| [`Rule`](_autosummary/s3dol.errors.html.md#s3dol.errors.Rule)          | `((operation, code, status), kind)`.                                       |
| [`DEFAULT_RULES`](_autosummary/s3dol.errors.html.md#s3dol.errors.DEFAULT_RULES) | The default classification table (ADR-0004 §2, measured against botocore). |

### Functions

| [`classify_client_error`](_autosummary/s3dol.errors.html.md#s3dol.errors.classify_client_error)(operation, code, status, \*)   | Classify a backend error by `(operation, code, status)`.                                                                                                                                                       |
|-------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [`code_of`](_autosummary/s3dol.errors.html.md#s3dol.errors.code_of)(client_error)                                | The `Error.Code` of a botocore `ClientError` (or `None`).                                                                                                                                                      |
| [`redact`](_autosummary/s3dol.errors.html.md#s3dol.errors.redact)(text)                                         | Redact signed-URL query secrets from `text`.                                                                                                                                                                   |
| [`redact_url`](_autosummary/s3dol.errors.html.md#s3dol.errors.redact_url)(url)                                      | A URL safe to display: userinfo, query and fragment removed.                                                                                                                                                   |
| [`status_of`](_autosummary/s3dol.errors.html.md#s3dol.errors.status_of)(client_error)                              | The HTTP status of a botocore `ClientError` (or `None`).                                                                                                                                                       |
| [`translate_client_error`](_autosummary/s3dol.errors.html.md#s3dol.errors.translate_client_error)(error, \*, operation)         | Translate a botocore `ClientError` into the s3dol taxonomy.                                                                                                                                                    |
| [`translate_s3_errors`](_autosummary/s3dol.errors.html.md#s3dol.errors.translate_s3_errors)(\*, operation[, key_arg])        | The one seam: decorate a Layer B method so botocore's `ClientError` becomes the s3dol taxonomy (ADR-0004 §1).                                                                                                  |
| [`translating_s3_errors`](_autosummary/s3dol.errors.html.md#s3dol.errors.translating_s3_errors)(store, \*, operation[, key])   | Generator/inline form of the seam, for code the decorator cannot wrap (`__iter__` bodies: a decorated generator function returns its generator before the body runs, so the decorator's `except` never fires). |

### Classes

| [`Classified`](_autosummary/s3dol.errors.html.md#s3dol.errors.Classified)(kind[, exception_type])   | The result of classifying a backend error.   |
|---------------------------------------------------------------------------------------|----------------------------------------------|

### Exceptions

| [`AccessDenied`](_autosummary/s3dol.errors.html.md#s3dol.errors.AccessDenied)                                       | Permission denied.                                                                                                                    |
|-----------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------|
| [`AmbiguousResolution`](_autosummary/s3dol.errors.html.md#s3dol.errors.AmbiguousResolution)                                | Resolution is legal but ambiguous (e.g. a named preset whose endpoint, supplied from the environment, matches no known host pattern). |
| [`AnonymousFallback`](_autosummary/s3dol.errors.html.md#s3dol.errors.AnonymousFallback)                                  | Anonymous access was used as a fallback (reserved for a future `anon='auto'` — ADR-0012 D5 defers that feature to v1.x).              |
| [`BucketNotEmpty`](_autosummary/s3dol.errors.html.md#s3dol.errors.BucketNotEmpty)                                     | Refusal to delete a non-empty bucket.                                                                                                 |
| [`BucketNotFound`](_autosummary/s3dol.errors.html.md#s3dol.errors.BucketNotFound)                                     | The bucket is absent.                                                                                                                 |
| [`ConfigurationError`](_autosummary/s3dol.errors.html.md#s3dol.errors.ConfigurationError)                                 | A construction- or resolution-time misconfiguration (ADR-0012 D1).                                                                    |
| [`CredentialsError`](_autosummary/s3dol.errors.html.md#s3dol.errors.CredentialsError)                                   | Credentials are missing, expired, or invalid.                                                                                         |
| [`InvalidEndpoint`](_autosummary/s3dol.errors.html.md#s3dol.errors.InvalidEndpoint)                                    | An endpoint URL failed hygiene checks (userinfo/query/fragment — ADR-0012 D4: a URL is the residual credential carrier).              |
| [`KeyNotValid`](_autosummary/s3dol.errors.html.md#s3dol.errors.KeyNotValid)                                        | The key is syntactically invalid (checked before the wire).                                                                           |
| [`MissingEndpoint`](_autosummary/s3dol.errors.html.md#s3dol.errors.MissingEndpoint)                                    | The named preset needs an endpoint (or endpoint parameters) that nothing supplied (ADR-0012 C1).                                      |
| [`MissingPresetParam`](_autosummary/s3dol.errors.html.md#s3dol.errors.MissingPresetParam)                                 | A preset's endpoint template has an unbound required parameter, so the row contributes no endpoint rung (ADR-0012 C1).                |
| [`NotSupported`](_autosummary/s3dol.errors.html.md#s3dol.errors.NotSupported)                                       | The operation is not supported by this provider (names both).                                                                         |
| [`ObjectArchived`](_autosummary/s3dol.errors.html.md#s3dol.errors.ObjectArchived)(message, \*[, storage_class, ...])  | The object exists but is archived (e.g. Glacier) and cannot be read now.                                                              |
| [`ObjectNotFound`](_autosummary/s3dol.errors.html.md#s3dol.errors.ObjectNotFound)                                     | The object is absent.                                                                                                                 |
| [`PresetConflict`](_autosummary/s3dol.errors.html.md#s3dol.errors.PresetConflict)                                     | An explicit argument contradicts a *pinned* (verified) preset value.                                                                  |
| [`PresetHostMismatch`](_autosummary/s3dol.errors.html.md#s3dol.errors.PresetHostMismatch)                                 | The resolved endpoint's host matches a *different* provider's patterns than the preset you named (ADR-0012 C2).                       |
| [`S3DolResolutionChanged`](_autosummary/s3dol.errors.html.md#s3dol.errors.S3DolResolutionChanged)                             | v1 resolves this call differently than v0 would have (ADR-0012 D7).                                                                   |
| [`S3DolWarning`](_autosummary/s3dol.errors.html.md#s3dol.errors.S3DolWarning)                                       | Base of every s3dol warning.                                                                                                          |
| [`S3Error`](_autosummary/s3dol.errors.html.md#s3dol.errors.S3Error)                                            | Base of every s3dol exception — `except S3Error` catches the package.                                                                 |
| [`S3PartialFailure`](_autosummary/s3dol.errors.html.md#s3dol.errors.S3PartialFailure)(message, \*, succeeded, failures) | A bulk operation partially failed (ADR-0010 §2).                                                                                      |
| [`UnknownPresetParam`](_autosummary/s3dol.errors.html.md#s3dol.errors.UnknownPresetParam)                                 | A parameter was bound that the preset's templates do not use.                                                                         |

### *exception* s3dol.errors.AccessDenied

Bases: [`S3Error`](_autosummary/s3dol.errors.html.md#s3dol.errors.S3Error)

Permission denied. **Not** a `KeyError` — a missing permission must
not look like a missing key (ADR-0004 §1/§3).

### *exception* s3dol.errors.AmbiguousResolution

Bases: [`S3DolWarning`](_autosummary/s3dol.errors.html.md#s3dol.errors.S3DolWarning)

Resolution is legal but ambiguous (e.g. a named preset whose endpoint,
supplied from the environment, matches no known host pattern).

### *exception* s3dol.errors.AnonymousFallback

Bases: [`S3DolWarning`](_autosummary/s3dol.errors.html.md#s3dol.errors.S3DolWarning)

Anonymous access was used as a fallback (reserved for a future
`anon='auto'` — ADR-0012 D5 defers that feature to v1.x).

### *exception* s3dol.errors.BucketNotEmpty

Bases: [`S3Error`](_autosummary/s3dol.errors.html.md#s3dol.errors.S3Error)

Refusal to delete a non-empty bucket. Use
`s3dol.delete_bucket(endpoint, name, force=True)` for the explicit
cascading form (ADR-0010 §3).

### *exception* s3dol.errors.BucketNotFound

Bases: [`S3Error`](_autosummary/s3dol.errors.html.md#s3dol.errors.S3Error), `_InformativeKeyError`

The bucket is absent.

Still a `KeyError`: for an object operation it is a key-space problem for
the caller; for a bucket operation it is the key of the endpoint mapping.

### *class* s3dol.errors.Classified(kind, exception_type=None)

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

The result of classifying a backend error.

### *exception* s3dol.errors.ConfigurationError

Bases: [`S3Error`](_autosummary/s3dol.errors.html.md#s3dol.errors.S3Error), [`ValueError`](https://docs.python.org/3/builtins/exceptions.html#ValueError)

A construction- or resolution-time misconfiguration (ADR-0012 D1).

### *exception* s3dol.errors.CredentialsError

Bases: [`S3Error`](_autosummary/s3dol.errors.html.md#s3dol.errors.S3Error)

Credentials are missing, expired, or invalid.

### s3dol.errors.DEFAULT_RULES *: [tuple](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[tuple](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[tuple](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[Optional](https://docs.python.org/3/library/typing.html#typing.Optional)[[str](https://docs.python.org/3/builtins/stdtypes.html#str)], [Optional](https://docs.python.org/3/library/typing.html#typing.Optional)[[str](https://docs.python.org/3/builtins/stdtypes.html#str)], [Optional](https://docs.python.org/3/library/typing.html#typing.Optional)[[int](https://docs.python.org/3/builtins/functions.html#int)]], [str](https://docs.python.org/3/builtins/stdtypes.html#str)], ...]* *= (((None, 'NoSuchKey', None), 'object_absent'), ((None, 'NoSuchBucket', None), 'bucket_absent'), ((None, 'NoSuchUpload', None), 'object_absent'), (('HeadObject', '404', 404), 'ambiguous_head'), (('HeadBucket', '404', 404), 'bucket_absent'), (('HeadObject', '404', None), 'ambiguous_head'), (('HeadBucket', '404', None), 'bucket_absent'), (('HeadObject', None, 405), 'delete_marker'), ((None, None, 301), 'wrong_region'), ((None, 'PermanentRedirect', None), 'wrong_region'), ((None, 'AuthorizationHeaderMalformed', None), 'wrong_region'), ((None, 'InvalidObjectState', None), 'archived'), ((None, 'RequestTimeTooSkewed', None), 'credentials'), ((None, 'RequestExpired', None), 'credentials'), ((None, 'AuthorizationQueryParametersError', None), 'credentials'), ((None, 'ExpiredToken', None), 'credentials'), ((None, 'InvalidAccessKeyId', None), 'credentials'), ((None, 'SignatureDoesNotMatch', None), 'credentials'), ((None, 'TokenRefreshRequired', None), 'credentials'), ((None, 'AccessDenied', None), 'access_denied'), ((None, 'AllAccessDisabled', None), 'access_denied'), ((None, '403', 403), 'access_denied'), ((None, None, 403), 'access_denied'), ((None, 'KeyTooLongError', None), 'invalid_key'), ((None, 'SlowDown', None), 'transient'), ((None, 'RequestTimeout', None), 'transient'), ((None, 'ServiceUnavailable', None), 'transient'), ((None, 'InternalError', None), 'transient'), ((None, None, 503), 'transient'))*

The default classification table (ADR-0004 §2, measured against botocore).

### *exception* s3dol.errors.InvalidEndpoint

Bases: [`ConfigurationError`](_autosummary/s3dol.errors.html.md#s3dol.errors.ConfigurationError)

An endpoint URL failed hygiene checks (userinfo/query/fragment —
ADR-0012 D4: a URL is the residual credential carrier).

### s3dol.errors.KINDS *= ('object_absent', 'bucket_absent', 'ambiguous_head', 'access_denied', 'credentials', 'invalid_key', 'archived', 'not_supported', 'wrong_region', 'delete_marker', 'transient', 'unknown')*

Kinds a classified error can be. Layer B maps kinds to behaviour; in
particular `ambiguous_head` triggers the one-`HeadBucket`
disambiguation of ADR-0004 §2 (HEAD has no body, so a missing key and a
missing bucket are both `('404', 404)` on real AWS).

### *exception* s3dol.errors.KeyNotValid

Bases: [`S3Error`](_autosummary/s3dol.errors.html.md#s3dol.errors.S3Error), `_InformativeKeyError`, [`ValueError`](https://docs.python.org/3/builtins/exceptions.html#ValueError)

The key is syntactically invalid (checked before the wire).

Inherits from both `KeyError` and `ValueError` deliberately, so either
`except` works. Named `KeyNotValid` (not `KeyValidationError`) because
dol already ships two *different* classes called `KeyValidationError`
(ADR-0004 §5).

### *exception* s3dol.errors.MissingEndpoint

Bases: [`ConfigurationError`](_autosummary/s3dol.errors.html.md#s3dol.errors.ConfigurationError)

The named preset needs an endpoint (or endpoint parameters) that nothing
supplied (ADR-0012 C1).

### *exception* s3dol.errors.MissingPresetParam

Bases: [`MissingEndpoint`](_autosummary/s3dol.errors.html.md#s3dol.errors.MissingEndpoint)

A preset’s endpoint template has an unbound required parameter, so the
row contributes no endpoint rung (ADR-0012 C1). A `MissingEndpoint`, so
either `except` works.

### *exception* s3dol.errors.NotSupported

Bases: [`S3Error`](_autosummary/s3dol.errors.html.md#s3dol.errors.S3Error)

The operation is not supported by this provider (names both).

### *exception* s3dol.errors.ObjectArchived(message, , storage_class=None, restore_status=None, restore=None)

Bases: [`S3Error`](_autosummary/s3dol.errors.html.md#s3dol.errors.S3Error), `_InformativeKeyError`

The object exists but is archived (e.g. Glacier) and cannot be read now.

A `KeyError`, deliberately and arguably (ADR-0004 §4): `k in store`
stays `True`, but `store[k]` fails as a `KeyError` so that
`store.get(k, default)` degrades to the not-available branch. Note that
only the *defaulted accessors* degrade — `dict(store)`, `.items()` and
`Mapping.__eq__` still raise. `setdefault`/`pop` are overridden in the
store to re-raise this instead of silently overwriting the archived object.

#### restore(days=1, , tier='Standard')

Request restoration of the archived object (if a handle was bound).

### *exception* s3dol.errors.ObjectNotFound

Bases: [`S3Error`](_autosummary/s3dol.errors.html.md#s3dol.errors.S3Error), `_InformativeKeyError`

The object is absent. The Mapping contract’s `KeyError`.

### *exception* s3dol.errors.PresetConflict

Bases: [`ConfigurationError`](_autosummary/s3dol.errors.html.md#s3dol.errors.ConfigurationError)

An explicit argument contradicts a *pinned* (verified) preset value.

### *exception* s3dol.errors.PresetHostMismatch

Bases: [`ConfigurationError`](_autosummary/s3dol.errors.html.md#s3dol.errors.ConfigurationError)

The resolved endpoint’s host matches a *different* provider’s patterns
than the preset you named (ADR-0012 C2).

### s3dol.errors.Rule

`((operation, code, status), kind)`. `None` is a wildcard.
First match wins; more specific rows come first.

* **Type:**
  Rule rows

alias of [`tuple`](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[`tuple`](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str) | [`None`](https://docs.python.org/3/builtins/constants.html#None), [`str`](https://docs.python.org/3/builtins/stdtypes.html#str) | [`None`](https://docs.python.org/3/builtins/constants.html#None), [`int`](https://docs.python.org/3/builtins/functions.html#int) | [`None`](https://docs.python.org/3/builtins/constants.html#None)], [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]

### *exception* s3dol.errors.S3DolResolutionChanged

Bases: [`S3DolWarning`](_autosummary/s3dol.errors.html.md#s3dol.errors.S3DolWarning)

v1 resolves this call differently than v0 would have (ADR-0012 D7).
Emitted by the compat shim; dies with it.

### *exception* s3dol.errors.S3DolWarning

Bases: [`UserWarning`](https://docs.python.org/3/builtins/exceptions.html#UserWarning)

Base of every s3dol warning.

### *exception* s3dol.errors.S3Error

Bases: [`Exception`](https://docs.python.org/3/builtins/exceptions.html#Exception)

Base of every s3dol exception — `except S3Error` catches the package.

### *exception* s3dol.errors.S3PartialFailure(message, , succeeded, failures)

Bases: [`S3Error`](_autosummary/s3dol.errors.html.md#s3dol.errors.S3Error)

A bulk operation partially failed (ADR-0010 §2).

Not an `ExceptionGroup` — the package supports Python 3.10.

#### succeeded

keys the backend reported as deleted (absent keys are
reported as deleted too — S3’s semantics, documented, not hidden).

#### failures

mapping of key -> the error for that key.

### *exception* s3dol.errors.UnknownPresetParam

Bases: [`ConfigurationError`](_autosummary/s3dol.errors.html.md#s3dol.errors.ConfigurationError)

A parameter was bound that the preset’s templates do not use.

### s3dol.errors.classify_client_error(operation, code, status, , overrides=())

Classify a backend error by `(operation, code, status)`.

`overrides` rows (typically from a preset) are consulted first, so a
provider divergence is a table row, never a code branch.

```pycon
>>> classify_client_error('HeadBucket', None, 400,
...     overrides=((('HeadBucket', None, 400), 'bucket_absent'),)).kind
'bucket_absent'
```

* **Return type:**
  [`Classified`](_autosummary/s3dol.errors.html.md#s3dol.errors.Classified)

### s3dol.errors.code_of(client_error)

The `Error.Code` of a botocore `ClientError` (or `None`).

* **Return type:**
  [`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]

### s3dol.errors.redact(text)

Redact signed-URL query secrets from `text`.

Error messages may name the operation, bucket, key, endpoint and code, but
never a credential, token, or signed URL — redaction is a tested function,
not a convention (ADR-0004 §7).

```pycon
>>> redact('https://b.s3.amazonaws.com/k?X-Amz-Signature=abc123&x=1')
'https://b.s3.amazonaws.com/k?X-Amz-Signature=REDACTED&x=1'
```

* **Return type:**
  [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)

### s3dol.errors.redact_url(url)

A URL safe to display: userinfo, query and fragment removed.

A URL is the residual credential carrier (ADR-0012 D4). Endpoint hygiene
refuses those shapes for values *s3dol* is given, but an endpoint read
from `AWS_ENDPOINT_URL_S3` or an aws-config profile is not ours to
refuse — it must merely never be echoed intact.

```pycon
>>> redact_url('https://user:pw@minio.internal:9000/x?sig=abc#f')
'https://REDACTED@minio.internal:9000/x?<redacted>'
```

* **Return type:**
  [`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]

### s3dol.errors.status_of(client_error)

The HTTP status of a botocore `ClientError` (or `None`).

* **Return type:**
  [`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`int`](https://docs.python.org/3/builtins/functions.html#int)]

### s3dol.errors.translate_client_error(error, , operation, bucket=None, key=None, endpoint=None, overrides=(), deny_means_absent=False, head_ambiguity_resolver=None)

Translate a botocore `ClientError` into the s3dol taxonomy.

Returns the replacement exception, or `None` meaning \*propagate the
original\* (transient/unknown — rule 2 of the module docstring).

`head_ambiguity_resolver` resolves the body-less `HeadObject` 404
(ADR-0004 §2): it returns `True` iff the bucket is known reachable, in
which case the miss really is the object’s. It is only called for the
ambiguous case, so the common path costs nothing.

`deny_means_absent=True` classifies an object-op 403 as
`ObjectNotFound` — for deployments knowingly running the canonical
least-privilege policy that omits `s3:ListBucket` (ADR-0004 §3).

* **Return type:**
  [`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`S3Error`](_autosummary/s3dol.errors.html.md#s3dol.errors.S3Error)]

### s3dol.errors.translate_s3_errors(, operation, key_arg=None, \*\*translate_kwargs)

The one seam: decorate a Layer B method so botocore’s `ClientError`
becomes the s3dol taxonomy (ADR-0004 §1).

`key_arg` names the decorated function’s key *parameter* (resolved via
the call’s kwargs/positionals — never an attribute, so the key is not lost
the way azuredol’s `key_arg='blob'` loses it). The store instance is
expected to provide `_error_context()` returning
`dict(bucket=..., endpoint=..., overrides=..., deny_means_absent=...,
head_ambiguity_resolver=...)` — Layer B owns that context.

### s3dol.errors.translating_s3_errors(store, , operation, key=None, \*\*translate_kwargs)

Generator/inline form of the seam, for code the decorator cannot wrap
(`__iter__` bodies: a decorated generator function returns its generator
before the body runs, so the decorator’s `except` never fires).

Same contract as [`translate_s3_errors()`](_autosummary/s3dol.errors.html.md#s3dol.errors.translate_s3_errors); the store supplies
`_error_context()`.


# _autosummary/s3dol.html.md

# s3dol

s3dol — S3 and S3-compatible object storage behind a dict-like interface.

The one-liner:

```default
import s3dol
s = s3dol.s3_store('my-bucket')          # MutableMapping[str, bytes]
s['k'] = b'v'; s['k']; list(s); del s['k']
```

Keyed capabilities are **sibling stores you index** (never methods — a dol key
wrapper would hand a method the unmapped key; ADR-0011):

```default
s3dol.handles(s)['k']    # ObjectHandle (ranged reads, streams, metadata)
s3dol.urls(s)['k']       # presigned URL
s3dol.info(s)['k']       # ObjectInfo (one HeadObject)
s3dol.listed_info(s)['k']  # ObjectInfo from one LIST (a snapshot)
```

Non-keyed operations are free functions taking the store first:

```default
s3dol.sub(s, 'folder/')          s3dol.prefixes(s)
s3dol.delete_many(s, keys)       s3dol.delete_bucket(endpoint, name, force=True)
```

Test without a cloud: `from s3dol.testing import mock_s3, run_conformance`.
Migrating from v0? `s3dol.diagnose(**your_S3Store_kwargs)` prints what
resolves, from where, and whether v1 moves it. The legacy `S3Store` keeps
working via `s3dol.store` (deprecated, removed in v2).

Everything here loads lazily (PEP 562): `import s3dol` does not import boto3.

### Functions

| [`S3Store`](_autosummary/s3dol.html.md#s3dol.S3Store)(bucket_name, \*[, make_bucket, path, ...])   | DEPRECATED — the v0 entry point, kept working until v2.                                                                                                                                                                       |
|-------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [`delete_bucket`](_autosummary/s3dol.html.md#s3dol.delete_bucket)(endpoint, name, \*[, force])           | Delete bucket `name`.                                                                                                                                                                                                         |
| [`delete_many`](_autosummary/s3dol.html.md#s3dol.delete_many)(store, keys)                             | Bulk delete (ADR-0010 §2; a free function per ADR-0011 D4 — keyed + destructive + delegated is the census's data-destroying shape).                                                                                           |
| [`diagnose`](_autosummary/s3dol.html.md#s3dol.diagnose)([connection, environ, aws_config, file])    | Print (and return) the resolution report.                                                                                                                                                                                     |
| [`handles`](_autosummary/s3dol.html.md#s3dol.handles)(store)                                       | The sibling store of [`ObjectHandle`](_autosummary/s3dol.html.md#s3dol.ObjectHandle)s: `handles(s)[k]`.                                                                                                                         |
| [`info`](_autosummary/s3dol.html.md#s3dol.info)(store)                                          | The sibling store of [`ObjectInfo`](_autosummary/s3dol.html.md#s3dol.ObjectInfo): `info(s)[k]`.                                                                                                                               |
| [`listed_info`](_autosummary/s3dol.html.md#s3dol.listed_info)(store)                                   | The sibling store of [`ObjectInfo`](_autosummary/s3dol.html.md#s3dol.ObjectInfo) built from one paginated LIST: `listed_info(s)[k]` (a lazy snapshot; see [`BucketListedInfo`](_autosummary/s3dol.html.md#s3dol.BucketListedInfo)). |
| [`prefixes`](_autosummary/s3dol.html.md#s3dol.prefixes)(store)                                      | The 'directories' one level under the store's scope, \*\*relative to the caller's key space\*\* — one `ListObjectsV2(Delimiter='/')` reading `CommonPrefixes` (which v0 parsed and then called from nowhere; ADR-0009).       |
| [`presigned_upload`](_autosummary/s3dol.html.md#s3dol.presigned_upload)(store, \*, key_prefix, ...)         | A presigned POST form for ONE new object under `key_prefix`.                                                                                                                                                                  |
| [`register_preset`](_autosummary/s3dol.html.md#s3dol.register_preset)(preset, \*[, overwrite])             | Add a row.                                                                                                                                                                                                                    |
| [`resolve`](_autosummary/s3dol.html.md#s3dol.resolve)(spec, environ[, aws_config])                 | Pure resolution: no `os.environ`, no disk, no network (ADR-0012 D2).                                                                                                                                                          |
| [`s3_store`](_autosummary/s3dol.html.md#s3dol.s3_store)(bucket, \*[, prefix, preset, ...])          | One bucket as a `MutableMapping[str, bytes]` (a `Mapping` when `readonly=True`).                                                                                                                                              |
| [`sub`](_autosummary/s3dol.html.md#s3dol.sub)(store, prefix)                                   | A store scoped to `prefix`, **in the caller's key space** (D3).                                                                                                                                                               |
| [`urls`](_autosummary/s3dol.html.md#s3dol.urls)(store, \*[, expires_in, client_method])         | The sibling store of presigned URLs: `urls(s)[k]`.                                                                                                                                                                            |

### Classes

| [`BucketCollection`](_autosummary/s3dol.html.md#s3dol.BucketCollection)(bucket, \*[, connection, ...])    | Keys of one bucket (under the prefix).                                                                                                                                                                                                        |
|-----------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [`BucketHandles`](_autosummary/s3dol.html.md#s3dol.BucketHandles)(bucket, \*[, connection, ...])       | `k -> ObjectHandle` (key bound at construction; zero round-trips).                                                                                                                                                                            |
| [`BucketInfo`](_autosummary/s3dol.html.md#s3dol.BucketInfo)(bucket, \*[, connection, prefix, ...])  | `k -> ObjectInfo` (one `HeadObject`).                                                                                                                                                                                                         |
| [`BucketListedInfo`](_autosummary/s3dol.html.md#s3dol.BucketListedInfo)(bucket, \*[, connection, ...])    | `k -> ObjectInfo` from the listing rows, not one `HeadObject` per key.                                                                                                                                                                        |
| [`BucketReader`](_autosummary/s3dol.html.md#s3dol.BucketReader)(bucket, \*[, connection, ...])        |                                                                                                                                                                                                                                               |
| [`BucketStore`](_autosummary/s3dol.html.md#s3dol.BucketStore)(bucket, \*[, connection, prefix, ...]) |                                                                                                                                                                                                                                               |
| [`BucketUrls`](_autosummary/s3dol.html.md#s3dol.BucketUrls)(\*args[, expires_in, client_method])    | `k -> presigned URL` (zero object requests; `None` when anonymous).                                                                                                                                                                           |
| [`CallableCredentials`](_autosummary/s3dol.html.md#s3dol.CallableCredentials)(fetch)                         | A picklable zero-arg callable returning a mapping with keys `access_key`/`secret_key` (aliases: `key`/`secret`), optional `token`, optional `expires_at`/`expiry_time` (ISO 8601).                                                            |
| [`Capabilities`](_autosummary/s3dol.html.md#s3dol.Capabilities)([list_objects_v2, ...])               | What a backend supports.                                                                                                                                                                                                                      |
| [`Chunks`](_autosummary/s3dol.html.md#s3dol.Chunks)(chunks[, consumed])                         | The value is the concatenation of an iterable of `bytes` chunks.                                                                                                                                                                              |
| [`DailyByteBudget`](_autosummary/s3dol.html.md#s3dol.DailyByteBudget)(limit_bytes, \*[, ledger, today])  | A per-day byte budget (one instance per tenant); call it to reserve.                                                                                                                                                                          |
| [`EndpointCollection`](_autosummary/s3dol.html.md#s3dol.EndpointCollection)([connection])                   | Bucket names at one endpoint.                                                                                                                                                                                                                 |
| [`EndpointReader`](_autosummary/s3dol.html.md#s3dol.EndpointReader)([connection])                       |                                                                                                                                                                                                                                               |
| [`EndpointStore`](_autosummary/s3dol.html.md#s3dol.EndpointStore)([connection])                        |                                                                                                                                                                                                                                               |
| [`Filepath`](_autosummary/s3dol.html.md#s3dol.Filepath)(path)                                     | The value *is the content of this file*.                                                                                                                                                                                                      |
| [`ObjectHandle`](_autosummary/s3dol.html.md#s3dol.ObjectHandle)(bucket, key, \*[, connection])        | One object, key bound **at construction** — which is what makes it immune to the delegation trap (a key codec over the store cannot corrupt a key that was resolved before the handle existed; ADR-0011 D1, following `azuredol.BlobHandle`). |
| [`ObjectInfo`](_autosummary/s3dol.html.md#s3dol.ObjectInfo)(key[, size, last_modified, etag, ...])  | Object metadata — from `HeadObject` or from a LIST row (which already carries size/mtime/etag/storage class that v0 threw away; ADR-0009).                                                                                                    |
| [`Preset`](_autosummary/s3dol.html.md#s3dol.Preset)(name, addressing_style[, ...])              | One provider's facts.                                                                                                                                                                                                                         |
| [`ProfileCredentials`](_autosummary/s3dol.html.md#s3dol.ProfileCredentials)(profile)                        | Credentials from a named profile — *credentials only*; the profile's other config is not selected by this (that is what `profile=` on the connection is for).                                                                                 |
| [`Resolution`](_autosummary/s3dol.html.md#s3dol.Resolution)(endpoint_url, region_name, ...)         | The result of [`resolve()`](_autosummary/s3dol.html.md#s3dol.resolve) — everything `diagnose()` prints and everything client-build consumes.                                                                                               |
| [`S3Connection`](_autosummary/s3dol.html.md#s3dol.S3Connection)([preset, endpoint_url, ...])          | A frozen, picklable connection spec.                                                                                                                                                                                                          |
| [`S3Jsons`](_autosummary/s3dol.html.md#s3dol.S3Jsons)                                            |                                                                                                                                                                                                                                               |
| [`S3Pickles`](_autosummary/s3dol.html.md#s3dol.S3Pickles)                                          |                                                                                                                                                                                                                                               |
| [`S3Profiles`](_autosummary/s3dol.html.md#s3dol.S3Profiles)(\*[, bucket_kwargs, readonly])          | AWS **profile** names -> endpoint stores (the v0 `S3Dol`, renamed — its keys are verifiably profile names, never endpoints; ADR-0007 §1).                                                                                                     |
| [`S3Texts`](_autosummary/s3dol.html.md#s3dol.S3Texts)                                            |                                                                                                                                                                                                                                               |
| [`StaticCredentials`](_autosummary/s3dol.html.md#s3dol.StaticCredentials)(access_key, secret_key[, ...])   | An explicit key pair (optionally a session token).                                                                                                                                                                                            |
| [`Streamable`](_autosummary/s3dol.html.md#s3dol.Streamable)(open_stream)                            | The value is whatever a zero-arg factory's stream yields — for sources that must be (re)opened at write time, e.g. an HTTP download.                                                                                                          |
| [`S3Dol`](_autosummary/s3dol.html.md#s3dol.S3Dol)                                              |                                                                                                                                                                                                                                               |

### Exceptions

| [`AccessDenied`](_autosummary/s3dol.html.md#s3dol.AccessDenied)                                       | Permission denied.                                                       |
|-----------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------|
| [`BucketNotEmpty`](_autosummary/s3dol.html.md#s3dol.BucketNotEmpty)                                     | Refusal to delete a non-empty bucket.                                    |
| [`BucketNotFound`](_autosummary/s3dol.html.md#s3dol.BucketNotFound)                                     | The bucket is absent.                                                    |
| [`ConfigurationError`](_autosummary/s3dol.html.md#s3dol.ConfigurationError)                                 | A construction- or resolution-time misconfiguration (ADR-0012 D1).       |
| [`CredentialsError`](_autosummary/s3dol.html.md#s3dol.CredentialsError)                                   | Credentials are missing, expired, or invalid.                            |
| [`KeyNotValid`](_autosummary/s3dol.html.md#s3dol.KeyNotValid)                                        | The key is syntactically invalid (checked before the wire).              |
| [`NotSupported`](_autosummary/s3dol.html.md#s3dol.NotSupported)                                       | The operation is not supported by this provider (names both).            |
| [`ObjectArchived`](_autosummary/s3dol.html.md#s3dol.ObjectArchived)(message, \*[, storage_class, ...])  | The object exists but is archived (e.g. Glacier) and cannot be read now. |
| [`ObjectNotFound`](_autosummary/s3dol.html.md#s3dol.ObjectNotFound)                                     | The object is absent.                                                    |
| [`S3DolWarning`](_autosummary/s3dol.html.md#s3dol.S3DolWarning)                                       | Base of every s3dol warning.                                             |
| [`S3Error`](_autosummary/s3dol.html.md#s3dol.S3Error)                                            | Base of every s3dol exception — `except S3Error` catches the package.    |
| [`S3PartialFailure`](_autosummary/s3dol.html.md#s3dol.S3PartialFailure)(message, \*, succeeded, failures) | A bulk operation partially failed (ADR-0010 §2).                         |
| [`UploadBudgetExceeded`](_autosummary/s3dol.html.md#s3dol.UploadBudgetExceeded)                               | The tenant's byte budget cannot cover this upload; no form was signed.   |

### *exception* s3dol.AccessDenied

Bases: [`S3Error`](_autosummary/s3dol.errors.html.md#s3dol.errors.S3Error)

Permission denied. **Not** a `KeyError` — a missing permission must
not look like a missing key (ADR-0004 §1/§3).

### *class* s3dol.BucketCollection(bucket, , connection=None, prefix='', delimiter='/', reads=None, writes=None, on_missing_bucket='assume', strict_delete=False)

Bases: `_BucketBase`, `Collection`

Keys of one bucket (under the prefix). `Collection` only —
iteration and membership, no reads.

### *class* s3dol.BucketHandles(bucket, , connection=None, prefix='', delimiter='/', reads=None, writes=None, on_missing_bucket='assume', strict_delete=False)

Bases: [`BucketCollection`](_autosummary/s3dol.base.html.md#s3dol.base.BucketCollection), `KvReader`

`k -> ObjectHandle` (key bound at construction; zero round-trips).

### *class* s3dol.BucketInfo(bucket, , connection=None, prefix='', delimiter='/', reads=None, writes=None, on_missing_bucket='assume', strict_delete=False)

Bases: [`BucketCollection`](_autosummary/s3dol.base.html.md#s3dol.base.BucketCollection), `KvReader`

`k -> ObjectInfo` (one `HeadObject`).

### *class* s3dol.BucketListedInfo(bucket, , connection=None, prefix='', delimiter='/', reads=None, writes=None, on_missing_bucket='assume', strict_delete=False)

Bases: [`BucketCollection`](_autosummary/s3dol.base.html.md#s3dol.base.BucketCollection), `KvReader`

`k -> ObjectInfo` from the listing rows, not one `HeadObject` per key.

The first access (a lookup or an iteration) pages through `ListObjectsV2`
once and keeps `{key: ObjectInfo}` (`size`, `last_modified`, `etag`,
`storage_class`; `content_type` and the other HEAD-only fields stay
`None`). It is **lazy and a snapshot**: later writes are not seen; make a
new `listed_info(store)` to refresh. A whole-bucket ETag comparison costs
one LIST per 1000 keys.

### *exception* s3dol.BucketNotEmpty

Bases: [`S3Error`](_autosummary/s3dol.errors.html.md#s3dol.errors.S3Error)

Refusal to delete a non-empty bucket. Use
`s3dol.delete_bucket(endpoint, name, force=True)` for the explicit
cascading form (ADR-0010 §3).

### *exception* s3dol.BucketNotFound

Bases: [`S3Error`](_autosummary/s3dol.errors.html.md#s3dol.errors.S3Error), `_InformativeKeyError`

The bucket is absent.

Still a `KeyError`: for an object operation it is a key-space problem for
the caller; for a bucket operation it is the key of the endpoint mapping.

### *class* s3dol.BucketReader(bucket, , connection=None, prefix='', delimiter='/', reads=None, writes=None, on_missing_bucket='assume', strict_delete=False)

Bases: [`BucketCollection`](_autosummary/s3dol.base.html.md#s3dol.base.BucketCollection), `KvReader`

+ `__getitem__` -> bytes (or the read strategy’s value type).

#### url_for(k, , expires_in=3600, client_method='get_object', \*\*params)

Presigned URL for `k` — **the one keyed method** (ADR-0011 D3b),
kept solely because `dol.SupportsUrlFor` requires a *method* and
`dol.content_url` reaches it by `getattr`. The canonical form is
`s3dol.urls(store)[k]`.

Guarded to be correct-or-loud, never silently wrong:

- **unwrapped store**: `k` is a key in this store’s own key space,
  so the URL addresses `self._id_of_key(k)`. Correct, and this is
  also the contract `dol.content_url` calls under — it resolves the
  key through the *outer* layers and stops at the layer owning
  `url_for`, “because that layer applies its own”
  (`dol/content.py`);
- **this leaf has ever been wrapped**: **raises**. Two call paths then
  reach this one signature with *different key domains* and nothing
  distinguishes them: `dol.content_url` hands over a key already
  mapped through the wrapper layers, while a direct
  `wrapped.url_for(k)` (delegation) hands over the raw outer key.
  Applying `_id_of_key` is right for the first and wrong for the
  second; re-resolving through the chain is right for the second and
  double-transforms the first. Since a wrong presigned URL addresses a
  *different real object*, the only honest answer is refusal, naming
  the sibling store — which is correct by construction because it goes
  through `__getitem__` (ADR-0011 D2/D3b, and see the note below);
- **anonymous connection**: returns `None` (`SupportsUrlFor` is
  `Optional[str]`; raising would turn a public-bucket streaming
  fallback into a 500 — ADR-0012 D5). The check reads the built
  client’s signature version, never `spec.anon`.

#### NOTE
This refusal is a *finding*, not a limitation we chose.
ADR-0011 D3b expected a guarded method to serve both paths; it
cannot, on a leaf that owns its prefix. Reported upstream on
dol#86/#83 as evidence that a keyed capability *method* is
unfixable in the general case, and that the sibling-store form is
the only one correct by construction.

* **Return type:**
  [`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]

### *class* s3dol.BucketStore(bucket, , connection=None, prefix='', delimiter='/', reads=None, writes=None, on_missing_bucket='assume', strict_delete=False)

Bases: [`BucketReader`](_autosummary/s3dol.base.html.md#s3dol.base.BucketReader), `KvPersister`

+ `__setitem__` / `__delitem__`. The user-facing read-write store.

#### pop(k) → v, remove specified key and return the corresponding value.

If key is not found, d is returned if given, otherwise KeyError is raised.

#### setdefault(k) → D.get(k,d), also set D[k]=d if k not in D

#### update(other=(), , \*\*kwargs)

If E present and has a .keys() method, does:     for k in E.keys(): D[k] = E[k]
If E present and lacks .keys() method, does:     for (k, v) in E: D[k] = v
In either case, this is followed by: for k, v in F.items(): D[k] = v

* **Return type:**
  [`None`](https://docs.python.org/3/builtins/constants.html#None)

### *class* s3dol.BucketUrls(\*args, expires_in=3600, client_method='get_object', \*\*kwargs)

Bases: [`BucketCollection`](_autosummary/s3dol.base.html.md#s3dol.base.BucketCollection), `KvReader`

`k -> presigned URL` (zero object requests; `None` when anonymous).
The canonical spelling of what `url_for` shims (ADR-0011 D3b).

### *class* s3dol.CallableCredentials(fetch)

Bases: [`CredentialProvider`](_autosummary/s3dol.connection.html.md#s3dol.connection.CredentialProvider)

A picklable zero-arg callable returning a mapping with keys
`access_key`/`secret_key` (aliases: `key`/`secret`), optional
`token`, optional `expires_at`/`expiry_time` (ISO 8601). With an
expiry, credentials are refreshable — the callable is re-invoked by
botocore’s refresh machinery (advisory 900 s / mandatory 600 s before
expiry).

#### provenance()

A label for diagnose() — never a credential value.

* **Return type:**
  [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)

### *class* s3dol.Capabilities(list_objects_v2=True, batch_delete=True, presigned_post=True, multipart=True, max_multipart_parts=10000, min_part_size=5242880, object_tagging=True, versioning=True, conditional_writes=True, consistency='strong')

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

What a backend supports. A *static declared table*, never a probe
(a probe costs a round-trip, is wrong under partial permissions, and can’t
be trusted anyway — ADR-0003 §2). Missing capabilities are handled
per-capability: emulate when exact (batch delete -> loop), substitute when
equivalent (ListObjectsV2 -> V1), raise `NotSupported` when there is no
honest fallback. Never silently degrade correctness.

### *class* s3dol.Chunks(chunks, consumed=list())

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

The value is the concatenation of an iterable of `bytes` chunks.
**One-shot** unless the iterable is re-iterable (a list is; a generator is
not — and a consumed generator writes `b''`, which is why assigning the
same one-shot ref twice is a documented error).

### *exception* s3dol.ConfigurationError

Bases: [`S3Error`](_autosummary/s3dol.errors.html.md#s3dol.errors.S3Error), [`ValueError`](https://docs.python.org/3/builtins/exceptions.html#ValueError)

A construction- or resolution-time misconfiguration (ADR-0012 D1).

### *exception* s3dol.CredentialsError

Bases: [`S3Error`](_autosummary/s3dol.errors.html.md#s3dol.errors.S3Error)

Credentials are missing, expired, or invalid.

### *class* s3dol.DailyByteBudget(limit_bytes, \*, ledger=None, today=<function DailyByteBudget.<lambda>>)

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

A per-day byte budget (one instance per tenant); call it to reserve.

`ledger` is any `MutableMapping[str, int]` (default: in-memory) keyed
by day, so persistence is a one-argument swap (a `dol` store, a file…).
`today` is the clock seam. Reservation is optimistic (the *maximum* the
form allows), and a form holds exactly one key, so re-posting cannot multiply
the budget on an unversioned bucket (on a versioned one each re-post stores a
new version: see the module docstring).

### *class* s3dol.EndpointCollection(connection=None, \*\*bucket_kwargs)

Bases: `_EndpointBase`, `Collection`

Bucket names at one endpoint.

### *class* s3dol.EndpointReader(connection=None, \*\*bucket_kwargs)

Bases: [`EndpointCollection`](_autosummary/s3dol.base.html.md#s3dol.base.EndpointCollection), `KvReader`

+ `__getitem__` -> [`BucketReader`](_autosummary/s3dol.html.md#s3dol.BucketReader).

### *class* s3dol.EndpointStore(connection=None, \*\*bucket_kwargs)

Bases: [`EndpointReader`](_autosummary/s3dol.base.html.md#s3dol.base.EndpointReader), `KvPersister`

+ bucket creation/deletion. `del endpoint[name]` refuses a non-empty
  bucket; the explicit cascading form is the free function
  `s3dol.delete_bucket(endpoint, name, force=True)` (ADR-0010 §3 as
  amended by ADR-0011 D4 — a public keyed destructive *method* is the shape
  the family census found destroying wrong data).

### *class* s3dol.Filepath(path)

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

The value *is the content of this file*. Re-readable (N1-total).

### *exception* s3dol.KeyNotValid

Bases: [`S3Error`](_autosummary/s3dol.errors.html.md#s3dol.errors.S3Error), `_InformativeKeyError`, [`ValueError`](https://docs.python.org/3/builtins/exceptions.html#ValueError)

The key is syntactically invalid (checked before the wire).

Inherits from both `KeyError` and `ValueError` deliberately, so either
`except` works. Named `KeyNotValid` (not `KeyValidationError`) because
dol already ships two *different* classes called `KeyValidationError`
(ADR-0004 §5).

### *exception* s3dol.NotSupported

Bases: [`S3Error`](_autosummary/s3dol.errors.html.md#s3dol.errors.S3Error)

The operation is not supported by this provider (names both).

### *exception* s3dol.ObjectArchived(message, , storage_class=None, restore_status=None, restore=None)

Bases: [`S3Error`](_autosummary/s3dol.errors.html.md#s3dol.errors.S3Error), `_InformativeKeyError`

The object exists but is archived (e.g. Glacier) and cannot be read now.

A `KeyError`, deliberately and arguably (ADR-0004 §4): `k in store`
stays `True`, but `store[k]` fails as a `KeyError` so that
`store.get(k, default)` degrades to the not-available branch. Note that
only the *defaulted accessors* degrade — `dict(store)`, `.items()` and
`Mapping.__eq__` still raise. `setdefault`/`pop` are overridden in the
store to re-raise this instead of silently overwriting the archived object.

#### restore(days=1, , tier='Standard')

Request restoration of the archived object (if a handle was bound).

### *class* s3dol.ObjectHandle(bucket, key, , connection=None)

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

One object, key bound **at construction** — which is what makes it
immune to the delegation trap (a key codec over the store cannot corrupt a
key that was resolved before the handle existed; ADR-0011 D1, following
`azuredol.BlobHandle`). This is where ranged reads, streaming,
download-to-disk, metadata and presigned URLs live.

#### download_to(path)

Download to disk (never fully in memory). Accepts a path or
[`Filepath`](_autosummary/s3dol.values.html.md#s3dol.values.Filepath); returns the path written.

* **Return type:**
  [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)

#### info()

One `HeadObject` -> [`ObjectInfo`](_autosummary/s3dol.html.md#s3dol.ObjectInfo).

* **Return type:**
  [`ObjectInfo`](_autosummary/s3dol.base.html.md#s3dol.base.ObjectInfo)

#### read(, offset=None, length=None)

The object’s bytes; a ranged read when `offset`/`length` given.

* **Return type:**
  [`bytes`](https://docs.python.org/3/builtins/stdtypes.html#bytes)

#### restore(days=1, , tier='Standard')

Request restoration of an archived (Glacier) object.

* **Return type:**
  [`None`](https://docs.python.org/3/builtins/constants.html#None)

#### stream(, chunk_size=8388608)

Lazy chunk iterator over the body.

* **Return type:**
  [`Iterator`](https://docs.python.org/3/library/typing.html#typing.Iterator)[[`bytes`](https://docs.python.org/3/builtins/stdtypes.html#bytes)]

#### url(, expires_in=3600, client_method='get_object', \*\*params)

Presigned URL. Always SigV4; `None` when anonymous; capped at
SigV4’s 604800 s; warns when the signing credential expires sooner
(the URL cannot outlive it).

* **Return type:**
  [`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]

#### write(value)

Write the object (same value domain as `store[k] = v`).

* **Return type:**
  [`None`](https://docs.python.org/3/builtins/constants.html#None)

### *class* s3dol.ObjectInfo(key, size=None, last_modified=None, etag=None, content_type=None, storage_class=None, restore_status=None, version_id=None)

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

Object metadata — from `HeadObject` or from a LIST row (which already
carries size/mtime/etag/storage class that v0 threw away; ADR-0009).

### *exception* s3dol.ObjectNotFound

Bases: [`S3Error`](_autosummary/s3dol.errors.html.md#s3dol.errors.S3Error), `_InformativeKeyError`

The object is absent. The Mapping contract’s `KeyError`.

### *class* s3dol.Preset(name, addressing_style, endpoint_url=None, region_name=None, checksum=None, payload_signing_enabled=None, capabilities=Capabilities(list_objects_v2=True, batch_delete=True, presigned_post=True, multipart=True, max_multipart_parts=10000, min_part_size=5242880, object_tagging=True, versioning=True, conditional_writes=True, consistency='strong'), presign_endpoint_url=None, presign_addressing_style=None, params=(), host_patterns=(), requires_endpoint=False, soft=False, config_kwargs=(), error_overrides=(), verified=False)

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

One provider’s facts. Public, shareable, committable config — which is
why there is **no credential slot**, structurally (ADR-0012 D4).

`endpoint_url`/`region_name` may contain `{placeholders}`; bind them
with [`bind()`](_autosummary/s3dol.html.md#s3dol.Preset.bind). A row whose endpoint template has an unbound *required*
placeholder contributes no endpoint rung (ADR-0012 C1).

#### addressing_style *: [Literal](https://docs.python.org/3/library/typing.html#typing.Literal)['path', 'virtual']*

Mandatory; no default; `'auto'` is illegal (ADR-0012 D4).

#### bind(\*\*params)

A copy of this row with template `params` bound.

```pycon
>>> r2 = get_preset('r2').bind(account_id='abc123')
>>> r2.bound_endpoint()
'https://abc123.r2.cloudflarestorage.com'
```

* **Return type:**
  [`Preset`](_autosummary/s3dol.presets.html.md#s3dol.presets.Preset)

#### bound_endpoint(, region_name=None)

The endpoint URL with params bound, or `None` if the template has
unbound placeholders (C1: an unbound row contributes no rung —
`preset='minio'` silently becoming AWS is structurally impossible).

`region_name` binds a `{region_name}` placeholder, per the region
ladder’s first rung (ADR-0012 D3).

* **Return type:**
  [`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]

#### checksum *: [Optional](https://docs.python.org/3/library/typing.html#typing.Optional)[[Literal](https://docs.python.org/3/library/typing.html#typing.Literal)['when_supported', 'when_required']]* *= None*

`None` == the row makes no claim (the ladder continues — ADR-0012 D3).

#### config_kwargs *: [tuple](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[tuple](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[str](https://docs.python.org/3/builtins/stdtypes.html#str), [Any](https://docs.python.org/3/library/typing.html#typing.Any)], ...]* *= ()*

Extra `botocore.Config` kwargs — allowlisted, scalars only.

#### error_overrides *: [tuple](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[tuple](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[tuple](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[Optional](https://docs.python.org/3/library/typing.html#typing.Optional)[[str](https://docs.python.org/3/builtins/stdtypes.html#str)], [Optional](https://docs.python.org/3/library/typing.html#typing.Optional)[[str](https://docs.python.org/3/builtins/stdtypes.html#str)], [Optional](https://docs.python.org/3/library/typing.html#typing.Optional)[[int](https://docs.python.org/3/builtins/functions.html#int)]], [str](https://docs.python.org/3/builtins/stdtypes.html#str)], ...]* *= ()*

Error-classification overrides, consulted before the default table
(ADR-0004 §2/§6): rows of `((operation, code, status), kind)`.

#### host_patterns *: [tuple](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[str](https://docs.python.org/3/builtins/stdtypes.html#str), ...]* *= ()*

`fnmatch` patterns over the endpoint *hostname*; used for detection
(pass 2) and the C2 named-vs-resolved guard.

#### matches_host(endpoint_url)

Whether `endpoint_url`’s hostname matches this row’s patterns.

* **Return type:**
  [`bool`](https://docs.python.org/3/builtins/functions.html#bool)

#### missing_endpoint_params(, region_name=None)

Which placeholders keep [`bound_endpoint()`](_autosummary/s3dol.html.md#s3dol.Preset.bound_endpoint) from producing a URL.

* **Return type:**
  [`set`](https://docs.python.org/3/builtins/stdtypes.html#set)

#### params *: [tuple](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[tuple](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[str](https://docs.python.org/3/builtins/stdtypes.html#str), [str](https://docs.python.org/3/builtins/stdtypes.html#str)], ...]* *= ()*

Bound template parameters, e.g. `(('account_id', 'abc'),)`.

#### *property* pinned *: [bool](https://docs.python.org/3/builtins/functions.html#bool)*

Whether the row’s region literal is authoritative enough to make a
conflicting explicit `region_name=` raise `PresetConflict`.
Derived, and gated on `verified` — dormant while rows are
doc-sourced (ADR-0012 D4).

#### presign_endpoint_url *: [Optional](https://docs.python.org/3/library/typing.html#typing.Optional)[[str](https://docs.python.org/3/builtins/stdtypes.html#str)]* *= None*

Presigning sometimes genuinely differs from the API config (Hetzner
presigns virtual while the API is path; R2 presigns only on the S3 API
domain) — ADR-0003 §1.

#### requires_endpoint *: [bool](https://docs.python.org/3/builtins/functions.html#bool)* *= False*

The provider cannot be reached without an explicit endpoint.

#### soft *: [bool](https://docs.python.org/3/builtins/functions.html#bool)* *= False*

they
never win detection over a non-soft row and never trigger the C2 guard.

* **Type:**
  Soft rows are last-resort fallbacks (`aws`, `generic-s3`)

#### template_params()

All placeholder names across this row’s templates.

* **Return type:**
  [`set`](https://docs.python.org/3/builtins/stdtypes.html#set)

#### verified *: [bool](https://docs.python.org/3/builtins/functions.html#bool)* *= False*

`True` only when the row was verified against a live endpoint (with a
date in the row’s docstring/comment). Builtin rows are doc-sourced.

### *class* s3dol.ProfileCredentials(profile)

Bases: [`CredentialProvider`](_autosummary/s3dol.connection.html.md#s3dol.connection.CredentialProvider)

Credentials from a named profile — *credentials only*; the profile’s
other config is not selected by this (that is what `profile=` on the
connection is for). Rebuilds live, still-refreshable credentials after
unpickling (a frozen dataclass holding only a profile name round-trips).

#### provenance()

A label for diagnose() — never a credential value.

* **Return type:**
  [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)

### *class* s3dol.Resolution(endpoint_url, region_name, signature_version, addressing_style, checksum, payload_signing_enabled, verify, preset, preset_source, credential_provenance, capabilities, environ_consulted, notes)

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

The result of [`resolve()`](_autosummary/s3dol.html.md#s3dol.resolve) — everything `diagnose()` prints and
everything client-build consumes. Carries provenance labels, never a
credential value.

#### environ_consulted *: [tuple](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[tuple](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[str](https://docs.python.org/3/builtins/stdtypes.html#str), [Optional](https://docs.python.org/3/library/typing.html#typing.Optional)[[str](https://docs.python.org/3/builtins/stdtypes.html#str)]], ...]*

The non-secret environment keys consulted, with their values.

#### notes *: [tuple](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[tuple](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[type](https://docs.python.org/3/builtins/functions.html#type), [str](https://docs.python.org/3/builtins/stdtypes.html#str)], ...]*

Collected (warning class, message) pairs. resolve() never emits them —
the impure caller decides (client build warns; diagnose prints rows).

### *class* s3dol.S3Connection(preset=None, endpoint_url=None, region_name=None, profile=None, credentials=None, anon=False, signature_version='s3v4', addressing_style=None, checksum=None, payload_signing_enabled=None, verify=None, client_kwargs=(), deny_means_absent=False)

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

A frozen, picklable connection spec. No live objects — ever.

Construction performs no I/O and does not import boto3 (ADR-0002); the
client is built lazily, once, under a per-instance lock (CPython ≥3.12
removed `cached_property`’s lock deliberately — measured: 8 racing
threads → 8 clients without one).

`__post_init__` is the only door: every normalisation and contradiction
check happens here, so a bad shape dies at construction with a message,
not later inside botocore.

```pycon
>>> S3Connection(anon=True, profile='prod')
Traceback (most recent call last):
...
s3dol.errors.ConfigurationError: ...
```

#### *property* client

The boto3 S3 client — built lazily, once, under the lock.

#### *property* presign_client

The client presigned URLs are generated with.

For most providers this is [`client`](_autosummary/s3dol.html.md#s3dol.S3Connection.client). Two providers genuinely
need different config for presigning than for the API (ADR-0003 §1):
Hetzner presigns virtual-hosted while the API is path-style; R2
presigns only on the S3 API domain. When the resolved preset carries
`presign_endpoint_url`/`presign_addressing_style`, a second client
is built (lazily, once, under the same lock) from the merged config.

#### resolution(environ=None, aws_config=<function load_aws_config>)

Resolve against the real environment by default (a thin impure
wrapper over the pure [`resolve()`](_autosummary/s3dol.html.md#s3dol.resolve)).

* **Return type:**
  [`Resolution`](_autosummary/s3dol.connection.html.md#s3dol.connection.Resolution)

### s3dol.S3Dol

alias of [`S3Profiles`](_autosummary/s3dol.base.html.md#s3dol.base.S3Profiles)

### *exception* s3dol.S3DolWarning

Bases: [`UserWarning`](https://docs.python.org/3/builtins/exceptions.html#UserWarning)

Base of every s3dol warning.

### *exception* s3dol.S3Error

Bases: [`Exception`](https://docs.python.org/3/builtins/exceptions.html#Exception)

Base of every s3dol exception — `except S3Error` catches the package.

### s3dol.S3Jsons

alias of [`BucketStore`](_autosummary/s3dol.base.html.md#s3dol.base.BucketStore)

### *exception* s3dol.S3PartialFailure(message, , succeeded, failures)

Bases: [`S3Error`](_autosummary/s3dol.errors.html.md#s3dol.errors.S3Error)

A bulk operation partially failed (ADR-0010 §2).

Not an `ExceptionGroup` — the package supports Python 3.10.

#### succeeded

keys the backend reported as deleted (absent keys are
reported as deleted too — S3’s semantics, documented, not hidden).

#### failures

mapping of key -> the error for that key.

### s3dol.S3Pickles

alias of [`BucketStore`](_autosummary/s3dol.base.html.md#s3dol.base.BucketStore)

### *class* s3dol.S3Profiles(, bucket_kwargs=None, readonly=False)

Bases: `KvReader`

AWS **profile** names -> endpoint stores (the v0 `S3Dol`, renamed —
its keys are verifiably profile names, never endpoints; ADR-0007 §1).

```pycon
>>> # S3Profiles()['prod']  ->  EndpointStore over the 'prod' profile
```

### s3dol.S3Store(bucket_name, , make_bucket=None, path=None, aws_access_key_id=None, aws_secret_access_key=None, aws_session_token=None, endpoint_url=None, region_name=None, profile_name=None, skip_bucket_check=None, is_supabase_endpoint=None)

DEPRECATED — the v0 entry point, kept working until v2.

Use [`s3dol.s3_store()`](_autosummary/s3dol.html.md#s3dol.s3_store) instead: `s3_store(bucket, prefix=...)`.

Signature is v0’s exactly (`path=` not renamed; `make_bucket`
tri-state maps `True -> on_missing_bucket='create'`, `False ->
'raise'`, `None -> 'assume'`). Behaviour differences vs v0 are bug
fixes only (explicit endpoint/credentials honoured; listing errors raise
instead of returning `[]`; writes no longer create buckets unless asked)
and announce themselves via `S3DolResolutionChanged` when they change
this call’s resolution.

* **Return type:**
  [`MutableMapping`](https://docs.python.org/3/library/typing.html#typing.MutableMapping)

### s3dol.S3Texts

alias of [`BucketStore`](_autosummary/s3dol.base.html.md#s3dol.base.BucketStore)

### *class* s3dol.StaticCredentials(access_key, secret_key, token=None)

Bases: [`CredentialProvider`](_autosummary/s3dol.connection.html.md#s3dol.connection.CredentialProvider)

An explicit key pair (optionally a session token).

#### NOTE
a *static* token expires and cannot refresh — prefer `profile=` or
a callable provider for STS/SSO. Pickling this object carries the secret
(that is what “explicit credentials” means); its repr does not.

#### provenance()

A label for diagnose() — never a credential value.

* **Return type:**
  [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)

### *class* s3dol.Streamable(open_stream)

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

The value is whatever a zero-arg factory’s stream yields — for sources
that must be (re)opened at write time, e.g. an HTTP download. The factory
is called once per write, so unlike [`Chunks`](_autosummary/s3dol.html.md#s3dol.Chunks) this ref IS safely
re-writable (each write gets a fresh stream).

### *exception* s3dol.UploadBudgetExceeded

Bases: [`S3Error`](_autosummary/s3dol.errors.html.md#s3dol.errors.S3Error)

The tenant’s byte budget cannot cover this upload; no form was signed.

### s3dol.delete_bucket(endpoint, name, , force=False)

Delete bucket `name`. Refuses a non-empty bucket unless
`force=True`, in which case the cascade **paginates** — v0 listed one
page, deleted ≤1000 objects, then failed: a partial, non-idempotent
destruction (ADR-0010 §3). A free function, not a method (ADR-0011 D4).

* **Return type:**
  [`None`](https://docs.python.org/3/builtins/constants.html#None)

### s3dol.delete_many(store, keys)

Bulk delete (ADR-0010 §2; a free function per ADR-0011 D4 — keyed +
destructive + delegated is the census’s data-destroying shape).

Chunks at 1000 (AWS’s cap), parses the `Errors` list out of the HTTP
200 response, and on partial failure raises one [`S3PartialFailure`](_autosummary/s3dol.html.md#s3dol.S3PartialFailure)
carrying `.succeeded` and `.failures`. Absent keys are reported by S3
as `Deleted` — this function does **not** distinguish them (same
idempotency as `del store[k]`).

Keys are the *caller’s* keys: with the store held as an argument the
chain is resolved via `dol.inner_most_key` (alive store — no weakref
hole). Validate-the-target caveat (D4): the first argument must be an
s3dol store or a dol wrapper over one.

* **Return type:**
  [`None`](https://docs.python.org/3/builtins/constants.html#None)

### s3dol.diagnose(connection=None, , environ=None, aws_config=None, file=None, \*\*kwargs)

Print (and return) the resolution report. Never raises.

Call it either with a ready [`S3Connection`](_autosummary/s3dol.connection.html.md#s3dol.connection.S3Connection), with
`S3Connection` kwargs, or — the migration case — with exactly the kwargs
you pass `s3dol.store.S3Store` today (`bucket_name=`, `path=`,
`profile_name=`, …), which additionally prints the v0-vs-v1
divergence table.

```pycon
>>> report = diagnose(endpoint_url='http://localhost:9000',
...                   environ={}, file=io.StringIO())
>>> 'endpoint_url' in report and 'resolution' in report.lower()
True
```

* **Return type:**
  [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)

### s3dol.handles(store)

The sibling store of [`ObjectHandle`](_autosummary/s3dol.html.md#s3dol.ObjectHandle)s: `handles(s)[k]`.

* **Return type:**
  [`BucketHandles`](_autosummary/s3dol.capabilities.html.md#s3dol.capabilities.BucketHandles)

### s3dol.info(store)

The sibling store of [`ObjectInfo`](_autosummary/s3dol.html.md#s3dol.ObjectInfo): `info(s)[k]`.

* **Return type:**
  [`BucketInfo`](_autosummary/s3dol.capabilities.html.md#s3dol.capabilities.BucketInfo)

### s3dol.listed_info(store)

The sibling store of [`ObjectInfo`](_autosummary/s3dol.html.md#s3dol.ObjectInfo) built from one paginated LIST:
`listed_info(s)[k]` (a lazy snapshot; see [`BucketListedInfo`](_autosummary/s3dol.html.md#s3dol.BucketListedInfo)).

* **Return type:**
  [`BucketListedInfo`](_autosummary/s3dol.capabilities.html.md#s3dol.capabilities.BucketListedInfo)

### s3dol.prefixes(store)

The ‘directories’ one level under the store’s scope, \*\*relative to the
caller’s key space\*\* — one `ListObjectsV2(Delimiter='/')` reading
`CommonPrefixes` (which v0 parsed and then called from nowhere;
ADR-0009). Through a dol wrapper chain, the listing is rooted at the
caller’s scope (each prefix layer’s contribution) and results are mapped
back **outward** (`_key_of_id` per layer, innermost first — the inverse
walk `dol` does not provide; ADR-0011 D3). A wrapper whose codec cannot
express the scope raises — loud, not wrong.

* **Return type:**
  [`list`](https://docs.python.org/3/builtins/stdtypes.html#list)

### s3dol.presigned_upload(store, , key_prefix, max_bytes, content_type, min_bytes=0, expires_in=900, budget=None, on_versioned_bucket='warn')

A presigned POST form for ONE new object under `key_prefix`.

`content_type` is required: pass the one type to accept, or `None` to
explicitly accept any (then a holder can store `text/html`: do not serve
such objects from a trusted origin).

`key_prefix` must end with the store’s delimiter (`tenant-7/` cannot
match `tenant-77/`) and is in the *store’s* key space (the store’s own
prefix is prepended, like every other s3dol key). The object key is
server-generated (`PresignedUpload.key`). Returns `None` for an
anonymous store (no signing capability, as [`s3dol.urls()`](_autosummary/s3dol.html.md#s3dol.urls) does).

When `budget` is given, the bucket’s versioning status is read first (one
`GetBucketVersioning` call): with versioning enabled a re-posted form
stores a new version each time, so `on_versioned_bucket` decides:
`'warn'` (default) emits `VersionedBucketWarning`, `'raise'`
refuses with [`ConfigurationError`](_autosummary/s3dol.html.md#s3dol.ConfigurationError), `'ignore'` skips the call.

Raises [`ConfigurationError`](_autosummary/s3dol.html.md#s3dol.ConfigurationError) for a bad prefix, size range,
`expires_in` or `on_versioned_bucket`, and [`UploadBudgetExceeded`](_autosummary/s3dol.html.md#s3dol.UploadBudgetExceeded)
if `budget` refuses.

* **Return type:**
  [`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`PresignedUpload`](_autosummary/s3dol.uploads.html.md#s3dol.uploads.PresignedUpload)]

### s3dol.register_preset(preset, , overwrite=False)

Add a row. Open-closed: adding a provider is adding a row.

* **Return type:**
  [`None`](https://docs.python.org/3/builtins/constants.html#None)

### s3dol.resolve(spec, environ, aws_config=None)

Pure resolution: no `os.environ`, no disk, no network (ADR-0012 D2).

`environ` is a plain mapping (pass `os.environ` at real call sites,
a dict in tests). `aws_config` is a pre-loaded, credential-scrubbed
config mapping, or a thunk for one (`load_aws_config()`) — called only
if a rung needs it.

* **Return type:**
  [`Resolution`](_autosummary/s3dol.connection.html.md#s3dol.connection.Resolution)

### s3dol.s3_store(bucket, , prefix='', preset=None, connection=None, endpoint_url=None, region_name=None, profile=None, credentials=None, anon=False, on_missing_bucket='assume', readonly=False, value_codec=None, reads=None, writes=None)

One bucket as a `MutableMapping[str, bytes]` (a `Mapping` when
`readonly=True`).

Annotated (deliberately) as the abstract Mapping, **not** `-> BucketStore`:
with `value_codec` the concrete type is a generated `dol` wrapper class
that is *not* a `BucketStore` subclass. (v0 annotated its factory
`-> Store` and returned something that was not one; inverting that lie
is not an improvement — architecture.md.)

Connection axes (`preset`/`endpoint_url`/`region_name`/`profile`/
`credentials`/`anon`) are conveniences that build an
[`S3Connection`](_autosummary/s3dol.connection.html.md#s3dol.connection.S3Connection); pass `connection=` instead for
full control (they are mutually exclusive with it).

### s3dol.sub(store, prefix)

A store scoped to `prefix`, **in the caller’s key space** (D3).

Two branches, deliberately different (each documented in the ADR):

- **unwrapped s3dol store**: `leaf._with(prefix=...)` — cheap, keeps
  server-side prefix pushdown, returns the same class;
- **dol-wrapped store**: composes `Pipe(filt_iter.prefixes(p),
  KeyCodecs.prefixed(p))` over the *outer* store (filter FIRST — the only
  safe composition, ADR-0006 §1), which preserves the user’s codecs but
  loses pushdown (a full scan filtered client-side; D8 closed this: the
  cheap path is the unwrapped branch) and returns a different type.

### s3dol.urls(store, , expires_in=3600, client_method='get_object')

The sibling store of presigned URLs: `urls(s)[k]`.

* **Return type:**
  [`BucketUrls`](_autosummary/s3dol.capabilities.html.md#s3dol.capabilities.BucketUrls)

### Modules

| [`base`](_autosummary/s3dol.base.html.md#module-s3dol.base)                 | Layer B — close-to-metal stores over one bucket or one endpoint.                                                                                                                                          |
|-----------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [`capabilities`](_autosummary/s3dol.capabilities.html.md#module-s3dol.capabilities) | Keyed capabilities as sibling stores; non-keyed operations as free functions (ADR-0011 D2/D3/D4).                                                                                                         |
| [`connection`](_autosummary/s3dol.connection.html.md#module-s3dol.connection)     | `S3Connection` — the credential + endpoint SSOT, and the pure resolver.                                                                                                                                   |
| [`errors`](_autosummary/s3dol.errors.html.md#module-s3dol.errors)             | The s3dol error taxonomy and the single error-translation seam.                                                                                                                                           |
| [`presets`](_autosummary/s3dol.presets.html.md#module-s3dol.presets)           | Provider presets: config rows, not subclasses.                                                                                                                                                            |
| [`reads`](_autosummary/s3dol.reads.html.md#module-s3dol.reads)               | Read strategies (ADR-0005 §6): what `s[k]` returns.                                                                                                                                                       |
| [`recipes`](_autosummary/s3dol.recipes.html.md#module-s3dol.recipes)           | Layer C — the one-liner factory and codec facades.                                                                                                                                                        |
| [`store`](_autosummary/s3dol.store.html.md#module-s3dol.store)               | COMPAT SHIM — the v0 `S3Store`, forwarded onto the v1 machinery.                                                                                                                                          |
| [`testing`](_autosummary/s3dol.testing.html.md#module-s3dol.testing)           | `s3dol.testing` — a shipped in-memory fake and the exported conformance suite (ADR-0008). Downstream users can test services that take a store as a dependency with **no network, no docker, no moto**::. |
| [`uploads`](_autosummary/s3dol.uploads.html.md#module-s3dol.uploads)           | Direct-to-S3 browser uploads: a presigned POST scoped to a key prefix.                                                                                                                                    |
| [`values`](_autosummary/s3dol.values.html.md#module-s3dol.values)             | Value refs and the write domain (ADR-0005).                                                                                                                                                               |
| [`writes`](_autosummary/s3dol.writes.html.md#module-s3dol.writes)             | Write strategies (ADR-0005 §5): how `s[k] = v` reaches the wire.                                                                                                                                          |


# _autosummary/s3dol.presets.html.md

# s3dol.presets

Provider presets: config rows, not subclasses.

Design record: `misc/docs/decisions/0003-provider-presets-and-capabilities.md`
(the survey of 16 backends, the checksum analysis, capabilities policy) amended
by `misc/docs/decisions/0012-credential-and-endpoint-resolution.md` §D4
(`params`/`host_patterns`/`requires_endpoint`/`soft`/`config_kwargs`,
derived `pinned`; `signature_version` and `client_kwargs` moved to the
connection; `addressing_style` mandatory with `'auto'` illegal; the
structural no-credential rule).

A provider divergence is a row in this registry — never a subclass, never an
endpoint-substring branch in the hot path. Users register their own rows:

```pycon
>>> row = Preset(name='mycorp', addressing_style='path',
...              endpoint_url='https://s3.mycorp.example', requires_endpoint=False)
>>> register(row)
>>> get_preset('mycorp').endpoint_url
'https://s3.mycorp.example'
>>> unregister('mycorp')  # (cleanup for this doctest)
```

Most builtin rows are **doc-sourced, not verified against a live endpoint** —
they say so via `verified=False`. Wrong values mostly fail loudly, which is
the acceptable failure mode; `pinned` (which makes a row’s region literal
conflict-raising) is derived and *gated on* `verified`, so it is dormant
until a row earns evidence (ADR-0012 D4).

### Module Attributes

| [`CONFIG_KWARGS_ALLOWLIST`](_autosummary/s3dol.presets.html.md#s3dol.presets.CONFIG_KWARGS_ALLOWLIST)   | `Config`-constructor kwargs a preset row may carry.   |
|----------------------------------------------------------------------------|-------------------------------------------------------|

### Functions

| `available_presets`()                                                                       |                                                                                                                                                                                                                                                                      |
|---------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [`detect_preset`](_autosummary/s3dol.presets.html.md#s3dol.presets.detect_preset)(endpoint_url)                | Detection (resolution pass 2): the non-soft row whose `host_patterns` match the resolved endpoint's host.                                                                                                                                                            |
| [`get_preset`](_autosummary/s3dol.presets.html.md#s3dol.presets.get_preset)(name)                           | Look a row up by name; unknown names raise, naming the registry.                                                                                                                                                                                                     |
| [`register`](_autosummary/s3dol.presets.html.md#s3dol.presets.register)(preset, \*[, overwrite])          | Add a row.                                                                                                                                                                                                                                                           |
| [`unregister`](_autosummary/s3dol.presets.html.md#s3dol.presets.unregister)(name)                           | Remove a row (mostly for tests).                                                                                                                                                                                                                                     |
| [`validate_endpoint_hygiene`](_autosummary/s3dol.presets.html.md#s3dol.presets.validate_endpoint_hygiene)(url, \*[, what]) | Refuse credential-carrying URL shapes: userinfo in the netloc, a query string, or a fragment (ADR-0012 D4 — a query-string endpoint is accepted by botocore and retained verbatim in `client.meta.endpoint_url`, so it would leak into `diagnose()` and tracebacks). |

### Classes

| [`Capabilities`](_autosummary/s3dol.presets.html.md#s3dol.presets.Capabilities)([list_objects_v2, ...])   | What a backend supports.   |
|-----------------------------------------------------------------------------------------|----------------------------|
| [`Preset`](_autosummary/s3dol.presets.html.md#s3dol.presets.Preset)(name, addressing_style[, ...])  | One provider's facts.      |

### s3dol.presets.CONFIG_KWARGS_ALLOWLIST *= frozenset({'connect_timeout', 'max_pool_connections', 'read_timeout', 'tcp_keepalive'})*

`Config`-constructor kwargs a preset row may carry. Scalars only, and
`proxies`/`proxies_config`/`client_context_params` are structurally
excluded — a preset must not be able to smuggle a credential-bearing proxy
URL (ADR-0012 D4).

### *class* s3dol.presets.Capabilities(list_objects_v2=True, batch_delete=True, presigned_post=True, multipart=True, max_multipart_parts=10000, min_part_size=5242880, object_tagging=True, versioning=True, conditional_writes=True, consistency='strong')

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

What a backend supports. A *static declared table*, never a probe
(a probe costs a round-trip, is wrong under partial permissions, and can’t
be trusted anyway — ADR-0003 §2). Missing capabilities are handled
per-capability: emulate when exact (batch delete -> loop), substitute when
equivalent (ListObjectsV2 -> V1), raise `NotSupported` when there is no
honest fallback. Never silently degrade correctness.

### *class* s3dol.presets.Preset(name, addressing_style, endpoint_url=None, region_name=None, checksum=None, payload_signing_enabled=None, capabilities=Capabilities(list_objects_v2=True, batch_delete=True, presigned_post=True, multipart=True, max_multipart_parts=10000, min_part_size=5242880, object_tagging=True, versioning=True, conditional_writes=True, consistency='strong'), presign_endpoint_url=None, presign_addressing_style=None, params=(), host_patterns=(), requires_endpoint=False, soft=False, config_kwargs=(), error_overrides=(), verified=False)

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

One provider’s facts. Public, shareable, committable config — which is
why there is **no credential slot**, structurally (ADR-0012 D4).

`endpoint_url`/`region_name` may contain `{placeholders}`; bind them
with [`bind()`](_autosummary/s3dol.presets.html.md#s3dol.presets.Preset.bind). A row whose endpoint template has an unbound *required*
placeholder contributes no endpoint rung (ADR-0012 C1).

#### addressing_style *: [Literal](https://docs.python.org/3/library/typing.html#typing.Literal)['path', 'virtual']*

Mandatory; no default; `'auto'` is illegal (ADR-0012 D4).

#### bind(\*\*params)

A copy of this row with template `params` bound.

```pycon
>>> r2 = get_preset('r2').bind(account_id='abc123')
>>> r2.bound_endpoint()
'https://abc123.r2.cloudflarestorage.com'
```

* **Return type:**
  [`Preset`](_autosummary/s3dol.presets.html.md#s3dol.presets.Preset)

#### bound_endpoint(, region_name=None)

The endpoint URL with params bound, or `None` if the template has
unbound placeholders (C1: an unbound row contributes no rung —
`preset='minio'` silently becoming AWS is structurally impossible).

`region_name` binds a `{region_name}` placeholder, per the region
ladder’s first rung (ADR-0012 D3).

* **Return type:**
  [`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]

#### checksum *: [Optional](https://docs.python.org/3/library/typing.html#typing.Optional)[[Literal](https://docs.python.org/3/library/typing.html#typing.Literal)['when_supported', 'when_required']]* *= None*

`None` == the row makes no claim (the ladder continues — ADR-0012 D3).

#### config_kwargs *: [tuple](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[tuple](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[str](https://docs.python.org/3/builtins/stdtypes.html#str), [Any](https://docs.python.org/3/library/typing.html#typing.Any)], ...]* *= ()*

Extra `botocore.Config` kwargs — allowlisted, scalars only.

#### error_overrides *: [tuple](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[tuple](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[tuple](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[Optional](https://docs.python.org/3/library/typing.html#typing.Optional)[[str](https://docs.python.org/3/builtins/stdtypes.html#str)], [Optional](https://docs.python.org/3/library/typing.html#typing.Optional)[[str](https://docs.python.org/3/builtins/stdtypes.html#str)], [Optional](https://docs.python.org/3/library/typing.html#typing.Optional)[[int](https://docs.python.org/3/builtins/functions.html#int)]], [str](https://docs.python.org/3/builtins/stdtypes.html#str)], ...]* *= ()*

Error-classification overrides, consulted before the default table
(ADR-0004 §2/§6): rows of `((operation, code, status), kind)`.

#### host_patterns *: [tuple](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[str](https://docs.python.org/3/builtins/stdtypes.html#str), ...]* *= ()*

`fnmatch` patterns over the endpoint *hostname*; used for detection
(pass 2) and the C2 named-vs-resolved guard.

#### matches_host(endpoint_url)

Whether `endpoint_url`’s hostname matches this row’s patterns.

* **Return type:**
  [`bool`](https://docs.python.org/3/builtins/functions.html#bool)

#### missing_endpoint_params(, region_name=None)

Which placeholders keep [`bound_endpoint()`](_autosummary/s3dol.presets.html.md#s3dol.presets.Preset.bound_endpoint) from producing a URL.

* **Return type:**
  [`set`](https://docs.python.org/3/builtins/stdtypes.html#set)

#### params *: [tuple](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[tuple](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[str](https://docs.python.org/3/builtins/stdtypes.html#str), [str](https://docs.python.org/3/builtins/stdtypes.html#str)], ...]* *= ()*

Bound template parameters, e.g. `(('account_id', 'abc'),)`.

#### *property* pinned *: [bool](https://docs.python.org/3/builtins/functions.html#bool)*

Whether the row’s region literal is authoritative enough to make a
conflicting explicit `region_name=` raise `PresetConflict`.
Derived, and gated on `verified` — dormant while rows are
doc-sourced (ADR-0012 D4).

#### presign_endpoint_url *: [Optional](https://docs.python.org/3/library/typing.html#typing.Optional)[[str](https://docs.python.org/3/builtins/stdtypes.html#str)]* *= None*

Presigning sometimes genuinely differs from the API config (Hetzner
presigns virtual while the API is path; R2 presigns only on the S3 API
domain) — ADR-0003 §1.

#### requires_endpoint *: [bool](https://docs.python.org/3/builtins/functions.html#bool)* *= False*

The provider cannot be reached without an explicit endpoint.

#### soft *: [bool](https://docs.python.org/3/builtins/functions.html#bool)* *= False*

they
never win detection over a non-soft row and never trigger the C2 guard.

* **Type:**
  Soft rows are last-resort fallbacks (`aws`, `generic-s3`)

#### template_params()

All placeholder names across this row’s templates.

* **Return type:**
  [`set`](https://docs.python.org/3/builtins/stdtypes.html#set)

#### verified *: [bool](https://docs.python.org/3/builtins/functions.html#bool)* *= False*

`True` only when the row was verified against a live endpoint (with a
date in the row’s docstring/comment). Builtin rows are doc-sourced.

### s3dol.presets.detect_preset(endpoint_url)

Detection (resolution pass 2): the non-soft row whose `host_patterns`
match the resolved endpoint’s host. Two matching rows is genuinely
ambiguous and raises; zero yields `None` (the caller falls back to
`generic-s3`/`aws` — ADR-0012 D4).

* **Return type:**
  [`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`Preset`](_autosummary/s3dol.presets.html.md#s3dol.presets.Preset)]

### s3dol.presets.get_preset(name)

Look a row up by name; unknown names raise, naming the registry.

* **Return type:**
  [`Preset`](_autosummary/s3dol.presets.html.md#s3dol.presets.Preset)

### s3dol.presets.register(preset, , overwrite=False)

Add a row. Open-closed: adding a provider is adding a row.

* **Return type:**
  [`None`](https://docs.python.org/3/builtins/constants.html#None)

### s3dol.presets.unregister(name)

Remove a row (mostly for tests).

* **Return type:**
  [`None`](https://docs.python.org/3/builtins/constants.html#None)

### s3dol.presets.validate_endpoint_hygiene(url, , what='endpoint_url')

Refuse credential-carrying URL shapes: userinfo in the netloc, a query
string, or a fragment (ADR-0012 D4 — a query-string endpoint is accepted by
botocore and retained verbatim in `client.meta.endpoint_url`, so it would
leak into `diagnose()` and tracebacks).

```pycon
>>> validate_endpoint_hygiene('https://s3.example.com')
>>> validate_endpoint_hygiene('https://user:pw@s3.example.com')
Traceback (most recent call last):
...
s3dol.errors.InvalidEndpoint: ...
```

* **Return type:**
  [`None`](https://docs.python.org/3/builtins/constants.html#None)


# _autosummary/s3dol.reads.html.md

# s3dol.reads

Read strategies (ADR-0005 §6): what `s[k]` returns.

`s[k]` returns `bytes` — always, under the default strategy, because the
N1 canonical form demands it. `stream_reads` is the documented *runtime*
variation (the store’s values become chunk iterators); it does not change the
class’s static value type — honest typing there would need a generic store,
which v1 does not do.

Ranged reads and download-to-disk are per-object concerns and live on
`ObjectHandle` (`handle.read(offset=, length=)`, `handle.download_to`),
not here — a store-level “ranged” strategy would need a per-key range, which a
Mapping cannot express.

Strategies are frozen dataclasses, not closures, because every s3dol store
must pickle (ADR-0008 §6) and a store carries its strategy.

### Module Attributes

| [`DEFAULT_CHUNK_SIZE`](_autosummary/s3dol.reads.html.md#s3dol.reads.DEFAULT_CHUNK_SIZE)   | Default streaming chunk size (8 MiB, matching the write side).   |
|-----------------------------------------------------------------------|------------------------------------------------------------------|

### Functions

| `bytes_reads`()            |    |
|----------------------------|----|
| `stream_reads`(\*\*kwargs) |    |

### Classes

| [`BytesReads`](_autosummary/s3dol.reads.html.md#s3dol.reads.BytesReads)()                     | The default: one `GetObject`, fully read -> `bytes`.                              |
|-----------------------------------------------------------------------------------|-----------------------------------------------------------------------------------|
| [`ReadStrategy`](_autosummary/s3dol.reads.html.md#s3dol.reads.ReadStrategy)(\*args, \*\*kwargs) |                                                                                   |
| [`StreamReads`](_autosummary/s3dol.reads.html.md#s3dol.reads.StreamReads)([chunk_size])        | Values become lazy chunk iterators (the body streams; nothing is held in memory). |

### *class* s3dol.reads.BytesReads

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

The default: one `GetObject`, fully read -> `bytes`.

### s3dol.reads.DEFAULT_CHUNK_SIZE *= 8388608*

Default streaming chunk size (8 MiB, matching the write side).

### *class* s3dol.reads.ReadStrategy(\*args, \*\*kwargs)

Bases: [`Protocol`](https://docs.python.org/3/library/typing.html#typing.Protocol)

### *class* s3dol.reads.StreamReads(chunk_size=8388608)

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

Values become lazy chunk iterators (the body streams; nothing is held
in memory). The `GetObject` itself — and its `KeyError` — still
happens eagerly at `s[k]`; only the byte transfer is lazy.


# _autosummary/s3dol.recipes.html.md

# s3dol.recipes

Layer C — the one-liner factory and codec facades. Composition ONLY.

If a recipe cannot be expressed as Layer B + `dol` wrappers, that is evidence
the capability belongs in Layer B as a *parameter* — this module never grows a
class statement (ADR-0001; the rule that keeps per-vendor classes from
reappearing).

The one-liner:

```default
s = s3dol.s3_store('my-bucket')                     # zero ceremony
s = s3dol.s3_store('my-bucket', prefix='logs/')     # scoped
s = s3dol.s3_store('pub-bucket', anon=True)         # public data
```

With `on_missing_bucket='assume'` (the default; no probe, ever — ADR-0010)
the two-line quickstart raises on a bucket that does not exist yet; start from
nothing with `on_missing_bucket='create'`.

### Functions

| [`s3_store`](_autosummary/s3dol.recipes.html.md#s3dol.recipes.s3_store)(bucket, \*[, prefix, preset, ...])   | One bucket as a `MutableMapping[str, bytes]` (a `Mapping` when `readonly=True`).   |
|------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------|

### s3dol.recipes.s3_store(bucket, , prefix='', preset=None, connection=None, endpoint_url=None, region_name=None, profile=None, credentials=None, anon=False, on_missing_bucket='assume', readonly=False, value_codec=None, reads=None, writes=None)

One bucket as a `MutableMapping[str, bytes]` (a `Mapping` when
`readonly=True`).

Annotated (deliberately) as the abstract Mapping, **not** `-> BucketStore`:
with `value_codec` the concrete type is a generated `dol` wrapper class
that is *not* a `BucketStore` subclass. (v0 annotated its factory
`-> Store` and returned something that was not one; inverting that lie
is not an improvement — architecture.md.)

Connection axes (`preset`/`endpoint_url`/`region_name`/`profile`/
`credentials`/`anon`) are conveniences that build an
[`S3Connection`](_autosummary/s3dol.connection.html.md#s3dol.connection.S3Connection); pass `connection=` instead for
full control (they are mutually exclusive with it).


# _autosummary/s3dol.store.html.md

# s3dol.store

COMPAT SHIM — the v0 `S3Store`, forwarded onto the v1 machinery.

Removed in v2. This module **must survive as an importable module**: external
dependents do `from s3dol.store import S3Store` (fully qualified), not
`from s3dol import S3Store` (ADR-0007 §3).

The shim keeps v0’s exact signature (`bucket_name` positional-or-keyword,
`path=` not renamed, the `make_bucket` tri-state, and
`is_supabase_endpoint=` which an early draft forgot) and is \*\*a fix delivery
mechanism\*\*: callers get the corrected endpoint/credential resolution without
changing a line. Three v0 behaviours a dependent’s *passing tests* rely on are
deliberately preserved here (and only here — ADR-0007 §4):

- `store[k] = 'a str'` is accepted (encoded utf-8, with a
  `DeprecationWarning`);
- `store['folder/']` returns a sub-store;
- `del store[absent]` silently succeeds (v1 deletes are idempotent anyway).

And one v0 behaviour is preserved on the Supabase branch only: the read-side
de-chunker for objects that v0’s misconfigured writes stored with their
`aws-chunked` HTTP framing verbatim (ADR-0003 §3). It is implemented
*correctly* here (multi-chunk; full-parse-or-passthrough) where v0’s truncated
multi-chunk payloads. Per ADR-0003’s sequencing rule the codec is not deleted
until a repair path ships — [`detect_chunked_framing()`](_autosummary/s3dol.store.html.md#s3dol.store.detect_chunked_framing) is that path’s
diagnostic.

When v1 resolves a call differently than v0 *effectively* did (v0 dropped an
explicit `endpoint_url` whenever env credentials were set, and let env
credentials override explicit ones), the shim warns with
[`S3DolResolutionChanged`](_autosummary/s3dol.errors.html.md#s3dol.errors.S3DolResolutionChanged) — the ADR-0012 D7 differential.
This module and that warning die together in v2.

### Functions

| [`S3Store`](_autosummary/s3dol.store.html.md#s3dol.store.S3Store)(bucket_name, \*[, make_bucket, path, ...])   | DEPRECATED — the v0 entry point, kept working until v2.                                                         |
|-------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------|
| [`dechunk_aws_chunked`](_autosummary/s3dol.store.html.md#s3dol.store.dechunk_aws_chunked)(data)                            | Undo verbatim-persisted `aws-chunked` framing, if present.                                                      |
| [`detect_chunked_framing`](_autosummary/s3dol.store.html.md#s3dol.store.detect_chunked_framing)(store, \*[, sample])          | Which of the first `sample` keys hold verbatim `aws-chunked` framing (objects corrupted by v0 Supabase writes). |

### s3dol.store.S3Store(bucket_name, , make_bucket=None, path=None, aws_access_key_id=None, aws_secret_access_key=None, aws_session_token=None, endpoint_url=None, region_name=None, profile_name=None, skip_bucket_check=None, is_supabase_endpoint=None)

DEPRECATED — the v0 entry point, kept working until v2.

Use [`s3dol.s3_store()`](_autosummary/s3dol.html.md#s3dol.s3_store) instead: `s3_store(bucket, prefix=...)`.

Signature is v0’s exactly (`path=` not renamed; `make_bucket`
tri-state maps `True -> on_missing_bucket='create'`, `False ->
'raise'`, `None -> 'assume'`). Behaviour differences vs v0 are bug
fixes only (explicit endpoint/credentials honoured; listing errors raise
instead of returning `[]`; writes no longer create buckets unless asked)
and announce themselves via `S3DolResolutionChanged` when they change
this call’s resolution.

* **Return type:**
  [`MutableMapping`](https://docs.python.org/3/library/typing.html#typing.MutableMapping)

### s3dol.store.dechunk_aws_chunked(data)

Undo verbatim-persisted `aws-chunked` framing, if present.

Full-parse-or-passthrough: either the ENTIRE payload parses as chunked
framing (every chunk header, every CRLF, through the terminal `0` chunk)
and the concatenated chunks are returned, or the payload is returned
untouched. v0’s parser truncated any payload larger than one chunk and
misfired on payloads that merely *started* with hex digits; requiring a
complete valid parse removes both failure modes (a random payload that
happens to be a complete chunked document is astronomically unlikely).

```pycon
>>> dechunk_aws_chunked(b'5\r\nhello\r\n0\r\n\r\n')
b'hello'
>>> framed = b'3\r\nabc\r\n2\r\nde\r\n0\r\nx-amz-checksum-crc32:AAAA\r\n\r\n'
>>> dechunk_aws_chunked(framed)  # multi-chunk (v0 truncated this)
b'abcde'
>>> dechunk_aws_chunked(b'cafe is hex-ish but not framed')
b'cafe is hex-ish but not framed'
```

* **Return type:**
  [`bytes`](https://docs.python.org/3/builtins/stdtypes.html#bytes)

### s3dol.store.detect_chunked_framing(store, , sample=20)

Which of the first `sample` keys hold verbatim `aws-chunked`
framing (objects corrupted by v0 Supabase writes). The repair path:
`store[k] = dechunk_aws_chunked(raw[k])` per flagged key, reading raw
bytes through an un-codec’d store.

* **Return type:**
  [`list`](https://docs.python.org/3/builtins/stdtypes.html#list)


# _autosummary/s3dol.testing.html.md

# s3dol.testing

`s3dol.testing` — a shipped in-memory fake and the exported conformance
suite (ADR-0008). Downstream users can test services that take a store as a
dependency with **no network, no docker, no moto**:

```default
from s3dol.testing import mock_s3

def test_my_service():
    assert MediaService(mock_s3()).url('a')
```

The fake is not a re-implementation: [`FakeBucketStore`](_autosummary/s3dol.testing.html.md#s3dol.testing.FakeBucketStore) *is* the real
[`BucketStore`](_autosummary/s3dol.base.html.md#s3dol.base.BucketStore) with only the backend protocol (the `_op_*`
seam of ADR-0002) swapped for a dict — so the prefix arithmetic, key validity,
error taxonomy (the fake raises *synthesized botocore ClientErrors* through
the same translation seam), guards and Mapping semantics are structurally
identical, and drift fails the same conformance suite that gates the real
store.

The suite is parameterized by capability flags: `mock_s3()` runs the
structural presign assertion (2a) but not the fetch-it assertion (2b — there
is no HTTP server), so the honest claim is  *“the same suite, parameterized by
an \`\`endpoint_is_fetchable\`\` capability”* (ADR-0008).

### Functions

| [`mock_s3`](_autosummary/s3dol.testing.html.md#s3dol.testing.mock_s3)([bucket, prefix, data, ...])   | An in-process fake `BucketStore`: no network, no docker, no moto.    |
|-----------------------------------------------------------------------------------------|----------------------------------------------------------------------|
| [`run_conformance`](_autosummary/s3dol.testing.html.md#s3dol.testing.run_conformance)(make_store, \*[, ...]) | Assert the s3dol store laws against a fresh store from `make_store`. |

### Classes

| [`FakeBucketHandles`](_autosummary/s3dol.testing.html.md#s3dol.testing.FakeBucketHandles)(\*args[, backing])               |                                                              |
|-----------------------------------------------------------------------------------------------------|--------------------------------------------------------------|
| [`FakeBucketInfo`](_autosummary/s3dol.testing.html.md#s3dol.testing.FakeBucketInfo)(\*args[, backing])                  |                                                              |
| [`FakeBucketListedInfo`](_autosummary/s3dol.testing.html.md#s3dol.testing.FakeBucketListedInfo)(\*args[, backing])            |                                                              |
| [`FakeBucketStore`](_autosummary/s3dol.testing.html.md#s3dol.testing.FakeBucketStore)(\*args[, backing])                 | The real `BucketStore` over a dict backend.                  |
| [`FakeBucketUrls`](_autosummary/s3dol.testing.html.md#s3dol.testing.FakeBucketUrls)(\*args[, backing])                  |                                                              |
| [`FakeObjectHandle`](_autosummary/s3dol.testing.html.md#s3dol.testing.FakeObjectHandle)(bucket, key, \*, backing[, anon]) | The fake's per-object escape hatch (mirrors `ObjectHandle`). |

### *class* s3dol.testing.FakeBucketHandles(\*args, backing=None, \*\*kwargs)

Bases: `_FakeOps`, [`BucketHandles`](_autosummary/s3dol.capabilities.html.md#s3dol.capabilities.BucketHandles)

### *class* s3dol.testing.FakeBucketInfo(\*args, backing=None, \*\*kwargs)

Bases: `_FakeOps`, [`BucketInfo`](_autosummary/s3dol.capabilities.html.md#s3dol.capabilities.BucketInfo)

### *class* s3dol.testing.FakeBucketListedInfo(\*args, backing=None, \*\*kwargs)

Bases: `_FakeOps`, [`BucketListedInfo`](_autosummary/s3dol.capabilities.html.md#s3dol.capabilities.BucketListedInfo)

### *class* s3dol.testing.FakeBucketStore(\*args, backing=None, \*\*kwargs)

Bases: `_FakeOps`, [`BucketStore`](_autosummary/s3dol.base.html.md#s3dol.base.BucketStore)

The real `BucketStore` over a dict backend.

### *class* s3dol.testing.FakeBucketUrls(\*args, backing=None, \*\*kwargs)

Bases: `_FakeOps`, [`BucketUrls`](_autosummary/s3dol.capabilities.html.md#s3dol.capabilities.BucketUrls)

### *class* s3dol.testing.FakeObjectHandle(bucket, key, , backing, anon=False)

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

The fake’s per-object escape hatch (mirrors `ObjectHandle`).

### s3dol.testing.mock_s3(bucket='mock-bucket', , prefix='', data=None, bucket_exists=True, anon=False)

An in-process fake `BucketStore`: no network, no docker, no moto.

`data` seeds the bucket with *absolute* (wire) keys -> bytes.

```pycon
>>> s = mock_s3(data={'logs/a.txt': b'hi', 'other/z': b'no'}, prefix='logs')
>>> list(s), s['a.txt']
(['a.txt'], b'hi')
>>> s['b'] = b'new'; sorted(s)
['a.txt', 'b']
```

* **Return type:**
  [`FakeBucketStore`](_autosummary/s3dol.testing.html.md#s3dol.testing.FakeBucketStore)

### s3dol.testing.run_conformance(make_store, \*, endpoint_is_fetchable=False, normalize=<function <lambda>>, check_pickle=True, check_urls=True, secret=None)

Assert the s3dol store laws against a fresh store from `make_store`.

`make_store` must return an EMPTY, writable store (each call may return
a new one over the same empty backend). `normalize` is the per-layer
canonical form of ADR-0005 N3 (identity for Layer B; `json.loads ∘
json.dumps` for a json recipe, …). `secret`, when given, is asserted
absent from every repr this suite touches.

Sibling packages and user code are welcome to run this against their own
stores — that is why it ships in the package rather than in `tests/`.

* **Return type:**
  [`None`](https://docs.python.org/3/builtins/constants.html#None)


# _autosummary/s3dol.uploads.html.md

# s3dol.uploads

Direct-to-S3 browser uploads: a presigned POST scoped to a key prefix.

A browser can upload straight to S3 without the server relaying bytes: the
server issues a presigned POST form whose signed policy pins

- the **exact key** (server-generated `<prefix><random token>`: the client
  never picks a filename, so it can neither overwrite a sibling object nor
  smuggle `..` segments; a form holds one object, and on an *unversioned*
  bucket re-posting with it only overwrites that object, so the byte budget
  cannot be multiplied; see “Versioned buckets” below),
- a **content-length range** (`min_bytes`..\`\`max_bytes\`\`),
- the **content type** (optional), and
- an **expiry** (the 7-day SigV4 cap; an STS session’s own expiry still ends it sooner).

Before signing, an optional `budget` callable is asked to reserve the bytes
(`budget(max_bytes)` raises [`UploadBudgetExceeded`](_autosummary/s3dol.uploads.html.md#s3dol.uploads.UploadBudgetExceeded) to refuse, and may return a `release()` callable that is called if signing fails), so a
daily per-tenant byte budget is enforced *before* any form exists.
[`DailyByteBudget`](_autosummary/s3dol.uploads.html.md#s3dol.uploads.DailyByteBudget) is the ready-made one; any callable works.

**Versioned buckets.** The budget caps what one form can store only when the
bucket keeps one version per key. With versioning *Enabled*, every re-post of
the same form within its expiry stores a new full version, so one reservation
of `max_bytes` can buy `N * max_bytes` of storage. Use an unversioned
bucket for uploads, or one with a lifecycle rule that expires noncurrent
versions promptly. When a `budget` is given, [`presigned_upload()`](_autosummary/s3dol.uploads.html.md#s3dol.uploads.presigned_upload) asks
the bucket for its versioning status and, per `on_versioned_bucket`, warns
(the default, [`VersionedBucketWarning`](_autosummary/s3dol.uploads.html.md#s3dol.uploads.VersionedBucketWarning)), refuses
(`ConfigurationError`) or skips the check (`'ignore'`, no extra call).

The function is host-agnostic: it takes the store, the prefix and the limits
as arguments, and the web app mounts it behind its own auth:

```default
form = s3dol.presigned_upload(
    store, key_prefix='tenant-7/', max_bytes=5_000_000, content_type='image/png')
form.url, form.fields      # hand both to the browser's <form>/FormData
```

```pycon
>>> from s3dol.uploads import DailyByteBudget
>>> budget = DailyByteBudget(100, today=lambda: '2026-01-01')
>>> _ = budget(60); _ = budget(40)
>>> budget(1)
Traceback (most recent call last):
  ...
s3dol.uploads.UploadBudgetExceeded: daily upload budget exceeded: 100 of 100 bytes already reserved, 1 requested
```

### Module Attributes

| [`DEFAULT_UPLOAD_EXPIRES_IN`](_autosummary/s3dol.uploads.html.md#s3dol.uploads.DEFAULT_UPLOAD_EXPIRES_IN)   | long enough to pick a file, short enough to not be a standing upload credential.                                                                                                           |
|------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [`ON_VERSIONED_BUCKET_CHOICES`](_autosummary/s3dol.uploads.html.md#s3dol.uploads.ON_VERSIONED_BUCKET_CHOICES) | What [`presigned_upload()`](_autosummary/s3dol.uploads.html.md#s3dol.uploads.presigned_upload) does when a budget is given and the bucket has versioning enabled: warn, refuse, or skip the check (no API call). |

### Functions

| [`presigned_upload`](_autosummary/s3dol.uploads.html.md#s3dol.uploads.presigned_upload)(store, \*, key_prefix, ...)   | A presigned POST form for ONE new object under `key_prefix`.   |
|-------------------------------------------------------------------------------------------------|----------------------------------------------------------------|

### Classes

| [`DailyByteBudget`](_autosummary/s3dol.uploads.html.md#s3dol.uploads.DailyByteBudget)(limit_bytes, \*[, ledger, today])   | A per-day byte budget (one instance per tenant); call it to reserve.   |
|------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------|
| [`PresignedUpload`](_autosummary/s3dol.uploads.html.md#s3dol.uploads.PresignedUpload)(url[, fields, key, ...])            | What the browser needs: POST `fields` + a `file` part to `url`.        |

### Exceptions

| [`UploadBudgetExceeded`](_autosummary/s3dol.uploads.html.md#s3dol.uploads.UploadBudgetExceeded)   | The tenant's byte budget cannot cover this upload; no form was signed.   |
|-------------------------------------------------------------------------|--------------------------------------------------------------------------|
| [`VersionedBucketWarning`](_autosummary/s3dol.uploads.html.md#s3dol.uploads.VersionedBucketWarning) | A budgeted upload form was signed for a bucket with versioning enabled.  |

### s3dol.uploads.DEFAULT_UPLOAD_EXPIRES_IN *= 900*

long enough to pick a file, short enough to
not be a standing upload credential.

* **Type:**
  Default form lifetime (seconds)

### *class* s3dol.uploads.DailyByteBudget(limit_bytes, \*, ledger=None, today=<function DailyByteBudget.<lambda>>)

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

A per-day byte budget (one instance per tenant); call it to reserve.

`ledger` is any `MutableMapping[str, int]` (default: in-memory) keyed
by day, so persistence is a one-argument swap (a `dol` store, a file…).
`today` is the clock seam. Reservation is optimistic (the *maximum* the
form allows), and a form holds exactly one key, so re-posting cannot multiply
the budget on an unversioned bucket (on a versioned one each re-post stores a
new version: see the module docstring).

### s3dol.uploads.ON_VERSIONED_BUCKET_CHOICES *= ('warn', 'raise', 'ignore')*

What [`presigned_upload()`](_autosummary/s3dol.uploads.html.md#s3dol.uploads.presigned_upload) does when a budget is given and the bucket
has versioning enabled: warn, refuse, or skip the check (no API call).

### *class* s3dol.uploads.PresignedUpload(url, fields=dict(), key='', key_prefix='', max_bytes=0)

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

What the browser needs: POST `fields` + a `file` part to `url`.

### *exception* s3dol.uploads.UploadBudgetExceeded

Bases: [`S3Error`](_autosummary/s3dol.errors.html.md#s3dol.errors.S3Error)

The tenant’s byte budget cannot cover this upload; no form was signed.

### *exception* s3dol.uploads.VersionedBucketWarning

Bases: [`S3DolWarning`](_autosummary/s3dol.errors.html.md#s3dol.errors.S3DolWarning)

A budgeted upload form was signed for a bucket with versioning enabled.

### s3dol.uploads.presigned_upload(store, , key_prefix, max_bytes, content_type, min_bytes=0, expires_in=900, budget=None, on_versioned_bucket='warn')

A presigned POST form for ONE new object under `key_prefix`.

`content_type` is required: pass the one type to accept, or `None` to
explicitly accept any (then a holder can store `text/html`: do not serve
such objects from a trusted origin).

`key_prefix` must end with the store’s delimiter (`tenant-7/` cannot
match `tenant-77/`) and is in the *store’s* key space (the store’s own
prefix is prepended, like every other s3dol key). The object key is
server-generated (`PresignedUpload.key`). Returns `None` for an
anonymous store (no signing capability, as [`s3dol.urls()`](_autosummary/s3dol.html.md#s3dol.urls) does).

When `budget` is given, the bucket’s versioning status is read first (one
`GetBucketVersioning` call): with versioning enabled a re-posted form
stores a new version each time, so `on_versioned_bucket` decides:
`'warn'` (default) emits [`VersionedBucketWarning`](_autosummary/s3dol.uploads.html.md#s3dol.uploads.VersionedBucketWarning), `'raise'`
refuses with `ConfigurationError`, `'ignore'` skips the call.

Raises `ConfigurationError` for a bad prefix, size range,
`expires_in` or `on_versioned_bucket`, and [`UploadBudgetExceeded`](_autosummary/s3dol.uploads.html.md#s3dol.uploads.UploadBudgetExceeded)
if `budget` refuses.

* **Return type:**
  [`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`PresignedUpload`](_autosummary/s3dol.uploads.html.md#s3dol.uploads.PresignedUpload)]


# _autosummary/s3dol.values.html.md

# s3dol.values

Value refs and the write domain (ADR-0005).

The write domain is a small, closed, explicitly-named union:

```default
BytesSource = bytes | bytearray | memoryview | BinaryIO | Filepath | Chunks | Streamable
```

`Filepath`/`Chunks`/`Streamable` are tiny frozen dataclasses — value
*refs*, not values (h5py’s `SoftLink`/`ExternalLink` are the precedent:
purpose-built objects meaning “the value is a reference to content elsewhere”,
assigned through an ordinary `__setitem__`).

The law that makes the asymmetric read/write types safe (ADR-0005 §3):

- **N1 (canonical form)**: `normalize: WriteDomain -> bytes` is total on
  `bytes | bytearray | memoryview | Filepath` and **one-shot** on
  `BinaryIO | Chunks | Streamable` — a stream ref is consumed by its first
  write; assigning the same ref twice is a documented error, not a second copy.
- **N3 (the honest invariant)**: `s[k] = v  =>  s[k] == normalize(v)` — for
  the re-readable half.

`str` is rejected, loudly, on **decidability** (§2): `s['config'] = '{"a":1}'`
and `s['video'] = '/tmp/big.mp4'` are both overwhelmingly plausible, and any
rule distinguishing them is a latent data-corruption bug. One word —
`Filepath(p)` — removes the ambiguity. Bare `os.PathLike` is rejected too:
accepting it while rejecting `str` would be a confusing half-rule.

```pycon
>>> reject_str_value('{"a": 1}')
Traceback (most recent call last):
...
TypeError: ...
```

### Module Attributes

| [`BytesSource`](_autosummary/s3dol.values.html.md#s3dol.values.BytesSource)   | The static write domain (`BinaryIO` is for mypy; runtime dispatch uses `io.IOBase` — see [`as_fileobj()`](_autosummary/s3dol.values.html.md#s3dol.values.as_fileobj)).   |
|----------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------|

### Functions

| [`as_fileobj`](_autosummary/s3dol.values.html.md#s3dol.values.as_fileobj)()        | A binary file object for any member of the write domain.             |
|----------------------------------------------------------------------|----------------------------------------------------------------------|
| [`is_bytes_like`](_autosummary/s3dol.values.html.md#s3dol.values.is_bytes_like)(v)    | Whether `v` is an in-memory bytes value (the `PutObject` fast path). |
| [`reject_str_value`](_autosummary/s3dol.values.html.md#s3dol.values.reject_str_value)(v) | The one error message for the `str` ambiguity (ADR-0005 §2).         |

### Classes

| [`Chunks`](_autosummary/s3dol.values.html.md#s3dol.values.Chunks)(chunks[, consumed])   | The value is the concatenation of an iterable of `bytes` chunks.                                                                     |
|-------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------|
| [`Filepath`](_autosummary/s3dol.values.html.md#s3dol.values.Filepath)(path)               | The value *is the content of this file*.                                                                                             |
| [`Streamable`](_autosummary/s3dol.values.html.md#s3dol.values.Streamable)(open_stream)      | The value is whatever a zero-arg factory's stream yields — for sources that must be (re)opened at write time, e.g. an HTTP download. |

### s3dol.values.BytesSource

The static write domain (`BinaryIO` is for mypy; runtime dispatch uses
`io.IOBase` — see [`as_fileobj()`](_autosummary/s3dol.values.html.md#s3dol.values.as_fileobj)).

alias of [`bytes`](https://docs.python.org/3/builtins/stdtypes.html#bytes) | [`bytearray`](https://docs.python.org/3/builtins/stdtypes.html#bytearray) | [`memoryview`](https://docs.python.org/3/builtins/stdtypes.html#memoryview) | [`BinaryIO`](https://docs.python.org/3/library/typing.html#typing.BinaryIO) | [`Filepath`](_autosummary/s3dol.values.html.md#s3dol.values.Filepath) | [`Chunks`](_autosummary/s3dol.values.html.md#s3dol.values.Chunks) | [`Streamable`](_autosummary/s3dol.values.html.md#s3dol.values.Streamable)

### *class* s3dol.values.Chunks(chunks, consumed=list())

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

The value is the concatenation of an iterable of `bytes` chunks.
**One-shot** unless the iterable is re-iterable (a list is; a generator is
not — and a consumed generator writes `b''`, which is why assigning the
same one-shot ref twice is a documented error).

### *class* s3dol.values.Filepath(path)

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

The value *is the content of this file*. Re-readable (N1-total).

### *class* s3dol.values.Streamable(open_stream)

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

The value is whatever a zero-arg factory’s stream yields — for sources
that must be (re)opened at write time, e.g. an HTTP download. The factory
is called once per write, so unlike [`Chunks`](_autosummary/s3dol.values.html.md#s3dol.values.Chunks) this ref IS safely
re-writable (each write gets a fresh stream).

### s3dol.values.as_fileobj(v)

### s3dol.values.as_fileobj(v)

### s3dol.values.as_fileobj(v)

### s3dol.values.as_fileobj(v)

### s3dol.values.as_fileobj(v)

### s3dol.values.as_fileobj(v)

### s3dol.values.as_fileobj(v)

### s3dol.values.as_fileobj(v)

A binary file object for any member of the write domain.

`functools.singledispatch`: the union is open for extension (users
register their own ref types) and closed for modification. Everything
non-`bytes` routes through `upload_fileobj` downstream, so seekability
is s3transfer’s problem.

* **Return type:**
  [`BinaryIO`](https://docs.python.org/3/library/typing.html#typing.BinaryIO)

### s3dol.values.is_bytes_like(v)

Whether `v` is an in-memory bytes value (the `PutObject` fast path).

* **Return type:**
  [`bool`](https://docs.python.org/3/builtins/functions.html#bool)

### s3dol.values.reject_str_value(v)

The one error message for the `str` ambiguity (ADR-0005 §2).


# _autosummary/s3dol.writes.html.md

# s3dol.writes

Write strategies (ADR-0005 §5): how `s[k] = v` reaches the wire.

A strategy is a callable `(client, bucket, key, value) -> None`, injected at
store construction — `__setitem__` stays `__setitem__`; *how* it uploads is
a constructor parameter. This is the answer to “infra-specific optimisation
without polluting the interface”: multipart is *transport*, not storage-model.

Strategies are frozen dataclasses, not closures, because every s3dol store
must pickle (ADR-0008 §6 / ADR-0012 D1) and a store carries its strategy.

Every non-`bytes` source routes through `upload_fileobj`/`TransferManager`,
never `PutObject` — so seekability is s3transfer’s problem, and the size
threshold is never consulted for a non-seekable source (where it is undecidable
anyway). Note `io.UnsupportedOperation` and botocore’s
`UnseekableStreamError` raise *before the request is built*, so they reach the
caller directly (they are not `ClientError``s and the error seam does not —
and must not — convert them to ``KeyError`).

```pycon
>>> strategy = transfer_writes(multipart_threshold=16 * 2**20)
>>> import pickle; pickle.loads(pickle.dumps(strategy)) == strategy
True
```

### Module Attributes

| [`DEFAULT_MULTIPART_THRESHOLD`](_autosummary/s3dol.writes.html.md#s3dol.writes.DEFAULT_MULTIPART_THRESHOLD)   | boto3's own default multipart threshold (8 MiB).   |
|--------------------------------------------------------------------------------|----------------------------------------------------|

### Functions

| `simple_writes`()                                                            |                                                                                                                                                                                        |
|------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [`transfer_writes`](_autosummary/s3dol.writes.html.md#s3dol.writes.transfer_writes)(\*\*kwargs) | Factory spelling of [`TransferWrites`](_autosummary/s3dol.writes.html.md#s3dol.writes.TransferWrites) (the constructor-injection idiom of ADR-0005 §5: `BucketStore(..., writes=transfer_writes(...))`). |

### Classes

| [`SimpleWrites`](_autosummary/s3dol.writes.html.md#s3dol.writes.SimpleWrites)()                             | Everything through a single `PutObject` — refs are materialised in memory first.                                                                                            |
|---------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [`TransferWrites`](_autosummary/s3dol.writes.html.md#s3dol.writes.TransferWrites)([multipart_threshold, ...]) | The default: small in-memory values take a single `PutObject`; file objects and refs go through `upload_fileobj` (which goes multipart above the threshold, transparently). |
| [`WriteStrategy`](_autosummary/s3dol.writes.html.md#s3dol.writes.WriteStrategy)(\*args, \*\*kwargs)          |                                                                                                                                                                             |

### s3dol.writes.DEFAULT_MULTIPART_THRESHOLD *= 8388608*

boto3’s own default multipart threshold (8 MiB).

### *class* s3dol.writes.SimpleWrites

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

Everything through a single `PutObject` — refs are materialised in
memory first. For small-object workloads and providers with no multipart
at all (`Capabilities.multipart=False`).

### *class* s3dol.writes.TransferWrites(multipart_threshold=8388608, multipart_chunksize=8388608, max_concurrency=10, use_threads=True)

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

The default: small in-memory values take a single `PutObject`; file
objects and refs go through `upload_fileobj` (which goes multipart above
the threshold, transparently). The overhead on small objects is one branch.

Providers that cap multipart parts (Scaleway: 1000 — see the preset’s
`Capabilities.max_multipart_parts`) may need a larger
`multipart_chunksize` for very large objects: parts ≈ size / chunksize.

### *class* s3dol.writes.WriteStrategy(\*args, \*\*kwargs)

Bases: [`Protocol`](https://docs.python.org/3/library/typing.html#typing.Protocol)

### s3dol.writes.transfer_writes(\*\*kwargs)

Factory spelling of [`TransferWrites`](_autosummary/s3dol.writes.html.md#s3dol.writes.TransferWrites) (the constructor-injection
idiom of ADR-0005 §5: `BucketStore(..., writes=transfer_writes(...))`).

* **Return type:**
  [`TransferWrites`](_autosummary/s3dol.writes.html.md#s3dol.writes.TransferWrites)


# about-this-build.html.md

<!-- generated by epythet -->

# About this build

This documentation was built on **2026-11-24 01:13 UTC** from commit <a href="https://github.com/i2mint/s3dol/commit/617983e4e1be1213df647c7a1842f5ee992de5a8"><code>617983e</code></a> on branch <code>master</code>, for **s3dol 1.0.5** (from <code>pyproject.toml</code>).

#### NOTE
Nothing suggests a mismatch: the tree was clean at the commit above, and the documented version is the one on PyPI.

## Source

|                     |                                                                                                                                                     |
|---------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------|
| Commit              | <a href="https://github.com/i2mint/s3dol/commit/617983e4e1be1213df647c7a1842f5ee992de5a8"><code>617983e4e1be1213df647c7a1842f5ee992de5a8</code></a> |
| Branch              | <code>master</code>                                                                                                                                 |
| Tags at this commit | none                                                                                                                                                |
| Working tree        | clean                                                                                                                                               |
| Remote              | <code>https://github.com/i2mint/s3dol</code>                                                                                                        |

## Continuous integration

|              |                                                                                            |
|--------------|--------------------------------------------------------------------------------------------|
| Repository   | <code>i2mint/s3dol</code>                                                                  |
| Run          | <a href="https://github.com/i2mint/s3dol/actions/runs/45303213940">45303213940</a>         |
| Ref          | <code>refs/heads/master</code>                                                             |
| Event commit | <code>617983e4e1be1213df647c7a1842f5ee992de5a8</code> (in the history of the built commit) |

## Tools

|          |         |
|----------|---------|
| epythet  | 0.2.25  |
| Sphinx   | 9.1.1   |
| docutils | 0.22.4  |
| Python   | 3.12.16 |

## Configuration as resolved

|               |                                                                  |
|---------------|------------------------------------------------------------------|
| theme         | <code>auto</code> (Sphinx theme <code>furo</code>)               |
| accent        | <code>#006c35</code>                                             |
| api_generator | <code>autosummary</code>                                         |
| ignore        | <code>tests/</code>, <code>scrap/</code>, <code>examples/</code> |
| agent_outputs | <code>true</code>                                                |
| aggregates    | <code>md</code>                                                  |
| ai_artifacts  | <code>true</code>                                                |

## Package on PyPI

Latest release: <a href="https://pypi.org/project/s3dol/1.0.5/">1.0.5</a>, the same as the documented version.

## Reproduce

```bash
git clone https://github.com/i2mint/s3dol && cd s3dol
git checkout 617983e4e1be1213df647c7a1842f5ee992de5a8
pip install "epythet==0.2.25"
epythet quickstart . --ignore tests/ scrap/ examples/
```

The same data, for machines: <a href="build_info.json"><code>build_info.json</code></a> (schema version 1).


# api.html.md

# API reference

| [`s3dol`](_autosummary/s3dol.html.md#module-s3dol)   | s3dol — S3 and S3-compatible object storage behind a dict-like interface.   |
|-----------------------------------------------------------------------|-----------------------------------------------------------------------------|


