Skip to content

Commit

Permalink
Generate Operations for Redis
Browse files Browse the repository at this point in the history
Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
modular-magician authored and rileykarson committed Feb 15, 2019
1 parent ac5820a commit 63f47d3
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 27 deletions.
27 changes: 20 additions & 7 deletions google-beta/redis_operation.go
Original file line number Diff line number Diff line change
@@ -1,28 +1,41 @@
// ----------------------------------------------------------------------------
//
// *** 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
}

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)
Expand Down
23 changes: 3 additions & 20 deletions google-beta/resource_redis_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
10 changes: 10 additions & 0 deletions website/google.erb
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,16 @@
</li>


<li<%= sidebar_current("docs-google-cloud-scheduler") %>>
<a href="#">Google Cloud Scheduler Resources</a>
<ul class="nav nav-visible">
<li<%= sidebar_current("docs-google-cloud-scheduler-job") %>>
<a href="/docs/providers/google/r/cloud_scheduler_job.html">google_cloud_scheduler_job</a>
</li>
</ul>
</li>


<li<%= sidebar_current("docs-google-cloud-scheduler") %>>
<a href="#">Google Cloud Scheduler Resources</a>
<ul class="nav nav-visible">
Expand Down

0 comments on commit 63f47d3

Please sign in to comment.