Buckets
The routes that create, read, replace, list, and delete buckets.
A bucket holds streams and the defaults every new stream in it starts
from. These routes manage buckets. Each route is also a method of the gRPC
service nova.v1.DataPlaneService.
Buckets
What a bucket holds, and its defaults
Create and manage with an SDK
Buckets and streams in Go and TypeScript
Bucket commands
The same operations from the nova CLI
| Operation | HTTP | gRPC |
|---|---|---|
| Create | POST /v1/buckets/{bucket} | CreateBucket |
| Get | GET /v1/buckets/{bucket} | GetBucket |
| Replace | PUT /v1/buckets/{bucket} | UpdateBucket |
| List | GET /v1/buckets | ListBuckets |
| Delete | DELETE /v1/buckets/{bucket} | DeleteBucket |
The examples use the quickstart cluster's Gateway at
localhost:8080. A bucket name is 3 to 63 bytes of lowercase letters, digits,
and hyphens, and starts and ends with a letter or digit, because it can become
part of a hostname.
The bucket object
{
"name": "demo",
"location": "local",
"create_stream_on_append": true,
"create_stream_on_read": false,
"default_class": "standard",
"default_producer_policy": "any",
"default_retention_max_age_ms": 604800000,
"default_timestamping_mode": "client-prefer",
"created_at_unix_ms": 1795371166076
}The default_ fields are the bucket's defaults: every stream created in
the bucket copies them at creation, for each field its create leaves out. The
stream fields say what each one does. The JSON
leaves out a field whose value is zero, false, or empty.
Over gRPC the object is Bucket, with the same fields, the enums of the
stream object, and deleted_at_unix_ms.
Create a bucket
POST /v1/buckets/{bucket}gRPC: DataPlaneService.CreateBucket. Creates a bucket and returns it with
201. The body takes every field of the bucket object except the
name and the creation time. A field you leave out takes Nova's default:
standard, any, client-prefer, no limits, and both create flags off. An
empty body is enough.
curl -s -X POST localhost:8080/v1/buckets/demo -d '{
"create_stream_on_append": true,
"default_retention_max_age_ms": 604800000
}'{
"name": "demo",
"location": "local",
"create_stream_on_append": true,
"create_stream_on_read": false,
"default_class": "standard",
"default_producer_policy": "any",
"default_retention_max_age_ms": 604800000,
"default_timestamping_mode": "client-prefer",
"created_at_unix_ms": 1795371166076
}location is a check: a bucket lives in its cluster's location, and a create
that names another one fails. A create retried with the same
creation_token returns 201 and the bucket the first attempt made. Without a
token, a second create fails with 409.
| Status | When | Retry |
|---|---|---|
| 400 | A body that is not valid JSON, an unknown enum value, a body name other than the path's, or a location other than the cluster's | No. Fix the request |
| 409 | The bucket exists | Only with the first attempt's creation_token |
| 500 | A name that breaks the naming rule. The node reports it as 500 today | No. Fix the name |
Get a bucket
GET /v1/buckets/{bucket}gRPC: DataPlaneService.GetBucket. Returns the bucket object.
curl -s localhost:8080/v1/buckets/demo| Status | When | Retry |
|---|---|---|
| 404 | No bucket by that name | No |
Replace a bucket's settings
PUT /v1/buckets/{bucket}gRPC: DataPlaneService.UpdateBucket. Replaces every setting and returns the
bucket as it now stands. A field you leave out takes Nova's default again, as
on a create:
curl -s -X PUT localhost:8080/v1/buckets/demo -d '{
"create_stream_on_read": true
}'{
"name": "demo",
"location": "local",
"create_stream_on_append": false,
"create_stream_on_read": true,
"default_class": "standard",
"default_producer_policy": "any",
"default_timestamping_mode": "client-prefer",
"created_at_unix_ms": 1795371166076
}This request turned off create_stream_on_append and dropped the 7-day
retention default, because it did not repeat them. To change one setting, get
the bucket, change the field, and send the whole object back.
The create flags apply to the next request at once. The defaults apply to
streams created afterwards; existing streams keep the settings they were
created with. The same 400 and 404 cases as above apply.
List buckets
GET /v1/bucketsgRPC: DataPlaneService.ListBuckets. Returns one page of buckets in name
order.
curl -s 'localhost:8080/v1/buckets?limit=1'{
"buckets": [
{
"name": "apps",
"location": "local",
"create_stream_on_append": false,
"create_stream_on_read": false,
"default_class": "standard",
"default_producer_policy": "any",
"default_timestamping_mode": "client-prefer",
"created_at_unix_ms": 1795371166252,
"creation_token": "apps-1"
}
],
"next": "apps"
}Pass next as start_after for the following page. A response without
next is the last page. With name_prefix, the response also returns the
prefix it applied as name_prefix.
| Status | When | Retry |
|---|---|---|
| 403 | The token's list grant does not cover every bucket the prefix names | No |
Listing buckets needs a list grant on every bucket the prefix names: with no
prefix, a grant on all buckets, or the admin grant. A token narrowed to one
bucket cannot list buckets.
Delete a bucket
DELETE /v1/buckets/{bucket}gRPC: DataPlaneService.DeleteBucket. Deletes an empty bucket and returns
204. Delete its streams and queues first; a bucket that still holds one is
refused. A stream you just deleted still counts for a few minutes, until Nova
has reclaimed its storage:
curl -s -X DELETE localhost:8080/v1/buckets/demo{
"error": "metadata: delete bucket \"demo\": metadata: bucket not empty"
}| Status | When | Retry |
|---|---|---|
| 404 | No bucket by that name | No |
| 503 | The bucket still holds a stream or a queue | Not until it is empty. The Retry-After header does not apply here |
Over gRPC, a non-empty bucket is FailedPrecondition. Create and replace need
the create grant on the whole bucket, and delete needs the delete grant.
Statuses every route shares are on Errors.