From fd5ce34d6c283860d98144f6ecdd3324f023ad4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CJavier?= Date: Thu, 24 Jun 2021 10:00:06 -0600 Subject: [PATCH 1/6] Including API definition for EntityType --- mmv1/products/dialogflowcx/api.yaml | 110 ++++++++++++++++++++++ mmv1/products/dialogflowcx/terraform.yaml | 19 ++++ 2 files changed, 129 insertions(+) diff --git a/mmv1/products/dialogflowcx/api.yaml b/mmv1/products/dialogflowcx/api.yaml index a931a3d97c06..18759bcb0926 100644 --- a/mmv1/products/dialogflowcx/api.yaml +++ b/mmv1/products/dialogflowcx/api.yaml @@ -111,3 +111,113 @@ objects: name: 'enableSpellCorrection' description: | Indicates if automatic spell correction is enabled in detect intent requests. + - !ruby/object:Api::Resource + name: 'EntityType' + base_url: "{{parent}}/entityTypes/" + self_link: "{{name}}" + update_verb: :PATCH + update_mask: true + description: | + Entities are extracted from user input and represent parameters that are meaningful to your application. + For example, a date range, a proper name such as a geographic location or landmark, and so on. Entities represent actionable data for your application. + references: !ruby/object:Api::Resource::ReferenceLinks + guides: + 'Official Documentation': + 'https://cloud.google.com/dialogflow/cx/docs' + api: 'https://cloud.google.com/dialogflow/cx/docs/reference/rest/v3/projects.locations.agents.entityTypes' + parameters: + - !ruby/object:Api::Type::String + name: parent + url_param_only: true + input: true + description: | + The agent to create a entity type for. + Format: projects//locations//agents/. + - !ruby/object:Api::Type::String + name: 'location' + description: | + The name of the location this entity type is located in. + required: true + input: true + url_param_only: true + - !ruby/object:Api::Type::String + name: 'languageCode' + description: | + The language of the following fields in entityType: + EntityType.entities.value + EntityType.entities.synonyms + EntityType.excluded_phrases.value + If not specified, the agent's default language is used. Many languages are supported. Note: languages must be enabled in the agent before they can be used. + input: true + url_param_only: true + properties: + - !ruby/object:Api::Type::String + name: 'name' + output: true + description: | + The unique identifier of the entity type. + Format: projects//locations//agents//entityTypes/. + - !ruby/object:Api::Type::String + name: 'displayName' + required: true + description: | + The human-readable name of the entity type, unique within the agent. + - !ruby/object:Api::Type::Enum + name: 'kind' + required: true + description: | + Indicates whether the entity type can be automatically expanded. + * KIND_MAP: Map entity types allow mapping of a group of synonyms to a canonical value. + * KIND_LIST: List entity types contain a set of entries that do not map to canonical values. However, list entity types can contain references to other entity types (with or without aliases). + * KIND_REGEXP: Regexp entity types allow to specify regular expressions in entries values. + values: + - :KIND_MAP + - :KIND_LIST + - :KIND_REGEXP + - !ruby/object:Api::Type::Enum + name: 'autoExpansionMode' + description: | + Represents kinds of entities. + * AUTO_EXPANSION_MODE_UNSPECIFIED: Auto expansion disabled for the entity. + * AUTO_EXPANSION_MODE_DEFAULT: Allows an agent to recognize values that have not been explicitly listed in the entity. + values: + - :AUTO_EXPANSION_MODE_DEFAULT + - :AUTO_EXPANSION_MODE_UNSPECIFIED + - !ruby/object:Api::Type::Array + name: 'entities' + required: true + description: | + The collection of entity entries associated with the entity type. + item_type: !ruby/object:Api::Type::NestedObject + properties: + - !ruby/object:Api::Type::String + name: 'value' + description: | + The primary value associated with this entity entry. For example, if the entity type is vegetable, the value could be scallions. + For KIND_MAP entity types: A canonical value to be used in place of synonyms. + For KIND_LIST entity types: A string that can contain references to other entity types (with or without aliases). + - !ruby/object:Api::Type::Array + name: 'synonyms' + item_type: Api::Type::String + description: | + A collection of value synonyms. For example, if the entity type is vegetable, and value is scallions, a synonym could be green onions. + For KIND_LIST entity types: This collection must contain exactly one synonym equal to value. + - !ruby/object:Api::Type::Array + name: 'excludedPhrases' + description: | + Collection of exceptional words and phrases that shouldn't be matched. For example, if you have a size entity type with entry giant(an adjective), you might consider adding giants(a noun) as an exclusion. + If the kind of entity type is KIND_MAP, then the phrases specified by entities and excluded phrases should be mutually exclusive. + item_type: !ruby/object:Api::Type::NestedObject + properties: + - !ruby/object:Api::Type::String + name: 'value' + description: | + The word or phrase to be excluded. + - !ruby/object:Api::Type::Boolean + name: 'enableFuzzyExtraction' + description: | + Enables fuzzy entity extraction during classification. + - !ruby/object:Api::Type::Boolean + name: 'redact' + description: | + Indicates whether parameters of the entity type should be redacted in log. If redaction is enabled, page parameters and intent parameters referring to the entity type will be replaced by parameter name when logging. \ No newline at end of file diff --git a/mmv1/products/dialogflowcx/terraform.yaml b/mmv1/products/dialogflowcx/terraform.yaml index 06bbe92a1ff3..9a068389574d 100644 --- a/mmv1/products/dialogflowcx/terraform.yaml +++ b/mmv1/products/dialogflowcx/terraform.yaml @@ -33,6 +33,25 @@ overrides: !ruby/object:Overrides::ResourceOverrides description: !ruby/object:Overrides::Terraform::PropertyOverride validation: !ruby/object:Provider::Terraform::Validation function: 'validation.StringLenBetween(0, 500)' + EntityType: !ruby/object:Overrides::Terraform::ResourceOverride + timeouts: !ruby/object:Api::Timeouts + insert_minutes: 40 + update_minutes: 40 + custom_code: !ruby/object:Provider::Terraform::CustomCode + custom_import: templates/terraform/custom_import/self_link_as_name_set_location.go.erb + examples: + - !ruby/object:Provider::Terraform::Examples + name: "dialogflowcx_entity_type_full" + primary_resource_id: "basic_entity_type" + vars: + agent_name: "dialogflowcx-agent" + skip_sweeper: true + id_format: "{{name}}" + import_format: ["{{name}}"] + properties: + displayName: !ruby/object:Overrides::Terraform::PropertyOverride + validation: !ruby/object:Provider::Terraform::Validation + function: 'validation.StringLenBetween(0, 64)' # This is for copying files over files: !ruby/object:Provider::Config::Files # These files have templating (ERB) code that will be run. From 557f9ffaa4c0db00c59ba37c51bb9e478039fa6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CJavier?= Date: Fri, 25 Jun 2021 09:51:30 -0600 Subject: [PATCH 2/6] Including acc tests for EntityTypes --- .../self_link_as_name_set_location.go.erb | 35 +++++ .../resource_dialogflowcx_entity_type.go.erb | 126 ++++++++++++++++++ 2 files changed, 161 insertions(+) create mode 100644 mmv1/templates/terraform/custom_import/self_link_as_name_set_location.go.erb create mode 100644 mmv1/third_party/terraform/tests/resource_dialogflowcx_entity_type.go.erb diff --git a/mmv1/templates/terraform/custom_import/self_link_as_name_set_location.go.erb b/mmv1/templates/terraform/custom_import/self_link_as_name_set_location.go.erb new file mode 100644 index 000000000000..d91c50be7d88 --- /dev/null +++ b/mmv1/templates/terraform/custom_import/self_link_as_name_set_location.go.erb @@ -0,0 +1,35 @@ + + config := meta.(*Config) + + // current import_formats cannot import fields with forward slashes in their value + if err := parseImportId([]string{"(?P.+)"}, d, config); err != nil { + return nil, err + } + + stringParts := strings.Split(d.Get("name").(string), "/") + if stringParts[2] != "locations" { + return nil, fmt.Errorf( + "Saw %s when the name is expected to contains location %s", + d.Get("name"), + "projects/{{project}}/locations/{{location}}/...", + ) + } + + if err := d.Set("location", stringParts[3]); err != nil { + return nil, fmt.Errorf("Error setting location: %s", err) + } + + // Removing last 2 elements from name to set parent + parent := strings.Join(stringParts[:len(stringParts)-2],"/") + if err := d.Set("parent", parent); err != nil { + return nil, fmt.Errorf("Error setting parent, %s", err) + } + + // Replace import id for the resource id + id, err := replaceVars(d, config, "{{name}}") + if err != nil { + return nil, fmt.Errorf("Error constructing id: %s", err) + } + d.SetId(id) + + return []*schema.ResourceData{d}, nil \ No newline at end of file diff --git a/mmv1/third_party/terraform/tests/resource_dialogflowcx_entity_type.go.erb b/mmv1/third_party/terraform/tests/resource_dialogflowcx_entity_type.go.erb new file mode 100644 index 000000000000..e88fa860dbc4 --- /dev/null +++ b/mmv1/third_party/terraform/tests/resource_dialogflowcx_entity_type.go.erb @@ -0,0 +1,126 @@ +<% autogen_exception -%> +package google + +import ( + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" +) + +func TestAccDialogflowCXEntityType_update(t *testing.T) { + t.Parallel() + + context := map[string]interface{}{ + "org_id": getTestOrgFromEnv(t), + "billing_account": getTestBillingAccountFromEnv(t), + "random_suffix": randString(t, 10), + } + + vcrTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + Steps: []resource.TestStep{ + { + Config: testAccDialogflowCXEntityType_basic(context), + }, + { + ResourceName: "google_dialogflow_cx_entity_type.my_entity", + ImportState: true, + ImportStateVerify: true, + }, + { + Config: testAccDialogflowCXEntityType_full(context), + }, + { + ResourceName: "google_dialogflow_cx_entity_type.my_entity", + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + +func testAccDialogflowCXEntityType_basic(context map[string]interface{}) string { + return Nprintf(` + resource "google_service_account" "dialogflowcx_service_account" { + account_id = "tf-test-dialogflow-%{random_suffix}" + } + + resource "google_project_iam_member" "agent_create" { + role = "roles/dialogflow.admin" + member = "serviceAccount:${google_service_account.dialogflowcx_service_account.email}" + } + + resource "google_dialogflow_cx_agent" "agent_entity" { + display_name = "tf-test-%{random_suffix}" + location = "global" + default_language_code = "en" + supported_language_codes = ["fr","de","es"] + time_zone = "America/New_York" + description = "Description 1." + avatar_uri = "https://storage.cloud.google.com/dialogflow-test-host-image/cloud-logo.png" + depends_on = [google_project_iam_member.agent_create] + } + + resource "google_dialogflow_cx_entity_type" "my_entity" { + parent = google_dialogflow_cx_agent.agent_entity.id + location = google_dialogflow_cx_agent.agent_entity.location + display_name = "MyEntity" + kind = "KIND_MAP" + entities { + value = "value1" + synonyms = ["synonym1","synonym2"] + } + entities { + value = "value2" + synonyms = ["synonym3","synonym4"] + } + enable_fuzzy_extraction = false + } + `, context) +} + +func testAccDialogflowCXEntityType_full(context map[string]interface{}) string { + return Nprintf(` + resource "google_service_account" "dialogflowcx_service_account" { + account_id = "tf-test-dialogflow-%{random_suffix}" + } + + resource "google_project_iam_member" "agent_create" { + role = "roles/dialogflow.admin" + member = "serviceAccount:${google_service_account.dialogflowcx_service_account.email}" + } + + resource "google_dialogflow_cx_agent" "agent_entity" { + display_name = "tf-test-%{random_suffix}update" + location = "global" + default_language_code = "en" + supported_language_codes = ["no"] + time_zone = "Europe/London" + description = "Description 2!" + avatar_uri = "https://storage.cloud.google.com/dialogflow-test-host-image/cloud-logo-2.png" + enable_stackdriver_logging = true + enable_spell_correction = true + speech_to_text_settings { + enable_speech_adaptation = true + } + depends_on = [google_project_iam_member.agent_create] + } + + resource "google_dialogflow_cx_entity_type" "my_entity" { + parent = google_dialogflow_cx_agent.agent_entity.id + location = google_dialogflow_cx_agent.agent_entity.location + display_name = "MyEntity" + kind = "KIND_MAP" + entities { + value = "value1" + synonyms = ["synonym1","synonym2"] + } + entities { + value = "value2" + synonyms = ["synonym3","synonym4"] + } + enable_fuzzy_extraction = false + } + `, context) +} \ No newline at end of file From 8c2f4a8e7ada280f65f5164b110c909dab5f1db2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CJavier?= Date: Mon, 28 Jun 2021 08:11:00 -0600 Subject: [PATCH 3/6] Adding example for Dialogflow entity type --- .../dialogflowcx_entity_type_full.tf.erb | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 mmv1/templates/terraform/examples/dialogflowcx_entity_type_full.tf.erb diff --git a/mmv1/templates/terraform/examples/dialogflowcx_entity_type_full.tf.erb b/mmv1/templates/terraform/examples/dialogflowcx_entity_type_full.tf.erb new file mode 100644 index 000000000000..09ca1b116d28 --- /dev/null +++ b/mmv1/templates/terraform/examples/dialogflowcx_entity_type_full.tf.erb @@ -0,0 +1,31 @@ +resource "google_dialogflow_cx_agent" "agent" { + display_name = "<%= ctx[:vars]["agent_name"] %>" + location = "global" + default_language_code = "en" + supported_language_codes = ["fr","de","es"] + time_zone = "America/New_York" + description = "Example description." + avatar_uri = "https://cloud.google.com/_static/images/cloud/icons/favicons/onecloud/super_cloud.png" + enable_stackdriver_logging = true + enable_spell_correction = true + speech_to_text_settings { + enable_speech_adaptation = true + } +} + + +resource "google_dialogflow_cx_entity_type" "<%= ctx[:primary_resource_id] %>" { + parent = google_dialogflow_cx_agent.agent.id + location = google_dialogflow_cx_agent.agent.location + displayName = "My Entity" + kind = "KIND_MAP" + entities { + value = "value1" + synonyms = ["synonym1","synonym2"] + } + entities { + value = "value2" + synonyms = ["synonym3","synonym4"] + } + enable_fuzzy_extraction = false +} \ No newline at end of file From a4d1b0159079aa21f2506805671a8cf638c6585f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CJavier?= Date: Thu, 1 Jul 2021 16:10:41 -0600 Subject: [PATCH 4/6] Refactoring with suggestions made in PR for versions --- mmv1/products/dialogflowcx/api.yaml | 12 ++----- mmv1/products/dialogflowcx/terraform.yaml | 8 +++-- .../dialogflowcx_entity_type.go.erb | 18 ++++++++++ .../self_link_as_name_set_location.go.erb | 35 ------------------- .../dialogflowcx_entity_type_full.tf.erb | 3 +- ...urce_dialogflowcx_entity_type_test.go.erb} | 2 -- 6 files changed, 26 insertions(+), 52 deletions(-) create mode 100644 mmv1/templates/terraform/custom_import/dialogflowcx_entity_type.go.erb delete mode 100644 mmv1/templates/terraform/custom_import/self_link_as_name_set_location.go.erb rename mmv1/third_party/terraform/tests/{resource_dialogflowcx_entity_type.go.erb => resource_dialogflowcx_entity_type_test.go.erb} (96%) diff --git a/mmv1/products/dialogflowcx/api.yaml b/mmv1/products/dialogflowcx/api.yaml index 18759bcb0926..fbab514377ee 100644 --- a/mmv1/products/dialogflowcx/api.yaml +++ b/mmv1/products/dialogflowcx/api.yaml @@ -17,7 +17,7 @@ display_name: Dialogflow CX versions: - !ruby/object:Api::Product::Version name: ga - base_url: https://{{location}}-dialogflow.googleapis.com/v3/ + base_url: https://dialogflow.googleapis.com/v3/ scopes: - https://www.googleapis.com/auth/cloud-platform apis_required: @@ -113,8 +113,7 @@ objects: Indicates if automatic spell correction is enabled in detect intent requests. - !ruby/object:Api::Resource name: 'EntityType' - base_url: "{{parent}}/entityTypes/" - self_link: "{{name}}" + base_url: "{{parent}}/entityTypes" update_verb: :PATCH update_mask: true description: | @@ -133,13 +132,6 @@ objects: description: | The agent to create a entity type for. Format: projects//locations//agents/. - - !ruby/object:Api::Type::String - name: 'location' - description: | - The name of the location this entity type is located in. - required: true - input: true - url_param_only: true - !ruby/object:Api::Type::String name: 'languageCode' description: | diff --git a/mmv1/products/dialogflowcx/terraform.yaml b/mmv1/products/dialogflowcx/terraform.yaml index 9a068389574d..0d781bf02362 100644 --- a/mmv1/products/dialogflowcx/terraform.yaml +++ b/mmv1/products/dialogflowcx/terraform.yaml @@ -38,7 +38,7 @@ overrides: !ruby/object:Overrides::ResourceOverrides insert_minutes: 40 update_minutes: 40 custom_code: !ruby/object:Provider::Terraform::CustomCode - custom_import: templates/terraform/custom_import/self_link_as_name_set_location.go.erb + custom_import: templates/terraform/custom_import/dialogflowcx_entity_type.go.erb examples: - !ruby/object:Provider::Terraform::Examples name: "dialogflowcx_entity_type_full" @@ -46,9 +46,11 @@ overrides: !ruby/object:Overrides::ResourceOverrides vars: agent_name: "dialogflowcx-agent" skip_sweeper: true - id_format: "{{name}}" - import_format: ["{{name}}"] + id_format: "{{parent}}/entityTypes/{{name}}" + import_format: ["{{parent}}/entityTypes/{{name}}"] properties: + name: !ruby/object:Overrides::Terraform::PropertyOverride + custom_flatten: templates/terraform/custom_flatten/name_from_self_link.erb displayName: !ruby/object:Overrides::Terraform::PropertyOverride validation: !ruby/object:Provider::Terraform::Validation function: 'validation.StringLenBetween(0, 64)' diff --git a/mmv1/templates/terraform/custom_import/dialogflowcx_entity_type.go.erb b/mmv1/templates/terraform/custom_import/dialogflowcx_entity_type.go.erb new file mode 100644 index 000000000000..368f7aba4c4f --- /dev/null +++ b/mmv1/templates/terraform/custom_import/dialogflowcx_entity_type.go.erb @@ -0,0 +1,18 @@ + config := meta.(*Config) + + // current import_formats can't import fields with forward slashes in their value and parent contains slashes + if err := parseImportId([]string{ + "(?P.+)/entityTypes/(?P[^/]+)", + "(?P.+)/(?P[^/]+)", + }, d, config); err != nil { + return nil, err + } + + // Replace import id for the resource id + id, err := replaceVars(d, config, "{{parent}}/entityTypes/{{name}}") + if err != nil { + return nil, fmt.Errorf("Error constructing id: %s", err) + } + d.SetId(id) + + return []*schema.ResourceData{d}, nil \ No newline at end of file diff --git a/mmv1/templates/terraform/custom_import/self_link_as_name_set_location.go.erb b/mmv1/templates/terraform/custom_import/self_link_as_name_set_location.go.erb deleted file mode 100644 index d91c50be7d88..000000000000 --- a/mmv1/templates/terraform/custom_import/self_link_as_name_set_location.go.erb +++ /dev/null @@ -1,35 +0,0 @@ - - config := meta.(*Config) - - // current import_formats cannot import fields with forward slashes in their value - if err := parseImportId([]string{"(?P.+)"}, d, config); err != nil { - return nil, err - } - - stringParts := strings.Split(d.Get("name").(string), "/") - if stringParts[2] != "locations" { - return nil, fmt.Errorf( - "Saw %s when the name is expected to contains location %s", - d.Get("name"), - "projects/{{project}}/locations/{{location}}/...", - ) - } - - if err := d.Set("location", stringParts[3]); err != nil { - return nil, fmt.Errorf("Error setting location: %s", err) - } - - // Removing last 2 elements from name to set parent - parent := strings.Join(stringParts[:len(stringParts)-2],"/") - if err := d.Set("parent", parent); err != nil { - return nil, fmt.Errorf("Error setting parent, %s", err) - } - - // Replace import id for the resource id - id, err := replaceVars(d, config, "{{name}}") - if err != nil { - return nil, fmt.Errorf("Error constructing id: %s", err) - } - d.SetId(id) - - return []*schema.ResourceData{d}, nil \ No newline at end of file diff --git a/mmv1/templates/terraform/examples/dialogflowcx_entity_type_full.tf.erb b/mmv1/templates/terraform/examples/dialogflowcx_entity_type_full.tf.erb index 09ca1b116d28..8a5c92ae08d1 100644 --- a/mmv1/templates/terraform/examples/dialogflowcx_entity_type_full.tf.erb +++ b/mmv1/templates/terraform/examples/dialogflowcx_entity_type_full.tf.erb @@ -16,8 +16,7 @@ resource "google_dialogflow_cx_agent" "agent" { resource "google_dialogflow_cx_entity_type" "<%= ctx[:primary_resource_id] %>" { parent = google_dialogflow_cx_agent.agent.id - location = google_dialogflow_cx_agent.agent.location - displayName = "My Entity" + display_name = "MyEntity" kind = "KIND_MAP" entities { value = "value1" diff --git a/mmv1/third_party/terraform/tests/resource_dialogflowcx_entity_type.go.erb b/mmv1/third_party/terraform/tests/resource_dialogflowcx_entity_type_test.go.erb similarity index 96% rename from mmv1/third_party/terraform/tests/resource_dialogflowcx_entity_type.go.erb rename to mmv1/third_party/terraform/tests/resource_dialogflowcx_entity_type_test.go.erb index e88fa860dbc4..3c4f39cf966a 100644 --- a/mmv1/third_party/terraform/tests/resource_dialogflowcx_entity_type.go.erb +++ b/mmv1/third_party/terraform/tests/resource_dialogflowcx_entity_type_test.go.erb @@ -64,7 +64,6 @@ func testAccDialogflowCXEntityType_basic(context map[string]interface{}) string resource "google_dialogflow_cx_entity_type" "my_entity" { parent = google_dialogflow_cx_agent.agent_entity.id - location = google_dialogflow_cx_agent.agent_entity.location display_name = "MyEntity" kind = "KIND_MAP" entities { @@ -109,7 +108,6 @@ func testAccDialogflowCXEntityType_full(context map[string]interface{}) string { resource "google_dialogflow_cx_entity_type" "my_entity" { parent = google_dialogflow_cx_agent.agent_entity.id - location = google_dialogflow_cx_agent.agent_entity.location display_name = "MyEntity" kind = "KIND_MAP" entities { From cb8fbb9d72a180f0ab7dc30a3f016e090bfb1cdd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CJavier?= Date: Fri, 23 Jul 2021 18:26:35 -0600 Subject: [PATCH 5/6] Updated Entity Type tests --- ...resource_dialogflowcx_entity_type_test.go} | 44 +++++++++---------- 1 file changed, 22 insertions(+), 22 deletions(-) rename mmv1/third_party/terraform/tests/{resource_dialogflowcx_entity_type_test.go.erb => resource_dialogflowcx_entity_type_test.go} (78%) diff --git a/mmv1/third_party/terraform/tests/resource_dialogflowcx_entity_type_test.go.erb b/mmv1/third_party/terraform/tests/resource_dialogflowcx_entity_type_test.go similarity index 78% rename from mmv1/third_party/terraform/tests/resource_dialogflowcx_entity_type_test.go.erb rename to mmv1/third_party/terraform/tests/resource_dialogflowcx_entity_type_test.go index 3c4f39cf966a..de6fb58aba8b 100644 --- a/mmv1/third_party/terraform/tests/resource_dialogflowcx_entity_type_test.go.erb +++ b/mmv1/third_party/terraform/tests/resource_dialogflowcx_entity_type_test.go @@ -1,4 +1,3 @@ -<% autogen_exception -%> package google import ( @@ -24,17 +23,17 @@ func TestAccDialogflowCXEntityType_update(t *testing.T) { Config: testAccDialogflowCXEntityType_basic(context), }, { - ResourceName: "google_dialogflow_cx_entity_type.my_entity", - ImportState: true, - ImportStateVerify: true, + ResourceName: "google_dialogflow_cx_entity_type.my_entity", + ImportState: true, + ImportStateVerify: true, }, { Config: testAccDialogflowCXEntityType_full(context), }, { - ResourceName: "google_dialogflow_cx_entity_type.my_entity", - ImportState: true, - ImportStateVerify: true, + ResourceName: "google_dialogflow_cx_entity_type.my_entity", + ImportState: true, + ImportStateVerify: true, }, }, }) @@ -91,34 +90,35 @@ func testAccDialogflowCXEntityType_full(context map[string]interface{}) string { } resource "google_dialogflow_cx_agent" "agent_entity" { - display_name = "tf-test-%{random_suffix}update" + display_name = "tf-test-%{random_suffix}" location = "global" default_language_code = "en" - supported_language_codes = ["no"] - time_zone = "Europe/London" - description = "Description 2!" - avatar_uri = "https://storage.cloud.google.com/dialogflow-test-host-image/cloud-logo-2.png" - enable_stackdriver_logging = true - enable_spell_correction = true - speech_to_text_settings { - enable_speech_adaptation = true - } + supported_language_codes = ["fr","de","es"] + time_zone = "America/New_York" + description = "Description 1." + avatar_uri = "https://storage.cloud.google.com/dialogflow-test-host-image/cloud-logo.png" depends_on = [google_project_iam_member.agent_create] } resource "google_dialogflow_cx_entity_type" "my_entity" { - parent = google_dialogflow_cx_agent.agent_entity.id - display_name = "MyEntity" - kind = "KIND_MAP" + parent = google_dialogflow_cx_agent.agent_entity.id + display_name = "MyEntity" + kind = "KIND_MAP" entities { value = "value1" - synonyms = ["synonym1","synonym2"] + synonyms = ["synonym1","synonym2","synonym11","synonym22"] } entities { value = "value2" synonyms = ["synonym3","synonym4"] } enable_fuzzy_extraction = false + redact = true + auto_expansion_mode = "AUTO_EXPANSION_MODE_DEFAULT" + excluded_phrases { + value = "excluded1" + } + } `, context) -} \ No newline at end of file +} From 9f1f2b5b3ac1dd27251a8c107ee79bce6ba5ebc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CJavier?= Date: Tue, 3 Aug 2021 10:46:43 -0600 Subject: [PATCH 6/6] Fix space in tests --- .../tests/resource_dialogflowcx_entity_type_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mmv1/third_party/terraform/tests/resource_dialogflowcx_entity_type_test.go b/mmv1/third_party/terraform/tests/resource_dialogflowcx_entity_type_test.go index de6fb58aba8b..8bacdd862435 100644 --- a/mmv1/third_party/terraform/tests/resource_dialogflowcx_entity_type_test.go +++ b/mmv1/third_party/terraform/tests/resource_dialogflowcx_entity_type_test.go @@ -113,11 +113,11 @@ func testAccDialogflowCXEntityType_full(context map[string]interface{}) string { synonyms = ["synonym3","synonym4"] } enable_fuzzy_extraction = false - redact = true - auto_expansion_mode = "AUTO_EXPANSION_MODE_DEFAULT" - excluded_phrases { + redact = true + auto_expansion_mode = "AUTO_EXPANSION_MODE_DEFAULT" + excluded_phrases { value = "excluded1" - } + } } `, context)