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

Documentai Processor #6083

Merged
merged 8 commits into from
Jun 14, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
97 changes: 97 additions & 0 deletions mmv1/products/documentai/api.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# Copyright 2021 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::Product
name: DocumentAI
display_name: Essential Contacts
versions:
- !ruby/object:Api::Product::Version
name: ga
base_url: https://documentai.googleapis.com/v1/
scopes:
- https://www.googleapis.com/auth/cloud-platform
apis_required:
- !ruby/object:Api::Product::ApiReference
name: Document AI API
url: https://console.cloud.google.com/apis/api/documentai.googleapis.com/overview
objects:
- !ruby/object:Api::Resource
name: 'Processor'
create_url: 'projects/{{project}}/locations/{{location}}/processors'
self_link: '{{name}}'
base_url: '{{name}}'
input: true
references: !ruby/object:Api::Resource::ReferenceLinks
guides:
'Official Documentation':
'https://cloud.google.com/document-ai/docs/overview'
api: 'https://cloud.google.com/document-ai/docs/reference/rest/v1/projects.locations.processors'
description: |
The first-class citizen for Document AI. Each processor defines how to extract structural information from a document.
parameters:
- !ruby/object:Api::Type::String
name: location
description: |
The location of the resource.
input: true
url_param_only: true
required: true
properties:
- !ruby/object:Api::Type::String
name: 'name'
description: |
The resource name of the processor.
output: true
- !ruby/object:Api::Type::String
name: 'type'
required: true
input: true
description: |
The type of processor. For possible types see the [official list](https://cloud.google.com/document-ai/docs/reference/rest/v1/projects.locations/fetchProcessorTypes#google.cloud.documentai.v1.DocumentProcessorService.FetchProcessorTypes)
- !ruby/object:Api::Type::String
name: 'displayName'
required: true
input: true
description: |
The display name. Must be unique.
- !ruby/object:Api::Type::String
name: 'kmsKeyName'
input: true
description: |
The KMS key used for encryption/decryption in CMEK scenarios. See https://cloud.google.com/security-key-management.
- !ruby/object:Api::Resource
name: 'ProcessorDefaultVersion'
input: true
base_url: '{{processor}}'
create_url: '{{processor}}:setDefaultProcessorVersion'
create_verb: :POST
self_link: '{{processor}}'
identity:
- processor
description: |
The default version for the processor. Deleting this resource is a no-op, and does not unset the default version.
parameters:
- !ruby/object:Api::Type::String
name: 'processor'
description: |
The processor to set the version on.
required: true
input: true
properties:
- !ruby/object:Api::Type::String
name: 'version'
api_name: 'defaultProcessorVersion'
description: |
The version to set
required: true
input: true
42 changes: 42 additions & 0 deletions mmv1/products/documentai/terraform.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Copyright 2021 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:Provider::Terraform::Config
overrides: !ruby/object:Overrides::ResourceOverrides
Processor: !ruby/object:Overrides::Terraform::ResourceOverride
import_format: ["{{%name}}"]
examples:
- !ruby/object:Provider::Terraform::Examples
name: "documentai_processor"
primary_resource_id: "processor"
vars:
processor_name: "test-processor"
ProcessorDefaultVersion: !ruby/object:Overrides::Terraform::ResourceOverride
skip_delete: true
import_format: ["{{%processor}}"]
properties:
processor: !ruby/object:Overrides::Terraform::PropertyOverride
ignore_read: true
examples:
- !ruby/object:Provider::Terraform::Examples
name: "documentai_default_version"
primary_resource_id: "processor"
vars:
processor_name: "test-processor"

# This is for copying files over
files: !ruby/object:Provider::Config::Files
# These files have templating (ERB) code that will be run.
# This is usually to add licensing info, autogeneration notices, etc.
compile:
<%= lines(indent(compile('provider/terraform/product~compile.yaml'), 4)) -%>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
resource "google_document_ai_processor" "processor" {
location = "us"
display_name = "<%= ctx[:vars]['processor_name'] %>"
type = "OCR_PROCESSOR"
}

resource "google_document_ai_processor_default_version" "<%= ctx[:primary_resource_id] %>" {
processor = google_document_ai_processor.processor.id
version = "${google_document_ai_processor.processor.id}/processorVersions/pretrained-next"
}
5 changes: 5 additions & 0 deletions mmv1/templates/terraform/examples/documentai_processor.tf.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
resource "google_document_ai_processor" "<%= ctx[:primary_resource_id] %>" {
location = "us"
display_name = "<%= ctx[:vars]['processor_name'] %>"
type = "OCR_PROCESSOR"
}