waiters.go 1.8 KB

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