Skip to content

Commit

Permalink
Add a new resource TargetSite. (GoogleCloudPlatform#11669)
Browse files Browse the repository at this point in the history
  • Loading branch information
jialei-chen authored and Philip Jonany committed Nov 4, 2024
1 parent a0731f7 commit 785f363
Show file tree
Hide file tree
Showing 4 changed files with 243 additions and 0 deletions.
187 changes: 187 additions & 0 deletions mmv1/products/discoveryengine/TargetSite.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
# Copyright 2024 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: 'TargetSite'
description: |
TargetSite represents a URI pattern that the users want to confine their
search.
references: !ruby/object:Api::Resource::ReferenceLinks
api: 'https://cloud.google.com/generative-ai-app-builder/docs/reference/rest/v1/projects.locations.collections.dataStores.siteSearchEngine.targetSites'

immutable: true
base_url: 'projects/{{project}}/locations/{{location}}/collections/default_collection/dataStores/{{data_store_id}}/siteSearchEngine/targetSites'
self_link: '{{name}}'
create_url: 'projects/{{project}}/locations/{{location}}/collections/default_collection/dataStores/{{data_store_id}}/siteSearchEngine/targetSites'
delete_url: '{{name}}'
import_format:
[
'projects/{{project}}/locations/{{location}}/collections/default_collection/dataStores/{{data_store_id}}/siteSearchEngine/targetSites/{{target_site_id}}',
]

autogen_async: true
async: !ruby/object:Api::OpAsync
operation: !ruby/object:Api::OpAsync::Operation
path: "name"
base_url: "{{op_id}}"
wait_ms: 1000
timeouts: !ruby/object:Api::Timeouts
insert_minutes: 60
update_minutes: 60
delete_minutes: 60
result: !ruby/object:Api::OpAsync::Result
path: "response"
status: !ruby/object:Api::OpAsync::Status
path: "done"
complete: true
allowed:
- true
- false
error: !ruby/object:Api::OpAsync::Error
path: "error"
message: "message"

examples:
- !ruby/object:Provider::Terraform::Examples
name: "discoveryengine_targetsite_basic"
primary_resource_id: 'basic'
vars:
data_store_id: "data-store-id"
ignore_read_extra:
- 'project'
- !ruby/object:Provider::Terraform::Examples
name: "discoveryengine_targetsite_advanced"
primary_resource_id: 'advanced'
vars:
data_store_id: "data-store-id"
ignore_read_extra:
- 'project'
custom_code: !ruby/object:Provider::Terraform::CustomCode
post_create: templates/terraform/post_create/set_computed_name.erb
custom_import: templates/terraform/custom_import/discoveryengine_targetsite_set_id.go.erb
parameters:
- !ruby/object:Api::Type::String
name: 'location'
required: true
immutable: true
url_param_only: true
description: |
The geographic location where the data store should reside. The value can
only be one of "global", "us" and "eu".
- !ruby/object:Api::Type::String
name: 'dataStoreId'
required: true
immutable: true
url_param_only: true
description: |
The unique id of the data store.
- !ruby/object:Api::Type::String
name: 'targetSiteId'
output: true
immutable: true
url_param_only: true
description: |
The unique id of the target site.
properties:
- !ruby/object:Api::Type::String
name: 'name'
description: |
The unique full resource name of the target site. Values are of the format
`projects/{project}/locations/{location}/collections/{collection_id}/dataStores/{data_store_id}/siteSearchEngine/targetSites/{target_site_id}`.
This field must be a UTF-8 encoded string with a length limit of 1024
characters.
output: true
- !ruby/object:Api::Type::String
name: 'providedUriPattern'
description: |
The user provided URI pattern from which the `generated_uri_pattern` is
generated.
required: true
ignore_read: true
- !ruby/object:Api::Type::Enum
name: 'type'
description: |
The possible target site types.
values:
- :INCLUDE
- :EXCLUDE
- !ruby/object:Api::Type::Boolean
name: 'exactMatch'
description: |
If set to false, a uri_pattern is generated to include all pages whose
address contains the provided_uri_pattern. If set to true, an uri_pattern
is generated to try to be an exact match of the provided_uri_pattern or
just the specific page if the provided_uri_pattern is a specific one.
provided_uri_pattern is always normalized to generate the URI pattern to
be used by the search engine.
default_value: false
- !ruby/object:Api::Type::String
name: 'generatedUriPattern'
description: |
This is system-generated based on the `provided_uri_pattern`.
output: true
- !ruby/object:Api::Type::String
name: 'rootDomainUri'
description: |
Root domain of the `provided_uri_pattern`.
output: true
- !ruby/object:Api::Type::NestedObject
name: 'siteVerificationInfo'
description: |
Site ownership and validity verification status.
output: true
properties:
- !ruby/object:Api::Type::Enum
name: 'siteVerificationState'
description: |
Site verification state indicating the ownership and validity.
values:
- :VERIFIED
- :UNVERIFIED
- :EXEMPTED
- !ruby/object:Api::Type::Time
name: "verifyTime"
description: |
Latest site verification time.
- !ruby/object:Api::Type::Enum
name: 'indexingStatus'
description: |
The indexing status.
output: true
values:
- :PENDING
- :FAILED
- :SUCCEEDED
- :DELETING
- !ruby/object:Api::Type::Time
name: "updateTime"
description: |
The target site's last updated time.
output: true
- !ruby/object:Api::Type::NestedObject
name: 'failureReason'
description: |
Site search indexing failure reasons.
output: true
properties:
- !ruby/object:Api::Type::NestedObject
name: 'quotaFailure'
description: |
Site verification state indicating the ownership and validity.
properties:
- !ruby/object:Api::Type::Integer
name: 'totalRequiredQuota'
description: |
This number is an estimation on how much total quota this project
needs to successfully complete indexing.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
config := meta.(*transport_tpg.Config)
if err := tpgresource.ParseImportId([]string{
"^projects/(?P<project>[^/]+)/locations/(?P<location>[^/]+)/collections/default_collection/dataStores/(?P<data_store_id>[^/]+)/siteSearchEngine/targetSites/(?P<target_site_id>[^/]+)$",
}, d, config); err != nil {
return nil, err
}

// Set name based on the components
if err := d.Set("name", "projects/{{project}}/locations/{{location}}/collections/default_collection/dataStores/{{data_store_id}}/siteSearchEngine/targetSites/{{target_site_id}}"); err != nil {
return nil, fmt.Errorf("Error setting name: %s", err)
}

// Replace import id for the resource id
id, err := tpgresource.ReplaceVars(d, config, d.Get("name").(string))
if err != nil {
return nil, fmt.Errorf("Error constructing id: %s", err)
}
d.SetId(id)

return []*schema.ResourceData{d}, nil
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
resource "google_discovery_engine_target_site" "advanced" {
location = google_discovery_engine_data_store.advanced.location
data_store_id = google_discovery_engine_data_store.advanced.data_store_id
provided_uri_pattern = "http://cloud.google.com/docs/*"
type = "INCLUDE"
exact_match = false
}

resource "google_discovery_engine_data_store" "advanced" {
location = "global"
data_store_id = "<%= ctx[:vars]['data_store_id'] %>"
display_name = "tf-test-advanced-site-search-datastore"
industry_vertical = "GENERIC"
content_config = "PUBLIC_WEBSITE"
solution_types = ["SOLUTION_TYPE_SEARCH"]
create_advanced_site_search = true
skip_default_schema_creation = false
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
resource "google_discovery_engine_target_site" "basic" {
location = google_discovery_engine_data_store.basic.location
data_store_id = google_discovery_engine_data_store.basic.data_store_id
provided_uri_pattern = "http://cloud.google.com/docs/*"
type = "INCLUDE"
exact_match = false
}

resource "google_discovery_engine_data_store" "basic" {
location = "global"
data_store_id = "<%= ctx[:vars]['data_store_id'] %>"
display_name = "tf-test-basic-site-search-datastore"
industry_vertical = "GENERIC"
content_config = "PUBLIC_WEBSITE"
solution_types = ["SOLUTION_TYPE_SEARCH"]
create_advanced_site_search = false
skip_default_schema_creation = false
}

0 comments on commit 785f363

Please sign in to comment.