Skip to content

Commit afec81e

Browse files
authored
chore: regenerate GAPIC layer with latest changes (#345)
1 parent 3e1ed13 commit afec81e

17 files changed

Lines changed: 414 additions & 639 deletions

File tree

packages/google-cloud-pubsub/.kokoro/test-samples-against-head.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
2-
# Copyright 2021 Google LLC
2+
# Copyright 2020 Google LLC
33
#
44
# Licensed under the Apache License, Version 2.0 (the "License");
55
# you may not use this file except in compliance with the License.

packages/google-cloud-pubsub/google/pubsub_v1/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,14 +110,14 @@
110110
"ModifyPushConfigRequest",
111111
"PublishRequest",
112112
"PublishResponse",
113-
"PublisherClient",
114113
"PubsubMessage",
115114
"PullRequest",
116115
"PullResponse",
117116
"PushConfig",
118117
"ReceivedMessage",
119118
"RetryPolicy",
120119
"Schema",
120+
"SchemaServiceClient",
121121
"SchemaSettings",
122122
"SchemaView",
123123
"SeekRequest",
@@ -135,5 +135,5 @@
135135
"ValidateMessageResponse",
136136
"ValidateSchemaRequest",
137137
"ValidateSchemaResponse",
138-
"SchemaServiceClient",
138+
"PublisherClient",
139139
)

packages/google-cloud-pubsub/google/pubsub_v1/services/publisher/async_client.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ async def create_topic(
238238
maximum=60.0,
239239
multiplier=1.3,
240240
predicate=retries.if_exception_type(exceptions.ServiceUnavailable,),
241+
deadline=60.0,
241242
),
242243
default_timeout=60.0,
243244
client_info=DEFAULT_CLIENT_INFO,
@@ -293,6 +294,7 @@ async def update_topic(
293294
maximum=60.0,
294295
multiplier=1.3,
295296
predicate=retries.if_exception_type(exceptions.ServiceUnavailable,),
297+
deadline=60.0,
296298
),
297299
default_timeout=60.0,
298300
client_info=DEFAULT_CLIENT_INFO,
@@ -390,6 +392,7 @@ async def publish(
390392
exceptions.ServiceUnavailable,
391393
exceptions.Unknown,
392394
),
395+
deadline=60.0,
393396
),
394397
default_timeout=60.0,
395398
client_info=DEFAULT_CLIENT_INFO,
@@ -470,6 +473,7 @@ async def get_topic(
470473
exceptions.ServiceUnavailable,
471474
exceptions.Unknown,
472475
),
476+
deadline=60.0,
473477
),
474478
default_timeout=60.0,
475479
client_info=DEFAULT_CLIENT_INFO,
@@ -554,6 +558,7 @@ async def list_topics(
554558
exceptions.ServiceUnavailable,
555559
exceptions.Unknown,
556560
),
561+
deadline=60.0,
557562
),
558563
default_timeout=60.0,
559564
client_info=DEFAULT_CLIENT_INFO,
@@ -647,6 +652,7 @@ async def list_topic_subscriptions(
647652
exceptions.ServiceUnavailable,
648653
exceptions.Unknown,
649654
),
655+
deadline=60.0,
650656
),
651657
default_timeout=60.0,
652658
client_info=DEFAULT_CLIENT_INFO,
@@ -744,6 +750,7 @@ async def list_topic_snapshots(
744750
exceptions.ServiceUnavailable,
745751
exceptions.Unknown,
746752
),
753+
deadline=60.0,
747754
),
748755
default_timeout=60.0,
749756
client_info=DEFAULT_CLIENT_INFO,
@@ -828,6 +835,7 @@ async def delete_topic(
828835
maximum=60.0,
829836
multiplier=1.3,
830837
predicate=retries.if_exception_type(exceptions.ServiceUnavailable,),
838+
deadline=60.0,
831839
),
832840
default_timeout=60.0,
833841
client_info=DEFAULT_CLIENT_INFO,
@@ -888,6 +896,7 @@ async def detach_subscription(
888896
maximum=60.0,
889897
multiplier=1.3,
890898
predicate=retries.if_exception_type(exceptions.ServiceUnavailable,),
899+
deadline=60.0,
891900
),
892901
default_timeout=60.0,
893902
client_info=DEFAULT_CLIENT_INFO,

packages/google-cloud-pubsub/google/pubsub_v1/services/publisher/transports/base.py

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -75,17 +75,20 @@ def __init__(
7575
scope (Optional[Sequence[str]]): A list of scopes.
7676
quota_project_id (Optional[str]): An optional project to use for billing
7777
and quota.
78-
client_info (google.api_core.gapic_v1.client_info.ClientInfo):
79-
The client info used to send a user-agent string along with
80-
API requests. If ``None``, then default info will be used.
81-
Generally, you only need to set this if you're developing
78+
client_info (google.api_core.gapic_v1.client_info.ClientInfo):
79+
The client info used to send a user-agent string along with
80+
API requests. If ``None``, then default info will be used.
81+
Generally, you only need to set this if you're developing
8282
your own client library.
8383
"""
8484
# Save the hostname. Default to port 443 (HTTPS) if none is specified.
8585
if ":" not in host:
8686
host += ":443"
8787
self._host = host
8888

89+
# Save the scopes.
90+
self._scopes = scopes or self.AUTH_SCOPES
91+
8992
# If no credentials are provided, then determine the appropriate
9093
# defaults.
9194
if credentials and credentials_file:
@@ -95,20 +98,17 @@ def __init__(
9598

9699
if credentials_file is not None:
97100
credentials, _ = auth.load_credentials_from_file(
98-
credentials_file, scopes=scopes, quota_project_id=quota_project_id
101+
credentials_file, scopes=self._scopes, quota_project_id=quota_project_id
99102
)
100103

101104
elif credentials is None:
102105
credentials, _ = auth.default(
103-
scopes=scopes, quota_project_id=quota_project_id
106+
scopes=self._scopes, quota_project_id=quota_project_id
104107
)
105108

106109
# Save the credentials.
107110
self._credentials = credentials
108111

109-
# Lifted into its own function so it can be stubbed out during tests.
110-
self._prep_wrapped_messages(client_info)
111-
112112
def _prep_wrapped_messages(self, client_info):
113113
# Precompute the wrapped methods.
114114
self._wrapped_methods = {
@@ -119,6 +119,7 @@ def _prep_wrapped_messages(self, client_info):
119119
maximum=60.0,
120120
multiplier=1.3,
121121
predicate=retries.if_exception_type(exceptions.ServiceUnavailable,),
122+
deadline=60.0,
122123
),
123124
default_timeout=60.0,
124125
client_info=client_info,
@@ -130,6 +131,7 @@ def _prep_wrapped_messages(self, client_info):
130131
maximum=60.0,
131132
multiplier=1.3,
132133
predicate=retries.if_exception_type(exceptions.ServiceUnavailable,),
134+
deadline=60.0,
133135
),
134136
default_timeout=60.0,
135137
client_info=client_info,
@@ -149,6 +151,7 @@ def _prep_wrapped_messages(self, client_info):
149151
exceptions.ServiceUnavailable,
150152
exceptions.Unknown,
151153
),
154+
deadline=60.0,
152155
),
153156
default_timeout=60.0,
154157
client_info=client_info,
@@ -164,6 +167,7 @@ def _prep_wrapped_messages(self, client_info):
164167
exceptions.ServiceUnavailable,
165168
exceptions.Unknown,
166169
),
170+
deadline=60.0,
167171
),
168172
default_timeout=60.0,
169173
client_info=client_info,
@@ -179,6 +183,7 @@ def _prep_wrapped_messages(self, client_info):
179183
exceptions.ServiceUnavailable,
180184
exceptions.Unknown,
181185
),
186+
deadline=60.0,
182187
),
183188
default_timeout=60.0,
184189
client_info=client_info,
@@ -194,6 +199,7 @@ def _prep_wrapped_messages(self, client_info):
194199
exceptions.ServiceUnavailable,
195200
exceptions.Unknown,
196201
),
202+
deadline=60.0,
197203
),
198204
default_timeout=60.0,
199205
client_info=client_info,
@@ -209,6 +215,7 @@ def _prep_wrapped_messages(self, client_info):
209215
exceptions.ServiceUnavailable,
210216
exceptions.Unknown,
211217
),
218+
deadline=60.0,
212219
),
213220
default_timeout=60.0,
214221
client_info=client_info,
@@ -220,6 +227,7 @@ def _prep_wrapped_messages(self, client_info):
220227
maximum=60.0,
221228
multiplier=1.3,
222229
predicate=retries.if_exception_type(exceptions.ServiceUnavailable,),
230+
deadline=60.0,
223231
),
224232
default_timeout=60.0,
225233
client_info=client_info,
@@ -231,6 +239,7 @@ def _prep_wrapped_messages(self, client_info):
231239
maximum=60.0,
232240
multiplier=1.3,
233241
predicate=retries.if_exception_type(exceptions.ServiceUnavailable,),
242+
deadline=60.0,
234243
),
235244
default_timeout=60.0,
236245
client_info=client_info,

packages/google-cloud-pubsub/google/pubsub_v1/services/publisher/transports/grpc.py

Lines changed: 37 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -110,79 +110,60 @@ def __init__(
110110
google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials``
111111
and ``credentials_file`` are passed.
112112
"""
113+
self._grpc_channel = None
113114
self._ssl_channel_credentials = ssl_channel_credentials
115+
self._stubs: Dict[str, Callable] = {}
114116

115117
if api_mtls_endpoint:
116118
warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning)
117119
if client_cert_source:
118120
warnings.warn("client_cert_source is deprecated", DeprecationWarning)
119121

120122
if channel:
121-
# Sanity check: Ensure that channel and credentials are not both
122-
# provided.
123+
# Ignore credentials if a channel was passed.
123124
credentials = False
124-
125125
# If a channel was explicitly provided, set it.
126126
self._grpc_channel = channel
127127
self._ssl_channel_credentials = None
128-
elif api_mtls_endpoint:
129-
host = (
130-
api_mtls_endpoint
131-
if ":" in api_mtls_endpoint
132-
else api_mtls_endpoint + ":443"
133-
)
134-
135-
if credentials is None:
136-
credentials, _ = auth.default(
137-
scopes=self.AUTH_SCOPES, quota_project_id=quota_project_id
138-
)
139-
140-
# Create SSL credentials with client_cert_source or application
141-
# default SSL credentials.
142-
if client_cert_source:
143-
cert, key = client_cert_source()
144-
ssl_credentials = grpc.ssl_channel_credentials(
145-
certificate_chain=cert, private_key=key
146-
)
147-
else:
148-
ssl_credentials = SslCredentials().ssl_credentials
149128

150-
# create a new channel. The provided one is ignored.
151-
self._grpc_channel = type(self).create_channel(
152-
host,
153-
credentials=credentials,
154-
credentials_file=credentials_file,
155-
ssl_credentials=ssl_credentials,
156-
scopes=scopes or self.AUTH_SCOPES,
157-
quota_project_id=quota_project_id,
158-
options=[
159-
("grpc.max_send_message_length", -1),
160-
("grpc.max_receive_message_length", -1),
161-
("grpc.keepalive_time_ms", 30000),
162-
],
163-
)
164-
self._ssl_channel_credentials = ssl_credentials
165129
else:
166-
host = host if ":" in host else host + ":443"
130+
if api_mtls_endpoint:
131+
host = api_mtls_endpoint
132+
133+
# Create SSL credentials with client_cert_source or application
134+
# default SSL credentials.
135+
if client_cert_source:
136+
cert, key = client_cert_source()
137+
self._ssl_channel_credentials = grpc.ssl_channel_credentials(
138+
certificate_chain=cert, private_key=key
139+
)
140+
else:
141+
self._ssl_channel_credentials = SslCredentials().ssl_credentials
167142

168-
if credentials is None:
169-
credentials, _ = auth.default(
170-
scopes=self.AUTH_SCOPES, quota_project_id=quota_project_id
171-
)
143+
else:
144+
if client_cert_source_for_mtls and not ssl_channel_credentials:
145+
cert, key = client_cert_source_for_mtls()
146+
self._ssl_channel_credentials = grpc.ssl_channel_credentials(
147+
certificate_chain=cert, private_key=key
148+
)
172149

173-
if client_cert_source_for_mtls and not ssl_channel_credentials:
174-
cert, key = client_cert_source_for_mtls()
175-
self._ssl_channel_credentials = grpc.ssl_channel_credentials(
176-
certificate_chain=cert, private_key=key
177-
)
150+
# The base transport sets the host, credentials and scopes
151+
super().__init__(
152+
host=host,
153+
credentials=credentials,
154+
credentials_file=credentials_file,
155+
scopes=scopes,
156+
quota_project_id=quota_project_id,
157+
client_info=client_info,
158+
)
178159

179-
# create a new channel. The provided one is ignored.
160+
if not self._grpc_channel:
180161
self._grpc_channel = type(self).create_channel(
181-
host,
182-
credentials=credentials,
162+
self._host,
163+
credentials=self._credentials,
183164
credentials_file=credentials_file,
165+
scopes=self._scopes,
184166
ssl_credentials=self._ssl_channel_credentials,
185-
scopes=scopes or self.AUTH_SCOPES,
186167
quota_project_id=quota_project_id,
187168
options=[
188169
("grpc.max_send_message_length", -1),
@@ -191,17 +172,8 @@ def __init__(
191172
],
192173
)
193174

194-
self._stubs = {} # type: Dict[str, Callable]
195-
196-
# Run the base constructor.
197-
super().__init__(
198-
host=host,
199-
credentials=credentials,
200-
credentials_file=credentials_file,
201-
scopes=scopes or self.AUTH_SCOPES,
202-
quota_project_id=quota_project_id,
203-
client_info=client_info,
204-
)
175+
# Wrap messages. This must be done after self._grpc_channel exists
176+
self._prep_wrapped_messages(client_info)
205177

206178
@classmethod
207179
def create_channel(
@@ -215,7 +187,7 @@ def create_channel(
215187
) -> grpc.Channel:
216188
"""Create and return a gRPC channel object.
217189
Args:
218-
address (Optional[str]): The host for the channel to use.
190+
host (Optional[str]): The host for the channel to use.
219191
credentials (Optional[~.Credentials]): The
220192
authorization credentials to attach to requests. These
221193
credentials identify this application to the service. If

0 commit comments

Comments
 (0)