Skip to content
This repository was archived by the owner on Feb 23, 2024. It is now read-only.

Commit cb63888

Browse files
feat: enable "rest" transport in Python for services supporting numeric enums (#483)
* feat: enable "rest" transport in Python for services supporting numeric enums PiperOrigin-RevId: 508143576 Source-Link: googleapis/googleapis@7a702a9 Source-Link: https://github.com/googleapis/googleapis-gen/commit/6ad1279c0e7aa787ac6b66c9fd4a210692edffcd Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNmFkMTI3OWMwZTdhYTc4N2FjNmI2NmM5ZmQ0YTIxMDY5MmVkZmZjZCJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * fix: Add service_yaml_parameters to py_gapic_library BUILD.bazel targets PiperOrigin-RevId: 510187992 Source-Link: googleapis/googleapis@5edc235 Source-Link: https://github.com/googleapis/googleapis-gen/commit/b0bedb72e4765a3e0b674a28c50ea0f9a9b26a89 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiYjBiZWRiNzJlNDc2NWEzZTBiNjc0YTI4YzUwZWEwZjlhOWIyNmE4OSJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * feat: Add supported fields in document translation request and refresh translation v3 GA service proto documentation PiperOrigin-RevId: 511225850 Source-Link: googleapis/googleapis@84bbbc5 Source-Link: https://github.com/googleapis/googleapis-gen/commit/431d15cddae84906d4ac2e1d75e243099747c52b Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNDMxZDE1Y2RkYWU4NDkwNmQ0YWMyZTFkNzVlMjQzMDk5NzQ3YzUyYiJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * chore: Update gapic-generator-python to v1.8.5 PiperOrigin-RevId: 511892190 Source-Link: googleapis/googleapis@a45d9c0 Source-Link: https://github.com/googleapis/googleapis-gen/commit/1907294b1d8365ea24f8c5f2e059a64124c4ed3b Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMTkwNzI5NGIxZDgzNjVlYTI0ZjhjNWYyZTA1OWE2NDEyNGM0ZWQzYiJ9 * 🦉 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: Victor Chudnovsky <vchudnov@google.com>
1 parent 6902594 commit cb63888

File tree

15 files changed

+9595
-373
lines changed

15 files changed

+9595
-373
lines changed

google/cloud/translate_v3/gapic_metadata.json

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,61 @@
116116
]
117117
}
118118
}
119+
},
120+
"rest": {
121+
"libraryClient": "TranslationServiceClient",
122+
"rpcs": {
123+
"BatchTranslateDocument": {
124+
"methods": [
125+
"batch_translate_document"
126+
]
127+
},
128+
"BatchTranslateText": {
129+
"methods": [
130+
"batch_translate_text"
131+
]
132+
},
133+
"CreateGlossary": {
134+
"methods": [
135+
"create_glossary"
136+
]
137+
},
138+
"DeleteGlossary": {
139+
"methods": [
140+
"delete_glossary"
141+
]
142+
},
143+
"DetectLanguage": {
144+
"methods": [
145+
"detect_language"
146+
]
147+
},
148+
"GetGlossary": {
149+
"methods": [
150+
"get_glossary"
151+
]
152+
},
153+
"GetSupportedLanguages": {
154+
"methods": [
155+
"get_supported_languages"
156+
]
157+
},
158+
"ListGlossaries": {
159+
"methods": [
160+
"list_glossaries"
161+
]
162+
},
163+
"TranslateDocument": {
164+
"methods": [
165+
"translate_document"
166+
]
167+
},
168+
"TranslateText": {
169+
"methods": [
170+
"translate_text"
171+
]
172+
}
173+
}
119174
}
120175
}
121176
}

google/cloud/translate_v3/services/translation_service/async_client.py

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -287,19 +287,19 @@ async def sample_translate_text():
287287
on the ``request`` instance; if ``request`` is provided, this
288288
should not be set.
289289
target_language_code (:class:`str`):
290-
Required. The BCP-47 language code to
291-
use for translation of the input text,
292-
set to one of the language codes listed
293-
in Language Support.
290+
Required. The ISO-639 language code
291+
to use for translation of the input
292+
text, set to one of the language codes
293+
listed in Language Support.
294294
295295
This corresponds to the ``target_language_code`` field
296296
on the ``request`` instance; if ``request`` is provided, this
297297
should not be set.
298298
contents (:class:`MutableSequence[str]`):
299299
Required. The content of the input in
300300
string format. We recommend the total
301-
content be less than 30k codepoints. The
302-
max length of this field is 1024.
301+
content be less than 30,000 codepoints.
302+
The max length of this field is 1024.
303303
Use BatchTranslateText for larger text.
304304
305305
This corresponds to the ``contents`` field
@@ -337,8 +337,8 @@ async def sample_translate_text():
337337
on the ``request`` instance; if ``request`` is provided, this
338338
should not be set.
339339
source_language_code (:class:`str`):
340-
Optional. The BCP-47 language code of
341-
the input text if known, for example,
340+
Optional. The ISO-639 language code
341+
of the input text if known, for example,
342342
"en-US" or "sr-Latn". Supported language
343343
codes are listed in Language Support. If
344344
the source language isn't specified, the
@@ -1027,19 +1027,17 @@ async def sample_batch_translate_document():
10271027
on the ``request`` instance; if ``request`` is provided, this
10281028
should not be set.
10291029
source_language_code (:class:`str`):
1030-
Required. The BCP-47 language code of
1031-
the input document if known, for
1032-
example, "en-US" or "sr-Latn". Supported
1033-
language codes are listed in Language
1034-
Support
1035-
(https://cloud.google.com/translate/docs/languages).
1030+
Required. The ISO-639 language code of the input
1031+
document if known, for example, "en-US" or "sr-Latn".
1032+
Supported language codes are listed in `Language
1033+
Support <https://cloud.google.com/translate/docs/languages>`__.
10361034
10371035
This corresponds to the ``source_language_code`` field
10381036
on the ``request`` instance; if ``request`` is provided, this
10391037
should not be set.
10401038
target_language_codes (:class:`MutableSequence[str]`):
1041-
Required. The BCP-47 language code to
1042-
use for translation of the input
1039+
Required. The ISO-639 language code
1040+
to use for translation of the input
10431041
document. Specify up to 10 language
10441042
codes here.
10451043
@@ -1223,7 +1221,7 @@ async def sample_create_glossary():
12231221
12241222
The result type for the operation will be
12251223
:class:`google.cloud.translate_v3.types.Glossary`
1226-
Represents a glossary built from user provided data.
1224+
Represents a glossary built from user-provided data.
12271225
12281226
"""
12291227
# Create or coerce a protobuf request object.
@@ -1461,8 +1459,8 @@ async def sample_get_glossary():
14611459
14621460
Returns:
14631461
google.cloud.translate_v3.types.Glossary:
1464-
Represents a glossary built from user
1465-
provided data.
1462+
Represents a glossary built from
1463+
user-provided data.
14661464
14671465
"""
14681466
# Create or coerce a protobuf request object.

google/cloud/translate_v3/services/translation_service/client.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
from .transports.base import TranslationServiceTransport, DEFAULT_CLIENT_INFO
5555
from .transports.grpc import TranslationServiceGrpcTransport
5656
from .transports.grpc_asyncio import TranslationServiceGrpcAsyncIOTransport
57+
from .transports.rest import TranslationServiceRestTransport
5758

5859

5960
class TranslationServiceClientMeta(type):
@@ -69,6 +70,7 @@ class TranslationServiceClientMeta(type):
6970
) # type: Dict[str, Type[TranslationServiceTransport]]
7071
_transport_registry["grpc"] = TranslationServiceGrpcTransport
7172
_transport_registry["grpc_asyncio"] = TranslationServiceGrpcAsyncIOTransport
73+
_transport_registry["rest"] = TranslationServiceRestTransport
7274

7375
def get_transport_class(
7476
cls,
@@ -513,19 +515,19 @@ def sample_translate_text():
513515
on the ``request`` instance; if ``request`` is provided, this
514516
should not be set.
515517
target_language_code (str):
516-
Required. The BCP-47 language code to
517-
use for translation of the input text,
518-
set to one of the language codes listed
519-
in Language Support.
518+
Required. The ISO-639 language code
519+
to use for translation of the input
520+
text, set to one of the language codes
521+
listed in Language Support.
520522
521523
This corresponds to the ``target_language_code`` field
522524
on the ``request`` instance; if ``request`` is provided, this
523525
should not be set.
524526
contents (MutableSequence[str]):
525527
Required. The content of the input in
526528
string format. We recommend the total
527-
content be less than 30k codepoints. The
528-
max length of this field is 1024.
529+
content be less than 30,000 codepoints.
530+
The max length of this field is 1024.
529531
Use BatchTranslateText for larger text.
530532
531533
This corresponds to the ``contents`` field
@@ -563,8 +565,8 @@ def sample_translate_text():
563565
on the ``request`` instance; if ``request`` is provided, this
564566
should not be set.
565567
source_language_code (str):
566-
Optional. The BCP-47 language code of
567-
the input text if known, for example,
568+
Optional. The ISO-639 language code
569+
of the input text if known, for example,
568570
"en-US" or "sr-Latn". Supported language
569571
codes are listed in Language Support. If
570572
the source language isn't specified, the
@@ -1245,19 +1247,17 @@ def sample_batch_translate_document():
12451247
on the ``request`` instance; if ``request`` is provided, this
12461248
should not be set.
12471249
source_language_code (str):
1248-
Required. The BCP-47 language code of
1249-
the input document if known, for
1250-
example, "en-US" or "sr-Latn". Supported
1251-
language codes are listed in Language
1252-
Support
1253-
(https://cloud.google.com/translate/docs/languages).
1250+
Required. The ISO-639 language code of the input
1251+
document if known, for example, "en-US" or "sr-Latn".
1252+
Supported language codes are listed in `Language
1253+
Support <https://cloud.google.com/translate/docs/languages>`__.
12541254
12551255
This corresponds to the ``source_language_code`` field
12561256
on the ``request`` instance; if ``request`` is provided, this
12571257
should not be set.
12581258
target_language_codes (MutableSequence[str]):
1259-
Required. The BCP-47 language code to
1260-
use for translation of the input
1259+
Required. The ISO-639 language code
1260+
to use for translation of the input
12611261
document. Specify up to 10 language
12621262
codes here.
12631263
@@ -1441,7 +1441,7 @@ def sample_create_glossary():
14411441
14421442
The result type for the operation will be
14431443
:class:`google.cloud.translate_v3.types.Glossary`
1444-
Represents a glossary built from user provided data.
1444+
Represents a glossary built from user-provided data.
14451445
14461446
"""
14471447
# Create or coerce a protobuf request object.
@@ -1669,8 +1669,8 @@ def sample_get_glossary():
16691669
16701670
Returns:
16711671
google.cloud.translate_v3.types.Glossary:
1672-
Represents a glossary built from user
1673-
provided data.
1672+
Represents a glossary built from
1673+
user-provided data.
16741674
16751675
"""
16761676
# Create or coerce a protobuf request object.

google/cloud/translate_v3/services/translation_service/transports/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
from .base import TranslationServiceTransport
2020
from .grpc import TranslationServiceGrpcTransport
2121
from .grpc_asyncio import TranslationServiceGrpcAsyncIOTransport
22+
from .rest import TranslationServiceRestTransport
23+
from .rest import TranslationServiceRestInterceptor
2224

2325

2426
# Compile a registry of transports.
@@ -27,9 +29,12 @@
2729
) # type: Dict[str, Type[TranslationServiceTransport]]
2830
_transport_registry["grpc"] = TranslationServiceGrpcTransport
2931
_transport_registry["grpc_asyncio"] = TranslationServiceGrpcAsyncIOTransport
32+
_transport_registry["rest"] = TranslationServiceRestTransport
3033

3134
__all__ = (
3235
"TranslationServiceTransport",
3336
"TranslationServiceGrpcTransport",
3437
"TranslationServiceGrpcAsyncIOTransport",
38+
"TranslationServiceRestTransport",
39+
"TranslationServiceRestInterceptor",
3540
)

0 commit comments

Comments
 (0)