Skip to content

Commit

Permalink
Skip default schema while datastore creation (#11311) (#19017)
Browse files Browse the repository at this point in the history
[upstream:95ad39b90ef375140e80f1d2bba8beba3a00ec03]

Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
modular-magician authored Aug 6, 2024
1 parent cff46d6 commit 9af2f7e
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 22 deletions.
3 changes: 3 additions & 0 deletions .changelog/11311.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
discoveryengine: added `skip_default_schema_creation` field to `google_data_store` resource
```
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,18 @@ config will be applied to all file types for Document parsing.`,
},
},
},
"skip_default_schema_creation": {
Type: schema.TypeBool,
Optional: true,
Description: `A boolean flag indicating whether to skip the default schema creation for
the data store. Only enable this flag if you are certain that the default
schema is incompatible with your use case.
If set to true, you must manually create a schema for the data store
before any documents can be ingested.
This flag cannot be specified if 'data_store.starting_schema' is
specified.`,
Default: false,
},
"solution_types": {
Type: schema.TypeList,
Optional: true,
Expand Down Expand Up @@ -271,7 +283,7 @@ func resourceDiscoveryEngineDataStoreCreate(d *schema.ResourceData, meta interfa
obj["documentProcessingConfig"] = documentProcessingConfigProp
}

url, err := tpgresource.ReplaceVars(d, config, "{{DiscoveryEngineBasePath}}projects/{{project}}/locations/{{location}}/collections/default_collection/dataStores?dataStoreId={{data_store_id}}&createAdvancedSiteSearch={{create_advanced_site_search}}")
url, err := tpgresource.ReplaceVars(d, config, "{{DiscoveryEngineBasePath}}projects/{{project}}/locations/{{location}}/collections/default_collection/dataStores?dataStoreId={{data_store_id}}&createAdvancedSiteSearch={{create_advanced_site_search}}&skipDefaultSchemaCreation={{skip_default_schema_creation}}")
if err != nil {
return err
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func TestAccDiscoveryEngineDataStore_discoveryengineDatastoreBasicExample(t *tes
ResourceName: "google_discovery_engine_data_store.basic",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"create_advanced_site_search", "data_store_id", "location"},
ImportStateVerifyIgnore: []string{"create_advanced_site_search", "data_store_id", "location", "skip_default_schema_creation"},
},
},
})
Expand All @@ -58,13 +58,14 @@ func TestAccDiscoveryEngineDataStore_discoveryengineDatastoreBasicExample(t *tes
func testAccDiscoveryEngineDataStore_discoveryengineDatastoreBasicExample(context map[string]interface{}) string {
return acctest.Nprintf(`
resource "google_discovery_engine_data_store" "basic" {
location = "global"
data_store_id = "tf-test-data-store-id%{random_suffix}"
display_name = "tf-test-structured-datastore"
industry_vertical = "GENERIC"
content_config = "NO_CONTENT"
solution_types = ["SOLUTION_TYPE_SEARCH"]
create_advanced_site_search = false
location = "global"
data_store_id = "tf-test-data-store-id%{random_suffix}"
display_name = "tf-test-structured-datastore"
industry_vertical = "GENERIC"
content_config = "NO_CONTENT"
solution_types = ["SOLUTION_TYPE_SEARCH"]
create_advanced_site_search = false
skip_default_schema_creation = false
}
`, context)
}
Expand All @@ -88,7 +89,7 @@ func TestAccDiscoveryEngineDataStore_discoveryengineDatastoreDocumentProcessingC
ResourceName: "google_discovery_engine_data_store.document_processing_config",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"create_advanced_site_search", "data_store_id", "location"},
ImportStateVerifyIgnore: []string{"create_advanced_site_search", "data_store_id", "location", "skip_default_schema_creation"},
},
},
})
Expand Down Expand Up @@ -138,7 +139,7 @@ func TestAccDiscoveryEngineDataStore_discoveryengineDatastoreDocumentProcessingC
ResourceName: "google_discovery_engine_data_store.document_processing_config_ocr",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"create_advanced_site_search", "data_store_id", "location"},
ImportStateVerifyIgnore: []string{"create_advanced_site_search", "data_store_id", "location", "skip_default_schema_creation"},
},
},
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
package discoveryengine_test

import (
"testing"

"github.com/hashicorp/terraform-plugin-testing/helper/resource"
"github.com/hashicorp/terraform-provider-google/google/acctest"
"testing"
)

func TestAccDiscoveryEngineDataStore_discoveryengineDatastoreBasicExample_update(t *testing.T) {
Expand All @@ -18,7 +19,6 @@ func TestAccDiscoveryEngineDataStore_discoveryengineDatastoreBasicExample_update
acctest.VcrTest(t, resource.TestCase{
PreCheck: func() { acctest.AccTestPreCheck(t) },
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
CheckDestroy: testAccCheckDiscoveryEngineDataStoreDestroyProducer(t),
Steps: []resource.TestStep{
{
Config: testAccDiscoveryEngineDataStore_discoveryengineDatastoreBasicExample_basic(context),
Expand All @@ -27,7 +27,7 @@ func TestAccDiscoveryEngineDataStore_discoveryengineDatastoreBasicExample_update
ResourceName: "google_discovery_engine_data_store.basic",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"location", "data_store_id", "create_advanced_site_search"},
ImportStateVerifyIgnore: []string{"location", "data_store_id", "create_advanced_site_search", "skip_default_schema_creation"},
},
{
Config: testAccDiscoveryEngineDataStore_discoveryengineDatastoreBasicExample_update(context),
Expand All @@ -36,7 +36,7 @@ func TestAccDiscoveryEngineDataStore_discoveryengineDatastoreBasicExample_update
ResourceName: "google_discovery_engine_data_store.basic",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"location", "data_store_id", "create_advanced_site_search"},
ImportStateVerifyIgnore: []string{"location", "data_store_id", "create_advanced_site_search", "skip_default_schema_creation"},
},
},
})
Expand Down
25 changes: 18 additions & 7 deletions website/docs/r/discovery_engine_data_store.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,14 @@ To get more information about DataStore, see:

```hcl
resource "google_discovery_engine_data_store" "basic" {
location = "global"
data_store_id = "data-store-id"
display_name = "tf-test-structured-datastore"
industry_vertical = "GENERIC"
content_config = "NO_CONTENT"
solution_types = ["SOLUTION_TYPE_SEARCH"]
create_advanced_site_search = false
location = "global"
data_store_id = "data-store-id"
display_name = "tf-test-structured-datastore"
industry_vertical = "GENERIC"
content_config = "NO_CONTENT"
solution_types = ["SOLUTION_TYPE_SEARCH"]
create_advanced_site_search = false
skip_default_schema_creation = false
}
```
<div class = "oics-button" style="float: right; margin: 0 0 -15px">
Expand Down Expand Up @@ -130,6 +131,16 @@ The following arguments are supported:
data store is not configured as site search (GENERIC vertical and
PUBLIC_WEBSITE contentConfig), this flag will be ignored.

* `skip_default_schema_creation` -
(Optional)
A boolean flag indicating whether to skip the default schema creation for
the data store. Only enable this flag if you are certain that the default
schema is incompatible with your use case.
If set to true, you must manually create a schema for the data store
before any documents can be ingested.
This flag cannot be specified if `data_store.starting_schema` is
specified.

* `project` - (Optional) The ID of the project in which the resource belongs.
If it is not provided, the provider project is used.

Expand Down

0 comments on commit 9af2f7e

Please sign in to comment.