Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WaitForActive ¶
WaitForActive waits for a vm to become active
Example ¶
// Create a goApiAbrha client. client := goApiAbrha.NewFromToken("dop_v1_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx") // Create a Vm. vmRoot, resp, err := client.Vms.Create(context.Background(), &goApiAbrha.VmCreateRequest{ Name: "test-vm", Region: "nyc3", Size: "s-1vcpu-1gb", Image: goApiAbrha.VmCreateImage{ Slug: "ubuntu-20-04-x64", }, }) if err != nil { log.Fatalf("failed to create vm: %v\n", err) } // Find the Vm create action, then wait for it to complete. for _, action := range resp.Links.Actions { if action.Rel == "create" { // Block until the action is complete. if err := WaitForActive(context.Background(), client, action.HREF); err != nil { log.Fatalf("error waiting for vm to become active: %v\n", err) } } } fmt.Println(vmRoot.Vm.Name)
Output:
func WaitForAvailable ¶
WaitForAvailable waits for an image to become available
Example ¶
// Create a goApiAbrha client. client := goApiAbrha.NewFromToken("dop_v1_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx") // Create an Image. image, resp, err := client.Images.Create(context.Background(), &goApiAbrha.CustomImageCreateRequest{ Name: "test-image", Url: "https://cloud-images.ubuntu.com/releases/focal/release/ubuntu-20.04-server-cloudimg-amd64.vmdk", Region: "nyc3", }) if err != nil { log.Fatalf("failed to create image: %v\n", err) } // Find the Image create action, then wait for it to complete. for _, action := range resp.Links.Actions { if action.Rel == "create" { // Block until the action is complete. if err := WaitForAvailable(context.Background(), client, action.HREF); err != nil { log.Fatalf("error waiting for image to become active: %v\n", err) } } } fmt.Println(image.Name)
Output:
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.