From 63f47d34c21f4b29ba024cb9f13e887d9b4a3e55 Mon Sep 17 00:00:00 2001 From: The Magician Date: Thu, 14 Feb 2019 16:00:54 -0800 Subject: [PATCH] Generate Operations for Redis Signed-off-by: Modular Magician --- google-beta/redis_operation.go | 27 +++++++++++++++++++------- google-beta/resource_redis_instance.go | 23 +++------------------- website/google.erb | 10 ++++++++++ 3 files changed, 33 insertions(+), 27 deletions(-) diff --git a/google-beta/redis_operation.go b/google-beta/redis_operation.go index 14ee7cd22a..0bf41782b4 100644 --- a/google-beta/redis_operation.go +++ b/google-beta/redis_operation.go @@ -1,13 +1,24 @@ +// ---------------------------------------------------------------------------- +// +// *** 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 ( "fmt" - - redis "google.golang.org/api/redis/v1beta1" ) type RedisOperationWaiter struct { - Service *redis.ProjectsLocationsService + Config *Config CommonOperationWaiter } @@ -15,14 +26,16 @@ func (w *RedisOperationWaiter) QueryOp() (interface{}, error) { if w == nil { return nil, fmt.Errorf("Cannot query operation, it's unset or nil.") } - return w.Service.Operations.Get(w.Op.Name).Do() + // Returns the proper get. + url := fmt.Sprintf("https://redis.googleapis.com/v1beta1/%s", w.CommonOperationWaiter.Op.Name) + return sendRequest(w.Config, "GET", url, nil) } -func redisOperationWaitTime(service *redis.Service, op *redis.Operation, project, activity string, timeoutMinutes int) error { +func redisOperationWaitTime(config *Config, op map[string]interface{}, project, activity string, timeoutMinutes int) error { w := &RedisOperationWaiter{ - Service: service.Projects.Locations, + Config: config, } - if err := w.SetOp(op); err != nil { + if err := w.CommonOperationWaiter.SetOp(op); err != nil { return err } return OperationWait(w, activity, timeoutMinutes) diff --git a/google-beta/resource_redis_instance.go b/google-beta/resource_redis_instance.go index 5f5f056f6f..97a91ea3de 100644 --- a/google-beta/resource_redis_instance.go +++ b/google-beta/resource_redis_instance.go @@ -24,7 +24,6 @@ import ( "github.com/hashicorp/terraform/helper/schema" "github.com/hashicorp/terraform/helper/validation" - redis "google.golang.org/api/redis/v1beta1" ) func resourceRedisInstance() *schema.Resource { @@ -231,14 +230,8 @@ func resourceRedisInstanceCreate(d *schema.ResourceData, meta interface{}) error if err != nil { return err } - op := &redis.Operation{} - err = Convert(res, op) - if err != nil { - return err - } - waitErr := redisOperationWaitTime( - config.clientRedis, op, project, "Creating Instance", + config, res, project, "Creating Instance", int(d.Timeout(schema.TimeoutCreate).Minutes())) if waitErr != nil { @@ -390,14 +383,9 @@ func resourceRedisInstanceUpdate(d *schema.ResourceData, meta interface{}) error if err != nil { return err } - op := &redis.Operation{} - err = Convert(res, op) - if err != nil { - return err - } err = redisOperationWaitTime( - config.clientRedis, op, project, "Updating Instance", + config, res, project, "Updating Instance", int(d.Timeout(schema.TimeoutUpdate).Minutes())) if err != nil { @@ -426,14 +414,9 @@ func resourceRedisInstanceDelete(d *schema.ResourceData, meta interface{}) error if err != nil { return err } - op := &redis.Operation{} - err = Convert(res, op) - if err != nil { - return err - } err = redisOperationWaitTime( - config.clientRedis, op, project, "Deleting Instance", + config, res, project, "Deleting Instance", int(d.Timeout(schema.TimeoutDelete).Minutes())) if err != nil { diff --git a/website/google.erb b/website/google.erb index 77e692d7ae..7473f432c8 100644 --- a/website/google.erb +++ b/website/google.erb @@ -316,6 +316,16 @@ + > + Google Cloud Scheduler Resources + + + + > Google Cloud Scheduler Resources