github.com/aavshr/aws-sdk-go@v1.41.3/service/dynamodb/waiters.go (about)

     1  // Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
     2  
     3  package dynamodb
     4  
     5  import (
     6  	"time"
     7  
     8  	"github.com/aavshr/aws-sdk-go/aws"
     9  	"github.com/aavshr/aws-sdk-go/aws/request"
    10  )
    11  
    12  // WaitUntilTableExists uses the DynamoDB API operation
    13  // DescribeTable 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.
    16  func (c *DynamoDB) WaitUntilTableExists(input *DescribeTableInput) error {
    17  	return c.WaitUntilTableExistsWithContext(aws.BackgroundContext(), input)
    18  }
    19  
    20  // WaitUntilTableExistsWithContext is an extended version of WaitUntilTableExists.
    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.
    28  func (c *DynamoDB) WaitUntilTableExistsWithContext(ctx aws.Context, input *DescribeTableInput, opts ...request.WaiterOption) error {
    29  	w := request.Waiter{
    30  		Name:        "WaitUntilTableExists",
    31  		MaxAttempts: 25,
    32  		Delay:       request.ConstantWaiterDelay(20 * time.Second),
    33  		Acceptors: []request.WaiterAcceptor{
    34  			{
    35  				State:   request.SuccessWaiterState,
    36  				Matcher: request.PathWaiterMatch, Argument: "Table.TableStatus",
    37  				Expected: "ACTIVE",
    38  			},
    39  			{
    40  				State:    request.RetryWaiterState,
    41  				Matcher:  request.ErrorWaiterMatch,
    42  				Expected: "ResourceNotFoundException",
    43  			},
    44  		},
    45  		Logger: c.Config.Logger,
    46  		NewRequest: func(opts []request.Option) (*request.Request, error) {
    47  			var inCpy *DescribeTableInput
    48  			if input != nil {
    49  				tmp := *input
    50  				inCpy = &tmp
    51  			}
    52  			req, _ := c.DescribeTableRequest(inCpy)
    53  			req.SetContext(ctx)
    54  			req.ApplyOptions(opts...)
    55  			return req, nil
    56  		},
    57  	}
    58  	w.ApplyOptions(opts...)
    59  
    60  	return w.WaitWithContext(ctx)
    61  }
    62  
    63  // WaitUntilTableNotExists uses the DynamoDB API operation
    64  // DescribeTable to wait for a condition to be met before returning.
    65  // If the condition is not met within the max attempt window, an error will
    66  // be returned.
    67  func (c *DynamoDB) WaitUntilTableNotExists(input *DescribeTableInput) error {
    68  	return c.WaitUntilTableNotExistsWithContext(aws.BackgroundContext(), input)
    69  }
    70  
    71  // WaitUntilTableNotExistsWithContext is an extended version of WaitUntilTableNotExists.
    72  // With the support for passing in a context and options to configure the
    73  // Waiter and the underlying request options.
    74  //
    75  // The context must be non-nil and will be used for request cancellation. If
    76  // the context is nil a panic will occur. In the future the SDK may create
    77  // sub-contexts for http.Requests. See https://golang.org/pkg/context/
    78  // for more information on using Contexts.
    79  func (c *DynamoDB) WaitUntilTableNotExistsWithContext(ctx aws.Context, input *DescribeTableInput, opts ...request.WaiterOption) error {
    80  	w := request.Waiter{
    81  		Name:        "WaitUntilTableNotExists",
    82  		MaxAttempts: 25,
    83  		Delay:       request.ConstantWaiterDelay(20 * time.Second),
    84  		Acceptors: []request.WaiterAcceptor{
    85  			{
    86  				State:    request.SuccessWaiterState,
    87  				Matcher:  request.ErrorWaiterMatch,
    88  				Expected: "ResourceNotFoundException",
    89  			},
    90  		},
    91  		Logger: c.Config.Logger,
    92  		NewRequest: func(opts []request.Option) (*request.Request, error) {
    93  			var inCpy *DescribeTableInput
    94  			if input != nil {
    95  				tmp := *input
    96  				inCpy = &tmp
    97  			}
    98  			req, _ := c.DescribeTableRequest(inCpy)
    99  			req.SetContext(ctx)
   100  			req.ApplyOptions(opts...)
   101  			return req, nil
   102  		},
   103  	}
   104  	w.ApplyOptions(opts...)
   105  
   106  	return w.WaitWithContext(ctx)
   107  }