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

     1  // Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
     2  
     3  package redshift
     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  // WaitUntilClusterAvailable uses the Amazon Redshift API operation
    13  // DescribeClusters 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 *Redshift) WaitUntilClusterAvailable(input *DescribeClustersInput) error {
    17  	return c.WaitUntilClusterAvailableWithContext(aws.BackgroundContext(), input)
    18  }
    19  
    20  // WaitUntilClusterAvailableWithContext is an extended version of WaitUntilClusterAvailable.
    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 *Redshift) WaitUntilClusterAvailableWithContext(ctx aws.Context, input *DescribeClustersInput, opts ...request.WaiterOption) error {
    29  	w := request.Waiter{
    30  		Name:        "WaitUntilClusterAvailable",
    31  		MaxAttempts: 30,
    32  		Delay:       request.ConstantWaiterDelay(60 * time.Second),
    33  		Acceptors: []request.WaiterAcceptor{
    34  			{
    35  				State:   request.SuccessWaiterState,
    36  				Matcher: request.PathAllWaiterMatch, Argument: "Clusters[].ClusterStatus",
    37  				Expected: "available",
    38  			},
    39  			{
    40  				State:   request.FailureWaiterState,
    41  				Matcher: request.PathAnyWaiterMatch, Argument: "Clusters[].ClusterStatus",
    42  				Expected: "deleting",
    43  			},
    44  			{
    45  				State:    request.RetryWaiterState,
    46  				Matcher:  request.ErrorWaiterMatch,
    47  				Expected: "ClusterNotFound",
    48  			},
    49  		},
    50  		Logger: c.Config.Logger,
    51  		NewRequest: func(opts []request.Option) (*request.Request, error) {
    52  			var inCpy *DescribeClustersInput
    53  			if input != nil {
    54  				tmp := *input
    55  				inCpy = &tmp
    56  			}
    57  			req, _ := c.DescribeClustersRequest(inCpy)
    58  			req.SetContext(ctx)
    59  			req.ApplyOptions(opts...)
    60  			return req, nil
    61  		},
    62  	}
    63  	w.ApplyOptions(opts...)
    64  
    65  	return w.WaitWithContext(ctx)
    66  }
    67  
    68  // WaitUntilClusterDeleted uses the Amazon Redshift API operation
    69  // DescribeClusters to wait for a condition to be met before returning.
    70  // If the condition is not met within the max attempt window, an error will
    71  // be returned.
    72  func (c *Redshift) WaitUntilClusterDeleted(input *DescribeClustersInput) error {
    73  	return c.WaitUntilClusterDeletedWithContext(aws.BackgroundContext(), input)
    74  }
    75  
    76  // WaitUntilClusterDeletedWithContext is an extended version of WaitUntilClusterDeleted.
    77  // With the support for passing in a context and options to configure the
    78  // Waiter and the underlying request options.
    79  //
    80  // The context must be non-nil and will be used for request cancellation. If
    81  // the context is nil a panic will occur. In the future the SDK may create
    82  // sub-contexts for http.Requests. See https://golang.org/pkg/context/
    83  // for more information on using Contexts.
    84  func (c *Redshift) WaitUntilClusterDeletedWithContext(ctx aws.Context, input *DescribeClustersInput, opts ...request.WaiterOption) error {
    85  	w := request.Waiter{
    86  		Name:        "WaitUntilClusterDeleted",
    87  		MaxAttempts: 30,
    88  		Delay:       request.ConstantWaiterDelay(60 * time.Second),
    89  		Acceptors: []request.WaiterAcceptor{
    90  			{
    91  				State:    request.SuccessWaiterState,
    92  				Matcher:  request.ErrorWaiterMatch,
    93  				Expected: "ClusterNotFound",
    94  			},
    95  			{
    96  				State:   request.FailureWaiterState,
    97  				Matcher: request.PathAnyWaiterMatch, Argument: "Clusters[].ClusterStatus",
    98  				Expected: "creating",
    99  			},
   100  			{
   101  				State:   request.FailureWaiterState,
   102  				Matcher: request.PathAnyWaiterMatch, Argument: "Clusters[].ClusterStatus",
   103  				Expected: "modifying",
   104  			},
   105  		},
   106  		Logger: c.Config.Logger,
   107  		NewRequest: func(opts []request.Option) (*request.Request, error) {
   108  			var inCpy *DescribeClustersInput
   109  			if input != nil {
   110  				tmp := *input
   111  				inCpy = &tmp
   112  			}
   113  			req, _ := c.DescribeClustersRequest(inCpy)
   114  			req.SetContext(ctx)
   115  			req.ApplyOptions(opts...)
   116  			return req, nil
   117  		},
   118  	}
   119  	w.ApplyOptions(opts...)
   120  
   121  	return w.WaitWithContext(ctx)
   122  }
   123  
   124  // WaitUntilClusterRestored uses the Amazon Redshift API operation
   125  // DescribeClusters to wait for a condition to be met before returning.
   126  // If the condition is not met within the max attempt window, an error will
   127  // be returned.
   128  func (c *Redshift) WaitUntilClusterRestored(input *DescribeClustersInput) error {
   129  	return c.WaitUntilClusterRestoredWithContext(aws.BackgroundContext(), input)
   130  }
   131  
   132  // WaitUntilClusterRestoredWithContext is an extended version of WaitUntilClusterRestored.
   133  // With the support for passing in a context and options to configure the
   134  // Waiter and the underlying request options.
   135  //
   136  // The context must be non-nil and will be used for request cancellation. If
   137  // the context is nil a panic will occur. In the future the SDK may create
   138  // sub-contexts for http.Requests. See https://golang.org/pkg/context/
   139  // for more information on using Contexts.
   140  func (c *Redshift) WaitUntilClusterRestoredWithContext(ctx aws.Context, input *DescribeClustersInput, opts ...request.WaiterOption) error {
   141  	w := request.Waiter{
   142  		Name:        "WaitUntilClusterRestored",
   143  		MaxAttempts: 30,
   144  		Delay:       request.ConstantWaiterDelay(60 * time.Second),
   145  		Acceptors: []request.WaiterAcceptor{
   146  			{
   147  				State:   request.SuccessWaiterState,
   148  				Matcher: request.PathAllWaiterMatch, Argument: "Clusters[].RestoreStatus.Status",
   149  				Expected: "completed",
   150  			},
   151  			{
   152  				State:   request.FailureWaiterState,
   153  				Matcher: request.PathAnyWaiterMatch, Argument: "Clusters[].ClusterStatus",
   154  				Expected: "deleting",
   155  			},
   156  		},
   157  		Logger: c.Config.Logger,
   158  		NewRequest: func(opts []request.Option) (*request.Request, error) {
   159  			var inCpy *DescribeClustersInput
   160  			if input != nil {
   161  				tmp := *input
   162  				inCpy = &tmp
   163  			}
   164  			req, _ := c.DescribeClustersRequest(inCpy)
   165  			req.SetContext(ctx)
   166  			req.ApplyOptions(opts...)
   167  			return req, nil
   168  		},
   169  	}
   170  	w.ApplyOptions(opts...)
   171  
   172  	return w.WaitWithContext(ctx)
   173  }
   174  
   175  // WaitUntilSnapshotAvailable uses the Amazon Redshift API operation
   176  // DescribeClusterSnapshots to wait for a condition to be met before returning.
   177  // If the condition is not met within the max attempt window, an error will
   178  // be returned.
   179  func (c *Redshift) WaitUntilSnapshotAvailable(input *DescribeClusterSnapshotsInput) error {
   180  	return c.WaitUntilSnapshotAvailableWithContext(aws.BackgroundContext(), input)
   181  }
   182  
   183  // WaitUntilSnapshotAvailableWithContext is an extended version of WaitUntilSnapshotAvailable.
   184  // With the support for passing in a context and options to configure the
   185  // Waiter and the underlying request options.
   186  //
   187  // The context must be non-nil and will be used for request cancellation. If
   188  // the context is nil a panic will occur. In the future the SDK may create
   189  // sub-contexts for http.Requests. See https://golang.org/pkg/context/
   190  // for more information on using Contexts.
   191  func (c *Redshift) WaitUntilSnapshotAvailableWithContext(ctx aws.Context, input *DescribeClusterSnapshotsInput, opts ...request.WaiterOption) error {
   192  	w := request.Waiter{
   193  		Name:        "WaitUntilSnapshotAvailable",
   194  		MaxAttempts: 20,
   195  		Delay:       request.ConstantWaiterDelay(15 * time.Second),
   196  		Acceptors: []request.WaiterAcceptor{
   197  			{
   198  				State:   request.SuccessWaiterState,
   199  				Matcher: request.PathAllWaiterMatch, Argument: "Snapshots[].Status",
   200  				Expected: "available",
   201  			},
   202  			{
   203  				State:   request.FailureWaiterState,
   204  				Matcher: request.PathAnyWaiterMatch, Argument: "Snapshots[].Status",
   205  				Expected: "failed",
   206  			},
   207  			{
   208  				State:   request.FailureWaiterState,
   209  				Matcher: request.PathAnyWaiterMatch, Argument: "Snapshots[].Status",
   210  				Expected: "deleted",
   211  			},
   212  		},
   213  		Logger: c.Config.Logger,
   214  		NewRequest: func(opts []request.Option) (*request.Request, error) {
   215  			var inCpy *DescribeClusterSnapshotsInput
   216  			if input != nil {
   217  				tmp := *input
   218  				inCpy = &tmp
   219  			}
   220  			req, _ := c.DescribeClusterSnapshotsRequest(inCpy)
   221  			req.SetContext(ctx)
   222  			req.ApplyOptions(opts...)
   223  			return req, nil
   224  		},
   225  	}
   226  	w.ApplyOptions(opts...)
   227  
   228  	return w.WaitWithContext(ctx)
   229  }