Skip to content

Commit

Permalink
change update verb for apigee_envgroup to patch (#5047) (#9740)
Browse files Browse the repository at this point in the history
Signed-off-by: Modular Magician <magic-modules@google.com>
  • Loading branch information
modular-magician authored Aug 6, 2021
1 parent 2e49f17 commit 6ae1e37
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
3 changes: 3 additions & 0 deletions .changelog/5047.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
apigee: fixed update behavior on `google_apigee_envgroup`
```
19 changes: 12 additions & 7 deletions google/resource_apigee_envgroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,12 +186,6 @@ func resourceApigeeEnvgroupUpdate(d *schema.ResourceData, meta interface{}) erro
billingProject := ""

obj := make(map[string]interface{})
nameProp, err := expandApigeeEnvgroupName(d.Get("name"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("name"); !isEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, nameProp)) {
obj["name"] = nameProp
}
hostnamesProp, err := expandApigeeEnvgroupHostnames(d.Get("hostnames"), d, config)
if err != nil {
return err
Expand All @@ -205,13 +199,24 @@ func resourceApigeeEnvgroupUpdate(d *schema.ResourceData, meta interface{}) erro
}

log.Printf("[DEBUG] Updating Envgroup %q: %#v", d.Id(), obj)
updateMask := []string{}

if d.HasChange("hostnames") {
updateMask = append(updateMask, "hostnames")
}
// updateMask is a URL parameter but not present in the schema, so replaceVars
// won't set it
url, err = addQueryParams(url, map[string]string{"updateMask": strings.Join(updateMask, ",")})
if err != nil {
return err
}

// err == nil indicates that the billing_project value was found
if bp, err := getBillingProject(d, config); err == nil {
billingProject = bp
}

res, err := sendRequestWithTimeout(config, "PUT", billingProject, url, userAgent, obj, d.Timeout(schema.TimeoutUpdate))
res, err := sendRequestWithTimeout(config, "PATCH", billingProject, url, userAgent, obj, d.Timeout(schema.TimeoutUpdate))

if err != nil {
return fmt.Errorf("Error updating Envgroup %q: %s", d.Id(), err)
Expand Down

0 comments on commit 6ae1e37

Please sign in to comment.