waiters.go 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. // Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
  2. package autoscaling
  3. import (
  4. "time"
  5. "github.com/aws/aws-sdk-go/aws"
  6. "github.com/aws/aws-sdk-go/aws/request"
  7. )
  8. // WaitUntilGroupExists uses the Auto Scaling API operation
  9. // DescribeAutoScalingGroups 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 *AutoScaling) WaitUntilGroupExists(input *DescribeAutoScalingGroupsInput) error {
  13. return c.WaitUntilGroupExistsWithContext(aws.BackgroundContext(), input)
  14. }
  15. // WaitUntilGroupExistsWithContext is an extended version of WaitUntilGroupExists.
  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 *AutoScaling) WaitUntilGroupExistsWithContext(ctx aws.Context, input *DescribeAutoScalingGroupsInput, opts ...request.WaiterOption) error {
  24. w := request.Waiter{
  25. Name: "WaitUntilGroupExists",
  26. MaxAttempts: 10,
  27. Delay: request.ConstantWaiterDelay(5 * time.Second),
  28. Acceptors: []request.WaiterAcceptor{
  29. {
  30. State: request.SuccessWaiterState,
  31. Matcher: request.PathWaiterMatch, Argument: "length(AutoScalingGroups) > `0`",
  32. Expected: true,
  33. },
  34. {
  35. State: request.RetryWaiterState,
  36. Matcher: request.PathWaiterMatch, Argument: "length(AutoScalingGroups) > `0`",
  37. Expected: false,
  38. },
  39. },
  40. Logger: c.Config.Logger,
  41. NewRequest: func(opts []request.Option) (*request.Request, error) {
  42. var inCpy *DescribeAutoScalingGroupsInput
  43. if input != nil {
  44. tmp := *input
  45. inCpy = &tmp
  46. }
  47. req, _ := c.DescribeAutoScalingGroupsRequest(inCpy)
  48. req.SetContext(ctx)
  49. req.ApplyOptions(opts...)
  50. return req, nil
  51. },
  52. }
  53. w.ApplyOptions(opts...)
  54. return w.WaitWithContext(ctx)
  55. }
  56. // WaitUntilGroupInService uses the Auto Scaling API operation
  57. // DescribeAutoScalingGroups to wait for a condition to be met before returning.
  58. // If the condition is not met within the max attempt window, an error will
  59. // be returned.
  60. func (c *AutoScaling) WaitUntilGroupInService(input *DescribeAutoScalingGroupsInput) error {
  61. return c.WaitUntilGroupInServiceWithContext(aws.BackgroundContext(), input)
  62. }
  63. // WaitUntilGroupInServiceWithContext is an extended version of WaitUntilGroupInService.
  64. // With the support for passing in a context and options to configure the
  65. // Waiter and the underlying request options.
  66. //
  67. // The context must be non-nil and will be used for request cancellation. If
  68. // the context is nil a panic will occur. In the future the SDK may create
  69. // sub-contexts for http.Requests. See https://golang.org/pkg/context/
  70. // for more information on using Contexts.
  71. func (c *AutoScaling) WaitUntilGroupInServiceWithContext(ctx aws.Context, input *DescribeAutoScalingGroupsInput, opts ...request.WaiterOption) error {
  72. w := request.Waiter{
  73. Name: "WaitUntilGroupInService",
  74. MaxAttempts: 40,
  75. Delay: request.ConstantWaiterDelay(15 * time.Second),
  76. Acceptors: []request.WaiterAcceptor{
  77. {
  78. State: request.SuccessWaiterState,
  79. Matcher: request.PathWaiterMatch, Argument: "contains(AutoScalingGroups[].[length(Instances[?LifecycleState=='InService']) >= MinSize][], `false`)",
  80. Expected: false,
  81. },
  82. {
  83. State: request.RetryWaiterState,
  84. Matcher: request.PathWaiterMatch, Argument: "contains(AutoScalingGroups[].[length(Instances[?LifecycleState=='InService']) >= MinSize][], `false`)",
  85. Expected: true,
  86. },
  87. },
  88. Logger: c.Config.Logger,
  89. NewRequest: func(opts []request.Option) (*request.Request, error) {
  90. var inCpy *DescribeAutoScalingGroupsInput
  91. if input != nil {
  92. tmp := *input
  93. inCpy = &tmp
  94. }
  95. req, _ := c.DescribeAutoScalingGroupsRequest(inCpy)
  96. req.SetContext(ctx)
  97. req.ApplyOptions(opts...)
  98. return req, nil
  99. },
  100. }
  101. w.ApplyOptions(opts...)
  102. return w.WaitWithContext(ctx)
  103. }
  104. // WaitUntilGroupNotExists uses the Auto Scaling API operation
  105. // DescribeAutoScalingGroups to wait for a condition to be met before returning.
  106. // If the condition is not met within the max attempt window, an error will
  107. // be returned.
  108. func (c *AutoScaling) WaitUntilGroupNotExists(input *DescribeAutoScalingGroupsInput) error {
  109. return c.WaitUntilGroupNotExistsWithContext(aws.BackgroundContext(), input)
  110. }
  111. // WaitUntilGroupNotExistsWithContext is an extended version of WaitUntilGroupNotExists.
  112. // With the support for passing in a context and options to configure the
  113. // Waiter and the underlying request options.
  114. //
  115. // The context must be non-nil and will be used for request cancellation. If
  116. // the context is nil a panic will occur. In the future the SDK may create
  117. // sub-contexts for http.Requests. See https://golang.org/pkg/context/
  118. // for more information on using Contexts.
  119. func (c *AutoScaling) WaitUntilGroupNotExistsWithContext(ctx aws.Context, input *DescribeAutoScalingGroupsInput, opts ...request.WaiterOption) error {
  120. w := request.Waiter{
  121. Name: "WaitUntilGroupNotExists",
  122. MaxAttempts: 40,
  123. Delay: request.ConstantWaiterDelay(15 * time.Second),
  124. Acceptors: []request.WaiterAcceptor{
  125. {
  126. State: request.SuccessWaiterState,
  127. Matcher: request.PathWaiterMatch, Argument: "length(AutoScalingGroups) > `0`",
  128. Expected: false,
  129. },
  130. {
  131. State: request.RetryWaiterState,
  132. Matcher: request.PathWaiterMatch, Argument: "length(AutoScalingGroups) > `0`",
  133. Expected: true,
  134. },
  135. },
  136. Logger: c.Config.Logger,
  137. NewRequest: func(opts []request.Option) (*request.Request, error) {
  138. var inCpy *DescribeAutoScalingGroupsInput
  139. if input != nil {
  140. tmp := *input
  141. inCpy = &tmp
  142. }
  143. req, _ := c.DescribeAutoScalingGroupsRequest(inCpy)
  144. req.SetContext(ctx)
  145. req.ApplyOptions(opts...)
  146. return req, nil
  147. },
  148. }
  149. w.ApplyOptions(opts...)
  150. return w.WaitWithContext(ctx)
  151. }