From 382850120422645b38d6a2c0c058bf424af11a9f Mon Sep 17 00:00:00 2001 From: Sam Levenick Date: Fri, 29 May 2026 13:21:15 -0700 Subject: [PATCH 1/2] Add SchemaVersion and test --- mmv1/products/documentai/SchemaVersion.yaml | 139 ++++++++++++++++++ .../documentai_schema_version.tf.tmpl | 21 +++ 2 files changed, 160 insertions(+) create mode 100644 mmv1/products/documentai/SchemaVersion.yaml create mode 100644 mmv1/templates/terraform/samples/services/documentai/documentai_schema_version.tf.tmpl diff --git a/mmv1/products/documentai/SchemaVersion.yaml b/mmv1/products/documentai/SchemaVersion.yaml new file mode 100644 index 000000000000..e8fdd17dccf0 --- /dev/null +++ b/mmv1/products/documentai/SchemaVersion.yaml @@ -0,0 +1,139 @@ +# Copyright 2026 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. + +--- +name: SchemaVersion +description: SchemaVersion is a version of the Schema which is created in SchemaGroup. +base_url: 'projects/{{project}}/locations/{{location}}/schemas/{{schema_id}}/schemaVersions' +immutable: true +self_link: 'projects/{{project}}/locations/{{location}}/schemas/{{schema_id}}/schemaVersions/{{name}}' +create_url: 'projects/{{project}}/locations/{{location}}/schemas/{{schema_id}}/schemaVersions' +import_format: + - 'projects/{{project}}/locations/{{location}}/schemas/{{schema_id}}/schemaVersions/{{name}}' +autogen_status: U2NoZW1hVmVyc2lvbg== +samples: + - name: documentai_schema_version + primary_resource_id: schema_version + steps: + - name: documentai_schema_version + vars: + schema_display_name: test-schema + version_display_name: my-schema-version +parameters: + - name: location + type: String + required: true + description: The location of the resource. + immutable: true + url_param_only: true + - name: schema_id + type: String + required: true + description: The parent schema scope. + immutable: true + url_param_only: true + diff_suppress_func: 'tpgresource.CompareSelfLinkOrResourceName' +properties: + - name: name + type: String + description: The resource name of the SchemaVersion. + output: true + custom_flatten: 'templates/terraform/custom_flatten/name_from_self_link.tmpl' + - name: displayName + type: String + description: The user-defined name of the SchemaVersion. + required: true + - name: labels + type: KeyValueLabels + description: The Google Cloud labels for the SchemaVersion. + - name: createTime + type: Time + description: The time when the SchemaVersion was created. + output: true + - name: schema + type: NestedObject + required: true + description: The schema defines the output of the processed document by a processor. + properties: + - name: description + type: String + description: Description of the schema. + - name: displayName + type: String + description: Display name to show users. + - name: documentPrompt + type: String + description: Document level prompt provided by the user. + - name: entityTypes + type: Array + description: Entity types of the schema. + item_type: + type: NestedObject + properties: + - name: baseTypes + type: Array + description: The entity type that this type is derived from. + item_type: + type: String + - name: displayName + type: String + description: User defined name for the type. + - name: enumValues + type: NestedObject + description: Defines the a list of enum values. + properties: + - name: values + type: Array + description: The individual values that this enum values type can include. + item_type: + type: String + - name: name + type: String + description: Name of the type. + - name: properties + type: Array + description: Description the nested structure, or composition of an entity. + item_type: + type: NestedObject + properties: + - name: displayName + type: String + description: User defined name for the property. + - name: method + type: String + description: Specifies how the entity value is obtained. + - name: name + type: String + description: The name of the property. + - name: occurrenceType + type: String + description: Occurrence type limits the number of instances an entity type appears. + - name: valueType + type: String + description: A reference to the value type of the property. + - name: metadata + type: NestedObject + description: Metadata for global schema behavior. + properties: + - name: documentAllowMultipleLabels + type: Boolean + description: If true, there can be multiple document annotations. + - name: documentSplitter + type: Boolean + description: If true, a document entity type can be applied to subdocument. + - name: prefixedNamingOnProperties + type: Boolean + description: If set, all the nested entities must be prefixed. + - name: skipNamingValidation + type: Boolean + description: If set, this will skip the naming format validation. diff --git a/mmv1/templates/terraform/samples/services/documentai/documentai_schema_version.tf.tmpl b/mmv1/templates/terraform/samples/services/documentai/documentai_schema_version.tf.tmpl new file mode 100644 index 000000000000..74de95618f49 --- /dev/null +++ b/mmv1/templates/terraform/samples/services/documentai/documentai_schema_version.tf.tmpl @@ -0,0 +1,21 @@ +resource "google_document_ai_schema" "schema" { + location = "us" + display_name = "{{index $.Vars "schema_display_name"}}" +} + +resource "google_document_ai_schema_version" "{{$.PrimaryResourceId}}" { + schema_id = google_document_ai_schema.schema.name + location = "us" + + display_name = "{{index $.Vars "version_display_name"}}" + + schema { + display_name = "Schema" + + entity_types { + name = "custom_entity" + display_name = "Custom Entity" + base_types = ["document"] + } + } +} From ed410ef16f1e2cd4fbfec75f3cfd410366ac51bb Mon Sep 17 00:00:00 2001 From: Sam Levenick Date: Fri, 29 May 2026 16:01:45 -0700 Subject: [PATCH 2/2] Add more fields to the test --- .../documentai_schema_version.tf.tmpl | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/mmv1/templates/terraform/samples/services/documentai/documentai_schema_version.tf.tmpl b/mmv1/templates/terraform/samples/services/documentai/documentai_schema_version.tf.tmpl index 74de95618f49..95d6982cb6ad 100644 --- a/mmv1/templates/terraform/samples/services/documentai/documentai_schema_version.tf.tmpl +++ b/mmv1/templates/terraform/samples/services/documentai/documentai_schema_version.tf.tmpl @@ -9,13 +9,35 @@ resource "google_document_ai_schema_version" "{{$.PrimaryResourceId}}" { display_name = "{{index $.Vars "version_display_name"}}" + labels = { + "tag1" = "value1" + "tag2" = "value2" + } + schema { - display_name = "Schema" + display_name = "Schema" + description = "A schema version description" + document_prompt = "Document level prompt string" entity_types { name = "custom_entity" display_name = "Custom Entity" base_types = ["document"] + + properties { + name = "custom_property" + display_name = "Custom Property" + value_type = "string" + occurrence_type = "OPTIONAL_ONCE" + method = "EXTRACT" + } + } + + metadata { + document_allow_multiple_labels = true + document_splitter = false + prefixed_naming_on_properties = true + skip_naming_validation = false } } }