@@ -218,8 +218,9 @@ async def translate_text(
218218 contents (:class:`Sequence[str]`):
219219 Required. The content of the input in
220220 string format. We recommend the total
221- content be less than 30k codepoints. Use
222- BatchTranslateText for larger text.
221+ content be less than 30k codepoints. The
222+ max length of this field is 1024.
223+ Use BatchTranslateText for larger text.
223224
224225 This corresponds to the ``contents`` field
225226 on the ``request`` instance; if ``request`` is provided, this
@@ -235,14 +236,13 @@ async def translate_text(
235236
236237 - General (built-in) models:
237238 ``projects/{project-number-or-id}/locations/{location-id}/models/general/nmt``,
238- ``projects/{project-number-or-id}/locations/{location-id}/models/general/base``
239239
240240 For global (non-regionalized) requests, use
241241 ``location-id`` ``global``. For example,
242242 ``projects/{project-number-or-id}/locations/global/models/general/nmt``.
243243
244- If missing , the system decides which google base model
245- to use .
244+ If not provided , the default Google model (NMT) will be
245+ used .
246246
247247 This corresponds to the ``model`` field
248248 on the ``request`` instance; if ``request`` is provided, this
@@ -506,11 +506,10 @@ async def get_supported_languages(
506506
507507 - General (built-in) models:
508508 ``projects/{project-number-or-id}/locations/{location-id}/models/general/nmt``,
509- ``projects/{project-number-or-id}/locations/{location-id}/models/general/base``
510509
511510 Returns languages supported by the specified model. If
512511 missing, we get supported languages of Google general
513- base (PBMT) model.
512+ NMT model.
514513
515514 This corresponds to the ``model`` field
516515 on the ``request`` instance; if ``request`` is provided, this
@@ -588,6 +587,54 @@ async def get_supported_languages(
588587 # Done; return the response.
589588 return response
590589
590+ async def translate_document (
591+ self ,
592+ request : translation_service .TranslateDocumentRequest = None ,
593+ * ,
594+ retry : retries .Retry = gapic_v1 .method .DEFAULT ,
595+ timeout : float = None ,
596+ metadata : Sequence [Tuple [str , str ]] = (),
597+ ) -> translation_service .TranslateDocumentResponse :
598+ r"""Translates documents in synchronous mode.
599+
600+ Args:
601+ request (:class:`google.cloud.translate_v3.types.TranslateDocumentRequest`):
602+ The request object. A document translation request.
603+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
604+ should be retried.
605+ timeout (float): The timeout for this request.
606+ metadata (Sequence[Tuple[str, str]]): Strings which should be
607+ sent along with the request as metadata.
608+
609+ Returns:
610+ google.cloud.translate_v3.types.TranslateDocumentResponse:
611+ A translated document response
612+ message.
613+
614+ """
615+ # Create or coerce a protobuf request object.
616+ request = translation_service .TranslateDocumentRequest (request )
617+
618+ # Wrap the RPC method; this adds retry and timeout information,
619+ # and friendly error handling.
620+ rpc = gapic_v1 .method_async .wrap_method (
621+ self ._client ._transport .translate_document ,
622+ default_timeout = 600.0 ,
623+ client_info = DEFAULT_CLIENT_INFO ,
624+ )
625+
626+ # Certain fields should be provided within the metadata header;
627+ # add these here.
628+ metadata = tuple (metadata ) + (
629+ gapic_v1 .routing_header .to_grpc_metadata ((("parent" , request .parent ),)),
630+ )
631+
632+ # Send the request.
633+ response = await rpc (request , retry = retry , timeout = timeout , metadata = metadata ,)
634+
635+ # Done; return the response.
636+ return response
637+
591638 async def batch_translate_text (
592639 self ,
593640 request : translation_service .BatchTranslateTextRequest = None ,
@@ -656,6 +703,74 @@ async def batch_translate_text(
656703 # Done; return the response.
657704 return response
658705
706+ async def batch_translate_document (
707+ self ,
708+ request : translation_service .BatchTranslateDocumentRequest = None ,
709+ * ,
710+ retry : retries .Retry = gapic_v1 .method .DEFAULT ,
711+ timeout : float = None ,
712+ metadata : Sequence [Tuple [str , str ]] = (),
713+ ) -> operation_async .AsyncOperation :
714+ r"""Translates a large volume of document in asynchronous
715+ batch mode. This function provides real-time output as
716+ the inputs are being processed. If caller cancels a
717+ request, the partial results (for an input file, it's
718+ all or nothing) may still be available on the specified
719+ output location.
720+ This call returns immediately and you can use
721+ google.longrunning.Operation.name to poll the status of
722+ the call.
723+
724+ Args:
725+ request (:class:`google.cloud.translate_v3.types.BatchTranslateDocumentRequest`):
726+ The request object. The BatchTranslateDocument request.
727+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
728+ should be retried.
729+ timeout (float): The timeout for this request.
730+ metadata (Sequence[Tuple[str, str]]): Strings which should be
731+ sent along with the request as metadata.
732+
733+ Returns:
734+ google.api_core.operation_async.AsyncOperation:
735+ An object representing a long-running operation.
736+
737+ The result type for the operation will be :class:`google.cloud.translate_v3.types.BatchTranslateDocumentResponse` Stored in the
738+ [google.longrunning.Operation.response][google.longrunning.Operation.response]
739+ field returned by BatchTranslateDocument if at least
740+ one document is translated successfully.
741+
742+ """
743+ # Create or coerce a protobuf request object.
744+ request = translation_service .BatchTranslateDocumentRequest (request )
745+
746+ # Wrap the RPC method; this adds retry and timeout information,
747+ # and friendly error handling.
748+ rpc = gapic_v1 .method_async .wrap_method (
749+ self ._client ._transport .batch_translate_document ,
750+ default_timeout = 600.0 ,
751+ client_info = DEFAULT_CLIENT_INFO ,
752+ )
753+
754+ # Certain fields should be provided within the metadata header;
755+ # add these here.
756+ metadata = tuple (metadata ) + (
757+ gapic_v1 .routing_header .to_grpc_metadata ((("parent" , request .parent ),)),
758+ )
759+
760+ # Send the request.
761+ response = await rpc (request , retry = retry , timeout = timeout , metadata = metadata ,)
762+
763+ # Wrap the response in an operation future.
764+ response = operation_async .from_gapic (
765+ response ,
766+ self ._client ._transport .operations_client ,
767+ translation_service .BatchTranslateDocumentResponse ,
768+ metadata_type = translation_service .BatchTranslateDocumentMetadata ,
769+ )
770+
771+ # Done; return the response.
772+ return response
773+
659774 async def create_glossary (
660775 self ,
661776 request : translation_service .CreateGlossaryRequest = None ,
0 commit comments