waiters.go 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. // Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
  2. package dynamodb
  3. import (
  4. "time"
  5. "github.com/aws/aws-sdk-go/aws"
  6. "github.com/aws/aws-sdk-go/aws/request"
  7. )
  8. // WaitUntilTableExists uses the DynamoDB API operation
  9. // DescribeTable 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 *DynamoDB) WaitUntilTableExists(input *DescribeTableInput) error {
  13. return c.WaitUntilTableExistsWithContext(aws.BackgroundContext(), input)
  14. }
  15. // WaitUntilTableExistsWithContext is an extended version of WaitUntilTableExists.
  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 *DynamoDB) WaitUntilTableExistsWithContext(ctx aws.Context, input *DescribeTableInput, opts ...request.WaiterOption) error {
  24. w := request.Waiter{
  25. Name: "WaitUntilTableExists",
  26. MaxAttempts: 25,
  27. Delay: request.ConstantWaiterDelay(20 * time.Second),
  28. Acceptors: []request.WaiterAcceptor{
  29. {
  30. State: request.SuccessWaiterState,
  31. Matcher: request.PathWaiterMatch, Argument: "Table.TableStatus",
  32. Expected: "ACTIVE",
  33. },
  34. {
  35. State: request.RetryWaiterState,
  36. Matcher: request.ErrorWaiterMatch,
  37. Expected: "ResourceNotFoundException",
  38. },
  39. },
  40. Logger: c.Config.Logger,
  41. NewRequest: func(opts []request.Option) (*request.Request, error) {
  42. var inCpy *DescribeTableInput
  43. if input != nil {
  44. tmp := *input
  45. inCpy = &tmp
  46. }
  47. req, _ := c.DescribeTableRequest(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. // WaitUntilTableNotExists uses the DynamoDB API operation
  57. // DescribeTable 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 *DynamoDB) WaitUntilTableNotExists(input *DescribeTableInput) error {
  61. return c.WaitUntilTableNotExistsWithContext(aws.BackgroundContext(), input)
  62. }
  63. // WaitUntilTableNotExistsWithContext is an extended version of WaitUntilTableNotExists.
  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 *DynamoDB) WaitUntilTableNotExistsWithContext(ctx aws.Context, input *DescribeTableInput, opts ...request.WaiterOption) error {
  72. w := request.Waiter{
  73. Name: "WaitUntilTableNotExists",
  74. MaxAttempts: 25,
  75. Delay: request.ConstantWaiterDelay(20 * time.Second),
  76. Acceptors: []request.WaiterAcceptor{
  77. {
  78. State: request.SuccessWaiterState,
  79. Matcher: request.ErrorWaiterMatch,
  80. Expected: "ResourceNotFoundException",
  81. },
  82. },
  83. Logger: c.Config.Logger,
  84. NewRequest: func(opts []request.Option) (*request.Request, error) {
  85. var inCpy *DescribeTableInput
  86. if input != nil {
  87. tmp := *input
  88. inCpy = &tmp
  89. }
  90. req, _ := c.DescribeTableRequest(inCpy)
  91. req.SetContext(ctx)
  92. req.ApplyOptions(opts...)
  93. return req, nil
  94. },
  95. }
  96. w.ApplyOptions(opts...)
  97. return w.WaitWithContext(ctx)
  98. }