Skip to content

Commit 5ecd69d

Browse files
Skip default schema while datastore creation (#11311) (#7900)
[upstream:95ad39b90ef375140e80f1d2bba8beba3a00ec03] Signed-off-by: Modular Magician <[email protected]>
1 parent f288db2 commit 5ecd69d

File tree

5 files changed

+49
-22
lines changed

5 files changed

+49
-22
lines changed

.changelog/11311.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
discoveryengine: added `skip_default_schema_creation` field to `google_data_store` resource
3+
```

google-beta/services/discoveryengine/resource_discovery_engine_data_store.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,18 @@ config will be applied to all file types for Document parsing.`,
193193
},
194194
},
195195
},
196+
"skip_default_schema_creation": {
197+
Type: schema.TypeBool,
198+
Optional: true,
199+
Description: `A boolean flag indicating whether to skip the default schema creation for
200+
the data store. Only enable this flag if you are certain that the default
201+
schema is incompatible with your use case.
202+
If set to true, you must manually create a schema for the data store
203+
before any documents can be ingested.
204+
This flag cannot be specified if 'data_store.starting_schema' is
205+
specified.`,
206+
Default: false,
207+
},
196208
"solution_types": {
197209
Type: schema.TypeList,
198210
Optional: true,
@@ -271,7 +283,7 @@ func resourceDiscoveryEngineDataStoreCreate(d *schema.ResourceData, meta interfa
271283
obj["documentProcessingConfig"] = documentProcessingConfigProp
272284
}
273285

274-
url, err := tpgresource.ReplaceVars(d, config, "{{DiscoveryEngineBasePath}}projects/{{project}}/locations/{{location}}/collections/default_collection/dataStores?dataStoreId={{data_store_id}}&createAdvancedSiteSearch={{create_advanced_site_search}}")
286+
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}}")
275287
if err != nil {
276288
return err
277289
}

google-beta/services/discoveryengine/resource_discovery_engine_data_store_generated_test.go

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func TestAccDiscoveryEngineDataStore_discoveryengineDatastoreBasicExample(t *tes
4949
ResourceName: "google_discovery_engine_data_store.basic",
5050
ImportState: true,
5151
ImportStateVerify: true,
52-
ImportStateVerifyIgnore: []string{"create_advanced_site_search", "data_store_id", "location"},
52+
ImportStateVerifyIgnore: []string{"create_advanced_site_search", "data_store_id", "location", "skip_default_schema_creation"},
5353
},
5454
},
5555
})
@@ -58,13 +58,14 @@ func TestAccDiscoveryEngineDataStore_discoveryengineDatastoreBasicExample(t *tes
5858
func testAccDiscoveryEngineDataStore_discoveryengineDatastoreBasicExample(context map[string]interface{}) string {
5959
return acctest.Nprintf(`
6060
resource "google_discovery_engine_data_store" "basic" {
61-
location = "global"
62-
data_store_id = "tf-test-data-store-id%{random_suffix}"
63-
display_name = "tf-test-structured-datastore"
64-
industry_vertical = "GENERIC"
65-
content_config = "NO_CONTENT"
66-
solution_types = ["SOLUTION_TYPE_SEARCH"]
67-
create_advanced_site_search = false
61+
location = "global"
62+
data_store_id = "tf-test-data-store-id%{random_suffix}"
63+
display_name = "tf-test-structured-datastore"
64+
industry_vertical = "GENERIC"
65+
content_config = "NO_CONTENT"
66+
solution_types = ["SOLUTION_TYPE_SEARCH"]
67+
create_advanced_site_search = false
68+
skip_default_schema_creation = false
6869
}
6970
`, context)
7071
}
@@ -88,7 +89,7 @@ func TestAccDiscoveryEngineDataStore_discoveryengineDatastoreDocumentProcessingC
8889
ResourceName: "google_discovery_engine_data_store.document_processing_config",
8990
ImportState: true,
9091
ImportStateVerify: true,
91-
ImportStateVerifyIgnore: []string{"create_advanced_site_search", "data_store_id", "location"},
92+
ImportStateVerifyIgnore: []string{"create_advanced_site_search", "data_store_id", "location", "skip_default_schema_creation"},
9293
},
9394
},
9495
})
@@ -138,7 +139,7 @@ func TestAccDiscoveryEngineDataStore_discoveryengineDatastoreDocumentProcessingC
138139
ResourceName: "google_discovery_engine_data_store.document_processing_config_ocr",
139140
ImportState: true,
140141
ImportStateVerify: true,
141-
ImportStateVerifyIgnore: []string{"create_advanced_site_search", "data_store_id", "location"},
142+
ImportStateVerifyIgnore: []string{"create_advanced_site_search", "data_store_id", "location", "skip_default_schema_creation"},
142143
},
143144
},
144145
})

google-beta/services/discoveryengine/resource_discovery_engine_data_store_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
package discoveryengine_test
44

55
import (
6+
"testing"
7+
68
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
79
"github.com/hashicorp/terraform-provider-google-beta/google-beta/acctest"
8-
"testing"
910
)
1011

1112
func TestAccDiscoveryEngineDataStore_discoveryengineDatastoreBasicExample_update(t *testing.T) {
@@ -18,7 +19,6 @@ func TestAccDiscoveryEngineDataStore_discoveryengineDatastoreBasicExample_update
1819
acctest.VcrTest(t, resource.TestCase{
1920
PreCheck: func() { acctest.AccTestPreCheck(t) },
2021
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
21-
CheckDestroy: testAccCheckDiscoveryEngineDataStoreDestroyProducer(t),
2222
Steps: []resource.TestStep{
2323
{
2424
Config: testAccDiscoveryEngineDataStore_discoveryengineDatastoreBasicExample_basic(context),
@@ -27,7 +27,7 @@ func TestAccDiscoveryEngineDataStore_discoveryengineDatastoreBasicExample_update
2727
ResourceName: "google_discovery_engine_data_store.basic",
2828
ImportState: true,
2929
ImportStateVerify: true,
30-
ImportStateVerifyIgnore: []string{"location", "data_store_id", "create_advanced_site_search"},
30+
ImportStateVerifyIgnore: []string{"location", "data_store_id", "create_advanced_site_search", "skip_default_schema_creation"},
3131
},
3232
{
3333
Config: testAccDiscoveryEngineDataStore_discoveryengineDatastoreBasicExample_update(context),
@@ -36,7 +36,7 @@ func TestAccDiscoveryEngineDataStore_discoveryengineDatastoreBasicExample_update
3636
ResourceName: "google_discovery_engine_data_store.basic",
3737
ImportState: true,
3838
ImportStateVerify: true,
39-
ImportStateVerifyIgnore: []string{"location", "data_store_id", "create_advanced_site_search"},
39+
ImportStateVerifyIgnore: []string{"location", "data_store_id", "create_advanced_site_search", "skip_default_schema_creation"},
4040
},
4141
},
4242
})

website/docs/r/discovery_engine_data_store.html.markdown

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,14 @@ To get more information about DataStore, see:
4141

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

134+
* `skip_default_schema_creation` -
135+
(Optional)
136+
A boolean flag indicating whether to skip the default schema creation for
137+
the data store. Only enable this flag if you are certain that the default
138+
schema is incompatible with your use case.
139+
If set to true, you must manually create a schema for the data store
140+
before any documents can be ingested.
141+
This flag cannot be specified if `data_store.starting_schema` is
142+
specified.
143+
133144
* `project` - (Optional) The ID of the project in which the resource belongs.
134145
If it is not provided, the provider project is used.
135146

0 commit comments

Comments
 (0)