Skip to content

Commit de9c4c8

Browse files
chore: Re-generated to pick up changes from googleapis. (#171)
* changes without context autosynth cannot find the source of changes triggered by earlier changes in this repository, or by version upgrades to tools such as linters. * chore: update Go generator, rules_go, and protobuf PiperOrigin-RevId: 352816749 Source-Author: Google APIs <[email protected]> Source-Date: Wed Jan 20 10:06:23 2021 -0800 Source-Repo: googleapis/googleapis Source-Sha: ceaaf31b3d13badab7cf9d3b570f5639db5593d9 Source-Link: googleapis/googleapis@ceaaf31 * chore: upgrade gapic-generator-python to 0.40.5 PiperOrigin-RevId: 354996675 Source-Author: Google APIs <[email protected]> Source-Date: Mon Feb 1 12:11:49 2021 -0800 Source-Repo: googleapis/googleapis Source-Sha: 20712b8fe95001b312f62c6c5f33e3e3ec92cfaf Source-Link: googleapis/googleapis@20712b8 Co-authored-by: Daniel Sanche <[email protected]>
1 parent db9bcee commit de9c4c8

File tree

15 files changed

+469
-302
lines changed

15 files changed

+469
-302
lines changed

.kokoro/test-samples.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,11 @@ for file in samples/**/requirements.txt; do
8787
python3.6 -m nox -s "$RUN_TESTS_SESSION"
8888
EXIT=$?
8989

90-
# If this is a periodic build, send the test log to the FlakyBot.
91-
# See https://github.com/googleapis/repo-automation-bots/tree/master/packages/flakybot.
90+
# If this is a periodic build, send the test log to the Build Cop Bot.
91+
# See https://github.com/googleapis/repo-automation-bots/tree/master/packages/buildcop.
9292
if [[ $KOKORO_BUILD_ARTIFACTS_SUBDIR = *"periodic"* ]]; then
93-
chmod +x $KOKORO_GFILE_DIR/linux_amd64/flakybot
94-
$KOKORO_GFILE_DIR/linux_amd64/flakybot
93+
chmod +x $KOKORO_GFILE_DIR/linux_amd64/buildcop
94+
$KOKORO_GFILE_DIR/linux_amd64/buildcop
9595
fi
9696

9797
if [[ $EXIT -ne 0 ]]; then

.kokoro/trampoline_v2.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ if [[ -n "${KOKORO_BUILD_ID:-}" ]]; then
159159
"KOKORO_GITHUB_COMMIT"
160160
"KOKORO_GITHUB_PULL_REQUEST_NUMBER"
161161
"KOKORO_GITHUB_PULL_REQUEST_COMMIT"
162-
# For FlakyBot
162+
# For Build Cop Bot
163163
"KOKORO_GITHUB_COMMIT_URL"
164164
"KOKORO_GITHUB_PULL_REQUEST_URL"
165165
)

google/cloud/logging_v2/services/config_service_v2/client.py

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -338,21 +338,17 @@ def __init__(
338338
util.strtobool(os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false"))
339339
)
340340

341-
ssl_credentials = None
341+
client_cert_source_func = None
342342
is_mtls = False
343343
if use_client_cert:
344344
if client_options.client_cert_source:
345-
import grpc # type: ignore
346-
347-
cert, key = client_options.client_cert_source()
348-
ssl_credentials = grpc.ssl_channel_credentials(
349-
certificate_chain=cert, private_key=key
350-
)
351345
is_mtls = True
346+
client_cert_source_func = client_options.client_cert_source
352347
else:
353-
creds = SslCredentials()
354-
is_mtls = creds.is_mtls
355-
ssl_credentials = creds.ssl_credentials if is_mtls else None
348+
is_mtls = mtls.has_default_client_cert_source()
349+
client_cert_source_func = (
350+
mtls.default_client_cert_source() if is_mtls else None
351+
)
356352

357353
# Figure out which api endpoint to use.
358354
if client_options.api_endpoint is not None:
@@ -395,7 +391,7 @@ def __init__(
395391
credentials_file=client_options.credentials_file,
396392
host=api_endpoint,
397393
scopes=client_options.scopes,
398-
ssl_channel_credentials=ssl_credentials,
394+
client_cert_source_for_mtls=client_cert_source_func,
399395
quota_project_id=client_options.quota_project_id,
400396
client_info=client_info,
401397
)

google/cloud/logging_v2/services/config_service_v2/transports/grpc.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ def __init__(
5858
api_mtls_endpoint: str = None,
5959
client_cert_source: Callable[[], Tuple[bytes, bytes]] = None,
6060
ssl_channel_credentials: grpc.ChannelCredentials = None,
61+
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
6162
quota_project_id: Optional[str] = None,
6263
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
6364
) -> None:
@@ -88,6 +89,10 @@ def __init__(
8889
``api_mtls_endpoint`` is None.
8990
ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials
9091
for grpc channel. It is ignored if ``channel`` is provided.
92+
client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]):
93+
A callback to provide client certificate bytes and private key bytes,
94+
both in PEM format. It is used to configure mutual TLS channel. It is
95+
ignored if ``channel`` or ``ssl_channel_credentials`` is provided.
9196
quota_project_id (Optional[str]): An optional project to use for billing
9297
and quota.
9398
client_info (google.api_core.gapic_v1.client_info.ClientInfo):
@@ -104,6 +109,11 @@ def __init__(
104109
"""
105110
self._ssl_channel_credentials = ssl_channel_credentials
106111

112+
if api_mtls_endpoint:
113+
warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning)
114+
if client_cert_source:
115+
warnings.warn("client_cert_source is deprecated", DeprecationWarning)
116+
107117
if channel:
108118
# Sanity check: Ensure that channel and credentials are not both
109119
# provided.
@@ -113,11 +123,6 @@ def __init__(
113123
self._grpc_channel = channel
114124
self._ssl_channel_credentials = None
115125
elif api_mtls_endpoint:
116-
warnings.warn(
117-
"api_mtls_endpoint and client_cert_source are deprecated",
118-
DeprecationWarning,
119-
)
120-
121126
host = (
122127
api_mtls_endpoint
123128
if ":" in api_mtls_endpoint
@@ -161,12 +166,18 @@ def __init__(
161166
scopes=self.AUTH_SCOPES, quota_project_id=quota_project_id
162167
)
163168

169+
if client_cert_source_for_mtls and not ssl_channel_credentials:
170+
cert, key = client_cert_source_for_mtls()
171+
self._ssl_channel_credentials = grpc.ssl_channel_credentials(
172+
certificate_chain=cert, private_key=key
173+
)
174+
164175
# create a new channel. The provided one is ignored.
165176
self._grpc_channel = type(self).create_channel(
166177
host,
167178
credentials=credentials,
168179
credentials_file=credentials_file,
169-
ssl_credentials=ssl_channel_credentials,
180+
ssl_credentials=self._ssl_channel_credentials,
170181
scopes=scopes or self.AUTH_SCOPES,
171182
quota_project_id=quota_project_id,
172183
options=[

google/cloud/logging_v2/services/config_service_v2/transports/grpc_asyncio.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ def __init__(
102102
api_mtls_endpoint: str = None,
103103
client_cert_source: Callable[[], Tuple[bytes, bytes]] = None,
104104
ssl_channel_credentials: grpc.ChannelCredentials = None,
105+
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
105106
quota_project_id=None,
106107
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
107108
) -> None:
@@ -133,6 +134,10 @@ def __init__(
133134
``api_mtls_endpoint`` is None.
134135
ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials
135136
for grpc channel. It is ignored if ``channel`` is provided.
137+
client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]):
138+
A callback to provide client certificate bytes and private key bytes,
139+
both in PEM format. It is used to configure mutual TLS channel. It is
140+
ignored if ``channel`` or ``ssl_channel_credentials`` is provided.
136141
quota_project_id (Optional[str]): An optional project to use for billing
137142
and quota.
138143
client_info (google.api_core.gapic_v1.client_info.ClientInfo):
@@ -149,6 +154,11 @@ def __init__(
149154
"""
150155
self._ssl_channel_credentials = ssl_channel_credentials
151156

157+
if api_mtls_endpoint:
158+
warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning)
159+
if client_cert_source:
160+
warnings.warn("client_cert_source is deprecated", DeprecationWarning)
161+
152162
if channel:
153163
# Sanity check: Ensure that channel and credentials are not both
154164
# provided.
@@ -158,11 +168,6 @@ def __init__(
158168
self._grpc_channel = channel
159169
self._ssl_channel_credentials = None
160170
elif api_mtls_endpoint:
161-
warnings.warn(
162-
"api_mtls_endpoint and client_cert_source are deprecated",
163-
DeprecationWarning,
164-
)
165-
166171
host = (
167172
api_mtls_endpoint
168173
if ":" in api_mtls_endpoint
@@ -206,12 +211,18 @@ def __init__(
206211
scopes=self.AUTH_SCOPES, quota_project_id=quota_project_id
207212
)
208213

214+
if client_cert_source_for_mtls and not ssl_channel_credentials:
215+
cert, key = client_cert_source_for_mtls()
216+
self._ssl_channel_credentials = grpc.ssl_channel_credentials(
217+
certificate_chain=cert, private_key=key
218+
)
219+
209220
# create a new channel. The provided one is ignored.
210221
self._grpc_channel = type(self).create_channel(
211222
host,
212223
credentials=credentials,
213224
credentials_file=credentials_file,
214-
ssl_credentials=ssl_channel_credentials,
225+
ssl_credentials=self._ssl_channel_credentials,
215226
scopes=scopes or self.AUTH_SCOPES,
216227
quota_project_id=quota_project_id,
217228
options=[

google/cloud/logging_v2/services/logging_service_v2/client.py

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -292,21 +292,17 @@ def __init__(
292292
util.strtobool(os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false"))
293293
)
294294

295-
ssl_credentials = None
295+
client_cert_source_func = None
296296
is_mtls = False
297297
if use_client_cert:
298298
if client_options.client_cert_source:
299-
import grpc # type: ignore
300-
301-
cert, key = client_options.client_cert_source()
302-
ssl_credentials = grpc.ssl_channel_credentials(
303-
certificate_chain=cert, private_key=key
304-
)
305299
is_mtls = True
300+
client_cert_source_func = client_options.client_cert_source
306301
else:
307-
creds = SslCredentials()
308-
is_mtls = creds.is_mtls
309-
ssl_credentials = creds.ssl_credentials if is_mtls else None
302+
is_mtls = mtls.has_default_client_cert_source()
303+
client_cert_source_func = (
304+
mtls.default_client_cert_source() if is_mtls else None
305+
)
310306

311307
# Figure out which api endpoint to use.
312308
if client_options.api_endpoint is not None:
@@ -349,7 +345,7 @@ def __init__(
349345
credentials_file=client_options.credentials_file,
350346
host=api_endpoint,
351347
scopes=client_options.scopes,
352-
ssl_channel_credentials=ssl_credentials,
348+
client_cert_source_for_mtls=client_cert_source_func,
353349
quota_project_id=client_options.quota_project_id,
354350
client_info=client_info,
355351
)

google/cloud/logging_v2/services/logging_service_v2/transports/grpc.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ def __init__(
5858
api_mtls_endpoint: str = None,
5959
client_cert_source: Callable[[], Tuple[bytes, bytes]] = None,
6060
ssl_channel_credentials: grpc.ChannelCredentials = None,
61+
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
6162
quota_project_id: Optional[str] = None,
6263
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
6364
) -> None:
@@ -88,6 +89,10 @@ def __init__(
8889
``api_mtls_endpoint`` is None.
8990
ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials
9091
for grpc channel. It is ignored if ``channel`` is provided.
92+
client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]):
93+
A callback to provide client certificate bytes and private key bytes,
94+
both in PEM format. It is used to configure mutual TLS channel. It is
95+
ignored if ``channel`` or ``ssl_channel_credentials`` is provided.
9196
quota_project_id (Optional[str]): An optional project to use for billing
9297
and quota.
9398
client_info (google.api_core.gapic_v1.client_info.ClientInfo):
@@ -104,6 +109,11 @@ def __init__(
104109
"""
105110
self._ssl_channel_credentials = ssl_channel_credentials
106111

112+
if api_mtls_endpoint:
113+
warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning)
114+
if client_cert_source:
115+
warnings.warn("client_cert_source is deprecated", DeprecationWarning)
116+
107117
if channel:
108118
# Sanity check: Ensure that channel and credentials are not both
109119
# provided.
@@ -113,11 +123,6 @@ def __init__(
113123
self._grpc_channel = channel
114124
self._ssl_channel_credentials = None
115125
elif api_mtls_endpoint:
116-
warnings.warn(
117-
"api_mtls_endpoint and client_cert_source are deprecated",
118-
DeprecationWarning,
119-
)
120-
121126
host = (
122127
api_mtls_endpoint
123128
if ":" in api_mtls_endpoint
@@ -161,12 +166,18 @@ def __init__(
161166
scopes=self.AUTH_SCOPES, quota_project_id=quota_project_id
162167
)
163168

169+
if client_cert_source_for_mtls and not ssl_channel_credentials:
170+
cert, key = client_cert_source_for_mtls()
171+
self._ssl_channel_credentials = grpc.ssl_channel_credentials(
172+
certificate_chain=cert, private_key=key
173+
)
174+
164175
# create a new channel. The provided one is ignored.
165176
self._grpc_channel = type(self).create_channel(
166177
host,
167178
credentials=credentials,
168179
credentials_file=credentials_file,
169-
ssl_credentials=ssl_channel_credentials,
180+
ssl_credentials=self._ssl_channel_credentials,
170181
scopes=scopes or self.AUTH_SCOPES,
171182
quota_project_id=quota_project_id,
172183
options=[

google/cloud/logging_v2/services/logging_service_v2/transports/grpc_asyncio.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ def __init__(
102102
api_mtls_endpoint: str = None,
103103
client_cert_source: Callable[[], Tuple[bytes, bytes]] = None,
104104
ssl_channel_credentials: grpc.ChannelCredentials = None,
105+
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
105106
quota_project_id=None,
106107
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
107108
) -> None:
@@ -133,6 +134,10 @@ def __init__(
133134
``api_mtls_endpoint`` is None.
134135
ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials
135136
for grpc channel. It is ignored if ``channel`` is provided.
137+
client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]):
138+
A callback to provide client certificate bytes and private key bytes,
139+
both in PEM format. It is used to configure mutual TLS channel. It is
140+
ignored if ``channel`` or ``ssl_channel_credentials`` is provided.
136141
quota_project_id (Optional[str]): An optional project to use for billing
137142
and quota.
138143
client_info (google.api_core.gapic_v1.client_info.ClientInfo):
@@ -149,6 +154,11 @@ def __init__(
149154
"""
150155
self._ssl_channel_credentials = ssl_channel_credentials
151156

157+
if api_mtls_endpoint:
158+
warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning)
159+
if client_cert_source:
160+
warnings.warn("client_cert_source is deprecated", DeprecationWarning)
161+
152162
if channel:
153163
# Sanity check: Ensure that channel and credentials are not both
154164
# provided.
@@ -158,11 +168,6 @@ def __init__(
158168
self._grpc_channel = channel
159169
self._ssl_channel_credentials = None
160170
elif api_mtls_endpoint:
161-
warnings.warn(
162-
"api_mtls_endpoint and client_cert_source are deprecated",
163-
DeprecationWarning,
164-
)
165-
166171
host = (
167172
api_mtls_endpoint
168173
if ":" in api_mtls_endpoint
@@ -206,12 +211,18 @@ def __init__(
206211
scopes=self.AUTH_SCOPES, quota_project_id=quota_project_id
207212
)
208213

214+
if client_cert_source_for_mtls and not ssl_channel_credentials:
215+
cert, key = client_cert_source_for_mtls()
216+
self._ssl_channel_credentials = grpc.ssl_channel_credentials(
217+
certificate_chain=cert, private_key=key
218+
)
219+
209220
# create a new channel. The provided one is ignored.
210221
self._grpc_channel = type(self).create_channel(
211222
host,
212223
credentials=credentials,
213224
credentials_file=credentials_file,
214-
ssl_credentials=ssl_channel_credentials,
225+
ssl_credentials=self._ssl_channel_credentials,
215226
scopes=scopes or self.AUTH_SCOPES,
216227
quota_project_id=quota_project_id,
217228
options=[

google/cloud/logging_v2/services/metrics_service_v2/client.py

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -286,21 +286,17 @@ def __init__(
286286
util.strtobool(os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false"))
287287
)
288288

289-
ssl_credentials = None
289+
client_cert_source_func = None
290290
is_mtls = False
291291
if use_client_cert:
292292
if client_options.client_cert_source:
293-
import grpc # type: ignore
294-
295-
cert, key = client_options.client_cert_source()
296-
ssl_credentials = grpc.ssl_channel_credentials(
297-
certificate_chain=cert, private_key=key
298-
)
299293
is_mtls = True
294+
client_cert_source_func = client_options.client_cert_source
300295
else:
301-
creds = SslCredentials()
302-
is_mtls = creds.is_mtls
303-
ssl_credentials = creds.ssl_credentials if is_mtls else None
296+
is_mtls = mtls.has_default_client_cert_source()
297+
client_cert_source_func = (
298+
mtls.default_client_cert_source() if is_mtls else None
299+
)
304300

305301
# Figure out which api endpoint to use.
306302
if client_options.api_endpoint is not None:
@@ -343,7 +339,7 @@ def __init__(
343339
credentials_file=client_options.credentials_file,
344340
host=api_endpoint,
345341
scopes=client_options.scopes,
346-
ssl_channel_credentials=ssl_credentials,
342+
client_cert_source_for_mtls=client_cert_source_func,
347343
quota_project_id=client_options.quota_project_id,
348344
client_info=client_info,
349345
)

0 commit comments

Comments
 (0)