2016-11-23 06:55:40 +00:00
|
|
|
package google
|
|
|
|
|
|
|
|
import (
|
|
|
|
"google.golang.org/api/cloudresourcemanager/v1"
|
2017-09-14 18:19:58 +00:00
|
|
|
resourceManagerV2Beta1 "google.golang.org/api/cloudresourcemanager/v2beta1"
|
2016-11-23 06:55:40 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type ResourceManagerOperationWaiter struct {
|
|
|
|
Service *cloudresourcemanager.Service
|
2018-12-27 01:42:37 +00:00
|
|
|
CommonOperationWaiter
|
2016-11-23 06:55:40 +00:00
|
|
|
}
|
|
|
|
|
2018-12-27 01:42:37 +00:00
|
|
|
func (w *ResourceManagerOperationWaiter) QueryOp() (interface{}, error) {
|
|
|
|
return w.Service.Operations.Get(w.Op.Name).Do()
|
2016-11-23 06:55:40 +00:00
|
|
|
}
|
|
|
|
|
2018-05-08 22:49:57 +00:00
|
|
|
func resourceManagerOperationWaitTime(service *cloudresourcemanager.Service, op *cloudresourcemanager.Operation, activity string, timeoutMin int) error {
|
2016-11-23 06:55:40 +00:00
|
|
|
w := &ResourceManagerOperationWaiter{
|
2018-05-08 22:49:57 +00:00
|
|
|
Service: service,
|
2016-11-23 06:55:40 +00:00
|
|
|
}
|
2018-12-27 01:42:37 +00:00
|
|
|
if err := w.SetOp(op); err != nil {
|
|
|
|
return err
|
2016-11-23 06:55:40 +00:00
|
|
|
}
|
2018-12-27 01:42:37 +00:00
|
|
|
return OperationWait(w, activity, timeoutMin)
|
|
|
|
}
|
2016-11-23 06:55:40 +00:00
|
|
|
|
2018-12-27 01:42:37 +00:00
|
|
|
func resourceManagerOperationWait(service *cloudresourcemanager.Service, op *cloudresourcemanager.Operation, activity string) error {
|
|
|
|
return resourceManagerOperationWaitTime(service, op, activity, 4)
|
2016-11-23 06:55:40 +00:00
|
|
|
}
|
2017-09-14 18:19:58 +00:00
|
|
|
|
2018-05-08 22:49:57 +00:00
|
|
|
func resourceManagerV2Beta1OperationWait(service *cloudresourcemanager.Service, op *resourceManagerV2Beta1.Operation, activity string) error {
|
|
|
|
return resourceManagerV2Beta1OperationWaitTime(service, op, activity, 4)
|
2017-09-14 18:19:58 +00:00
|
|
|
}
|
|
|
|
|
2018-05-08 22:49:57 +00:00
|
|
|
func resourceManagerV2Beta1OperationWaitTime(service *cloudresourcemanager.Service, op *resourceManagerV2Beta1.Operation, activity string, timeoutMin int) error {
|
2017-09-14 18:19:58 +00:00
|
|
|
opV1 := &cloudresourcemanager.Operation{}
|
|
|
|
err := Convert(op, opV1)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2018-05-08 22:49:57 +00:00
|
|
|
return resourceManagerOperationWaitTime(service, opV1, activity, timeoutMin)
|
2017-09-14 18:19:58 +00:00
|
|
|
}
|