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

fix endpoint for non-global #13014

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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/6752.txt
@@ -0,0 +1,3 @@
```release-note:bug
dialogflowcx: fixed a deployment issue for `google_dialogflow_cx_version` and `google_dialogflow_cx_environment` when they are deployed to a non-global location
```
28 changes: 8 additions & 20 deletions google/dialogflow_cx_operation.go
@@ -1,17 +1,3 @@
// ----------------------------------------------------------------------------
//
// *** AUTO GENERATED CODE *** Type: MMv1 ***
//
// ----------------------------------------------------------------------------
//
// 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 (
Expand All @@ -24,22 +10,24 @@ type DialogflowCXOperationWaiter struct {
Config *Config
UserAgent string
CommonOperationWaiter
Location string
}

func (w *DialogflowCXOperationWaiter) 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://dialogflow.googleapis.com/v3/%s", w.CommonOperationWaiter.Op.Name)
url := fmt.Sprintf("https://%s-dialogflow.googleapis.com/v3/%s", w.Location, w.CommonOperationWaiter.Op.Name)

return sendRequest(w.Config, "GET", "", url, w.UserAgent, nil)
}

func createDialogflowCXWaiter(config *Config, op map[string]interface{}, activity, userAgent string) (*DialogflowCXOperationWaiter, error) {
func createDialogflowCXWaiter(config *Config, op map[string]interface{}, activity, userAgent, location string) (*DialogflowCXOperationWaiter, error) {
w := &DialogflowCXOperationWaiter{
Config: config,
UserAgent: userAgent,
Location: location,
}
if err := w.CommonOperationWaiter.SetOp(op); err != nil {
return nil, err
Expand All @@ -48,8 +36,8 @@ func createDialogflowCXWaiter(config *Config, op map[string]interface{}, activit
}

// nolint: deadcode,unused
func dialogflowCXOperationWaitTimeWithResponse(config *Config, op map[string]interface{}, response *map[string]interface{}, activity, userAgent string, timeout time.Duration) error {
w, err := createDialogflowCXWaiter(config, op, activity, userAgent)
func dialogflowCXOperationWaitTimeWithResponse(config *Config, op map[string]interface{}, response *map[string]interface{}, activity, userAgent, location string, timeout time.Duration) error {
w, err := createDialogflowCXWaiter(config, op, activity, userAgent, location)
if err != nil {
return err
}
Expand All @@ -59,12 +47,12 @@ func dialogflowCXOperationWaitTimeWithResponse(config *Config, op map[string]int
return json.Unmarshal([]byte(w.CommonOperationWaiter.Op.Response), response)
}

func dialogflowCXOperationWaitTime(config *Config, op map[string]interface{}, activity, userAgent string, timeout time.Duration) error {
func dialogflowCXOperationWaitTime(config *Config, op map[string]interface{}, activity, userAgent, location 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 := createDialogflowCXWaiter(config, op, activity, userAgent)
w, err := createDialogflowCXWaiter(config, op, activity, userAgent, location)
if err != nil {
// If w is nil, the op was synchronous.
return err
Expand Down
8 changes: 4 additions & 4 deletions google/provider.go
Expand Up @@ -925,9 +925,9 @@ func Provider() *schema.Provider {
return provider
}

// Generated resources: 248
// Generated resources: 246
// Generated IAM resources: 150
// Total generated resources: 398
// Total generated resources: 396
func ResourceMap() map[string]*schema.Resource {
resourceMap, _ := ResourceMapWithErrors()
return resourceMap
Expand Down Expand Up @@ -1153,10 +1153,8 @@ func ResourceMapWithErrors() (map[string]*schema.Resource, error) {
"google_dialogflow_cx_agent": resourceDialogflowCXAgent(),
"google_dialogflow_cx_intent": resourceDialogflowCXIntent(),
"google_dialogflow_cx_flow": resourceDialogflowCXFlow(),
"google_dialogflow_cx_version": resourceDialogflowCXVersion(),
"google_dialogflow_cx_page": resourceDialogflowCXPage(),
"google_dialogflow_cx_entity_type": resourceDialogflowCXEntityType(),
"google_dialogflow_cx_environment": resourceDialogflowCXEnvironment(),
"google_dialogflow_cx_webhook": resourceDialogflowCXWebhook(),
"google_dns_managed_zone": resourceDNSManagedZone(),
"google_dns_policy": resourceDNSPolicy(),
Expand Down Expand Up @@ -1355,6 +1353,8 @@ func ResourceMapWithErrors() (map[string]*schema.Resource, error) {
"google_dataflow_job": resourceDataflowJob(),
"google_dataproc_cluster": resourceDataprocCluster(),
"google_dataproc_job": resourceDataprocJob(),
"google_dialogflow_cx_version": resourceDialogflowCXVersion(),
"google_dialogflow_cx_environment": resourceDialogflowCXEnvironment(),
"google_dns_record_set": resourceDnsRecordSet(),
"google_endpoints_service": resourceEndpointsService(),
"google_folder": resourceGoogleFolder(),
Expand Down
20 changes: 3 additions & 17 deletions google/resource_dialogflow_cx_environment.go
@@ -1,17 +1,3 @@
// ----------------------------------------------------------------------------
//
// *** AUTO GENERATED CODE *** Type: MMv1 ***
//
// ----------------------------------------------------------------------------
//
// 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 (
Expand Down Expand Up @@ -162,7 +148,7 @@ func resourceDialogflowCXEnvironmentCreate(d *schema.ResourceData, meta interfac
// identity fields and d.Id() before read
var opRes map[string]interface{}
err = dialogflowCXOperationWaitTimeWithResponse(
config, res, &opRes, "Creating Environment", userAgent,
config, res, &opRes, "Creating Environment", userAgent, location,
d.Timeout(schema.TimeoutCreate))
if err != nil {
// The resource didn't actually create
Expand Down Expand Up @@ -328,7 +314,7 @@ func resourceDialogflowCXEnvironmentUpdate(d *schema.ResourceData, meta interfac
}

err = dialogflowCXOperationWaitTime(
config, res, "Updating Environment", userAgent,
config, res, "Updating Environment", userAgent, location,
d.Timeout(schema.TimeoutUpdate))

if err != nil {
Expand Down Expand Up @@ -381,7 +367,7 @@ func resourceDialogflowCXEnvironmentDelete(d *schema.ResourceData, meta interfac
}

err = dialogflowCXOperationWaitTime(
config, res, "Deleting Environment", userAgent,
config, res, "Deleting Environment", userAgent, location,
d.Timeout(schema.TimeoutDelete))

if err != nil {
Expand Down
116 changes: 0 additions & 116 deletions google/resource_dialogflow_cx_environment_generated_test.go

This file was deleted.

20 changes: 3 additions & 17 deletions google/resource_dialogflow_cx_version.go
@@ -1,17 +1,3 @@
// ----------------------------------------------------------------------------
//
// *** AUTO GENERATED CODE *** Type: MMv1 ***
//
// ----------------------------------------------------------------------------
//
// 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 (
Expand Down Expand Up @@ -181,7 +167,7 @@ func resourceDialogflowCXVersionCreate(d *schema.ResourceData, meta interface{})
// identity fields and d.Id() before read
var opRes map[string]interface{}
err = dialogflowCXOperationWaitTimeWithResponse(
config, res, &opRes, "Creating Version", userAgent,
config, res, &opRes, "Creating Version", userAgent, location,
d.Timeout(schema.TimeoutCreate))
if err != nil {
// The resource didn't actually create
Expand Down Expand Up @@ -340,7 +326,7 @@ func resourceDialogflowCXVersionUpdate(d *schema.ResourceData, meta interface{})
}

err = dialogflowCXOperationWaitTime(
config, res, "Updating Version", userAgent,
config, res, "Updating Version", userAgent, location,
d.Timeout(schema.TimeoutUpdate))

if err != nil {
Expand Down Expand Up @@ -393,7 +379,7 @@ func resourceDialogflowCXVersionDelete(d *schema.ResourceData, meta interface{})
}

err = dialogflowCXOperationWaitTime(
config, res, "Deleting Version", userAgent,
config, res, "Deleting Version", userAgent, location,
d.Timeout(schema.TimeoutDelete))

if err != nil {
Expand Down