waiters.go 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. // Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
  2. package s3
  3. import (
  4. "time"
  5. "github.com/aws/aws-sdk-go/aws"
  6. "github.com/aws/aws-sdk-go/aws/request"
  7. )
  8. // WaitUntilBucketExists uses the Amazon S3 API operation
  9. // HeadBucket 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 *S3) WaitUntilBucketExists(input *HeadBucketInput) error {
  13. return c.WaitUntilBucketExistsWithContext(aws.BackgroundContext(), input)
  14. }
  15. // WaitUntilBucketExistsWithContext is an extended version of WaitUntilBucketExists.
  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 *S3) WaitUntilBucketExistsWithContext(ctx aws.Context, input *HeadBucketInput, opts ...request.WaiterOption) error {
  24. w := request.Waiter{
  25. Name: "WaitUntilBucketExists",
  26. MaxAttempts: 20,
  27. Delay: request.ConstantWaiterDelay(5 * time.Second),
  28. Acceptors: []request.WaiterAcceptor{
  29. {
  30. State: request.SuccessWaiterState,
  31. Matcher: request.StatusWaiterMatch,
  32. Expected: 200,
  33. },
  34. {
  35. State: request.SuccessWaiterState,
  36. Matcher: request.StatusWaiterMatch,
  37. Expected: 301,
  38. },
  39. {
  40. State: request.SuccessWaiterState,
  41. Matcher: request.StatusWaiterMatch,
  42. Expected: 403,
  43. },
  44. {
  45. State: request.RetryWaiterState,
  46. Matcher: request.StatusWaiterMatch,
  47. Expected: 404,
  48. },
  49. },
  50. Logger: c.Config.Logger,
  51. NewRequest: func(opts []request.Option) (*request.Request, error) {
  52. var inCpy *HeadBucketInput
  53. if input != nil {
  54. tmp := *input
  55. inCpy = &tmp
  56. }
  57. req, _ := c.HeadBucketRequest(inCpy)
  58. req.SetContext(ctx)
  59. req.ApplyOptions(opts...)
  60. return req, nil
  61. },
  62. }
  63. w.ApplyOptions(opts...)
  64. return w.WaitWithContext(ctx)
  65. }
  66. // WaitUntilBucketNotExists uses the Amazon S3 API operation
  67. // HeadBucket to wait for a condition to be met before returning.
  68. // If the condition is not met within the max attempt window, an error will
  69. // be returned.
  70. func (c *S3) WaitUntilBucketNotExists(input *HeadBucketInput) error {
  71. return c.WaitUntilBucketNotExistsWithContext(aws.BackgroundContext(), input)
  72. }
  73. // WaitUntilBucketNotExistsWithContext is an extended version of WaitUntilBucketNotExists.
  74. // With the support for passing in a context and options to configure the
  75. // Waiter and the underlying request options.
  76. //
  77. // The context must be non-nil and will be used for request cancellation. If
  78. // the context is nil a panic will occur. In the future the SDK may create
  79. // sub-contexts for http.Requests. See https://golang.org/pkg/context/
  80. // for more information on using Contexts.
  81. func (c *S3) WaitUntilBucketNotExistsWithContext(ctx aws.Context, input *HeadBucketInput, opts ...request.WaiterOption) error {
  82. w := request.Waiter{
  83. Name: "WaitUntilBucketNotExists",
  84. MaxAttempts: 20,
  85. Delay: request.ConstantWaiterDelay(5 * time.Second),
  86. Acceptors: []request.WaiterAcceptor{
  87. {
  88. State: request.SuccessWaiterState,
  89. Matcher: request.StatusWaiterMatch,
  90. Expected: 404,
  91. },
  92. },
  93. Logger: c.Config.Logger,
  94. NewRequest: func(opts []request.Option) (*request.Request, error) {
  95. var inCpy *HeadBucketInput
  96. if input != nil {
  97. tmp := *input
  98. inCpy = &tmp
  99. }
  100. req, _ := c.HeadBucketRequest(inCpy)
  101. req.SetContext(ctx)
  102. req.ApplyOptions(opts...)
  103. return req, nil
  104. },
  105. }
  106. w.ApplyOptions(opts...)
  107. return w.WaitWithContext(ctx)
  108. }
  109. // WaitUntilObjectExists uses the Amazon S3 API operation
  110. // HeadObject to wait for a condition to be met before returning.
  111. // If the condition is not met within the max attempt window, an error will
  112. // be returned.
  113. func (c *S3) WaitUntilObjectExists(input *HeadObjectInput) error {
  114. return c.WaitUntilObjectExistsWithContext(aws.BackgroundContext(), input)
  115. }
  116. // WaitUntilObjectExistsWithContext is an extended version of WaitUntilObjectExists.
  117. // With the support for passing in a context and options to configure the
  118. // Waiter and the underlying request options.
  119. //
  120. // The context must be non-nil and will be used for request cancellation. If
  121. // the context is nil a panic will occur. In the future the SDK may create
  122. // sub-contexts for http.Requests. See https://golang.org/pkg/context/
  123. // for more information on using Contexts.
  124. func (c *S3) WaitUntilObjectExistsWithContext(ctx aws.Context, input *HeadObjectInput, opts ...request.WaiterOption) error {
  125. w := request.Waiter{
  126. Name: "WaitUntilObjectExists",
  127. MaxAttempts: 20,
  128. Delay: request.ConstantWaiterDelay(5 * time.Second),
  129. Acceptors: []request.WaiterAcceptor{
  130. {
  131. State: request.SuccessWaiterState,
  132. Matcher: request.StatusWaiterMatch,
  133. Expected: 200,
  134. },
  135. {
  136. State: request.RetryWaiterState,
  137. Matcher: request.StatusWaiterMatch,
  138. Expected: 404,
  139. },
  140. },
  141. Logger: c.Config.Logger,
  142. NewRequest: func(opts []request.Option) (*request.Request, error) {
  143. var inCpy *HeadObjectInput
  144. if input != nil {
  145. tmp := *input
  146. inCpy = &tmp
  147. }
  148. req, _ := c.HeadObjectRequest(inCpy)
  149. req.SetContext(ctx)
  150. req.ApplyOptions(opts...)
  151. return req, nil
  152. },
  153. }
  154. w.ApplyOptions(opts...)
  155. return w.WaitWithContext(ctx)
  156. }
  157. // WaitUntilObjectNotExists uses the Amazon S3 API operation
  158. // HeadObject to wait for a condition to be met before returning.
  159. // If the condition is not met within the max attempt window, an error will
  160. // be returned.
  161. func (c *S3) WaitUntilObjectNotExists(input *HeadObjectInput) error {
  162. return c.WaitUntilObjectNotExistsWithContext(aws.BackgroundContext(), input)
  163. }
  164. // WaitUntilObjectNotExistsWithContext is an extended version of WaitUntilObjectNotExists.
  165. // With the support for passing in a context and options to configure the
  166. // Waiter and the underlying request options.
  167. //
  168. // The context must be non-nil and will be used for request cancellation. If
  169. // the context is nil a panic will occur. In the future the SDK may create
  170. // sub-contexts for http.Requests. See https://golang.org/pkg/context/
  171. // for more information on using Contexts.
  172. func (c *S3) WaitUntilObjectNotExistsWithContext(ctx aws.Context, input *HeadObjectInput, opts ...request.WaiterOption) error {
  173. w := request.Waiter{
  174. Name: "WaitUntilObjectNotExists",
  175. MaxAttempts: 20,
  176. Delay: request.ConstantWaiterDelay(5 * time.Second),
  177. Acceptors: []request.WaiterAcceptor{
  178. {
  179. State: request.SuccessWaiterState,
  180. Matcher: request.StatusWaiterMatch,
  181. Expected: 404,
  182. },
  183. },
  184. Logger: c.Config.Logger,
  185. NewRequest: func(opts []request.Option) (*request.Request, error) {
  186. var inCpy *HeadObjectInput
  187. if input != nil {
  188. tmp := *input
  189. inCpy = &tmp
  190. }
  191. req, _ := c.HeadObjectRequest(inCpy)
  192. req.SetContext(ctx)
  193. req.ApplyOptions(opts...)
  194. return req, nil
  195. },
  196. }
  197. w.ApplyOptions(opts...)
  198. return w.WaitWithContext(ctx)
  199. }