Skip to content

Commit 0e9fe54

Browse files
deps: upgrade gapic-generator-python to 0.43.1 (#276)
* build: use gapic-generator-typescript v1.2.11. Fixed IAM v1 library generation. Committer: @alexander-fenster PiperOrigin-RevId: 361676678 Source-Author: Google APIs <[email protected]> Source-Date: Mon Mar 8 15:51:18 2021 -0800 Source-Repo: googleapis/googleapis Source-Sha: 3aeb3a70f66457a9e6b07caff841719bb9873b57 Source-Link: googleapis/googleapis@3aeb3a7 * chore: upgrade gapic-generator-python to 0.43.1 PiperOrigin-RevId: 364411656 Source-Author: Google APIs <[email protected]> Source-Date: Mon Mar 22 14:40:22 2021 -0700 Source-Repo: googleapis/googleapis Source-Sha: 149a3a84c29c9b8189576c7442ccb6dcf6a8f95b Source-Link: googleapis/googleapis@149a3a8 * feat: add `kind` field which is used to distinguish between response types feat: add `potentially_thresholded_requests_per_hour` field to `PropertyQuota` PiperOrigin-RevId: 365882072 Source-Author: Google APIs <[email protected]> Source-Date: Tue Mar 30 13:17:13 2021 -0700 Source-Repo: googleapis/googleapis Source-Sha: 95dd24960cf9f794ef583e59ad9f1fabe1c4a924 Source-Link: googleapis/googleapis@95dd249
1 parent c4564d1 commit 0e9fe54

File tree

13 files changed

+323
-429
lines changed

13 files changed

+323
-429
lines changed

google/cloud/bigtable_admin_v2/services/bigtable_instance_admin/async_client.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,7 @@ async def get_instance(
387387
predicate=retries.if_exception_type(
388388
exceptions.DeadlineExceeded, exceptions.ServiceUnavailable,
389389
),
390+
deadline=60.0,
390391
),
391392
default_timeout=60.0,
392393
client_info=DEFAULT_CLIENT_INFO,
@@ -469,6 +470,7 @@ async def list_instances(
469470
predicate=retries.if_exception_type(
470471
exceptions.DeadlineExceeded, exceptions.ServiceUnavailable,
471472
),
473+
deadline=60.0,
472474
),
473475
default_timeout=60.0,
474476
client_info=DEFAULT_CLIENT_INFO,
@@ -538,6 +540,7 @@ async def update_instance(
538540
predicate=retries.if_exception_type(
539541
exceptions.DeadlineExceeded, exceptions.ServiceUnavailable,
540542
),
543+
deadline=60.0,
541544
),
542545
default_timeout=60.0,
543546
client_info=DEFAULT_CLIENT_INFO,
@@ -637,6 +640,7 @@ async def partial_update_instance(
637640
predicate=retries.if_exception_type(
638641
exceptions.DeadlineExceeded, exceptions.ServiceUnavailable,
639642
),
643+
deadline=60.0,
640644
),
641645
default_timeout=60.0,
642646
client_info=DEFAULT_CLIENT_INFO,
@@ -906,6 +910,7 @@ async def get_cluster(
906910
predicate=retries.if_exception_type(
907911
exceptions.DeadlineExceeded, exceptions.ServiceUnavailable,
908912
),
913+
deadline=60.0,
909914
),
910915
default_timeout=60.0,
911916
client_info=DEFAULT_CLIENT_INFO,
@@ -990,6 +995,7 @@ async def list_clusters(
990995
predicate=retries.if_exception_type(
991996
exceptions.DeadlineExceeded, exceptions.ServiceUnavailable,
992997
),
998+
deadline=60.0,
993999
),
9941000
default_timeout=60.0,
9951001
client_info=DEFAULT_CLIENT_INFO,
@@ -1055,6 +1061,7 @@ async def update_cluster(
10551061
predicate=retries.if_exception_type(
10561062
exceptions.DeadlineExceeded, exceptions.ServiceUnavailable,
10571063
),
1064+
deadline=60.0,
10581065
),
10591066
default_timeout=60.0,
10601067
client_info=DEFAULT_CLIENT_INFO,
@@ -1310,6 +1317,7 @@ async def get_app_profile(
13101317
predicate=retries.if_exception_type(
13111318
exceptions.DeadlineExceeded, exceptions.ServiceUnavailable,
13121319
),
1320+
deadline=60.0,
13131321
),
13141322
default_timeout=60.0,
13151323
client_info=DEFAULT_CLIENT_INFO,
@@ -1398,6 +1406,7 @@ async def list_app_profiles(
13981406
predicate=retries.if_exception_type(
13991407
exceptions.DeadlineExceeded, exceptions.ServiceUnavailable,
14001408
),
1409+
deadline=60.0,
14011410
),
14021411
default_timeout=60.0,
14031412
client_info=DEFAULT_CLIENT_INFO,
@@ -1498,6 +1507,7 @@ async def update_app_profile(
14981507
predicate=retries.if_exception_type(
14991508
exceptions.DeadlineExceeded, exceptions.ServiceUnavailable,
15001509
),
1510+
deadline=60.0,
15011511
),
15021512
default_timeout=60.0,
15031513
client_info=DEFAULT_CLIENT_INFO,
@@ -1713,6 +1723,7 @@ async def get_iam_policy(
17131723
predicate=retries.if_exception_type(
17141724
exceptions.DeadlineExceeded, exceptions.ServiceUnavailable,
17151725
),
1726+
deadline=60.0,
17161727
),
17171728
default_timeout=60.0,
17181729
client_info=DEFAULT_CLIENT_INFO,
@@ -1936,6 +1947,7 @@ async def test_iam_permissions(
19361947
predicate=retries.if_exception_type(
19371948
exceptions.DeadlineExceeded, exceptions.ServiceUnavailable,
19381949
),
1950+
deadline=60.0,
19391951
),
19401952
default_timeout=60.0,
19411953
client_info=DEFAULT_CLIENT_INFO,

google/cloud/bigtable_admin_v2/services/bigtable_instance_admin/transports/base.py

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -83,17 +83,20 @@ def __init__(
8383
scope (Optional[Sequence[str]]): A list of scopes.
8484
quota_project_id (Optional[str]): An optional project to use for billing
8585
and quota.
86-
client_info (google.api_core.gapic_v1.client_info.ClientInfo):
87-
The client info used to send a user-agent string along with
88-
API requests. If ``None``, then default info will be used.
89-
Generally, you only need to set this if you're developing
86+
client_info (google.api_core.gapic_v1.client_info.ClientInfo):
87+
The client info used to send a user-agent string along with
88+
API requests. If ``None``, then default info will be used.
89+
Generally, you only need to set this if you're developing
9090
your own client library.
9191
"""
9292
# Save the hostname. Default to port 443 (HTTPS) if none is specified.
9393
if ":" not in host:
9494
host += ":443"
9595
self._host = host
9696

97+
# Save the scopes.
98+
self._scopes = scopes or self.AUTH_SCOPES
99+
97100
# If no credentials are provided, then determine the appropriate
98101
# defaults.
99102
if credentials and credentials_file:
@@ -103,20 +106,17 @@ def __init__(
103106

104107
if credentials_file is not None:
105108
credentials, _ = auth.load_credentials_from_file(
106-
credentials_file, scopes=scopes, quota_project_id=quota_project_id
109+
credentials_file, scopes=self._scopes, quota_project_id=quota_project_id
107110
)
108111

109112
elif credentials is None:
110113
credentials, _ = auth.default(
111-
scopes=scopes, quota_project_id=quota_project_id
114+
scopes=self._scopes, quota_project_id=quota_project_id
112115
)
113116

114117
# Save the credentials.
115118
self._credentials = credentials
116119

117-
# Lifted into its own function so it can be stubbed out during tests.
118-
self._prep_wrapped_messages(client_info)
119-
120120
def _prep_wrapped_messages(self, client_info):
121121
# Precompute the wrapped methods.
122122
self._wrapped_methods = {
@@ -132,6 +132,7 @@ def _prep_wrapped_messages(self, client_info):
132132
predicate=retries.if_exception_type(
133133
exceptions.DeadlineExceeded, exceptions.ServiceUnavailable,
134134
),
135+
deadline=60.0,
135136
),
136137
default_timeout=60.0,
137138
client_info=client_info,
@@ -145,6 +146,7 @@ def _prep_wrapped_messages(self, client_info):
145146
predicate=retries.if_exception_type(
146147
exceptions.DeadlineExceeded, exceptions.ServiceUnavailable,
147148
),
149+
deadline=60.0,
148150
),
149151
default_timeout=60.0,
150152
client_info=client_info,
@@ -158,6 +160,7 @@ def _prep_wrapped_messages(self, client_info):
158160
predicate=retries.if_exception_type(
159161
exceptions.DeadlineExceeded, exceptions.ServiceUnavailable,
160162
),
163+
deadline=60.0,
161164
),
162165
default_timeout=60.0,
163166
client_info=client_info,
@@ -171,6 +174,7 @@ def _prep_wrapped_messages(self, client_info):
171174
predicate=retries.if_exception_type(
172175
exceptions.DeadlineExceeded, exceptions.ServiceUnavailable,
173176
),
177+
deadline=60.0,
174178
),
175179
default_timeout=60.0,
176180
client_info=client_info,
@@ -190,6 +194,7 @@ def _prep_wrapped_messages(self, client_info):
190194
predicate=retries.if_exception_type(
191195
exceptions.DeadlineExceeded, exceptions.ServiceUnavailable,
192196
),
197+
deadline=60.0,
193198
),
194199
default_timeout=60.0,
195200
client_info=client_info,
@@ -203,6 +208,7 @@ def _prep_wrapped_messages(self, client_info):
203208
predicate=retries.if_exception_type(
204209
exceptions.DeadlineExceeded, exceptions.ServiceUnavailable,
205210
),
211+
deadline=60.0,
206212
),
207213
default_timeout=60.0,
208214
client_info=client_info,
@@ -216,6 +222,7 @@ def _prep_wrapped_messages(self, client_info):
216222
predicate=retries.if_exception_type(
217223
exceptions.DeadlineExceeded, exceptions.ServiceUnavailable,
218224
),
225+
deadline=60.0,
219226
),
220227
default_timeout=60.0,
221228
client_info=client_info,
@@ -235,6 +242,7 @@ def _prep_wrapped_messages(self, client_info):
235242
predicate=retries.if_exception_type(
236243
exceptions.DeadlineExceeded, exceptions.ServiceUnavailable,
237244
),
245+
deadline=60.0,
238246
),
239247
default_timeout=60.0,
240248
client_info=client_info,
@@ -248,6 +256,7 @@ def _prep_wrapped_messages(self, client_info):
248256
predicate=retries.if_exception_type(
249257
exceptions.DeadlineExceeded, exceptions.ServiceUnavailable,
250258
),
259+
deadline=60.0,
251260
),
252261
default_timeout=60.0,
253262
client_info=client_info,
@@ -261,6 +270,7 @@ def _prep_wrapped_messages(self, client_info):
261270
predicate=retries.if_exception_type(
262271
exceptions.DeadlineExceeded, exceptions.ServiceUnavailable,
263272
),
273+
deadline=60.0,
264274
),
265275
default_timeout=60.0,
266276
client_info=client_info,
@@ -277,6 +287,7 @@ def _prep_wrapped_messages(self, client_info):
277287
predicate=retries.if_exception_type(
278288
exceptions.DeadlineExceeded, exceptions.ServiceUnavailable,
279289
),
290+
deadline=60.0,
280291
),
281292
default_timeout=60.0,
282293
client_info=client_info,
@@ -293,6 +304,7 @@ def _prep_wrapped_messages(self, client_info):
293304
predicate=retries.if_exception_type(
294305
exceptions.DeadlineExceeded, exceptions.ServiceUnavailable,
295306
),
307+
deadline=60.0,
296308
),
297309
default_timeout=60.0,
298310
client_info=client_info,

google/cloud/bigtable_admin_v2/services/bigtable_instance_admin/transports/grpc.py

Lines changed: 38 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -115,97 +115,70 @@ def __init__(
115115
google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials``
116116
and ``credentials_file`` are passed.
117117
"""
118+
self._grpc_channel = None
118119
self._ssl_channel_credentials = ssl_channel_credentials
120+
self._stubs: Dict[str, Callable] = {}
121+
self._operations_client = None
119122

120123
if api_mtls_endpoint:
121124
warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning)
122125
if client_cert_source:
123126
warnings.warn("client_cert_source is deprecated", DeprecationWarning)
124127

125128
if channel:
126-
# Sanity check: Ensure that channel and credentials are not both
127-
# provided.
129+
# Ignore credentials if a channel was passed.
128130
credentials = False
129-
130131
# If a channel was explicitly provided, set it.
131132
self._grpc_channel = channel
132133
self._ssl_channel_credentials = None
133-
elif api_mtls_endpoint:
134-
host = (
135-
api_mtls_endpoint
136-
if ":" in api_mtls_endpoint
137-
else api_mtls_endpoint + ":443"
138-
)
139-
140-
if credentials is None:
141-
credentials, _ = auth.default(
142-
scopes=self.AUTH_SCOPES, quota_project_id=quota_project_id
143-
)
144-
145-
# Create SSL credentials with client_cert_source or application
146-
# default SSL credentials.
147-
if client_cert_source:
148-
cert, key = client_cert_source()
149-
ssl_credentials = grpc.ssl_channel_credentials(
150-
certificate_chain=cert, private_key=key
151-
)
152-
else:
153-
ssl_credentials = SslCredentials().ssl_credentials
154134

155-
# create a new channel. The provided one is ignored.
156-
self._grpc_channel = type(self).create_channel(
157-
host,
158-
credentials=credentials,
159-
credentials_file=credentials_file,
160-
ssl_credentials=ssl_credentials,
161-
scopes=scopes or self.AUTH_SCOPES,
162-
quota_project_id=quota_project_id,
163-
options=[
164-
("grpc.max_send_message_length", -1),
165-
("grpc.max_receive_message_length", -1),
166-
],
167-
)
168-
self._ssl_channel_credentials = ssl_credentials
169135
else:
170-
host = host if ":" in host else host + ":443"
136+
if api_mtls_endpoint:
137+
host = api_mtls_endpoint
138+
139+
# Create SSL credentials with client_cert_source or application
140+
# default SSL credentials.
141+
if client_cert_source:
142+
cert, key = client_cert_source()
143+
self._ssl_channel_credentials = grpc.ssl_channel_credentials(
144+
certificate_chain=cert, private_key=key
145+
)
146+
else:
147+
self._ssl_channel_credentials = SslCredentials().ssl_credentials
171148

172-
if credentials is None:
173-
credentials, _ = auth.default(
174-
scopes=self.AUTH_SCOPES, quota_project_id=quota_project_id
175-
)
149+
else:
150+
if client_cert_source_for_mtls and not ssl_channel_credentials:
151+
cert, key = client_cert_source_for_mtls()
152+
self._ssl_channel_credentials = grpc.ssl_channel_credentials(
153+
certificate_chain=cert, private_key=key
154+
)
176155

177-
if client_cert_source_for_mtls and not ssl_channel_credentials:
178-
cert, key = client_cert_source_for_mtls()
179-
self._ssl_channel_credentials = grpc.ssl_channel_credentials(
180-
certificate_chain=cert, private_key=key
181-
)
156+
# The base transport sets the host, credentials and scopes
157+
super().__init__(
158+
host=host,
159+
credentials=credentials,
160+
credentials_file=credentials_file,
161+
scopes=scopes,
162+
quota_project_id=quota_project_id,
163+
client_info=client_info,
164+
)
182165

183-
# create a new channel. The provided one is ignored.
166+
if not self._grpc_channel:
184167
self._grpc_channel = type(self).create_channel(
185-
host,
186-
credentials=credentials,
168+
self._host,
169+
credentials=self._credentials,
187170
credentials_file=credentials_file,
171+
scopes=self._scopes,
188172
ssl_credentials=self._ssl_channel_credentials,
189-
scopes=scopes or self.AUTH_SCOPES,
190173
quota_project_id=quota_project_id,
191174
options=[
192175
("grpc.max_send_message_length", -1),
193176
("grpc.max_receive_message_length", -1),
194177
],
195178
)
196179

197-
self._stubs = {} # type: Dict[str, Callable]
198-
self._operations_client = None
199-
200-
# Run the base constructor.
201-
super().__init__(
202-
host=host,
203-
credentials=credentials,
204-
credentials_file=credentials_file,
205-
scopes=scopes or self.AUTH_SCOPES,
206-
quota_project_id=quota_project_id,
207-
client_info=client_info,
208-
)
180+
# Wrap messages. This must be done after self._grpc_channel exists
181+
self._prep_wrapped_messages(client_info)
209182

210183
@classmethod
211184
def create_channel(
@@ -219,7 +192,7 @@ def create_channel(
219192
) -> grpc.Channel:
220193
"""Create and return a gRPC channel object.
221194
Args:
222-
address (Optional[str]): The host for the channel to use.
195+
host (Optional[str]): The host for the channel to use.
223196
credentials (Optional[~.Credentials]): The
224197
authorization credentials to attach to requests. These
225198
credentials identify this application to the service. If

0 commit comments

Comments
 (0)