Wait for instance to reach a target state
client.Instances.Wait(ctx, id, query) (*WaitForStateResponse, error)
/instances/{id}/wait
Blocks until the instance reaches the specified target state, the timeout expires, or the instance enters a terminal/error state. Useful for avoiding client-side polling when waiting for state transitions (e.g. waiting for an instance to become Running).
Parameters
id string
Returns
Wait for instance to reach a target state
package main
import (
"context"
"fmt"
"github.com/kernel/hypeman-go"
"github.com/kernel/hypeman-go/option"
)
func main() {
client := hypeman.NewClient(
option.WithAPIKey("My API Key"),
)
waitForStateResponse, err := client.Instances.Wait(
context.TODO(),
"id",
hypeman.InstanceWaitParams{
State: hypeman.InstanceWaitParamsStateCreated,
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", waitForStateResponse.State)
}
{
"state": "Created",
"timed_out": true,
"state_error": "state_error"
}
Returns Examples
{
"state": "Created",
"timed_out": true,
"state_error": "state_error"
}