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

Add support for type in ApigeeEnvironment; remove obsolete broken test #16349

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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/9340.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
apigee: add support for type in `google_apigee_environment`
```
37 changes: 37 additions & 0 deletions google/services/apigee/resource_apigee_environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,16 @@ all instances.`,
},
},
},
"type": {
Type: schema.TypeString,
Computed: true,
Optional: true,
ValidateFunc: verify.ValidateEnum([]string{"ENVIRONMENT_TYPE_UNSPECIFIED", "BASE", "INTERMEDIATE", "COMPREHENSIVE", ""}),
Description: `Types that can be selected for an Environment. Each of the types are
limited by capability and capacity. Refer to Apigee's public documentation
to understand about each of these types in details.
An Apigee org can support heterogeneous Environments. Possible values: ["ENVIRONMENT_TYPE_UNSPECIFIED", "BASE", "INTERMEDIATE", "COMPREHENSIVE"]`,
},
},
UseJSONNumber: true,
}
Expand Down Expand Up @@ -177,6 +187,12 @@ func resourceApigeeEnvironmentCreate(d *schema.ResourceData, meta interface{}) e
} else if v, ok := d.GetOkExists("node_config"); !tpgresource.IsEmptyValue(reflect.ValueOf(nodeConfigProp)) && (ok || !reflect.DeepEqual(v, nodeConfigProp)) {
obj["nodeConfig"] = nodeConfigProp
}
typeProp, err := expandApigeeEnvironmentType(d.Get("type"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("type"); !tpgresource.IsEmptyValue(reflect.ValueOf(typeProp)) && (ok || !reflect.DeepEqual(v, typeProp)) {
obj["type"] = typeProp
}

url, err := tpgresource.ReplaceVars(d, config, "{{ApigeeBasePath}}{{org_id}}/environments")
if err != nil {
Expand Down Expand Up @@ -288,6 +304,9 @@ func resourceApigeeEnvironmentRead(d *schema.ResourceData, meta interface{}) err
if err := d.Set("node_config", flattenApigeeEnvironmentNodeConfig(res["nodeConfig"], d, config)); err != nil {
return fmt.Errorf("Error reading Environment: %s", err)
}
if err := d.Set("type", flattenApigeeEnvironmentType(res["type"], d, config)); err != nil {
return fmt.Errorf("Error reading Environment: %s", err)
}

return nil
}
Expand All @@ -308,6 +327,12 @@ func resourceApigeeEnvironmentUpdate(d *schema.ResourceData, meta interface{}) e
} else if v, ok := d.GetOkExists("node_config"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, nodeConfigProp)) {
obj["nodeConfig"] = nodeConfigProp
}
typeProp, err := expandApigeeEnvironmentType(d.Get("type"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("type"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, typeProp)) {
obj["type"] = typeProp
}

url, err := tpgresource.ReplaceVars(d, config, "{{ApigeeBasePath}}{{org_id}}/environments/{{name}}")
if err != nil {
Expand All @@ -320,6 +345,10 @@ func resourceApigeeEnvironmentUpdate(d *schema.ResourceData, meta interface{}) e
if d.HasChange("node_config") {
updateMask = append(updateMask, "nodeConfig")
}

if d.HasChange("type") {
updateMask = append(updateMask, "type")
}
// updateMask is a URL parameter but not present in the schema, so ReplaceVars
// won't set it
url, err = transport_tpg.AddQueryParams(url, map[string]string{"updateMask": strings.Join(updateMask, ",")})
Expand Down Expand Up @@ -503,6 +532,10 @@ func flattenApigeeEnvironmentNodeConfigCurrentAggregateNodeCount(v interface{},
return v
}

func flattenApigeeEnvironmentType(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
return v
}

func expandApigeeEnvironmentName(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
return v, nil
}
Expand Down Expand Up @@ -567,3 +600,7 @@ func expandApigeeEnvironmentNodeConfigMaxNodeCount(v interface{}, d tpgresource.
func expandApigeeEnvironmentNodeConfigCurrentAggregateNodeCount(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
return v, nil
}

func expandApigeeEnvironmentType(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
return v, nil
}

This file was deleted.

8 changes: 8 additions & 0 deletions website/docs/r/apigee_environment.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,14 @@ The following arguments are supported:
NodeConfig for setting the min/max number of nodes associated with the environment.
Structure is [documented below](#nested_node_config).

* `type` -
(Optional)
Types that can be selected for an Environment. Each of the types are
limited by capability and capacity. Refer to Apigee's public documentation
to understand about each of these types in details.
An Apigee org can support heterogeneous Environments.
Possible values are: `ENVIRONMENT_TYPE_UNSPECIFIED`, `BASE`, `INTERMEDIATE`, `COMPREHENSIVE`.


<a name="nested_node_config"></a>The `node_config` block supports:

Expand Down