mirror of
https://github.com/letic/terraform-provider-google.git
synced 2024-10-01 16:21:06 +00:00
Revert "[Terraform] Autogen resource manager operations" (#3224)
Signed-off-by: Modular Magician <magic-modules@google.com>
This commit is contained in:
parent
7a91ac0205
commit
ead3dc9928
@ -63,13 +63,7 @@ func resourceGoogleFolderCreate(d *schema.ResourceData, meta interface{}) error
|
||||
return fmt.Errorf("Error creating folder '%s' in '%s': %s", displayName, parent, err)
|
||||
}
|
||||
|
||||
opV1 := make(map[string]interface{})
|
||||
waitErr := Convert(op, opV1)
|
||||
if waitErr != nil {
|
||||
return waitErr
|
||||
}
|
||||
|
||||
err = resourceManagerOperationWaitTime(config, opV1, "", "creating folder", int(d.Timeout(schema.TimeoutCreate).Minutes()))
|
||||
err = resourceManagerV2Beta1OperationWait(config.clientResourceManager, op, "creating folder")
|
||||
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating folder '%s' in '%s': %s", displayName, parent, err)
|
||||
@ -138,13 +132,7 @@ func resourceGoogleFolderUpdate(d *schema.ResourceData, meta interface{}) error
|
||||
return fmt.Errorf("Error moving folder '%s' to '%s': %s", displayName, newParent, err)
|
||||
}
|
||||
|
||||
opV1 := make(map[string]interface{})
|
||||
waitErr := Convert(op, opV1)
|
||||
if waitErr != nil {
|
||||
return waitErr
|
||||
}
|
||||
|
||||
err = resourceManagerOperationWaitTime(config, opV1, "", "move folder", int(d.Timeout(schema.TimeoutCreate).Minutes()))
|
||||
err = resourceManagerV2Beta1OperationWait(config.clientResourceManager, op, "move folder")
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error moving folder '%s' to '%s': %s", displayName, newParent, err)
|
||||
}
|
||||
|
@ -227,13 +227,7 @@ func resourceGoogleProjectCreate(d *schema.ResourceData, meta interface{}) error
|
||||
d.SetId(pid)
|
||||
|
||||
// Wait for the operation to complete
|
||||
opV1 := make(map[string]interface{})
|
||||
waitErr := Convert(op, opV1)
|
||||
if waitErr != nil {
|
||||
return waitErr
|
||||
}
|
||||
|
||||
waitErr = resourceManagerOperationWaitTime(config, opV1, "", "creating folder", int(d.Timeout(schema.TimeoutCreate).Minutes()))
|
||||
waitErr := resourceManagerOperationWait(config.clientResourceManager, op, "project to create")
|
||||
if waitErr != nil {
|
||||
// The resource wasn't actually created
|
||||
d.SetId("")
|
||||
|
@ -1,46 +0,0 @@
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// *** 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"
|
||||
)
|
||||
|
||||
type ResourceManagerOperationWaiter struct {
|
||||
Config *Config
|
||||
CommonOperationWaiter
|
||||
}
|
||||
|
||||
func (w *ResourceManagerOperationWaiter) 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://cloudresourcemanager.googleapis.com/v1/%s", w.CommonOperationWaiter.Op.Name)
|
||||
return sendRequest(w.Config, "GET", url, nil)
|
||||
}
|
||||
|
||||
func resourceManagerOperationWaitTime(config *Config, op map[string]interface{}, project, activity string, timeoutMinutes int) error {
|
||||
if val, ok := op["name"]; !ok || val == "" {
|
||||
// This was a synchronous call - there is no operation to wait for.
|
||||
return nil
|
||||
}
|
||||
w := &ResourceManagerOperationWaiter{
|
||||
Config: config,
|
||||
}
|
||||
if err := w.CommonOperationWaiter.SetOp(op); err != nil {
|
||||
return err
|
||||
}
|
||||
return OperationWait(w, activity, timeoutMinutes)
|
||||
}
|
48
google/resourcemanager_operation.go
Normal file
48
google/resourcemanager_operation.go
Normal file
@ -0,0 +1,48 @@
|
||||
package google
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"google.golang.org/api/cloudresourcemanager/v1"
|
||||
resourceManagerV2Beta1 "google.golang.org/api/cloudresourcemanager/v2beta1"
|
||||
)
|
||||
|
||||
type ResourceManagerOperationWaiter struct {
|
||||
Service *cloudresourcemanager.Service
|
||||
CommonOperationWaiter
|
||||
}
|
||||
|
||||
func (w *ResourceManagerOperationWaiter) 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()
|
||||
}
|
||||
|
||||
func resourceManagerOperationWaitTime(service *cloudresourcemanager.Service, op *cloudresourcemanager.Operation, activity string, timeoutMin int) error {
|
||||
w := &ResourceManagerOperationWaiter{
|
||||
Service: service,
|
||||
}
|
||||
if err := w.SetOp(op); err != nil {
|
||||
return err
|
||||
}
|
||||
return OperationWait(w, activity, timeoutMin)
|
||||
}
|
||||
|
||||
func resourceManagerOperationWait(service *cloudresourcemanager.Service, op *cloudresourcemanager.Operation, activity string) error {
|
||||
return resourceManagerOperationWaitTime(service, op, activity, 4)
|
||||
}
|
||||
|
||||
func resourceManagerV2Beta1OperationWait(service *cloudresourcemanager.Service, op *resourceManagerV2Beta1.Operation, activity string) error {
|
||||
return resourceManagerV2Beta1OperationWaitTime(service, op, activity, 4)
|
||||
}
|
||||
|
||||
func resourceManagerV2Beta1OperationWaitTime(service *cloudresourcemanager.Service, op *resourceManagerV2Beta1.Operation, activity string, timeoutMin int) error {
|
||||
opV1 := &cloudresourcemanager.Operation{}
|
||||
err := Convert(op, opV1)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return resourceManagerOperationWaitTime(service, opV1, activity, timeoutMin)
|
||||
}
|
Loading…
Reference in New Issue
Block a user