# VPCs

## Create VPC

`client.Networking.VPCs.New(ctx, body) (*Operation, error)`

**post** `/v1/networking/vpcs`

Create a VPC

### Parameters

- `body VPCNewParams`

  - `Name param.Field[string]`

    Name of the VPC.

  - `ProjectID param.Field[string]`

    Project ID the VPC belongs to.

  - `Region param.Field[RegionName]`

    Region the resource is in.

  - `SubnetName param.Field[string]`

    Name of the subnet to create.

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

    Tags to attach to the VPC.

### 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/networking"
  "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.Networking.VPCs.New(context.TODO(), networking.VPCNewParams{
    Name: "my-vpc",
    ProjectID: "123e4567-e89b-12d3-a456-426614174000",
    Region: shared.RegionNameUsSva2,
    SubnetName: "my-subnet",
  })
  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 VPC Details

`client.Networking.VPCs.Get(ctx, vpcID) (*VPC, error)`

**get** `/v1/networking/vpcs/{vpc_id}`

Get details about a VPC

### Parameters

- `vpcID string`

### Returns

- `type VPC struct{…}`

  VPC details.

  - `ID string`

    Unique identifier for the VPC.

  - `CreatedAt Time`

    When the VPC was created.

  - `FirewallRuleIDs []string`

    IDs of the Firewall Rules associated with the VPC.

  - `Name string`

    Name of the VPC.

  - `ProjectID string`

    Project ID the VPC belongs to.

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

  - `Subnet Subnet`

    Subnet of the VPC.

    - `ID string`

      Unique identifier for the Subnet.

    - `CIDR string`

      CIDR block for the Subnet.

    - `CreatedAt Time`

      When the Subnet was created.

    - `Name string`

      Name of the Subnet.

    - `UpdatedAt Time`

      When the Subnet was updated.

  - `Tags []string`

    Tags to attach to the VPC.

  - `UpdatedAt Time`

    When the VPC 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"),
  )
  vpc, err := client.Networking.VPCs.Get(context.TODO(), "vpc_id")
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", vpc.ID)
}
```

#### Response

```json
{
  "id": "123e4567-e89b-12d3-a456-426614174000",
  "created_at": "2025-01-01T00:00:00Z",
  "firewall_rule_ids": [
    "123e4567-e89b-12d3-a456-426614174001",
    "123e4567-e89b-12d3-a456-426614174002"
  ],
  "name": "my-vpc",
  "project_id": "123e4567-e89b-12d3-a456-426614174000",
  "region": "us-sva-2",
  "status": "ready",
  "subnet": {
    "id": "123e4567-e89b-12d3-a456-426614174000",
    "cidr": "10.128.35.128/25",
    "created_at": "2025-01-01T00:00:00Z",
    "name": "my-subnet",
    "updated_at": "2025-01-01T00:00:00Z"
  },
  "tags": [
    "production",
    "ethereum"
  ],
  "updated_at": "2025-01-01T00:00:00Z"
}
```

## Update VPC

`client.Networking.VPCs.Update(ctx, vpcID, body) (*Operation, error)`

**patch** `/v1/networking/vpcs/{vpc_id}`

Update a VPC

### Parameters

- `vpcID string`

- `body VPCUpdateParams`

  - `Name param.Field[string]`

    Name of the VPC.

  - `SubnetName param.Field[string]`

    Name of the subnet to create.

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

    Tags to attach to the VPC.

### 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/networking"
  "github.com/nirvana-labs/nirvana-go/option"
)

func main() {
  client := nirvana.NewClient(
    option.WithAPIKey("My API Key"),
  )
  operation, err := client.Networking.VPCs.Update(
    context.TODO(),
    "vpc_id",
    networking.VPCUpdateParams{

    },
  )
  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 VPC

`client.Networking.VPCs.Delete(ctx, vpcID) (*Operation, error)`

**delete** `/v1/networking/vpcs/{vpc_id}`

Delete a VPC

### Parameters

- `vpcID 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.Networking.VPCs.Delete(context.TODO(), "vpc_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 VPCs

`client.Networking.VPCs.List(ctx, query) (*Cursor[VPC], error)`

**get** `/v1/networking/vpcs`

List all VPCs

### Parameters

- `query VPCListParams`

  - `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 VPC struct{…}`

  VPC details.

  - `ID string`

    Unique identifier for the VPC.

  - `CreatedAt Time`

    When the VPC was created.

  - `FirewallRuleIDs []string`

    IDs of the Firewall Rules associated with the VPC.

  - `Name string`

    Name of the VPC.

  - `ProjectID string`

    Project ID the VPC belongs to.

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

  - `Subnet Subnet`

    Subnet of the VPC.

    - `ID string`

      Unique identifier for the Subnet.

    - `CIDR string`

      CIDR block for the Subnet.

    - `CreatedAt Time`

      When the Subnet was created.

    - `Name string`

      Name of the Subnet.

    - `UpdatedAt Time`

      When the Subnet was updated.

  - `Tags []string`

    Tags to attach to the VPC.

  - `UpdatedAt Time`

    When the VPC was updated.

### Example

```go
package main

import (
  "context"
  "fmt"

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

func main() {
  client := nirvana.NewClient(
    option.WithAPIKey("My API Key"),
  )
  page, err := client.Networking.VPCs.List(context.TODO(), networking.VPCListParams{
    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",
      "firewall_rule_ids": [
        "123e4567-e89b-12d3-a456-426614174001",
        "123e4567-e89b-12d3-a456-426614174002"
      ],
      "name": "my-vpc",
      "project_id": "123e4567-e89b-12d3-a456-426614174000",
      "region": "us-sva-2",
      "status": "ready",
      "subnet": {
        "id": "123e4567-e89b-12d3-a456-426614174000",
        "cidr": "10.128.35.128/25",
        "created_at": "2025-01-01T00:00:00Z",
        "name": "my-subnet",
        "updated_at": "2025-01-01T00:00:00Z"
      },
      "tags": [
        "production",
        "ethereum"
      ],
      "updated_at": "2025-01-01T00:00:00Z"
    }
  ],
  "pagination": {
    "next_cursor": "RhwniMT4B74siYZcPF8TnCdGI1l9rpPvg",
    "previous_cursor": "ARhwnmi1hA7wEbHbMjdYQlOB_ZusP4fYvw",
    "total_count": 125
  }
}
```

## Domain Types

### Subnet

- `type Subnet struct{…}`

  Subnet of the VPC.

  - `ID string`

    Unique identifier for the Subnet.

  - `CIDR string`

    CIDR block for the Subnet.

  - `CreatedAt Time`

    When the Subnet was created.

  - `Name string`

    Name of the Subnet.

  - `UpdatedAt Time`

    When the Subnet was updated.

### VPC

- `type VPC struct{…}`

  VPC details.

  - `ID string`

    Unique identifier for the VPC.

  - `CreatedAt Time`

    When the VPC was created.

  - `FirewallRuleIDs []string`

    IDs of the Firewall Rules associated with the VPC.

  - `Name string`

    Name of the VPC.

  - `ProjectID string`

    Project ID the VPC belongs to.

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

  - `Subnet Subnet`

    Subnet of the VPC.

    - `ID string`

      Unique identifier for the Subnet.

    - `CIDR string`

      CIDR block for the Subnet.

    - `CreatedAt Time`

      When the Subnet was created.

    - `Name string`

      Name of the Subnet.

    - `UpdatedAt Time`

      When the Subnet was updated.

  - `Tags []string`

    Tags to attach to the VPC.

  - `UpdatedAt Time`

    When the VPC was updated.

### VPC List

- `type VPCList struct{…}`

  - `Items []VPC`

    - `ID string`

      Unique identifier for the VPC.

    - `CreatedAt Time`

      When the VPC was created.

    - `FirewallRuleIDs []string`

      IDs of the Firewall Rules associated with the VPC.

    - `Name string`

      Name of the VPC.

    - `ProjectID string`

      Project ID the VPC belongs to.

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

    - `Subnet Subnet`

      Subnet of the VPC.

      - `ID string`

        Unique identifier for the Subnet.

      - `CIDR string`

        CIDR block for the Subnet.

      - `CreatedAt Time`

        When the Subnet was created.

      - `Name string`

        Name of the Subnet.

      - `UpdatedAt Time`

        When the Subnet was updated.

    - `Tags []string`

      Tags to attach to the VPC.

    - `UpdatedAt Time`

      When the VPC was updated.

  - `Pagination Pagination`

    Pagination response details.

    - `NextCursor string`

    - `PreviousCursor string`

    - `TotalCount int64`

# Availability

## Check Create VPC Availability

`client.Networking.VPCs.Availability.New(ctx, body) error`

**post** `/v1/networking/vpcs/availability`

Check if a VPC can be created

### Parameters

- `body VPCAvailabilityNewParams`

  - `Name param.Field[string]`

    Name of the VPC.

  - `ProjectID param.Field[string]`

    Project ID the VPC belongs to.

  - `Region param.Field[RegionName]`

    Region the resource is in.

  - `SubnetName param.Field[string]`

    Name of the subnet to create.

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

    Tags to attach to the VPC.

### Example

```go
package main

import (
  "context"

  "github.com/nirvana-labs/nirvana-go"
  "github.com/nirvana-labs/nirvana-go/networking"
  "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.Networking.VPCs.Availability.New(context.TODO(), networking.VPCAvailabilityNewParams{
    Name: "my-vpc",
    ProjectID: "123e4567-e89b-12d3-a456-426614174000",
    Region: shared.RegionNameUsSva2,
    SubnetName: "my-subnet",
  })
  if err != nil {
    panic(err.Error())
  }
}
```

## Check Update VPC Availability

`client.Networking.VPCs.Availability.Update(ctx, vpcID, body) error`

**patch** `/v1/networking/vpcs/{vpc_id}/availability`

Check if a VPC can be updated

### Parameters

- `vpcID string`

- `body VPCAvailabilityUpdateParams`

  - `Name param.Field[string]`

    Name of the VPC.

  - `SubnetName param.Field[string]`

    Name of the subnet to create.

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

    Tags to attach to the VPC.

### Example

```go
package main

import (
  "context"

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

func main() {
  client := nirvana.NewClient(
    option.WithAPIKey("My API Key"),
  )
  err := client.Networking.VPCs.Availability.Update(
    context.TODO(),
    "vpc_id",
    networking.VPCAvailabilityUpdateParams{

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