-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add generated snippets for Document AI (#245)
* chore: add generated snippets for Document AI PiperOrigin-RevId: 410062505 Source-Link: googleapis/googleapis@cf65a53 Source-Link: googleapis/googleapis-gen@c99813e Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiYzk5ODEzZWVhZTFjNWFhOWE1YmRmZmM5MWI0YzdiYWQzZmIwOTNjZSJ9 * 🦉 Updates from OwlBot See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
- Loading branch information
1 parent
3791e69
commit 9876aaa
Showing
24 changed files
with
1,306 additions
and
0 deletions.
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
...entai_generated_documentai_v1_document_processor_service_batch_process_documents_async.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2020 Google LLC | ||
# | ||
# 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. | ||
# | ||
# Generated code. DO NOT EDIT! | ||
# | ||
# Snippet for BatchProcessDocuments | ||
# NOTE: This snippet has been automatically generated for illustrative purposes only. | ||
# It may require modifications to work in your environment. | ||
|
||
# To install the latest published package dependency, execute the following: | ||
# python3 -m pip install google-cloud-documentai | ||
|
||
|
||
# [START documentai_generated_documentai_v1_DocumentProcessorService_BatchProcessDocuments_async] | ||
from google.cloud import documentai_v1 | ||
|
||
|
||
async def sample_batch_process_documents(): | ||
"""Snippet for batch_process_documents""" | ||
|
||
# Create a client | ||
client = documentai_v1.DocumentProcessorServiceAsyncClient() | ||
|
||
# Initialize request argument(s) | ||
project = "my-project-id" | ||
location = "us-central1" | ||
processor = "processor_value" | ||
name = f"projects/{project}/locations/{location}/processors/{processor}" | ||
|
||
request = documentai_v1.BatchProcessRequest( | ||
name=name, | ||
) | ||
|
||
# Make the request | ||
operation = client.batch_process_documents(request=request) | ||
|
||
print("Waiting for operation to complete...") | ||
|
||
response = await operation.result() | ||
print(response) | ||
|
||
# [END documentai_generated_documentai_v1_DocumentProcessorService_BatchProcessDocuments_async] |
54 changes: 54 additions & 0 deletions
54
...mentai_generated_documentai_v1_document_processor_service_batch_process_documents_sync.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2020 Google LLC | ||
# | ||
# 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. | ||
# | ||
# Generated code. DO NOT EDIT! | ||
# | ||
# Snippet for BatchProcessDocuments | ||
# NOTE: This snippet has been automatically generated for illustrative purposes only. | ||
# It may require modifications to work in your environment. | ||
|
||
# To install the latest published package dependency, execute the following: | ||
# python3 -m pip install google-cloud-documentai | ||
|
||
|
||
# [START documentai_generated_documentai_v1_DocumentProcessorService_BatchProcessDocuments_sync] | ||
from google.cloud import documentai_v1 | ||
|
||
|
||
def sample_batch_process_documents(): | ||
"""Snippet for batch_process_documents""" | ||
|
||
# Create a client | ||
client = documentai_v1.DocumentProcessorServiceClient() | ||
|
||
# Initialize request argument(s) | ||
project = "my-project-id" | ||
location = "us-central1" | ||
processor = "processor_value" | ||
name = f"projects/{project}/locations/{location}/processors/{processor}" | ||
|
||
request = documentai_v1.BatchProcessRequest( | ||
name=name, | ||
) | ||
|
||
# Make the request | ||
operation = client.batch_process_documents(request=request) | ||
|
||
print("Waiting for operation to complete...") | ||
|
||
response = operation.result() | ||
print(response) | ||
|
||
# [END documentai_generated_documentai_v1_DocumentProcessorService_BatchProcessDocuments_sync] |
56 changes: 56 additions & 0 deletions
56
...s/documentai_generated_documentai_v1_document_processor_service_process_document_async.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2020 Google LLC | ||
# | ||
# 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. | ||
# | ||
# Generated code. DO NOT EDIT! | ||
# | ||
# Snippet for ProcessDocument | ||
# NOTE: This snippet has been automatically generated for illustrative purposes only. | ||
# It may require modifications to work in your environment. | ||
|
||
# To install the latest published package dependency, execute the following: | ||
# python3 -m pip install google-cloud-documentai | ||
|
||
|
||
# [START documentai_generated_documentai_v1_DocumentProcessorService_ProcessDocument_async] | ||
from google.cloud import documentai_v1 | ||
|
||
|
||
async def sample_process_document(): | ||
"""Snippet for process_document""" | ||
|
||
# Create a client | ||
client = documentai_v1.DocumentProcessorServiceAsyncClient() | ||
|
||
# Initialize request argument(s) | ||
inline_document = documentai_v1.Document() | ||
inline_document.uri = "uri_value" | ||
|
||
project = "my-project-id" | ||
location = "us-central1" | ||
processor = "processor_value" | ||
name = f"projects/{project}/locations/{location}/processors/{processor}" | ||
|
||
request = documentai_v1.ProcessRequest( | ||
inline_document=inline_document, | ||
name=name, | ||
) | ||
|
||
# Make the request | ||
response = await client.process_document(request=request) | ||
|
||
# Handle response | ||
print(response) | ||
|
||
# [END documentai_generated_documentai_v1_DocumentProcessorService_ProcessDocument_async] |
56 changes: 56 additions & 0 deletions
56
...es/documentai_generated_documentai_v1_document_processor_service_process_document_sync.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2020 Google LLC | ||
# | ||
# 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. | ||
# | ||
# Generated code. DO NOT EDIT! | ||
# | ||
# Snippet for ProcessDocument | ||
# NOTE: This snippet has been automatically generated for illustrative purposes only. | ||
# It may require modifications to work in your environment. | ||
|
||
# To install the latest published package dependency, execute the following: | ||
# python3 -m pip install google-cloud-documentai | ||
|
||
|
||
# [START documentai_generated_documentai_v1_DocumentProcessorService_ProcessDocument_sync] | ||
from google.cloud import documentai_v1 | ||
|
||
|
||
def sample_process_document(): | ||
"""Snippet for process_document""" | ||
|
||
# Create a client | ||
client = documentai_v1.DocumentProcessorServiceClient() | ||
|
||
# Initialize request argument(s) | ||
inline_document = documentai_v1.Document() | ||
inline_document.uri = "uri_value" | ||
|
||
project = "my-project-id" | ||
location = "us-central1" | ||
processor = "processor_value" | ||
name = f"projects/{project}/locations/{location}/processors/{processor}" | ||
|
||
request = documentai_v1.ProcessRequest( | ||
inline_document=inline_document, | ||
name=name, | ||
) | ||
|
||
# Make the request | ||
response = client.process_document(request=request) | ||
|
||
# Handle response | ||
print(response) | ||
|
||
# [END documentai_generated_documentai_v1_DocumentProcessorService_ProcessDocument_sync] |
58 changes: 58 additions & 0 deletions
58
...es/documentai_generated_documentai_v1_document_processor_service_review_document_async.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2020 Google LLC | ||
# | ||
# 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. | ||
# | ||
# Generated code. DO NOT EDIT! | ||
# | ||
# Snippet for ReviewDocument | ||
# NOTE: This snippet has been automatically generated for illustrative purposes only. | ||
# It may require modifications to work in your environment. | ||
|
||
# To install the latest published package dependency, execute the following: | ||
# python3 -m pip install google-cloud-documentai | ||
|
||
|
||
# [START documentai_generated_documentai_v1_DocumentProcessorService_ReviewDocument_async] | ||
from google.cloud import documentai_v1 | ||
|
||
|
||
async def sample_review_document(): | ||
"""Snippet for review_document""" | ||
|
||
# Create a client | ||
client = documentai_v1.DocumentProcessorServiceAsyncClient() | ||
|
||
# Initialize request argument(s) | ||
inline_document = documentai_v1.Document() | ||
inline_document.uri = "uri_value" | ||
|
||
project = "my-project-id" | ||
location = "us-central1" | ||
processor = "processor_value" | ||
human_review_config = f"projects/{project}/locations/{location}/processors/{processor}/humanReviewConfig" | ||
|
||
request = documentai_v1.ReviewDocumentRequest( | ||
inline_document=inline_document, | ||
human_review_config=human_review_config, | ||
) | ||
|
||
# Make the request | ||
operation = client.review_document(request=request) | ||
|
||
print("Waiting for operation to complete...") | ||
|
||
response = await operation.result() | ||
print(response) | ||
|
||
# [END documentai_generated_documentai_v1_DocumentProcessorService_ReviewDocument_async] |
58 changes: 58 additions & 0 deletions
58
...les/documentai_generated_documentai_v1_document_processor_service_review_document_sync.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2020 Google LLC | ||
# | ||
# 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. | ||
# | ||
# Generated code. DO NOT EDIT! | ||
# | ||
# Snippet for ReviewDocument | ||
# NOTE: This snippet has been automatically generated for illustrative purposes only. | ||
# It may require modifications to work in your environment. | ||
|
||
# To install the latest published package dependency, execute the following: | ||
# python3 -m pip install google-cloud-documentai | ||
|
||
|
||
# [START documentai_generated_documentai_v1_DocumentProcessorService_ReviewDocument_sync] | ||
from google.cloud import documentai_v1 | ||
|
||
|
||
def sample_review_document(): | ||
"""Snippet for review_document""" | ||
|
||
# Create a client | ||
client = documentai_v1.DocumentProcessorServiceClient() | ||
|
||
# Initialize request argument(s) | ||
inline_document = documentai_v1.Document() | ||
inline_document.uri = "uri_value" | ||
|
||
project = "my-project-id" | ||
location = "us-central1" | ||
processor = "processor_value" | ||
human_review_config = f"projects/{project}/locations/{location}/processors/{processor}/humanReviewConfig" | ||
|
||
request = documentai_v1.ReviewDocumentRequest( | ||
inline_document=inline_document, | ||
human_review_config=human_review_config, | ||
) | ||
|
||
# Make the request | ||
operation = client.review_document(request=request) | ||
|
||
print("Waiting for operation to complete...") | ||
|
||
response = operation.result() | ||
print(response) | ||
|
||
# [END documentai_generated_documentai_v1_DocumentProcessorService_ReviewDocument_sync] |
54 changes: 54 additions & 0 deletions
54
..._generated_documentai_v1beta3_document_processor_service_batch_process_documents_async.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2020 Google LLC | ||
# | ||
# 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. | ||
# | ||
# Generated code. DO NOT EDIT! | ||
# | ||
# Snippet for BatchProcessDocuments | ||
# NOTE: This snippet has been automatically generated for illustrative purposes only. | ||
# It may require modifications to work in your environment. | ||
|
||
# To install the latest published package dependency, execute the following: | ||
# python3 -m pip install google-cloud-documentai | ||
|
||
|
||
# [START documentai_generated_documentai_v1beta3_DocumentProcessorService_BatchProcessDocuments_async] | ||
from google.cloud import documentai_v1beta3 | ||
|
||
|
||
async def sample_batch_process_documents(): | ||
"""Snippet for batch_process_documents""" | ||
|
||
# Create a client | ||
client = documentai_v1beta3.DocumentProcessorServiceAsyncClient() | ||
|
||
# Initialize request argument(s) | ||
project = "my-project-id" | ||
location = "us-central1" | ||
processor = "processor_value" | ||
name = f"projects/{project}/locations/{location}/processors/{processor}" | ||
|
||
request = documentai_v1beta3.BatchProcessRequest( | ||
name=name, | ||
) | ||
|
||
# Make the request | ||
operation = client.batch_process_documents(request=request) | ||
|
||
print("Waiting for operation to complete...") | ||
|
||
response = await operation.result() | ||
print(response) | ||
|
||
# [END documentai_generated_documentai_v1beta3_DocumentProcessorService_BatchProcessDocuments_async] |
Oops, something went wrong.