Skip to content

Commit

Permalink
chore: add generated snippets for Document AI (#245)
Browse files Browse the repository at this point in the history
* 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
gcf-owl-bot[bot] and gcf-owl-bot[bot] authored Dec 6, 2021
1 parent 3791e69 commit 9876aaa
Show file tree
Hide file tree
Showing 24 changed files with 1,306 additions and 0 deletions.
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]
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]
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]
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]
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]
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]
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]
Loading

0 comments on commit 9876aaa

Please sign in to comment.