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

Commit d1e6767

Browse files
chore: use gapic-generator-python 0.62.1 (#161)
- [ ] Regenerate this pull request now. fix: resolve DuplicateCredentialArgs error when using credentials_file committer: parthea PiperOrigin-RevId: 425964861 Source-Link: googleapis/googleapis@84b1a5a Source-Link: https://github.com/googleapis/googleapis-gen/commit/4fb761bbd8506ac156f49bac5f18306aa8eb3aa8 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNGZiNzYxYmJkODUwNmFjMTU2ZjQ5YmFjNWYxODMwNmFhOGViM2FhOCJ9
1 parent a3938e3 commit d1e6767

File tree

5 files changed

+103
-21
lines changed

5 files changed

+103
-21
lines changed

google/cloud/bigquery_connection_v1/services/connection_service/async_client.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ async def create_connection(
256256
257257
"""
258258
# Create or coerce a protobuf request object.
259-
# Sanity check: If we got a request object, we should *not* have
259+
# Quick check: If we got a request object, we should *not* have
260260
# gotten any keyword arguments that map to the request.
261261
has_flattened_params = any([parent, connection, connection_id])
262262
if request is not None and has_flattened_params:
@@ -332,7 +332,7 @@ async def get_connection(
332332
333333
"""
334334
# Create or coerce a protobuf request object.
335-
# Sanity check: If we got a request object, we should *not* have
335+
# Quick check: If we got a request object, we should *not* have
336336
# gotten any keyword arguments that map to the request.
337337
has_flattened_params = any([name])
338338
if request is not None and has_flattened_params:
@@ -416,7 +416,7 @@ async def list_connections(
416416
417417
"""
418418
# Create or coerce a protobuf request object.
419-
# Sanity check: If we got a request object, we should *not* have
419+
# Quick check: If we got a request object, we should *not* have
420420
# gotten any keyword arguments that map to the request.
421421
has_flattened_params = any([parent])
422422
if request is not None and has_flattened_params:
@@ -522,7 +522,7 @@ async def update_connection(
522522
523523
"""
524524
# Create or coerce a protobuf request object.
525-
# Sanity check: If we got a request object, we should *not* have
525+
# Quick check: If we got a request object, we should *not* have
526526
# gotten any keyword arguments that map to the request.
527527
has_flattened_params = any([name, connection, update_mask])
528528
if request is not None and has_flattened_params:
@@ -591,7 +591,7 @@ async def delete_connection(
591591
sent along with the request as metadata.
592592
"""
593593
# Create or coerce a protobuf request object.
594-
# Sanity check: If we got a request object, we should *not* have
594+
# Quick check: If we got a request object, we should *not* have
595595
# gotten any keyword arguments that map to the request.
596596
has_flattened_params = any([name])
597597
if request is not None and has_flattened_params:
@@ -728,7 +728,7 @@ async def get_iam_policy(
728728
729729
"""
730730
# Create or coerce a protobuf request object.
731-
# Sanity check: If we got a request object, we should *not* have
731+
# Quick check: If we got a request object, we should *not* have
732732
# gotten any keyword arguments that map to the request.
733733
has_flattened_params = any([resource])
734734
if request is not None and has_flattened_params:
@@ -858,7 +858,7 @@ async def set_iam_policy(
858858
859859
"""
860860
# Create or coerce a protobuf request object.
861-
# Sanity check: If we got a request object, we should *not* have
861+
# Quick check: If we got a request object, we should *not* have
862862
# gotten any keyword arguments that map to the request.
863863
has_flattened_params = any([resource])
864864
if request is not None and has_flattened_params:
@@ -946,7 +946,7 @@ async def test_iam_permissions(
946946
Response message for TestIamPermissions method.
947947
"""
948948
# Create or coerce a protobuf request object.
949-
# Sanity check: If we got a request object, we should *not* have
949+
# Quick check: If we got a request object, we should *not* have
950950
# gotten any keyword arguments that map to the request.
951951
has_flattened_params = any([resource, permissions])
952952
if request is not None and has_flattened_params:

google/cloud/bigquery_connection_v1/services/connection_service/client.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ def create_connection(
455455
456456
"""
457457
# Create or coerce a protobuf request object.
458-
# Sanity check: If we got a request object, we should *not* have
458+
# Quick check: If we got a request object, we should *not* have
459459
# gotten any keyword arguments that map to the request.
460460
has_flattened_params = any([parent, connection, connection_id])
461461
if request is not None and has_flattened_params:
@@ -531,7 +531,7 @@ def get_connection(
531531
532532
"""
533533
# Create or coerce a protobuf request object.
534-
# Sanity check: If we got a request object, we should *not* have
534+
# Quick check: If we got a request object, we should *not* have
535535
# gotten any keyword arguments that map to the request.
536536
has_flattened_params = any([name])
537537
if request is not None and has_flattened_params:
@@ -605,7 +605,7 @@ def list_connections(
605605
606606
"""
607607
# Create or coerce a protobuf request object.
608-
# Sanity check: If we got a request object, we should *not* have
608+
# Quick check: If we got a request object, we should *not* have
609609
# gotten any keyword arguments that map to the request.
610610
has_flattened_params = any([parent])
611611
if request is not None and has_flattened_params:
@@ -701,7 +701,7 @@ def update_connection(
701701
702702
"""
703703
# Create or coerce a protobuf request object.
704-
# Sanity check: If we got a request object, we should *not* have
704+
# Quick check: If we got a request object, we should *not* have
705705
# gotten any keyword arguments that map to the request.
706706
has_flattened_params = any([name, connection, update_mask])
707707
if request is not None and has_flattened_params:
@@ -770,7 +770,7 @@ def delete_connection(
770770
sent along with the request as metadata.
771771
"""
772772
# Create or coerce a protobuf request object.
773-
# Sanity check: If we got a request object, we should *not* have
773+
# Quick check: If we got a request object, we should *not* have
774774
# gotten any keyword arguments that map to the request.
775775
has_flattened_params = any([name])
776776
if request is not None and has_flattened_params:
@@ -897,7 +897,7 @@ def get_iam_policy(
897897
898898
"""
899899
# Create or coerce a protobuf request object.
900-
# Sanity check: If we got a request object, we should *not* have
900+
# Quick check: If we got a request object, we should *not* have
901901
# gotten any keyword arguments that map to the request.
902902
has_flattened_params = any([resource])
903903
if request is not None and has_flattened_params:
@@ -1026,7 +1026,7 @@ def set_iam_policy(
10261026
10271027
"""
10281028
# Create or coerce a protobuf request object.
1029-
# Sanity check: If we got a request object, we should *not* have
1029+
# Quick check: If we got a request object, we should *not* have
10301030
# gotten any keyword arguments that map to the request.
10311031
has_flattened_params = any([resource])
10321032
if request is not None and has_flattened_params:
@@ -1113,7 +1113,7 @@ def test_iam_permissions(
11131113
Response message for TestIamPermissions method.
11141114
"""
11151115
# Create or coerce a protobuf request object.
1116-
# Sanity check: If we got a request object, we should *not* have
1116+
# Quick check: If we got a request object, we should *not* have
11171117
# gotten any keyword arguments that map to the request.
11181118
has_flattened_params = any([resource, permissions])
11191119
if request is not None and has_flattened_params:

google/cloud/bigquery_connection_v1/services/connection_service/transports/grpc.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,11 @@ def __init__(
162162
if not self._grpc_channel:
163163
self._grpc_channel = type(self).create_channel(
164164
self._host,
165+
# use the credentials which are saved
165166
credentials=self._credentials,
166-
credentials_file=credentials_file,
167+
# Set ``credentials_file`` to ``None`` here as
168+
# the credentials that we saved earlier should be used.
169+
credentials_file=None,
167170
scopes=self._scopes,
168171
ssl_credentials=self._ssl_channel_credentials,
169172
quota_project_id=quota_project_id,

google/cloud/bigquery_connection_v1/services/connection_service/transports/grpc_asyncio.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,11 @@ def __init__(
207207
if not self._grpc_channel:
208208
self._grpc_channel = type(self).create_channel(
209209
self._host,
210+
# use the credentials which are saved
210211
credentials=self._credentials,
211-
credentials_file=credentials_file,
212+
# Set ``credentials_file`` to ``None`` here as
213+
# the credentials that we saved earlier should be used.
214+
credentials_file=None,
212215
scopes=self._scopes,
213216
ssl_credentials=self._ssl_channel_credentials,
214217
quota_project_id=quota_project_id,

tests/unit/gapic/bigquery_connection_v1/test_connection_service.py

+79-3
Original file line numberDiff line numberDiff line change
@@ -529,21 +529,28 @@ def test_connection_service_client_client_options_scopes(
529529

530530

531531
@pytest.mark.parametrize(
532-
"client_class,transport_class,transport_name",
532+
"client_class,transport_class,transport_name,grpc_helpers",
533533
[
534-
(ConnectionServiceClient, transports.ConnectionServiceGrpcTransport, "grpc"),
534+
(
535+
ConnectionServiceClient,
536+
transports.ConnectionServiceGrpcTransport,
537+
"grpc",
538+
grpc_helpers,
539+
),
535540
(
536541
ConnectionServiceAsyncClient,
537542
transports.ConnectionServiceGrpcAsyncIOTransport,
538543
"grpc_asyncio",
544+
grpc_helpers_async,
539545
),
540546
],
541547
)
542548
def test_connection_service_client_client_options_credentials_file(
543-
client_class, transport_class, transport_name
549+
client_class, transport_class, transport_name, grpc_helpers
544550
):
545551
# Check the case credentials file is provided.
546552
options = client_options.ClientOptions(credentials_file="credentials.json")
553+
547554
with mock.patch.object(transport_class, "__init__") as patched:
548555
patched.return_value = None
549556
client = client_class(client_options=options, transport=transport_name)
@@ -579,6 +586,75 @@ def test_connection_service_client_client_options_from_dict():
579586
)
580587

581588

589+
@pytest.mark.parametrize(
590+
"client_class,transport_class,transport_name,grpc_helpers",
591+
[
592+
(
593+
ConnectionServiceClient,
594+
transports.ConnectionServiceGrpcTransport,
595+
"grpc",
596+
grpc_helpers,
597+
),
598+
(
599+
ConnectionServiceAsyncClient,
600+
transports.ConnectionServiceGrpcAsyncIOTransport,
601+
"grpc_asyncio",
602+
grpc_helpers_async,
603+
),
604+
],
605+
)
606+
def test_connection_service_client_create_channel_credentials_file(
607+
client_class, transport_class, transport_name, grpc_helpers
608+
):
609+
# Check the case credentials file is provided.
610+
options = client_options.ClientOptions(credentials_file="credentials.json")
611+
612+
with mock.patch.object(transport_class, "__init__") as patched:
613+
patched.return_value = None
614+
client = client_class(client_options=options, transport=transport_name)
615+
patched.assert_called_once_with(
616+
credentials=None,
617+
credentials_file="credentials.json",
618+
host=client.DEFAULT_ENDPOINT,
619+
scopes=None,
620+
client_cert_source_for_mtls=None,
621+
quota_project_id=None,
622+
client_info=transports.base.DEFAULT_CLIENT_INFO,
623+
always_use_jwt_access=True,
624+
)
625+
626+
# test that the credentials from file are saved and used as the credentials.
627+
with mock.patch.object(
628+
google.auth, "load_credentials_from_file", autospec=True
629+
) as load_creds, mock.patch.object(
630+
google.auth, "default", autospec=True
631+
) as adc, mock.patch.object(
632+
grpc_helpers, "create_channel"
633+
) as create_channel:
634+
creds = ga_credentials.AnonymousCredentials()
635+
file_creds = ga_credentials.AnonymousCredentials()
636+
load_creds.return_value = (file_creds, None)
637+
adc.return_value = (creds, None)
638+
client = client_class(client_options=options, transport=transport_name)
639+
create_channel.assert_called_with(
640+
"bigqueryconnection.googleapis.com:443",
641+
credentials=file_creds,
642+
credentials_file=None,
643+
quota_project_id=None,
644+
default_scopes=(
645+
"https://www.googleapis.com/auth/bigquery",
646+
"https://www.googleapis.com/auth/cloud-platform",
647+
),
648+
scopes=None,
649+
default_host="bigqueryconnection.googleapis.com",
650+
ssl_credentials=None,
651+
options=[
652+
("grpc.max_send_message_length", -1),
653+
("grpc.max_receive_message_length", -1),
654+
],
655+
)
656+
657+
582658
@pytest.mark.parametrize(
583659
"request_type", [gcbc_connection.CreateConnectionRequest, dict,]
584660
)

0 commit comments

Comments
 (0)