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

Commit

Permalink
feat: enable "rest" transport in Python for services supporting numer…
Browse files Browse the repository at this point in the history
…ic 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>
  • Loading branch information
3 people authored Feb 28, 2023
1 parent 6902594 commit cb63888
Show file tree
Hide file tree
Showing 15 changed files with 9,595 additions and 373 deletions.
55 changes: 55 additions & 0 deletions google/cloud/translate_v3/gapic_metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,61 @@
]
}
}
},
"rest": {
"libraryClient": "TranslationServiceClient",
"rpcs": {
"BatchTranslateDocument": {
"methods": [
"batch_translate_document"
]
},
"BatchTranslateText": {
"methods": [
"batch_translate_text"
]
},
"CreateGlossary": {
"methods": [
"create_glossary"
]
},
"DeleteGlossary": {
"methods": [
"delete_glossary"
]
},
"DetectLanguage": {
"methods": [
"detect_language"
]
},
"GetGlossary": {
"methods": [
"get_glossary"
]
},
"GetSupportedLanguages": {
"methods": [
"get_supported_languages"
]
},
"ListGlossaries": {
"methods": [
"list_glossaries"
]
},
"TranslateDocument": {
"methods": [
"translate_document"
]
},
"TranslateText": {
"methods": [
"translate_text"
]
}
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,19 +287,19 @@ async def sample_translate_text():
on the ``request`` instance; if ``request`` is provided, this
should not be set.
target_language_code (:class:`str`):
Required. The BCP-47 language code to
use for translation of the input text,
set to one of the language codes listed
in Language Support.
Required. The ISO-639 language code
to use for translation of the input
text, set to one of the language codes
listed in Language Support.
This corresponds to the ``target_language_code`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
contents (:class:`MutableSequence[str]`):
Required. The content of the input in
string format. We recommend the total
content be less than 30k codepoints. The
max length of this field is 1024.
content be less than 30,000 codepoints.
The max length of this field is 1024.
Use BatchTranslateText for larger text.
This corresponds to the ``contents`` field
Expand Down Expand Up @@ -337,8 +337,8 @@ async def sample_translate_text():
on the ``request`` instance; if ``request`` is provided, this
should not be set.
source_language_code (:class:`str`):
Optional. The BCP-47 language code of
the input text if known, for example,
Optional. The ISO-639 language code
of the input text if known, for example,
"en-US" or "sr-Latn". Supported language
codes are listed in Language Support. If
the source language isn't specified, the
Expand Down Expand Up @@ -1027,19 +1027,17 @@ async def sample_batch_translate_document():
on the ``request`` instance; if ``request`` is provided, this
should not be set.
source_language_code (:class:`str`):
Required. The BCP-47 language code of
the input document if known, for
example, "en-US" or "sr-Latn". Supported
language codes are listed in Language
Support
(https://cloud.google.com/translate/docs/languages).
Required. The ISO-639 language code of the input
document if known, for example, "en-US" or "sr-Latn".
Supported language codes are listed in `Language
Support <https://cloud.google.com/translate/docs/languages>`__.
This corresponds to the ``source_language_code`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
target_language_codes (:class:`MutableSequence[str]`):
Required. The BCP-47 language code to
use for translation of the input
Required. The ISO-639 language code
to use for translation of the input
document. Specify up to 10 language
codes here.
Expand Down Expand Up @@ -1223,7 +1221,7 @@ async def sample_create_glossary():
The result type for the operation will be
:class:`google.cloud.translate_v3.types.Glossary`
Represents a glossary built from user provided data.
Represents a glossary built from user-provided data.
"""
# Create or coerce a protobuf request object.
Expand Down Expand Up @@ -1461,8 +1459,8 @@ async def sample_get_glossary():
Returns:
google.cloud.translate_v3.types.Glossary:
Represents a glossary built from user
provided data.
Represents a glossary built from
user-provided data.
"""
# Create or coerce a protobuf request object.
Expand Down
38 changes: 19 additions & 19 deletions google/cloud/translate_v3/services/translation_service/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
from .transports.base import TranslationServiceTransport, DEFAULT_CLIENT_INFO
from .transports.grpc import TranslationServiceGrpcTransport
from .transports.grpc_asyncio import TranslationServiceGrpcAsyncIOTransport
from .transports.rest import TranslationServiceRestTransport


class TranslationServiceClientMeta(type):
Expand All @@ -69,6 +70,7 @@ class TranslationServiceClientMeta(type):
) # type: Dict[str, Type[TranslationServiceTransport]]
_transport_registry["grpc"] = TranslationServiceGrpcTransport
_transport_registry["grpc_asyncio"] = TranslationServiceGrpcAsyncIOTransport
_transport_registry["rest"] = TranslationServiceRestTransport

def get_transport_class(
cls,
Expand Down Expand Up @@ -513,19 +515,19 @@ def sample_translate_text():
on the ``request`` instance; if ``request`` is provided, this
should not be set.
target_language_code (str):
Required. The BCP-47 language code to
use for translation of the input text,
set to one of the language codes listed
in Language Support.
Required. The ISO-639 language code
to use for translation of the input
text, set to one of the language codes
listed in Language Support.
This corresponds to the ``target_language_code`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
contents (MutableSequence[str]):
Required. The content of the input in
string format. We recommend the total
content be less than 30k codepoints. The
max length of this field is 1024.
content be less than 30,000 codepoints.
The max length of this field is 1024.
Use BatchTranslateText for larger text.
This corresponds to the ``contents`` field
Expand Down Expand Up @@ -563,8 +565,8 @@ def sample_translate_text():
on the ``request`` instance; if ``request`` is provided, this
should not be set.
source_language_code (str):
Optional. The BCP-47 language code of
the input text if known, for example,
Optional. The ISO-639 language code
of the input text if known, for example,
"en-US" or "sr-Latn". Supported language
codes are listed in Language Support. If
the source language isn't specified, the
Expand Down Expand Up @@ -1245,19 +1247,17 @@ def sample_batch_translate_document():
on the ``request`` instance; if ``request`` is provided, this
should not be set.
source_language_code (str):
Required. The BCP-47 language code of
the input document if known, for
example, "en-US" or "sr-Latn". Supported
language codes are listed in Language
Support
(https://cloud.google.com/translate/docs/languages).
Required. The ISO-639 language code of the input
document if known, for example, "en-US" or "sr-Latn".
Supported language codes are listed in `Language
Support <https://cloud.google.com/translate/docs/languages>`__.
This corresponds to the ``source_language_code`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
target_language_codes (MutableSequence[str]):
Required. The BCP-47 language code to
use for translation of the input
Required. The ISO-639 language code
to use for translation of the input
document. Specify up to 10 language
codes here.
Expand Down Expand Up @@ -1441,7 +1441,7 @@ def sample_create_glossary():
The result type for the operation will be
:class:`google.cloud.translate_v3.types.Glossary`
Represents a glossary built from user provided data.
Represents a glossary built from user-provided data.
"""
# Create or coerce a protobuf request object.
Expand Down Expand Up @@ -1669,8 +1669,8 @@ def sample_get_glossary():
Returns:
google.cloud.translate_v3.types.Glossary:
Represents a glossary built from user
provided data.
Represents a glossary built from
user-provided data.
"""
# Create or coerce a protobuf request object.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
from .base import TranslationServiceTransport
from .grpc import TranslationServiceGrpcTransport
from .grpc_asyncio import TranslationServiceGrpcAsyncIOTransport
from .rest import TranslationServiceRestTransport
from .rest import TranslationServiceRestInterceptor


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

__all__ = (
"TranslationServiceTransport",
"TranslationServiceGrpcTransport",
"TranslationServiceGrpcAsyncIOTransport",
"TranslationServiceRestTransport",
"TranslationServiceRestInterceptor",
)
Loading

0 comments on commit cb63888

Please sign in to comment.