|
| 1 | +// ---------------------------------------------------------------------------- |
| 2 | +// |
| 3 | +// *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** |
| 4 | +// |
| 5 | +// ---------------------------------------------------------------------------- |
| 6 | +// |
| 7 | +// This file is automatically generated by Magic Modules and manual |
| 8 | +// changes will be clobbered when the file is regenerated. |
| 9 | +// |
| 10 | +// Please read more about how to change this file in |
| 11 | +// .github/CONTRIBUTING.md. |
| 12 | +// |
| 13 | +// ---------------------------------------------------------------------------- |
| 14 | +package google |
| 15 | + |
| 16 | +import ( |
| 17 | + "encoding/json" |
| 18 | + "fmt" |
| 19 | + "time" |
| 20 | +) |
| 21 | + |
| 22 | +type ActiveDirectoryOperationWaiter struct { |
| 23 | + Config *Config |
| 24 | + Project string |
| 25 | + CommonOperationWaiter |
| 26 | +} |
| 27 | + |
| 28 | +func (w *ActiveDirectoryOperationWaiter) QueryOp() (interface{}, error) { |
| 29 | + if w == nil { |
| 30 | + return nil, fmt.Errorf("Cannot query operation, it's unset or nil.") |
| 31 | + } |
| 32 | + // Returns the proper get. |
| 33 | + url := fmt.Sprintf("https://managedidentities.googleapis.com/v1/%s", w.CommonOperationWaiter.Op.Name) |
| 34 | + return sendRequest(w.Config, "GET", w.Project, url, nil) |
| 35 | +} |
| 36 | + |
| 37 | +func createActiveDirectoryWaiter(config *Config, op map[string]interface{}, project, activity string) (*ActiveDirectoryOperationWaiter, error) { |
| 38 | + if val, ok := op["name"]; !ok || val == "" { |
| 39 | + // This was a synchronous call - there is no operation to wait for. |
| 40 | + return nil, nil |
| 41 | + } |
| 42 | + w := &ActiveDirectoryOperationWaiter{ |
| 43 | + Config: config, |
| 44 | + Project: project, |
| 45 | + } |
| 46 | + if err := w.CommonOperationWaiter.SetOp(op); err != nil { |
| 47 | + return nil, err |
| 48 | + } |
| 49 | + return w, nil |
| 50 | +} |
| 51 | + |
| 52 | +// nolint: deadcode,unused |
| 53 | +func activeDirectoryOperationWaitTimeWithResponse(config *Config, op map[string]interface{}, response *map[string]interface{}, project, activity string, timeout time.Duration) error { |
| 54 | + w, err := createActiveDirectoryWaiter(config, op, project, activity) |
| 55 | + if err != nil || w == nil { |
| 56 | + // If w is nil, the op was synchronous. |
| 57 | + return err |
| 58 | + } |
| 59 | + if err := OperationWait(w, activity, timeout, config.PollInterval); err != nil { |
| 60 | + return err |
| 61 | + } |
| 62 | + return json.Unmarshal([]byte(w.CommonOperationWaiter.Op.Response), response) |
| 63 | +} |
| 64 | + |
| 65 | +func activeDirectoryOperationWaitTime(config *Config, op map[string]interface{}, project, activity string, timeout time.Duration) error { |
| 66 | + w, err := createActiveDirectoryWaiter(config, op, project, activity) |
| 67 | + if err != nil || w == nil { |
| 68 | + // If w is nil, the op was synchronous. |
| 69 | + return err |
| 70 | + } |
| 71 | + return OperationWait(w, activity, timeout, config.PollInterval) |
| 72 | +} |
0 commit comments