Skip to content

Commit ce2c79a

Browse files
chore: Update gapic-generator-python to v1.6.1 (#239)
* chore: update to gapic-generator-python 1.5.0 feat: add support for `google.cloud.<api>.__version__` PiperOrigin-RevId: 484665853 Source-Link: googleapis/googleapis@8eb249a Source-Link: googleapis/googleapis-gen@c8aa327 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiYzhhYTMyN2I1ZjQ3ODg2NWZjM2ZkOTFlM2MyNzY4ZTU0ZTI2YWQ0NCJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * update version in gapic_version.py * add .release-please-manifest.json with correct version * add owlbot.py to exclude generated gapic_version.py * add release-please-config.json * chore: Update to gapic-generator-python 1.6.0 feat(python): Add typing to proto.Message based class attributes feat(python): Snippetgen handling of repeated enum field PiperOrigin-RevId: 487326846 Source-Link: googleapis/googleapis@da380c7 Source-Link: googleapis/googleapis-gen@61ef576 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNjFlZjU3NjJlZTY3MzFhMGNiYmZlYTIyZmQwZWVjZWU1MWFiMWM4ZSJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * feat: new APIs added to reflect updates to the filestore service - Add ENTERPRISE Tier - Add snapshot APIs: RevertInstance, ListSnapshots, CreateSnapshot, DeleteSnapshot, UpdateSnapshot - Add multi-share APIs: ListShares, GetShare, CreateShare, DeleteShare, UpdateShare - Add ConnectMode to NetworkConfig (for Private Service Access support) - New status codes (SUSPENDED/SUSPENDING, REVERTING/RESUMING) - Add SuspensionReason (for KMS related suspension) - Add new fields to Instance information: max_capacity_gb, capacity_step_size_gb, max_share_count, capacity_gb, multi_share_enabled PiperOrigin-RevId: 487492758 Source-Link: googleapis/googleapis@5be5981 Source-Link: googleapis/googleapis-gen@ab0e217 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiYWIwZTIxN2Y1NjBjYzJjMWFmYzExNDQxYzJlYWI2YjY5NTBlZmQyYiJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * update path to snippet metadata json * chore: Update gapic-generator-python to v1.6.1 PiperOrigin-RevId: 488036204 Source-Link: googleapis/googleapis@08f275f Source-Link: googleapis/googleapis-gen@555c094 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNTU1YzA5NDVlNjA2NDllMzg3MzlhZTY0YmM0NTcxOWNkZjcyMTc4ZiJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * configure release-please to use manifest Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: Anthonios Partheniou <[email protected]>
1 parent d9b2ff5 commit ce2c79a

File tree

21 files changed

+242
-70
lines changed

21 files changed

+242
-70
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
releaseType: python
22
handleGHRelease: true
3+
manifest: true
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
".": "0.9.4"
3+
}

packages/google-cloud-media-translation/docs/mediatranslation_v1beta1/types.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,4 @@ Types for Google Cloud Mediatranslation v1beta1 API
33

44
.. automodule:: google.cloud.mediatranslation_v1beta1.types
55
:members:
6-
:undoc-members:
76
:show-inheritance:

packages/google-cloud-media-translation/google/cloud/mediatranslation/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
#
16+
from google.cloud.mediatranslation import gapic_version as package_version
17+
18+
__version__ = package_version.__version__
19+
1620

1721
from google.cloud.mediatranslation_v1beta1.services.speech_translation_service.async_client import (
1822
SpeechTranslationServiceAsyncClient,
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# -*- coding: utf-8 -*-
2+
# Copyright 2022 Google LLC
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
__version__ = "0.9.4" # {x-release-please-version}

packages/google-cloud-media-translation/google/cloud/mediatranslation_v1beta1/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
#
16+
from google.cloud.mediatranslation import gapic_version as package_version
17+
18+
__version__ = package_version.__version__
19+
1620

1721
from .services.speech_translation_service import (
1822
SpeechTranslationServiceAsyncClient,

packages/google-cloud-media-translation/google/cloud/mediatranslation_v1beta1/services/speech_translation_service/async_client.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
Awaitable,
2323
Dict,
2424
Mapping,
25+
MutableMapping,
26+
MutableSequence,
2527
Optional,
2628
Sequence,
2729
Tuple,
@@ -174,9 +176,9 @@ def transport(self) -> SpeechTranslationServiceTransport:
174176
def __init__(
175177
self,
176178
*,
177-
credentials: ga_credentials.Credentials = None,
179+
credentials: Optional[ga_credentials.Credentials] = None,
178180
transport: Union[str, SpeechTranslationServiceTransport] = "grpc_asyncio",
179-
client_options: ClientOptions = None,
181+
client_options: Optional[ClientOptions] = None,
180182
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
181183
) -> None:
182184
"""Instantiates the speech translation service client.
@@ -220,12 +222,12 @@ def __init__(
220222

221223
def streaming_translate_speech(
222224
self,
223-
requests: AsyncIterator[
224-
media_translation.StreamingTranslateSpeechRequest
225+
requests: Optional[
226+
AsyncIterator[media_translation.StreamingTranslateSpeechRequest]
225227
] = None,
226228
*,
227229
retry: OptionalRetry = gapic_v1.method.DEFAULT,
228-
timeout: float = None,
230+
timeout: Optional[float] = None,
229231
metadata: Sequence[Tuple[str, str]] = (),
230232
) -> Awaitable[AsyncIterable[media_translation.StreamingTranslateSpeechResponse]]:
231233
r"""Performs bidirectional streaming speech translation:

packages/google-cloud-media-translation/google/cloud/mediatranslation_v1beta1/services/speech_translation_service/client.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,14 @@
2121
Iterable,
2222
Iterator,
2323
Mapping,
24+
MutableMapping,
25+
MutableSequence,
2426
Optional,
2527
Sequence,
2628
Tuple,
2729
Type,
2830
Union,
31+
cast,
2932
)
3033

3134
from google.api_core import client_options as client_options_lib
@@ -69,7 +72,7 @@ class SpeechTranslationServiceClientMeta(type):
6972

7073
def get_transport_class(
7174
cls,
72-
label: str = None,
75+
label: Optional[str] = None,
7376
) -> Type[SpeechTranslationServiceTransport]:
7477
"""Returns an appropriate transport class.
7578
@@ -322,8 +325,8 @@ def __init__(
322325
self,
323326
*,
324327
credentials: Optional[ga_credentials.Credentials] = None,
325-
transport: Union[str, SpeechTranslationServiceTransport, None] = None,
326-
client_options: Optional[client_options_lib.ClientOptions] = None,
328+
transport: Optional[Union[str, SpeechTranslationServiceTransport]] = None,
329+
client_options: Optional[Union[client_options_lib.ClientOptions, dict]] = None,
327330
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
328331
) -> None:
329332
"""Instantiates the speech translation service client.
@@ -337,7 +340,7 @@ def __init__(
337340
transport (Union[str, SpeechTranslationServiceTransport]): The
338341
transport to use. If set to None, a transport is chosen
339342
automatically.
340-
client_options (google.api_core.client_options.ClientOptions): Custom options for the
343+
client_options (Optional[Union[google.api_core.client_options.ClientOptions, dict]]): Custom options for the
341344
client. It won't take effect if a ``transport`` instance is provided.
342345
(1) The ``api_endpoint`` property can be used to override the
343346
default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT
@@ -367,6 +370,7 @@ def __init__(
367370
client_options = client_options_lib.from_dict(client_options)
368371
if client_options is None:
369372
client_options = client_options_lib.ClientOptions()
373+
client_options = cast(client_options_lib.ClientOptions, client_options)
370374

371375
api_endpoint, client_cert_source_func = self.get_mtls_endpoint_and_cert_source(
372376
client_options
@@ -419,10 +423,12 @@ def __init__(
419423

420424
def streaming_translate_speech(
421425
self,
422-
requests: Iterator[media_translation.StreamingTranslateSpeechRequest] = None,
426+
requests: Optional[
427+
Iterator[media_translation.StreamingTranslateSpeechRequest]
428+
] = None,
423429
*,
424430
retry: OptionalRetry = gapic_v1.method.DEFAULT,
425-
timeout: float = None,
431+
timeout: Optional[float] = None,
426432
metadata: Sequence[Tuple[str, str]] = (),
427433
) -> Iterable[media_translation.StreamingTranslateSpeechResponse]:
428434
r"""Performs bidirectional streaming speech translation:

packages/google-cloud-media-translation/google/cloud/mediatranslation_v1beta1/services/speech_translation_service/transports/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def __init__(
4848
self,
4949
*,
5050
host: str = DEFAULT_HOST,
51-
credentials: ga_credentials.Credentials = None,
51+
credentials: Optional[ga_credentials.Credentials] = None,
5252
credentials_file: Optional[str] = None,
5353
scopes: Optional[Sequence[str]] = None,
5454
quota_project_id: Optional[str] = None,

packages/google-cloud-media-translation/google/cloud/mediatranslation_v1beta1/services/speech_translation_service/transports/grpc.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,14 @@ def __init__(
4646
self,
4747
*,
4848
host: str = "mediatranslation.googleapis.com",
49-
credentials: ga_credentials.Credentials = None,
50-
credentials_file: str = None,
51-
scopes: Sequence[str] = None,
52-
channel: grpc.Channel = None,
53-
api_mtls_endpoint: str = None,
54-
client_cert_source: Callable[[], Tuple[bytes, bytes]] = None,
55-
ssl_channel_credentials: grpc.ChannelCredentials = None,
56-
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
49+
credentials: Optional[ga_credentials.Credentials] = None,
50+
credentials_file: Optional[str] = None,
51+
scopes: Optional[Sequence[str]] = None,
52+
channel: Optional[grpc.Channel] = None,
53+
api_mtls_endpoint: Optional[str] = None,
54+
client_cert_source: Optional[Callable[[], Tuple[bytes, bytes]]] = None,
55+
ssl_channel_credentials: Optional[grpc.ChannelCredentials] = None,
56+
client_cert_source_for_mtls: Optional[Callable[[], Tuple[bytes, bytes]]] = None,
5757
quota_project_id: Optional[str] = None,
5858
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
5959
always_use_jwt_access: Optional[bool] = False,
@@ -180,8 +180,8 @@ def __init__(
180180
def create_channel(
181181
cls,
182182
host: str = "mediatranslation.googleapis.com",
183-
credentials: ga_credentials.Credentials = None,
184-
credentials_file: str = None,
183+
credentials: Optional[ga_credentials.Credentials] = None,
184+
credentials_file: Optional[str] = None,
185185
scopes: Optional[Sequence[str]] = None,
186186
quota_project_id: Optional[str] = None,
187187
**kwargs,

packages/google-cloud-media-translation/google/cloud/mediatranslation_v1beta1/services/speech_translation_service/transports/grpc_asyncio.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class SpeechTranslationServiceGrpcAsyncIOTransport(SpeechTranslationServiceTrans
4848
def create_channel(
4949
cls,
5050
host: str = "mediatranslation.googleapis.com",
51-
credentials: ga_credentials.Credentials = None,
51+
credentials: Optional[ga_credentials.Credentials] = None,
5252
credentials_file: Optional[str] = None,
5353
scopes: Optional[Sequence[str]] = None,
5454
quota_project_id: Optional[str] = None,
@@ -91,15 +91,15 @@ def __init__(
9191
self,
9292
*,
9393
host: str = "mediatranslation.googleapis.com",
94-
credentials: ga_credentials.Credentials = None,
94+
credentials: Optional[ga_credentials.Credentials] = None,
9595
credentials_file: Optional[str] = None,
9696
scopes: Optional[Sequence[str]] = None,
97-
channel: aio.Channel = None,
98-
api_mtls_endpoint: str = None,
99-
client_cert_source: Callable[[], Tuple[bytes, bytes]] = None,
100-
ssl_channel_credentials: grpc.ChannelCredentials = None,
101-
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
102-
quota_project_id=None,
97+
channel: Optional[aio.Channel] = None,
98+
api_mtls_endpoint: Optional[str] = None,
99+
client_cert_source: Optional[Callable[[], Tuple[bytes, bytes]]] = None,
100+
ssl_channel_credentials: Optional[grpc.ChannelCredentials] = None,
101+
client_cert_source_for_mtls: Optional[Callable[[], Tuple[bytes, bytes]]] = None,
102+
quota_project_id: Optional[str] = None,
103103
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
104104
always_use_jwt_access: Optional[bool] = False,
105105
api_audience: Optional[str] = None,

packages/google-cloud-media-translation/google/cloud/mediatranslation_v1beta1/types/media_translation.py

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
#
16+
from typing import MutableMapping, MutableSequence
17+
1618
from google.rpc import status_pb2 # type: ignore
1719
import proto # type: ignore
1820

@@ -96,23 +98,23 @@ class TranslateSpeechConfig(proto.Message):
9698
model.
9799
"""
98100

99-
audio_encoding = proto.Field(
101+
audio_encoding: str = proto.Field(
100102
proto.STRING,
101103
number=1,
102104
)
103-
source_language_code = proto.Field(
105+
source_language_code: str = proto.Field(
104106
proto.STRING,
105107
number=2,
106108
)
107-
target_language_code = proto.Field(
109+
target_language_code: str = proto.Field(
108110
proto.STRING,
109111
number=3,
110112
)
111-
sample_rate_hertz = proto.Field(
113+
sample_rate_hertz: int = proto.Field(
112114
proto.INT32,
113115
number=4,
114116
)
115-
model = proto.Field(
117+
model: str = proto.Field(
116118
proto.STRING,
117119
number=5,
118120
)
@@ -147,12 +149,12 @@ class StreamingTranslateSpeechConfig(proto.Message):
147149
previous response is true).
148150
"""
149151

150-
audio_config = proto.Field(
152+
audio_config: "TranslateSpeechConfig" = proto.Field(
151153
proto.MESSAGE,
152154
number=1,
153155
message="TranslateSpeechConfig",
154156
)
155-
single_utterance = proto.Field(
157+
single_utterance: bool = proto.Field(
156158
proto.BOOL,
157159
number=2,
158160
)
@@ -197,13 +199,13 @@ class StreamingTranslateSpeechRequest(proto.Message):
197199
This field is a member of `oneof`_ ``streaming_request``.
198200
"""
199201

200-
streaming_config = proto.Field(
202+
streaming_config: "StreamingTranslateSpeechConfig" = proto.Field(
201203
proto.MESSAGE,
202204
number=1,
203205
oneof="streaming_request",
204206
message="StreamingTranslateSpeechConfig",
205207
)
206-
audio_content = proto.Field(
208+
audio_content: bytes = proto.Field(
207209
proto.BYTES,
208210
number=2,
209211
oneof="streaming_request",
@@ -240,16 +242,16 @@ class TextTranslationResult(proto.Message):
240242
the transcript and corresponding audio.
241243
"""
242244

243-
translation = proto.Field(
245+
translation: str = proto.Field(
244246
proto.STRING,
245247
number=1,
246248
)
247-
is_final = proto.Field(
249+
is_final: bool = proto.Field(
248250
proto.BOOL,
249251
number=2,
250252
)
251253

252-
text_translation_result = proto.Field(
254+
text_translation_result: TextTranslationResult = proto.Field(
253255
proto.MESSAGE,
254256
number=1,
255257
oneof="result",
@@ -279,17 +281,17 @@ class SpeechEventType(proto.Enum):
279281
SPEECH_EVENT_TYPE_UNSPECIFIED = 0
280282
END_OF_SINGLE_UTTERANCE = 1
281283

282-
error = proto.Field(
284+
error: status_pb2.Status = proto.Field(
283285
proto.MESSAGE,
284286
number=1,
285287
message=status_pb2.Status,
286288
)
287-
result = proto.Field(
289+
result: "StreamingTranslateSpeechResult" = proto.Field(
288290
proto.MESSAGE,
289291
number=2,
290292
message="StreamingTranslateSpeechResult",
291293
)
292-
speech_event_type = proto.Field(
294+
speech_event_type: SpeechEventType = proto.Field(
293295
proto.ENUM,
294296
number=3,
295297
enum=SpeechEventType,
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Copyright 2022 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
import json
16+
from pathlib import Path
17+
import shutil
18+
19+
import synthtool as s
20+
import synthtool.gcp as gcp
21+
from synthtool.languages import python
22+
23+
# ----------------------------------------------------------------------------
24+
# Copy the generated client from the owl-bot staging directory
25+
# ----------------------------------------------------------------------------
26+
27+
clean_up_generated_samples = True
28+
29+
# Load the default version defined in .repo-metadata.json.
30+
default_version = json.load(open(".repo-metadata.json", "rt")).get(
31+
"default_version"
32+
)
33+
34+
for library in s.get_staging_dirs(default_version):
35+
if clean_up_generated_samples:
36+
shutil.rmtree("samples/generated_samples", ignore_errors=True)
37+
clean_up_generated_samples = False
38+
s.move([library], excludes=["**/gapic_version.py"])
39+
s.remove_staging_dirs()
40+
41+
# ----------------------------------------------------------------------------
42+
# Add templated files
43+
# ----------------------------------------------------------------------------
44+
45+
templated_files = gcp.CommonTemplates().py_library(
46+
cov_level=100,
47+
microgenerator=True,
48+
versions=gcp.common.detect_versions(path="./google", default_first=True),
49+
)
50+
s.move(templated_files, excludes=[".coveragerc", ".github/release-please.yml"])
51+
52+
python.py_samples(skip_readmes=True)
53+
54+
# run format session for all directories which have a noxfile
55+
for noxfile in Path(".").glob("**/noxfile.py"):
56+
s.shell.run(["nox", "-s", "format"], cwd=noxfile.parent, hide_output=False)

0 commit comments

Comments
 (0)