terraform-provider-google/google/spanner_instance_operation.go

29 lines
714 B
Go
Raw Normal View History

package google
import (
"google.golang.org/api/spanner/v1"
)
type SpannerInstanceOperationWaiter struct {
Service *spanner.Service
2018-12-27 01:42:37 +00:00
CommonOperationWaiter
}
2018-12-27 01:42:37 +00:00
func (w *SpannerInstanceOperationWaiter) QueryOp() (interface{}, error) {
return w.Service.Projects.Instances.Operations.Get(w.Op.Name).Do()
}
func spannerOperationWaitTime(spanner *spanner.Service, op *spanner.Operation, _ string, activity string, timeoutMinutes int) error {
if op.Name == "" {
// This was a synchronous call - there is no operation to wait for.
return nil
}
w := &SpannerInstanceOperationWaiter{
Service: spanner,
}
2018-12-27 01:42:37 +00:00
if err := w.SetOp(op); err != nil {
return err
}
2018-12-27 01:42:37 +00:00
return OperationWait(w, activity, timeoutMinutes)
}