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

Commit b3b1ee2

Browse files
chore: use gapic-generator-python 0.62.1 (#36)
- [ ] 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 124de81 commit b3b1ee2

File tree

6 files changed

+100
-21
lines changed

6 files changed

+100
-21
lines changed

google/cloud/bigquery_migration_v2alpha/services/migration_service/async_client.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ async def create_migration_workflow(
260260
261261
"""
262262
# Create or coerce a protobuf request object.
263-
# Sanity check: If we got a request object, we should *not* have
263+
# Quick check: If we got a request object, we should *not* have
264264
# gotten any keyword arguments that map to the request.
265265
has_flattened_params = any([parent, migration_workflow])
266266
if request is not None and has_flattened_params:
@@ -335,7 +335,7 @@ async def get_migration_workflow(
335335
336336
"""
337337
# Create or coerce a protobuf request object.
338-
# Sanity check: If we got a request object, we should *not* have
338+
# Quick check: If we got a request object, we should *not* have
339339
# gotten any keyword arguments that map to the request.
340340
has_flattened_params = any([name])
341341
if request is not None and has_flattened_params:
@@ -418,7 +418,7 @@ async def list_migration_workflows(
418418
419419
"""
420420
# Create or coerce a protobuf request object.
421-
# Sanity check: If we got a request object, we should *not* have
421+
# Quick check: If we got a request object, we should *not* have
422422
# gotten any keyword arguments that map to the request.
423423
has_flattened_params = any([parent])
424424
if request is not None and has_flattened_params:
@@ -499,7 +499,7 @@ async def delete_migration_workflow(
499499
sent along with the request as metadata.
500500
"""
501501
# Create or coerce a protobuf request object.
502-
# Sanity check: If we got a request object, we should *not* have
502+
# Quick check: If we got a request object, we should *not* have
503503
# gotten any keyword arguments that map to the request.
504504
has_flattened_params = any([name])
505505
if request is not None and has_flattened_params:
@@ -568,7 +568,7 @@ async def start_migration_workflow(
568568
sent along with the request as metadata.
569569
"""
570570
# Create or coerce a protobuf request object.
571-
# Sanity check: If we got a request object, we should *not* have
571+
# Quick check: If we got a request object, we should *not* have
572572
# gotten any keyword arguments that map to the request.
573573
has_flattened_params = any([name])
574574
if request is not None and has_flattened_params:
@@ -652,7 +652,7 @@ async def get_migration_subtask(
652652
653653
"""
654654
# Create or coerce a protobuf request object.
655-
# Sanity check: If we got a request object, we should *not* have
655+
# Quick check: If we got a request object, we should *not* have
656656
# gotten any keyword arguments that map to the request.
657657
has_flattened_params = any([name])
658658
if request is not None and has_flattened_params:
@@ -734,7 +734,7 @@ async def list_migration_subtasks(
734734
735735
"""
736736
# Create or coerce a protobuf request object.
737-
# Sanity check: If we got a request object, we should *not* have
737+
# Quick check: If we got a request object, we should *not* have
738738
# gotten any keyword arguments that map to the request.
739739
has_flattened_params = any([parent])
740740
if request is not None and has_flattened_params:

google/cloud/bigquery_migration_v2alpha/services/migration_service/client.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ def create_migration_workflow(
467467
468468
"""
469469
# Create or coerce a protobuf request object.
470-
# Sanity check: If we got a request object, we should *not* have
470+
# Quick check: If we got a request object, we should *not* have
471471
# gotten any keyword arguments that map to the request.
472472
has_flattened_params = any([parent, migration_workflow])
473473
if request is not None and has_flattened_params:
@@ -544,7 +544,7 @@ def get_migration_workflow(
544544
545545
"""
546546
# Create or coerce a protobuf request object.
547-
# Sanity check: If we got a request object, we should *not* have
547+
# Quick check: If we got a request object, we should *not* have
548548
# gotten any keyword arguments that map to the request.
549549
has_flattened_params = any([name])
550550
if request is not None and has_flattened_params:
@@ -618,7 +618,7 @@ def list_migration_workflows(
618618
619619
"""
620620
# Create or coerce a protobuf request object.
621-
# Sanity check: If we got a request object, we should *not* have
621+
# Quick check: If we got a request object, we should *not* have
622622
# gotten any keyword arguments that map to the request.
623623
has_flattened_params = any([parent])
624624
if request is not None and has_flattened_params:
@@ -690,7 +690,7 @@ def delete_migration_workflow(
690690
sent along with the request as metadata.
691691
"""
692692
# Create or coerce a protobuf request object.
693-
# Sanity check: If we got a request object, we should *not* have
693+
# Quick check: If we got a request object, we should *not* have
694694
# gotten any keyword arguments that map to the request.
695695
has_flattened_params = any([name])
696696
if request is not None and has_flattened_params:
@@ -761,7 +761,7 @@ def start_migration_workflow(
761761
sent along with the request as metadata.
762762
"""
763763
# Create or coerce a protobuf request object.
764-
# Sanity check: If we got a request object, we should *not* have
764+
# Quick check: If we got a request object, we should *not* have
765765
# gotten any keyword arguments that map to the request.
766766
has_flattened_params = any([name])
767767
if request is not None and has_flattened_params:
@@ -836,7 +836,7 @@ def get_migration_subtask(
836836
837837
"""
838838
# Create or coerce a protobuf request object.
839-
# Sanity check: If we got a request object, we should *not* have
839+
# Quick check: If we got a request object, we should *not* have
840840
# gotten any keyword arguments that map to the request.
841841
has_flattened_params = any([name])
842842
if request is not None and has_flattened_params:
@@ -909,7 +909,7 @@ def list_migration_subtasks(
909909
910910
"""
911911
# Create or coerce a protobuf request object.
912-
# Sanity check: If we got a request object, we should *not* have
912+
# Quick check: If we got a request object, we should *not* have
913913
# gotten any keyword arguments that map to the request.
914914
has_flattened_params = any([parent])
915915
if request is not None and has_flattened_params:

google/cloud/bigquery_migration_v2alpha/services/migration_service/transports/grpc.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,11 @@ def __init__(
160160
if not self._grpc_channel:
161161
self._grpc_channel = type(self).create_channel(
162162
self._host,
163+
# use the credentials which are saved
163164
credentials=self._credentials,
164-
credentials_file=credentials_file,
165+
# Set ``credentials_file`` to ``None`` here as
166+
# the credentials that we saved earlier should be used.
167+
credentials_file=None,
165168
scopes=self._scopes,
166169
ssl_credentials=self._ssl_channel_credentials,
167170
quota_project_id=quota_project_id,

google/cloud/bigquery_migration_v2alpha/services/migration_service/transports/grpc_asyncio.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,11 @@ def __init__(
205205
if not self._grpc_channel:
206206
self._grpc_channel = type(self).create_channel(
207207
self._host,
208+
# use the credentials which are saved
208209
credentials=self._credentials,
209-
credentials_file=credentials_file,
210+
# Set ``credentials_file`` to ``None`` here as
211+
# the credentials that we saved earlier should be used.
212+
credentials_file=None,
210213
scopes=self._scopes,
211214
ssl_credentials=self._ssl_channel_credentials,
212215
quota_project_id=quota_project_id,

google/cloud/bigquery_migration_v2alpha/types/migration_entities.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ class MigrationTask(proto.Message):
105105
This field is a member of `oneof`_ ``task_details``.
106106
id (str):
107107
Output only. Immutable. The unique identifier
108-
for the migration task. The ID is server-
109-
generated.
108+
for the migration task. The ID is
109+
server-generated.
110110
type_ (str):
111111
The type of the task. This must be a
112112
supported task type.

tests/unit/gapic/bigquery_migration_v2alpha/test_migration_service.py

Lines changed: 76 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -534,21 +534,28 @@ def test_migration_service_client_client_options_scopes(
534534

535535

536536
@pytest.mark.parametrize(
537-
"client_class,transport_class,transport_name",
537+
"client_class,transport_class,transport_name,grpc_helpers",
538538
[
539-
(MigrationServiceClient, transports.MigrationServiceGrpcTransport, "grpc"),
539+
(
540+
MigrationServiceClient,
541+
transports.MigrationServiceGrpcTransport,
542+
"grpc",
543+
grpc_helpers,
544+
),
540545
(
541546
MigrationServiceAsyncClient,
542547
transports.MigrationServiceGrpcAsyncIOTransport,
543548
"grpc_asyncio",
549+
grpc_helpers_async,
544550
),
545551
],
546552
)
547553
def test_migration_service_client_client_options_credentials_file(
548-
client_class, transport_class, transport_name
554+
client_class, transport_class, transport_name, grpc_helpers
549555
):
550556
# Check the case credentials file is provided.
551557
options = client_options.ClientOptions(credentials_file="credentials.json")
558+
552559
with mock.patch.object(transport_class, "__init__") as patched:
553560
patched.return_value = None
554561
client = client_class(client_options=options, transport=transport_name)
@@ -584,6 +591,72 @@ def test_migration_service_client_client_options_from_dict():
584591
)
585592

586593

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

0 commit comments

Comments
 (0)