Class TranslationServiceAsyncClient (3.0.2)

TranslationServiceAsyncClient(*, credentials: google.auth.credentials.Credentials = None, transport: Union[str, google.cloud.translate_v3beta1.services.translation_service.transports.base.TranslationServiceTransport] = 'grpc_asyncio', client_options: <module 'google.api_core.client_options' from '/workspace/python-translate/.nox/docfx/lib/python3.9/site-packages/google/api_core/client_options.py'> = None, client_info: google.api_core.gapic_v1.client_info.ClientInfo = <google.api_core.gapic_v1.client_info.ClientInfo object>)

Provides natural language translation operations.

Methods

TranslationServiceAsyncClient

TranslationServiceAsyncClient(*, credentials: google.auth.credentials.Credentials = None, transport: Union[str, google.cloud.translate_v3beta1.services.translation_service.transports.base.TranslationServiceTransport] = 'grpc_asyncio', client_options: <module 'google.api_core.client_options' from '/workspace/python-translate/.nox/docfx/lib/python3.9/site-packages/google/api_core/client_options.py'> = None, client_info: google.api_core.gapic_v1.client_info.ClientInfo = <google.api_core.gapic_v1.client_info.ClientInfo object>)

Instantiate the translation service client.

Parameters
NameDescription
credentials Optional[google.auth.credentials.Credentials]

The authorization credentials to attach to requests. These credentials identify the application to the service; if none are specified, the client will attempt to ascertain the credentials from the environment.

transport Union[str, .TranslationServiceTransport]

The transport to use. If set to None, a transport is chosen automatically.

client_options ClientOptions

Custom options for the client. It won't take effect if a transport instance is provided. (1) The api_endpoint property can be used to override the default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT environment variable can also be used to override the endpoint: "always" (always use the default mTLS endpoint), "never" (always use the default regular endpoint) and "auto" (auto switch to the default mTLS endpoint if client certificate is present, this is the default value). However, the api_endpoint property takes precedence if provided. (2) If GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable is "true", then the client_cert_source property can be used to provide client certificate for mutual TLS transport. If not provided, the default SSL client certificate will be used if present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not set, no client certificate will be used.

Exceptions
TypeDescription
google.auth.exceptions.MutualTlsChannelErrorIf mutual TLS transport creation failed for any reason.

batch_translate_text

batch_translate_text(request: Optional[google.cloud.translate_v3beta1.types.translation_service.BatchTranslateTextRequest] = None, *, retry: google.api_core.retry.Retry = <_MethodDefault._DEFAULT_VALUE: <object object>>, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = ())

Translates a large volume of text in asynchronous batch mode. This function provides real-time output as the inputs are being processed. If caller cancels a request, the partial results (for an input file, it's all or nothing) may still be available on the specified output location. This call returns immediately and you can use google.longrunning.Operation.name to poll the status of the call.

Parameters
NameDescription
request .translation_service.BatchTranslateTextRequest

The request object. The batch translation request.

retry google.api_core.retry.Retry

Designation of what errors, if any, should be retried.

timeout float

The timeout for this request.

metadata Sequence[Tuple[str, str]]

Strings which should be sent along with the request as metadata.

Returns
TypeDescription
.operation_async.AsyncOperationAn object representing a long-running operation. The result type for the operation will be
.translation_service.BatchTranslateResponse
: Stored in the google.longrunning.Operation.response][google.longrunning.Operation.response] field returned by BatchTranslateText if at least one sentence is translated successfully.

create_glossary

create_glossary(request: Optional[google.cloud.translate_v3beta1.types.translation_service.CreateGlossaryRequest] = None, *, parent: Optional[str] = None, glossary: Optional[google.cloud.translate_v3beta1.types.translation_service.Glossary] = None, retry: google.api_core.retry.Retry = <_MethodDefault._DEFAULT_VALUE: <object object>>, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = ())

Creates a glossary and returns the long-running operation. Returns NOT_FOUND, if the project doesn't exist.

Parameters
NameDescription
request .translation_service.CreateGlossaryRequest

The request object. Request message for CreateGlossary.

parent str

Required. The project name. This corresponds to the parent field on the request instance; if request is provided, this should not be set.

glossary .translation_service.Glossary

Required. The glossary to create. This corresponds to the glossary field on the request instance; if request is provided, this should not be set.

retry google.api_core.retry.Retry

Designation of what errors, if any, should be retried.

timeout float

The timeout for this request.

metadata Sequence[Tuple[str, str]]

Strings which should be sent along with the request as metadata.

Returns
TypeDescription
.operation_async.AsyncOperationAn object representing a long-running operation. The result type for the operation will be
.translation_service.Glossary
: Represents a glossary built from user provided data.

delete_glossary

delete_glossary(request: Optional[google.cloud.translate_v3beta1.types.translation_service.DeleteGlossaryRequest] = None, *, name: Optional[str] = None, retry: google.api_core.retry.Retry = <_MethodDefault._DEFAULT_VALUE: <object object>>, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = ())

Deletes a glossary, or cancels glossary construction if the glossary isn't created yet. Returns NOT_FOUND, if the glossary doesn't exist.

Parameters
NameDescription
request .translation_service.DeleteGlossaryRequest

The request object. Request message for DeleteGlossary.

name str

Required. The name of the glossary to delete. This corresponds to the name field on the request instance; if request is provided, this should not be set.

retry google.api_core.retry.Retry

Designation of what errors, if any, should be retried.

timeout float

The timeout for this request.

metadata Sequence[Tuple[str, str]]

Strings which should be sent along with the request as metadata.

Returns
TypeDescription
.operation_async.AsyncOperationAn object representing a long-running operation. The result type for the operation will be
.translation_service.DeleteGlossaryResponse
: Stored in the google.longrunning.Operation.response][google.longrunning.Operation.response] field returned by DeleteGlossary.

detect_language

detect_language(request: Optional[google.cloud.translate_v3beta1.types.translation_service.DetectLanguageRequest] = None, *, parent: Optional[str] = None, model: Optional[str] = None, mime_type: Optional[str] = None, retry: google.api_core.retry.Retry = <_MethodDefault._DEFAULT_VALUE: <object object>>, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = ())

Detects the language of text within a request.

Parameters
NameDescription
request .translation_service.DetectLanguageRequest

The request object. The request message for language detection.

parent str

Required. Project or location to make a call. Must refer to a caller's project. Format: projects/{project-id}/locations/{location-id} or projects/{project-id}. For global calls, use projects/{project-id}/locations/global or projects/{project-id}. Only models within the same region (has same location-id) can be used. Otherwise an INVALID_ARGUMENT (400) error is returned. This corresponds to the parent field on the request instance; if request is provided, this should not be set.

model str

Optional. The language detection model to be used. Format: projects/{project-id}/locations/{location-id}/models/language-detection/{model-id} Only one language detection model is currently supported: projects/{project-id}/locations/{location-id}/models/language-detection/default. If not specified, the default model is used. This corresponds to the model field on the request instance; if request is provided, this should not be set.

mime_type str

Optional. The format of the source text, for example, "text/html", "text/plain". If left blank, the MIME type defaults to "text/html". This corresponds to the mime_type field on the request instance; if request is provided, this should not be set.

retry google.api_core.retry.Retry

Designation of what errors, if any, should be retried.

timeout float

The timeout for this request.

metadata Sequence[Tuple[str, str]]

Strings which should be sent along with the request as metadata.

Returns
TypeDescription
.translation_service.DetectLanguageResponseThe response message for language detection.

from_service_account_file

from_service_account_file(filename: str, *args, **kwargs)

Creates an instance of this client using the provided credentials file.

Parameter
NameDescription
filename str

The path to the service account private key json file.

Returns
TypeDescription
{@api.name}The constructed client.

from_service_account_json

from_service_account_json(filename: str, *args, **kwargs)

Creates an instance of this client using the provided credentials file.

Parameter
NameDescription
filename str

The path to the service account private key json file.

Returns
TypeDescription
{@api.name}The constructed client.

get_glossary

get_glossary(request: Optional[google.cloud.translate_v3beta1.types.translation_service.GetGlossaryRequest] = None, *, name: Optional[str] = None, retry: google.api_core.retry.Retry = <_MethodDefault._DEFAULT_VALUE: <object object>>, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = ())

Gets a glossary. Returns NOT_FOUND, if the glossary doesn't exist.

Parameters
NameDescription
request .translation_service.GetGlossaryRequest

The request object. Request message for GetGlossary.

name str

Required. The name of the glossary to retrieve. This corresponds to the name field on the request instance; if request is provided, this should not be set.

retry google.api_core.retry.Retry

Designation of what errors, if any, should be retried.

timeout float

The timeout for this request.

metadata Sequence[Tuple[str, str]]

Strings which should be sent along with the request as metadata.

Returns
TypeDescription
.translation_service.GlossaryRepresents a glossary built from user provided data.

get_supported_languages

get_supported_languages(request: Optional[google.cloud.translate_v3beta1.types.translation_service.GetSupportedLanguagesRequest] = None, *, parent: Optional[str] = None, display_language_code: Optional[str] = None, model: Optional[str] = None, retry: google.api_core.retry.Retry = <_MethodDefault._DEFAULT_VALUE: <object object>>, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = ())

Returns a list of supported languages for translation.

Parameters
NameDescription
request .translation_service.GetSupportedLanguagesRequest

The request object. The request message for discovering supported languages.

parent str

Required. Project or location to make a call. Must refer to a caller's project. Format: projects/{project-id} or projects/{project-id}/locations/{location-id}. For global calls, use projects/{project-id}/locations/global or projects/{project-id}. Non-global location is required for AutoML models. Only models within the same region (have same location-id) can be used, otherwise an INVALID_ARGUMENT (400) error is returned. This corresponds to the parent field on the request instance; if request is provided, this should not be set.

display_language_code str

Optional. The language to use to return localized, human readable names of supported languages. If missing, then display names are not returned in a response. This corresponds to the display_language_code field on the request instance; if request is provided, this should not be set.

model str

Optional. Get supported languages of this model. The format depends on model type: - AutoML Translation models: projects/{project-id}/locations/{location-id}/models/{model-id} - General (built-in) models: projects/{project-id}/locations/{location-id}/models/general/nmt, projects/{project-id}/locations/{location-id}/models/general/base Returns languages supported by the specified model. If missing, we get supported languages of Google general base (PBMT) model. This corresponds to the model field on the request instance; if request is provided, this should not be set.

retry google.api_core.retry.Retry

Designation of what errors, if any, should be retried.

timeout float

The timeout for this request.

metadata Sequence[Tuple[str, str]]

Strings which should be sent along with the request as metadata.

Returns
TypeDescription
.translation_service.SupportedLanguagesThe response message for discovering supported languages.

get_transport_class

get_transport_class()

Return an appropriate transport class.

glossary_path

glossary_path(project: str, location: str, glossary: str)

Return a fully-qualified glossary string.

list_glossaries

list_glossaries(request: Optional[google.cloud.translate_v3beta1.types.translation_service.ListGlossariesRequest] = None, *, parent: Optional[str] = None, filter: Optional[str] = None, retry: google.api_core.retry.Retry = <_MethodDefault._DEFAULT_VALUE: <object object>>, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = ())

Lists glossaries in a project. Returns NOT_FOUND, if the project doesn't exist.

Parameters
NameDescription
request .translation_service.ListGlossariesRequest

The request object. Request message for ListGlossaries.

parent str

Required. The name of the project from which to list all of the glossaries. This corresponds to the parent field on the request instance; if request is provided, this should not be set.

filter str

Optional. Filter specifying constraints of a list operation. Filtering is not supported yet, and the parameter currently has no effect. If missing, no filtering is performed. This corresponds to the filter field on the request instance; if request is provided, this should not be set.

retry google.api_core.retry.Retry

Designation of what errors, if any, should be retried.

timeout float

The timeout for this request.

metadata Sequence[Tuple[str, str]]

Strings which should be sent along with the request as metadata.

Returns
TypeDescription
.pagers.ListGlossariesAsyncPagerResponse message for ListGlossaries. Iterating over this object will yield results and resolve additional pages automatically.

parse_glossary_path

parse_glossary_path(path: str)

Parse a glossary path into its component segments.

translate_text

translate_text(request: Optional[google.cloud.translate_v3beta1.types.translation_service.TranslateTextRequest] = None, *, retry: google.api_core.retry.Retry = <_MethodDefault._DEFAULT_VALUE: <object object>>, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = ())

Translates input text and returns translated text.

Parameters
NameDescription
request .translation_service.TranslateTextRequest

The request object. The request message for synchronous translation.

retry google.api_core.retry.Retry

Designation of what errors, if any, should be retried.

timeout float

The timeout for this request.

metadata Sequence[Tuple[str, str]]

Strings which should be sent along with the request as metadata.