From 8847ec7ee10ff22a50a1b7923616c7478df5f5df Mon Sep 17 00:00:00 2001 From: rauchfussp Date: Wed, 25 Sep 2024 20:06:24 +0200 Subject: [PATCH 01/28] add auto_accept_projects in ncc group --- mmv1/products/networkconnectivity/Group.yaml | 118 ++++++++++++++++++ .../networkconnectivity/go_Group.yaml | 117 +++++++++++++++++ .../network_connectivity_group_basic.tf.erb | 18 +++ ...esource_network_connectivity_group_test.go | 96 ++++++++++++++ 4 files changed, 349 insertions(+) create mode 100644 mmv1/products/networkconnectivity/Group.yaml create mode 100644 mmv1/products/networkconnectivity/go_Group.yaml create mode 100644 mmv1/templates/terraform/examples/network_connectivity_group_basic.tf.erb create mode 100644 mmv1/third_party/terraform/services/networkconnectivity/resource_network_connectivity_group_test.go diff --git a/mmv1/products/networkconnectivity/Group.yaml b/mmv1/products/networkconnectivity/Group.yaml new file mode 100644 index 000000000000..06c5a48faa27 --- /dev/null +++ b/mmv1/products/networkconnectivity/Group.yaml @@ -0,0 +1,118 @@ +!ruby/object:Api::Resource +# Copyright 2023 Google Inc. +# Licensed under the Apache License, Version 2.0 (the License); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +name: Group +legacy_long_form_project: true +base_url: projects/{{project}}/locations/global/hubs/{{hub}}/groups +create_url: projects/{{project}}/locations/global/hubs/{{hub}}/groups/{{name}}?updateMask=autoAccept.autoAcceptProjects +self_link: projects/{{project}}/locations/global/hubs/{{hub}}/groups/{{name}} +create_verb: :PATCH +update_verb: :PATCH +update_mask: true +references: !ruby/object:Api::Resource::ReferenceLinks + guides: + 'Official Documentation': 'https://cloud.google.com/network-connectivity/docs/network-connectivity-center/concepts/overview' + api: 'https://cloud.google.com/network-connectivity/docs/reference/networkconnectivity/rest/v1beta/projects.locations.global.hubs.groups' +async: !ruby/object:Api::OpAsync + operation: !ruby/object:Api::OpAsync::Operation + path: 'name' + base_url: '{{op_id}}' + wait_ms: 1000 + result: !ruby/object:Api::OpAsync::Result + path: 'targetLink' + status: !ruby/object:Api::OpAsync::Status + path: 'status' + complete: 'DONE' + allowed: + - 'PENDING' + - 'RUNNING' + - 'DONE' + error: !ruby/object:Api::OpAsync::Error + path: 'error/errors' + message: 'message' +examples: + - !ruby/object:Provider::Terraform::Examples + name: 'network_connectivity_group_basic' + primary_resource_id: 'primary' + vars: + hub_name: "hub1" + auto_accept_project_1_name: "foo" + auto_accept_project_2_name: "bar" +description: The NetworkConnectivity Group resource +parameters: + - !ruby/object:Api::Type::ResourceRef + name: 'hub' + resource: 'Hub' + imports: 'name' + description: | + The name of the hub. Hub names must be unique. They use the following form: projects/{projectNumber}/locations/global/hubs/{hubId} + immutable: true + required: true + url_param_only: true + custom_flatten: templates/terraform/custom_flatten/name_from_self_link.erb +properties: + - !ruby/object:Api::Type::Enum + name: name + description: 'The name of the group. Group names must be unique. They use the following form: `projects/{projectNumber}/locations/global/hubs/{hub}/groups/{groupId}`' + diff_suppress_func: 'tpgresource.CompareSelfLinkOrResourceName' + required: true + immutable: true + values: + - default + - center + - edge + - !ruby/object:Api::Type::String + name: createTime + description: Output only. The time the hub was created. + output: true + - !ruby/object:Api::Type::String + name: updateTime + description: Output only. The time the hub was last updated. + output: true + - !ruby/object:Api::Type::KeyValueLabels + name: labels + description: Optional labels in key:value format. For more information about labels, see [Requirements for labels](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements). + - !ruby/object:Api::Type::String + name: description + description: An optional description of the hub. + - !ruby/object:Api::Type::String + name: uid + description: Output only. The Google-generated UUID for the group. This value is unique across all group resources. If a group is deleted and another with the same name is created, the new route table is assigned a different uniqueId. + output: true + - !ruby/object:Api::Type::String + name: state + description: Output only. The current lifecycle state of this hub. + output: true + exactly_one_of: + - STATE_UNSPECIFIED + - CREATING + - ACTIVE + - DELETING + default_value: null + - !ruby/object:Api::Type::NestedObject + name: autoAccept + description: Optional. The auto-accept setting for this group. + immutable: true + properties: + - !ruby/object:Api::Type::Array + name: autoAcceptProjects + description: 'A list of project ids or project numbers for which you want to enable auto-accept. The auto-accept setting is applied to spokes being created or updated in these projects.' + min_version: ga + required: true + immutable: true + item_type: Api::Type::String + - !ruby/object:Api::Type::String + name: routeTable + description: 'Output only. The name of the route table that corresponds to this group. They use the following form: `projects/{projectNumber}/locations/global/hubs/{hubId}/routeTables/{route_table_id}`' + output: true diff --git a/mmv1/products/networkconnectivity/go_Group.yaml b/mmv1/products/networkconnectivity/go_Group.yaml new file mode 100644 index 000000000000..e1ca4a7446d6 --- /dev/null +++ b/mmv1/products/networkconnectivity/go_Group.yaml @@ -0,0 +1,117 @@ +# Copyright 2024 Google Inc. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Warning: This is a temporary file, and should not be edited directly +--- +name: 'Group' +description: The NetworkConnectivity Group resource +references: + guides: + 'Official Documentation': 'https://cloud.google.com/network-connectivity/docs/network-connectivity-center/concepts/overview' + api: 'https://cloud.google.com/network-connectivity/docs/reference/networkconnectivity/rest/v1beta/projects.locations.global.hubs.groups' +docs: +base_url: 'projects/{{project}}/locations/global/hubs/{{hub}}/groups' +create_url: 'projects/{{project}}/locations/global/hubs/{{hub}}/groups/{{name}}?updateMask=autoAccept.autoAcceptProjects' +self_link: 'projects/{{project}}/locations/global/hubs/{{hub}}/groups/{{name}}' +create_verb: :PATCH +update_verb: :PATCH +update_mask: true +timeouts: + insert_minutes: 20 + update_minutes: 20 + delete_minutes: 20 +async: + actions: ['create', 'update'] + type: 'OpAsync' + operation: + base_url: '{{op_id}}' + path: 'name' + wait_ms: 1000 + result: + path: 'targetLink' + resource_inside_response: false + error: + path: 'error/errors' + message: 'message' +custom_code: +legacy_long_form_project: true +examples: + - name: 'network_connectivity_group_basic' + primary_resource_id: 'primary' + vars: + hub_name: 'hub1' + auto_accept_project_1_name: 'foo' + auto_accept_project_2_name: 'bar' +parameters: + - name: 'hub' + type: ResourceRef + resource: 'Hub' + imports: 'name' + description: | + The name of the hub. Hub names must be unique. They use the following form: projects/{projectNumber}/locations/global/hubs/{hubId} + required: true + immutable: true + url_param_only: true + custom_flatten: 'templates/terraform/custom_flatten/go/name_from_self_link.tmpl' +properties: + - name: 'name' + type: Enum + description: 'Immutable. The name of the group. Group names must be unique. They use the following form: projects/{projectNumber}/locations/global/hubs/{hub}/groups/{groupId}' + required: true + immutable: true + diff_suppress_func: 'tpgresource.CompareSelfLinkOrResourceName' + enum_values: + - 'default' + - 'center' + - 'edge' + - name: 'createTime' + type: String + description: Output only. The time the hub was created. + output: true + - name: 'updateTime' + type: String + description: Output only. The time the hub was last updated. + output: true + - name: 'labels' + type: KeyValueLabels + description: Optional labels in key:value format. For more information about labels, see [Requirements for labels](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements). + - name: 'description' + type: String + description: An optional description of the hub. + - name: 'uid' + type: String + description: Output only. The Google-generated UUID for the group. This value is unique across all group resources. If a group is deleted and another with the same name is created, the new route table is assigned a different uniqueId. + output: true + - name: 'state' + type: String + description: Output only. The current lifecycle state of this hub. + output: true + exactly_one_of: + - 'STATE_UNSPECIFIED' + - 'CREATING' + - 'ACTIVE' + - 'DELETING' + - name: 'autoAccept' + type: NestedObject + description: Optional. The auto-accept setting for this group. + output: true + item_type: + type: Array + properties: + - name: 'autoAcceptProjects' + type: String + description: A list of project ids or project numbers for which you want to enable auto-accept. The auto-accept setting is applied to spokes being created or updated in these projects. + - name: 'uid' + type: String + description: 'Output only. The name of the route table that corresponds to this group. They use the following form: `projects/{projectNumber}/locations/global/hubs/{hubId}/routeTables/{route_table_id}`' + output: true diff --git a/mmv1/templates/terraform/examples/network_connectivity_group_basic.tf.erb b/mmv1/templates/terraform/examples/network_connectivity_group_basic.tf.erb new file mode 100644 index 000000000000..047812af5052 --- /dev/null +++ b/mmv1/templates/terraform/examples/network_connectivity_group_basic.tf.erb @@ -0,0 +1,18 @@ +resource "google_network_connectivity_hub" "basic_hub" { + name = "<%= ctx[:vars]['hub_name'] %>" + description = "A sample hub" + labels = { + label-one = "value-one" + } +} + +resource "google_network_connectivity_group" "<%= ctx[:primary_resource_id] %>" { + hub = google_network_connectivity_hub.basic_hub.id + name = "default" + auto_accept { + auto_accept_projects = [ + "<%= ctx[:vars]['auto_accept_project_1_name'] %>", + "<%= ctx[:vars]['auto_accept_project_2_name'] %>", + ] + } +} \ No newline at end of file diff --git a/mmv1/third_party/terraform/services/networkconnectivity/resource_network_connectivity_group_test.go b/mmv1/third_party/terraform/services/networkconnectivity/resource_network_connectivity_group_test.go new file mode 100644 index 000000000000..7607c11474c4 --- /dev/null +++ b/mmv1/third_party/terraform/services/networkconnectivity/resource_network_connectivity_group_test.go @@ -0,0 +1,96 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + +package networkconnectivity_test + +import ( + "testing" + + "github.com/hashicorp/terraform-plugin-testing/helper/resource" + + "github.com/hashicorp/terraform-provider-google/google/acctest" + "github.com/hashicorp/terraform-provider-google/google/envvar" +) + +func TestAccNetworkConnectivityGroup_BasicGroup(t *testing.T) { + t.Parallel() + + context := map[string]interface{}{ + "project_name": envvar.GetTestProjectFromEnv(), + "random_suffix": acctest.RandString(t, 10), + } + + acctest.VcrTest(t, resource.TestCase{ + PreCheck: func() { acctest.AccTestPreCheck(t) }, + ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t), + CheckDestroy: testAccCheckNetworkConnectivityGroupDestroyProducer(t), + Steps: []resource.TestStep{ + { + Config: testAccNetworkConnectivityGroup_BasicGroup(context), + }, + { + ResourceName: "google_network_connectivity_group.primary", + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"labels", "terraform_labels"}, + }, + { + Config: testAccNetworkConnectivityGroup_BasicGroupUpdate0(context), + }, + { + ResourceName: "google_network_connectivity_group.primary", + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"labels", "terraform_labels"}, + }, + }, + }) +} + +func testAccNetworkConnectivityGroup_BasicGroup(context map[string]interface{}) string { + return acctest.Nprintf(` +resource "google_network_connectivity_hub" "basic_hub" { + name = "tf-test-hub%{random_suffix}" + description = "A sample hub" + project = "%{project_name}" + + labels = { + label-one = "value-one" + } +} + +resource "google_network_connectivity_group" "name" { + hub = google_network_connectivity_hub.basic_hub.id + name = "default" + auto_accept { + auto_accept_projects = ["tf-test-name%{random_suffix}"] + } +} + + +`, context) +} + +func testAccNetworkConnectivityGroup_BasicGroupUpdate0(context map[string]interface{}) string { + return acctest.Nprintf(` +resource "google_network_connectivity_hub" "basic_hub" { + name = "tf-test-hub%{random_suffix}" + description = "A sample hub" + project = "%{project_name}" + + labels = { + label-one = "value-one" + } +} + +resource "google_network_connectivity_group" "name" { + hub = google_network_connectivity_hub.basic_hub.id + name = "default" + auto_accept { + auto_accept_projects = ["tf-test-name%{random_suffix}", "tf-test-name%{random_suffix}"] + } +} + + +`, context) +} From 7f8570c073b2675d0e7019c155a7be44deb905f5 Mon Sep 17 00:00:00 2001 From: rauchfussp Date: Thu, 26 Sep 2024 07:33:51 +0200 Subject: [PATCH 02/28] fix test --- .../resource_network_connectivity_group_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mmv1/third_party/terraform/services/networkconnectivity/resource_network_connectivity_group_test.go b/mmv1/third_party/terraform/services/networkconnectivity/resource_network_connectivity_group_test.go index 7607c11474c4..99c5faab772c 100644 --- a/mmv1/third_party/terraform/services/networkconnectivity/resource_network_connectivity_group_test.go +++ b/mmv1/third_party/terraform/services/networkconnectivity/resource_network_connectivity_group_test.go @@ -59,7 +59,7 @@ resource "google_network_connectivity_hub" "basic_hub" { } } -resource "google_network_connectivity_group" "name" { +resource "google_network_connectivity_group" "primary" { hub = google_network_connectivity_hub.basic_hub.id name = "default" auto_accept { @@ -83,7 +83,7 @@ resource "google_network_connectivity_hub" "basic_hub" { } } -resource "google_network_connectivity_group" "name" { +resource "google_network_connectivity_group" "primary" { hub = google_network_connectivity_hub.basic_hub.id name = "default" auto_accept { From d220ebec2f6e6095a118647648af05d2e428b742 Mon Sep 17 00:00:00 2001 From: rauchfussp Date: Thu, 26 Sep 2024 07:59:07 +0200 Subject: [PATCH 03/28] MMv1 Go migration --- mmv1/products/networkconnectivity/Group.yaml | 64 +++++++++---------- ... network_connectivity_group_basic.tf.tmpl} | 8 +-- 2 files changed, 36 insertions(+), 36 deletions(-) rename mmv1/templates/terraform/examples/{network_connectivity_group_basic.tf.erb => network_connectivity_group_basic.tf.tmpl} (51%) diff --git a/mmv1/products/networkconnectivity/Group.yaml b/mmv1/products/networkconnectivity/Group.yaml index 06c5a48faa27..36e50d7deeb5 100644 --- a/mmv1/products/networkconnectivity/Group.yaml +++ b/mmv1/products/networkconnectivity/Group.yaml @@ -1,4 +1,3 @@ -!ruby/object:Api::Resource # Copyright 2023 Google Inc. # Licensed under the Apache License, Version 2.0 (the License); # you may not use this file except in compliance with the License. @@ -20,30 +19,30 @@ self_link: projects/{{project}}/locations/global/hubs/{{hub}}/groups/{{name}} create_verb: :PATCH update_verb: :PATCH update_mask: true -references: !ruby/object:Api::Resource::ReferenceLinks +references: guides: 'Official Documentation': 'https://cloud.google.com/network-connectivity/docs/network-connectivity-center/concepts/overview' api: 'https://cloud.google.com/network-connectivity/docs/reference/networkconnectivity/rest/v1beta/projects.locations.global.hubs.groups' -async: !ruby/object:Api::OpAsync - operation: !ruby/object:Api::OpAsync::Operation +async: + type: 'OpAsync' + operation: path: 'name' base_url: '{{op_id}}' wait_ms: 1000 - result: !ruby/object:Api::OpAsync::Result + result: path: 'targetLink' - status: !ruby/object:Api::OpAsync::Status + status: path: 'status' complete: 'DONE' allowed: - 'PENDING' - 'RUNNING' - 'DONE' - error: !ruby/object:Api::OpAsync::Error + error: path: 'error/errors' message: 'message' examples: - - !ruby/object:Provider::Terraform::Examples - name: 'network_connectivity_group_basic' + - name: 'network_connectivity_group_basic' primary_resource_id: 'primary' vars: hub_name: "hub1" @@ -51,8 +50,8 @@ examples: auto_accept_project_2_name: "bar" description: The NetworkConnectivity Group resource parameters: - - !ruby/object:Api::Type::ResourceRef - name: 'hub' + - name: 'hub' + type: ResourceRef resource: 'Hub' imports: 'name' description: | @@ -62,8 +61,8 @@ parameters: url_param_only: true custom_flatten: templates/terraform/custom_flatten/name_from_self_link.erb properties: - - !ruby/object:Api::Type::Enum - name: name + - name: name + type: Enum description: 'The name of the group. Group names must be unique. They use the following form: `projects/{projectNumber}/locations/global/hubs/{hub}/groups/{groupId}`' diff_suppress_func: 'tpgresource.CompareSelfLinkOrResourceName' required: true @@ -72,26 +71,26 @@ properties: - default - center - edge - - !ruby/object:Api::Type::String - name: createTime + - name: createTime + type: String description: Output only. The time the hub was created. output: true - - !ruby/object:Api::Type::String - name: updateTime + - name: updateTime + type: String description: Output only. The time the hub was last updated. output: true - - !ruby/object:Api::Type::KeyValueLabels - name: labels + - name: labels + type: KeyValueLabels description: Optional labels in key:value format. For more information about labels, see [Requirements for labels](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements). - - !ruby/object:Api::Type::String - name: description + - name: description + type: KeyValueLabels description: An optional description of the hub. - - !ruby/object:Api::Type::String - name: uid + - name: uid + type: String description: Output only. The Google-generated UUID for the group. This value is unique across all group resources. If a group is deleted and another with the same name is created, the new route table is assigned a different uniqueId. output: true - - !ruby/object:Api::Type::String - name: state + - name: state + type: String description: Output only. The current lifecycle state of this hub. output: true exactly_one_of: @@ -100,19 +99,20 @@ properties: - ACTIVE - DELETING default_value: null - - !ruby/object:Api::Type::NestedObject - name: autoAccept + - name: autoAccept + type: NestedObject description: Optional. The auto-accept setting for this group. immutable: true properties: - - !ruby/object:Api::Type::Array - name: autoAcceptProjects + - name: autoAcceptProjects + type: Array description: 'A list of project ids or project numbers for which you want to enable auto-accept. The auto-accept setting is applied to spokes being created or updated in these projects.' min_version: ga required: true immutable: true - item_type: Api::Type::String - - !ruby/object:Api::Type::String - name: routeTable + item_type: + type: String + - name: routeTable + type: String description: 'Output only. The name of the route table that corresponds to this group. They use the following form: `projects/{projectNumber}/locations/global/hubs/{hubId}/routeTables/{route_table_id}`' output: true diff --git a/mmv1/templates/terraform/examples/network_connectivity_group_basic.tf.erb b/mmv1/templates/terraform/examples/network_connectivity_group_basic.tf.tmpl similarity index 51% rename from mmv1/templates/terraform/examples/network_connectivity_group_basic.tf.erb rename to mmv1/templates/terraform/examples/network_connectivity_group_basic.tf.tmpl index 047812af5052..fc4e02ba572e 100644 --- a/mmv1/templates/terraform/examples/network_connectivity_group_basic.tf.erb +++ b/mmv1/templates/terraform/examples/network_connectivity_group_basic.tf.tmpl @@ -1,18 +1,18 @@ resource "google_network_connectivity_hub" "basic_hub" { - name = "<%= ctx[:vars]['hub_name'] %>" + name = "{{index $.Vars "hub_name"}}" description = "A sample hub" labels = { label-one = "value-one" } } -resource "google_network_connectivity_group" "<%= ctx[:primary_resource_id] %>" { +resource "google_network_connectivity_group" "{{$.PrimaryResourceId}}" { hub = google_network_connectivity_hub.basic_hub.id name = "default" auto_accept { auto_accept_projects = [ - "<%= ctx[:vars]['auto_accept_project_1_name'] %>", - "<%= ctx[:vars]['auto_accept_project_2_name'] %>", + "{{index $.Vars "auto_accept_project_1_name"}}", + "{{index $.Vars "auto_accept_project_2_name"}}", ] } } \ No newline at end of file From aacf4e2704c2befe68087e8000d322c4c352701f Mon Sep 17 00:00:00 2001 From: rauchfussp Date: Thu, 26 Sep 2024 08:06:14 +0200 Subject: [PATCH 04/28] remove status --- mmv1/products/networkconnectivity/Group.yaml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/mmv1/products/networkconnectivity/Group.yaml b/mmv1/products/networkconnectivity/Group.yaml index 36e50d7deeb5..ea088491e66a 100644 --- a/mmv1/products/networkconnectivity/Group.yaml +++ b/mmv1/products/networkconnectivity/Group.yaml @@ -31,13 +31,6 @@ async: wait_ms: 1000 result: path: 'targetLink' - status: - path: 'status' - complete: 'DONE' - allowed: - - 'PENDING' - - 'RUNNING' - - 'DONE' error: path: 'error/errors' message: 'message' From 566858524d2241995fd2c0ed40c8767e2fb438d9 Mon Sep 17 00:00:00 2001 From: rauchfussp Date: Thu, 26 Sep 2024 08:12:38 +0200 Subject: [PATCH 05/28] add quotes --- mmv1/products/networkconnectivity/Group.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mmv1/products/networkconnectivity/Group.yaml b/mmv1/products/networkconnectivity/Group.yaml index ea088491e66a..20d752ba6d52 100644 --- a/mmv1/products/networkconnectivity/Group.yaml +++ b/mmv1/products/networkconnectivity/Group.yaml @@ -61,9 +61,9 @@ properties: required: true immutable: true values: - - default - - center - - edge + - 'default' + - 'center' + - 'edge' - name: createTime type: String description: Output only. The time the hub was created. From e124dbfbde17477b548236ca20b3ed7ec912dd26 Mon Sep 17 00:00:00 2001 From: rauchfussp Date: Thu, 26 Sep 2024 08:27:15 +0200 Subject: [PATCH 06/28] remove legacy go-yaml file --- .../networkconnectivity/go_Group.yaml | 117 ------------------ 1 file changed, 117 deletions(-) delete mode 100644 mmv1/products/networkconnectivity/go_Group.yaml diff --git a/mmv1/products/networkconnectivity/go_Group.yaml b/mmv1/products/networkconnectivity/go_Group.yaml deleted file mode 100644 index e1ca4a7446d6..000000000000 --- a/mmv1/products/networkconnectivity/go_Group.yaml +++ /dev/null @@ -1,117 +0,0 @@ -# Copyright 2024 Google Inc. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# Warning: This is a temporary file, and should not be edited directly ---- -name: 'Group' -description: The NetworkConnectivity Group resource -references: - guides: - 'Official Documentation': 'https://cloud.google.com/network-connectivity/docs/network-connectivity-center/concepts/overview' - api: 'https://cloud.google.com/network-connectivity/docs/reference/networkconnectivity/rest/v1beta/projects.locations.global.hubs.groups' -docs: -base_url: 'projects/{{project}}/locations/global/hubs/{{hub}}/groups' -create_url: 'projects/{{project}}/locations/global/hubs/{{hub}}/groups/{{name}}?updateMask=autoAccept.autoAcceptProjects' -self_link: 'projects/{{project}}/locations/global/hubs/{{hub}}/groups/{{name}}' -create_verb: :PATCH -update_verb: :PATCH -update_mask: true -timeouts: - insert_minutes: 20 - update_minutes: 20 - delete_minutes: 20 -async: - actions: ['create', 'update'] - type: 'OpAsync' - operation: - base_url: '{{op_id}}' - path: 'name' - wait_ms: 1000 - result: - path: 'targetLink' - resource_inside_response: false - error: - path: 'error/errors' - message: 'message' -custom_code: -legacy_long_form_project: true -examples: - - name: 'network_connectivity_group_basic' - primary_resource_id: 'primary' - vars: - hub_name: 'hub1' - auto_accept_project_1_name: 'foo' - auto_accept_project_2_name: 'bar' -parameters: - - name: 'hub' - type: ResourceRef - resource: 'Hub' - imports: 'name' - description: | - The name of the hub. Hub names must be unique. They use the following form: projects/{projectNumber}/locations/global/hubs/{hubId} - required: true - immutable: true - url_param_only: true - custom_flatten: 'templates/terraform/custom_flatten/go/name_from_self_link.tmpl' -properties: - - name: 'name' - type: Enum - description: 'Immutable. The name of the group. Group names must be unique. They use the following form: projects/{projectNumber}/locations/global/hubs/{hub}/groups/{groupId}' - required: true - immutable: true - diff_suppress_func: 'tpgresource.CompareSelfLinkOrResourceName' - enum_values: - - 'default' - - 'center' - - 'edge' - - name: 'createTime' - type: String - description: Output only. The time the hub was created. - output: true - - name: 'updateTime' - type: String - description: Output only. The time the hub was last updated. - output: true - - name: 'labels' - type: KeyValueLabels - description: Optional labels in key:value format. For more information about labels, see [Requirements for labels](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements). - - name: 'description' - type: String - description: An optional description of the hub. - - name: 'uid' - type: String - description: Output only. The Google-generated UUID for the group. This value is unique across all group resources. If a group is deleted and another with the same name is created, the new route table is assigned a different uniqueId. - output: true - - name: 'state' - type: String - description: Output only. The current lifecycle state of this hub. - output: true - exactly_one_of: - - 'STATE_UNSPECIFIED' - - 'CREATING' - - 'ACTIVE' - - 'DELETING' - - name: 'autoAccept' - type: NestedObject - description: Optional. The auto-accept setting for this group. - output: true - item_type: - type: Array - properties: - - name: 'autoAcceptProjects' - type: String - description: A list of project ids or project numbers for which you want to enable auto-accept. The auto-accept setting is applied to spokes being created or updated in these projects. - - name: 'uid' - type: String - description: 'Output only. The name of the route table that corresponds to this group. They use the following form: `projects/{projectNumber}/locations/global/hubs/{hubId}/routeTables/{route_table_id}`' - output: true From f699696d576b2abfab9747050151d8ef6564c4af Mon Sep 17 00:00:00 2001 From: rauchfussp Date: Thu, 26 Sep 2024 08:27:31 +0200 Subject: [PATCH 07/28] adjust prop field --- mmv1/products/networkconnectivity/Group.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mmv1/products/networkconnectivity/Group.yaml b/mmv1/products/networkconnectivity/Group.yaml index 20d752ba6d52..47b7c623eefe 100644 --- a/mmv1/products/networkconnectivity/Group.yaml +++ b/mmv1/products/networkconnectivity/Group.yaml @@ -60,7 +60,7 @@ properties: diff_suppress_func: 'tpgresource.CompareSelfLinkOrResourceName' required: true immutable: true - values: + enum_values: - 'default' - 'center' - 'edge' From ecbc0cb8773cbac3ab1a9b49d10d3493b179faa3 Mon Sep 17 00:00:00 2001 From: rauchfussp Date: Thu, 26 Sep 2024 08:32:39 +0200 Subject: [PATCH 08/28] adjust verb definition --- mmv1/products/networkconnectivity/Group.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mmv1/products/networkconnectivity/Group.yaml b/mmv1/products/networkconnectivity/Group.yaml index 47b7c623eefe..ca0273ed3211 100644 --- a/mmv1/products/networkconnectivity/Group.yaml +++ b/mmv1/products/networkconnectivity/Group.yaml @@ -16,8 +16,8 @@ legacy_long_form_project: true base_url: projects/{{project}}/locations/global/hubs/{{hub}}/groups create_url: projects/{{project}}/locations/global/hubs/{{hub}}/groups/{{name}}?updateMask=autoAccept.autoAcceptProjects self_link: projects/{{project}}/locations/global/hubs/{{hub}}/groups/{{name}} -create_verb: :PATCH -update_verb: :PATCH +create_verb: 'PATCH' +update_verb: 'PATCH' update_mask: true references: guides: From 178244277f4a1fd4c044c504f6ff872eefc69e78 Mon Sep 17 00:00:00 2001 From: rauchfussp Date: Thu, 26 Sep 2024 08:39:16 +0200 Subject: [PATCH 09/28] fix description field type --- mmv1/products/networkconnectivity/Group.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mmv1/products/networkconnectivity/Group.yaml b/mmv1/products/networkconnectivity/Group.yaml index ca0273ed3211..d208f7a15c45 100644 --- a/mmv1/products/networkconnectivity/Group.yaml +++ b/mmv1/products/networkconnectivity/Group.yaml @@ -76,7 +76,7 @@ properties: type: KeyValueLabels description: Optional labels in key:value format. For more information about labels, see [Requirements for labels](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements). - name: description - type: KeyValueLabels + type: String description: An optional description of the hub. - name: uid type: String From 10921a46ec50e85fcc28aadb49a7b8f241a5af13 Mon Sep 17 00:00:00 2001 From: rauchfussp Date: Thu, 26 Sep 2024 11:29:43 +0200 Subject: [PATCH 10/28] fix test --- mmv1/products/networkconnectivity/Group.yaml | 112 ++++++++++++++++++ .../network_connectivity_group_basic.tf.tmpl | 18 +++ ...esource_network_connectivity_group_test.go | 90 ++++++++++++++ 3 files changed, 220 insertions(+) create mode 100644 mmv1/products/networkconnectivity/Group.yaml create mode 100644 mmv1/templates/terraform/examples/network_connectivity_group_basic.tf.tmpl create mode 100644 mmv1/third_party/terraform/services/networkconnectivity/resource_network_connectivity_group_test.go diff --git a/mmv1/products/networkconnectivity/Group.yaml b/mmv1/products/networkconnectivity/Group.yaml new file mode 100644 index 000000000000..55fbb10502ff --- /dev/null +++ b/mmv1/products/networkconnectivity/Group.yaml @@ -0,0 +1,112 @@ +# Copyright 2023 Google Inc. +# Licensed under the Apache License, Version 2.0 (the License); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +name: Group +legacy_long_form_project: true +base_url: projects/{{project}}/locations/global/hubs/{{hub}}/groups +create_url: projects/{{project}}/locations/global/hubs/{{hub}}/groups/{{name}}?updateMask=autoAccept.autoAcceptProjects +self_link: projects/{{project}}/locations/global/hubs/{{hub}}/groups/{{name}} +create_verb: 'PATCH' +update_verb: 'PATCH' +update_mask: true +references: + guides: + 'Official Documentation': 'https://cloud.google.com/network-connectivity/docs/network-connectivity-center/concepts/overview' + api: 'https://cloud.google.com/network-connectivity/docs/reference/networkconnectivity/rest/v1beta/projects.locations.global.hubs.groups' +async: + type: 'OpAsync' + operation: + path: 'name' + base_url: '{{op_id}}' + wait_ms: 1000 + result: + path: 'targetLink' + error: + path: 'error/errors' + message: 'message' +examples: + - name: 'network_connectivity_group_basic' + primary_resource_id: 'primary' + vars: + hub_name: "hub1" + auto_accept_project_1_name: "foo" + auto_accept_project_2_name: "bar" +description: The NetworkConnectivity Group resource +parameters: + - name: 'hub' + type: ResourceRef + resource: 'Hub' + imports: 'id' + description: | + The name of the hub. Hub names must be unique. They use the following form: projects/{projectNumber}/locations/global/hubs/{hubId} + immutable: true + required: true + url_param_only: true + custom_flatten: templates/terraform/custom_flatten/name_from_self_link.erb +properties: + - name: name + type: Enum + description: 'The name of the group. Group names must be unique. They use the following form: `projects/{projectNumber}/locations/global/hubs/{hub}/groups/{groupId}`' + diff_suppress_func: 'tpgresource.CompareSelfLinkOrResourceName' + required: true + immutable: true + custom_flatten: 'templates/terraform/custom_flatten/name_from_self_link.tmpl' + enum_values: + - 'default' + - 'center' + - 'edge' + - name: createTime + type: String + description: Output only. The time the hub was created. + output: true + - name: updateTime + type: String + description: Output only. The time the hub was last updated. + output: true + - name: labels + type: KeyValueLabels + description: Optional labels in key:value format. For more information about labels, see [Requirements for labels](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements). + - name: description + type: String + description: An optional description of the hub. + - name: uid + type: String + description: Output only. The Google-generated UUID for the group. This value is unique across all group resources. If a group is deleted and another with the same name is created, the new route table is assigned a different uniqueId. + output: true + - name: state + type: String + description: Output only. The current lifecycle state of this hub. + output: true + exactly_one_of: + - STATE_UNSPECIFIED + - CREATING + - ACTIVE + - DELETING + default_value: null + - name: autoAccept + type: NestedObject + description: Optional. The auto-accept setting for this group. + immutable: true + properties: + - name: autoAcceptProjects + type: Array + description: 'A list of project ids or project numbers for which you want to enable auto-accept. The auto-accept setting is applied to spokes being created or updated in these projects.' + min_version: ga + required: true + immutable: true + item_type: + type: String + - name: routeTable + type: String + description: 'Output only. The name of the route table that corresponds to this group. They use the following form: `projects/{projectNumber}/locations/global/hubs/{hubId}/routeTables/{route_table_id}`' + output: true \ No newline at end of file diff --git a/mmv1/templates/terraform/examples/network_connectivity_group_basic.tf.tmpl b/mmv1/templates/terraform/examples/network_connectivity_group_basic.tf.tmpl new file mode 100644 index 000000000000..cc359346125b --- /dev/null +++ b/mmv1/templates/terraform/examples/network_connectivity_group_basic.tf.tmpl @@ -0,0 +1,18 @@ +resource "google_network_connectivity_hub" "basic_hub" { + name = "{{index $.Vars "hub_name"}}" + description = "A sample hub" + labels = { + label-one = "value-one" + } +} + +resource "google_network_connectivity_group" "{{$.PrimaryResourceId}}" { + hub = google_network_connectivity_hub.basic_hub.id + name = "default" + auto_accept { + auto_accept_projects = [ + "{{index $.Vars "auto_accept_project_1_name"}}", + "{{index $.Vars "auto_accept_project_2_name"}}", + ] + } +} \ No newline at end of file diff --git a/mmv1/third_party/terraform/services/networkconnectivity/resource_network_connectivity_group_test.go b/mmv1/third_party/terraform/services/networkconnectivity/resource_network_connectivity_group_test.go new file mode 100644 index 000000000000..a7b2a6f77388 --- /dev/null +++ b/mmv1/third_party/terraform/services/networkconnectivity/resource_network_connectivity_group_test.go @@ -0,0 +1,90 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + +package networkconnectivity_test + +import ( + "testing" + + "github.com/hashicorp/terraform-plugin-testing/helper/resource" + + "github.com/hashicorp/terraform-provider-google/google/acctest" + "github.com/hashicorp/terraform-provider-google/google/envvar" +) + +func TestAccNetworkConnectivityGroup_BasicGroup(t *testing.T) { + t.Parallel() + + context := map[string]interface{}{ + "project_name": envvar.GetTestProjectFromEnv(), + "hub_random_suffix": acctest.RandString(t, 10), + "project_random_suffix_1": acctest.RandString(t, 10), + "project_random_suffix_2": acctest.RandString(t, 10), + } + + acctest.VcrTest(t, resource.TestCase{ + PreCheck: func() { acctest.AccTestPreCheck(t) }, + ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t), + CheckDestroy: testAccCheckNetworkConnectivityGroupDestroyProducer(t), + Steps: []resource.TestStep{ + { + Config: testAccNetworkConnectivityGroup_BasicGroup(context), + }, + { + ResourceName: "google_network_connectivity_group.primary", + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"hub", "labels", "terraform_labels"}, + }, + { + Config: testAccNetworkConnectivityGroup_BasicGroupUpdate0(context), + }, + { + ResourceName: "google_network_connectivity_group.primary", + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"hub", "labels", "terraform_labels"}, + }, + }, + }) +} + +func testAccNetworkConnectivityGroup_BasicGroup(context map[string]interface{}) string { + return acctest.Nprintf(` +resource "google_network_connectivity_hub" "basic_hub" { + name = "tf-test-hub%{hub_random_suffix}" + description = "A sample hub" + project = "%{project_name}" + labels = { + label-one = "value-one" + } +} +resource "google_network_connectivity_group" "primary" { + hub = google_network_connectivity_hub.basic_hub.id + name = "default" + auto_accept { + auto_accept_projects = ["tf-test-name%{project_random_suffix_1}"] + } +} +`, context) +} + +func testAccNetworkConnectivityGroup_BasicGroupUpdate0(context map[string]interface{}) string { + return acctest.Nprintf(` +resource "google_network_connectivity_hub" "basic_hub" { + name = "tf-test-hub%{hub_random_suffix}" + description = "A sample hub" + project = "%{project_name}" + labels = { + label-one = "value-one" + } +} +resource "google_network_connectivity_group" "primary" { + hub = google_network_connectivity_hub.basic_hub.id + name = "default" + auto_accept { + auto_accept_projects = ["tf-test-name%{project_random_suffix_1}", "tf-test-name%{project_random_suffix_2}"] + } +} +`, context) +} From b491eb466d909f8ffa67d3b56384e34420c9e8e6 Mon Sep 17 00:00:00 2001 From: rauchfussp Date: Thu, 26 Sep 2024 11:39:07 +0200 Subject: [PATCH 11/28] Revert "fix description field type" This reverts commit 178244277f4a1fd4c044c504f6ff872eefc69e78. --- mmv1/products/networkconnectivity/Group.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mmv1/products/networkconnectivity/Group.yaml b/mmv1/products/networkconnectivity/Group.yaml index d28a64c2a7ad..4490ce40cad2 100644 --- a/mmv1/products/networkconnectivity/Group.yaml +++ b/mmv1/products/networkconnectivity/Group.yaml @@ -77,7 +77,7 @@ properties: type: KeyValueLabels description: Optional labels in key:value format. For more information about labels, see [Requirements for labels](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements). - name: description - type: String + type: KeyValueLabels description: An optional description of the hub. - name: uid type: String From 2a210f9c55a8a309315c7e6b56c3ac9ec209e805 Mon Sep 17 00:00:00 2001 From: rauchfussp Date: Thu, 26 Sep 2024 11:48:44 +0200 Subject: [PATCH 12/28] fix field --- mmv1/products/networkconnectivity/Group.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mmv1/products/networkconnectivity/Group.yaml b/mmv1/products/networkconnectivity/Group.yaml index 4490ce40cad2..d28a64c2a7ad 100644 --- a/mmv1/products/networkconnectivity/Group.yaml +++ b/mmv1/products/networkconnectivity/Group.yaml @@ -77,7 +77,7 @@ properties: type: KeyValueLabels description: Optional labels in key:value format. For more information about labels, see [Requirements for labels](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements). - name: description - type: KeyValueLabels + type: String description: An optional description of the hub. - name: uid type: String From c70f294f441da35d8662d08390ef6a8ad6155b5c Mon Sep 17 00:00:00 2001 From: rauchfussp Date: Thu, 26 Sep 2024 12:34:17 +0200 Subject: [PATCH 13/28] fmt --- .../resource_network_connectivity_group_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mmv1/third_party/terraform/services/networkconnectivity/resource_network_connectivity_group_test.go b/mmv1/third_party/terraform/services/networkconnectivity/resource_network_connectivity_group_test.go index a7b2a6f77388..bee92657d31b 100644 --- a/mmv1/third_party/terraform/services/networkconnectivity/resource_network_connectivity_group_test.go +++ b/mmv1/third_party/terraform/services/networkconnectivity/resource_network_connectivity_group_test.go @@ -16,8 +16,8 @@ func TestAccNetworkConnectivityGroup_BasicGroup(t *testing.T) { t.Parallel() context := map[string]interface{}{ - "project_name": envvar.GetTestProjectFromEnv(), - "hub_random_suffix": acctest.RandString(t, 10), + "project_name": envvar.GetTestProjectFromEnv(), + "hub_random_suffix": acctest.RandString(t, 10), "project_random_suffix_1": acctest.RandString(t, 10), "project_random_suffix_2": acctest.RandString(t, 10), } From c6549639c3c90832f02908d55188907a939baca4 Mon Sep 17 00:00:00 2001 From: rauchfussp Date: Thu, 26 Sep 2024 12:46:50 +0200 Subject: [PATCH 14/28] fix automated test --- .../network_connectivity_group_basic.tf.tmpl | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/mmv1/templates/terraform/examples/network_connectivity_group_basic.tf.tmpl b/mmv1/templates/terraform/examples/network_connectivity_group_basic.tf.tmpl index 1655d7bea4fd..cc359346125b 100644 --- a/mmv1/templates/terraform/examples/network_connectivity_group_basic.tf.tmpl +++ b/mmv1/templates/terraform/examples/network_connectivity_group_basic.tf.tmpl @@ -6,24 +6,6 @@ resource "google_network_connectivity_hub" "basic_hub" { } } -resource "google_network_connectivity_group" "{{$.PrimaryResourceId}}" { - hub = google_network_connectivity_hub.basic_hub.id - name = "default" - auto_accept { - auto_accept_projects = [ - "{{index $.Vars "auto_accept_project_1_name"}}", - "{{index $.Vars "auto_accept_project_2_name"}}", - ] - } -} -resource "google_network_connectivity_hub" "basic_hub" { - name = "{{index $.Vars "hub_name"}}" - description = "A sample hub" - labels = { - label-one = "value-one" - } -} - resource "google_network_connectivity_group" "{{$.PrimaryResourceId}}" { hub = google_network_connectivity_hub.basic_hub.id name = "default" From ed076b137f085160f64820b509003c46e2cd29e0 Mon Sep 17 00:00:00 2001 From: Patrick Rauchfuss Date: Fri, 4 Oct 2024 12:58:19 +0200 Subject: [PATCH 15/28] update description Co-authored-by: Zhenhua Li --- mmv1/products/networkconnectivity/Group.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mmv1/products/networkconnectivity/Group.yaml b/mmv1/products/networkconnectivity/Group.yaml index d28a64c2a7ad..44a175a764f9 100644 --- a/mmv1/products/networkconnectivity/Group.yaml +++ b/mmv1/products/networkconnectivity/Group.yaml @@ -56,7 +56,7 @@ parameters: properties: - name: name type: Enum - description: 'The name of the group. Group names must be unique. They use the following form: `projects/{projectNumber}/locations/global/hubs/{hub}/groups/{groupId}`' + description: 'The name of the group. Group names must be unique. diff_suppress_func: 'tpgresource.CompareSelfLinkOrResourceName' required: true immutable: true From 387b7ecb7006634c7469a478bc1a376a85d12ac0 Mon Sep 17 00:00:00 2001 From: rauchfussp Date: Fri, 4 Oct 2024 12:59:03 +0200 Subject: [PATCH 16/28] adjust copyright year --- mmv1/products/networkconnectivity/Group.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mmv1/products/networkconnectivity/Group.yaml b/mmv1/products/networkconnectivity/Group.yaml index d28a64c2a7ad..f6d35b6d84f9 100644 --- a/mmv1/products/networkconnectivity/Group.yaml +++ b/mmv1/products/networkconnectivity/Group.yaml @@ -1,4 +1,4 @@ -# Copyright 2023 Google Inc. +# Copyright 2024 Google Inc. # Licensed under the Apache License, Version 2.0 (the License); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at From 9743f0d41153500cf06e0a7d4ce6b80b9808c5d8 Mon Sep 17 00:00:00 2001 From: rauchfussp Date: Fri, 4 Oct 2024 12:59:32 +0200 Subject: [PATCH 17/28] remove STATE_UNSPECIFIED --- mmv1/products/networkconnectivity/Group.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/mmv1/products/networkconnectivity/Group.yaml b/mmv1/products/networkconnectivity/Group.yaml index f6d35b6d84f9..03f26af00428 100644 --- a/mmv1/products/networkconnectivity/Group.yaml +++ b/mmv1/products/networkconnectivity/Group.yaml @@ -88,7 +88,6 @@ properties: description: Output only. The current lifecycle state of this hub. output: true exactly_one_of: - - STATE_UNSPECIFIED - CREATING - ACTIVE - DELETING From 2e35044aa3b822536b2dbdca72c1f053d15ce90c Mon Sep 17 00:00:00 2001 From: rauchfussp Date: Fri, 4 Oct 2024 13:00:21 +0200 Subject: [PATCH 18/28] remove default null state --- mmv1/products/networkconnectivity/Group.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/mmv1/products/networkconnectivity/Group.yaml b/mmv1/products/networkconnectivity/Group.yaml index 03f26af00428..e08de301940c 100644 --- a/mmv1/products/networkconnectivity/Group.yaml +++ b/mmv1/products/networkconnectivity/Group.yaml @@ -91,7 +91,6 @@ properties: - CREATING - ACTIVE - DELETING - default_value: null - name: autoAccept type: NestedObject description: Optional. The auto-accept setting for this group. From 27cdfd02d790682c0594b25924d6d9c54fe48f2a Mon Sep 17 00:00:00 2001 From: rauchfussp Date: Fri, 4 Oct 2024 13:03:30 +0200 Subject: [PATCH 19/28] remove min provider version --- mmv1/products/networkconnectivity/Group.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/mmv1/products/networkconnectivity/Group.yaml b/mmv1/products/networkconnectivity/Group.yaml index e08de301940c..0d1b17923361 100644 --- a/mmv1/products/networkconnectivity/Group.yaml +++ b/mmv1/products/networkconnectivity/Group.yaml @@ -99,7 +99,6 @@ properties: - name: autoAcceptProjects type: Array description: 'A list of project ids or project numbers for which you want to enable auto-accept. The auto-accept setting is applied to spokes being created or updated in these projects.' - min_version: ga required: true immutable: true item_type: From 3158e33a97cba5e0afae6e8cf24536068ec5a748 Mon Sep 17 00:00:00 2001 From: Patrick Rauchfuss Date: Fri, 4 Oct 2024 13:03:51 +0200 Subject: [PATCH 20/28] adjust hub name Co-authored-by: Zhenhua Li --- mmv1/products/networkconnectivity/Group.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mmv1/products/networkconnectivity/Group.yaml b/mmv1/products/networkconnectivity/Group.yaml index 44a175a764f9..d8840c1e5883 100644 --- a/mmv1/products/networkconnectivity/Group.yaml +++ b/mmv1/products/networkconnectivity/Group.yaml @@ -38,7 +38,7 @@ examples: - name: 'network_connectivity_group_basic' primary_resource_id: 'primary' vars: - hub_name: "hub1" + hub_name: "network-connectivity-hub1" auto_accept_project_1_name: "foo" auto_accept_project_2_name: "bar" description: The NetworkConnectivity Group resource From 7d499fa444f29a9fb8b554d7c70c18bde37a3e92 Mon Sep 17 00:00:00 2001 From: rauchfussp Date: Fri, 4 Oct 2024 13:05:29 +0200 Subject: [PATCH 21/28] add exclude_sweeper --- mmv1/products/networkconnectivity/Group.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mmv1/products/networkconnectivity/Group.yaml b/mmv1/products/networkconnectivity/Group.yaml index 0d1b17923361..456ed08b701d 100644 --- a/mmv1/products/networkconnectivity/Group.yaml +++ b/mmv1/products/networkconnectivity/Group.yaml @@ -61,6 +61,8 @@ properties: required: true immutable: true custom_flatten: 'templates/terraform/custom_flatten/name_from_self_link.tmpl' + # A handwritten sweeper is needed as the resource name can only be `default`, `center`, and `edge`. + exclude_sweeper: true enum_values: - 'default' - 'center' From 3d30920125c1a4028f4d531469aa0feb1b0c2c5b Mon Sep 17 00:00:00 2001 From: rauchfussp Date: Fri, 4 Oct 2024 13:09:15 +0200 Subject: [PATCH 22/28] test labels and description update --- .../resource_network_connectivity_group_test.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/mmv1/third_party/terraform/services/networkconnectivity/resource_network_connectivity_group_test.go b/mmv1/third_party/terraform/services/networkconnectivity/resource_network_connectivity_group_test.go index bee92657d31b..df1f485464c9 100644 --- a/mmv1/third_party/terraform/services/networkconnectivity/resource_network_connectivity_group_test.go +++ b/mmv1/third_party/terraform/services/networkconnectivity/resource_network_connectivity_group_test.go @@ -34,7 +34,7 @@ func TestAccNetworkConnectivityGroup_BasicGroup(t *testing.T) { ResourceName: "google_network_connectivity_group.primary", ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"hub", "labels", "terraform_labels"}, + ImportStateVerifyIgnore: []string{"hub", "terraform_labels"}, }, { Config: testAccNetworkConnectivityGroup_BasicGroupUpdate0(context), @@ -43,7 +43,7 @@ func TestAccNetworkConnectivityGroup_BasicGroup(t *testing.T) { ResourceName: "google_network_connectivity_group.primary", ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"hub", "labels", "terraform_labels"}, + ImportStateVerifyIgnore: []string{"hub", "terraform_labels"}, }, }, }) @@ -62,6 +62,10 @@ resource "google_network_connectivity_hub" "basic_hub" { resource "google_network_connectivity_group" "primary" { hub = google_network_connectivity_hub.basic_hub.id name = "default" + labels = { + label-one = "value-one" + } + description = "A sample hub group" auto_accept { auto_accept_projects = ["tf-test-name%{project_random_suffix_1}"] } @@ -82,6 +86,10 @@ resource "google_network_connectivity_hub" "basic_hub" { resource "google_network_connectivity_group" "primary" { hub = google_network_connectivity_hub.basic_hub.id name = "default" + labels = { + label-one = "value-two" + } + description = "A sample hub group update" auto_accept { auto_accept_projects = ["tf-test-name%{project_random_suffix_1}", "tf-test-name%{project_random_suffix_2}"] } From 001340c22bd3d3fdaa8abbc831cb458504d79665 Mon Sep 17 00:00:00 2001 From: rauchfussp Date: Fri, 4 Oct 2024 13:12:11 +0200 Subject: [PATCH 23/28] fix failing yaml --- mmv1/products/networkconnectivity/Group.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mmv1/products/networkconnectivity/Group.yaml b/mmv1/products/networkconnectivity/Group.yaml index fc5463697c1f..0f3de983021e 100644 --- a/mmv1/products/networkconnectivity/Group.yaml +++ b/mmv1/products/networkconnectivity/Group.yaml @@ -56,7 +56,7 @@ parameters: properties: - name: name type: Enum - description: 'The name of the group. Group names must be unique. + description: 'The name of the group. Group names must be unique.' diff_suppress_func: 'tpgresource.CompareSelfLinkOrResourceName' required: true immutable: true From a7b855c3708c13c46149740245d66517956727a7 Mon Sep 17 00:00:00 2001 From: rauchfussp Date: Fri, 4 Oct 2024 13:17:28 +0200 Subject: [PATCH 24/28] fix exclude_sweeper position --- mmv1/products/networkconnectivity/Group.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mmv1/products/networkconnectivity/Group.yaml b/mmv1/products/networkconnectivity/Group.yaml index 0f3de983021e..3fd51572f215 100644 --- a/mmv1/products/networkconnectivity/Group.yaml +++ b/mmv1/products/networkconnectivity/Group.yaml @@ -34,6 +34,8 @@ async: error: path: 'error/errors' message: 'message' +# A handwritten sweeper is needed as the resource name can only be `default`, `center`, and `edge`. +exclude_sweeper: true examples: - name: 'network_connectivity_group_basic' primary_resource_id: 'primary' @@ -61,8 +63,6 @@ properties: required: true immutable: true custom_flatten: 'templates/terraform/custom_flatten/name_from_self_link.tmpl' - # A handwritten sweeper is needed as the resource name can only be `default`, `center`, and `edge`. - exclude_sweeper: true enum_values: - 'default' - 'center' From cb8cb098a32734cdb5d908c044dad6af7b5afab7 Mon Sep 17 00:00:00 2001 From: rauchfussp Date: Fri, 4 Oct 2024 13:37:11 +0200 Subject: [PATCH 25/28] fix test --- .../resource_network_connectivity_group_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mmv1/third_party/terraform/services/networkconnectivity/resource_network_connectivity_group_test.go b/mmv1/third_party/terraform/services/networkconnectivity/resource_network_connectivity_group_test.go index df1f485464c9..d02b61b3ed58 100644 --- a/mmv1/third_party/terraform/services/networkconnectivity/resource_network_connectivity_group_test.go +++ b/mmv1/third_party/terraform/services/networkconnectivity/resource_network_connectivity_group_test.go @@ -34,7 +34,7 @@ func TestAccNetworkConnectivityGroup_BasicGroup(t *testing.T) { ResourceName: "google_network_connectivity_group.primary", ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"hub", "terraform_labels"}, + ImportStateVerifyIgnore: []string{"hub", "labels", "terraform_labels"}, }, { Config: testAccNetworkConnectivityGroup_BasicGroupUpdate0(context), @@ -43,7 +43,7 @@ func TestAccNetworkConnectivityGroup_BasicGroup(t *testing.T) { ResourceName: "google_network_connectivity_group.primary", ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"hub", "terraform_labels"}, + ImportStateVerifyIgnore: []string{"hub", "labels", "terraform_labels"}, }, }, }) From 97e0734366ab695bc1d34523da1e96de2ea6896f Mon Sep 17 00:00:00 2001 From: rauchfussp Date: Fri, 4 Oct 2024 15:50:20 +0200 Subject: [PATCH 26/28] fix tests --- mmv1/products/networkconnectivity/Group.yaml | 4 ++-- .../examples/network_connectivity_group_basic.tf.tmpl | 4 ++++ .../resource_network_connectivity_group_test.go | 6 +++--- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/mmv1/products/networkconnectivity/Group.yaml b/mmv1/products/networkconnectivity/Group.yaml index 3fd51572f215..a1fb18cc18af 100644 --- a/mmv1/products/networkconnectivity/Group.yaml +++ b/mmv1/products/networkconnectivity/Group.yaml @@ -14,7 +14,7 @@ name: Group legacy_long_form_project: true base_url: projects/{{project}}/locations/global/hubs/{{hub}}/groups -create_url: projects/{{project}}/locations/global/hubs/{{hub}}/groups/{{name}}?updateMask=autoAccept.autoAcceptProjects +create_url: projects/{{project}}/locations/global/hubs/{{hub}}/groups/{{name}}?updateMask=autoAccept.autoAcceptProjects,labels,description self_link: projects/{{project}}/locations/global/hubs/{{hub}}/groups/{{name}} create_verb: 'PATCH' update_verb: 'PATCH' @@ -80,7 +80,7 @@ properties: description: Optional labels in key:value format. For more information about labels, see [Requirements for labels](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements). - name: description type: String - description: An optional description of the hub. + description: An optional description of the group. - name: uid type: String description: Output only. The Google-generated UUID for the group. This value is unique across all group resources. If a group is deleted and another with the same name is created, the new route table is assigned a different uniqueId. diff --git a/mmv1/templates/terraform/examples/network_connectivity_group_basic.tf.tmpl b/mmv1/templates/terraform/examples/network_connectivity_group_basic.tf.tmpl index cc359346125b..b3ee2b621624 100644 --- a/mmv1/templates/terraform/examples/network_connectivity_group_basic.tf.tmpl +++ b/mmv1/templates/terraform/examples/network_connectivity_group_basic.tf.tmpl @@ -9,6 +9,10 @@ resource "google_network_connectivity_hub" "basic_hub" { resource "google_network_connectivity_group" "{{$.PrimaryResourceId}}" { hub = google_network_connectivity_hub.basic_hub.id name = "default" + labels = { + label-one = "value-one" + } + description = "A sample hub group" auto_accept { auto_accept_projects = [ "{{index $.Vars "auto_accept_project_1_name"}}", diff --git a/mmv1/third_party/terraform/services/networkconnectivity/resource_network_connectivity_group_test.go b/mmv1/third_party/terraform/services/networkconnectivity/resource_network_connectivity_group_test.go index d02b61b3ed58..dc0d96c0a552 100644 --- a/mmv1/third_party/terraform/services/networkconnectivity/resource_network_connectivity_group_test.go +++ b/mmv1/third_party/terraform/services/networkconnectivity/resource_network_connectivity_group_test.go @@ -65,7 +65,7 @@ resource "google_network_connectivity_group" "primary" { labels = { label-one = "value-one" } - description = "A sample hub group" + description = "A sample group" auto_accept { auto_accept_projects = ["tf-test-name%{project_random_suffix_1}"] } @@ -87,9 +87,9 @@ resource "google_network_connectivity_group" "primary" { hub = google_network_connectivity_hub.basic_hub.id name = "default" labels = { - label-one = "value-two" + label-two = "value-one" } - description = "A sample hub group update" + description = "An updated sample group" auto_accept { auto_accept_projects = ["tf-test-name%{project_random_suffix_1}", "tf-test-name%{project_random_suffix_2}"] } From bda54e56102f3cceb739f33a51c495ad54180342 Mon Sep 17 00:00:00 2001 From: rauchfussp Date: Thu, 17 Oct 2024 16:46:55 +0200 Subject: [PATCH 27/28] fix field immutability --- mmv1/products/networkconnectivity/Group.yaml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/mmv1/products/networkconnectivity/Group.yaml b/mmv1/products/networkconnectivity/Group.yaml index a1fb18cc18af..00db44c3de50 100644 --- a/mmv1/products/networkconnectivity/Group.yaml +++ b/mmv1/products/networkconnectivity/Group.yaml @@ -15,10 +15,10 @@ name: Group legacy_long_form_project: true base_url: projects/{{project}}/locations/global/hubs/{{hub}}/groups create_url: projects/{{project}}/locations/global/hubs/{{hub}}/groups/{{name}}?updateMask=autoAccept.autoAcceptProjects,labels,description +update_url: projects/{{project}}/locations/global/hubs/{{hub}}/groups/{{name}}?updateMask=autoAccept.autoAcceptProjects,labels,description self_link: projects/{{project}}/locations/global/hubs/{{hub}}/groups/{{name}} create_verb: 'PATCH' update_verb: 'PATCH' -update_mask: true references: guides: 'Official Documentation': 'https://cloud.google.com/network-connectivity/docs/network-connectivity-center/concepts/overview' @@ -96,13 +96,11 @@ properties: - name: autoAccept type: NestedObject description: Optional. The auto-accept setting for this group. - immutable: true properties: - name: autoAcceptProjects type: Array description: 'A list of project ids or project numbers for which you want to enable auto-accept. The auto-accept setting is applied to spokes being created or updated in these projects.' required: true - immutable: true item_type: type: String - name: routeTable From 31fe6f20e85c194e3d62b1c734a2e8e5b4f47f49 Mon Sep 17 00:00:00 2001 From: rauchfussp Date: Thu, 17 Oct 2024 21:07:05 +0200 Subject: [PATCH 28/28] remove copyright --- .../resource_network_connectivity_group_test.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/mmv1/third_party/terraform/services/networkconnectivity/resource_network_connectivity_group_test.go b/mmv1/third_party/terraform/services/networkconnectivity/resource_network_connectivity_group_test.go index dc0d96c0a552..68b531193d0c 100644 --- a/mmv1/third_party/terraform/services/networkconnectivity/resource_network_connectivity_group_test.go +++ b/mmv1/third_party/terraform/services/networkconnectivity/resource_network_connectivity_group_test.go @@ -1,6 +1,3 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - package networkconnectivity_test import (