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

Commit 9fe2aed

Browse files
chore: use gapic-generator-python 0.62.1 (#119)
- [ ] 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 2c259e7 commit 9fe2aed

File tree

8 files changed

+173
-19
lines changed

8 files changed

+173
-19
lines changed

google/cloud/dataqna_v1alpha/services/auto_suggestion_service/transports/grpc.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,11 @@ def __init__(
228228
if not self._grpc_channel:
229229
self._grpc_channel = type(self).create_channel(
230230
self._host,
231+
# use the credentials which are saved
231232
credentials=self._credentials,
232-
credentials_file=credentials_file,
233+
# Set ``credentials_file`` to ``None`` here as
234+
# the credentials that we saved earlier should be used.
235+
credentials_file=None,
233236
scopes=self._scopes,
234237
ssl_credentials=self._ssl_channel_credentials,
235238
quota_project_id=quota_project_id,

google/cloud/dataqna_v1alpha/services/auto_suggestion_service/transports/grpc_asyncio.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,8 +273,11 @@ def __init__(
273273
if not self._grpc_channel:
274274
self._grpc_channel = type(self).create_channel(
275275
self._host,
276+
# use the credentials which are saved
276277
credentials=self._credentials,
277-
credentials_file=credentials_file,
278+
# Set ``credentials_file`` to ``None`` here as
279+
# the credentials that we saved earlier should be used.
280+
credentials_file=None,
278281
scopes=self._scopes,
279282
ssl_credentials=self._ssl_channel_credentials,
280283
quota_project_id=quota_project_id,

google/cloud/dataqna_v1alpha/services/question_service/async_client.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ async def get_question(
267267
268268
"""
269269
# Create or coerce a protobuf request object.
270-
# Sanity check: If we got a request object, we should *not* have
270+
# Quick check: If we got a request object, we should *not* have
271271
# gotten any keyword arguments that map to the request.
272272
has_flattened_params = any([name])
273273
if request is not None and has_flattened_params:
@@ -348,7 +348,7 @@ async def create_question(
348348
349349
"""
350350
# Create or coerce a protobuf request object.
351-
# Sanity check: If we got a request object, we should *not* have
351+
# Quick check: If we got a request object, we should *not* have
352352
# gotten any keyword arguments that map to the request.
353353
has_flattened_params = any([parent, question])
354354
if request is not None and has_flattened_params:
@@ -432,7 +432,7 @@ async def execute_question(
432432
433433
"""
434434
# Create or coerce a protobuf request object.
435-
# Sanity check: If we got a request object, we should *not* have
435+
# Quick check: If we got a request object, we should *not* have
436436
# gotten any keyword arguments that map to the request.
437437
has_flattened_params = any([name, interpretation_index])
438438
if request is not None and has_flattened_params:
@@ -504,7 +504,7 @@ async def get_user_feedback(
504504
Feedback provided by a user.
505505
"""
506506
# Create or coerce a protobuf request object.
507-
# Sanity check: If we got a request object, we should *not* have
507+
# Quick check: If we got a request object, we should *not* have
508508
# gotten any keyword arguments that map to the request.
509509
has_flattened_params = any([name])
510510
if request is not None and has_flattened_params:
@@ -583,7 +583,7 @@ async def update_user_feedback(
583583
Feedback provided by a user.
584584
"""
585585
# Create or coerce a protobuf request object.
586-
# Sanity check: If we got a request object, we should *not* have
586+
# Quick check: If we got a request object, we should *not* have
587587
# gotten any keyword arguments that map to the request.
588588
has_flattened_params = any([user_feedback, update_mask])
589589
if request is not None and has_flattened_params:

google/cloud/dataqna_v1alpha/services/question_service/client.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ def get_question(
476476
477477
"""
478478
# Create or coerce a protobuf request object.
479-
# Sanity check: If we got a request object, we should *not* have
479+
# Quick check: If we got a request object, we should *not* have
480480
# gotten any keyword arguments that map to the request.
481481
has_flattened_params = any([name])
482482
if request is not None and has_flattened_params:
@@ -557,7 +557,7 @@ def create_question(
557557
558558
"""
559559
# Create or coerce a protobuf request object.
560-
# Sanity check: If we got a request object, we should *not* have
560+
# Quick check: If we got a request object, we should *not* have
561561
# gotten any keyword arguments that map to the request.
562562
has_flattened_params = any([parent, question])
563563
if request is not None and has_flattened_params:
@@ -641,7 +641,7 @@ def execute_question(
641641
642642
"""
643643
# Create or coerce a protobuf request object.
644-
# Sanity check: If we got a request object, we should *not* have
644+
# Quick check: If we got a request object, we should *not* have
645645
# gotten any keyword arguments that map to the request.
646646
has_flattened_params = any([name, interpretation_index])
647647
if request is not None and has_flattened_params:
@@ -713,7 +713,7 @@ def get_user_feedback(
713713
Feedback provided by a user.
714714
"""
715715
# Create or coerce a protobuf request object.
716-
# Sanity check: If we got a request object, we should *not* have
716+
# Quick check: If we got a request object, we should *not* have
717717
# gotten any keyword arguments that map to the request.
718718
has_flattened_params = any([name])
719719
if request is not None and has_flattened_params:
@@ -792,7 +792,7 @@ def update_user_feedback(
792792
Feedback provided by a user.
793793
"""
794794
# Create or coerce a protobuf request object.
795-
# Sanity check: If we got a request object, we should *not* have
795+
# Quick check: If we got a request object, we should *not* have
796796
# gotten any keyword arguments that map to the request.
797797
has_flattened_params = any([user_feedback, update_mask])
798798
if request is not None and has_flattened_params:

google/cloud/dataqna_v1alpha/services/question_service/transports/grpc.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,11 @@ def __init__(
178178
if not self._grpc_channel:
179179
self._grpc_channel = type(self).create_channel(
180180
self._host,
181+
# use the credentials which are saved
181182
credentials=self._credentials,
182-
credentials_file=credentials_file,
183+
# Set ``credentials_file`` to ``None`` here as
184+
# the credentials that we saved earlier should be used.
185+
credentials_file=None,
183186
scopes=self._scopes,
184187
ssl_credentials=self._ssl_channel_credentials,
185188
quota_project_id=quota_project_id,

google/cloud/dataqna_v1alpha/services/question_service/transports/grpc_asyncio.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,11 @@ def __init__(
223223
if not self._grpc_channel:
224224
self._grpc_channel = type(self).create_channel(
225225
self._host,
226+
# use the credentials which are saved
226227
credentials=self._credentials,
227-
credentials_file=credentials_file,
228+
# Set ``credentials_file`` to ``None`` here as
229+
# the credentials that we saved earlier should be used.
230+
credentials_file=None,
228231
scopes=self._scopes,
229232
ssl_credentials=self._ssl_channel_credentials,
230233
quota_project_id=quota_project_id,

tests/unit/gapic/dataqna_v1alpha/test_auto_suggestion_service.py

Lines changed: 71 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -530,25 +530,28 @@ def test_auto_suggestion_service_client_client_options_scopes(
530530

531531

532532
@pytest.mark.parametrize(
533-
"client_class,transport_class,transport_name",
533+
"client_class,transport_class,transport_name,grpc_helpers",
534534
[
535535
(
536536
AutoSuggestionServiceClient,
537537
transports.AutoSuggestionServiceGrpcTransport,
538538
"grpc",
539+
grpc_helpers,
539540
),
540541
(
541542
AutoSuggestionServiceAsyncClient,
542543
transports.AutoSuggestionServiceGrpcAsyncIOTransport,
543544
"grpc_asyncio",
545+
grpc_helpers_async,
544546
),
545547
],
546548
)
547549
def test_auto_suggestion_service_client_client_options_credentials_file(
548-
client_class, transport_class, transport_name
550+
client_class, transport_class, transport_name, grpc_helpers
549551
):
550552
# Check the case credentials file is provided.
551553
options = client_options.ClientOptions(credentials_file="credentials.json")
554+
552555
with mock.patch.object(transport_class, "__init__") as patched:
553556
patched.return_value = None
554557
client = client_class(client_options=options, transport=transport_name)
@@ -584,6 +587,72 @@ def test_auto_suggestion_service_client_client_options_from_dict():
584587
)
585588

586589

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

tests/unit/gapic/dataqna_v1alpha/test_question_service.py

Lines changed: 76 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -528,21 +528,28 @@ def test_question_service_client_client_options_scopes(
528528

529529

530530
@pytest.mark.parametrize(
531-
"client_class,transport_class,transport_name",
531+
"client_class,transport_class,transport_name,grpc_helpers",
532532
[
533-
(QuestionServiceClient, transports.QuestionServiceGrpcTransport, "grpc"),
533+
(
534+
QuestionServiceClient,
535+
transports.QuestionServiceGrpcTransport,
536+
"grpc",
537+
grpc_helpers,
538+
),
534539
(
535540
QuestionServiceAsyncClient,
536541
transports.QuestionServiceGrpcAsyncIOTransport,
537542
"grpc_asyncio",
543+
grpc_helpers_async,
538544
),
539545
],
540546
)
541547
def test_question_service_client_client_options_credentials_file(
542-
client_class, transport_class, transport_name
548+
client_class, transport_class, transport_name, grpc_helpers
543549
):
544550
# Check the case credentials file is provided.
545551
options = client_options.ClientOptions(credentials_file="credentials.json")
552+
546553
with mock.patch.object(transport_class, "__init__") as patched:
547554
patched.return_value = None
548555
client = client_class(client_options=options, transport=transport_name)
@@ -578,6 +585,72 @@ def test_question_service_client_client_options_from_dict():
578585
)
579586

580587

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

0 commit comments

Comments
 (0)