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: googleapis/googleapis-gen@bf4e86b
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: googleapis/googleapis-gen@ca893ff
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 <[email protected]>
  • Loading branch information
3 people authored Feb 26, 2022
1 parent 00b125c commit 8e6b946
Show file tree
Hide file tree
Showing 86 changed files with 6,764 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,27 @@ async def translate_text(
) -> translation_service.TranslateTextResponse:
r"""Translates input text and returns translated text.
.. code-block:: python
from google.cloud import translate_v3
def sample_translate_text():
# Create a client
client = translate_v3.TranslationServiceClient()
# Initialize request argument(s)
request = translate_v3.TranslateTextRequest(
contents=['contents_value_1', 'contents_value_2'],
target_language_code="target_language_code_value",
parent="parent_value",
)
# Make the request
response = client.translate_text(request=request)
# Handle the response
print(response)
Args:
request (Union[google.cloud.translate_v3.types.TranslateTextRequest, dict]):
The request object. The request message for synchronous
Expand Down Expand Up @@ -390,6 +411,26 @@ async def detect_language(
) -> translation_service.DetectLanguageResponse:
r"""Detects the language of text within a request.
.. code-block:: python
from google.cloud import translate_v3
def sample_detect_language():
# Create a client
client = translate_v3.TranslationServiceClient()
# Initialize request argument(s)
request = translate_v3.DetectLanguageRequest(
content="content_value",
parent="parent_value",
)
# Make the request
response = client.detect_language(request=request)
# Handle the response
print(response)
Args:
request (Union[google.cloud.translate_v3.types.DetectLanguageRequest, dict]):
The request object. The request message for language
Expand Down Expand Up @@ -513,6 +554,26 @@ async def get_supported_languages(
r"""Returns a list of supported languages for
translation.
.. code-block:: python
from google.cloud import translate_v3
def sample_get_supported_languages():
# Create a client
client = translate_v3.TranslationServiceClient()
# Initialize request argument(s)
request = translate_v3.GetSupportedLanguagesRequest(
parent="parent_value",
)
# Make the request
response = client.get_supported_languages(request=request)
# Handle the response
print(response)
Args:
request (Union[google.cloud.translate_v3.types.GetSupportedLanguagesRequest, dict]):
The request object. The request message for discovering
Expand Down Expand Up @@ -638,6 +699,30 @@ async def translate_document(
) -> translation_service.TranslateDocumentResponse:
r"""Translates documents in synchronous mode.
.. code-block:: python
from google.cloud import translate_v3
def sample_translate_document():
# Create a client
client = translate_v3.TranslationServiceClient()
# Initialize request argument(s)
document_input_config = translate_v3.DocumentInputConfig()
document_input_config.content = b'content_blob'
request = translate_v3.TranslateDocumentRequest(
parent="parent_value",
target_language_code="target_language_code_value",
document_input_config=document_input_config,
)
# Make the request
response = client.translate_document(request=request)
# Handle the response
print(response)
Args:
request (Union[google.cloud.translate_v3.types.TranslateDocumentRequest, dict]):
The request object. A document translation request.
Expand Down Expand Up @@ -694,6 +779,40 @@ async def batch_translate_text(
use google.longrunning.Operation.name to poll the status
of the call.
.. code-block:: python
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)
Args:
request (Union[google.cloud.translate_v3.types.BatchTranslateTextRequest, dict]):
The request object. The batch translation request.
Expand Down Expand Up @@ -767,6 +886,40 @@ async def batch_translate_document(
google.longrunning.Operation.name to poll the status of
the call.
.. code-block:: python
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)
Args:
request (Union[google.cloud.translate_v3.types.BatchTranslateDocumentRequest, dict]):
The request object. The BatchTranslateDocument request.
Expand Down Expand Up @@ -917,6 +1070,34 @@ async def create_glossary(
r"""Creates a glossary and returns the long-running operation.
Returns NOT_FOUND, if the project doesn't exist.
.. code-block:: python
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)
Args:
request (Union[google.cloud.translate_v3.types.CreateGlossaryRequest, dict]):
The request object. Request message for CreateGlossary.
Expand Down Expand Up @@ -1004,6 +1185,27 @@ async def list_glossaries(
r"""Lists glossaries in a project. Returns NOT_FOUND, if the project
doesn't exist.
.. code-block:: python
from google.cloud import translate_v3
def sample_list_glossaries():
# Create a client
client = translate_v3.TranslationServiceClient()
# Initialize request argument(s)
request = translate_v3.ListGlossariesRequest(
parent="parent_value",
)
# Make the request
page_result = client.list_glossaries(request=request)
# Handle the response
for response in page_result:
print(response)
Args:
request (Union[google.cloud.translate_v3.types.ListGlossariesRequest, dict]):
The request object. Request message for ListGlossaries.
Expand Down Expand Up @@ -1094,6 +1296,26 @@ async def get_glossary(
r"""Gets a glossary. Returns NOT_FOUND, if the glossary doesn't
exist.
.. code-block:: python
from google.cloud import translate_v3
def sample_get_glossary():
# Create a client
client = translate_v3.TranslationServiceClient()
# Initialize request argument(s)
request = translate_v3.GetGlossaryRequest(
name="name_value",
)
# Make the request
response = client.get_glossary(request=request)
# Handle the response
print(response)
Args:
request (Union[google.cloud.translate_v3.types.GetGlossaryRequest, dict]):
The request object. Request message for GetGlossary.
Expand Down Expand Up @@ -1176,6 +1398,30 @@ async def delete_glossary(
glossary isn't created yet. Returns NOT_FOUND, if the glossary
doesn't exist.
.. code-block:: python
from google.cloud import translate_v3
def sample_delete_glossary():
# Create a client
client = translate_v3.TranslationServiceClient()
# 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 = operation.result()
# Handle the response
print(response)
Args:
request (Union[google.cloud.translate_v3.types.DeleteGlossaryRequest, dict]):
The request object. Request message for DeleteGlossary.
Expand Down
Loading

0 comments on commit 8e6b946

Please sign in to comment.