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

     1  // Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
     2  
     3  package opsworkscm
     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  // WaitUntilNodeAssociated uses the OpsWorksCM API operation
    13  // DescribeNodeAssociationStatus 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 *OpsWorksCM) WaitUntilNodeAssociated(input *DescribeNodeAssociationStatusInput) error {
    17  	return c.WaitUntilNodeAssociatedWithContext(aws.BackgroundContext(), input)
    18  }
    19  
    20  // WaitUntilNodeAssociatedWithContext is an extended version of WaitUntilNodeAssociated.
    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 *OpsWorksCM) WaitUntilNodeAssociatedWithContext(ctx aws.Context, input *DescribeNodeAssociationStatusInput, opts ...request.WaiterOption) error {
    29  	w := request.Waiter{
    30  		Name:        "WaitUntilNodeAssociated",
    31  		MaxAttempts: 15,
    32  		Delay:       request.ConstantWaiterDelay(15 * time.Second),
    33  		Acceptors: []request.WaiterAcceptor{
    34  			{
    35  				State:   request.SuccessWaiterState,
    36  				Matcher: request.PathWaiterMatch, Argument: "NodeAssociationStatus",
    37  				Expected: "SUCCESS",
    38  			},
    39  			{
    40  				State:   request.FailureWaiterState,
    41  				Matcher: request.PathWaiterMatch, Argument: "NodeAssociationStatus",
    42  				Expected: "FAILED",
    43  			},
    44  		},
    45  		Logger: c.Config.Logger,
    46  		NewRequest: func(opts []request.Option) (*request.Request, error) {
    47  			var inCpy *DescribeNodeAssociationStatusInput
    48  			if input != nil {
    49  				tmp := *input
    50  				inCpy = &tmp
    51  			}
    52  			req, _ := c.DescribeNodeAssociationStatusRequest(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  }