From ab0af69a78860b27efab4b8e2863dc34f2a978a6 Mon Sep 17 00:00:00 2001 From: Aleksandr Averbukh Date: Wed, 2 Oct 2024 18:46:25 +0200 Subject: [PATCH] Added dialogflow_agent_to_link field to the google_discovery_engine_chat_engine resource (#11889) --- mmv1/products/discoveryengine/ChatEngine.yaml | 25 ++++++++++++++-- ...t_engine_existing_dialogflow_agent.tf.tmpl | 30 +++++++++++++++++++ 2 files changed, 53 insertions(+), 2 deletions(-) create mode 100644 mmv1/templates/terraform/examples/discoveryengine_chat_engine_existing_dialogflow_agent.tf.tmpl diff --git a/mmv1/products/discoveryengine/ChatEngine.yaml b/mmv1/products/discoveryengine/ChatEngine.yaml index 2c0c12ca404d..d91385c8ba6e 100644 --- a/mmv1/products/discoveryengine/ChatEngine.yaml +++ b/mmv1/products/discoveryengine/ChatEngine.yaml @@ -50,6 +50,11 @@ examples: engine_id: 'chat-engine-id' data_store_id: 'data-store' data_store_2_id: 'data-store-2' + - name: 'discoveryengine_chat_engine_existing_dialogflow_agent' + primary_resource_id: 'primary' + vars: + engine_id: 'chat-engine-id' + data_store_id: 'data-store' parameters: - name: 'engineId' type: String @@ -99,7 +104,6 @@ properties: description: | The data stores associated with this engine. Multiple DataStores in the same Collection can be associated here. All listed DataStores must be `SOLUTION_TYPE_CHAT`. Adding or removing data stores will force recreation. required: true - immutable: true item_type: type: String min_size: 1 @@ -125,7 +129,12 @@ properties: type: NestedObject description: | The configuration to generate the Dialogflow agent that is associated to this Engine. - required: true + Exactly one of `agent_creation_config` or `dialogflow_agent_to_link` must be set. + immutable: true + ignore_read: true + exactly_one_of: + - 'chat_engine_config.0.agent_creation_config' + - 'chat_engine_config.0.dialogflow_agent_to_link' properties: - name: 'business' type: String @@ -145,6 +154,18 @@ properties: type: String description: | Agent location for Agent creation, currently supported values: global/us/eu, it needs to be the same region as the Chat Engine. + - name: 'dialogflowAgentToLink' + type: String + description: | + The resource name of an existing Dialogflow agent to link to this Chat Engine. Format: `projects//locations//agents/`. + Exactly one of `agent_creation_config` or `dialogflow_agent_to_link` must be set. + immutable: true + ignore_read: true + validation: + regex: '^projects\/[a-zA-Z0-9-]+(?:\/locations\/[a-zA-Z0-9-]+)?\/agents\/[a-zA-Z0-9-]+$' + exactly_one_of: + - 'chat_engine_config.0.agent_creation_config' + - 'chat_engine_config.0.dialogflow_agent_to_link' - name: 'commonConfig' type: NestedObject description: | diff --git a/mmv1/templates/terraform/examples/discoveryengine_chat_engine_existing_dialogflow_agent.tf.tmpl b/mmv1/templates/terraform/examples/discoveryengine_chat_engine_existing_dialogflow_agent.tf.tmpl new file mode 100644 index 000000000000..6569a5f20b36 --- /dev/null +++ b/mmv1/templates/terraform/examples/discoveryengine_chat_engine_existing_dialogflow_agent.tf.tmpl @@ -0,0 +1,30 @@ +resource "google_discovery_engine_data_store" "test_data_store" { + location = "global" + data_store_id = "{{index $.Vars "data_store_id"}}" + display_name = "Structured datastore" + industry_vertical = "GENERIC" + content_config = "NO_CONTENT" + solution_types = ["SOLUTION_TYPE_CHAT"] +} + +resource "google_dialogflow_cx_agent" "agent" { + display_name = "dialogflowcx-agent" + location = "global" + default_language_code = "en" + time_zone = "America/Los_Angeles" +} + +resource "google_discovery_engine_chat_engine" "primary" { + engine_id = "{{index $.Vars "engine_id"}}" + collection_id = "default_collection" + location = google_discovery_engine_data_store.test_data_store.location + display_name = "Chat engine" + industry_vertical = "GENERIC" + data_store_ids = [google_discovery_engine_data_store.test_data_store.data_store_id] + common_config { + company_name = "test-company" + } + chat_engine_config { + dialogflow_agent_to_link = google_dialogflow_cx_agent.agent.id + } +}