1// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. 2 3package cloudwatch 4 5import ( 6 "time" 7 8 "github.com/aws/aws-sdk-go/aws" 9 "github.com/aws/aws-sdk-go/aws/request" 10) 11 12// WaitUntilAlarmExists uses the CloudWatch API operation 13// DescribeAlarms to wait for a condition to be met before returning. 14// If the condition is not met within the max attempt window, an error will 15// be returned. 16func (c *CloudWatch) WaitUntilAlarmExists(input *DescribeAlarmsInput) error { 17 return c.WaitUntilAlarmExistsWithContext(aws.BackgroundContext(), input) 18} 19 20// WaitUntilAlarmExistsWithContext is an extended version of WaitUntilAlarmExists. 21// With the support for passing in a context and options to configure the 22// Waiter and the underlying request options. 23// 24// The context must be non-nil and will be used for request cancellation. If 25// the context is nil a panic will occur. In the future the SDK may create 26// sub-contexts for http.Requests. See https://golang.org/pkg/context/ 27// for more information on using Contexts. 28func (c *CloudWatch) WaitUntilAlarmExistsWithContext(ctx aws.Context, input *DescribeAlarmsInput, opts ...request.WaiterOption) error { 29 w := request.Waiter{ 30 Name: "WaitUntilAlarmExists", 31 MaxAttempts: 40, 32 Delay: request.ConstantWaiterDelay(5 * time.Second), 33 Acceptors: []request.WaiterAcceptor{ 34 { 35 State: request.SuccessWaiterState, 36 Matcher: request.PathWaiterMatch, Argument: "length(MetricAlarms[]) > `0`", 37 Expected: true, 38 }, 39 }, 40 Logger: c.Config.Logger, 41 NewRequest: func(opts []request.Option) (*request.Request, error) { 42 var inCpy *DescribeAlarmsInput 43 if input != nil { 44 tmp := *input 45 inCpy = &tmp 46 } 47 req, _ := c.DescribeAlarmsRequest(inCpy) 48 req.SetContext(ctx) 49 req.ApplyOptions(opts...) 50 return req, nil 51 }, 52 } 53 w.ApplyOptions(opts...) 54 55 return w.WaitWithContext(ctx) 56} 57