waiters.go 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. // Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
  2. package elastictranscoder
  3. import (
  4. "time"
  5. "github.com/aws/aws-sdk-go/aws"
  6. "github.com/aws/aws-sdk-go/aws/request"
  7. )
  8. // WaitUntilJobComplete uses the Amazon Elastic Transcoder API operation
  9. // ReadJob to wait for a condition to be met before returning.
  10. // If the condition is not met within the max attempt window, an error will
  11. // be returned.
  12. func (c *ElasticTranscoder) WaitUntilJobComplete(input *ReadJobInput) error {
  13. return c.WaitUntilJobCompleteWithContext(aws.BackgroundContext(), input)
  14. }
  15. // WaitUntilJobCompleteWithContext is an extended version of WaitUntilJobComplete.
  16. // With the support for passing in a context and options to configure the
  17. // Waiter and the underlying request options.
  18. //
  19. // The context must be non-nil and will be used for request cancellation. If
  20. // the context is nil a panic will occur. In the future the SDK may create
  21. // sub-contexts for http.Requests. See https://golang.org/pkg/context/
  22. // for more information on using Contexts.
  23. func (c *ElasticTranscoder) WaitUntilJobCompleteWithContext(ctx aws.Context, input *ReadJobInput, opts ...request.WaiterOption) error {
  24. w := request.Waiter{
  25. Name: "WaitUntilJobComplete",
  26. MaxAttempts: 120,
  27. Delay: request.ConstantWaiterDelay(30 * time.Second),
  28. Acceptors: []request.WaiterAcceptor{
  29. {
  30. State: request.SuccessWaiterState,
  31. Matcher: request.PathWaiterMatch, Argument: "Job.Status",
  32. Expected: "Complete",
  33. },
  34. {
  35. State: request.FailureWaiterState,
  36. Matcher: request.PathWaiterMatch, Argument: "Job.Status",
  37. Expected: "Canceled",
  38. },
  39. {
  40. State: request.FailureWaiterState,
  41. Matcher: request.PathWaiterMatch, Argument: "Job.Status",
  42. Expected: "Error",
  43. },
  44. },
  45. Logger: c.Config.Logger,
  46. NewRequest: func(opts []request.Option) (*request.Request, error) {
  47. var inCpy *ReadJobInput
  48. if input != nil {
  49. tmp := *input
  50. inCpy = &tmp
  51. }
  52. req, _ := c.ReadJobRequest(inCpy)
  53. req.SetContext(ctx)
  54. req.ApplyOptions(opts...)
  55. return req, nil
  56. },
  57. }
  58. w.ApplyOptions(opts...)
  59. return w.WaitWithContext(ctx)
  60. }