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

     1  // Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
     2  
     3  package emr
     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  // WaitUntilClusterRunning uses the Amazon EMR API operation
    13  // DescribeCluster 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 *EMR) WaitUntilClusterRunning(input *DescribeClusterInput) error {
    17  	return c.WaitUntilClusterRunningWithContext(aws.BackgroundContext(), input)
    18  }
    19  
    20  // WaitUntilClusterRunningWithContext is an extended version of WaitUntilClusterRunning.
    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 *EMR) WaitUntilClusterRunningWithContext(ctx aws.Context, input *DescribeClusterInput, opts ...request.WaiterOption) error {
    29  	w := request.Waiter{
    30  		Name:        "WaitUntilClusterRunning",
    31  		MaxAttempts: 60,
    32  		Delay:       request.ConstantWaiterDelay(30 * time.Second),
    33  		Acceptors: []request.WaiterAcceptor{
    34  			{
    35  				State:   request.SuccessWaiterState,
    36  				Matcher: request.PathWaiterMatch, Argument: "Cluster.Status.State",
    37  				Expected: "RUNNING",
    38  			},
    39  			{
    40  				State:   request.SuccessWaiterState,
    41  				Matcher: request.PathWaiterMatch, Argument: "Cluster.Status.State",
    42  				Expected: "WAITING",
    43  			},
    44  			{
    45  				State:   request.FailureWaiterState,
    46  				Matcher: request.PathWaiterMatch, Argument: "Cluster.Status.State",
    47  				Expected: "TERMINATING",
    48  			},
    49  			{
    50  				State:   request.FailureWaiterState,
    51  				Matcher: request.PathWaiterMatch, Argument: "Cluster.Status.State",
    52  				Expected: "TERMINATED",
    53  			},
    54  			{
    55  				State:   request.FailureWaiterState,
    56  				Matcher: request.PathWaiterMatch, Argument: "Cluster.Status.State",
    57  				Expected: "TERMINATED_WITH_ERRORS",
    58  			},
    59  		},
    60  		Logger: c.Config.Logger,
    61  		NewRequest: func(opts []request.Option) (*request.Request, error) {
    62  			var inCpy *DescribeClusterInput
    63  			if input != nil {
    64  				tmp := *input
    65  				inCpy = &tmp
    66  			}
    67  			req, _ := c.DescribeClusterRequest(inCpy)
    68  			req.SetContext(ctx)
    69  			req.ApplyOptions(opts...)
    70  			return req, nil
    71  		},
    72  	}
    73  	w.ApplyOptions(opts...)
    74  
    75  	return w.WaitWithContext(ctx)
    76  }
    77  
    78  // WaitUntilClusterTerminated uses the Amazon EMR API operation
    79  // DescribeCluster to wait for a condition to be met before returning.
    80  // If the condition is not met within the max attempt window, an error will
    81  // be returned.
    82  func (c *EMR) WaitUntilClusterTerminated(input *DescribeClusterInput) error {
    83  	return c.WaitUntilClusterTerminatedWithContext(aws.BackgroundContext(), input)
    84  }
    85  
    86  // WaitUntilClusterTerminatedWithContext is an extended version of WaitUntilClusterTerminated.
    87  // With the support for passing in a context and options to configure the
    88  // Waiter and the underlying request options.
    89  //
    90  // The context must be non-nil and will be used for request cancellation. If
    91  // the context is nil a panic will occur. In the future the SDK may create
    92  // sub-contexts for http.Requests. See https://golang.org/pkg/context/
    93  // for more information on using Contexts.
    94  func (c *EMR) WaitUntilClusterTerminatedWithContext(ctx aws.Context, input *DescribeClusterInput, opts ...request.WaiterOption) error {
    95  	w := request.Waiter{
    96  		Name:        "WaitUntilClusterTerminated",
    97  		MaxAttempts: 60,
    98  		Delay:       request.ConstantWaiterDelay(30 * time.Second),
    99  		Acceptors: []request.WaiterAcceptor{
   100  			{
   101  				State:   request.SuccessWaiterState,
   102  				Matcher: request.PathWaiterMatch, Argument: "Cluster.Status.State",
   103  				Expected: "TERMINATED",
   104  			},
   105  			{
   106  				State:   request.FailureWaiterState,
   107  				Matcher: request.PathWaiterMatch, Argument: "Cluster.Status.State",
   108  				Expected: "TERMINATED_WITH_ERRORS",
   109  			},
   110  		},
   111  		Logger: c.Config.Logger,
   112  		NewRequest: func(opts []request.Option) (*request.Request, error) {
   113  			var inCpy *DescribeClusterInput
   114  			if input != nil {
   115  				tmp := *input
   116  				inCpy = &tmp
   117  			}
   118  			req, _ := c.DescribeClusterRequest(inCpy)
   119  			req.SetContext(ctx)
   120  			req.ApplyOptions(opts...)
   121  			return req, nil
   122  		},
   123  	}
   124  	w.ApplyOptions(opts...)
   125  
   126  	return w.WaitWithContext(ctx)
   127  }
   128  
   129  // WaitUntilStepComplete uses the Amazon EMR API operation
   130  // DescribeStep to wait for a condition to be met before returning.
   131  // If the condition is not met within the max attempt window, an error will
   132  // be returned.
   133  func (c *EMR) WaitUntilStepComplete(input *DescribeStepInput) error {
   134  	return c.WaitUntilStepCompleteWithContext(aws.BackgroundContext(), input)
   135  }
   136  
   137  // WaitUntilStepCompleteWithContext is an extended version of WaitUntilStepComplete.
   138  // With the support for passing in a context and options to configure the
   139  // Waiter and the underlying request options.
   140  //
   141  // The context must be non-nil and will be used for request cancellation. If
   142  // the context is nil a panic will occur. In the future the SDK may create
   143  // sub-contexts for http.Requests. See https://golang.org/pkg/context/
   144  // for more information on using Contexts.
   145  func (c *EMR) WaitUntilStepCompleteWithContext(ctx aws.Context, input *DescribeStepInput, opts ...request.WaiterOption) error {
   146  	w := request.Waiter{
   147  		Name:        "WaitUntilStepComplete",
   148  		MaxAttempts: 60,
   149  		Delay:       request.ConstantWaiterDelay(30 * time.Second),
   150  		Acceptors: []request.WaiterAcceptor{
   151  			{
   152  				State:   request.SuccessWaiterState,
   153  				Matcher: request.PathWaiterMatch, Argument: "Step.Status.State",
   154  				Expected: "COMPLETED",
   155  			},
   156  			{
   157  				State:   request.FailureWaiterState,
   158  				Matcher: request.PathWaiterMatch, Argument: "Step.Status.State",
   159  				Expected: "FAILED",
   160  			},
   161  			{
   162  				State:   request.FailureWaiterState,
   163  				Matcher: request.PathWaiterMatch, Argument: "Step.Status.State",
   164  				Expected: "CANCELLED",
   165  			},
   166  		},
   167  		Logger: c.Config.Logger,
   168  		NewRequest: func(opts []request.Option) (*request.Request, error) {
   169  			var inCpy *DescribeStepInput
   170  			if input != nil {
   171  				tmp := *input
   172  				inCpy = &tmp
   173  			}
   174  			req, _ := c.DescribeStepRequest(inCpy)
   175  			req.SetContext(ctx)
   176  			req.ApplyOptions(opts...)
   177  			return req, nil
   178  		},
   179  	}
   180  	w.ApplyOptions(opts...)
   181  
   182  	return w.WaitWithContext(ctx)
   183  }