From c4d0e53e276916cec7639260ceeea5db51cfdcad Mon Sep 17 00:00:00 2001 From: Modular Magician Date: Tue, 14 Jan 2025 22:56:11 +0000 Subject: [PATCH] updated DataStore.yaml to add 'advancedSiteSearchConfig' (#12753) [upstream:f796dce98ddbe2277df6a276c7e37b626919d5f4] Signed-off-by: Modular Magician --- .changelog/12753.txt | 3 + .../resource_discovery_engine_data_store.go | 87 +++++++++++++++++++ ...covery_engine_data_store_generated_test.go | 45 ++++++++++ .../discovery_engine_data_store.html.markdown | 40 +++++++++ 4 files changed, 175 insertions(+) create mode 100644 .changelog/12753.txt diff --git a/.changelog/12753.txt b/.changelog/12753.txt new file mode 100644 index 0000000000..9215383abc --- /dev/null +++ b/.changelog/12753.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +discoveryengine: added `advanced_site_search_config` field to `google_discovery_engine_data_store` resource +``` \ No newline at end of file diff --git a/google-beta/services/discoveryengine/resource_discovery_engine_data_store.go b/google-beta/services/discoveryengine/resource_discovery_engine_data_store.go index 710e69aa4b..afe1c5571e 100644 --- a/google-beta/services/discoveryengine/resource_discovery_engine_data_store.go +++ b/google-beta/services/discoveryengine/resource_discovery_engine_data_store.go @@ -88,6 +88,27 @@ string with a length limit of 128 characters.`, Description: `The geographic location where the data store should reside. The value can only be one of "global", "us" and "eu".`, }, + "advanced_site_search_config": { + Type: schema.TypeList, + Optional: true, + ForceNew: true, + Description: `Configuration data for advance site search.`, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "disable_automatic_refresh": { + Type: schema.TypeBool, + Optional: true, + Description: `If set true, automatic refresh is disabled for the DataStore.`, + }, + "disable_initial_index": { + Type: schema.TypeBool, + Optional: true, + Description: `If set true, initial indexing is disabled for the DataStore.`, + }, + }, + }, + }, "create_advanced_site_search": { Type: schema.TypeBool, Optional: true, @@ -328,6 +349,12 @@ func resourceDiscoveryEngineDataStoreCreate(d *schema.ResourceData, meta interfa } else if v, ok := d.GetOkExists("content_config"); !tpgresource.IsEmptyValue(reflect.ValueOf(contentConfigProp)) && (ok || !reflect.DeepEqual(v, contentConfigProp)) { obj["contentConfig"] = contentConfigProp } + advancedSiteSearchConfigProp, err := expandDiscoveryEngineDataStoreAdvancedSiteSearchConfig(d.Get("advanced_site_search_config"), d, config) + if err != nil { + return err + } else if v, ok := d.GetOkExists("advanced_site_search_config"); !tpgresource.IsEmptyValue(reflect.ValueOf(advancedSiteSearchConfigProp)) && (ok || !reflect.DeepEqual(v, advancedSiteSearchConfigProp)) { + obj["advancedSiteSearchConfig"] = advancedSiteSearchConfigProp + } documentProcessingConfigProp, err := expandDiscoveryEngineDataStoreDocumentProcessingConfig(d.Get("document_processing_config"), d, config) if err != nil { return err @@ -451,6 +478,9 @@ func resourceDiscoveryEngineDataStoreRead(d *schema.ResourceData, meta interface if err := d.Set("content_config", flattenDiscoveryEngineDataStoreContentConfig(res["contentConfig"], d, config)); err != nil { return fmt.Errorf("Error reading DataStore: %s", err) } + if err := d.Set("advanced_site_search_config", flattenDiscoveryEngineDataStoreAdvancedSiteSearchConfig(res["advancedSiteSearchConfig"], d, config)); err != nil { + return fmt.Errorf("Error reading DataStore: %s", err) + } if err := d.Set("document_processing_config", flattenDiscoveryEngineDataStoreDocumentProcessingConfig(res["documentProcessingConfig"], d, config)); err != nil { return fmt.Errorf("Error reading DataStore: %s", err) } @@ -632,6 +662,29 @@ func flattenDiscoveryEngineDataStoreContentConfig(v interface{}, d *schema.Resou return v } +func flattenDiscoveryEngineDataStoreAdvancedSiteSearchConfig(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { + if v == nil { + return nil + } + original := v.(map[string]interface{}) + if len(original) == 0 { + return nil + } + transformed := make(map[string]interface{}) + transformed["disable_initial_index"] = + flattenDiscoveryEngineDataStoreAdvancedSiteSearchConfigDisableInitialIndex(original["disableInitialIndex"], d, config) + transformed["disable_automatic_refresh"] = + flattenDiscoveryEngineDataStoreAdvancedSiteSearchConfigDisableAutomaticRefresh(original["disableAutomaticRefresh"], d, config) + return []interface{}{transformed} +} +func flattenDiscoveryEngineDataStoreAdvancedSiteSearchConfigDisableInitialIndex(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { + return v +} + +func flattenDiscoveryEngineDataStoreAdvancedSiteSearchConfigDisableAutomaticRefresh(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { + return v +} + func flattenDiscoveryEngineDataStoreDocumentProcessingConfig(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { if v == nil { return nil @@ -821,6 +874,40 @@ func expandDiscoveryEngineDataStoreContentConfig(v interface{}, d tpgresource.Te return v, nil } +func expandDiscoveryEngineDataStoreAdvancedSiteSearchConfig(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + l := v.([]interface{}) + if len(l) == 0 || l[0] == nil { + return nil, nil + } + raw := l[0] + original := raw.(map[string]interface{}) + transformed := make(map[string]interface{}) + + transformedDisableInitialIndex, err := expandDiscoveryEngineDataStoreAdvancedSiteSearchConfigDisableInitialIndex(original["disable_initial_index"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedDisableInitialIndex); val.IsValid() && !tpgresource.IsEmptyValue(val) { + transformed["disableInitialIndex"] = transformedDisableInitialIndex + } + + transformedDisableAutomaticRefresh, err := expandDiscoveryEngineDataStoreAdvancedSiteSearchConfigDisableAutomaticRefresh(original["disable_automatic_refresh"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedDisableAutomaticRefresh); val.IsValid() && !tpgresource.IsEmptyValue(val) { + transformed["disableAutomaticRefresh"] = transformedDisableAutomaticRefresh + } + + return transformed, nil +} + +func expandDiscoveryEngineDataStoreAdvancedSiteSearchConfigDisableInitialIndex(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + return v, nil +} + +func expandDiscoveryEngineDataStoreAdvancedSiteSearchConfigDisableAutomaticRefresh(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + return v, nil +} + func expandDiscoveryEngineDataStoreDocumentProcessingConfig(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { l := v.([]interface{}) if len(l) == 0 || l[0] == nil { diff --git a/google-beta/services/discoveryengine/resource_discovery_engine_data_store_generated_test.go b/google-beta/services/discoveryengine/resource_discovery_engine_data_store_generated_test.go index 7c6befaf6b..7664e9d0ad 100644 --- a/google-beta/services/discoveryengine/resource_discovery_engine_data_store_generated_test.go +++ b/google-beta/services/discoveryengine/resource_discovery_engine_data_store_generated_test.go @@ -216,6 +216,51 @@ resource "google_discovery_engine_data_store" "document_processing_config_layout `, context) } +func TestAccDiscoveryEngineDataStore_discoveryengineDatastoreAdvancedSiteSearchConfigExample(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: testAccCheckDiscoveryEngineDataStoreDestroyProducer(t), + Steps: []resource.TestStep{ + { + Config: testAccDiscoveryEngineDataStore_discoveryengineDatastoreAdvancedSiteSearchConfigExample(context), + }, + { + ResourceName: "google_discovery_engine_data_store.advanced_site_search_config", + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"create_advanced_site_search", "data_store_id", "location", "skip_default_schema_creation"}, + }, + }, + }) +} + +func testAccDiscoveryEngineDataStore_discoveryengineDatastoreAdvancedSiteSearchConfigExample(context map[string]interface{}) string { + return acctest.Nprintf(` +resource "google_discovery_engine_data_store" "advanced_site_search_config" { + location = "global" + data_store_id = "tf-test-data-store-id%{random_suffix}" + display_name = "tf-test-advanced-site-search-config-datastore" + industry_vertical = "GENERIC" + content_config = "PUBLIC_WEBSITE" + solution_types = ["SOLUTION_TYPE_CHAT"] + create_advanced_site_search = true + skip_default_schema_creation = false + + advanced_site_search_config { + disable_initial_index = true + disable_automatic_refresh = true + } +} +`, context) +} + func testAccCheckDiscoveryEngineDataStoreDestroyProducer(t *testing.T) func(s *terraform.State) error { return func(s *terraform.State) error { for name, rs := range s.RootModule().Resources { diff --git a/website/docs/r/discovery_engine_data_store.html.markdown b/website/docs/r/discovery_engine_data_store.html.markdown index f3aa8e4e37..f6608b2b6b 100644 --- a/website/docs/r/discovery_engine_data_store.html.markdown +++ b/website/docs/r/discovery_engine_data_store.html.markdown @@ -81,6 +81,31 @@ resource "google_discovery_engine_data_store" "document_processing_config" { } } ``` + +## Example Usage - Discoveryengine Datastore Advanced Site Search Config + + +```hcl +resource "google_discovery_engine_data_store" "advanced_site_search_config" { + location = "global" + data_store_id = "data-store-id" + display_name = "tf-test-advanced-site-search-config-datastore" + industry_vertical = "GENERIC" + content_config = "PUBLIC_WEBSITE" + solution_types = ["SOLUTION_TYPE_CHAT"] + create_advanced_site_search = true + skip_default_schema_creation = false + + advanced_site_search_config { + disable_initial_index = true + disable_automatic_refresh = true + } +} +``` ## Argument Reference @@ -120,6 +145,11 @@ The following arguments are supported: The solutions that the data store enrolls. Each value may be one of: `SOLUTION_TYPE_RECOMMENDATION`, `SOLUTION_TYPE_SEARCH`, `SOLUTION_TYPE_CHAT`, `SOLUTION_TYPE_GENERATIVE_CHAT`. +* `advanced_site_search_config` - + (Optional) + Configuration data for advance site search. + Structure is [documented below](#nested_advanced_site_search_config). + * `document_processing_config` - (Optional) Configuration for Document understanding and enrichment. @@ -145,6 +175,16 @@ The following arguments are supported: If it is not provided, the provider project is used. +The `advanced_site_search_config` block supports: + +* `disable_initial_index` - + (Optional) + If set true, initial indexing is disabled for the DataStore. + +* `disable_automatic_refresh` - + (Optional) + If set true, automatic refresh is disabled for the DataStore. + The `document_processing_config` block supports: * `name` -