Skip to content

Commit

Permalink
updated DataStore.yaml to add 'advancedSiteSearchConfig' (#12753)
Browse files Browse the repository at this point in the history
[upstream:f796dce98ddbe2277df6a276c7e37b626919d5f4]

Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
modular-magician committed Jan 14, 2025
1 parent 8050505 commit c4d0e53
Show file tree
Hide file tree
Showing 4 changed files with 175 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .changelog/12753.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
discoveryengine: added `advanced_site_search_config` field to `google_discovery_engine_data_store` resource
```
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
40 changes: 40 additions & 0 deletions website/docs/r/discovery_engine_data_store.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,31 @@ resource "google_discovery_engine_data_store" "document_processing_config" {
}
}
```
<div class = "oics-button" style="float: right; margin: 0 0 -15px">
<a href="https://console.cloud.google.com/cloudshell/open?cloudshell_git_repo=https%3A%2F%2Fgithub.com%2Fterraform-google-modules%2Fdocs-examples.git&cloudshell_image=gcr.io%2Fcloudshell-images%2Fcloudshell%3Alatest&cloudshell_print=.%2Fmotd&cloudshell_tutorial=.%2Ftutorial.md&cloudshell_working_dir=discoveryengine_datastore_advanced_site_search_config&open_in_editor=main.tf" target="_blank">
<img alt="Open in Cloud Shell" src="//gstatic.com/cloudssh/images/open-btn.svg" style="max-height: 44px; margin: 32px auto; max-width: 100%;">
</a>
</div>
## 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

Expand Down Expand Up @@ -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.
Expand All @@ -145,6 +175,16 @@ The following arguments are supported:
If it is not provided, the provider project is used.


<a name="nested_advanced_site_search_config"></a>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.

<a name="nested_document_processing_config"></a>The `document_processing_config` block supports:

* `name` -
Expand Down

0 comments on commit c4d0e53

Please sign in to comment.