From 265c6c2ca440799439239473499a379ffb2e97e2 Mon Sep 17 00:00:00 2001 From: The Magician Date: Fri, 31 May 2024 13:46:06 -0700 Subject: [PATCH] Introduce endpoint global access field in endpoint attachment resource (#10632) (#7443) [upstream:48dec2af5cf1b80049cdfe22b02eaea8ad9c1146] Signed-off-by: Modular Magician --- ...egration_connectors_endpoint_attachment.go | 32 +++++++++++++++++++ ...ion_connectors_endpoint_attachment_test.go | 2 ++ ...nnectors_endpoint_attachment.html.markdown | 4 +++ 3 files changed, 38 insertions(+) diff --git a/google-beta/services/integrationconnectors/resource_integration_connectors_endpoint_attachment.go b/google-beta/services/integrationconnectors/resource_integration_connectors_endpoint_attachment.go index afeaa99ea0..64572cd9ee 100644 --- a/google-beta/services/integrationconnectors/resource_integration_connectors_endpoint_attachment.go +++ b/google-beta/services/integrationconnectors/resource_integration_connectors_endpoint_attachment.go @@ -78,6 +78,11 @@ func ResourceIntegrationConnectorsEndpointAttachment() *schema.Resource { Optional: true, Description: `Description of the resource.`, }, + "endpoint_global_access": { + Type: schema.TypeBool, + Optional: true, + Description: `Enable global access for endpoint attachment.`, + }, "labels": { Type: schema.TypeMap, Optional: true, @@ -147,6 +152,12 @@ func resourceIntegrationConnectorsEndpointAttachmentCreate(d *schema.ResourceDat } else if v, ok := d.GetOkExists("service_attachment"); !tpgresource.IsEmptyValue(reflect.ValueOf(serviceAttachmentProp)) && (ok || !reflect.DeepEqual(v, serviceAttachmentProp)) { obj["serviceAttachment"] = serviceAttachmentProp } + endpointGlobalAccessProp, err := expandIntegrationConnectorsEndpointAttachmentEndpointGlobalAccess(d.Get("endpoint_global_access"), d, config) + if err != nil { + return err + } else if v, ok := d.GetOkExists("endpoint_global_access"); !tpgresource.IsEmptyValue(reflect.ValueOf(endpointGlobalAccessProp)) && (ok || !reflect.DeepEqual(v, endpointGlobalAccessProp)) { + obj["endpointGlobalAccess"] = endpointGlobalAccessProp + } labelsProp, err := expandIntegrationConnectorsEndpointAttachmentEffectiveLabels(d.Get("effective_labels"), d, config) if err != nil { return err @@ -280,6 +291,9 @@ func resourceIntegrationConnectorsEndpointAttachmentRead(d *schema.ResourceData, if err := d.Set("endpoint_ip", flattenIntegrationConnectorsEndpointAttachmentEndpointIp(res["endpointIp"], d, config)); err != nil { return fmt.Errorf("Error reading EndpointAttachment: %s", err) } + if err := d.Set("endpoint_global_access", flattenIntegrationConnectorsEndpointAttachmentEndpointGlobalAccess(res["endpointGlobalAccess"], d, config)); err != nil { + return fmt.Errorf("Error reading EndpointAttachment: %s", err) + } if err := d.Set("terraform_labels", flattenIntegrationConnectorsEndpointAttachmentTerraformLabels(res["labels"], d, config)); err != nil { return fmt.Errorf("Error reading EndpointAttachment: %s", err) } @@ -312,6 +326,12 @@ func resourceIntegrationConnectorsEndpointAttachmentUpdate(d *schema.ResourceDat } else if v, ok := d.GetOkExists("description"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, descriptionProp)) { obj["description"] = descriptionProp } + endpointGlobalAccessProp, err := expandIntegrationConnectorsEndpointAttachmentEndpointGlobalAccess(d.Get("endpoint_global_access"), d, config) + if err != nil { + return err + } else if v, ok := d.GetOkExists("endpoint_global_access"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, endpointGlobalAccessProp)) { + obj["endpointGlobalAccess"] = endpointGlobalAccessProp + } labelsProp, err := expandIntegrationConnectorsEndpointAttachmentEffectiveLabels(d.Get("effective_labels"), d, config) if err != nil { return err @@ -332,6 +352,10 @@ func resourceIntegrationConnectorsEndpointAttachmentUpdate(d *schema.ResourceDat updateMask = append(updateMask, "description") } + if d.HasChange("endpoint_global_access") { + updateMask = append(updateMask, "endpointGlobalAccess") + } + if d.HasChange("effective_labels") { updateMask = append(updateMask, "labels") } @@ -489,6 +513,10 @@ func flattenIntegrationConnectorsEndpointAttachmentEndpointIp(v interface{}, d * return v } +func flattenIntegrationConnectorsEndpointAttachmentEndpointGlobalAccess(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { + return v +} + func flattenIntegrationConnectorsEndpointAttachmentTerraformLabels(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { if v == nil { return v @@ -516,6 +544,10 @@ func expandIntegrationConnectorsEndpointAttachmentServiceAttachment(v interface{ return v, nil } +func expandIntegrationConnectorsEndpointAttachmentEndpointGlobalAccess(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + return v, nil +} + func expandIntegrationConnectorsEndpointAttachmentEffectiveLabels(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (map[string]string, error) { if v == nil { return map[string]string{}, nil diff --git a/google-beta/services/integrationconnectors/resource_integration_connectors_endpoint_attachment_test.go b/google-beta/services/integrationconnectors/resource_integration_connectors_endpoint_attachment_test.go index b9f076f36b..e94c5ec4c0 100644 --- a/google-beta/services/integrationconnectors/resource_integration_connectors_endpoint_attachment_test.go +++ b/google-beta/services/integrationconnectors/resource_integration_connectors_endpoint_attachment_test.go @@ -58,6 +58,7 @@ resource "google_integration_connectors_endpoint_attachment" "sampleendpointatta labels = { foo = "bar" } + endpoint_global_access = false } `, context) } @@ -76,6 +77,7 @@ resource "google_integration_connectors_endpoint_attachment" "sampleendpointatta labels = { bar = "foo" } + endpoint_global_access = true } `, context) } diff --git a/website/docs/r/integration_connectors_endpoint_attachment.html.markdown b/website/docs/r/integration_connectors_endpoint_attachment.html.markdown index 3b52535a12..d34e1a4589 100644 --- a/website/docs/r/integration_connectors_endpoint_attachment.html.markdown +++ b/website/docs/r/integration_connectors_endpoint_attachment.html.markdown @@ -80,6 +80,10 @@ The following arguments are supported: **Note**: This field is non-authoritative, and will only manage the labels present in your configuration. Please refer to the field `effective_labels` for all of the labels present on the resource. +* `endpoint_global_access` - + (Optional) + Enable global access for endpoint attachment. + * `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used.