diff --git a/mmv1/products/discoveryengine/SearchEngine.yaml b/mmv1/products/discoveryengine/SearchEngine.yaml new file mode 100644 index 000000000000..f653ffd152ed --- /dev/null +++ b/mmv1/products/discoveryengine/SearchEngine.yaml @@ -0,0 +1,151 @@ +# Copyright 2023 Google Inc. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +--- !ruby/object:Api::Resource +name: 'SearchEngine' +description: | + Vertex AI Search and Conversation can be used to create a search engine or a chat application by connecting it with a datastore +references: !ruby/object:Api::Resource::ReferenceLinks + guides: + 'Create a Search Engine': 'https://cloud.google.com/generative-ai-app-builder/docs/create-engine-es' + api: 'https://cloud.google.com/generative-ai-app-builder/docs/reference/rest/v1/projects.locations.collections.engines' + +base_url: 'projects/{{project}}/locations/{{location}}/collections/{{collection_id}}/engines/{{engine_id}}' +self_link: 'projects/{{project}}/locations/{{location}}/collections/{{collection_id}}/engines/{{engine_id}}' +create_url: 'projects/{{project}}/locations/{{location}}/collections/{{collection_id}}/engines?engineId={{engine_id}}' +delete_url: 'projects/{{project}}/locations/{{location}}/collections/{{collection_id}}/engines/{{engine_id}}' + +update_verb: :PATCH +update_mask: true + +autogen_async: true + +async: !ruby/object:Api::OpAsync + actions: ['create', 'delete'] + operation: !ruby/object:Api::OpAsync::Operation + base_url: '{{op_id}}' + result: !ruby/object:Api::OpAsync::Result + resource_inside_response: true + +import_format: + [ + 'projects/{{project}}/locations/{{location}}/collections/{{collection_id}}/engines/{{engine_id}}', + ] +custom_code: !ruby/object:Provider::Terraform::CustomCode + encoder: templates/terraform/encoders/discovery_engine_search_engine_hardcode_solution_type.go.erb +examples: + - !ruby/object:Provider::Terraform::Examples + name: "discoveryengine_searchengine_basic" + primary_resource_id: 'basic' + vars: + engine_id: "example-engine-id" + data_store_id: "example-datastore-id" + +parameters: + - !ruby/object:Api::Type::String + name: 'engineId' + description: | + Unique ID to use for Search Engine App. + required: true + immutable: true + url_param_only: true + - !ruby/object:Api::Type::String + name: 'collectionId' + description: | + The collection ID. + required: true + immutable: true + url_param_only: true + - !ruby/object:Api::Type::String + name: 'location' + description: | + Location. + required: true + immutable: true + url_param_only: true + +properties: + - !ruby/object:Api::Type::String + name: 'name' + description: | + The unique full resource name of the search engine. Values are of the format + `projects/{project}/locations/{location}/collections/{collection_id}/engines/{engine_id}`. + This field must be a UTF-8 encoded string with a length limit of 1024 + characters. + output: true + - !ruby/object:Api::Type::Enum + name: 'industryVertical' + description: | + The industry vertical that the engine registers. The restriction of the Engine industry vertical is based on DataStore: If unspecified, default to GENERIC. Vertical on Engine has to match vertical of the DataStore liniked to the engine. + immutable: true + values: + - :GENERIC + - :MEDIA + default_value: :GENERIC + - !ruby/object:Api::Type::String + name: 'displayName' + description: | + Required. The display name of the engine. Should be human readable. UTF-8 encoded string with limit of 1024 characters. + required: true + - !ruby/object:Api::Type::Array + name: 'dataStoreIds' + description: | + The data stores associated with this engine. For SOLUTION_TYPE_SEARCH type of engines, they can only associate with at most one data store. + required: true + immutable: true + item_type: Api::Type::String + - !ruby/object:Api::Type::Time + name: 'createTime' + description: | + Timestamp the Engine was created at. + output: true + - !ruby/object:Api::Type::Time + name: 'updateTime' + description: | + Timestamp the Engine was last updated. + output: true + - !ruby/object:Api::Type::NestedObject + name: 'searchEngineConfig' + description: | + Configurations for a Search Engine. + required: true + properties: + - !ruby/object:Api::Type::Enum + name: 'searchTier' + description: | + The search feature tier of this engine. Defaults to SearchTier.SEARCH_TIER_STANDARD if not specified. + values: + - :SEARCH_TIER_STANDARD + - :SEARCH_TIER_ENTERPRISE + default_value: :SEARCH_TIER_STANDARD + - !ruby/object:Api::Type::Array + name: 'searchAddOns' + description: | + The add-on that this search engine enables. + item_type: !ruby/object:Api::Type::Enum + name: 'searchAddOn' + description: | + The add-on that this search engine enables. + values: + - :SEARCH_ADD_ON_LLM + - !ruby/object:Api::Type::NestedObject + name: 'commonConfig' + description: | + Common config spec that specifies the metadata of the engine. + immutable: true + properties: + - !ruby/object:Api::Type::String + name: 'companyName' + description: | + The name of the company, business or entity that is associated with the engine. Setting this may help improve LLM related features.cd + immutable: true diff --git a/mmv1/templates/terraform/encoders/discovery_engine_search_engine_hardcode_solution_type.go.erb b/mmv1/templates/terraform/encoders/discovery_engine_search_engine_hardcode_solution_type.go.erb new file mode 100644 index 000000000000..fb2cf72a32af --- /dev/null +++ b/mmv1/templates/terraform/encoders/discovery_engine_search_engine_hardcode_solution_type.go.erb @@ -0,0 +1,3 @@ +// hard code solutionType to "SOLUTION_TYPE_SEARCH" for search engine resource +obj["solutionType"] = "SOLUTION_TYPE_SEARCH" +return obj, nil \ No newline at end of file diff --git a/mmv1/templates/terraform/examples/discoveryengine_searchengine_basic.tf.erb b/mmv1/templates/terraform/examples/discoveryengine_searchengine_basic.tf.erb new file mode 100644 index 000000000000..f6bb41971e17 --- /dev/null +++ b/mmv1/templates/terraform/examples/discoveryengine_searchengine_basic.tf.erb @@ -0,0 +1,18 @@ +resource "google_discovery_engine_data_store" "basic" { + location = "global" + data_store_id = "<%= ctx[:vars]['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 +} +resource "google_discovery_engine_search_engine" "basic" { + engine_id = "<%= ctx[:vars]['engine_id'] %>" + collection_id = "default_collection" + location = google_discovery_engine_data_store.basic.location + display_name = "Example Display Name" + data_store_ids = [google_discovery_engine_data_store.basic.data_store_id] + search_engine_config { + } +} diff --git a/mmv1/third_party/terraform/services/discoveryengine/resource_discovery_engine_search_engine_test.go b/mmv1/third_party/terraform/services/discoveryengine/resource_discovery_engine_search_engine_test.go new file mode 100644 index 000000000000..665032591394 --- /dev/null +++ b/mmv1/third_party/terraform/services/discoveryengine/resource_discovery_engine_search_engine_test.go @@ -0,0 +1,101 @@ +package discoveryengine_test + +import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-provider-google/google/acctest" + "testing" +) + +func TestAccDiscoveryEngineSearchEngine_discoveryengineSearchengineBasicExample_update(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: testAccCheckDiscoveryEngineSearchEngineDestroyProducer(t), + Steps: []resource.TestStep{ + { + Config: testAccDiscoveryEngineSearchEngine_discoveryengineSearchengineBasicExample_basic(context), + }, + { + ResourceName: "google_discovery_engine_search_engine.basic", + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"engine_id", "collection_id", "location"}, + }, + { + Config: testAccDiscoveryEngineSearchEngine_discoveryengineSearchengineBasicExample_update(context), + }, + { + ResourceName: "google_discovery_engine_search_engine.basic", + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"engine_id", "collection_id", "location"}, + }, + }, + }) +} + +func testAccDiscoveryEngineSearchEngine_discoveryengineSearchengineBasicExample_basic(context map[string]interface{}) string { + return acctest.Nprintf(` +resource "google_discovery_engine_data_store" "basic" { + location = "global" + data_store_id = "tf-test-example-datastore%{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 + } +resource "google_discovery_engine_search_engine" "basic" { + engine_id = "tf-test-example-engine-id%{random_suffix}" + collection_id = "default_collection" + location = google_discovery_engine_data_store.basic.location + display_name = "Example Display Name" + data_store_ids = [google_discovery_engine_data_store.basic.data_store_id] + industry_vertical = google_discovery_engine_data_store.basic.industry_vertical + common_config { + company_name = "Example Company Name" + } + search_engine_config { + search_tier = "SEARCH_TIER_ENTERPRISE" + search_add_ons = ["SEARCH_ADD_ON_LLM"] + } +} +`, context) +} + +func testAccDiscoveryEngineSearchEngine_discoveryengineSearchengineBasicExample_update(context map[string]interface{}) string { + return acctest.Nprintf(` +resource "google_discovery_engine_data_store" "basic" { + location = "global" + data_store_id = "tf-test-example-datastore%{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 + } +resource "google_discovery_engine_search_engine" "basic" { + engine_id = "tf-test-example-engine-id%{random_suffix}" + collection_id = "default_collection" + location = google_discovery_engine_data_store.basic.location + display_name = "Updated Example Display Name" + data_store_ids = [google_discovery_engine_data_store.basic.data_store_id] + industry_vertical = google_discovery_engine_data_store.basic.industry_vertical + common_config { + company_name = "Updated Example Company Name" + } + search_engine_config { + search_tier = "SEARCH_TIER_STANDARD" + search_add_ons = ["SEARCH_ADD_ON_LLM"] + } +} +`, context) +}