|
23 | 23 | import google.api_core.gapic_v1.client_info |
24 | 24 | import google.api_core.gapic_v1.config |
25 | 25 | import google.api_core.gapic_v1.method |
| 26 | +import google.api_core.gapic_v1.routing_header |
26 | 27 | import google.api_core.grpc_helpers |
27 | 28 | import google.api_core.operation |
28 | 29 | import google.api_core.operations_v1 |
@@ -242,11 +243,13 @@ def translate_text( |
242 | 243 | Otherwise 400 is returned. |
243 | 244 | model (str): Optional. The ``model`` type requested for this translation. |
244 | 245 |
|
245 | | - The format depends on model type: 1. Custom models: |
246 | | - projects/{project-id}/locations/{location-id}/models/{model-id}. 2. |
247 | | - General (built-in) models: |
248 | | - projects/{project-id}/locations/{location-id}/models/general/nmt |
249 | | - projects/{project-id}/locations/{location-id}/models/general/base |
| 246 | + The format depends on model type: |
| 247 | +
|
| 248 | + 1. Custom models: |
| 249 | + projects/{project-id}/locations/{location-id}/models/{model-id}. |
| 250 | + 2. General (built-in) models: |
| 251 | + projects/{project-id}/locations/{location-id}/models/general/nmt |
| 252 | + projects/{project-id}/locations/{location-id}/models/general/base |
250 | 253 |
|
251 | 254 | For global (non-regionalized) requests, use {location-id} 'global'. For |
252 | 255 | example, projects/{project-id}/locations/global/models/general/nmt |
@@ -296,6 +299,19 @@ def translate_text( |
296 | 299 | model=model, |
297 | 300 | glossary_config=glossary_config, |
298 | 301 | ) |
| 302 | + if metadata is None: |
| 303 | + metadata = [] |
| 304 | + metadata = list(metadata) |
| 305 | + try: |
| 306 | + routing_header = [("parent", parent)] |
| 307 | + except AttributeError: |
| 308 | + pass |
| 309 | + else: |
| 310 | + routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata( |
| 311 | + routing_header |
| 312 | + ) |
| 313 | + metadata.append(routing_metadata) |
| 314 | + |
299 | 315 | return self._inner_api_calls["translate_text"]( |
300 | 316 | request, retry=retry, timeout=timeout, metadata=metadata |
301 | 317 | ) |
@@ -370,6 +386,19 @@ def detect_language( |
370 | 386 | request = translation_service_pb2.DetectLanguageRequest( |
371 | 387 | parent=parent, model=model, content=content, mime_type=mime_type |
372 | 388 | ) |
| 389 | + if metadata is None: |
| 390 | + metadata = [] |
| 391 | + metadata = list(metadata) |
| 392 | + try: |
| 393 | + routing_header = [("parent", parent)] |
| 394 | + except AttributeError: |
| 395 | + pass |
| 396 | + else: |
| 397 | + routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata( |
| 398 | + routing_header |
| 399 | + ) |
| 400 | + metadata.append(routing_metadata) |
| 401 | + |
373 | 402 | return self._inner_api_calls["detect_language"]( |
374 | 403 | request, retry=retry, timeout=timeout, metadata=metadata |
375 | 404 | ) |
@@ -445,6 +474,19 @@ def get_supported_languages( |
445 | 474 | request = translation_service_pb2.GetSupportedLanguagesRequest( |
446 | 475 | parent=parent, display_language_code=display_language_code, model=model |
447 | 476 | ) |
| 477 | + if metadata is None: |
| 478 | + metadata = [] |
| 479 | + metadata = list(metadata) |
| 480 | + try: |
| 481 | + routing_header = [("parent", parent)] |
| 482 | + except AttributeError: |
| 483 | + pass |
| 484 | + else: |
| 485 | + routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata( |
| 486 | + routing_header |
| 487 | + ) |
| 488 | + metadata.append(routing_metadata) |
| 489 | + |
448 | 490 | return self._inner_api_calls["get_supported_languages"]( |
449 | 491 | request, retry=retry, timeout=timeout, metadata=metadata |
450 | 492 | ) |
@@ -578,6 +620,19 @@ def batch_translate_text( |
578 | 620 | models=models, |
579 | 621 | glossaries=glossaries, |
580 | 622 | ) |
| 623 | + if metadata is None: |
| 624 | + metadata = [] |
| 625 | + metadata = list(metadata) |
| 626 | + try: |
| 627 | + routing_header = [("parent", parent)] |
| 628 | + except AttributeError: |
| 629 | + pass |
| 630 | + else: |
| 631 | + routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata( |
| 632 | + routing_header |
| 633 | + ) |
| 634 | + metadata.append(routing_metadata) |
| 635 | + |
581 | 636 | operation = self._inner_api_calls["batch_translate_text"]( |
582 | 637 | request, retry=retry, timeout=timeout, metadata=metadata |
583 | 638 | ) |
@@ -660,6 +715,19 @@ def create_glossary( |
660 | 715 | request = translation_service_pb2.CreateGlossaryRequest( |
661 | 716 | parent=parent, glossary=glossary |
662 | 717 | ) |
| 718 | + if metadata is None: |
| 719 | + metadata = [] |
| 720 | + metadata = list(metadata) |
| 721 | + try: |
| 722 | + routing_header = [("parent", parent)] |
| 723 | + except AttributeError: |
| 724 | + pass |
| 725 | + else: |
| 726 | + routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata( |
| 727 | + routing_header |
| 728 | + ) |
| 729 | + metadata.append(routing_metadata) |
| 730 | + |
663 | 731 | operation = self._inner_api_calls["create_glossary"]( |
664 | 732 | request, retry=retry, timeout=timeout, metadata=metadata |
665 | 733 | ) |
@@ -748,6 +816,19 @@ def list_glossaries( |
748 | 816 | request = translation_service_pb2.ListGlossariesRequest( |
749 | 817 | parent=parent, page_size=page_size, filter=filter_ |
750 | 818 | ) |
| 819 | + if metadata is None: |
| 820 | + metadata = [] |
| 821 | + metadata = list(metadata) |
| 822 | + try: |
| 823 | + routing_header = [("parent", parent)] |
| 824 | + except AttributeError: |
| 825 | + pass |
| 826 | + else: |
| 827 | + routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata( |
| 828 | + routing_header |
| 829 | + ) |
| 830 | + metadata.append(routing_metadata) |
| 831 | + |
751 | 832 | iterator = google.api_core.page_iterator.GRPCIterator( |
752 | 833 | client=None, |
753 | 834 | method=functools.partial( |
@@ -815,6 +896,19 @@ def get_glossary( |
815 | 896 | ) |
816 | 897 |
|
817 | 898 | request = translation_service_pb2.GetGlossaryRequest(name=name) |
| 899 | + if metadata is None: |
| 900 | + metadata = [] |
| 901 | + metadata = list(metadata) |
| 902 | + try: |
| 903 | + routing_header = [("name", name)] |
| 904 | + except AttributeError: |
| 905 | + pass |
| 906 | + else: |
| 907 | + routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata( |
| 908 | + routing_header |
| 909 | + ) |
| 910 | + metadata.append(routing_metadata) |
| 911 | + |
818 | 912 | return self._inner_api_calls["get_glossary"]( |
819 | 913 | request, retry=retry, timeout=timeout, metadata=metadata |
820 | 914 | ) |
@@ -881,6 +975,19 @@ def delete_glossary( |
881 | 975 | ) |
882 | 976 |
|
883 | 977 | request = translation_service_pb2.DeleteGlossaryRequest(name=name) |
| 978 | + if metadata is None: |
| 979 | + metadata = [] |
| 980 | + metadata = list(metadata) |
| 981 | + try: |
| 982 | + routing_header = [("name", name)] |
| 983 | + except AttributeError: |
| 984 | + pass |
| 985 | + else: |
| 986 | + routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata( |
| 987 | + routing_header |
| 988 | + ) |
| 989 | + metadata.append(routing_metadata) |
| 990 | + |
884 | 991 | operation = self._inner_api_calls["delete_glossary"]( |
885 | 992 | request, retry=retry, timeout=timeout, metadata=metadata |
886 | 993 | ) |
|
0 commit comments