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

     1  // Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
     2  
     3  package elbv2
     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  // WaitUntilLoadBalancerAvailable uses the Elastic Load Balancing v2 API operation
    13  // DescribeLoadBalancers 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 *ELBV2) WaitUntilLoadBalancerAvailable(input *DescribeLoadBalancersInput) error {
    17  	return c.WaitUntilLoadBalancerAvailableWithContext(aws.BackgroundContext(), input)
    18  }
    19  
    20  // WaitUntilLoadBalancerAvailableWithContext is an extended version of WaitUntilLoadBalancerAvailable.
    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 *ELBV2) WaitUntilLoadBalancerAvailableWithContext(ctx aws.Context, input *DescribeLoadBalancersInput, opts ...request.WaiterOption) error {
    29  	w := request.Waiter{
    30  		Name:        "WaitUntilLoadBalancerAvailable",
    31  		MaxAttempts: 40,
    32  		Delay:       request.ConstantWaiterDelay(15 * time.Second),
    33  		Acceptors: []request.WaiterAcceptor{
    34  			{
    35  				State:   request.SuccessWaiterState,
    36  				Matcher: request.PathAllWaiterMatch, Argument: "LoadBalancers[].State.Code",
    37  				Expected: "active",
    38  			},
    39  			{
    40  				State:   request.RetryWaiterState,
    41  				Matcher: request.PathAnyWaiterMatch, Argument: "LoadBalancers[].State.Code",
    42  				Expected: "provisioning",
    43  			},
    44  			{
    45  				State:    request.RetryWaiterState,
    46  				Matcher:  request.ErrorWaiterMatch,
    47  				Expected: "LoadBalancerNotFound",
    48  			},
    49  		},
    50  		Logger: c.Config.Logger,
    51  		NewRequest: func(opts []request.Option) (*request.Request, error) {
    52  			var inCpy *DescribeLoadBalancersInput
    53  			if input != nil {
    54  				tmp := *input
    55  				inCpy = &tmp
    56  			}
    57  			req, _ := c.DescribeLoadBalancersRequest(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  // WaitUntilLoadBalancerExists uses the Elastic Load Balancing v2 API operation
    69  // DescribeLoadBalancers 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 *ELBV2) WaitUntilLoadBalancerExists(input *DescribeLoadBalancersInput) error {
    73  	return c.WaitUntilLoadBalancerExistsWithContext(aws.BackgroundContext(), input)
    74  }
    75  
    76  // WaitUntilLoadBalancerExistsWithContext is an extended version of WaitUntilLoadBalancerExists.
    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 *ELBV2) WaitUntilLoadBalancerExistsWithContext(ctx aws.Context, input *DescribeLoadBalancersInput, opts ...request.WaiterOption) error {
    85  	w := request.Waiter{
    86  		Name:        "WaitUntilLoadBalancerExists",
    87  		MaxAttempts: 40,
    88  		Delay:       request.ConstantWaiterDelay(15 * time.Second),
    89  		Acceptors: []request.WaiterAcceptor{
    90  			{
    91  				State:    request.SuccessWaiterState,
    92  				Matcher:  request.StatusWaiterMatch,
    93  				Expected: 200,
    94  			},
    95  			{
    96  				State:    request.RetryWaiterState,
    97  				Matcher:  request.ErrorWaiterMatch,
    98  				Expected: "LoadBalancerNotFound",
    99  			},
   100  		},
   101  		Logger: c.Config.Logger,
   102  		NewRequest: func(opts []request.Option) (*request.Request, error) {
   103  			var inCpy *DescribeLoadBalancersInput
   104  			if input != nil {
   105  				tmp := *input
   106  				inCpy = &tmp
   107  			}
   108  			req, _ := c.DescribeLoadBalancersRequest(inCpy)
   109  			req.SetContext(ctx)
   110  			req.ApplyOptions(opts...)
   111  			return req, nil
   112  		},
   113  	}
   114  	w.ApplyOptions(opts...)
   115  
   116  	return w.WaitWithContext(ctx)
   117  }
   118  
   119  // WaitUntilLoadBalancersDeleted uses the Elastic Load Balancing v2 API operation
   120  // DescribeLoadBalancers to wait for a condition to be met before returning.
   121  // If the condition is not met within the max attempt window, an error will
   122  // be returned.
   123  func (c *ELBV2) WaitUntilLoadBalancersDeleted(input *DescribeLoadBalancersInput) error {
   124  	return c.WaitUntilLoadBalancersDeletedWithContext(aws.BackgroundContext(), input)
   125  }
   126  
   127  // WaitUntilLoadBalancersDeletedWithContext is an extended version of WaitUntilLoadBalancersDeleted.
   128  // With the support for passing in a context and options to configure the
   129  // Waiter and the underlying request options.
   130  //
   131  // The context must be non-nil and will be used for request cancellation. If
   132  // the context is nil a panic will occur. In the future the SDK may create
   133  // sub-contexts for http.Requests. See https://golang.org/pkg/context/
   134  // for more information on using Contexts.
   135  func (c *ELBV2) WaitUntilLoadBalancersDeletedWithContext(ctx aws.Context, input *DescribeLoadBalancersInput, opts ...request.WaiterOption) error {
   136  	w := request.Waiter{
   137  		Name:        "WaitUntilLoadBalancersDeleted",
   138  		MaxAttempts: 40,
   139  		Delay:       request.ConstantWaiterDelay(15 * time.Second),
   140  		Acceptors: []request.WaiterAcceptor{
   141  			{
   142  				State:   request.RetryWaiterState,
   143  				Matcher: request.PathAllWaiterMatch, Argument: "LoadBalancers[].State.Code",
   144  				Expected: "active",
   145  			},
   146  			{
   147  				State:    request.SuccessWaiterState,
   148  				Matcher:  request.ErrorWaiterMatch,
   149  				Expected: "LoadBalancerNotFound",
   150  			},
   151  		},
   152  		Logger: c.Config.Logger,
   153  		NewRequest: func(opts []request.Option) (*request.Request, error) {
   154  			var inCpy *DescribeLoadBalancersInput
   155  			if input != nil {
   156  				tmp := *input
   157  				inCpy = &tmp
   158  			}
   159  			req, _ := c.DescribeLoadBalancersRequest(inCpy)
   160  			req.SetContext(ctx)
   161  			req.ApplyOptions(opts...)
   162  			return req, nil
   163  		},
   164  	}
   165  	w.ApplyOptions(opts...)
   166  
   167  	return w.WaitWithContext(ctx)
   168  }
   169  
   170  // WaitUntilTargetDeregistered uses the Elastic Load Balancing v2 API operation
   171  // DescribeTargetHealth to wait for a condition to be met before returning.
   172  // If the condition is not met within the max attempt window, an error will
   173  // be returned.
   174  func (c *ELBV2) WaitUntilTargetDeregistered(input *DescribeTargetHealthInput) error {
   175  	return c.WaitUntilTargetDeregisteredWithContext(aws.BackgroundContext(), input)
   176  }
   177  
   178  // WaitUntilTargetDeregisteredWithContext is an extended version of WaitUntilTargetDeregistered.
   179  // With the support for passing in a context and options to configure the
   180  // Waiter and the underlying request options.
   181  //
   182  // The context must be non-nil and will be used for request cancellation. If
   183  // the context is nil a panic will occur. In the future the SDK may create
   184  // sub-contexts for http.Requests. See https://golang.org/pkg/context/
   185  // for more information on using Contexts.
   186  func (c *ELBV2) WaitUntilTargetDeregisteredWithContext(ctx aws.Context, input *DescribeTargetHealthInput, opts ...request.WaiterOption) error {
   187  	w := request.Waiter{
   188  		Name:        "WaitUntilTargetDeregistered",
   189  		MaxAttempts: 40,
   190  		Delay:       request.ConstantWaiterDelay(15 * time.Second),
   191  		Acceptors: []request.WaiterAcceptor{
   192  			{
   193  				State:    request.SuccessWaiterState,
   194  				Matcher:  request.ErrorWaiterMatch,
   195  				Expected: "InvalidTarget",
   196  			},
   197  			{
   198  				State:   request.SuccessWaiterState,
   199  				Matcher: request.PathAllWaiterMatch, Argument: "TargetHealthDescriptions[].TargetHealth.State",
   200  				Expected: "unused",
   201  			},
   202  		},
   203  		Logger: c.Config.Logger,
   204  		NewRequest: func(opts []request.Option) (*request.Request, error) {
   205  			var inCpy *DescribeTargetHealthInput
   206  			if input != nil {
   207  				tmp := *input
   208  				inCpy = &tmp
   209  			}
   210  			req, _ := c.DescribeTargetHealthRequest(inCpy)
   211  			req.SetContext(ctx)
   212  			req.ApplyOptions(opts...)
   213  			return req, nil
   214  		},
   215  	}
   216  	w.ApplyOptions(opts...)
   217  
   218  	return w.WaitWithContext(ctx)
   219  }
   220  
   221  // WaitUntilTargetInService uses the Elastic Load Balancing v2 API operation
   222  // DescribeTargetHealth to wait for a condition to be met before returning.
   223  // If the condition is not met within the max attempt window, an error will
   224  // be returned.
   225  func (c *ELBV2) WaitUntilTargetInService(input *DescribeTargetHealthInput) error {
   226  	return c.WaitUntilTargetInServiceWithContext(aws.BackgroundContext(), input)
   227  }
   228  
   229  // WaitUntilTargetInServiceWithContext is an extended version of WaitUntilTargetInService.
   230  // With the support for passing in a context and options to configure the
   231  // Waiter and the underlying request options.
   232  //
   233  // The context must be non-nil and will be used for request cancellation. If
   234  // the context is nil a panic will occur. In the future the SDK may create
   235  // sub-contexts for http.Requests. See https://golang.org/pkg/context/
   236  // for more information on using Contexts.
   237  func (c *ELBV2) WaitUntilTargetInServiceWithContext(ctx aws.Context, input *DescribeTargetHealthInput, opts ...request.WaiterOption) error {
   238  	w := request.Waiter{
   239  		Name:        "WaitUntilTargetInService",
   240  		MaxAttempts: 40,
   241  		Delay:       request.ConstantWaiterDelay(15 * time.Second),
   242  		Acceptors: []request.WaiterAcceptor{
   243  			{
   244  				State:   request.SuccessWaiterState,
   245  				Matcher: request.PathAllWaiterMatch, Argument: "TargetHealthDescriptions[].TargetHealth.State",
   246  				Expected: "healthy",
   247  			},
   248  			{
   249  				State:    request.RetryWaiterState,
   250  				Matcher:  request.ErrorWaiterMatch,
   251  				Expected: "InvalidInstance",
   252  			},
   253  		},
   254  		Logger: c.Config.Logger,
   255  		NewRequest: func(opts []request.Option) (*request.Request, error) {
   256  			var inCpy *DescribeTargetHealthInput
   257  			if input != nil {
   258  				tmp := *input
   259  				inCpy = &tmp
   260  			}
   261  			req, _ := c.DescribeTargetHealthRequest(inCpy)
   262  			req.SetContext(ctx)
   263  			req.ApplyOptions(opts...)
   264  			return req, nil
   265  		},
   266  	}
   267  	w.ApplyOptions(opts...)
   268  
   269  	return w.WaitWithContext(ctx)
   270  }