Skip to content

Commit 0a8a6bc

Browse files
Add connector support for dialogflowcx tool beta provider (#15653)
1 parent f5690e5 commit 0a8a6bc

File tree

8 files changed

+451
-3
lines changed

8 files changed

+451
-3
lines changed

mmv1/products/dialogflowcx/Tool.yaml

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ examples:
5151
primary_resource_id: 'function_tool'
5252
vars:
5353
agent_name: 'dialogflowcx-agent-fucntion'
54+
- name: 'dialogflowcx_tool_connector'
55+
primary_resource_id: 'connector_tool'
56+
vars:
57+
agent_name: 'dialogflowcx-agent-connector'
58+
min_version: beta
5459
parameters:
5560
- name: 'parent'
5661
type: String
@@ -305,3 +310,103 @@ properties:
305310
custom_expand: 'templates/terraform/custom_expand/json_schema.tmpl'
306311
validation:
307312
function: 'validation.StringIsJSON'
313+
- name: 'connectorSpec'
314+
type: NestedObject
315+
description: |
316+
Integration connectors tool specification.
317+
This field is part of a union field `specification`: Only one of `openApiSpec`, `dataStoreSpec`, `functionSpec`, or `connectorSpec` may be set.
318+
min_version: beta
319+
properties:
320+
- name: 'name'
321+
type: String
322+
required: true
323+
description: |
324+
The full resource name of the referenced Integration Connectors Connection.
325+
Format: projects/*/locations/*/connections/*
326+
- name: 'actions'
327+
type: Array
328+
required: true
329+
description: |
330+
Actions for the tool to use.
331+
item_type:
332+
type: NestedObject
333+
properties:
334+
- name: 'inputFields'
335+
type: Array
336+
description: |
337+
Entity fields to use as inputs for the operation.
338+
If no fields are specified, all fields of the Entity will be used.
339+
item_type:
340+
type: String
341+
- name: 'outputFields'
342+
type: Array
343+
description: |
344+
Entity fields to return from the operation.
345+
If no fields are specified, all fields of the Entity will be returned.
346+
item_type:
347+
type: String
348+
- name: 'connectionActionId'
349+
type: String
350+
description: |
351+
ID of a Connection action for the tool to use. This field is part of a required union field `action_spec`.
352+
- name: 'entityOperation'
353+
type: NestedObject
354+
description: |
355+
Entity operation configuration for the tool to use. This field is part of a required union field `action_spec`.
356+
properties:
357+
- name: 'entityId'
358+
type: String
359+
description: |
360+
ID of the entity.
361+
required: true
362+
- name: 'operation'
363+
type: Enum
364+
description: |
365+
The operation to perform on the entity.
366+
enum_values:
367+
- 'LIST'
368+
- 'CREATE'
369+
- 'UPDATE'
370+
- 'DELETE'
371+
- 'GET'
372+
required: true
373+
- name: 'endUserAuthConfig'
374+
type: NestedObject
375+
description: |
376+
Integration Connectors end-user authentication configuration.
377+
If configured, the end-user authentication fields will be passed in the Integration Connectors API request
378+
and override the admin, default authentication configured for the Connection.
379+
Note: The Connection must have authentication override enabled in order to specify an EUC configuration here - otherwise,
380+
the ConnectorTool creation will fail.
381+
See: https://cloud.google.com/application-integration/docs/configure-connectors-task#configure-authentication-override properties:
382+
properties:
383+
- name: 'oauth2AuthCodeConfig'
384+
type: NestedObject
385+
description: |
386+
Oauth 2.0 Authorization Code authentication. This field is part of a union field `end_user_auth_config`. Only one of `oauth2AuthCodeConfig` or `oauth2JwtBearerConfig` may be set.
387+
properties:
388+
- name: 'oauthToken'
389+
type: String
390+
description: |
391+
Oauth token value or parameter name to pass it through.
392+
required: true
393+
- name: 'oauth2JwtBearerConfig'
394+
type: NestedObject
395+
description: |
396+
JWT Profile Oauth 2.0 Authorization Grant authentication.. This field is part of a union field `end_user_auth_config`. Only one of `oauth2AuthCodeConfig` or `oauth2JwtBearerConfig` may be set.
397+
properties:
398+
- name: 'issuer'
399+
type: String
400+
description: |
401+
Issuer value or parameter name to pass it through.
402+
required: true
403+
- name: 'subject'
404+
type: String
405+
description: |
406+
Subject value or parameter name to pass it through.
407+
required: true
408+
- name: 'clientKey'
409+
type: String
410+
description: |
411+
Client key value or parameter name to pass it through.
412+
required: true

mmv1/products/dialogflowcx/product.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,7 @@ display_name: 'Dialogflow CX'
1717
versions:
1818
- name: 'ga'
1919
base_url: 'https://{{location}}-dialogflow.googleapis.com/v3/'
20+
- name: 'beta'
21+
base_url: 'https://{{location}}-dialogflow.googleapis.com/v3beta1/'
2022
scopes:
2123
- 'https://www.googleapis.com/auth/cloud-platform'

mmv1/products/integrationconnectors/product.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,7 @@ display_name: 'Integration Connectors'
1717
versions:
1818
- name: 'ga'
1919
base_url: 'https://connectors.googleapis.com/v1/'
20+
- name: 'beta'
21+
base_url: 'https://connectors.googleapis.com/v1/'
2022
scopes:
2123
- 'https://www.googleapis.com/auth/cloud-platform'
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
resource "google_dialogflow_cx_agent" "agent" {
2+
provider = google-beta
3+
display_name = "{{index $.Vars "agent_name"}}"
4+
location = "us-central1"
5+
default_language_code = "en"
6+
time_zone = "America/New_York"
7+
description = "Example description."
8+
delete_chat_engine_on_destroy = true
9+
}
10+
11+
resource "google_integration_connectors_connection" "integration_connector" {
12+
provider = google-beta
13+
name = "terraform-df-cx-tool-connection"
14+
location = "us-central1"
15+
connector_version = "projects/${google_dialogflow_cx_agent.agent.project}/locations/global/providers/gcp/connectors/bigquery/versions/1"
16+
description = "tf created description"
17+
config_variable {
18+
key = "dataset_id"
19+
string_value = google_bigquery_dataset.bq_dataset.dataset_id
20+
}
21+
config_variable {
22+
key = "project_id"
23+
string_value = google_dialogflow_cx_agent.agent.project
24+
}
25+
config_variable {
26+
key = "support_native_data_type"
27+
boolean_value = false
28+
}
29+
config_variable {
30+
key = "proxy_enabled"
31+
boolean_value = false
32+
}
33+
34+
service_account = "${data.google_project.test_project.number}[email protected]"
35+
36+
auth_config {
37+
auth_type = "AUTH_TYPE_UNSPECIFIED"
38+
}
39+
lifecycle {
40+
ignore_changes = [
41+
auth_config,
42+
]
43+
}
44+
}
45+
46+
resource "google_bigquery_dataset" "bq_dataset" {
47+
provider = google-beta
48+
dataset_id = "terraformdatasetdfcxtool"
49+
friendly_name = "test"
50+
description = "This is a test description"
51+
location = "us-central1"
52+
delete_contents_on_destroy = true
53+
}
54+
55+
resource "google_bigquery_table" "bq_table" {
56+
provider = google-beta
57+
deletion_protection = false
58+
dataset_id = google_bigquery_dataset.bq_dataset.dataset_id
59+
table_id = "terraformdatasetdfcxtooltable"
60+
}
61+
62+
63+
resource "google_bigquery_dataset_iam_member" "connector_sa_dataset_perms" {
64+
provider = google-beta
65+
project = data.google_project.test_project.project_id
66+
dataset_id = google_bigquery_dataset.bq_dataset.dataset_id
67+
role = "roles/bigquery.dataEditor"
68+
member = "serviceAccount:${data.google_project.test_project.number}[email protected]"
69+
}
70+
71+
resource "google_dialogflow_cx_tool" "{{$.PrimaryResourceId}}" {
72+
provider = google-beta
73+
parent = google_dialogflow_cx_agent.agent.id
74+
display_name = "Example Connector Tool"
75+
description = "Example Description"
76+
77+
78+
connector_spec {
79+
name = "projects/${google_dialogflow_cx_agent.agent.project}/locations/us-central1/connections/${google_integration_connectors_connection.integration_connector.name}"
80+
actions {
81+
connection_action_id = "ExecuteCustomQuery"
82+
input_fields = ["test1"]
83+
output_fields = ["test1"]
84+
}
85+
actions {
86+
entity_operation {
87+
entity_id = google_bigquery_table.bq_table.table_id
88+
operation = "LIST"
89+
}
90+
}
91+
}
92+
}
93+
94+
data "google_project" "test_project" {
95+
provider = google-beta
96+
}

mmv1/templates/terraform/pre_create/dialogflow_set_location.go.tmpl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ if parts := regexp.MustCompile(`locations\/([^\/]*)\/`).FindStringSubmatch(d.Get
1212
}
1313

1414
// only insert location into url if the base_url in products/dialogflowcx/product.yaml is used
15-
if strings.HasPrefix(url, "https://-dialogflow.googleapis.com/v3/") {
15+
if strings.HasPrefix(url, "https://-dialogflow.googleapis.com/v3/") || strings.HasPrefix(url, "https://-dialogflow.googleapis.com/v3beta1/") {
1616
url = strings.Replace(url, "-dialogflow", fmt.Sprintf("%s-dialogflow", location), 1)
1717
}
18+

mmv1/templates/terraform/pre_create/dialogflowcx_generator.go.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ if parts := regexp.MustCompile(`locations\/([^\/]*)\/`).FindStringSubmatch(d.Get
1212
}
1313

1414
// only insert location into url if the base_url in products/dialogflowcx/product.yaml is used
15-
if strings.HasPrefix(url, "https://-dialogflow.googleapis.com/v3/") {
15+
if strings.HasPrefix(url, "https://-dialogflow.googleapis.com/v3/") || strings.HasPrefix(url, "https://-dialogflow.googleapis.com/v3beta1/") {
1616
url = strings.Replace(url,"-dialogflow",fmt.Sprintf("%s-dialogflow",location),1)
1717
}
1818

mmv1/templates/terraform/pre_create/dialogflowcx_set_location_skip_default_obj.go.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ if parts := regexp.MustCompile(`locations\/([^\/]*)\/`).FindStringSubmatch(d.Get
1212
}
1313

1414
// only insert location into url if the base_url in products/dialogflowcx/product.yaml is used
15-
if strings.HasPrefix(url, "https://-dialogflow.googleapis.com/v3/") {
15+
if strings.HasPrefix(url, "https://-dialogflow.googleapis.com/v3/") || strings.HasPrefix(url, "https://-dialogflow.googleapis.com/v3beta1/") {
1616
url = strings.Replace(url,"-dialogflow",fmt.Sprintf("%s-dialogflow",location),1)
1717
}
1818

0 commit comments

Comments
 (0)