# Buckets

## Create Bucket

`$ nirvana storage:buckets create`

**post** `/v1/storage/buckets`

Create a Bucket. The Bucket is created asynchronously: follow the returned operation until it is done.

### Parameters

- `--name: string`

  Name of the Bucket, used to address it over S3. It must be 3 to 63
  characters of lowercase letters, digits, dots and hyphens, start and end
  with a letter or digit, not contain two adjacent dots and not be formatted
  as an IP address. "admin" and "ops-api" are reserved. The name cannot be
  changed once the Bucket is created.

- `--project-id: string`

  Project ID the Bucket belongs to.

- `--region: "us-sva-2" or "us-wdc-1"`

  Region the resource is in.

- `--tag: optional array of string`

  Tags to attach to the Bucket.

### Returns

- `operation: object { id, created_at, details, 6 more }`

  Operation details.

  - `id: string`

    Unique identifier for the Operation.

  - `created_at: string`

    When the Operation was created.

  - `details: object { changes }`

    Structured details about what an operation is changing.

    - `changes: map[OperationFieldDiff]`

      Map of changed field names to their from/to diffs. Keys depend on the parent operation's kind+type.

      - `from: string or number or boolean or array of string`

        Previous value.

        - `union_member_0: string`

        - `union_member_1: number`

        - `union_member_2: boolean`

        - `union_member_3: array of string`

      - `to: string or number or boolean or array of string`

        New value.

        - `union_member_0: string`

        - `union_member_1: number`

        - `union_member_2: boolean`

        - `union_member_3: array of string`

  - `kind: "vm" or "volume" or "vpc" or 5 more`

    Kind of Operation.

    - `"vm"`

    - `"volume"`

    - `"vpc"`

    - `"firewall_rule"`

    - `"nks_cluster"`

    - `"nks_node_pool"`

    - `"sandbox_cluster"`

    - `"bucket"`

  - `project_id: string`

    Project ID the Operation belongs to.

  - `resource_id: string`

    ID of the resource that the Operation is acting on.

  - `status: "pending" or "running" or "done" or 2 more`

    Status of the Operation.

    - `"pending"`

    - `"running"`

    - `"done"`

    - `"failed"`

    - `"unknown"`

  - `type: "create" or "update" or "delete" or "restart"`

    Type of Operation.

    - `"create"`

    - `"update"`

    - `"delete"`

    - `"restart"`

  - `updated_at: string`

    When the Operation was updated.

### Example

```cli
nirvana storage:buckets create \
  --api-key 'My API Key' \
  --name my-bucket \
  --project-id 123e4567-e89b-12d3-a456-426614174000 \
  --region us-sva-2
```

#### Response

```json
{
  "id": "123e4567-e89b-12d3-a456-426614174000",
  "created_at": "2025-01-01T00:00:00Z",
  "details": {
    "changes": {
      "foo": {
        "from": "string",
        "to": "string"
      }
    }
  },
  "kind": "vm",
  "project_id": "123e4567-e89b-12d3-a456-426614174000",
  "resource_id": "123e4567-e89b-12d3-a456-426614174000",
  "status": "pending",
  "type": "create",
  "updated_at": "2025-01-01T00:00:00Z"
}
```

## Get Bucket Details

`$ nirvana storage:buckets get`

**get** `/v1/storage/buckets/{bucket_id}`

Get details about a Bucket

### Parameters

- `--bucket-id: string`

  Bucket ID

### Returns

- `bucket: object { id, created_at, endpoint, 10 more }`

  Bucket details.

  - `id: string`

    Unique identifier for the Bucket.

  - `created_at: string`

    When the Bucket was created.

  - `endpoint: string`

    S3 endpoint of the Bucket's region. Point S3 clients at it, with an Object
    Storage Key of the same project and region.

  - `name: string`

    Name of the Bucket, used to address it over S3.

  - `object_count: number`

    Number of objects in the Bucket. Updated periodically, so it can lag behind
    recent writes.

  - `project_id: string`

    Project ID the Bucket belongs to.

  - `region: "us-sva-2" or "us-wdc-1"`

    Region the resource is in.

    - `"us-sva-2"`

    - `"us-wdc-1"`

  - `signing_region: string`

    Region S3 clients must sign their requests for (the SigV4 region). Configure
    it as the region of any S3 client or SDK used with the Bucket.

  - `size_bytes: number`

    Total size of the objects in the Bucket, in bytes. Updated periodically,
    so it can lag behind recent writes.

  - `status: "pending" or "creating" or "updating" or 5 more`

    Status of the resource.

    - `"pending"`

    - `"creating"`

    - `"updating"`

    - `"ready"`

    - `"deleting"`

    - `"deleted"`

    - `"error"`

    - `"suspended"`

  - `tags: array of string`

    Tags attached to the Bucket.

  - `updated_at: string`

    When the Bucket was updated.

  - `url: string`

    Path-style URL of the Bucket.

### Example

```cli
nirvana storage:buckets get \
  --api-key 'My API Key' \
  --bucket-id bucket_id
```

#### Response

```json
{
  "id": "123e4567-e89b-12d3-a456-426614174000",
  "created_at": "2025-01-01T00:00:00Z",
  "endpoint": "https://s3.sva2.nirvanacloud.io",
  "name": "my-bucket",
  "object_count": 1024,
  "project_id": "123e4567-e89b-12d3-a456-426614174000",
  "region": "us-sva-2",
  "signing_region": "us-east-1",
  "size_bytes": 1073741824,
  "status": "ready",
  "tags": [
    "production",
    "ethereum"
  ],
  "updated_at": "2025-01-01T00:00:00Z",
  "url": "https://s3.sva2.nirvanacloud.io/my-bucket"
}
```

## Update Bucket

`$ nirvana storage:buckets update`

**patch** `/v1/storage/buckets/{bucket_id}`

Update a Bucket's tags. A Bucket's name is its S3 name and cannot be changed.

### Parameters

- `--bucket-id: string`

  Bucket ID

- `--tag: optional array of string`

  Tags to attach to the Bucket.

### Returns

- `bucket: object { id, created_at, endpoint, 10 more }`

  Bucket details.

  - `id: string`

    Unique identifier for the Bucket.

  - `created_at: string`

    When the Bucket was created.

  - `endpoint: string`

    S3 endpoint of the Bucket's region. Point S3 clients at it, with an Object
    Storage Key of the same project and region.

  - `name: string`

    Name of the Bucket, used to address it over S3.

  - `object_count: number`

    Number of objects in the Bucket. Updated periodically, so it can lag behind
    recent writes.

  - `project_id: string`

    Project ID the Bucket belongs to.

  - `region: "us-sva-2" or "us-wdc-1"`

    Region the resource is in.

    - `"us-sva-2"`

    - `"us-wdc-1"`

  - `signing_region: string`

    Region S3 clients must sign their requests for (the SigV4 region). Configure
    it as the region of any S3 client or SDK used with the Bucket.

  - `size_bytes: number`

    Total size of the objects in the Bucket, in bytes. Updated periodically,
    so it can lag behind recent writes.

  - `status: "pending" or "creating" or "updating" or 5 more`

    Status of the resource.

    - `"pending"`

    - `"creating"`

    - `"updating"`

    - `"ready"`

    - `"deleting"`

    - `"deleted"`

    - `"error"`

    - `"suspended"`

  - `tags: array of string`

    Tags attached to the Bucket.

  - `updated_at: string`

    When the Bucket was updated.

  - `url: string`

    Path-style URL of the Bucket.

### Example

```cli
nirvana storage:buckets update \
  --api-key 'My API Key' \
  --bucket-id bucket_id
```

#### Response

```json
{
  "id": "123e4567-e89b-12d3-a456-426614174000",
  "created_at": "2025-01-01T00:00:00Z",
  "endpoint": "https://s3.sva2.nirvanacloud.io",
  "name": "my-bucket",
  "object_count": 1024,
  "project_id": "123e4567-e89b-12d3-a456-426614174000",
  "region": "us-sva-2",
  "signing_region": "us-east-1",
  "size_bytes": 1073741824,
  "status": "ready",
  "tags": [
    "production",
    "ethereum"
  ],
  "updated_at": "2025-01-01T00:00:00Z",
  "url": "https://s3.sva2.nirvanacloud.io/my-bucket"
}
```

## Delete Bucket

`$ nirvana storage:buckets delete`

**delete** `/v1/storage/buckets/{bucket_id}`

Delete a Bucket. The Bucket is deleted asynchronously: follow the returned operation until it is done. A Bucket that still holds objects is only deleted with force: without it, the request is refused with 409 BUCKET_NOT_EMPTY and no operation is started, and objects written after the request is accepted fail the operation instead.

### Parameters

- `--bucket-id: string`

  Bucket ID

- `--force: optional boolean`

  Permanently delete every object in the Bucket, including all versions, before deleting it. Without it, deleting a Bucket that holds objects fails.

### Returns

- `operation: object { id, created_at, details, 6 more }`

  Operation details.

  - `id: string`

    Unique identifier for the Operation.

  - `created_at: string`

    When the Operation was created.

  - `details: object { changes }`

    Structured details about what an operation is changing.

    - `changes: map[OperationFieldDiff]`

      Map of changed field names to their from/to diffs. Keys depend on the parent operation's kind+type.

      - `from: string or number or boolean or array of string`

        Previous value.

        - `union_member_0: string`

        - `union_member_1: number`

        - `union_member_2: boolean`

        - `union_member_3: array of string`

      - `to: string or number or boolean or array of string`

        New value.

        - `union_member_0: string`

        - `union_member_1: number`

        - `union_member_2: boolean`

        - `union_member_3: array of string`

  - `kind: "vm" or "volume" or "vpc" or 5 more`

    Kind of Operation.

    - `"vm"`

    - `"volume"`

    - `"vpc"`

    - `"firewall_rule"`

    - `"nks_cluster"`

    - `"nks_node_pool"`

    - `"sandbox_cluster"`

    - `"bucket"`

  - `project_id: string`

    Project ID the Operation belongs to.

  - `resource_id: string`

    ID of the resource that the Operation is acting on.

  - `status: "pending" or "running" or "done" or 2 more`

    Status of the Operation.

    - `"pending"`

    - `"running"`

    - `"done"`

    - `"failed"`

    - `"unknown"`

  - `type: "create" or "update" or "delete" or "restart"`

    Type of Operation.

    - `"create"`

    - `"update"`

    - `"delete"`

    - `"restart"`

  - `updated_at: string`

    When the Operation was updated.

### Example

```cli
nirvana storage:buckets delete \
  --api-key 'My API Key' \
  --bucket-id bucket_id
```

#### Response

```json
{
  "id": "123e4567-e89b-12d3-a456-426614174000",
  "created_at": "2025-01-01T00:00:00Z",
  "details": {
    "changes": {
      "foo": {
        "from": "string",
        "to": "string"
      }
    }
  },
  "kind": "vm",
  "project_id": "123e4567-e89b-12d3-a456-426614174000",
  "resource_id": "123e4567-e89b-12d3-a456-426614174000",
  "status": "pending",
  "type": "create",
  "updated_at": "2025-01-01T00:00:00Z"
}
```

## List Buckets

`$ nirvana storage:buckets list`

**get** `/v1/storage/buckets`

List all Buckets

### Parameters

- `--project-id: string`

  Project ID of resources to request

- `--cursor: optional string`

  Pagination cursor returned by a previous request. Only valid for the same filters and sort order.

- `--limit: optional number`

  Maximum number of items to return

- `--name: optional string`

  Filter by a case-insensitive substring of the Bucket name

- `--region: optional string`

  Filter by region

- `--sort: optional string`

  Comma-separated sort terms in precedence order, each field:asc or field:desc. Fields: created_at, updated_at, name, status, size_bytes, object_count

- `--status: optional "pending" or "creating" or "updating" or 3 more`

  Filter by Bucket status

- `--tag: optional array of string`

  Filter by tags. Repeat the parameter to require several tags; a Bucket must carry all of them.

### Returns

- `bucket_list: object { items, pagination }`

  - `items: array of Bucket`

    - `id: string`

      Unique identifier for the Bucket.

    - `created_at: string`

      When the Bucket was created.

    - `endpoint: string`

      S3 endpoint of the Bucket's region. Point S3 clients at it, with an Object
      Storage Key of the same project and region.

    - `name: string`

      Name of the Bucket, used to address it over S3.

    - `object_count: number`

      Number of objects in the Bucket. Updated periodically, so it can lag behind
      recent writes.

    - `project_id: string`

      Project ID the Bucket belongs to.

    - `region: "us-sva-2" or "us-wdc-1"`

      Region the resource is in.

      - `"us-sva-2"`

      - `"us-wdc-1"`

    - `signing_region: string`

      Region S3 clients must sign their requests for (the SigV4 region). Configure
      it as the region of any S3 client or SDK used with the Bucket.

    - `size_bytes: number`

      Total size of the objects in the Bucket, in bytes. Updated periodically,
      so it can lag behind recent writes.

    - `status: "pending" or "creating" or "updating" or 5 more`

      Status of the resource.

      - `"pending"`

      - `"creating"`

      - `"updating"`

      - `"ready"`

      - `"deleting"`

      - `"deleted"`

      - `"error"`

      - `"suspended"`

    - `tags: array of string`

      Tags attached to the Bucket.

    - `updated_at: string`

      When the Bucket was updated.

    - `url: string`

      Path-style URL of the Bucket.

  - `pagination: object { next_cursor, previous_cursor, total_count }`

    Pagination response details.

    - `next_cursor: string`

    - `previous_cursor: string`

    - `total_count: number`

### Example

```cli
nirvana storage:buckets list \
  --api-key 'My API Key' \
  --project-id project_id
```

#### Response

```json
{
  "items": [
    {
      "id": "123e4567-e89b-12d3-a456-426614174000",
      "created_at": "2025-01-01T00:00:00Z",
      "endpoint": "https://s3.sva2.nirvanacloud.io",
      "name": "my-bucket",
      "object_count": 1024,
      "project_id": "123e4567-e89b-12d3-a456-426614174000",
      "region": "us-sva-2",
      "signing_region": "us-east-1",
      "size_bytes": 1073741824,
      "status": "ready",
      "tags": [
        "production",
        "ethereum"
      ],
      "updated_at": "2025-01-01T00:00:00Z",
      "url": "https://s3.sva2.nirvanacloud.io/my-bucket"
    }
  ],
  "pagination": {
    "next_cursor": "RhwniMT4B74siYZcPF8TnCdGI1l9rpPvg",
    "previous_cursor": "ARhwnmi1hA7wEbHbMjdYQlOB_ZusP4fYvw",
    "total_count": 125
  }
}
```

## Domain Types

### Bucket

- `bucket: object { id, created_at, endpoint, 10 more }`

  Bucket details.

  - `id: string`

    Unique identifier for the Bucket.

  - `created_at: string`

    When the Bucket was created.

  - `endpoint: string`

    S3 endpoint of the Bucket's region. Point S3 clients at it, with an Object
    Storage Key of the same project and region.

  - `name: string`

    Name of the Bucket, used to address it over S3.

  - `object_count: number`

    Number of objects in the Bucket. Updated periodically, so it can lag behind
    recent writes.

  - `project_id: string`

    Project ID the Bucket belongs to.

  - `region: "us-sva-2" or "us-wdc-1"`

    Region the resource is in.

    - `"us-sva-2"`

    - `"us-wdc-1"`

  - `signing_region: string`

    Region S3 clients must sign their requests for (the SigV4 region). Configure
    it as the region of any S3 client or SDK used with the Bucket.

  - `size_bytes: number`

    Total size of the objects in the Bucket, in bytes. Updated periodically,
    so it can lag behind recent writes.

  - `status: "pending" or "creating" or "updating" or 5 more`

    Status of the resource.

    - `"pending"`

    - `"creating"`

    - `"updating"`

    - `"ready"`

    - `"deleting"`

    - `"deleted"`

    - `"error"`

    - `"suspended"`

  - `tags: array of string`

    Tags attached to the Bucket.

  - `updated_at: string`

    When the Bucket was updated.

  - `url: string`

    Path-style URL of the Bucket.

### Bucket List

- `bucket_list: object { items, pagination }`

  - `items: array of Bucket`

    - `id: string`

      Unique identifier for the Bucket.

    - `created_at: string`

      When the Bucket was created.

    - `endpoint: string`

      S3 endpoint of the Bucket's region. Point S3 clients at it, with an Object
      Storage Key of the same project and region.

    - `name: string`

      Name of the Bucket, used to address it over S3.

    - `object_count: number`

      Number of objects in the Bucket. Updated periodically, so it can lag behind
      recent writes.

    - `project_id: string`

      Project ID the Bucket belongs to.

    - `region: "us-sva-2" or "us-wdc-1"`

      Region the resource is in.

      - `"us-sva-2"`

      - `"us-wdc-1"`

    - `signing_region: string`

      Region S3 clients must sign their requests for (the SigV4 region). Configure
      it as the region of any S3 client or SDK used with the Bucket.

    - `size_bytes: number`

      Total size of the objects in the Bucket, in bytes. Updated periodically,
      so it can lag behind recent writes.

    - `status: "pending" or "creating" or "updating" or 5 more`

      Status of the resource.

      - `"pending"`

      - `"creating"`

      - `"updating"`

      - `"ready"`

      - `"deleting"`

      - `"deleted"`

      - `"error"`

      - `"suspended"`

    - `tags: array of string`

      Tags attached to the Bucket.

    - `updated_at: string`

      When the Bucket was updated.

    - `url: string`

      Path-style URL of the Bucket.

  - `pagination: object { next_cursor, previous_cursor, total_count }`

    Pagination response details.

    - `next_cursor: string`

    - `previous_cursor: string`

    - `total_count: number`

# Availability

## Check Create Bucket Availability

`$ nirvana storage:buckets:availability create`

**post** `/v1/storage/buckets/availability`

Check if a Bucket can be created

### Parameters

- `--name: string`

  Name of the Bucket, used to address it over S3. It must be 3 to 63
  characters of lowercase letters, digits, dots and hyphens, start and end
  with a letter or digit, not contain two adjacent dots and not be formatted
  as an IP address. "admin" and "ops-api" are reserved. The name cannot be
  changed once the Bucket is created.

- `--project-id: string`

  Project ID the Bucket belongs to.

- `--region: "us-sva-2" or "us-wdc-1"`

  Region the resource is in.

- `--tag: optional array of string`

  Tags to attach to the Bucket.

### Example

```cli
nirvana storage:buckets:availability create \
  --api-key 'My API Key' \
  --name my-bucket \
  --project-id 123e4567-e89b-12d3-a456-426614174000 \
  --region us-sva-2
```

# Cost

## Estimate Bucket Create Cost

`$ nirvana storage:buckets:cost create`

**post** `/v1/storage/buckets/cost`

Return a priced monthly cost quote for the proposed Bucket storing size_gb of data. A Bucket is charged per GB it stores, prorated by the hour.

### Parameters

- `--name: string`

  Name of the Bucket, used to address it over S3. It must be 3 to 63
  characters of lowercase letters, digits, dots and hyphens, start and end
  with a letter or digit, not contain two adjacent dots and not be formatted
  as an IP address. "admin" and "ops-api" are reserved. The name cannot be
  changed once the Bucket is created.

- `--project-id: string`

  Project ID the Bucket belongs to.

- `--region: "us-sva-2" or "us-wdc-1"`

  Region the resource is in.

- `--size-gb: optional number`

  Amount of data to price the Bucket at storing, in GB (1 GB = 10^9 bytes).
  A Bucket is charged for what it stores, so a quote without it is empty.

- `--tag: optional array of string`

  Tags to attach to the Bucket.

### Returns

- `cost_quote: object { currency, monthly_total, priced_at, 3 more }`

  Cost quote returned by POST /cost. current_summary and updated_summary hold the org billing summary now and with this resource; omitted when the caller cannot view billing.

  - `currency: string`

    Currency the quote is denominated in. Always "USD" in v1.

  - `monthly_total: string`

    Arbitrary-precision decimal serialized as a string (e.g. "58.40").

  - `priced_at: string`

    Timestamp the quote was priced at.

  - `usage_dimensions: array of object { dimension, dimension_display_name, monthly_amount, 2 more }`

    Priced rows, one per usage dimension emitted by the resource.

    - `dimension: string`

      Usage dimension being priced (e.g. compute_vcpu, storage_abs_gb).

    - `dimension_display_name: string`

      User-facing label for the dimension (e.g. "vCPU (hours)").

    - `monthly_amount: string`

      Arbitrary-precision decimal serialized as a string (e.g. "58.40").

    - `quantity: number`

      Quantity of the dimension being priced.

    - `unit_price: string`

      Arbitrary-precision decimal serialized as a string (e.g. "58.40").

  - `current_summary: optional object { daily_cost, effective_balance, monthly_cost, 3 more }`

    Forward-looking billing summary for an organization. All costs are run-rate projections from the organization's current active usage ("≈ $X/mo at current usage").

    - `daily_cost: string`

      Arbitrary-precision decimal serialized as a string (e.g. "58.40").

    - `effective_balance: string`

      Arbitrary-precision decimal serialized as a string (e.g. "58.40").

    - `monthly_cost: string`

      Arbitrary-precision decimal serialized as a string (e.g. "58.40").

    - `recharge_threshold_days: string`

      Arbitrary-precision decimal serialized as a string (e.g. "58.40").

    - `estimated_next_charge_at: optional string`

      Projected date the balance reaches the recharge threshold at the current run-rate. Null when there is no active usage (never charges).

    - `runway_months: optional string`

      Arbitrary-precision decimal serialized as a string (e.g. "58.40").

  - `updated_summary: optional object { daily_cost, effective_balance, monthly_cost, 3 more }`

    Forward-looking billing summary for an organization. All costs are run-rate projections from the organization's current active usage ("≈ $X/mo at current usage").

    - `daily_cost: string`

      Arbitrary-precision decimal serialized as a string (e.g. "58.40").

    - `effective_balance: string`

      Arbitrary-precision decimal serialized as a string (e.g. "58.40").

    - `monthly_cost: string`

      Arbitrary-precision decimal serialized as a string (e.g. "58.40").

    - `recharge_threshold_days: string`

      Arbitrary-precision decimal serialized as a string (e.g. "58.40").

    - `estimated_next_charge_at: optional string`

      Projected date the balance reaches the recharge threshold at the current run-rate. Null when there is no active usage (never charges).

    - `runway_months: optional string`

      Arbitrary-precision decimal serialized as a string (e.g. "58.40").

### Example

```cli
nirvana storage:buckets:cost create \
  --api-key 'My API Key' \
  --name my-bucket \
  --project-id 123e4567-e89b-12d3-a456-426614174000 \
  --region us-sva-2
```

#### Response

```json
{
  "currency": "USD",
  "monthly_total": "-69125",
  "priced_at": "2025-01-01T00:00:00Z",
  "usage_dimensions": [
    {
      "dimension": "compute_vcpu",
      "dimension_display_name": "vCPU (hours)",
      "monthly_amount": "-69125",
      "quantity": 4,
      "unit_price": "-69125"
    }
  ],
  "current_summary": {
    "daily_cost": "-69125",
    "effective_balance": "-69125",
    "monthly_cost": "-69125",
    "recharge_threshold_days": "-69125",
    "estimated_next_charge_at": "2025-01-01T00:00:00Z",
    "runway_months": "-69125"
  },
  "updated_summary": {
    "daily_cost": "-69125",
    "effective_balance": "-69125",
    "monthly_cost": "-69125",
    "recharge_threshold_days": "-69125",
    "estimated_next_charge_at": "2025-01-01T00:00:00Z",
    "runway_months": "-69125"
  }
}
```
