Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WaitForActive ¶
WaitForActive waits for a droplet to become active
Example ¶
// Create a godo client. client := godo.NewFromToken("dop_v1_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx") // Create a Droplet. droplet, resp, err := client.Droplets.Create(context.Background(), &godo.DropletCreateRequest{ Name: "test-droplet", Region: "nyc3", Size: "s-1vcpu-1gb", Image: godo.DropletCreateImage{ Slug: "ubuntu-20-04-x64", }, }) if err != nil { log.Fatalf("failed to create droplet: %v\n", err) } // Find the Droplet 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 droplet to become active: %v\n", err) } } } fmt.Println(droplet.Name)
Output:
func WaitForAvailable ¶ added in v1.90.0
WaitForAvailable waits for a image to become available
Example ¶
// Create a godo client. client := godo.NewFromToken("dop_v1_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx") // Create an Image. image, resp, err := client.Images.Create(context.Background(), &godo.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.