Create VM
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)
}
{
"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"
}Returns Examples
{
"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"
}