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

     1  // Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
     2  
     3  package prometheusservice
     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  // WaitUntilWorkspaceActive uses the Amazon Prometheus Service API operation
    13  // DescribeWorkspace 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 *PrometheusService) WaitUntilWorkspaceActive(input *DescribeWorkspaceInput) error {
    17  	return c.WaitUntilWorkspaceActiveWithContext(aws.BackgroundContext(), input)
    18  }
    19  
    20  // WaitUntilWorkspaceActiveWithContext is an extended version of WaitUntilWorkspaceActive.
    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 *PrometheusService) WaitUntilWorkspaceActiveWithContext(ctx aws.Context, input *DescribeWorkspaceInput, opts ...request.WaiterOption) error {
    29  	w := request.Waiter{
    30  		Name:        "WaitUntilWorkspaceActive",
    31  		MaxAttempts: 60,
    32  		Delay:       request.ConstantWaiterDelay(2 * time.Second),
    33  		Acceptors: []request.WaiterAcceptor{
    34  			{
    35  				State:   request.SuccessWaiterState,
    36  				Matcher: request.PathWaiterMatch, Argument: "workspace.status.statusCode",
    37  				Expected: "ACTIVE",
    38  			},
    39  			{
    40  				State:   request.RetryWaiterState,
    41  				Matcher: request.PathWaiterMatch, Argument: "workspace.status.statusCode",
    42  				Expected: "UPDATING",
    43  			},
    44  			{
    45  				State:   request.RetryWaiterState,
    46  				Matcher: request.PathWaiterMatch, Argument: "workspace.status.statusCode",
    47  				Expected: "CREATING",
    48  			},
    49  		},
    50  		Logger: c.Config.Logger,
    51  		NewRequest: func(opts []request.Option) (*request.Request, error) {
    52  			var inCpy *DescribeWorkspaceInput
    53  			if input != nil {
    54  				tmp := *input
    55  				inCpy = &tmp
    56  			}
    57  			req, _ := c.DescribeWorkspaceRequest(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  // WaitUntilWorkspaceDeleted uses the Amazon Prometheus Service API operation
    69  // DescribeWorkspace 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 *PrometheusService) WaitUntilWorkspaceDeleted(input *DescribeWorkspaceInput) error {
    73  	return c.WaitUntilWorkspaceDeletedWithContext(aws.BackgroundContext(), input)
    74  }
    75  
    76  // WaitUntilWorkspaceDeletedWithContext is an extended version of WaitUntilWorkspaceDeleted.
    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 *PrometheusService) WaitUntilWorkspaceDeletedWithContext(ctx aws.Context, input *DescribeWorkspaceInput, opts ...request.WaiterOption) error {
    85  	w := request.Waiter{
    86  		Name:        "WaitUntilWorkspaceDeleted",
    87  		MaxAttempts: 60,
    88  		Delay:       request.ConstantWaiterDelay(2 * time.Second),
    89  		Acceptors: []request.WaiterAcceptor{
    90  			{
    91  				State:    request.SuccessWaiterState,
    92  				Matcher:  request.ErrorWaiterMatch,
    93  				Expected: "ResourceNotFoundException",
    94  			},
    95  			{
    96  				State:   request.RetryWaiterState,
    97  				Matcher: request.PathWaiterMatch, Argument: "workspace.status.statusCode",
    98  				Expected: "DELETING",
    99  			},
   100  		},
   101  		Logger: c.Config.Logger,
   102  		NewRequest: func(opts []request.Option) (*request.Request, error) {
   103  			var inCpy *DescribeWorkspaceInput
   104  			if input != nil {
   105  				tmp := *input
   106  				inCpy = &tmp
   107  			}
   108  			req, _ := c.DescribeWorkspaceRequest(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  }