Skip to content

Commit 9876aaa

Browse files
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>
1 parent 3791e69 commit 9876aaa

File tree

24 files changed

+1306
-0
lines changed

24 files changed

+1306
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# -*- coding: utf-8 -*-
2+
# Copyright 2020 Google LLC
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
# Generated code. DO NOT EDIT!
17+
#
18+
# Snippet for BatchProcessDocuments
19+
# NOTE: This snippet has been automatically generated for illustrative purposes only.
20+
# It may require modifications to work in your environment.
21+
22+
# To install the latest published package dependency, execute the following:
23+
# python3 -m pip install google-cloud-documentai
24+
25+
26+
# [START documentai_generated_documentai_v1_DocumentProcessorService_BatchProcessDocuments_async]
27+
from google.cloud import documentai_v1
28+
29+
30+
async def sample_batch_process_documents():
31+
"""Snippet for batch_process_documents"""
32+
33+
# Create a client
34+
client = documentai_v1.DocumentProcessorServiceAsyncClient()
35+
36+
# Initialize request argument(s)
37+
project = "my-project-id"
38+
location = "us-central1"
39+
processor = "processor_value"
40+
name = f"projects/{project}/locations/{location}/processors/{processor}"
41+
42+
request = documentai_v1.BatchProcessRequest(
43+
name=name,
44+
)
45+
46+
# Make the request
47+
operation = client.batch_process_documents(request=request)
48+
49+
print("Waiting for operation to complete...")
50+
51+
response = await operation.result()
52+
print(response)
53+
54+
# [END documentai_generated_documentai_v1_DocumentProcessorService_BatchProcessDocuments_async]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# -*- coding: utf-8 -*-
2+
# Copyright 2020 Google LLC
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
# Generated code. DO NOT EDIT!
17+
#
18+
# Snippet for BatchProcessDocuments
19+
# NOTE: This snippet has been automatically generated for illustrative purposes only.
20+
# It may require modifications to work in your environment.
21+
22+
# To install the latest published package dependency, execute the following:
23+
# python3 -m pip install google-cloud-documentai
24+
25+
26+
# [START documentai_generated_documentai_v1_DocumentProcessorService_BatchProcessDocuments_sync]
27+
from google.cloud import documentai_v1
28+
29+
30+
def sample_batch_process_documents():
31+
"""Snippet for batch_process_documents"""
32+
33+
# Create a client
34+
client = documentai_v1.DocumentProcessorServiceClient()
35+
36+
# Initialize request argument(s)
37+
project = "my-project-id"
38+
location = "us-central1"
39+
processor = "processor_value"
40+
name = f"projects/{project}/locations/{location}/processors/{processor}"
41+
42+
request = documentai_v1.BatchProcessRequest(
43+
name=name,
44+
)
45+
46+
# Make the request
47+
operation = client.batch_process_documents(request=request)
48+
49+
print("Waiting for operation to complete...")
50+
51+
response = operation.result()
52+
print(response)
53+
54+
# [END documentai_generated_documentai_v1_DocumentProcessorService_BatchProcessDocuments_sync]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# -*- coding: utf-8 -*-
2+
# Copyright 2020 Google LLC
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
# Generated code. DO NOT EDIT!
17+
#
18+
# Snippet for ProcessDocument
19+
# NOTE: This snippet has been automatically generated for illustrative purposes only.
20+
# It may require modifications to work in your environment.
21+
22+
# To install the latest published package dependency, execute the following:
23+
# python3 -m pip install google-cloud-documentai
24+
25+
26+
# [START documentai_generated_documentai_v1_DocumentProcessorService_ProcessDocument_async]
27+
from google.cloud import documentai_v1
28+
29+
30+
async def sample_process_document():
31+
"""Snippet for process_document"""
32+
33+
# Create a client
34+
client = documentai_v1.DocumentProcessorServiceAsyncClient()
35+
36+
# Initialize request argument(s)
37+
inline_document = documentai_v1.Document()
38+
inline_document.uri = "uri_value"
39+
40+
project = "my-project-id"
41+
location = "us-central1"
42+
processor = "processor_value"
43+
name = f"projects/{project}/locations/{location}/processors/{processor}"
44+
45+
request = documentai_v1.ProcessRequest(
46+
inline_document=inline_document,
47+
name=name,
48+
)
49+
50+
# Make the request
51+
response = await client.process_document(request=request)
52+
53+
# Handle response
54+
print(response)
55+
56+
# [END documentai_generated_documentai_v1_DocumentProcessorService_ProcessDocument_async]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# -*- coding: utf-8 -*-
2+
# Copyright 2020 Google LLC
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
# Generated code. DO NOT EDIT!
17+
#
18+
# Snippet for ProcessDocument
19+
# NOTE: This snippet has been automatically generated for illustrative purposes only.
20+
# It may require modifications to work in your environment.
21+
22+
# To install the latest published package dependency, execute the following:
23+
# python3 -m pip install google-cloud-documentai
24+
25+
26+
# [START documentai_generated_documentai_v1_DocumentProcessorService_ProcessDocument_sync]
27+
from google.cloud import documentai_v1
28+
29+
30+
def sample_process_document():
31+
"""Snippet for process_document"""
32+
33+
# Create a client
34+
client = documentai_v1.DocumentProcessorServiceClient()
35+
36+
# Initialize request argument(s)
37+
inline_document = documentai_v1.Document()
38+
inline_document.uri = "uri_value"
39+
40+
project = "my-project-id"
41+
location = "us-central1"
42+
processor = "processor_value"
43+
name = f"projects/{project}/locations/{location}/processors/{processor}"
44+
45+
request = documentai_v1.ProcessRequest(
46+
inline_document=inline_document,
47+
name=name,
48+
)
49+
50+
# Make the request
51+
response = client.process_document(request=request)
52+
53+
# Handle response
54+
print(response)
55+
56+
# [END documentai_generated_documentai_v1_DocumentProcessorService_ProcessDocument_sync]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# -*- coding: utf-8 -*-
2+
# Copyright 2020 Google LLC
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
# Generated code. DO NOT EDIT!
17+
#
18+
# Snippet for ReviewDocument
19+
# NOTE: This snippet has been automatically generated for illustrative purposes only.
20+
# It may require modifications to work in your environment.
21+
22+
# To install the latest published package dependency, execute the following:
23+
# python3 -m pip install google-cloud-documentai
24+
25+
26+
# [START documentai_generated_documentai_v1_DocumentProcessorService_ReviewDocument_async]
27+
from google.cloud import documentai_v1
28+
29+
30+
async def sample_review_document():
31+
"""Snippet for review_document"""
32+
33+
# Create a client
34+
client = documentai_v1.DocumentProcessorServiceAsyncClient()
35+
36+
# Initialize request argument(s)
37+
inline_document = documentai_v1.Document()
38+
inline_document.uri = "uri_value"
39+
40+
project = "my-project-id"
41+
location = "us-central1"
42+
processor = "processor_value"
43+
human_review_config = f"projects/{project}/locations/{location}/processors/{processor}/humanReviewConfig"
44+
45+
request = documentai_v1.ReviewDocumentRequest(
46+
inline_document=inline_document,
47+
human_review_config=human_review_config,
48+
)
49+
50+
# Make the request
51+
operation = client.review_document(request=request)
52+
53+
print("Waiting for operation to complete...")
54+
55+
response = await operation.result()
56+
print(response)
57+
58+
# [END documentai_generated_documentai_v1_DocumentProcessorService_ReviewDocument_async]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# -*- coding: utf-8 -*-
2+
# Copyright 2020 Google LLC
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
# Generated code. DO NOT EDIT!
17+
#
18+
# Snippet for ReviewDocument
19+
# NOTE: This snippet has been automatically generated for illustrative purposes only.
20+
# It may require modifications to work in your environment.
21+
22+
# To install the latest published package dependency, execute the following:
23+
# python3 -m pip install google-cloud-documentai
24+
25+
26+
# [START documentai_generated_documentai_v1_DocumentProcessorService_ReviewDocument_sync]
27+
from google.cloud import documentai_v1
28+
29+
30+
def sample_review_document():
31+
"""Snippet for review_document"""
32+
33+
# Create a client
34+
client = documentai_v1.DocumentProcessorServiceClient()
35+
36+
# Initialize request argument(s)
37+
inline_document = documentai_v1.Document()
38+
inline_document.uri = "uri_value"
39+
40+
project = "my-project-id"
41+
location = "us-central1"
42+
processor = "processor_value"
43+
human_review_config = f"projects/{project}/locations/{location}/processors/{processor}/humanReviewConfig"
44+
45+
request = documentai_v1.ReviewDocumentRequest(
46+
inline_document=inline_document,
47+
human_review_config=human_review_config,
48+
)
49+
50+
# Make the request
51+
operation = client.review_document(request=request)
52+
53+
print("Waiting for operation to complete...")
54+
55+
response = operation.result()
56+
print(response)
57+
58+
# [END documentai_generated_documentai_v1_DocumentProcessorService_ReviewDocument_sync]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# -*- coding: utf-8 -*-
2+
# Copyright 2020 Google LLC
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
# Generated code. DO NOT EDIT!
17+
#
18+
# Snippet for BatchProcessDocuments
19+
# NOTE: This snippet has been automatically generated for illustrative purposes only.
20+
# It may require modifications to work in your environment.
21+
22+
# To install the latest published package dependency, execute the following:
23+
# python3 -m pip install google-cloud-documentai
24+
25+
26+
# [START documentai_generated_documentai_v1beta3_DocumentProcessorService_BatchProcessDocuments_async]
27+
from google.cloud import documentai_v1beta3
28+
29+
30+
async def sample_batch_process_documents():
31+
"""Snippet for batch_process_documents"""
32+
33+
# Create a client
34+
client = documentai_v1beta3.DocumentProcessorServiceAsyncClient()
35+
36+
# Initialize request argument(s)
37+
project = "my-project-id"
38+
location = "us-central1"
39+
processor = "processor_value"
40+
name = f"projects/{project}/locations/{location}/processors/{processor}"
41+
42+
request = documentai_v1beta3.BatchProcessRequest(
43+
name=name,
44+
)
45+
46+
# Make the request
47+
operation = client.batch_process_documents(request=request)
48+
49+
print("Waiting for operation to complete...")
50+
51+
response = await operation.result()
52+
print(response)
53+
54+
# [END documentai_generated_documentai_v1beta3_DocumentProcessorService_BatchProcessDocuments_async]

0 commit comments

Comments
 (0)