# Bucket

> Buckets: files by key, private by default, with signed links and an S3-compatible escape hatch.

```python
bucket = noclick.Bucket.from_name("uploads", create_if_missing=True)
bucket.put("invoices/0042.pdf", pdf_bytes, content_type="application/pdf")
link = bucket.signed_url("invoices/0042.pdf", expires_in=3600)
```

A key is a path-like name (`invoices/0042.pdf`); `/` separates folders only
by convention, so listing with `delimiter="/"` shows them as folders.

## noclick.Bucket

```python
class Bucket
```

A bucket of files by key. Private by default: files are reached through
this client, a `signed_url` or S3 credentials. A public bucket also serves
every file at `url(key)`.

| Attribute | Type | Description |
| --- | --- | --- |
| `id` | `str` |  |
| `name` | `str` |  |
| `public` | `bool` | Whether every file is readable at `url(key)` without a link. |
| `size_bytes` | `int | None` |  |
| `object_count` | `int | None` |  |
| `public_base_url` | `str | None` | Where a public bucket serves its files (None while it's private). |
| `used_by` | `list[dict[str, Any]]` | Who uses it: apps that bind it (`kind` `project`, with the `binding` name) and agents with it in their tools (`kind` `agent`), each with its `id` and `name`. |
| `notifications` | `list[dict[str, Any]]` | Where it tells about new files (`notify`): each with the `queue` (its name) and `prefix` (None for every file). |
| `region` | `str | None` | The region it keeps its files in (`noclick.regions()`), fixed when it was created. |
| `user_id` | `str | None` |  |
| `created_at` | `Any` |  |
| `console_url` | `str | None` | This bucket in the developer console (None off the hosted API). |

### Bucket.only

```python
bucket.only(*operations) -> BucketOperations
```

A tool ref to some of its operations, for `tools=`: `"objects"` (list
keys under a prefix), `"head"` (one file's size, type and metadata),
`"put"` (store a file from a `url` or from `text`, with a content type and
metadata; the model never handles bytes), `"signed_url"` (a link that reads a
file, to hand a person) and `"remove"`. The bucket itself in an agent's
`tools=` gives all five, as `{name}__objects` and so on. Its calls follow
your policy as `bucket.objects`, `bucket.put` and the rest (`bucket.*`). A
file the agent's browser downloads comes back to it as a signed URL, which
`put` stores from `url`. An agent may use its own scope's buckets and the
account's. In a toolkit or a hosted MCP server, a bucket is in invite-only
beta.

Parameters:

- `operations` (`str`)

Returns: `BucketOperations` A ref to just those operations, to list in `tools=`; `bind(...)` fixes arguments.

Usage:

```python
reports = noclick.Bucket.from_name("reports")
analyst = noclick.Agent.from_name(
    "analyst",
    create_if_missing=True,
    instructions="You write the weekly report, save it, and share a link to it.",
    tools=[reports.only("put", "signed_url"), "search"],
)
```

### Bucket.create

```python
noclick.Bucket.create(
    name, *, public=False, region=None, allow_existing=False, user=..., client=None
) -> Bucket
```

Create a bucket called `name`, unique to its user (a taken name raises
`noclick.Conflict` with `existing_id`, or with `allow_existing=True` returns
the bucket already there, as it is). `public=True` serves every
file at a plain URL. `region` (`noclick.regions()`) is where its files
are kept, for good; without one, your account's default region, else
`us-east`. Object storage takes it as a location hint: the bucket is
made there when the store has room there, which is a placement, not a
legal promise of residency. A name is 1-64 letters, digits and `. _ -`.

Parameters:

- `name` (`str`, required)
- `public` (`bool`, default `False`)
- `region` (`str | None`, default `None`)
- `allow_existing` (`bool`, default `False`)
- `user` (`Any`, default: the current user): Who the call acts for. Defaults to the user set by `noclick.as_user` (none: the account itself).
- `client` (`Client | None`, default `None`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.

Returns: `Bucket` The new, empty bucket.

Usage:

Private files your app hands out by signed link:

```python
uploads = noclick.Bucket.create("uploads")
```

Public assets, such as images on a site:

```python
assets = noclick.Bucket.create("public-assets", public=True)
print(assets.public_base_url)
```

Files that stay in Europe:

```python
records = noclick.Bucket.create("patient-records", region="eu")
```

### Bucket.from_name

```python
noclick.Bucket.from_name(
    name, *, create_if_missing=False, public=False, region=None, user=..., client=None
) -> Bucket
```

A lazy reference to the bucket called `name` in the current (or given)
user. With `create_if_missing=True` it's created on first use (in `region`,
as `create`); one that exists is used as it is (change it with `update`).

Inside a deployed app (signed in by its deployment) the name is looked up in the app's own
namespace for the environment the code runs in, and one made there is the app's: a name bound to
the app by hand wins, and in a preview of an app whose `preview_resources` is `branch` the
branch gets an overlay at its first write: what it writes is its own, and it reads
production's files through it, so a preview never changes production's data.

Parameters:

- `name` (`str`, required)
- `create_if_missing` (`bool`, default `False`)
- `public` (`bool`, default `False`)
- `region` (`str | None`, default `None`)
- `user` (`Any`, default: the current user): Who the call acts for. Defaults to the user set by `noclick.as_user` (none: the account itself).
- `client` (`Client | None`, default `None`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.

Returns: `Bucket` A bucket that loads (or is created) the first time it's used. Nothing is sent yet.

Usage:

Name it in your code; the first run creates it:

```python
bucket = noclick.Bucket.from_name("uploads", create_if_missing=True)
bucket.put("hello.txt", "hi")
```

A bucket per user, for what their agent saves:

```python
with noclick.as_user("user_42"):
    files = noclick.Bucket.from_name("assistant-files", create_if_missing=True)
    print(files.objects(prefix="receipts/"))
```

### Bucket.from_id

```python
noclick.Bucket.from_id(bucket_id, *, client=None, user=...) -> Bucket
```

A lazy reference to a bucket by id.

Parameters:

- `bucket_id` (`str`, required)
- `client` (`Client | None`, default `None`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.
- `user` (`Any`, default: the current user): Who the call acts for. Defaults to the user set by `noclick.as_user` (none: the account itself).

Returns: `Bucket` A bucket that loads the first time you read a field. Nothing is sent yet.

Usage:

```python
bucket = noclick.Bucket.from_id("8d1f3b27-5a6e-4c09-b2d8-9e4a7c1f0b35")
data = bucket.read("invoices/0042.pdf")
```

### Bucket.get

```python
noclick.Bucket.get(bucket_id, *, user=..., client=None) -> Bucket
```

Load a bucket by id now; an unknown id raises `noclick.NotFound`.

Parameters:

- `bucket_id` (`str`, required)
- `user` (`Any`, default: the current user): Who the call acts for. Defaults to the user set by `noclick.as_user` (none: the account itself).
- `client` (`Client | None`, default `None`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.

Returns: `Bucket` The bucket, loaded: whether it's public, how many files it holds and their total size.

Usage:

```python
bucket = noclick.Bucket.get("8d1f3b27-5a6e-4c09-b2d8-9e4a7c1f0b35")
print(bucket.name, bucket.public, bucket.object_count, bucket.size_bytes)
```

### Bucket.list

```python
noclick.Bucket.list(
    *, limit=None, user_filter=None, user=..., client=None
) -> list[Bucket]
```

The current user's buckets (the account's own outside `as_user`, or those `user_filter` covers).

Parameters:

- `limit` (`int | None`, default `None`): Return at most this many.
- `user_filter` (`Any`, default `None`): Which users a read covers: `noclick.ALL_USERS`, `noclick.NO_USER`, a `User`, or your id for one. It filters without acting as that user.
- `user` (`Any`, default: the current user): Who the call acts for. Defaults to the user set by `noclick.as_user` (none: the account itself).
- `client` (`Client | None`, default `None`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.

Returns: `list[Bucket]` Every matching bucket, newest first, fetched page by page.

Usage:

```python
for bucket in noclick.Bucket.list():
    print(bucket.name, bucket.public, bucket.size_bytes)

everyone = noclick.Bucket.list(user_filter=noclick.ALL_USERS)   # every user's, plus your account's
```

### Bucket.list_page

```python
noclick.Bucket.list_page(
    *, cursor=None, limit=None, user_filter=None, user=..., client=None
) -> Page
```

One page of buckets; pass `next_cursor` back as `cursor`.

Parameters:

- `cursor` (`str | None`, default `None`): The `next_cursor` of the page before; omit it for the first page.
- `limit` (`int | None`, default `None`): Return at most this many.
- `user_filter` (`Any`, default `None`): Which users a read covers: `noclick.ALL_USERS`, `noclick.NO_USER`, a `User`, or your id for one. It filters without acting as that user.
- `user` (`Any`, default: the current user): Who the call acts for. Defaults to the user set by `noclick.as_user` (none: the account itself).
- `client` (`Client | None`, default `None`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.

Returns: `Page` A page whose `data` holds the buckets and whose `next_cursor` is `None` on the last page.

Usage:

```python
page = noclick.Bucket.list_page(limit=50)
while True:
    for bucket in page.data:
        print(bucket.name, bucket.object_count)
    if page.next_cursor is None:
        break
    page = noclick.Bucket.list_page(limit=50, cursor=page.next_cursor)
```

### Bucket.put

```python
bucket.put(key, data, *, content_type=None, metadata=None) -> BucketObject
```

Store `data` (bytes, text as UTF-8, or a binary file) at `key`,
replacing what was there. `content_type` is guessed from the key's
extension when omitted; `metadata` is up to 2 KB of your own ASCII
string pairs (names come back lowercased), returned with the file. One
`put` carries up to 100 MB; send
larger files straight from where they are with a `PUT` signed link.

Parameters:

- `key` (`str`, required)
- `data` (`Data`, required)
- `content_type` (`str | None`, default `None`)
- `metadata` (`Mapping[str, str] | None`, default `None`)

Returns: `BucketObject` The file as stored, with its `size` and `etag`.

Usage:

Store what your code made:

```python
bucket = noclick.Bucket.from_name("uploads", create_if_missing=True)
stored = bucket.put("invoices/0042.pdf", b"%PDF-1.7 ...", content_type="application/pdf")
print(stored.size, stored.etag)
```

Upload a file from disk, with metadata your app reads back later:

```python
bucket = noclick.Bucket.from_name("uploads")
with open("report.csv", "rb") as f:
    bucket.put("reports/2026-09.csv", f, metadata={"user": "acme", "source": "nightly"})
```

### Bucket.read

```python
bucket.read(key) -> bytes
```

Read the file at `key`; a missing key raises `noclick.NotFound`.

Parameters:

- `key` (`str`, required)

Returns: `bytes` The file's bytes, exactly as stored; decode text yourself.

Usage:

```python
bucket = noclick.Bucket.from_name("uploads")
pdf = bucket.read("invoices/0042.pdf")
with open("0042.pdf", "wb") as f:
    f.write(pdf)
```

### Bucket.head

```python
bucket.head(key) -> BucketObject
```

Look a file up without downloading it; a missing key raises `noclick.NotFound`.

Parameters:

- `key` (`str`, required)

Returns: `BucketObject` The file's size, content type, etag, metadata and when it last changed.

Usage:

```python
bucket = noclick.Bucket.from_name("uploads")
info = bucket.head("invoices/0042.pdf")
print(info.size, info.content_type, info.metadata)
```

### Bucket.objects

```python
bucket.objects(prefix=None, *, delimiter=None, limit=None) -> list[BucketObject]
```

The files whose keys start with `prefix`, in key order. With
`delimiter="/"`, keys below the next `/` are rolled up into one folder
entry each (`is_folder`), so you can walk the bucket a level at a time.

Parameters:

- `prefix` (`str | None`, default `None`)
- `delimiter` (`str | None`, default `None`)
- `limit` (`int | None`, default `None`): Return at most this many.

Returns: `list[BucketObject]` Every matching file (or the first `limit`), fetched page by page.

Usage:

Everything under a prefix:

```python
bucket = noclick.Bucket.from_name("uploads")
for obj in bucket.objects(prefix="invoices/"):
    print(obj.key, obj.size, obj.updated_at)
```

One level at a time, like a file browser:

```python
bucket = noclick.Bucket.from_name("uploads")
for entry in bucket.objects(prefix="invoices/", delimiter="/"):
    print(entry.key + (" (folder)" if entry.is_folder else f" {entry.size} bytes"))
```

### Bucket.objects_page

```python
bucket.objects_page(prefix=None, *, delimiter=None, cursor=None, limit=None) -> Page
```

One page of `objects`; pass `next_cursor` back as `cursor`.

Parameters:

- `prefix` (`str | None`, default `None`)
- `delimiter` (`str | None`, default `None`)
- `cursor` (`str | None`, default `None`): The `next_cursor` of the page before; omit it for the first page.
- `limit` (`int | None`, default `None`): Return at most this many.

Returns: `Page` A page whose `data` holds `BucketObject`s and whose `next_cursor` is `None` on the last page.

Usage:

```python
bucket = noclick.Bucket.from_name("uploads")
page = bucket.objects_page(prefix="invoices/", limit=100)
while True:
    for obj in page.data:
        print(obj.key, obj.size)
    if page.next_cursor is None:
        break
    page = bucket.objects_page(prefix="invoices/", limit=100, cursor=page.next_cursor)
```

### Bucket.remove

```python
bucket.remove(key) -> None
```

Delete the file at `key`. Removing a key that isn't there does nothing.

Parameters:

- `key` (`str`, required)

Usage:

```python
bucket = noclick.Bucket.from_name("uploads")
bucket.remove("invoices/0042.pdf")
```

### Bucket.versions

```python
bucket.versions(key) -> list[ObjectVersion]
```

What `key` held before each write through NoClick of the last 30 days, newest first.

Parameters:

- `key` (`str`, required)

Returns: `list[ObjectVersion]` Each earlier version.

Usage:

```python
bucket = noclick.Bucket.from_name("uploads")
for version in bucket.versions("menu.pdf"):
    print(version.replaced_at, version.op, version.size)
```

### Bucket.restore_version

```python
bucket.restore_version(key, version) -> BucketObject
```

Put `key` back as `version` held it; what it holds now is kept as a version in turn.

Parameters:

- `key` (`str`, required)
- `version` (`Any`, required)

Returns: `BucketObject` The file, as it's stored again.

Usage:

Undo an overwrite:

```python
bucket = noclick.Bucket.from_name("uploads")
bucket.restore_version("menu.pdf", bucket.versions("menu.pdf")[0])
```

### Bucket.signed_url

```python
bucket.signed_url(key, *, method='GET', expires_in=3600, content_type=None) -> str
```

A link that reads (`GET`) or uploads (`PUT`) the file at `key`
without a NoClick key, for `expires_in` seconds (60 to 604,800, a week).
A `PUT` link takes up to 5 GB; with `content_type` the upload must send
that type.

Parameters:

- `key` (`str`, required)
- `method` (`Literal['GET', 'PUT']`, default `'GET'`)
- `expires_in` (`int`, default `3600`)
- `content_type` (`str | None`, default `None`)

Returns: `str` The link. Anyone who has it can use it until it expires, so hand it only to whoever needs it.

Usage:

Let a user download a private file:

```python
bucket = noclick.Bucket.from_name("uploads")
link = bucket.signed_url("invoices/0042.pdf", expires_in=3600)
```

Let a browser upload straight to the bucket, so the file never passes through your server:

```python
bucket = noclick.Bucket.from_name("uploads")
upload = bucket.signed_url("avatars/u42.png", method="PUT", expires_in=600, content_type="image/png")
# the browser runs: fetch(upload, {method: "PUT", body: file, headers: {"Content-Type": "image/png"}})
```

### Bucket.start_upload

```python
bucket.start_upload(key, *, content_type=None, metadata=None) -> BucketUpload
```

Begin uploading the file at `key` in parts: for a file bigger than a `PUT`
link carries (5 GB), or one a page sends a piece at a time. Sign a link per part
with `upload_part_urls`, `PUT` each part's bytes to its link (a browser can,
straight from a page: each answers with an `ETag` header), then join them with
`complete_upload`, or drop them with `abort_upload`. Each part is 5 MiB to
5 GiB, every part but the last the same size, up to 10,000 parts. Nothing is at
`key` until the upload completes, and one left unfinished is dropped after 7
days. `content_type` and `metadata` are as `put` takes them. An app's own
code uploads this way, since S3 credentials stay with a person.

Parameters:

- `key` (`str`, required)
- `content_type` (`str | None`, default `None`)
- `metadata` (`Mapping[str, str] | None`, default `None`)

Returns: `BucketUpload` The upload: its `upload_id` and the part sizes it takes.

Usage:

Upload a big file from disk, 64 MB at a time:

```python
import os

import httpx

part = 64 * 1024 * 1024
bucket = noclick.Bucket.from_name("recordings", create_if_missing=True)
upload = bucket.start_upload("calls/all-hands.mp4", content_type="video/mp4")
count = -(-os.path.getsize("all-hands.mp4") // part)
links = bucket.upload_part_urls("calls/all-hands.mp4", upload.upload_id, range(1, count + 1))
etags = {}
with open("all-hands.mp4", "rb") as f:
    for number in range(1, count + 1):
        sent = httpx.put(links[number], content=f.read(part))
        sent.raise_for_status()
        etags[number] = sent.headers["ETag"]
stored = bucket.complete_upload("calls/all-hands.mp4", upload.upload_id, etags)
print(stored.size)
```

### Bucket.upload_part_urls

```python
bucket.upload_part_urls(
    key, upload_id, part_numbers, *, expires_in=3600
) -> dict[int, str]
```

A `PUT` link for each of `part_numbers` (1 to 10,000) of the upload, for
`expires_in` seconds (60 to 604,800). `PUT` a part's bytes to its link: the
answer's `ETag` header names the part for `complete_upload`. A part
uploaded again replaces it, so a failed part is simply sent again.

Parameters:

- `key` (`str`, required)
- `upload_id` (`str`, required)
- `part_numbers` (`Iterable[int]`, required)
- `expires_in` (`int`, default `3600`)

Returns: `dict[int, str]` Each part number's link.

Usage:

Hand a page the links for a 1 GB file in 16 MiB parts:

```python
bucket = noclick.Bucket.from_name("manuals")
links = bucket.upload_part_urls("b737/fcom.pdf", upload_id, range(1, 65), expires_in=3600)
```

### Bucket.complete_upload

```python
bucket.complete_upload(key, upload_id, parts) -> BucketObject
```

Join the uploaded parts into the file at `key`, in part number order:
`parts` maps each part's number to the `ETag` its upload answered with (as
a page sends them back, numbers as text are fine). What `key` held is kept
as an earlier version, as `put` keeps it. Parts that can't be joined raise
`noclick.InvalidRequest` saying why (a wrong ETag, a part but the last under
5 MiB, or parts but the last of different sizes); an upload already completed,
aborted or over 7 days old raises `noclick.NotFound`.

Parameters:

- `key` (`str`, required)
- `upload_id` (`str`, required)
- `parts` (`Mapping[int, str]`, required)

Returns: `BucketObject` The file as stored, with its `size` and `etag`.

Usage:

```python
bucket = noclick.Bucket.from_name("manuals")
stored = bucket.complete_upload("b737/fcom.pdf", upload_id, {1: '"9b2c..."', 2: '"0e41..."'})
print(stored.size)
```

### Bucket.abort_upload

```python
bucket.abort_upload(key, upload_id) -> None
```

Drop the upload and every part sent. One already completed or aborted is fine.

Parameters:

- `key` (`str`, required)
- `upload_id` (`str`, required)

Usage:

```python
bucket = noclick.Bucket.from_name("manuals")
bucket.abort_upload("b737/fcom.pdf", upload_id)
```

### Bucket.url

```python
bucket.url(key) -> str
```

The plain URL a public bucket serves `key` at. A private bucket raises
`noclick.NotAvailable`: use `signed_url`, or `update(public=True)`.

Parameters:

- `key` (`str`, required)

Returns: `str` `public_base_url` followed by the key; it works for as long as the bucket stays public.

Usage:

```python
assets = noclick.Bucket.from_name("public-assets")
print(assets.url("logo.png"))   # https://.../logo.png
```

### Bucket.update

```python
bucket.update(*, public=None) -> Bucket
```

Change the bucket's settings. Making it private stops every public URL
at once; signed links keep working until they expire.

Parameters:

- `public` (`bool | None`, default `None`)

Returns: `Bucket` This bucket, with the server's current fields.

Usage:

```python
assets = noclick.Bucket.from_name("public-assets", create_if_missing=True)
assets.update(public=True)
print(assets.public_base_url)
```

### Bucket.notify

```python
bucket.notify(queue, *, prefix=None, enabled=True) -> Bucket
```

Put a message on `queue` (a `Queue` or its name, in the bucket's own user)
for every file stored under `prefix` (the whole bucket when omitted), however it
arrived: `put`, a `PUT` signed link, or S3 credentials. The message is
`{"event": "put", "bucket", "key", "size", "content_type", "etag", "at"}`, so a
worker or an agent with `OnQueue` picks each upload up. Asking again for the same
queue and prefix changes nothing; `enabled=False` stops it. A bucket tells up to
10 queues.

Parameters:

- `queue` (`Any`, required)
- `prefix` (`str | None`, default `None`)
- `enabled` (`bool`, default `True`)

Returns: `Bucket` This bucket, whose `notifications` list where it tells.

Usage:

Transcribe every call recording as it lands:

```python
recordings = noclick.Bucket.from_name("recordings", create_if_missing=True)
calls = noclick.Queue.from_name("new-recordings", create_if_missing=True)
recordings.notify(calls, prefix="calls/")
for msg in calls.iterate():
    link = recordings.signed_url(msg.body["key"])
    print(noclick.AI.transcribe(link).text)
    msg.ack()
```

Stop:

```python
recordings = noclick.Bucket.from_name("recordings")
recordings.notify("new-recordings", prefix="calls/", enabled=False)
```

### Bucket.s3_credentials

```python
bucket.s3_credentials(*, read_only=False, ttl_s=3600) -> S3Credentials
```

Keys for the bucket's S3-compatible endpoint, for rclone, the AWS CLI or
an S3 library, valid `ttl_s` seconds (900 to 43,200). They reach this
bucket only; `read_only=True` for keys that can't change anything. They're
for you and your own code: an app's deployed code is refused them
(`noclick.PermissionDenied`) and uploads big files in parts
(`start_upload`) instead.

Parameters:

- `read_only` (`bool`, default `False`)
- `ttl_s` (`int`, default `3600`)

Returns: `S3Credentials` The endpoint, bucket name, keys and `expires_at`. The secret is shown once; mint new ones when they expire.

Usage:

```python
import boto3

bucket = noclick.Bucket.from_name("uploads")
creds = bucket.s3_credentials(read_only=True, ttl_s=3600)
s3 = boto3.client(
    "s3",
    endpoint_url=creds.endpoint,
    region_name=creds.region,
    aws_access_key_id=creds.access_key_id,
    aws_secret_access_key=creds.secret_access_key,
    aws_session_token=creds.session_token,
)
print(s3.list_objects_v2(Bucket=creds.bucket, Prefix="invoices/")["KeyCount"])
```

### Bucket.export

```python
bucket.export() -> Operation
```

Export every file, to take anywhere: a zip holding each one at its key
(under `buckets/<name>/files/`), with `index.jsonl` listing each key's
content type and metadata. A key that can't be a path in a zip (an empty,
`.` or `..` part) is kept under `renamed/`, and the index says which.

Returns: `Operation` An operation whose `wait()` gives an `ExportBundle`: the zip at `url`, valid 7 days.

Usage:

```python
bucket = noclick.Bucket.from_name("uploads")
bundle = bucket.export().wait()
print(bundle.url, bundle.size_bytes)
```

### Bucket.delete

```python
bucket.delete(*, force=False) -> TrashItem
```

Delete the bucket: it goes to the trash, restorable for 30 days. It must be empty unless
`force=True`, which takes every file in it too (a non-empty bucket otherwise raises
`noclick.Conflict`); its files are stored, and billed, until it's purged.
A bucket in an agent's tools (`used_by`) raises `noclick.Conflict` until
you take it out; so will one an app binds, when apps ship.

Parameters:

- `force` (`bool`, default `False`)

Returns: `TrashItem` Its `TrashItem`: `restore()` puts it back, files and all.

Usage:

```python
bucket = noclick.Bucket.from_name("scratch")
bucket.delete(force=True)
```

## noclick.BucketObject

```python
class BucketObject
```

A file in a bucket: its `key`, `size` in bytes, `content_type`, `etag`
(it changes whenever the content does), the `metadata` you gave it and
`updated_at`. In a listing with a `delimiter`, an entry whose `is_folder`
is true stands for every key under that prefix, and only its `key` is set.

| Attribute | Type | Description |
| --- | --- | --- |
| `key` | `str` |  |
| `size` | `int | None` |  |
| `content_type` | `str | None` |  |
| `etag` | `str | None` |  |
| `metadata` | `dict[str, str]` |  |
| `updated_at` | `Any` |  |
| `is_folder` | `bool` |  |
| `raw` | `dict[str, Any]` | The response JSON exactly as the API sent it. |

## noclick.ObjectVersion

```python
class ObjectVersion
```

What a file held before a write through NoClick replaced it (`op` `changed`) or removed it
(`deleted`), kept 30 days. An upload through a signed link or S3 credentials keeps none.

| Attribute | Type | Description |
| --- | --- | --- |
| `id` | `str` |  |
| `key` | `str` |  |
| `op` | `str` |  |
| `size` | `int | None` |  |
| `replaced_at` | `Any` |  |
| `raw` | `dict[str, Any]` | The response JSON exactly as the API sent it. |

## noclick.BucketOperations

```python
class BucketOperations
```

Some of a bucket's operations as tools (`bucket.only(...)`), with the
arguments `bind(...)` fixed.

| Attribute | Type | Description |
| --- | --- | --- |
| `bucket` | `Bucket` |  |
| `operations` | `list[str]` |  |
| `bindings` | `dict[str, Any]` | The arguments NoClick fills on every call, out of the model's reach. |

### BucketOperations.bind

```python
bucket_operations.bind(**arguments) -> BucketOperations
```

Fix arguments of these operations, as `ConnectionOperations.bind` does:
a bound parameter leaves the tool's schema and NoClick fills it on every call.
`prefix` is the one to bind here: every key the tools take and return is
then under it, so one bucket can hold a folder per user
(`prefix="users/{{user.id}}/"`). Sends nothing.

Parameters:

- `arguments` (`Any`)

Returns: `BucketOperations` A new ref with these arguments bound on top of any bound before.

Usage:

```python
uploads = noclick.Bucket.from_name("uploads")
assistant = noclick.Agent.from_name(
    "assistant",
    create_if_missing=True,
    instructions="You file what the user sends you and share links to it.",
    tools=[uploads.only("objects", "put", "signed_url").bind(prefix="users/{{user.id}}/")],
)
```

## noclick.BucketUpload

```python
class BucketUpload
```

A file being uploaded in parts (`Bucket.start_upload`): its `key` and
`upload_id`, which the other upload calls take, its `content_type`, and
the parts it takes: each `min_part_bytes` (5 MiB) to `max_part_bytes`
(5 GiB), every part but the last the same size, up to `max_parts`
(10,000).

| Attribute | Type | Description |
| --- | --- | --- |
| `key` | `str` |  |
| `upload_id` | `str` |  |
| `content_type` | `str | None` |  |
| `min_part_bytes` | `int` |  |
| `max_part_bytes` | `int` |  |
| `max_parts` | `int` |  |
| `raw` | `dict[str, Any]` | The response JSON exactly as the API sent it. |

## noclick.S3Credentials

```python
class S3Credentials
```

Short-lived keys for the bucket's S3-compatible endpoint, for tools that
speak S3 (rclone, the AWS CLI, boto3). They reach this bucket only (read-only
if you asked) and stop working at `expires_at`. Give the tool all of
`endpoint`, `access_key_id`, `secret_access_key` and `session_token`,
with `region`; `bucket` is the bucket's name on that endpoint, which isn't
its NoClick name. Keys are a person's: an app's deployed code gets none, and
uploads a file of any size in parts (`Bucket.start_upload`) instead.

| Attribute | Type | Description |
| --- | --- | --- |
| `endpoint` | `str` |  |
| `bucket` | `str` |  |
| `access_key_id` | `str` |  |
| `secret_access_key` | `str` |  |
| `session_token` | `str | None` |  |
| `region` | `str` |  |
| `read_only` | `bool` |  |
| `expires_at` | `Any` |  |
| `raw` | `dict[str, Any]` | The response JSON exactly as the API sent it. |
