From 3b77fa17ac43cfff0c037ba3a769890ce4aa8eb8 Mon Sep 17 00:00:00 2001 From: Modular Magician Date: Tue, 24 Oct 2023 19:05:21 +0000 Subject: [PATCH] Add support for type in ApigeeEnvironment; remove obsolete broken test (#9340) [upstream:127027fb175033d97d86cb241af0ba2ba9fa0729] Signed-off-by: Modular Magician --- .changelog/9340.txt | 3 ++ .../apigee/resource_apigee_environment.go | 37 +++++++++++++++++++ ...urce_apigee_environment_nodeconfig_test.go | 3 -- .../docs/r/apigee_environment.html.markdown | 8 ++++ 4 files changed, 48 insertions(+), 3 deletions(-) create mode 100644 .changelog/9340.txt delete mode 100644 google/services/apigee/resource_apigee_environment_nodeconfig_test.go diff --git a/.changelog/9340.txt b/.changelog/9340.txt new file mode 100644 index 00000000000..ab92dafe1df --- /dev/null +++ b/.changelog/9340.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +apigee: add support for type in `google_apigee_environment` +``` diff --git a/google/services/apigee/resource_apigee_environment.go b/google/services/apigee/resource_apigee_environment.go index 7c6a9917e50..e3cfb9a6950 100644 --- a/google/services/apigee/resource_apigee_environment.go +++ b/google/services/apigee/resource_apigee_environment.go @@ -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, } @@ -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 { @@ -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 } @@ -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 { @@ -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, ",")}) @@ -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 } @@ -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 +} diff --git a/google/services/apigee/resource_apigee_environment_nodeconfig_test.go b/google/services/apigee/resource_apigee_environment_nodeconfig_test.go deleted file mode 100644 index e063eb4fd21..00000000000 --- a/google/services/apigee/resource_apigee_environment_nodeconfig_test.go +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 -package apigee_test diff --git a/website/docs/r/apigee_environment.html.markdown b/website/docs/r/apigee_environment.html.markdown index b19f4658b77..402fd67e7c4 100644 --- a/website/docs/r/apigee_environment.html.markdown +++ b/website/docs/r/apigee_environment.html.markdown @@ -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`. + The `node_config` block supports: