-
Notifications
You must be signed in to change notification settings - Fork 262
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for Datastream service & for ConnectionProfile resource (…
…#6479) (#4657) * Added datastream connection profile * Updated resource and tests to get to passing basic/full tests * Added update test * Corrected license dates * Moved url params into parameters array * Removed long timeouts * Ensured that update test actually tests update * Made update test move from gcs bucket to postgresql database instance * Switched to handwritten operation due to unexpected error structure * Added authorized networks to sql database instance * fixed whitespace * Re-added async definitions Async definitions are used to figure out whether to call async code even if the async code isn't autogenerated * Added postgresql password to importstateverifyignore Signed-off-by: Modular Magician <[email protected]> Signed-off-by: Modular Magician <[email protected]>
- Loading branch information
1 parent
73c7f33
commit 9122286
Showing
9 changed files
with
2,283 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
```release-note:new-resource | ||
google_datastream_connection_profile | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
package google | ||
|
||
import ( | ||
"bytes" | ||
"encoding/json" | ||
"fmt" | ||
datastream "google.golang.org/api/datastream/v1" | ||
"time" | ||
) | ||
|
||
type DatastreamOperationWaiter struct { | ||
Config *Config | ||
UserAgent string | ||
Project string | ||
CommonOperationWaiter | ||
} | ||
|
||
func (w *DatastreamOperationWaiter) QueryOp() (interface{}, error) { | ||
if w == nil { | ||
return nil, fmt.Errorf("Cannot query operation, it's unset or nil.") | ||
} | ||
// Returns the proper get. | ||
url := fmt.Sprintf("%s%s", w.Config.DatastreamBasePath, w.CommonOperationWaiter.Op.Name) | ||
|
||
return sendRequest(w.Config, "GET", w.Project, url, w.UserAgent, nil) | ||
} | ||
|
||
func (w *DatastreamOperationWaiter) Error() error { | ||
if w != nil && w.Op.Error != nil { | ||
return DatastreamError(*w.Op.Error) | ||
} | ||
return nil | ||
} | ||
|
||
func createDatastreamWaiter(config *Config, op map[string]interface{}, project, activity, userAgent string) (*DatastreamOperationWaiter, error) { | ||
w := &DatastreamOperationWaiter{ | ||
Config: config, | ||
UserAgent: userAgent, | ||
Project: project, | ||
} | ||
if err := w.CommonOperationWaiter.SetOp(op); err != nil { | ||
return nil, err | ||
} | ||
return w, nil | ||
} | ||
|
||
// nolint: deadcode,unused | ||
func datastreamOperationWaitTimeWithResponse(config *Config, op map[string]interface{}, response *map[string]interface{}, project, activity, userAgent string, timeout time.Duration) error { | ||
w, err := createDatastreamWaiter(config, op, project, activity, userAgent) | ||
if err != nil { | ||
return err | ||
} | ||
if err := OperationWait(w, activity, timeout, config.PollInterval); err != nil { | ||
return err | ||
} | ||
return json.Unmarshal([]byte(w.CommonOperationWaiter.Op.Response), response) | ||
} | ||
|
||
func datastreamOperationWaitTime(config *Config, op map[string]interface{}, project, activity, userAgent string, timeout time.Duration) error { | ||
if val, ok := op["name"]; !ok || val == "" { | ||
// This was a synchronous call - there is no operation to wait for. | ||
return nil | ||
} | ||
w, err := createDatastreamWaiter(config, op, project, activity, userAgent) | ||
if err != nil { | ||
// If w is nil, the op was synchronous. | ||
return err | ||
} | ||
return OperationWait(w, activity, timeout, config.PollInterval) | ||
} | ||
|
||
// DatastreamError wraps datastream.Status and implements the | ||
// error interface so it can be returned. | ||
type DatastreamError datastream.Status | ||
|
||
func (e DatastreamError) Error() string { | ||
var buf bytes.Buffer | ||
|
||
for _, err := range e.Details { | ||
buf.Write(err) | ||
buf.WriteString("\n") | ||
} | ||
|
||
return buf.String() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.