Skip to content
This repository was archived by the owner on Nov 12, 2025. It is now read-only.

Commit 8c10713

Browse files
chore: upgrade gapic-generator-python to 0.43.1 (#164)
PiperOrigin-RevId: 364411656 Source-Author: Google APIs <noreply@google.com> Source-Date: Mon Mar 22 14:40:22 2021 -0700 Source-Repo: googleapis/googleapis Source-Sha: 149a3a84c29c9b8189576c7442ccb6dcf6a8f95b Source-Link: googleapis/googleapis@149a3a8
1 parent 2d98146 commit 8c10713

13 files changed

Lines changed: 288 additions & 426 deletions

File tree

google/cloud/bigquery_storage_v1/services/big_query_read/async_client.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,7 @@ async def create_read_session(
288288
predicate=retries.if_exception_type(
289289
exceptions.DeadlineExceeded, exceptions.ServiceUnavailable,
290290
),
291+
deadline=600.0,
291292
),
292293
default_timeout=600.0,
293294
client_info=DEFAULT_CLIENT_INFO,
@@ -386,6 +387,7 @@ def read_rows(
386387
maximum=60.0,
387388
multiplier=1.3,
388389
predicate=retries.if_exception_type(exceptions.ServiceUnavailable,),
390+
deadline=86400.0,
389391
),
390392
default_timeout=86400.0,
391393
client_info=DEFAULT_CLIENT_INFO,
@@ -457,6 +459,7 @@ async def split_read_stream(
457459
predicate=retries.if_exception_type(
458460
exceptions.DeadlineExceeded, exceptions.ServiceUnavailable,
459461
),
462+
deadline=600.0,
460463
),
461464
default_timeout=600.0,
462465
client_info=DEFAULT_CLIENT_INFO,

google/cloud/bigquery_storage_v1/services/big_query_read/transports/base.py

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

88+
# Save the scopes.
89+
self._scopes = scopes or self.AUTH_SCOPES
90+
8891
# If no credentials are provided, then determine the appropriate
8992
# defaults.
9093
if credentials and credentials_file:
@@ -94,20 +97,17 @@ def __init__(
9497

9598
if credentials_file is not None:
9699
credentials, _ = auth.load_credentials_from_file(
97-
credentials_file, scopes=scopes, quota_project_id=quota_project_id
100+
credentials_file, scopes=self._scopes, quota_project_id=quota_project_id
98101
)
99102

100103
elif credentials is None:
101104
credentials, _ = auth.default(
102-
scopes=scopes, quota_project_id=quota_project_id
105+
scopes=self._scopes, quota_project_id=quota_project_id
103106
)
104107

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

108-
# Lifted into its own function so it can be stubbed out during tests.
109-
self._prep_wrapped_messages(client_info)
110-
111111
def _prep_wrapped_messages(self, client_info):
112112
# Precompute the wrapped methods.
113113
self._wrapped_methods = {
@@ -120,6 +120,7 @@ def _prep_wrapped_messages(self, client_info):
120120
predicate=retries.if_exception_type(
121121
exceptions.DeadlineExceeded, exceptions.ServiceUnavailable,
122122
),
123+
deadline=600.0,
123124
),
124125
default_timeout=600.0,
125126
client_info=client_info,
@@ -131,6 +132,7 @@ def _prep_wrapped_messages(self, client_info):
131132
maximum=60.0,
132133
multiplier=1.3,
133134
predicate=retries.if_exception_type(exceptions.ServiceUnavailable,),
135+
deadline=86400.0,
134136
),
135137
default_timeout=86400.0,
136138
client_info=client_info,
@@ -144,6 +146,7 @@ def _prep_wrapped_messages(self, client_info):
144146
predicate=retries.if_exception_type(
145147
exceptions.DeadlineExceeded, exceptions.ServiceUnavailable,
146148
),
149+
deadline=600.0,
147150
),
148151
default_timeout=600.0,
149152
client_info=client_info,

google/cloud/bigquery_storage_v1/services/big_query_read/transports/grpc.py

Lines changed: 37 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -108,96 +108,69 @@ def __init__(
108108
google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials``
109109
and ``credentials_file`` are passed.
110110
"""
111+
self._grpc_channel = None
111112
self._ssl_channel_credentials = ssl_channel_credentials
113+
self._stubs: Dict[str, Callable] = {}
112114

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

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

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

165-
if credentials is None:
166-
credentials, _ = auth.default(
167-
scopes=self.AUTH_SCOPES, quota_project_id=quota_project_id
168-
)
141+
else:
142+
if client_cert_source_for_mtls and not ssl_channel_credentials:
143+
cert, key = client_cert_source_for_mtls()
144+
self._ssl_channel_credentials = grpc.ssl_channel_credentials(
145+
certificate_chain=cert, private_key=key
146+
)
169147

170-
if client_cert_source_for_mtls and not ssl_channel_credentials:
171-
cert, key = client_cert_source_for_mtls()
172-
self._ssl_channel_credentials = grpc.ssl_channel_credentials(
173-
certificate_chain=cert, private_key=key
174-
)
148+
# The base transport sets the host, credentials and scopes
149+
super().__init__(
150+
host=host,
151+
credentials=credentials,
152+
credentials_file=credentials_file,
153+
scopes=scopes,
154+
quota_project_id=quota_project_id,
155+
client_info=client_info,
156+
)
175157

176-
# create a new channel. The provided one is ignored.
158+
if not self._grpc_channel:
177159
self._grpc_channel = type(self).create_channel(
178-
host,
179-
credentials=credentials,
160+
self._host,
161+
credentials=self._credentials,
180162
credentials_file=credentials_file,
163+
scopes=self._scopes,
181164
ssl_credentials=self._ssl_channel_credentials,
182-
scopes=scopes or self.AUTH_SCOPES,
183165
quota_project_id=quota_project_id,
184166
options=[
185167
("grpc.max_send_message_length", -1),
186168
("grpc.max_receive_message_length", -1),
187169
],
188170
)
189171

190-
self._stubs = {} # type: Dict[str, Callable]
191-
192-
# Run the base constructor.
193-
super().__init__(
194-
host=host,
195-
credentials=credentials,
196-
credentials_file=credentials_file,
197-
scopes=scopes or self.AUTH_SCOPES,
198-
quota_project_id=quota_project_id,
199-
client_info=client_info,
200-
)
172+
# Wrap messages. This must be done after self._grpc_channel exists
173+
self._prep_wrapped_messages(client_info)
201174

202175
@classmethod
203176
def create_channel(
@@ -211,7 +184,7 @@ def create_channel(
211184
) -> grpc.Channel:
212185
"""Create and return a gRPC channel object.
213186
Args:
214-
address (Optional[str]): The host for the channel to use.
187+
host (Optional[str]): The host for the channel to use.
215188
credentials (Optional[~.Credentials]): The
216189
authorization credentials to attach to requests. These
217190
credentials identify this application to the service. If

google/cloud/bigquery_storage_v1/services/big_query_read/transports/grpc_asyncio.py

Lines changed: 41 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def create_channel(
6363
) -> aio.Channel:
6464
"""Create and return a gRPC AsyncIO channel object.
6565
Args:
66-
address (Optional[str]): The host for the channel to use.
66+
host (Optional[str]): The host for the channel to use.
6767
credentials (Optional[~.Credentials]): The
6868
authorization credentials to attach to requests. These
6969
credentials identify this application to the service. If
@@ -141,10 +141,10 @@ def __init__(
141141
ignored if ``channel`` or ``ssl_channel_credentials`` is provided.
142142
quota_project_id (Optional[str]): An optional project to use for billing
143143
and quota.
144-
client_info (google.api_core.gapic_v1.client_info.ClientInfo):
145-
The client info used to send a user-agent string along with
146-
API requests. If ``None``, then default info will be used.
147-
Generally, you only need to set this if you're developing
144+
client_info (google.api_core.gapic_v1.client_info.ClientInfo):
145+
The client info used to send a user-agent string along with
146+
API requests. If ``None``, then default info will be used.
147+
Generally, you only need to set this if you're developing
148148
your own client library.
149149
150150
Raises:
@@ -153,96 +153,69 @@ def __init__(
153153
google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials``
154154
and ``credentials_file`` are passed.
155155
"""
156+
self._grpc_channel = None
156157
self._ssl_channel_credentials = ssl_channel_credentials
158+
self._stubs: Dict[str, Callable] = {}
157159

158160
if api_mtls_endpoint:
159161
warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning)
160162
if client_cert_source:
161163
warnings.warn("client_cert_source is deprecated", DeprecationWarning)
162164

163165
if channel:
164-
# Sanity check: Ensure that channel and credentials are not both
165-
# provided.
166+
# Ignore credentials if a channel was passed.
166167
credentials = False
167-
168168
# If a channel was explicitly provided, set it.
169169
self._grpc_channel = channel
170170
self._ssl_channel_credentials = None
171-
elif api_mtls_endpoint:
172-
host = (
173-
api_mtls_endpoint
174-
if ":" in api_mtls_endpoint
175-
else api_mtls_endpoint + ":443"
176-
)
177-
178-
if credentials is None:
179-
credentials, _ = auth.default(
180-
scopes=self.AUTH_SCOPES, quota_project_id=quota_project_id
181-
)
182-
183-
# Create SSL credentials with client_cert_source or application
184-
# default SSL credentials.
185-
if client_cert_source:
186-
cert, key = client_cert_source()
187-
ssl_credentials = grpc.ssl_channel_credentials(
188-
certificate_chain=cert, private_key=key
189-
)
190-
else:
191-
ssl_credentials = SslCredentials().ssl_credentials
192171

193-
# create a new channel. The provided one is ignored.
194-
self._grpc_channel = type(self).create_channel(
195-
host,
196-
credentials=credentials,
197-
credentials_file=credentials_file,
198-
ssl_credentials=ssl_credentials,
199-
scopes=scopes or self.AUTH_SCOPES,
200-
quota_project_id=quota_project_id,
201-
options=[
202-
("grpc.max_send_message_length", -1),
203-
("grpc.max_receive_message_length", -1),
204-
],
205-
)
206-
self._ssl_channel_credentials = ssl_credentials
207172
else:
208-
host = host if ":" in host else host + ":443"
173+
if api_mtls_endpoint:
174+
host = api_mtls_endpoint
175+
176+
# Create SSL credentials with client_cert_source or application
177+
# default SSL credentials.
178+
if client_cert_source:
179+
cert, key = client_cert_source()
180+
self._ssl_channel_credentials = grpc.ssl_channel_credentials(
181+
certificate_chain=cert, private_key=key
182+
)
183+
else:
184+
self._ssl_channel_credentials = SslCredentials().ssl_credentials
209185

210-
if credentials is None:
211-
credentials, _ = auth.default(
212-
scopes=self.AUTH_SCOPES, quota_project_id=quota_project_id
213-
)
186+
else:
187+
if client_cert_source_for_mtls and not ssl_channel_credentials:
188+
cert, key = client_cert_source_for_mtls()
189+
self._ssl_channel_credentials = grpc.ssl_channel_credentials(
190+
certificate_chain=cert, private_key=key
191+
)
214192

215-
if client_cert_source_for_mtls and not ssl_channel_credentials:
216-
cert, key = client_cert_source_for_mtls()
217-
self._ssl_channel_credentials = grpc.ssl_channel_credentials(
218-
certificate_chain=cert, private_key=key
219-
)
193+
# The base transport sets the host, credentials and scopes
194+
super().__init__(
195+
host=host,
196+
credentials=credentials,
197+
credentials_file=credentials_file,
198+
scopes=scopes,
199+
quota_project_id=quota_project_id,
200+
client_info=client_info,
201+
)
220202

221-
# create a new channel. The provided one is ignored.
203+
if not self._grpc_channel:
222204
self._grpc_channel = type(self).create_channel(
223-
host,
224-
credentials=credentials,
205+
self._host,
206+
credentials=self._credentials,
225207
credentials_file=credentials_file,
208+
scopes=self._scopes,
226209
ssl_credentials=self._ssl_channel_credentials,
227-
scopes=scopes or self.AUTH_SCOPES,
228210
quota_project_id=quota_project_id,
229211
options=[
230212
("grpc.max_send_message_length", -1),
231213
("grpc.max_receive_message_length", -1),
232214
],
233215
)
234216

235-
# Run the base constructor.
236-
super().__init__(
237-
host=host,
238-
credentials=credentials,
239-
credentials_file=credentials_file,
240-
scopes=scopes or self.AUTH_SCOPES,
241-
quota_project_id=quota_project_id,
242-
client_info=client_info,
243-
)
244-
245-
self._stubs = {}
217+
# Wrap messages. This must be done after self._grpc_channel exists
218+
self._prep_wrapped_messages(client_info)
246219

247220
@property
248221
def grpc_channel(self) -> aio.Channel:

0 commit comments

Comments
 (0)