Buckets

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.

OperationHTTPgRPC
CreatePOST /v1/buckets/{bucket}CreateBucket
GetGET /v1/buckets/{bucket}GetBucket
ReplacePUT /v1/buckets/{bucket}UpdateBucket
ListGET /v1/bucketsListBuckets
DeleteDELETE /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
}
namestring
The bucket's name, taken from the path
locationstring
The cluster's location, local unless novad --location sets one
create_stream_on_appendboolean
An append to a stream that does not exist creates it
create_stream_on_readboolean
A read or a subscription of a stream that does not exist creates it, empty
default_classstring
standard or express
default_producer_policystring
any or fenced
default_retention_max_age_msinteger
Trim records older than this; 0 for no age limit
default_retention_max_bytesinteger
Trim the oldest records past this size; 0 for no size limit
default_throughput_max_bytes_per_secondinteger
Slow appends down past this rate; 0 for no limit
default_timestamping_modestring
client-prefer, client-require, or arrival
default_timestamping_uncappedboolean
Let client stamps run past the arrival time
created_at_unix_msinteger
When the bucket was created
creation_tokenstring
The token the bucket was created with, if any

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
}'
201 Created
{
  "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.

StatusWhenRetry
400A 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'sNo. Fix the request
409The bucket existsOnly with the first attempt's creation_token
500A name that breaks the naming rule. The node reports it as 500 todayNo. Fix the name

Get a bucket

GET /v1/buckets/{bucket}

gRPC: DataPlaneService.GetBucket. Returns the bucket object.

curl -s localhost:8080/v1/buckets/demo
StatusWhenRetry
404No bucket by that nameNo

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
}'
200 OK
{
  "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/buckets

gRPC: DataPlaneService.ListBuckets. Returns one page of buckets in name order.

name_prefixstringDefaultNone
Only buckets whose name starts with this
limitintegerDefault1,000
The most buckets on the page, at most 1,000
start_afterstringDefaultNone
The next of the page before: the last name it returned
curl -s 'localhost:8080/v1/buckets?limit=1'
200 OK
{
  "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.

StatusWhenRetry
403The token's list grant does not cover every bucket the prefix namesNo

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
503 Service Unavailable
{
  "error": "metadata: delete bucket \"demo\": metadata: bucket not empty"
}
StatusWhenRetry
404No bucket by that nameNo
503The bucket still holds a stream or a queueNot 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.

On this page