# Compute

# VMs

## Create VM

`client.Compute.VMs.New(ctx, body) (*Operation, error)`

**post** `/v1/compute/vms`

Create a VM

### Parameters

- `body VMNewParams`

  - `BootVolume param.Field[VMNewParamsBootVolume]`

    Boot volume for the VM.

    - `Size int64`

      Size of the Volume in GB.

    - `Type VolumeType`

      Type of the Volume.

      - `const VolumeTypeNvme VolumeType = "nvme"`

      - `const VolumeTypeABS VolumeType = "abs"`

    - `Tags []string`

      Tags to attach to the Volume.

  - `InstanceType param.Field[string]`

    Instance type name.

  - `Name param.Field[string]`

    Name of the VM.

  - `OSImageName param.Field[string]`

    Name of the OS Image to use for the VM.

  - `ProjectID param.Field[string]`

    Project ID to create the VM in.

  - `PublicIPEnabled param.Field[bool]`

    Whether to enable public IP for the VM.

  - `Region param.Field[RegionName]`

    Region the resource is in.

  - `SSHKey param.Field[SSHKeyRequest]`

    Public SSH key configuration for the VM.

  - `SubnetID param.Field[string]`

    ID of the subnet to use for the VM.

  - `DataVolumes param.Field[[]VMNewParamsDataVolume]`

    Data volumes for the VM.

    - `Name string`

      Name of the Volume.

    - `Size int64`

      Size of the Volume in GB.

    - `Type VolumeType`

      Type of the Volume.

    - `Tags []string`

      Tags to attach to the Volume.

  - `Tags param.Field[[]string]`

    Tags to attach to the VM.

### Returns

- `type Operation struct{…}`

  Operation details.

  - `ID string`

    Unique identifier for the Operation.

  - `CreatedAt Time`

    When the Operation was created.

  - `Details OperationDetails`

    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 OperationFieldDiffFromUnion`

        Previous value.

        - `string`

        - `float64`

        - `bool`

        - `type OperationFieldDiffFromArray []string`

      - `To OperationFieldDiffToUnion`

        New value.

        - `string`

        - `float64`

        - `bool`

        - `type OperationFieldDiffToArray []string`

  - `Kind OperationKind`

    Kind of Operation.

    - `const OperationKindVM OperationKind = "vm"`

    - `const OperationKindVolume OperationKind = "volume"`

    - `const OperationKindVPC OperationKind = "vpc"`

    - `const OperationKindFirewallRule OperationKind = "firewall_rule"`

    - `const OperationKindNKSCluster OperationKind = "nks_cluster"`

    - `const OperationKindNKSNodePool OperationKind = "nks_node_pool"`

  - `ProjectID string`

    Project ID the Operation belongs to.

  - `ResourceID string`

    ID of the resource that the Operation is acting on.

  - `Status OperationStatus`

    Status of the Operation.

    - `const OperationStatusPending OperationStatus = "pending"`

    - `const OperationStatusRunning OperationStatus = "running"`

    - `const OperationStatusDone OperationStatus = "done"`

    - `const OperationStatusFailed OperationStatus = "failed"`

    - `const OperationStatusUnknown OperationStatus = "unknown"`

  - `Type OperationType`

    Type of Operation.

    - `const OperationTypeCreate OperationType = "create"`

    - `const OperationTypeUpdate OperationType = "update"`

    - `const OperationTypeDelete OperationType = "delete"`

    - `const OperationTypeRestart OperationType = "restart"`

  - `UpdatedAt Time`

    When the Operation was updated.

### Example

```go
package main

import (
  "context"
  "fmt"

  "github.com/nirvana-labs/nirvana-go"
  "github.com/nirvana-labs/nirvana-go/compute"
  "github.com/nirvana-labs/nirvana-go/option"
  "github.com/nirvana-labs/nirvana-go/shared"
)

func main() {
  client := nirvana.NewClient(
    option.WithAPIKey("My API Key"),
  )
  operation, err := client.Compute.VMs.New(context.TODO(), compute.VMNewParams{
    BootVolume: compute.VMNewParamsBootVolume{
      Size: 100,
      Type: compute.VolumeTypeABS,
    },
    InstanceType: "n1-standard-8",
    Name: "my-vm",
    OSImageName: "ubuntu-noble-2025-10-01",
    ProjectID: "123e4567-e89b-12d3-a456-426614174000",
    PublicIPEnabled: true,
    Region: shared.RegionNameUsSva2,
    SSHKey: compute.SSHKeyRequestParam{
      PublicKey: "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDBIASkmwNiLcdlW6927Zjt1Hf7Kw/PpEZ4Zm+wU9wn2",
    },
    SubnetID: "123e4567-e89b-12d3-a456-426614174000",
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", 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 VM Details

`client.Compute.VMs.Get(ctx, vmID) (*VM, error)`

**get** `/v1/compute/vms/{vm_id}`

Get details about a VM

### Parameters

- `vmID string`

### Returns

- `type VM struct{…}`

  VM details.

  - `ID string`

    Unique identifier for the VM.

  - `BootVolumeID string`

    ID of the boot volume attached to the VM.

  - `CPUConfig CPUConfig`

    CPU configuration for the VM.

    - `Vcpu int64`

      Number of virtual CPUs.

  - `CreatedAt Time`

    When the VM was created.

  - `DataVolumeIDs []string`

    IDs of the data volumes attached to the VM.

  - `MemoryConfig MemoryConfig`

    Memory configuration for the VM.

    - `Size int64`

      Size of the memory in GB.

  - `Name string`

    Name of the VM.

  - `PrivateIP string`

    Private IP of the VM.

  - `ProjectID string`

    Project ID the VM belongs to.

  - `PublicIP string`

    Public IP of the VM.

  - `PublicIPEnabled bool`

    Whether the public IP is enabled for the VM.

  - `Region RegionName`

    Region the resource is in.

    - `const RegionNameUsSva2 RegionName = "us-sva-2"`

  - `Status ResourceStatus`

    Status of the resource.

    - `const ResourceStatusPending ResourceStatus = "pending"`

    - `const ResourceStatusCreating ResourceStatus = "creating"`

    - `const ResourceStatusUpdating ResourceStatus = "updating"`

    - `const ResourceStatusReady ResourceStatus = "ready"`

    - `const ResourceStatusDeleting ResourceStatus = "deleting"`

    - `const ResourceStatusDeleted ResourceStatus = "deleted"`

    - `const ResourceStatusError ResourceStatus = "error"`

  - `SubnetID string`

    ID of the subnet the VM is in.

  - `Tags []string`

    Tags to attach to the VM.

  - `UpdatedAt Time`

    When the VM was updated.

  - `VPCID string`

    ID of the VPC the VM is in.

  - `VPCName string`

    Name of the VPC the VM is in.

  - `InstanceType string`

    Instance type name.

### Example

```go
package main

import (
  "context"
  "fmt"

  "github.com/nirvana-labs/nirvana-go"
  "github.com/nirvana-labs/nirvana-go/option"
)

func main() {
  client := nirvana.NewClient(
    option.WithAPIKey("My API Key"),
  )
  vm, err := client.Compute.VMs.Get(context.TODO(), "vm_id")
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", vm.ID)
}
```

#### Response

```json
{
  "id": "123e4567-e89b-12d3-a456-426614174000",
  "boot_volume_id": "123e4567-e89b-12d3-a456-426614174000",
  "cpu_config": {
    "vcpu": 2
  },
  "created_at": "2025-01-01T00:00:00Z",
  "data_volume_ids": [
    "123e4567-e89b-12d3-a456-426614174001",
    "123e4567-e89b-12d3-a456-426614174002"
  ],
  "memory_config": {
    "size": 2
  },
  "name": "my-vm",
  "private_ip": "10.0.0.1",
  "project_id": "123e4567-e89b-12d3-a456-426614174000",
  "public_ip": "123.123.123.123",
  "public_ip_enabled": true,
  "region": "us-sva-2",
  "status": "ready",
  "subnet_id": "123e4567-e89b-12d3-a456-426614174000",
  "tags": [
    "production",
    "ethereum"
  ],
  "updated_at": "2025-01-01T00:00:00Z",
  "vpc_id": "123e4567-e89b-12d3-a456-426614174000",
  "vpc_name": "my-vpc",
  "instance_type": "n1-standard-8"
}
```

## Update VM

`client.Compute.VMs.Update(ctx, vmID, body) (*Operation, error)`

**patch** `/v1/compute/vms/{vm_id}`

Update a VM

### Parameters

- `vmID string`

- `body VMUpdateParams`

  - `InstanceType param.Field[string]`

    Instance type name.

  - `Name param.Field[string]`

    Name of the VM.

  - `PublicIPEnabled param.Field[bool]`

    Whether to enable public IP for the VM.

  - `Tags param.Field[[]string]`

    Tags to attach to the VM.

### Returns

- `type Operation struct{…}`

  Operation details.

  - `ID string`

    Unique identifier for the Operation.

  - `CreatedAt Time`

    When the Operation was created.

  - `Details OperationDetails`

    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 OperationFieldDiffFromUnion`

        Previous value.

        - `string`

        - `float64`

        - `bool`

        - `type OperationFieldDiffFromArray []string`

      - `To OperationFieldDiffToUnion`

        New value.

        - `string`

        - `float64`

        - `bool`

        - `type OperationFieldDiffToArray []string`

  - `Kind OperationKind`

    Kind of Operation.

    - `const OperationKindVM OperationKind = "vm"`

    - `const OperationKindVolume OperationKind = "volume"`

    - `const OperationKindVPC OperationKind = "vpc"`

    - `const OperationKindFirewallRule OperationKind = "firewall_rule"`

    - `const OperationKindNKSCluster OperationKind = "nks_cluster"`

    - `const OperationKindNKSNodePool OperationKind = "nks_node_pool"`

  - `ProjectID string`

    Project ID the Operation belongs to.

  - `ResourceID string`

    ID of the resource that the Operation is acting on.

  - `Status OperationStatus`

    Status of the Operation.

    - `const OperationStatusPending OperationStatus = "pending"`

    - `const OperationStatusRunning OperationStatus = "running"`

    - `const OperationStatusDone OperationStatus = "done"`

    - `const OperationStatusFailed OperationStatus = "failed"`

    - `const OperationStatusUnknown OperationStatus = "unknown"`

  - `Type OperationType`

    Type of Operation.

    - `const OperationTypeCreate OperationType = "create"`

    - `const OperationTypeUpdate OperationType = "update"`

    - `const OperationTypeDelete OperationType = "delete"`

    - `const OperationTypeRestart OperationType = "restart"`

  - `UpdatedAt Time`

    When the Operation was updated.

### Example

```go
package main

import (
  "context"
  "fmt"

  "github.com/nirvana-labs/nirvana-go"
  "github.com/nirvana-labs/nirvana-go/compute"
  "github.com/nirvana-labs/nirvana-go/option"
)

func main() {
  client := nirvana.NewClient(
    option.WithAPIKey("My API Key"),
  )
  operation, err := client.Compute.VMs.Update(
    context.TODO(),
    "vm_id",
    compute.VMUpdateParams{

    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", 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 VM

`client.Compute.VMs.Delete(ctx, vmID) (*Operation, error)`

**delete** `/v1/compute/vms/{vm_id}`

Delete a VM

### Parameters

- `vmID string`

### Returns

- `type Operation struct{…}`

  Operation details.

  - `ID string`

    Unique identifier for the Operation.

  - `CreatedAt Time`

    When the Operation was created.

  - `Details OperationDetails`

    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 OperationFieldDiffFromUnion`

        Previous value.

        - `string`

        - `float64`

        - `bool`

        - `type OperationFieldDiffFromArray []string`

      - `To OperationFieldDiffToUnion`

        New value.

        - `string`

        - `float64`

        - `bool`

        - `type OperationFieldDiffToArray []string`

  - `Kind OperationKind`

    Kind of Operation.

    - `const OperationKindVM OperationKind = "vm"`

    - `const OperationKindVolume OperationKind = "volume"`

    - `const OperationKindVPC OperationKind = "vpc"`

    - `const OperationKindFirewallRule OperationKind = "firewall_rule"`

    - `const OperationKindNKSCluster OperationKind = "nks_cluster"`

    - `const OperationKindNKSNodePool OperationKind = "nks_node_pool"`

  - `ProjectID string`

    Project ID the Operation belongs to.

  - `ResourceID string`

    ID of the resource that the Operation is acting on.

  - `Status OperationStatus`

    Status of the Operation.

    - `const OperationStatusPending OperationStatus = "pending"`

    - `const OperationStatusRunning OperationStatus = "running"`

    - `const OperationStatusDone OperationStatus = "done"`

    - `const OperationStatusFailed OperationStatus = "failed"`

    - `const OperationStatusUnknown OperationStatus = "unknown"`

  - `Type OperationType`

    Type of Operation.

    - `const OperationTypeCreate OperationType = "create"`

    - `const OperationTypeUpdate OperationType = "update"`

    - `const OperationTypeDelete OperationType = "delete"`

    - `const OperationTypeRestart OperationType = "restart"`

  - `UpdatedAt Time`

    When the Operation was updated.

### Example

```go
package main

import (
  "context"
  "fmt"

  "github.com/nirvana-labs/nirvana-go"
  "github.com/nirvana-labs/nirvana-go/option"
)

func main() {
  client := nirvana.NewClient(
    option.WithAPIKey("My API Key"),
  )
  operation, err := client.Compute.VMs.Delete(context.TODO(), "vm_id")
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", 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 VMs

`client.Compute.VMs.List(ctx, query) (*Cursor[VM], error)`

**get** `/v1/compute/vms`

List all VMs

### Parameters

- `query VMListParams`

  - `ProjectID param.Field[string]`

    Project ID of resources to request

  - `Cursor param.Field[string]`

    Pagination cursor returned by a previous request

  - `Limit param.Field[int64]`

    Maximum number of items to return

### Returns

- `type VM struct{…}`

  VM details.

  - `ID string`

    Unique identifier for the VM.

  - `BootVolumeID string`

    ID of the boot volume attached to the VM.

  - `CPUConfig CPUConfig`

    CPU configuration for the VM.

    - `Vcpu int64`

      Number of virtual CPUs.

  - `CreatedAt Time`

    When the VM was created.

  - `DataVolumeIDs []string`

    IDs of the data volumes attached to the VM.

  - `MemoryConfig MemoryConfig`

    Memory configuration for the VM.

    - `Size int64`

      Size of the memory in GB.

  - `Name string`

    Name of the VM.

  - `PrivateIP string`

    Private IP of the VM.

  - `ProjectID string`

    Project ID the VM belongs to.

  - `PublicIP string`

    Public IP of the VM.

  - `PublicIPEnabled bool`

    Whether the public IP is enabled for the VM.

  - `Region RegionName`

    Region the resource is in.

    - `const RegionNameUsSva2 RegionName = "us-sva-2"`

  - `Status ResourceStatus`

    Status of the resource.

    - `const ResourceStatusPending ResourceStatus = "pending"`

    - `const ResourceStatusCreating ResourceStatus = "creating"`

    - `const ResourceStatusUpdating ResourceStatus = "updating"`

    - `const ResourceStatusReady ResourceStatus = "ready"`

    - `const ResourceStatusDeleting ResourceStatus = "deleting"`

    - `const ResourceStatusDeleted ResourceStatus = "deleted"`

    - `const ResourceStatusError ResourceStatus = "error"`

  - `SubnetID string`

    ID of the subnet the VM is in.

  - `Tags []string`

    Tags to attach to the VM.

  - `UpdatedAt Time`

    When the VM was updated.

  - `VPCID string`

    ID of the VPC the VM is in.

  - `VPCName string`

    Name of the VPC the VM is in.

  - `InstanceType string`

    Instance type name.

### Example

```go
package main

import (
  "context"
  "fmt"

  "github.com/nirvana-labs/nirvana-go"
  "github.com/nirvana-labs/nirvana-go/compute"
  "github.com/nirvana-labs/nirvana-go/option"
)

func main() {
  client := nirvana.NewClient(
    option.WithAPIKey("My API Key"),
  )
  page, err := client.Compute.VMs.List(context.TODO(), compute.VMListParams{
    ProjectID: "project_id",
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", page)
}
```

#### Response

```json
{
  "items": [
    {
      "id": "123e4567-e89b-12d3-a456-426614174000",
      "boot_volume_id": "123e4567-e89b-12d3-a456-426614174000",
      "cpu_config": {
        "vcpu": 2
      },
      "created_at": "2025-01-01T00:00:00Z",
      "data_volume_ids": [
        "123e4567-e89b-12d3-a456-426614174001",
        "123e4567-e89b-12d3-a456-426614174002"
      ],
      "memory_config": {
        "size": 2
      },
      "name": "my-vm",
      "private_ip": "10.0.0.1",
      "project_id": "123e4567-e89b-12d3-a456-426614174000",
      "public_ip": "123.123.123.123",
      "public_ip_enabled": true,
      "region": "us-sva-2",
      "status": "ready",
      "subnet_id": "123e4567-e89b-12d3-a456-426614174000",
      "tags": [
        "production",
        "ethereum"
      ],
      "updated_at": "2025-01-01T00:00:00Z",
      "vpc_id": "123e4567-e89b-12d3-a456-426614174000",
      "vpc_name": "my-vpc",
      "instance_type": "n1-standard-8"
    }
  ],
  "pagination": {
    "next_cursor": "RhwniMT4B74siYZcPF8TnCdGI1l9rpPvg",
    "previous_cursor": "ARhwnmi1hA7wEbHbMjdYQlOB_ZusP4fYvw",
    "total_count": 125
  }
}
```

## Restart VM

`client.Compute.VMs.Restart(ctx, vmID) (*Operation, error)`

**post** `/v1/compute/vms/{vm_id}/restart`

Restart a VM

### Parameters

- `vmID string`

### Returns

- `type Operation struct{…}`

  Operation details.

  - `ID string`

    Unique identifier for the Operation.

  - `CreatedAt Time`

    When the Operation was created.

  - `Details OperationDetails`

    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 OperationFieldDiffFromUnion`

        Previous value.

        - `string`

        - `float64`

        - `bool`

        - `type OperationFieldDiffFromArray []string`

      - `To OperationFieldDiffToUnion`

        New value.

        - `string`

        - `float64`

        - `bool`

        - `type OperationFieldDiffToArray []string`

  - `Kind OperationKind`

    Kind of Operation.

    - `const OperationKindVM OperationKind = "vm"`

    - `const OperationKindVolume OperationKind = "volume"`

    - `const OperationKindVPC OperationKind = "vpc"`

    - `const OperationKindFirewallRule OperationKind = "firewall_rule"`

    - `const OperationKindNKSCluster OperationKind = "nks_cluster"`

    - `const OperationKindNKSNodePool OperationKind = "nks_node_pool"`

  - `ProjectID string`

    Project ID the Operation belongs to.

  - `ResourceID string`

    ID of the resource that the Operation is acting on.

  - `Status OperationStatus`

    Status of the Operation.

    - `const OperationStatusPending OperationStatus = "pending"`

    - `const OperationStatusRunning OperationStatus = "running"`

    - `const OperationStatusDone OperationStatus = "done"`

    - `const OperationStatusFailed OperationStatus = "failed"`

    - `const OperationStatusUnknown OperationStatus = "unknown"`

  - `Type OperationType`

    Type of Operation.

    - `const OperationTypeCreate OperationType = "create"`

    - `const OperationTypeUpdate OperationType = "update"`

    - `const OperationTypeDelete OperationType = "delete"`

    - `const OperationTypeRestart OperationType = "restart"`

  - `UpdatedAt Time`

    When the Operation was updated.

### Example

```go
package main

import (
  "context"
  "fmt"

  "github.com/nirvana-labs/nirvana-go"
  "github.com/nirvana-labs/nirvana-go/option"
)

func main() {
  client := nirvana.NewClient(
    option.WithAPIKey("My API Key"),
  )
  operation, err := client.Compute.VMs.Restart(context.TODO(), "vm_id")
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", 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

### CPU Config

- `type CPUConfig struct{…}`

  CPU configuration for the VM.

  - `Vcpu int64`

    Number of virtual CPUs.

### Memory Config

- `type MemoryConfig struct{…}`

  Memory configuration for the VM.

  - `Size int64`

    Size of the memory in GB.

### OS Image

- `type OSImage struct{…}`

  OS Image details.

  - `CreatedAt Time`

    When the OS Image was created.

  - `DisplayName string`

    Display name of the OS Image.

  - `Name string`

    Name of the OS Image.

### SSH Key Request

- `type SSHKeyRequest struct{…}`

  Public SSH key configuration for the VM.

  - `PublicKey string`

    Public key to and use to access the VM.

### VM

- `type VM struct{…}`

  VM details.

  - `ID string`

    Unique identifier for the VM.

  - `BootVolumeID string`

    ID of the boot volume attached to the VM.

  - `CPUConfig CPUConfig`

    CPU configuration for the VM.

    - `Vcpu int64`

      Number of virtual CPUs.

  - `CreatedAt Time`

    When the VM was created.

  - `DataVolumeIDs []string`

    IDs of the data volumes attached to the VM.

  - `MemoryConfig MemoryConfig`

    Memory configuration for the VM.

    - `Size int64`

      Size of the memory in GB.

  - `Name string`

    Name of the VM.

  - `PrivateIP string`

    Private IP of the VM.

  - `ProjectID string`

    Project ID the VM belongs to.

  - `PublicIP string`

    Public IP of the VM.

  - `PublicIPEnabled bool`

    Whether the public IP is enabled for the VM.

  - `Region RegionName`

    Region the resource is in.

    - `const RegionNameUsSva2 RegionName = "us-sva-2"`

  - `Status ResourceStatus`

    Status of the resource.

    - `const ResourceStatusPending ResourceStatus = "pending"`

    - `const ResourceStatusCreating ResourceStatus = "creating"`

    - `const ResourceStatusUpdating ResourceStatus = "updating"`

    - `const ResourceStatusReady ResourceStatus = "ready"`

    - `const ResourceStatusDeleting ResourceStatus = "deleting"`

    - `const ResourceStatusDeleted ResourceStatus = "deleted"`

    - `const ResourceStatusError ResourceStatus = "error"`

  - `SubnetID string`

    ID of the subnet the VM is in.

  - `Tags []string`

    Tags to attach to the VM.

  - `UpdatedAt Time`

    When the VM was updated.

  - `VPCID string`

    ID of the VPC the VM is in.

  - `VPCName string`

    Name of the VPC the VM is in.

  - `InstanceType string`

    Instance type name.

### VM List

- `type VMList struct{…}`

  - `Items []VM`

    - `ID string`

      Unique identifier for the VM.

    - `BootVolumeID string`

      ID of the boot volume attached to the VM.

    - `CPUConfig CPUConfig`

      CPU configuration for the VM.

      - `Vcpu int64`

        Number of virtual CPUs.

    - `CreatedAt Time`

      When the VM was created.

    - `DataVolumeIDs []string`

      IDs of the data volumes attached to the VM.

    - `MemoryConfig MemoryConfig`

      Memory configuration for the VM.

      - `Size int64`

        Size of the memory in GB.

    - `Name string`

      Name of the VM.

    - `PrivateIP string`

      Private IP of the VM.

    - `ProjectID string`

      Project ID the VM belongs to.

    - `PublicIP string`

      Public IP of the VM.

    - `PublicIPEnabled bool`

      Whether the public IP is enabled for the VM.

    - `Region RegionName`

      Region the resource is in.

      - `const RegionNameUsSva2 RegionName = "us-sva-2"`

    - `Status ResourceStatus`

      Status of the resource.

      - `const ResourceStatusPending ResourceStatus = "pending"`

      - `const ResourceStatusCreating ResourceStatus = "creating"`

      - `const ResourceStatusUpdating ResourceStatus = "updating"`

      - `const ResourceStatusReady ResourceStatus = "ready"`

      - `const ResourceStatusDeleting ResourceStatus = "deleting"`

      - `const ResourceStatusDeleted ResourceStatus = "deleted"`

      - `const ResourceStatusError ResourceStatus = "error"`

    - `SubnetID string`

      ID of the subnet the VM is in.

    - `Tags []string`

      Tags to attach to the VM.

    - `UpdatedAt Time`

      When the VM was updated.

    - `VPCID string`

      ID of the VPC the VM is in.

    - `VPCName string`

      Name of the VPC the VM is in.

    - `InstanceType string`

      Instance type name.

  - `Pagination Pagination`

    Pagination response details.

    - `NextCursor string`

    - `PreviousCursor string`

    - `TotalCount int64`

# Availability

## Check VM Create Availability

`client.Compute.VMs.Availability.New(ctx, body) error`

**post** `/v1/compute/vms/availability`

Check VM Create Availability

### Parameters

- `body VMAvailabilityNewParams`

  - `BootVolume param.Field[VMAvailabilityNewParamsBootVolume]`

    Boot volume for the VM.

    - `Size int64`

      Size of the Volume in GB.

    - `Type VolumeType`

      Type of the Volume.

      - `const VolumeTypeNvme VolumeType = "nvme"`

      - `const VolumeTypeABS VolumeType = "abs"`

    - `Tags []string`

      Tags to attach to the Volume.

  - `InstanceType param.Field[string]`

    Instance type name.

  - `Name param.Field[string]`

    Name of the VM.

  - `OSImageName param.Field[string]`

    Name of the OS Image to use for the VM.

  - `ProjectID param.Field[string]`

    Project ID to create the VM in.

  - `PublicIPEnabled param.Field[bool]`

    Whether to enable public IP for the VM.

  - `Region param.Field[RegionName]`

    Region the resource is in.

  - `SSHKey param.Field[SSHKeyRequest]`

    Public SSH key configuration for the VM.

  - `SubnetID param.Field[string]`

    ID of the subnet to use for the VM.

  - `DataVolumes param.Field[[]VMAvailabilityNewParamsDataVolume]`

    Data volumes for the VM.

    - `Name string`

      Name of the Volume.

    - `Size int64`

      Size of the Volume in GB.

    - `Type VolumeType`

      Type of the Volume.

    - `Tags []string`

      Tags to attach to the Volume.

  - `Tags param.Field[[]string]`

    Tags to attach to the VM.

### Example

```go
package main

import (
  "context"

  "github.com/nirvana-labs/nirvana-go"
  "github.com/nirvana-labs/nirvana-go/compute"
  "github.com/nirvana-labs/nirvana-go/option"
  "github.com/nirvana-labs/nirvana-go/shared"
)

func main() {
  client := nirvana.NewClient(
    option.WithAPIKey("My API Key"),
  )
  err := client.Compute.VMs.Availability.New(context.TODO(), compute.VMAvailabilityNewParams{
    BootVolume: compute.VMAvailabilityNewParamsBootVolume{
      Size: 100,
      Type: compute.VolumeTypeABS,
    },
    InstanceType: "n1-standard-8",
    Name: "my-vm",
    OSImageName: "ubuntu-noble-2025-10-01",
    ProjectID: "123e4567-e89b-12d3-a456-426614174000",
    PublicIPEnabled: true,
    Region: shared.RegionNameUsSva2,
    SSHKey: compute.SSHKeyRequestParam{
      PublicKey: "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDBIASkmwNiLcdlW6927Zjt1Hf7Kw/PpEZ4Zm+wU9wn2",
    },
    SubnetID: "123e4567-e89b-12d3-a456-426614174000",
  })
  if err != nil {
    panic(err.Error())
  }
}
```

## Check VM Update Availability

`client.Compute.VMs.Availability.Update(ctx, vmID, body) error`

**patch** `/v1/compute/vms/{vm_id}/availability`

Check VM Update Availability

### Parameters

- `vmID string`

- `body VMAvailabilityUpdateParams`

  - `InstanceType param.Field[string]`

    Instance type name.

  - `Name param.Field[string]`

    Name of the VM.

  - `PublicIPEnabled param.Field[bool]`

    Whether to enable public IP for the VM.

  - `Tags param.Field[[]string]`

    Tags to attach to the VM.

### Example

```go
package main

import (
  "context"

  "github.com/nirvana-labs/nirvana-go"
  "github.com/nirvana-labs/nirvana-go/compute"
  "github.com/nirvana-labs/nirvana-go/option"
)

func main() {
  client := nirvana.NewClient(
    option.WithAPIKey("My API Key"),
  )
  err := client.Compute.VMs.Availability.Update(
    context.TODO(),
    "vm_id",
    compute.VMAvailabilityUpdateParams{

    },
  )
  if err != nil {
    panic(err.Error())
  }
}
```

# Volumes

## List VM's Volumes

`client.Compute.VMs.Volumes.List(ctx, vmID, query) (*Cursor[Volume], error)`

**get** `/v1/compute/vms/{vm_id}/volumes`

List VM's Volumes

### Parameters

- `vmID string`

- `query VMVolumeListParams`

  - `Cursor param.Field[string]`

    Pagination cursor returned by a previous request

  - `Limit param.Field[int64]`

    Maximum number of items to return

### Returns

- `type Volume struct{…}`

  Volume details.

  - `ID string`

    Unique identifier for the Volume.

  - `CreatedAt Time`

    When the Volume was created.

  - `Kind VolumeKind`

    Volume kind.

    - `const VolumeKindBoot VolumeKind = "boot"`

    - `const VolumeKindData VolumeKind = "data"`

  - `Name string`

    Name of the Volume.

  - `ProjectID string`

    Project ID the Volume belongs to.

  - `Region RegionName`

    Region the resource is in.

    - `const RegionNameUsSva2 RegionName = "us-sva-2"`

  - `Size int64`

    Size of the Volume in GB.

  - `Status ResourceStatus`

    Status of the resource.

    - `const ResourceStatusPending ResourceStatus = "pending"`

    - `const ResourceStatusCreating ResourceStatus = "creating"`

    - `const ResourceStatusUpdating ResourceStatus = "updating"`

    - `const ResourceStatusReady ResourceStatus = "ready"`

    - `const ResourceStatusDeleting ResourceStatus = "deleting"`

    - `const ResourceStatusDeleted ResourceStatus = "deleted"`

    - `const ResourceStatusError ResourceStatus = "error"`

  - `Tags []string`

    Tags to attach to the Volume.

  - `Type VolumeType`

    Type of the Volume.

    - `const VolumeTypeNvme VolumeType = "nvme"`

    - `const VolumeTypeABS VolumeType = "abs"`

  - `UpdatedAt Time`

    When the Volume was updated.

  - `VMID string`

    ID of the VM the Volume is attached to.

  - `VMName string`

    Name of the VM the Volume is attached to.

### Example

```go
package main

import (
  "context"
  "fmt"

  "github.com/nirvana-labs/nirvana-go"
  "github.com/nirvana-labs/nirvana-go/compute"
  "github.com/nirvana-labs/nirvana-go/option"
)

func main() {
  client := nirvana.NewClient(
    option.WithAPIKey("My API Key"),
  )
  page, err := client.Compute.VMs.Volumes.List(
    context.TODO(),
    "vm_id",
    compute.VMVolumeListParams{

    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", page)
}
```

#### 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
  }
}
```

# OS Images

## List OS Images

`client.Compute.VMs.OSImages.List(ctx, query) (*Cursor[OSImage], error)`

**get** `/v1/compute/vms/os_images`

List all OS Images

### Parameters

- `query VMOSImageListParams`

  - `Cursor param.Field[string]`

    Pagination cursor returned by a previous request

  - `Limit param.Field[int64]`

    Maximum number of items to return

### Returns

- `type OSImage struct{…}`

  OS Image details.

  - `CreatedAt Time`

    When the OS Image was created.

  - `DisplayName string`

    Display name of the OS Image.

  - `Name string`

    Name of the OS Image.

### Example

```go
package main

import (
  "context"
  "fmt"

  "github.com/nirvana-labs/nirvana-go"
  "github.com/nirvana-labs/nirvana-go/compute"
  "github.com/nirvana-labs/nirvana-go/option"
)

func main() {
  client := nirvana.NewClient(
    option.WithAPIKey("My API Key"),
  )
  page, err := client.Compute.VMs.OSImages.List(context.TODO(), compute.VMOSImageListParams{

  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", page)
}
```

#### Response

```json
{
  "items": [
    {
      "created_at": "2025-01-01T00:00:00Z",
      "display_name": "Ubuntu 24.04 (Noble)",
      "name": "ubuntu-noble-2025-10-01"
    }
  ],
  "pagination": {
    "next_cursor": "RhwniMT4B74siYZcPF8TnCdGI1l9rpPvg",
    "previous_cursor": "ARhwnmi1hA7wEbHbMjdYQlOB_ZusP4fYvw",
    "total_count": 125
  }
}
```

# Volumes

## Create Volume

`client.Compute.Volumes.New(ctx, body) (*Operation, error)`

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

Create a Volume. Only data volumes can be created.

### Parameters

- `body VolumeNewParams`

  - `Name param.Field[string]`

    Name of the Volume.

  - `ProjectID param.Field[string]`

    Project ID the Volume belongs to.

  - `Region param.Field[RegionName]`

    Region the resource is in.

  - `Size param.Field[int64]`

    Size of the Volume in GB.

  - `Type param.Field[VolumeType]`

    Type of the Volume.

  - `Tags param.Field[[]string]`

    Tags to attach to the Volume.

  - `VMID param.Field[string]`

    ID of the VM the Volume is attached to.

### Returns

- `type Operation struct{…}`

  Operation details.

  - `ID string`

    Unique identifier for the Operation.

  - `CreatedAt Time`

    When the Operation was created.

  - `Details OperationDetails`

    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 OperationFieldDiffFromUnion`

        Previous value.

        - `string`

        - `float64`

        - `bool`

        - `type OperationFieldDiffFromArray []string`

      - `To OperationFieldDiffToUnion`

        New value.

        - `string`

        - `float64`

        - `bool`

        - `type OperationFieldDiffToArray []string`

  - `Kind OperationKind`

    Kind of Operation.

    - `const OperationKindVM OperationKind = "vm"`

    - `const OperationKindVolume OperationKind = "volume"`

    - `const OperationKindVPC OperationKind = "vpc"`

    - `const OperationKindFirewallRule OperationKind = "firewall_rule"`

    - `const OperationKindNKSCluster OperationKind = "nks_cluster"`

    - `const OperationKindNKSNodePool OperationKind = "nks_node_pool"`

  - `ProjectID string`

    Project ID the Operation belongs to.

  - `ResourceID string`

    ID of the resource that the Operation is acting on.

  - `Status OperationStatus`

    Status of the Operation.

    - `const OperationStatusPending OperationStatus = "pending"`

    - `const OperationStatusRunning OperationStatus = "running"`

    - `const OperationStatusDone OperationStatus = "done"`

    - `const OperationStatusFailed OperationStatus = "failed"`

    - `const OperationStatusUnknown OperationStatus = "unknown"`

  - `Type OperationType`

    Type of Operation.

    - `const OperationTypeCreate OperationType = "create"`

    - `const OperationTypeUpdate OperationType = "update"`

    - `const OperationTypeDelete OperationType = "delete"`

    - `const OperationTypeRestart OperationType = "restart"`

  - `UpdatedAt Time`

    When the Operation was updated.

### Example

```go
package main

import (
  "context"
  "fmt"

  "github.com/nirvana-labs/nirvana-go"
  "github.com/nirvana-labs/nirvana-go/compute"
  "github.com/nirvana-labs/nirvana-go/option"
  "github.com/nirvana-labs/nirvana-go/shared"
)

func main() {
  client := nirvana.NewClient(
    option.WithAPIKey("My API Key"),
  )
  operation, err := client.Compute.Volumes.New(context.TODO(), compute.VolumeNewParams{
    Name: "my-data-volume",
    ProjectID: "123e4567-e89b-12d3-a456-426614174000",
    Region: shared.RegionNameUsSva2,
    Size: 100,
    Type: compute.VolumeTypeABS,
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", 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(ctx, volumeID) (*Volume, error)`

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

Get a Volume.

### Parameters

- `volumeID string`

### Returns

- `type Volume struct{…}`

  Volume details.

  - `ID string`

    Unique identifier for the Volume.

  - `CreatedAt Time`

    When the Volume was created.

  - `Kind VolumeKind`

    Volume kind.

    - `const VolumeKindBoot VolumeKind = "boot"`

    - `const VolumeKindData VolumeKind = "data"`

  - `Name string`

    Name of the Volume.

  - `ProjectID string`

    Project ID the Volume belongs to.

  - `Region RegionName`

    Region the resource is in.

    - `const RegionNameUsSva2 RegionName = "us-sva-2"`

  - `Size int64`

    Size of the Volume in GB.

  - `Status ResourceStatus`

    Status of the resource.

    - `const ResourceStatusPending ResourceStatus = "pending"`

    - `const ResourceStatusCreating ResourceStatus = "creating"`

    - `const ResourceStatusUpdating ResourceStatus = "updating"`

    - `const ResourceStatusReady ResourceStatus = "ready"`

    - `const ResourceStatusDeleting ResourceStatus = "deleting"`

    - `const ResourceStatusDeleted ResourceStatus = "deleted"`

    - `const ResourceStatusError ResourceStatus = "error"`

  - `Tags []string`

    Tags to attach to the Volume.

  - `Type VolumeType`

    Type of the Volume.

    - `const VolumeTypeNvme VolumeType = "nvme"`

    - `const VolumeTypeABS VolumeType = "abs"`

  - `UpdatedAt Time`

    When the Volume was updated.

  - `VMID string`

    ID of the VM the Volume is attached to.

  - `VMName string`

    Name of the VM the Volume is attached to.

### Example

```go
package main

import (
  "context"
  "fmt"

  "github.com/nirvana-labs/nirvana-go"
  "github.com/nirvana-labs/nirvana-go/option"
)

func main() {
  client := nirvana.NewClient(
    option.WithAPIKey("My API Key"),
  )
  volume, err := client.Compute.Volumes.Get(context.TODO(), "volume_id")
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", 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(ctx, volumeID, body) (*Operation, error)`

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

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

### Parameters

- `volumeID string`

- `body VolumeUpdateParams`

  - `Name param.Field[string]`

    Name of the Volume.

  - `Size param.Field[int64]`

    Size of the Volume in GB.

  - `Tags param.Field[[]string]`

    Tags to attach to the Volume.

### Returns

- `type Operation struct{…}`

  Operation details.

  - `ID string`

    Unique identifier for the Operation.

  - `CreatedAt Time`

    When the Operation was created.

  - `Details OperationDetails`

    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 OperationFieldDiffFromUnion`

        Previous value.

        - `string`

        - `float64`

        - `bool`

        - `type OperationFieldDiffFromArray []string`

      - `To OperationFieldDiffToUnion`

        New value.

        - `string`

        - `float64`

        - `bool`

        - `type OperationFieldDiffToArray []string`

  - `Kind OperationKind`

    Kind of Operation.

    - `const OperationKindVM OperationKind = "vm"`

    - `const OperationKindVolume OperationKind = "volume"`

    - `const OperationKindVPC OperationKind = "vpc"`

    - `const OperationKindFirewallRule OperationKind = "firewall_rule"`

    - `const OperationKindNKSCluster OperationKind = "nks_cluster"`

    - `const OperationKindNKSNodePool OperationKind = "nks_node_pool"`

  - `ProjectID string`

    Project ID the Operation belongs to.

  - `ResourceID string`

    ID of the resource that the Operation is acting on.

  - `Status OperationStatus`

    Status of the Operation.

    - `const OperationStatusPending OperationStatus = "pending"`

    - `const OperationStatusRunning OperationStatus = "running"`

    - `const OperationStatusDone OperationStatus = "done"`

    - `const OperationStatusFailed OperationStatus = "failed"`

    - `const OperationStatusUnknown OperationStatus = "unknown"`

  - `Type OperationType`

    Type of Operation.

    - `const OperationTypeCreate OperationType = "create"`

    - `const OperationTypeUpdate OperationType = "update"`

    - `const OperationTypeDelete OperationType = "delete"`

    - `const OperationTypeRestart OperationType = "restart"`

  - `UpdatedAt Time`

    When the Operation was updated.

### Example

```go
package main

import (
  "context"
  "fmt"

  "github.com/nirvana-labs/nirvana-go"
  "github.com/nirvana-labs/nirvana-go/compute"
  "github.com/nirvana-labs/nirvana-go/option"
)

func main() {
  client := nirvana.NewClient(
    option.WithAPIKey("My API Key"),
  )
  operation, err := client.Compute.Volumes.Update(
    context.TODO(),
    "volume_id",
    compute.VolumeUpdateParams{

    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", 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(ctx, volumeID) (*Operation, error)`

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

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

### Parameters

- `volumeID string`

### Returns

- `type Operation struct{…}`

  Operation details.

  - `ID string`

    Unique identifier for the Operation.

  - `CreatedAt Time`

    When the Operation was created.

  - `Details OperationDetails`

    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 OperationFieldDiffFromUnion`

        Previous value.

        - `string`

        - `float64`

        - `bool`

        - `type OperationFieldDiffFromArray []string`

      - `To OperationFieldDiffToUnion`

        New value.

        - `string`

        - `float64`

        - `bool`

        - `type OperationFieldDiffToArray []string`

  - `Kind OperationKind`

    Kind of Operation.

    - `const OperationKindVM OperationKind = "vm"`

    - `const OperationKindVolume OperationKind = "volume"`

    - `const OperationKindVPC OperationKind = "vpc"`

    - `const OperationKindFirewallRule OperationKind = "firewall_rule"`

    - `const OperationKindNKSCluster OperationKind = "nks_cluster"`

    - `const OperationKindNKSNodePool OperationKind = "nks_node_pool"`

  - `ProjectID string`

    Project ID the Operation belongs to.

  - `ResourceID string`

    ID of the resource that the Operation is acting on.

  - `Status OperationStatus`

    Status of the Operation.

    - `const OperationStatusPending OperationStatus = "pending"`

    - `const OperationStatusRunning OperationStatus = "running"`

    - `const OperationStatusDone OperationStatus = "done"`

    - `const OperationStatusFailed OperationStatus = "failed"`

    - `const OperationStatusUnknown OperationStatus = "unknown"`

  - `Type OperationType`

    Type of Operation.

    - `const OperationTypeCreate OperationType = "create"`

    - `const OperationTypeUpdate OperationType = "update"`

    - `const OperationTypeDelete OperationType = "delete"`

    - `const OperationTypeRestart OperationType = "restart"`

  - `UpdatedAt Time`

    When the Operation was updated.

### Example

```go
package main

import (
  "context"
  "fmt"

  "github.com/nirvana-labs/nirvana-go"
  "github.com/nirvana-labs/nirvana-go/option"
)

func main() {
  client := nirvana.NewClient(
    option.WithAPIKey("My API Key"),
  )
  operation, err := client.Compute.Volumes.Delete(context.TODO(), "volume_id")
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", 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(ctx, query) (*Cursor[Volume], error)`

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

List all volumes

### Parameters

- `query VolumeListParams`

  - `ProjectID param.Field[string]`

    Project ID of resources to request

  - `Cursor param.Field[string]`

    Pagination cursor returned by a previous request

  - `Limit param.Field[int64]`

    Maximum number of items to return

### Returns

- `type Volume struct{…}`

  Volume details.

  - `ID string`

    Unique identifier for the Volume.

  - `CreatedAt Time`

    When the Volume was created.

  - `Kind VolumeKind`

    Volume kind.

    - `const VolumeKindBoot VolumeKind = "boot"`

    - `const VolumeKindData VolumeKind = "data"`

  - `Name string`

    Name of the Volume.

  - `ProjectID string`

    Project ID the Volume belongs to.

  - `Region RegionName`

    Region the resource is in.

    - `const RegionNameUsSva2 RegionName = "us-sva-2"`

  - `Size int64`

    Size of the Volume in GB.

  - `Status ResourceStatus`

    Status of the resource.

    - `const ResourceStatusPending ResourceStatus = "pending"`

    - `const ResourceStatusCreating ResourceStatus = "creating"`

    - `const ResourceStatusUpdating ResourceStatus = "updating"`

    - `const ResourceStatusReady ResourceStatus = "ready"`

    - `const ResourceStatusDeleting ResourceStatus = "deleting"`

    - `const ResourceStatusDeleted ResourceStatus = "deleted"`

    - `const ResourceStatusError ResourceStatus = "error"`

  - `Tags []string`

    Tags to attach to the Volume.

  - `Type VolumeType`

    Type of the Volume.

    - `const VolumeTypeNvme VolumeType = "nvme"`

    - `const VolumeTypeABS VolumeType = "abs"`

  - `UpdatedAt Time`

    When the Volume was updated.

  - `VMID string`

    ID of the VM the Volume is attached to.

  - `VMName string`

    Name of the VM the Volume is attached to.

### Example

```go
package main

import (
  "context"
  "fmt"

  "github.com/nirvana-labs/nirvana-go"
  "github.com/nirvana-labs/nirvana-go/compute"
  "github.com/nirvana-labs/nirvana-go/option"
)

func main() {
  client := nirvana.NewClient(
    option.WithAPIKey("My API Key"),
  )
  page, err := client.Compute.Volumes.List(context.TODO(), compute.VolumeListParams{
    ProjectID: "project_id",
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", page)
}
```

#### 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(ctx, volumeID, body) (*Operation, error)`

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

Attach a volume to a VM

### Parameters

- `volumeID string`

- `body VolumeAttachParams`

  - `VMID param.Field[string]`

    ID of the VM to attach the Volume to.

### Returns

- `type Operation struct{…}`

  Operation details.

  - `ID string`

    Unique identifier for the Operation.

  - `CreatedAt Time`

    When the Operation was created.

  - `Details OperationDetails`

    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 OperationFieldDiffFromUnion`

        Previous value.

        - `string`

        - `float64`

        - `bool`

        - `type OperationFieldDiffFromArray []string`

      - `To OperationFieldDiffToUnion`

        New value.

        - `string`

        - `float64`

        - `bool`

        - `type OperationFieldDiffToArray []string`

  - `Kind OperationKind`

    Kind of Operation.

    - `const OperationKindVM OperationKind = "vm"`

    - `const OperationKindVolume OperationKind = "volume"`

    - `const OperationKindVPC OperationKind = "vpc"`

    - `const OperationKindFirewallRule OperationKind = "firewall_rule"`

    - `const OperationKindNKSCluster OperationKind = "nks_cluster"`

    - `const OperationKindNKSNodePool OperationKind = "nks_node_pool"`

  - `ProjectID string`

    Project ID the Operation belongs to.

  - `ResourceID string`

    ID of the resource that the Operation is acting on.

  - `Status OperationStatus`

    Status of the Operation.

    - `const OperationStatusPending OperationStatus = "pending"`

    - `const OperationStatusRunning OperationStatus = "running"`

    - `const OperationStatusDone OperationStatus = "done"`

    - `const OperationStatusFailed OperationStatus = "failed"`

    - `const OperationStatusUnknown OperationStatus = "unknown"`

  - `Type OperationType`

    Type of Operation.

    - `const OperationTypeCreate OperationType = "create"`

    - `const OperationTypeUpdate OperationType = "update"`

    - `const OperationTypeDelete OperationType = "delete"`

    - `const OperationTypeRestart OperationType = "restart"`

  - `UpdatedAt Time`

    When the Operation was updated.

### Example

```go
package main

import (
  "context"
  "fmt"

  "github.com/nirvana-labs/nirvana-go"
  "github.com/nirvana-labs/nirvana-go/compute"
  "github.com/nirvana-labs/nirvana-go/option"
)

func main() {
  client := nirvana.NewClient(
    option.WithAPIKey("My API Key"),
  )
  operation, err := client.Compute.Volumes.Attach(
    context.TODO(),
    "volume_id",
    compute.VolumeAttachParams{
      VMID: "123e4567-e89b-12d3-a456-426614174000",
    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", 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(ctx, volumeID) (*Operation, error)`

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

Detach a volume from a VM

### Parameters

- `volumeID string`

### Returns

- `type Operation struct{…}`

  Operation details.

  - `ID string`

    Unique identifier for the Operation.

  - `CreatedAt Time`

    When the Operation was created.

  - `Details OperationDetails`

    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 OperationFieldDiffFromUnion`

        Previous value.

        - `string`

        - `float64`

        - `bool`

        - `type OperationFieldDiffFromArray []string`

      - `To OperationFieldDiffToUnion`

        New value.

        - `string`

        - `float64`

        - `bool`

        - `type OperationFieldDiffToArray []string`

  - `Kind OperationKind`

    Kind of Operation.

    - `const OperationKindVM OperationKind = "vm"`

    - `const OperationKindVolume OperationKind = "volume"`

    - `const OperationKindVPC OperationKind = "vpc"`

    - `const OperationKindFirewallRule OperationKind = "firewall_rule"`

    - `const OperationKindNKSCluster OperationKind = "nks_cluster"`

    - `const OperationKindNKSNodePool OperationKind = "nks_node_pool"`

  - `ProjectID string`

    Project ID the Operation belongs to.

  - `ResourceID string`

    ID of the resource that the Operation is acting on.

  - `Status OperationStatus`

    Status of the Operation.

    - `const OperationStatusPending OperationStatus = "pending"`

    - `const OperationStatusRunning OperationStatus = "running"`

    - `const OperationStatusDone OperationStatus = "done"`

    - `const OperationStatusFailed OperationStatus = "failed"`

    - `const OperationStatusUnknown OperationStatus = "unknown"`

  - `Type OperationType`

    Type of Operation.

    - `const OperationTypeCreate OperationType = "create"`

    - `const OperationTypeUpdate OperationType = "update"`

    - `const OperationTypeDelete OperationType = "delete"`

    - `const OperationTypeRestart OperationType = "restart"`

  - `UpdatedAt Time`

    When the Operation was updated.

### Example

```go
package main

import (
  "context"
  "fmt"

  "github.com/nirvana-labs/nirvana-go"
  "github.com/nirvana-labs/nirvana-go/option"
)

func main() {
  client := nirvana.NewClient(
    option.WithAPIKey("My API Key"),
  )
  operation, err := client.Compute.Volumes.Detach(context.TODO(), "volume_id")
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", 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

- `type Volume struct{…}`

  Volume details.

  - `ID string`

    Unique identifier for the Volume.

  - `CreatedAt Time`

    When the Volume was created.

  - `Kind VolumeKind`

    Volume kind.

    - `const VolumeKindBoot VolumeKind = "boot"`

    - `const VolumeKindData VolumeKind = "data"`

  - `Name string`

    Name of the Volume.

  - `ProjectID string`

    Project ID the Volume belongs to.

  - `Region RegionName`

    Region the resource is in.

    - `const RegionNameUsSva2 RegionName = "us-sva-2"`

  - `Size int64`

    Size of the Volume in GB.

  - `Status ResourceStatus`

    Status of the resource.

    - `const ResourceStatusPending ResourceStatus = "pending"`

    - `const ResourceStatusCreating ResourceStatus = "creating"`

    - `const ResourceStatusUpdating ResourceStatus = "updating"`

    - `const ResourceStatusReady ResourceStatus = "ready"`

    - `const ResourceStatusDeleting ResourceStatus = "deleting"`

    - `const ResourceStatusDeleted ResourceStatus = "deleted"`

    - `const ResourceStatusError ResourceStatus = "error"`

  - `Tags []string`

    Tags to attach to the Volume.

  - `Type VolumeType`

    Type of the Volume.

    - `const VolumeTypeNvme VolumeType = "nvme"`

    - `const VolumeTypeABS VolumeType = "abs"`

  - `UpdatedAt Time`

    When the Volume was updated.

  - `VMID string`

    ID of the VM the Volume is attached to.

  - `VMName string`

    Name of the VM the Volume is attached to.

### Volume Kind

- `type VolumeKind string`

  Volume kind.

  - `const VolumeKindBoot VolumeKind = "boot"`

  - `const VolumeKindData VolumeKind = "data"`

### Volume List

- `type VolumeList struct{…}`

  - `Items []Volume`

    - `ID string`

      Unique identifier for the Volume.

    - `CreatedAt Time`

      When the Volume was created.

    - `Kind VolumeKind`

      Volume kind.

      - `const VolumeKindBoot VolumeKind = "boot"`

      - `const VolumeKindData VolumeKind = "data"`

    - `Name string`

      Name of the Volume.

    - `ProjectID string`

      Project ID the Volume belongs to.

    - `Region RegionName`

      Region the resource is in.

      - `const RegionNameUsSva2 RegionName = "us-sva-2"`

    - `Size int64`

      Size of the Volume in GB.

    - `Status ResourceStatus`

      Status of the resource.

      - `const ResourceStatusPending ResourceStatus = "pending"`

      - `const ResourceStatusCreating ResourceStatus = "creating"`

      - `const ResourceStatusUpdating ResourceStatus = "updating"`

      - `const ResourceStatusReady ResourceStatus = "ready"`

      - `const ResourceStatusDeleting ResourceStatus = "deleting"`

      - `const ResourceStatusDeleted ResourceStatus = "deleted"`

      - `const ResourceStatusError ResourceStatus = "error"`

    - `Tags []string`

      Tags to attach to the Volume.

    - `Type VolumeType`

      Type of the Volume.

      - `const VolumeTypeNvme VolumeType = "nvme"`

      - `const VolumeTypeABS VolumeType = "abs"`

    - `UpdatedAt Time`

      When the Volume was updated.

    - `VMID string`

      ID of the VM the Volume is attached to.

    - `VMName string`

      Name of the VM the Volume is attached to.

  - `Pagination Pagination`

    Pagination response details.

    - `NextCursor string`

    - `PreviousCursor string`

    - `TotalCount int64`

### Volume Type

- `type VolumeType string`

  Type of the Volume.

  - `const VolumeTypeNvme VolumeType = "nvme"`

  - `const VolumeTypeABS VolumeType = "abs"`

# Availability

## Check Volume Create Availability

`client.Compute.Volumes.Availability.New(ctx, body) error`

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

Check Volume Create Availability

### Parameters

- `body VolumeAvailabilityNewParams`

  - `Name param.Field[string]`

    Name of the Volume.

  - `ProjectID param.Field[string]`

    Project ID the Volume belongs to.

  - `Region param.Field[RegionName]`

    Region the resource is in.

  - `Size param.Field[int64]`

    Size of the Volume in GB.

  - `Type param.Field[VolumeType]`

    Type of the Volume.

  - `Tags param.Field[[]string]`

    Tags to attach to the Volume.

  - `VMID param.Field[string]`

    ID of the VM the Volume is attached to.

### Example

```go
package main

import (
  "context"

  "github.com/nirvana-labs/nirvana-go"
  "github.com/nirvana-labs/nirvana-go/compute"
  "github.com/nirvana-labs/nirvana-go/option"
  "github.com/nirvana-labs/nirvana-go/shared"
)

func main() {
  client := nirvana.NewClient(
    option.WithAPIKey("My API Key"),
  )
  err := client.Compute.Volumes.Availability.New(context.TODO(), compute.VolumeAvailabilityNewParams{
    Name: "my-data-volume",
    ProjectID: "123e4567-e89b-12d3-a456-426614174000",
    Region: shared.RegionNameUsSva2,
    Size: 100,
    Type: compute.VolumeTypeABS,
  })
  if err != nil {
    panic(err.Error())
  }
}
```

## Check Volume Update Availability

`client.Compute.Volumes.Availability.Update(ctx, volumeID, body) error`

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

Check Volume Update Availability

### Parameters

- `volumeID string`

- `body VolumeAvailabilityUpdateParams`

  - `Name param.Field[string]`

    Name of the Volume.

  - `Size param.Field[int64]`

    Size of the Volume in GB.

  - `Tags param.Field[[]string]`

    Tags to attach to the Volume.

### Example

```go
package main

import (
  "context"

  "github.com/nirvana-labs/nirvana-go"
  "github.com/nirvana-labs/nirvana-go/compute"
  "github.com/nirvana-labs/nirvana-go/option"
)

func main() {
  client := nirvana.NewClient(
    option.WithAPIKey("My API Key"),
  )
  err := client.Compute.Volumes.Availability.Update(
    context.TODO(),
    "volume_id",
    compute.VolumeAvailabilityUpdateParams{

    },
  )
  if err != nil {
    panic(err.Error())
  }
}
```
