Skip to content

Commit

Permalink
docs: add generated snippets (#336)
Browse files Browse the repository at this point in the history
* chore: use gapic-generator-python 0.63.2
docs: add generated snippets

PiperOrigin-RevId: 427792504

Source-Link: googleapis/googleapis@55b9e1e

Source-Link: https://github.com/googleapis/googleapis-gen/commit/bf4e86b753f42cb0edb1fd51fbe840d7da0a1cde
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiYmY0ZTg2Yjc1M2Y0MmNiMGVkYjFmZDUxZmJlODQwZDdkYTBhMWNkZSJ9

* 🦉 Updates from OwlBot

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* 🦉 Updates from OwlBot

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* 🦉 Updates from OwlBot

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* 🦉 Updates from OwlBot

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* chore: use gapic-generator-python 0.63.4

chore: fix snippet region tag format
chore: fix docstring code block formatting
PiperOrigin-RevId: 430730865

Source-Link: googleapis/googleapis@ea58002

Source-Link: https://github.com/googleapis/googleapis-gen/commit/ca893ff8af25fc7fe001de1405a517d80446ecca
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiY2E4OTNmZjhhZjI1ZmM3ZmUwMDFkZTE0MDVhNTE3ZDgwNDQ2ZWNjYSJ9

* 🦉 Updates from OwlBot post-processor

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>
Co-authored-by: Bu Sun Kim <8822365+busunkim96@users.noreply.github.com>
  • Loading branch information
3 people authored Feb 26, 2022
1 parent 7e69b77 commit a16b917
Show file tree
Hide file tree
Showing 82 changed files with 5,780 additions and 0 deletions.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# -*- 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 BatchTranslateDocument
# 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-translate


# [START translate_generated_translate_v3_TranslationService_BatchTranslateDocument_async]
from google.cloud import translate_v3


async def sample_batch_translate_document():
# Create a client
client = translate_v3.TranslationServiceAsyncClient()

# Initialize request argument(s)
input_configs = translate_v3.BatchDocumentInputConfig()
input_configs.gcs_source.input_uri = "input_uri_value"

output_config = translate_v3.BatchDocumentOutputConfig()
output_config.gcs_destination.output_uri_prefix = "output_uri_prefix_value"

request = translate_v3.BatchTranslateDocumentRequest(
parent="parent_value",
source_language_code="source_language_code_value",
target_language_codes=['target_language_codes_value_1', 'target_language_codes_value_2'],
input_configs=input_configs,
output_config=output_config,
)

# Make the request
operation = client.batch_translate_document(request=request)

print("Waiting for operation to complete...")

response = await operation.result()

# Handle the response
print(response)

# [END translate_generated_translate_v3_TranslationService_BatchTranslateDocument_async]
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# -*- 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 BatchTranslateDocument
# 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-translate


# [START translate_generated_translate_v3_TranslationService_BatchTranslateDocument_sync]
from google.cloud import translate_v3


def sample_batch_translate_document():
# Create a client
client = translate_v3.TranslationServiceClient()

# Initialize request argument(s)
input_configs = translate_v3.BatchDocumentInputConfig()
input_configs.gcs_source.input_uri = "input_uri_value"

output_config = translate_v3.BatchDocumentOutputConfig()
output_config.gcs_destination.output_uri_prefix = "output_uri_prefix_value"

request = translate_v3.BatchTranslateDocumentRequest(
parent="parent_value",
source_language_code="source_language_code_value",
target_language_codes=['target_language_codes_value_1', 'target_language_codes_value_2'],
input_configs=input_configs,
output_config=output_config,
)

# Make the request
operation = client.batch_translate_document(request=request)

print("Waiting for operation to complete...")

response = operation.result()

# Handle the response
print(response)

# [END translate_generated_translate_v3_TranslationService_BatchTranslateDocument_sync]
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# -*- 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 BatchTranslateText
# 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-translate


# [START translate_generated_translate_v3_TranslationService_BatchTranslateText_async]
from google.cloud import translate_v3


async def sample_batch_translate_text():
# Create a client
client = translate_v3.TranslationServiceAsyncClient()

# Initialize request argument(s)
input_configs = translate_v3.InputConfig()
input_configs.gcs_source.input_uri = "input_uri_value"

output_config = translate_v3.OutputConfig()
output_config.gcs_destination.output_uri_prefix = "output_uri_prefix_value"

request = translate_v3.BatchTranslateTextRequest(
parent="parent_value",
source_language_code="source_language_code_value",
target_language_codes=['target_language_codes_value_1', 'target_language_codes_value_2'],
input_configs=input_configs,
output_config=output_config,
)

# Make the request
operation = client.batch_translate_text(request=request)

print("Waiting for operation to complete...")

response = await operation.result()

# Handle the response
print(response)

# [END translate_generated_translate_v3_TranslationService_BatchTranslateText_async]
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# -*- 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 BatchTranslateText
# 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-translate


# [START translate_generated_translate_v3_TranslationService_BatchTranslateText_sync]
from google.cloud import translate_v3


def sample_batch_translate_text():
# Create a client
client = translate_v3.TranslationServiceClient()

# Initialize request argument(s)
input_configs = translate_v3.InputConfig()
input_configs.gcs_source.input_uri = "input_uri_value"

output_config = translate_v3.OutputConfig()
output_config.gcs_destination.output_uri_prefix = "output_uri_prefix_value"

request = translate_v3.BatchTranslateTextRequest(
parent="parent_value",
source_language_code="source_language_code_value",
target_language_codes=['target_language_codes_value_1', 'target_language_codes_value_2'],
input_configs=input_configs,
output_config=output_config,
)

# Make the request
operation = client.batch_translate_text(request=request)

print("Waiting for operation to complete...")

response = operation.result()

# Handle the response
print(response)

# [END translate_generated_translate_v3_TranslationService_BatchTranslateText_sync]
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# -*- 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 CreateGlossary
# 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-translate


# [START translate_generated_translate_v3_TranslationService_CreateGlossary_async]
from google.cloud import translate_v3


async def sample_create_glossary():
# Create a client
client = translate_v3.TranslationServiceAsyncClient()

# Initialize request argument(s)
glossary = translate_v3.Glossary()
glossary.name = "name_value"

request = translate_v3.CreateGlossaryRequest(
parent="parent_value",
glossary=glossary,
)

# Make the request
operation = client.create_glossary(request=request)

print("Waiting for operation to complete...")

response = await operation.result()

# Handle the response
print(response)

# [END translate_generated_translate_v3_TranslationService_CreateGlossary_async]
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# -*- 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 CreateGlossary
# 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-translate


# [START translate_generated_translate_v3_TranslationService_CreateGlossary_sync]
from google.cloud import translate_v3


def sample_create_glossary():
# Create a client
client = translate_v3.TranslationServiceClient()

# Initialize request argument(s)
glossary = translate_v3.Glossary()
glossary.name = "name_value"

request = translate_v3.CreateGlossaryRequest(
parent="parent_value",
glossary=glossary,
)

# Make the request
operation = client.create_glossary(request=request)

print("Waiting for operation to complete...")

response = operation.result()

# Handle the response
print(response)

# [END translate_generated_translate_v3_TranslationService_CreateGlossary_sync]
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# -*- 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 DeleteGlossary
# 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-translate


# [START translate_generated_translate_v3_TranslationService_DeleteGlossary_async]
from google.cloud import translate_v3


async def sample_delete_glossary():
# Create a client
client = translate_v3.TranslationServiceAsyncClient()

# Initialize request argument(s)
request = translate_v3.DeleteGlossaryRequest(
name="name_value",
)

# Make the request
operation = client.delete_glossary(request=request)

print("Waiting for operation to complete...")

response = await operation.result()

# Handle the response
print(response)

# [END translate_generated_translate_v3_TranslationService_DeleteGlossary_async]
Loading

0 comments on commit a16b917

Please sign in to comment.