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: current-state quote, post-update quote, and signed diff. current_summary and updated_summary omitted when the caller cannot view billing.

    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
    CurrentSummary OrganizationBillingSummaryOptional

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

    DailyCost string

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

    formatdecimal
    EffectiveBalance string

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

    formatdecimal
    MonthlyCost string

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

    formatdecimal
    RechargeThresholdDays string

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

    formatdecimal
    EstimatedNextChargeAt TimeOptional

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

    formatdate-time
    RunwayMonths stringOptional

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

    formatdecimal
    UpdatedSummary OrganizationBillingSummaryOptional

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

    DailyCost string

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

    formatdecimal
    EffectiveBalance string

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

    formatdecimal
    MonthlyCost string

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

    formatdecimal
    RechargeThresholdDays string

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

    formatdecimal
    EstimatedNextChargeAt TimeOptional

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

    formatdate-time
    RunwayMonths stringOptional

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

    formatdecimal

    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",
      "current_summary": {
        "daily_cost": "-69125",
        "effective_balance": "-69125",
        "monthly_cost": "-69125",
        "recharge_threshold_days": "-69125",
        "estimated_next_charge_at": "2025-01-01T00:00:00Z",
        "runway_months": "-69125"
      },
      "updated_summary": {
        "daily_cost": "-69125",
        "effective_balance": "-69125",
        "monthly_cost": "-69125",
        "recharge_threshold_days": "-69125",
        "estimated_next_charge_at": "2025-01-01T00:00:00Z",
        "runway_months": "-69125"
      }
    }
    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",
      "current_summary": {
        "daily_cost": "-69125",
        "effective_balance": "-69125",
        "monthly_cost": "-69125",
        "recharge_threshold_days": "-69125",
        "estimated_next_charge_at": "2025-01-01T00:00:00Z",
        "runway_months": "-69125"
      },
      "updated_summary": {
        "daily_cost": "-69125",
        "effective_balance": "-69125",
        "monthly_cost": "-69125",
        "recharge_threshold_days": "-69125",
        "estimated_next_charge_at": "2025-01-01T00:00:00Z",
        "runway_months": "-69125"
      }
    }