Skip to content

Commit

Permalink
Add Endpoint Attachment support for Integration Connectors (GoogleClo…
Browse files Browse the repository at this point in the history
…udPlatform#9616)

* Add EndpointAttachment support for integrationconnectors

* Update mmv1/third_party/terraform/services/integrationconnectors/resource_integration_connectors_endpoint_attachment_test.go

* Update mmv1/third_party/terraform/services/integrationconnectors/resource_integration_connectors_endpoint_attachment_test.go

---------

Co-authored-by: Sarah French <15078782+SarahFrench@users.noreply.github.com>
  • Loading branch information
balanaguharsha and SarahFrench authored Dec 18, 2023
1 parent 1fc256b commit d1c644e
Show file tree
Hide file tree
Showing 3 changed files with 195 additions and 0 deletions.
107 changes: 107 additions & 0 deletions mmv1/products/integrationconnectors/EndpointAttachment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
# 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.

---
!ruby/object:Api::Resource
name: "EndpointAttachment"
description: |
An Integration connectors Endpoint Attachment.
references: !ruby/object:Api::Resource::ReferenceLinks
guides:
"Official Documentation": "https://cloud.google.com/integration-connectors/docs/create-endpoint-attachment"
api: "https://cloud.google.com/integration-connectors/docs/reference/rest/v1/projects.locations.endpointAttachments"
base_url: projects/{{project}}/locations/{{location}}/endpointAttachments
self_link: projects/{{project}}/locations/{{location}}/endpointAttachments/{{name}}
timeouts: !ruby/object:Api::Timeouts
insert_minutes: 5
update_minutes: 5
delete_minutes: 5
create_url: projects/{{project}}/locations/{{location}}/endpointAttachments?endpointAttachmentId={{name}}
update_verb: :PATCH
update_mask: true
autogen_async: true
examples:
- !ruby/object:Provider::Terraform::Examples
name: "integration_connectors_endpoint_attachment"
primary_resource_id: "sampleendpointattachment"
vars:
endpoint_attachment_name: "test-endpoint-attachment"
async: !ruby/object:Api::OpAsync
operation: !ruby/object:Api::OpAsync::Operation
path: "name"
base_url: "{{op_id}}"
wait_ms: 1000
timeouts: !ruby/object:Api::Timeouts
insert_minutes: 5
update_minutes: 5
delete_minutes: 5
result: !ruby/object:Api::OpAsync::Result
path: "response"
resource_inside_response: true
status: !ruby/object:Api::OpAsync::Status
path: "done"
complete: true
allowed:
- "true"
- "false"
error: !ruby/object:Api::OpAsync::Error
path: "error"
message: "message"

parameters:
- !ruby/object:Api::Type::String
name: "location"
required: true
immutable: true
url_param_only: true
description: |
Location in which Endpoint Attachment needs to be created.
- !ruby/object:Api::Type::String
name: "name"
required: true
immutable: true
url_param_only: true
description: |
Name of Endpoint Attachment needs to be created.
properties:
- !ruby/object:Api::Type::Time
name: "createTime"
description: |
Time the Namespace was created in UTC.
output: true
- !ruby/object:Api::Type::Time
name: "updateTime"
description: |
Time the Namespace was updated in UTC.
output: true
- !ruby/object:Api::Type::String
name: "description"
description: |
Description of the resource.
- !ruby/object:Api::Type::KeyValueLabels
name: "labels"
description: |
Resource labels to represent user provided metadata.
- !ruby/object:Api::Type::String
name: "serviceAttachment"
required: true
immutable: true
description: |
The path of the service attachment.
- !ruby/object:Api::Type::String
name: "endpointIp"
description: |
The Private Service Connect connection endpoint ip.
output: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
resource "google_integration_connectors_endpoint_attachment" "<%= ctx[:primary_resource_id] %>" {
name = "<%= ctx[:vars]['endpoint_attachment_name'] %>"
location = "us-central1"
description = "tf created description"
service_attachment = "projects/connectors-example/regions/us-central1/serviceAttachments/test"
labels = {
foo = "bar"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
package integrationconnectors_test

import (
"testing"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"

"github.com/hashicorp/terraform-provider-google/google/acctest"
)

func TestAccIntegrationConnectorsEndpointAttachment_integrationConnectorsEndpointAttachmentExample_update(t *testing.T) {
t.Parallel()

context := map[string]interface{}{
"random_suffix": acctest.RandString(t, 10),
}

acctest.VcrTest(t, resource.TestCase{
PreCheck: func() { acctest.AccTestPreCheck(t) },
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
CheckDestroy: testAccCheckIntegrationConnectorsEndpointAttachmentDestroyProducer(t),
Steps: []resource.TestStep{
{
Config: testAccIntegrationConnectorsEndpointAttachment_integrationConnectorsEndpointAttachmentExample_full(context),
},
{
ResourceName: "google_integration_connectors_endpoint_attachment.sampleendpointattachment",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"location", "name", "labels", "terraform_labels"},
},
{
Config: testAccIntegrationConnectorsEndpointAttachment_integrationConnectorsEndpointAttachmentExample_update(context),
},
{
ResourceName: "google_integration_connectors_endpoint_attachment.sampleendpointattachment",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"location", "name", "labels", "terraform_labels"},
},
},
})
}

func testAccIntegrationConnectorsEndpointAttachment_integrationConnectorsEndpointAttachmentExample_full(context map[string]interface{}) string {
return acctest.Nprintf(`
data "google_project" "test_project" {
}
resource "google_integration_connectors_endpoint_attachment" "sampleendpointattachment" {
name = "tf-test-test-endpoint-attachment%{random_suffix}"
location = "us-central1"
description = "tf created description"
# Third party dependency, see https://github.com/GoogleCloudPlatform/magic-modules/pull/9616#discussion_r1429029155
service_attachment = "projects/connectors-example/regions/us-central1/serviceAttachments/test"
labels = {
foo = "bar"
}
}
`, context)
}

func testAccIntegrationConnectorsEndpointAttachment_integrationConnectorsEndpointAttachmentExample_update(context map[string]interface{}) string {
return acctest.Nprintf(`
data "google_project" "test_project" {
}
resource "google_integration_connectors_endpoint_attachment" "sampleendpointattachment" {
name = "tf-test-test-endpoint-attachment%{random_suffix}"
location = "us-central1"
description = "tf updated description"
# Third party dependency, see https://github.com/GoogleCloudPlatform/magic-modules/pull/9616#discussion_r1429029155
service_attachment = "projects/connectors-example/regions/us-central1/serviceAttachments/test"
labels = {
bar = "foo"
}
}
`, context)
}

0 comments on commit d1c644e

Please sign in to comment.