Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add schema resource #11018

Merged
merged 14 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
101 changes: 101 additions & 0 deletions mmv1/products/discoveryengine/Schema.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# 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: 'Schema'
description: |
Schema defines the structure and layout of a type of document data.
references: !ruby/object:Api::Resource::ReferenceLinks
guides:
'Provide a schema for your data store': 'https://cloud.google.com/generative-ai-app-builder/docs/provide-schema'
api: 'https://cloud.google.com/generative-ai-app-builder/docs/reference/rest/v1/projects.locations.collections.dataStores.schemas'

base_url: 'projects/{{project}}/locations/{{location}}/collections/default_collection/dataStores/{{data_store_id}}/schemas'
self_link: 'projects/{{project}}/locations/{{location}}/collections/default_collection/dataStores/{{data_store_id}}/schemas/{{schema_id}}'
create_url: 'projects/{{project}}/locations/{{location}}/collections/default_collection/dataStores/{{data_store_id}}/schemas?schemaId={{schema_id}}'
update_verb: :PATCH
update_mask: true
zli82016 marked this conversation as resolved.
Show resolved Hide resolved
delete_url: 'projects/{{project}}/locations/{{location}}/collections/default_collection/dataStores/{{data_store_id}}/schemas/{{schema_id}}'
import_format:
[
'projects/{{project}}/locations/{{location}}/collections/default_collection/dataStores/{{data_store_id}}/schemas/{{schema_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_schema_basic"
primary_resource_id: 'basic'
primary_resource_name:
'fmt.Sprintf("tf_test_schema%s", context["random_suffix"])'
zli82016 marked this conversation as resolved.
Show resolved Hide resolved
vars:
data_store_id: "data-store-id"
schema_id: "schema-id"
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: 'schemaId'
required: true
immutable: true
url_param_only: true
description: |
The unique id of the schema.

properties:
- !ruby/object:Api::Type::String
name: 'name'
description: |
The unique full resource name of the schema. Values are of the format
`projects/{project}/locations/{location}/collections/{collection_id}/dataStores/{data_store_id}/schemas/{schema_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: 'jsonSchema'
zli82016 marked this conversation as resolved.
Show resolved Hide resolved
zli82016 marked this conversation as resolved.
Show resolved Hide resolved
description: |
The JSON representation of the schema.
zli82016 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
resource "google_discovery_engine_schema" "basic" {
location = google_discovery_engine_data_store.basic.location
data_store_id = google_discovery_engine_data_store.basic.data_store_id
schema_id = "<%= ctx[:vars]['schema_id'] %>"
json_schema = "{\"$schema\":\"https://json-schema.org/draft/2020-12/schema\",\"date_detection\":true,\"type\":\"object\",\"geolocation_detection\":true}"
zli82016 marked this conversation as resolved.
Show resolved Hide resolved
}

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
skip_default_schema_creation = true
}