# Volumes

## Create Volume

`client.compute.volumes.create(VolumeCreateParamsbody, RequestOptionsoptions?): Operation`

**post** `/v1/compute/volumes`

Create a Volume. Only data volumes can be created.

### Parameters

- `body: VolumeCreateParams`

  - `name: string`

    Name of the Volume.

  - `project_id: string`

    Project ID the Volume belongs to.

  - `region: RegionName`

    Region the resource is in.

    - `"us-sva-2"`

  - `size: number`

    Size of the Volume in GB.

  - `type: VolumeType`

    Type of the Volume.

    - `"nvme"`

    - `"abs"`

  - `tags?: Array<string>`

    Tags to attach to the Volume.

  - `vm_id?: string`

    ID of the VM the Volume is attached to.

### Returns

- `Operation`

  Operation details.

  - `id: string`

    Unique identifier for the Operation.

  - `created_at: string`

    When the Operation was created.

  - `details: OperationDetails | null`

    Structured details about what an operation is changing.

    - `changes: OperationChanges`

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

      - `from: string | number | boolean | Array<string>`

        Previous value.

        - `string`

        - `number`

        - `boolean`

        - `Array<string>`

      - `to: string | number | boolean | Array<string>`

        New value.

        - `string`

        - `number`

        - `boolean`

        - `Array<string>`

  - `kind: OperationKind`

    Kind of Operation.

    - `"vm"`

    - `"volume"`

    - `"vpc"`

    - `"firewall_rule"`

    - `"nks_cluster"`

    - `"nks_node_pool"`

  - `project_id: string`

    Project ID the Operation belongs to.

  - `resource_id: string`

    ID of the resource that the Operation is acting on.

  - `status: OperationStatus`

    Status of the Operation.

    - `"pending"`

    - `"running"`

    - `"done"`

    - `"failed"`

    - `"unknown"`

  - `type: OperationType`

    Type of Operation.

    - `"create"`

    - `"update"`

    - `"delete"`

    - `"restart"`

  - `updated_at: string`

    When the Operation was updated.

### Example

```typescript
import NirvanaLabs from '@nirvana-labs/nirvana';

const client = new NirvanaLabs({
  apiKey: process.env['NIRVANA_LABS_API_KEY'], // This is the default and can be omitted
});

const operation = await client.compute.volumes.create({
  name: 'my-data-volume',
  project_id: '123e4567-e89b-12d3-a456-426614174000',
  region: 'us-sva-2',
  size: 100,
  type: 'abs',
});

console.log(operation.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"
}
```

## Get Volume

`client.compute.volumes.get(stringvolumeID, RequestOptionsoptions?): Volume`

**get** `/v1/compute/volumes/{volume_id}`

Get a Volume.

### Parameters

- `volumeID: string`

### Returns

- `Volume`

  Volume details.

  - `id: string`

    Unique identifier for the Volume.

  - `created_at: string`

    When the Volume was created.

  - `kind: VolumeKind`

    Volume kind.

    - `"boot"`

    - `"data"`

  - `name: string`

    Name of the Volume.

  - `project_id: string`

    Project ID the Volume belongs to.

  - `region: RegionName`

    Region the resource is in.

    - `"us-sva-2"`

  - `size: number`

    Size of the Volume in GB.

  - `status: ResourceStatus`

    Status of the resource.

    - `"pending"`

    - `"creating"`

    - `"updating"`

    - `"ready"`

    - `"deleting"`

    - `"deleted"`

    - `"error"`

  - `tags: Array<string>`

    Tags to attach to the Volume.

  - `type: VolumeType`

    Type of the Volume.

    - `"nvme"`

    - `"abs"`

  - `updated_at: string`

    When the Volume was updated.

  - `vm_id: string | null`

    ID of the VM the Volume is attached to.

  - `vm_name: string | null`

    Name of the VM the Volume is attached to.

### Example

```typescript
import NirvanaLabs from '@nirvana-labs/nirvana';

const client = new NirvanaLabs({
  apiKey: process.env['NIRVANA_LABS_API_KEY'], // This is the default and can be omitted
});

const volume = await client.compute.volumes.get('volume_id');

console.log(volume.id);
```

#### Response

```json
{
  "id": "123e4567-e89b-12d3-a456-426614174000",
  "created_at": "2025-01-01T00:00:00Z",
  "kind": "boot",
  "name": "my-volume",
  "project_id": "123e4567-e89b-12d3-a456-426614174000",
  "region": "us-sva-2",
  "size": 100,
  "status": "ready",
  "tags": [
    "production",
    "ethereum"
  ],
  "type": "abs",
  "updated_at": "2025-01-01T00:00:00Z",
  "vm_id": "123e4567-e89b-12d3-a456-426614174000",
  "vm_name": "my-vm"
}
```

## Update Volume

`client.compute.volumes.update(stringvolumeID, VolumeUpdateParamsbody, RequestOptionsoptions?): Operation`

**patch** `/v1/compute/volumes/{volume_id}`

Update a Volume. Boot or data volumes can be updated.

### Parameters

- `volumeID: string`

- `body: VolumeUpdateParams`

  - `name?: string`

    Name of the Volume.

  - `size?: number`

    Size of the Volume in GB.

  - `tags?: Array<string>`

    Tags to attach to the Volume.

### Returns

- `Operation`

  Operation details.

  - `id: string`

    Unique identifier for the Operation.

  - `created_at: string`

    When the Operation was created.

  - `details: OperationDetails | null`

    Structured details about what an operation is changing.

    - `changes: OperationChanges`

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

      - `from: string | number | boolean | Array<string>`

        Previous value.

        - `string`

        - `number`

        - `boolean`

        - `Array<string>`

      - `to: string | number | boolean | Array<string>`

        New value.

        - `string`

        - `number`

        - `boolean`

        - `Array<string>`

  - `kind: OperationKind`

    Kind of Operation.

    - `"vm"`

    - `"volume"`

    - `"vpc"`

    - `"firewall_rule"`

    - `"nks_cluster"`

    - `"nks_node_pool"`

  - `project_id: string`

    Project ID the Operation belongs to.

  - `resource_id: string`

    ID of the resource that the Operation is acting on.

  - `status: OperationStatus`

    Status of the Operation.

    - `"pending"`

    - `"running"`

    - `"done"`

    - `"failed"`

    - `"unknown"`

  - `type: OperationType`

    Type of Operation.

    - `"create"`

    - `"update"`

    - `"delete"`

    - `"restart"`

  - `updated_at: string`

    When the Operation was updated.

### Example

```typescript
import NirvanaLabs from '@nirvana-labs/nirvana';

const client = new NirvanaLabs({
  apiKey: process.env['NIRVANA_LABS_API_KEY'], // This is the default and can be omitted
});

const operation = await client.compute.volumes.update('volume_id');

console.log(operation.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"
}
```

## Delete Volume

`client.compute.volumes.delete(stringvolumeID, RequestOptionsoptions?): Operation`

**delete** `/v1/compute/volumes/{volume_id}`

Delete a Volume. Boot or data volumes can be deleted.

### Parameters

- `volumeID: string`

### Returns

- `Operation`

  Operation details.

  - `id: string`

    Unique identifier for the Operation.

  - `created_at: string`

    When the Operation was created.

  - `details: OperationDetails | null`

    Structured details about what an operation is changing.

    - `changes: OperationChanges`

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

      - `from: string | number | boolean | Array<string>`

        Previous value.

        - `string`

        - `number`

        - `boolean`

        - `Array<string>`

      - `to: string | number | boolean | Array<string>`

        New value.

        - `string`

        - `number`

        - `boolean`

        - `Array<string>`

  - `kind: OperationKind`

    Kind of Operation.

    - `"vm"`

    - `"volume"`

    - `"vpc"`

    - `"firewall_rule"`

    - `"nks_cluster"`

    - `"nks_node_pool"`

  - `project_id: string`

    Project ID the Operation belongs to.

  - `resource_id: string`

    ID of the resource that the Operation is acting on.

  - `status: OperationStatus`

    Status of the Operation.

    - `"pending"`

    - `"running"`

    - `"done"`

    - `"failed"`

    - `"unknown"`

  - `type: OperationType`

    Type of Operation.

    - `"create"`

    - `"update"`

    - `"delete"`

    - `"restart"`

  - `updated_at: string`

    When the Operation was updated.

### Example

```typescript
import NirvanaLabs from '@nirvana-labs/nirvana';

const client = new NirvanaLabs({
  apiKey: process.env['NIRVANA_LABS_API_KEY'], // This is the default and can be omitted
});

const operation = await client.compute.volumes.delete('volume_id');

console.log(operation.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 Volumes

`client.compute.volumes.list(VolumeListParamsquery, RequestOptionsoptions?): Cursor<Volume>`

**get** `/v1/compute/volumes`

List all volumes

### Parameters

- `query: VolumeListParams`

  - `project_id: string`

    Project ID of resources to request

  - `cursor?: string`

    Pagination cursor returned by a previous request

  - `limit?: number`

    Maximum number of items to return

### Returns

- `Volume`

  Volume details.

  - `id: string`

    Unique identifier for the Volume.

  - `created_at: string`

    When the Volume was created.

  - `kind: VolumeKind`

    Volume kind.

    - `"boot"`

    - `"data"`

  - `name: string`

    Name of the Volume.

  - `project_id: string`

    Project ID the Volume belongs to.

  - `region: RegionName`

    Region the resource is in.

    - `"us-sva-2"`

  - `size: number`

    Size of the Volume in GB.

  - `status: ResourceStatus`

    Status of the resource.

    - `"pending"`

    - `"creating"`

    - `"updating"`

    - `"ready"`

    - `"deleting"`

    - `"deleted"`

    - `"error"`

  - `tags: Array<string>`

    Tags to attach to the Volume.

  - `type: VolumeType`

    Type of the Volume.

    - `"nvme"`

    - `"abs"`

  - `updated_at: string`

    When the Volume was updated.

  - `vm_id: string | null`

    ID of the VM the Volume is attached to.

  - `vm_name: string | null`

    Name of the VM the Volume is attached to.

### Example

```typescript
import NirvanaLabs from '@nirvana-labs/nirvana';

const client = new NirvanaLabs({
  apiKey: process.env['NIRVANA_LABS_API_KEY'], // This is the default and can be omitted
});

// Automatically fetches more pages as needed.
for await (const volume of client.compute.volumes.list({ project_id: 'project_id' })) {
  console.log(volume.id);
}
```

#### Response

```json
{
  "items": [
    {
      "id": "123e4567-e89b-12d3-a456-426614174000",
      "created_at": "2025-01-01T00:00:00Z",
      "kind": "boot",
      "name": "my-volume",
      "project_id": "123e4567-e89b-12d3-a456-426614174000",
      "region": "us-sva-2",
      "size": 100,
      "status": "ready",
      "tags": [
        "production",
        "ethereum"
      ],
      "type": "abs",
      "updated_at": "2025-01-01T00:00:00Z",
      "vm_id": "123e4567-e89b-12d3-a456-426614174000",
      "vm_name": "my-vm"
    }
  ],
  "pagination": {
    "next_cursor": "RhwniMT4B74siYZcPF8TnCdGI1l9rpPvg",
    "previous_cursor": "ARhwnmi1hA7wEbHbMjdYQlOB_ZusP4fYvw",
    "total_count": 125
  }
}
```

## Attach Volume

`client.compute.volumes.attach(stringvolumeID, VolumeAttachParamsbody, RequestOptionsoptions?): Operation`

**post** `/v1/compute/volumes/{volume_id}/attach`

Attach a volume to a VM

### Parameters

- `volumeID: string`

- `body: VolumeAttachParams`

  - `vm_id: string`

    ID of the VM to attach the Volume to.

### Returns

- `Operation`

  Operation details.

  - `id: string`

    Unique identifier for the Operation.

  - `created_at: string`

    When the Operation was created.

  - `details: OperationDetails | null`

    Structured details about what an operation is changing.

    - `changes: OperationChanges`

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

      - `from: string | number | boolean | Array<string>`

        Previous value.

        - `string`

        - `number`

        - `boolean`

        - `Array<string>`

      - `to: string | number | boolean | Array<string>`

        New value.

        - `string`

        - `number`

        - `boolean`

        - `Array<string>`

  - `kind: OperationKind`

    Kind of Operation.

    - `"vm"`

    - `"volume"`

    - `"vpc"`

    - `"firewall_rule"`

    - `"nks_cluster"`

    - `"nks_node_pool"`

  - `project_id: string`

    Project ID the Operation belongs to.

  - `resource_id: string`

    ID of the resource that the Operation is acting on.

  - `status: OperationStatus`

    Status of the Operation.

    - `"pending"`

    - `"running"`

    - `"done"`

    - `"failed"`

    - `"unknown"`

  - `type: OperationType`

    Type of Operation.

    - `"create"`

    - `"update"`

    - `"delete"`

    - `"restart"`

  - `updated_at: string`

    When the Operation was updated.

### Example

```typescript
import NirvanaLabs from '@nirvana-labs/nirvana';

const client = new NirvanaLabs({
  apiKey: process.env['NIRVANA_LABS_API_KEY'], // This is the default and can be omitted
});

const operation = await client.compute.volumes.attach('volume_id', {
  vm_id: '123e4567-e89b-12d3-a456-426614174000',
});

console.log(operation.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"
}
```

## Detach Volume

`client.compute.volumes.detach(stringvolumeID, RequestOptionsoptions?): Operation`

**post** `/v1/compute/volumes/{volume_id}/detach`

Detach a volume from a VM

### Parameters

- `volumeID: string`

### Returns

- `Operation`

  Operation details.

  - `id: string`

    Unique identifier for the Operation.

  - `created_at: string`

    When the Operation was created.

  - `details: OperationDetails | null`

    Structured details about what an operation is changing.

    - `changes: OperationChanges`

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

      - `from: string | number | boolean | Array<string>`

        Previous value.

        - `string`

        - `number`

        - `boolean`

        - `Array<string>`

      - `to: string | number | boolean | Array<string>`

        New value.

        - `string`

        - `number`

        - `boolean`

        - `Array<string>`

  - `kind: OperationKind`

    Kind of Operation.

    - `"vm"`

    - `"volume"`

    - `"vpc"`

    - `"firewall_rule"`

    - `"nks_cluster"`

    - `"nks_node_pool"`

  - `project_id: string`

    Project ID the Operation belongs to.

  - `resource_id: string`

    ID of the resource that the Operation is acting on.

  - `status: OperationStatus`

    Status of the Operation.

    - `"pending"`

    - `"running"`

    - `"done"`

    - `"failed"`

    - `"unknown"`

  - `type: OperationType`

    Type of Operation.

    - `"create"`

    - `"update"`

    - `"delete"`

    - `"restart"`

  - `updated_at: string`

    When the Operation was updated.

### Example

```typescript
import NirvanaLabs from '@nirvana-labs/nirvana';

const client = new NirvanaLabs({
  apiKey: process.env['NIRVANA_LABS_API_KEY'], // This is the default and can be omitted
});

const operation = await client.compute.volumes.detach('volume_id');

console.log(operation.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"
}
```

## Domain Types

### Volume

- `Volume`

  Volume details.

  - `id: string`

    Unique identifier for the Volume.

  - `created_at: string`

    When the Volume was created.

  - `kind: VolumeKind`

    Volume kind.

    - `"boot"`

    - `"data"`

  - `name: string`

    Name of the Volume.

  - `project_id: string`

    Project ID the Volume belongs to.

  - `region: RegionName`

    Region the resource is in.

    - `"us-sva-2"`

  - `size: number`

    Size of the Volume in GB.

  - `status: ResourceStatus`

    Status of the resource.

    - `"pending"`

    - `"creating"`

    - `"updating"`

    - `"ready"`

    - `"deleting"`

    - `"deleted"`

    - `"error"`

  - `tags: Array<string>`

    Tags to attach to the Volume.

  - `type: VolumeType`

    Type of the Volume.

    - `"nvme"`

    - `"abs"`

  - `updated_at: string`

    When the Volume was updated.

  - `vm_id: string | null`

    ID of the VM the Volume is attached to.

  - `vm_name: string | null`

    Name of the VM the Volume is attached to.

### Volume Kind

- `VolumeKind = "boot" | "data"`

  Volume kind.

  - `"boot"`

  - `"data"`

### Volume List

- `VolumeList`

  - `items: Array<Volume>`

    - `id: string`

      Unique identifier for the Volume.

    - `created_at: string`

      When the Volume was created.

    - `kind: VolumeKind`

      Volume kind.

      - `"boot"`

      - `"data"`

    - `name: string`

      Name of the Volume.

    - `project_id: string`

      Project ID the Volume belongs to.

    - `region: RegionName`

      Region the resource is in.

      - `"us-sva-2"`

    - `size: number`

      Size of the Volume in GB.

    - `status: ResourceStatus`

      Status of the resource.

      - `"pending"`

      - `"creating"`

      - `"updating"`

      - `"ready"`

      - `"deleting"`

      - `"deleted"`

      - `"error"`

    - `tags: Array<string>`

      Tags to attach to the Volume.

    - `type: VolumeType`

      Type of the Volume.

      - `"nvme"`

      - `"abs"`

    - `updated_at: string`

      When the Volume was updated.

    - `vm_id: string | null`

      ID of the VM the Volume is attached to.

    - `vm_name: string | null`

      Name of the VM the Volume is attached to.

  - `pagination: Pagination`

    Pagination response details.

    - `next_cursor: string | null`

    - `previous_cursor: string | null`

    - `total_count: number`

### Volume Type

- `VolumeType = "nvme" | "abs"`

  Type of the Volume.

  - `"nvme"`

  - `"abs"`

# Availability

## Check Volume Create Availability

`client.compute.volumes.availability.create(AvailabilityCreateParamsbody, RequestOptionsoptions?): void`

**post** `/v1/compute/volumes/availability`

Check Volume Create Availability

### Parameters

- `body: AvailabilityCreateParams`

  - `name: string`

    Name of the Volume.

  - `project_id: string`

    Project ID the Volume belongs to.

  - `region: RegionName`

    Region the resource is in.

    - `"us-sva-2"`

  - `size: number`

    Size of the Volume in GB.

  - `type: VolumeType`

    Type of the Volume.

    - `"nvme"`

    - `"abs"`

  - `tags?: Array<string>`

    Tags to attach to the Volume.

  - `vm_id?: string`

    ID of the VM the Volume is attached to.

### Example

```typescript
import NirvanaLabs from '@nirvana-labs/nirvana';

const client = new NirvanaLabs({
  apiKey: process.env['NIRVANA_LABS_API_KEY'], // This is the default and can be omitted
});

await client.compute.volumes.availability.create({
  name: 'my-data-volume',
  project_id: '123e4567-e89b-12d3-a456-426614174000',
  region: 'us-sva-2',
  size: 100,
  type: 'abs',
});
```

## Check Volume Update Availability

`client.compute.volumes.availability.update(stringvolumeID, AvailabilityUpdateParamsbody, RequestOptionsoptions?): void`

**patch** `/v1/compute/volumes/{volume_id}/availability`

Check Volume Update Availability

### Parameters

- `volumeID: string`

- `body: AvailabilityUpdateParams`

  - `name?: string`

    Name of the Volume.

  - `size?: number`

    Size of the Volume in GB.

  - `tags?: Array<string>`

    Tags to attach to the Volume.

### Example

```typescript
import NirvanaLabs from '@nirvana-labs/nirvana';

const client = new NirvanaLabs({
  apiKey: process.env['NIRVANA_LABS_API_KEY'], // This is the default and can be omitted
});

await client.compute.volumes.availability.update('volume_id');
```
