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

     1  // Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
     2  
     3  package ecs
     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  // WaitUntilServicesInactive uses the Amazon ECS API operation
    13  // DescribeServices 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 *ECS) WaitUntilServicesInactive(input *DescribeServicesInput) error {
    17  	return c.WaitUntilServicesInactiveWithContext(aws.BackgroundContext(), input)
    18  }
    19  
    20  // WaitUntilServicesInactiveWithContext is an extended version of WaitUntilServicesInactive.
    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 *ECS) WaitUntilServicesInactiveWithContext(ctx aws.Context, input *DescribeServicesInput, opts ...request.WaiterOption) error {
    29  	w := request.Waiter{
    30  		Name:        "WaitUntilServicesInactive",
    31  		MaxAttempts: 40,
    32  		Delay:       request.ConstantWaiterDelay(15 * time.Second),
    33  		Acceptors: []request.WaiterAcceptor{
    34  			{
    35  				State:   request.FailureWaiterState,
    36  				Matcher: request.PathAnyWaiterMatch, Argument: "failures[].reason",
    37  				Expected: "MISSING",
    38  			},
    39  			{
    40  				State:   request.SuccessWaiterState,
    41  				Matcher: request.PathAnyWaiterMatch, Argument: "services[].status",
    42  				Expected: "INACTIVE",
    43  			},
    44  		},
    45  		Logger: c.Config.Logger,
    46  		NewRequest: func(opts []request.Option) (*request.Request, error) {
    47  			var inCpy *DescribeServicesInput
    48  			if input != nil {
    49  				tmp := *input
    50  				inCpy = &tmp
    51  			}
    52  			req, _ := c.DescribeServicesRequest(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  // WaitUntilServicesStable uses the Amazon ECS API operation
    64  // DescribeServices 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 *ECS) WaitUntilServicesStable(input *DescribeServicesInput) error {
    68  	return c.WaitUntilServicesStableWithContext(aws.BackgroundContext(), input)
    69  }
    70  
    71  // WaitUntilServicesStableWithContext is an extended version of WaitUntilServicesStable.
    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 *ECS) WaitUntilServicesStableWithContext(ctx aws.Context, input *DescribeServicesInput, opts ...request.WaiterOption) error {
    80  	w := request.Waiter{
    81  		Name:        "WaitUntilServicesStable",
    82  		MaxAttempts: 40,
    83  		Delay:       request.ConstantWaiterDelay(15 * time.Second),
    84  		Acceptors: []request.WaiterAcceptor{
    85  			{
    86  				State:   request.FailureWaiterState,
    87  				Matcher: request.PathAnyWaiterMatch, Argument: "failures[].reason",
    88  				Expected: "MISSING",
    89  			},
    90  			{
    91  				State:   request.FailureWaiterState,
    92  				Matcher: request.PathAnyWaiterMatch, Argument: "services[].status",
    93  				Expected: "DRAINING",
    94  			},
    95  			{
    96  				State:   request.FailureWaiterState,
    97  				Matcher: request.PathAnyWaiterMatch, Argument: "services[].status",
    98  				Expected: "INACTIVE",
    99  			},
   100  			{
   101  				State:   request.SuccessWaiterState,
   102  				Matcher: request.PathWaiterMatch, Argument: "length(services[?!(length(deployments) == `1` && runningCount == desiredCount)]) == `0`",
   103  				Expected: true,
   104  			},
   105  		},
   106  		Logger: c.Config.Logger,
   107  		NewRequest: func(opts []request.Option) (*request.Request, error) {
   108  			var inCpy *DescribeServicesInput
   109  			if input != nil {
   110  				tmp := *input
   111  				inCpy = &tmp
   112  			}
   113  			req, _ := c.DescribeServicesRequest(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  // WaitUntilTasksRunning uses the Amazon ECS API operation
   125  // DescribeTasks 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 *ECS) WaitUntilTasksRunning(input *DescribeTasksInput) error {
   129  	return c.WaitUntilTasksRunningWithContext(aws.BackgroundContext(), input)
   130  }
   131  
   132  // WaitUntilTasksRunningWithContext is an extended version of WaitUntilTasksRunning.
   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 *ECS) WaitUntilTasksRunningWithContext(ctx aws.Context, input *DescribeTasksInput, opts ...request.WaiterOption) error {
   141  	w := request.Waiter{
   142  		Name:        "WaitUntilTasksRunning",
   143  		MaxAttempts: 100,
   144  		Delay:       request.ConstantWaiterDelay(6 * time.Second),
   145  		Acceptors: []request.WaiterAcceptor{
   146  			{
   147  				State:   request.FailureWaiterState,
   148  				Matcher: request.PathAnyWaiterMatch, Argument: "tasks[].lastStatus",
   149  				Expected: "STOPPED",
   150  			},
   151  			{
   152  				State:   request.FailureWaiterState,
   153  				Matcher: request.PathAnyWaiterMatch, Argument: "failures[].reason",
   154  				Expected: "MISSING",
   155  			},
   156  			{
   157  				State:   request.SuccessWaiterState,
   158  				Matcher: request.PathAllWaiterMatch, Argument: "tasks[].lastStatus",
   159  				Expected: "RUNNING",
   160  			},
   161  		},
   162  		Logger: c.Config.Logger,
   163  		NewRequest: func(opts []request.Option) (*request.Request, error) {
   164  			var inCpy *DescribeTasksInput
   165  			if input != nil {
   166  				tmp := *input
   167  				inCpy = &tmp
   168  			}
   169  			req, _ := c.DescribeTasksRequest(inCpy)
   170  			req.SetContext(ctx)
   171  			req.ApplyOptions(opts...)
   172  			return req, nil
   173  		},
   174  	}
   175  	w.ApplyOptions(opts...)
   176  
   177  	return w.WaitWithContext(ctx)
   178  }
   179  
   180  // WaitUntilTasksStopped uses the Amazon ECS API operation
   181  // DescribeTasks to wait for a condition to be met before returning.
   182  // If the condition is not met within the max attempt window, an error will
   183  // be returned.
   184  func (c *ECS) WaitUntilTasksStopped(input *DescribeTasksInput) error {
   185  	return c.WaitUntilTasksStoppedWithContext(aws.BackgroundContext(), input)
   186  }
   187  
   188  // WaitUntilTasksStoppedWithContext is an extended version of WaitUntilTasksStopped.
   189  // With the support for passing in a context and options to configure the
   190  // Waiter and the underlying request options.
   191  //
   192  // The context must be non-nil and will be used for request cancellation. If
   193  // the context is nil a panic will occur. In the future the SDK may create
   194  // sub-contexts for http.Requests. See https://golang.org/pkg/context/
   195  // for more information on using Contexts.
   196  func (c *ECS) WaitUntilTasksStoppedWithContext(ctx aws.Context, input *DescribeTasksInput, opts ...request.WaiterOption) error {
   197  	w := request.Waiter{
   198  		Name:        "WaitUntilTasksStopped",
   199  		MaxAttempts: 100,
   200  		Delay:       request.ConstantWaiterDelay(6 * time.Second),
   201  		Acceptors: []request.WaiterAcceptor{
   202  			{
   203  				State:   request.SuccessWaiterState,
   204  				Matcher: request.PathAllWaiterMatch, Argument: "tasks[].lastStatus",
   205  				Expected: "STOPPED",
   206  			},
   207  		},
   208  		Logger: c.Config.Logger,
   209  		NewRequest: func(opts []request.Option) (*request.Request, error) {
   210  			var inCpy *DescribeTasksInput
   211  			if input != nil {
   212  				tmp := *input
   213  				inCpy = &tmp
   214  			}
   215  			req, _ := c.DescribeTasksRequest(inCpy)
   216  			req.SetContext(ctx)
   217  			req.ApplyOptions(opts...)
   218  			return req, nil
   219  		},
   220  	}
   221  	w.ApplyOptions(opts...)
   222  
   223  	return w.WaitWithContext(ctx)
   224  }