Skip to content
Docs

Estimate VM Update Cost

client.Compute.VMs.Cost.Update(ctx, vmID, body) (*CostQuoteUpdate, error)
PATCH/v1/compute/vms/{vm_id}/cost

Return a priced cost quote for the proposed VM update plus a diff against the current state.

ParametersExpand Collapse
vmID string
body VMCostUpdateParams
InstanceType param.Field[string]Optional

Instance type name.

Name param.Field[string]Optional

Name of the VM.

PublicIPEnabled param.Field[bool]Optional

Whether to enable public IP for the VM.

Tags param.Field[[]string]Optional

Tags to attach to the VM.

ReturnsExpand Collapse
type CostQuoteUpdate struct{…}

Cost quote returned by PATCH /:id/cost: the current-state quote, the post-update quote, and the signed diff.

After CostQuoteUpdateAfter

Quote for the proposed (post-update) resource state.

MonthlyTotal string

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

formatdecimal
UsageDimensions []CostQuoteUpdateAfterUsageDimension

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

Dimension string

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

DimensionDisplayName string

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

MonthlyAmount string

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

formatdecimal
Quantity int64

Quantity of the dimension being priced.

UnitPrice string

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

formatdecimal
Before CostQuoteUpdateBefore

Quote for the proposed (post-update) resource state.

MonthlyTotal string

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

formatdecimal
UsageDimensions []CostQuoteUpdateBeforeUsageDimension

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

Dimension string

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

DimensionDisplayName string

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

MonthlyAmount string

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

formatdecimal
Quantity int64

Quantity of the dimension being priced.

UnitPrice string

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

formatdecimal
Currency string

Currency the quote is denominated in. Always “USD” in v1.

Diff CostQuoteUpdateDiff

Per-dimension and total deltas: after minus before.

MonthlyTotalDelta string

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

formatdecimal
UsageDimensions []CostQuoteUpdateDiffUsageDimension

Per-dimension diff entries. Includes every dimension touched by the update.

After CostQuoteUpdateDiffUsageDimensionAfter

Priced row after the update. Always present.

MonthlyAmount string

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

formatdecimal
Quantity int64
UnitPrice string

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

formatdecimal
Before CostQuoteUpdateDiffUsageDimensionBefore

Priced row after the update. Always present.

MonthlyAmount string

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

formatdecimal
Quantity int64
UnitPrice string

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

formatdecimal
Dimension string

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

DimensionDisplayName string

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

MonthlyAmountDelta string

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

formatdecimal
PricedAt Time

Timestamp the quote was priced at.

formatdate-time

Estimate VM Update Cost

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"),
  )
  costQuoteUpdate, err := client.Compute.VMs.Cost.Update(
    context.TODO(),
    "vm_id",
    compute.VMCostUpdateParams{

    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", costQuoteUpdate.After)
}
{
  "after": {
    "monthly_total": "-69125",
    "usage_dimensions": [
      {
        "dimension": "compute_vcpu",
        "dimension_display_name": "vCPU (hours)",
        "monthly_amount": "-69125",
        "quantity": 4,
        "unit_price": "-69125"
      }
    ]
  },
  "before": {
    "monthly_total": "-69125",
    "usage_dimensions": [
      {
        "dimension": "compute_vcpu",
        "dimension_display_name": "vCPU (hours)",
        "monthly_amount": "-69125",
        "quantity": 4,
        "unit_price": "-69125"
      }
    ]
  },
  "currency": "USD",
  "diff": {
    "monthly_total_delta": "-69125",
    "usage_dimensions": [
      {
        "after": {
          "monthly_amount": "-69125",
          "quantity": 4,
          "unit_price": "-69125"
        },
        "before": {
          "monthly_amount": "-69125",
          "quantity": 4,
          "unit_price": "-69125"
        },
        "dimension": "compute_vcpu",
        "dimension_display_name": "vCPU (hours)",
        "monthly_amount_delta": "-69125"
      }
    ]
  },
  "priced_at": "2025-01-01T00:00:00Z"
}
Returns Examples
{
  "after": {
    "monthly_total": "-69125",
    "usage_dimensions": [
      {
        "dimension": "compute_vcpu",
        "dimension_display_name": "vCPU (hours)",
        "monthly_amount": "-69125",
        "quantity": 4,
        "unit_price": "-69125"
      }
    ]
  },
  "before": {
    "monthly_total": "-69125",
    "usage_dimensions": [
      {
        "dimension": "compute_vcpu",
        "dimension_display_name": "vCPU (hours)",
        "monthly_amount": "-69125",
        "quantity": 4,
        "unit_price": "-69125"
      }
    ]
  },
  "currency": "USD",
  "diff": {
    "monthly_total_delta": "-69125",
    "usage_dimensions": [
      {
        "after": {
          "monthly_amount": "-69125",
          "quantity": 4,
          "unit_price": "-69125"
        },
        "before": {
          "monthly_amount": "-69125",
          "quantity": 4,
          "unit_price": "-69125"
        },
        "dimension": "compute_vcpu",
        "dimension_display_name": "vCPU (hours)",
        "monthly_amount_delta": "-69125"
      }
    ]
  },
  "priced_at": "2025-01-01T00:00:00Z"
}