Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build datastore index resource. #1755

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .changelog/3085.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
```release-note:new-resource
google_datastore_index

```
27 changes: 25 additions & 2 deletions google-beta/access_context_manager_operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
package google

import (
"encoding/json"
"fmt"
)

Expand All @@ -31,15 +32,37 @@ func (w *AccessContextManagerOperationWaiter) QueryOp() (interface{}, error) {
return sendRequest(w.Config, "GET", "", url, nil)
}

func accessContextManagerOperationWaitTime(config *Config, op map[string]interface{}, activity string, timeoutMinutes int) error {
func createAccessContextManagerWaiter(config *Config, op map[string]interface{}, activity string) (*AccessContextManagerOperationWaiter, error) {
if val, ok := op["name"]; !ok || val == "" {
// This was a synchronous call - there is no operation to wait for.
return nil
return nil, nil
}
w := &AccessContextManagerOperationWaiter{
Config: config,
}
if err := w.CommonOperationWaiter.SetOp(op); err != nil {
return nil, err
}
return w, nil
}

// nolint: deadcode,unused
func accessContextManagerOperationWaitTimeWithResponse(config *Config, op map[string]interface{}, response *map[string]interface{}, activity string, timeoutMinutes int) error {
w, err := createAccessContextManagerWaiter(config, op, activity)
if err != nil || w == nil {
// If w is nil, the op was synchronous.
return err
}
if err := OperationWait(w, activity, timeoutMinutes); err != nil {
return err
}
return json.Unmarshal([]byte(w.CommonOperationWaiter.Op.Response), response)
}

func accessContextManagerOperationWaitTime(config *Config, op map[string]interface{}, activity string, timeoutMinutes int) error {
w, err := createAccessContextManagerWaiter(config, op, activity)
if err != nil || w == nil {
// If w is nil, the op was synchronous.
return err
}
return OperationWait(w, activity, timeoutMinutes)
Expand Down
22 changes: 22 additions & 0 deletions google-beta/appengine_operation.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package google

import (
"encoding/json"
"fmt"
"regexp"

Expand Down Expand Up @@ -32,6 +33,27 @@ func appEngineOperationWait(config *Config, res interface{}, appId, activity str
return appEngineOperationWaitTime(config, res, appId, activity, 4)
}

func appEngineOperationWaitTimeWithResponse(config *Config, res interface{}, response *map[string]interface{}, appId, activity string, timeoutMinutes int) error {
op := &appengine.Operation{}
err := Convert(res, op)
if err != nil {
return err
}

w := &AppEngineOperationWaiter{
Service: config.clientAppEngine,
AppId: appId,
}

if err := w.SetOp(op); err != nil {
return err
}
if err := OperationWait(w, activity, timeoutMinutes); err != nil {
return err
}
return json.Unmarshal([]byte(w.CommonOperationWaiter.Op.Response), response)
}

func appEngineOperationWaitTime(config *Config, res interface{}, appId, activity string, timeoutMinutes int) error {
op := &appengine.Operation{}
err := Convert(res, op)
Expand Down
3 changes: 3 additions & 0 deletions google-beta/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ type Config struct {
ContainerAnalysisBasePath string
DataFusionBasePath string
DataprocBasePath string
DatastoreBasePath string
DeploymentManagerBasePath string
DialogflowBasePath string
DNSBasePath string
Expand Down Expand Up @@ -233,6 +234,7 @@ var ComputeDefaultBasePath = "https://www.googleapis.com/compute/beta/"
var ContainerAnalysisDefaultBasePath = "https://containeranalysis.googleapis.com/v1beta1/"
var DataFusionDefaultBasePath = "https://datafusion.googleapis.com/v1beta1/"
var DataprocDefaultBasePath = "https://dataproc.googleapis.com/v1beta2/"
var DatastoreDefaultBasePath = "https://datastore.googleapis.com/v1/"
var DeploymentManagerDefaultBasePath = "https://www.googleapis.com/deploymentmanager/v2/"
var DialogflowDefaultBasePath = "https://dialogflow.googleapis.com/v2/"
var DNSDefaultBasePath = "https://www.googleapis.com/dns/v1beta2/"
Expand Down Expand Up @@ -734,6 +736,7 @@ func ConfigureBasePaths(c *Config) {
c.ContainerAnalysisBasePath = ContainerAnalysisDefaultBasePath
c.DataFusionBasePath = DataFusionDefaultBasePath
c.DataprocBasePath = DataprocDefaultBasePath
c.DatastoreBasePath = DatastoreDefaultBasePath
c.DeploymentManagerBasePath = DeploymentManagerDefaultBasePath
c.DialogflowBasePath = DialogflowDefaultBasePath
c.DNSBasePath = DNSDefaultBasePath
Expand Down
27 changes: 25 additions & 2 deletions google-beta/data_fusion_operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
package google

import (
"encoding/json"
"fmt"
)

Expand All @@ -32,16 +33,38 @@ func (w *DataFusionOperationWaiter) QueryOp() (interface{}, error) {
return sendRequest(w.Config, "GET", w.Project, url, nil)
}

func dataFusionOperationWaitTime(config *Config, op map[string]interface{}, project, activity string, timeoutMinutes int) error {
func createDataFusionWaiter(config *Config, op map[string]interface{}, project, activity string) (*DataFusionOperationWaiter, error) {
if val, ok := op["name"]; !ok || val == "" {
// This was a synchronous call - there is no operation to wait for.
return nil
return nil, nil
}
w := &DataFusionOperationWaiter{
Config: config,
Project: project,
}
if err := w.CommonOperationWaiter.SetOp(op); err != nil {
return nil, err
}
return w, nil
}

// nolint: deadcode,unused
func dataFusionOperationWaitTimeWithResponse(config *Config, op map[string]interface{}, response *map[string]interface{}, project, activity string, timeoutMinutes int) error {
w, err := createDataFusionWaiter(config, op, project, activity)
if err != nil || w == nil {
// If w is nil, the op was synchronous.
return err
}
if err := OperationWait(w, activity, timeoutMinutes); err != nil {
return err
}
return json.Unmarshal([]byte(w.CommonOperationWaiter.Op.Response), response)
}

func dataFusionOperationWaitTime(config *Config, op map[string]interface{}, project, activity string, timeoutMinutes int) error {
w, err := createDataFusionWaiter(config, op, project, activity)
if err != nil || w == nil {
// If w is nil, the op was synchronous.
return err
}
return OperationWait(w, activity, timeoutMinutes)
Expand Down
71 changes: 71 additions & 0 deletions google-beta/datastore_operation.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
// ----------------------------------------------------------------------------
//
// *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
//
// ----------------------------------------------------------------------------
//
// This file is automatically generated by Magic Modules and manual
// changes will be clobbered when the file is regenerated.
//
// Please read more about how to change this file in
// .github/CONTRIBUTING.md.
//
// ----------------------------------------------------------------------------
package google

import (
"encoding/json"
"fmt"
)

type DatastoreOperationWaiter struct {
Config *Config
Project string
CommonOperationWaiter
}

func (w *DatastoreOperationWaiter) 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("https://datastore.googleapis.com/v1/%s", w.CommonOperationWaiter.Op.Name)
return sendRequest(w.Config, "GET", w.Project, url, nil)
}

func createDatastoreWaiter(config *Config, op map[string]interface{}, project, activity string) (*DatastoreOperationWaiter, error) {
if val, ok := op["name"]; !ok || val == "" {
// This was a synchronous call - there is no operation to wait for.
return nil, nil
}
w := &DatastoreOperationWaiter{
Config: config,
Project: project,
}
if err := w.CommonOperationWaiter.SetOp(op); err != nil {
return nil, err
}
return w, nil
}

// nolint: deadcode,unused
func datastoreOperationWaitTimeWithResponse(config *Config, op map[string]interface{}, response *map[string]interface{}, project, activity string, timeoutMinutes int) error {
w, err := createDatastoreWaiter(config, op, project, activity)
if err != nil || w == nil {
// If w is nil, the op was synchronous.
return err
}
if err := OperationWait(w, activity, timeoutMinutes); err != nil {
return err
}
return json.Unmarshal([]byte(w.CommonOperationWaiter.Op.Response), response)
}

func datastoreOperationWaitTime(config *Config, op map[string]interface{}, project, activity string, timeoutMinutes int) error {
w, err := createDatastoreWaiter(config, op, project, activity)
if err != nil || w == nil {
// If w is nil, the op was synchronous.
return err
}
return OperationWait(w, activity, timeoutMinutes)
}
27 changes: 25 additions & 2 deletions google-beta/filestore_operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
package google

import (
"encoding/json"
"fmt"
)

Expand All @@ -32,16 +33,38 @@ func (w *FilestoreOperationWaiter) QueryOp() (interface{}, error) {
return sendRequest(w.Config, "GET", w.Project, url, nil)
}

func filestoreOperationWaitTime(config *Config, op map[string]interface{}, project, activity string, timeoutMinutes int) error {
func createFilestoreWaiter(config *Config, op map[string]interface{}, project, activity string) (*FilestoreOperationWaiter, error) {
if val, ok := op["name"]; !ok || val == "" {
// This was a synchronous call - there is no operation to wait for.
return nil
return nil, nil
}
w := &FilestoreOperationWaiter{
Config: config,
Project: project,
}
if err := w.CommonOperationWaiter.SetOp(op); err != nil {
return nil, err
}
return w, nil
}

// nolint: deadcode,unused
func filestoreOperationWaitTimeWithResponse(config *Config, op map[string]interface{}, response *map[string]interface{}, project, activity string, timeoutMinutes int) error {
w, err := createFilestoreWaiter(config, op, project, activity)
if err != nil || w == nil {
// If w is nil, the op was synchronous.
return err
}
if err := OperationWait(w, activity, timeoutMinutes); err != nil {
return err
}
return json.Unmarshal([]byte(w.CommonOperationWaiter.Op.Response), response)
}

func filestoreOperationWaitTime(config *Config, op map[string]interface{}, project, activity string, timeoutMinutes int) error {
w, err := createFilestoreWaiter(config, op, project, activity)
if err != nil || w == nil {
// If w is nil, the op was synchronous.
return err
}
return OperationWait(w, activity, timeoutMinutes)
Expand Down
27 changes: 25 additions & 2 deletions google-beta/firestore_operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
package google

import (
"encoding/json"
"fmt"
)

Expand All @@ -32,16 +33,38 @@ func (w *FirestoreOperationWaiter) QueryOp() (interface{}, error) {
return sendRequest(w.Config, "GET", w.Project, url, nil)
}

func firestoreOperationWaitTime(config *Config, op map[string]interface{}, project, activity string, timeoutMinutes int) error {
func createFirestoreWaiter(config *Config, op map[string]interface{}, project, activity string) (*FirestoreOperationWaiter, error) {
if val, ok := op["name"]; !ok || val == "" {
// This was a synchronous call - there is no operation to wait for.
return nil
return nil, nil
}
w := &FirestoreOperationWaiter{
Config: config,
Project: project,
}
if err := w.CommonOperationWaiter.SetOp(op); err != nil {
return nil, err
}
return w, nil
}

// nolint: deadcode,unused
func firestoreOperationWaitTimeWithResponse(config *Config, op map[string]interface{}, response *map[string]interface{}, project, activity string, timeoutMinutes int) error {
w, err := createFirestoreWaiter(config, op, project, activity)
if err != nil || w == nil {
// If w is nil, the op was synchronous.
return err
}
if err := OperationWait(w, activity, timeoutMinutes); err != nil {
return err
}
return json.Unmarshal([]byte(w.CommonOperationWaiter.Op.Response), response)
}

func firestoreOperationWaitTime(config *Config, op map[string]interface{}, project, activity string, timeoutMinutes int) error {
w, err := createFirestoreWaiter(config, op, project, activity)
if err != nil || w == nil {
// If w is nil, the op was synchronous.
return err
}
return OperationWait(w, activity, timeoutMinutes)
Expand Down
27 changes: 25 additions & 2 deletions google-beta/ml_engine_operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
package google

import (
"encoding/json"
"fmt"
)

Expand All @@ -32,16 +33,38 @@ func (w *MLEngineOperationWaiter) QueryOp() (interface{}, error) {
return sendRequest(w.Config, "GET", w.Project, url, nil)
}

func mLEngineOperationWaitTime(config *Config, op map[string]interface{}, project, activity string, timeoutMinutes int) error {
func createMLEngineWaiter(config *Config, op map[string]interface{}, project, activity string) (*MLEngineOperationWaiter, error) {
if val, ok := op["name"]; !ok || val == "" {
// This was a synchronous call - there is no operation to wait for.
return nil
return nil, nil
}
w := &MLEngineOperationWaiter{
Config: config,
Project: project,
}
if err := w.CommonOperationWaiter.SetOp(op); err != nil {
return nil, err
}
return w, nil
}

// nolint: deadcode,unused
func mLEngineOperationWaitTimeWithResponse(config *Config, op map[string]interface{}, response *map[string]interface{}, project, activity string, timeoutMinutes int) error {
w, err := createMLEngineWaiter(config, op, project, activity)
if err != nil || w == nil {
// If w is nil, the op was synchronous.
return err
}
if err := OperationWait(w, activity, timeoutMinutes); err != nil {
return err
}
return json.Unmarshal([]byte(w.CommonOperationWaiter.Op.Response), response)
}

func mLEngineOperationWaitTime(config *Config, op map[string]interface{}, project, activity string, timeoutMinutes int) error {
w, err := createMLEngineWaiter(config, op, project, activity)
if err != nil || w == nil {
// If w is nil, the op was synchronous.
return err
}
return OperationWait(w, activity, timeoutMinutes)
Expand Down
Loading