Skip to content

Commit bb3e183

Browse files
chore: use gapic-generator-python 0.62.1 (#66)
- [ ] 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: googleapis/googleapis-gen@4fb761b Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNGZiNzYxYmJkODUwNmFjMTU2ZjQ5YmFjNWYxODMwNmFhOGViM2FhOCJ9
1 parent deb19e4 commit bb3e183

File tree

6 files changed

+86
-17
lines changed

6 files changed

+86
-17
lines changed

packages/google-cloud-data-fusion/google/cloud/data_fusion_v1/services/data_fusion/async_client.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ async def list_available_versions(
247247
248248
"""
249249
# Create or coerce a protobuf request object.
250-
# Sanity check: If we got a request object, we should *not* have
250+
# Quick check: If we got a request object, we should *not* have
251251
# gotten any keyword arguments that map to the request.
252252
has_flattened_params = any([parent])
253253
if request is not None and has_flattened_params:
@@ -449,7 +449,7 @@ async def create_instance(
449449
450450
"""
451451
# Create or coerce a protobuf request object.
452-
# Sanity check: If we got a request object, we should *not* have
452+
# Quick check: If we got a request object, we should *not* have
453453
# gotten any keyword arguments that map to the request.
454454
has_flattened_params = any([parent, instance, instance_id])
455455
if request is not None and has_flattened_params:
@@ -546,7 +546,7 @@ async def delete_instance(
546546
547547
"""
548548
# Create or coerce a protobuf request object.
549-
# Sanity check: If we got a request object, we should *not* have
549+
# Quick check: If we got a request object, we should *not* have
550550
# gotten any keyword arguments that map to the request.
551551
has_flattened_params = any([name])
552552
if request is not None and has_flattened_params:
@@ -647,7 +647,7 @@ async def update_instance(
647647
648648
"""
649649
# Create or coerce a protobuf request object.
650-
# Sanity check: If we got a request object, we should *not* have
650+
# Quick check: If we got a request object, we should *not* have
651651
# gotten any keyword arguments that map to the request.
652652
has_flattened_params = any([instance, update_mask])
653653
if request is not None and has_flattened_params:

packages/google-cloud-data-fusion/google/cloud/data_fusion_v1/services/data_fusion/client.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ def list_available_versions(
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])
473473
if request is not None and has_flattened_params:
@@ -671,7 +671,7 @@ def create_instance(
671671
672672
"""
673673
# Create or coerce a protobuf request object.
674-
# Sanity check: If we got a request object, we should *not* have
674+
# Quick check: If we got a request object, we should *not* have
675675
# gotten any keyword arguments that map to the request.
676676
has_flattened_params = any([parent, instance, instance_id])
677677
if request is not None and has_flattened_params:
@@ -768,7 +768,7 @@ def delete_instance(
768768
769769
"""
770770
# Create or coerce a protobuf request object.
771-
# Sanity check: If we got a request object, we should *not* have
771+
# Quick check: If we got a request object, we should *not* have
772772
# gotten any keyword arguments that map to the request.
773773
has_flattened_params = any([name])
774774
if request is not None and has_flattened_params:
@@ -869,7 +869,7 @@ def update_instance(
869869
870870
"""
871871
# Create or coerce a protobuf request object.
872-
# Sanity check: If we got a request object, we should *not* have
872+
# Quick check: If we got a request object, we should *not* have
873873
# gotten any keyword arguments that map to the request.
874874
has_flattened_params = any([instance, update_mask])
875875
if request is not None and has_flattened_params:

packages/google-cloud-data-fusion/google/cloud/data_fusion_v1/services/data_fusion/transports/grpc.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,11 @@ def __init__(
163163
if not self._grpc_channel:
164164
self._grpc_channel = type(self).create_channel(
165165
self._host,
166+
# use the credentials which are saved
166167
credentials=self._credentials,
167-
credentials_file=credentials_file,
168+
# Set ``credentials_file`` to ``None`` here as
169+
# the credentials that we saved earlier should be used.
170+
credentials_file=None,
168171
scopes=self._scopes,
169172
ssl_credentials=self._ssl_channel_credentials,
170173
quota_project_id=quota_project_id,
@@ -237,7 +240,7 @@ def operations_client(self) -> operations_v1.OperationsClient:
237240
This property caches on the instance; repeated calls return the same
238241
client.
239242
"""
240-
# Sanity check: Only create a new client if we do not already have one.
243+
# Quick check: Only create a new client if we do not already have one.
241244
if self._operations_client is None:
242245
self._operations_client = operations_v1.OperationsClient(self.grpc_channel)
243246

packages/google-cloud-data-fusion/google/cloud/data_fusion_v1/services/data_fusion/transports/grpc_asyncio.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,11 @@ def __init__(
208208
if not self._grpc_channel:
209209
self._grpc_channel = type(self).create_channel(
210210
self._host,
211+
# use the credentials which are saved
211212
credentials=self._credentials,
212-
credentials_file=credentials_file,
213+
# Set ``credentials_file`` to ``None`` here as
214+
# the credentials that we saved earlier should be used.
215+
credentials_file=None,
213216
scopes=self._scopes,
214217
ssl_credentials=self._ssl_channel_credentials,
215218
quota_project_id=quota_project_id,
@@ -239,7 +242,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient:
239242
This property caches on the instance; repeated calls return the same
240243
client.
241244
"""
242-
# Sanity check: Only create a new client if we do not already have one.
245+
# Quick check: Only create a new client if we do not already have one.
243246
if self._operations_client is None:
244247
self._operations_client = operations_v1.OperationsAsyncClient(
245248
self.grpc_channel

packages/google-cloud-data-fusion/google/cloud/data_fusion_v1/types/datafusion.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,7 @@ class NetworkConfig(proto.Message):
5858
executing pipelines. In case of shared VPC where
5959
the network resides in another host project the
6060
network should specified in the form of
61-
projects/{host-project-
62-
id}/global/networks/{network}
61+
projects/{host-project-id}/global/networks/{network}
6362
ip_allocation (str):
6463
The IP range in CIDR notation to use for the
6564
managed Data Fusion instance nodes. This range

packages/google-cloud-data-fusion/tests/unit/gapic/data_fusion_v1/test_data_fusion.py

Lines changed: 67 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
from google.api_core import gapic_v1
3030
from google.api_core import grpc_helpers
3131
from google.api_core import grpc_helpers_async
32+
from google.api_core import operation
3233
from google.api_core import operation_async # type: ignore
3334
from google.api_core import operations_v1
3435
from google.api_core import path_template
@@ -499,21 +500,23 @@ def test_data_fusion_client_client_options_scopes(
499500

500501

501502
@pytest.mark.parametrize(
502-
"client_class,transport_class,transport_name",
503+
"client_class,transport_class,transport_name,grpc_helpers",
503504
[
504-
(DataFusionClient, transports.DataFusionGrpcTransport, "grpc"),
505+
(DataFusionClient, transports.DataFusionGrpcTransport, "grpc", grpc_helpers),
505506
(
506507
DataFusionAsyncClient,
507508
transports.DataFusionGrpcAsyncIOTransport,
508509
"grpc_asyncio",
510+
grpc_helpers_async,
509511
),
510512
],
511513
)
512514
def test_data_fusion_client_client_options_credentials_file(
513-
client_class, transport_class, transport_name
515+
client_class, transport_class, transport_name, grpc_helpers
514516
):
515517
# Check the case credentials file is provided.
516518
options = client_options.ClientOptions(credentials_file="credentials.json")
519+
517520
with mock.patch.object(transport_class, "__init__") as patched:
518521
patched.return_value = None
519522
client = client_class(client_options=options, transport=transport_name)
@@ -547,6 +550,67 @@ def test_data_fusion_client_client_options_from_dict():
547550
)
548551

549552

553+
@pytest.mark.parametrize(
554+
"client_class,transport_class,transport_name,grpc_helpers",
555+
[
556+
(DataFusionClient, transports.DataFusionGrpcTransport, "grpc", grpc_helpers),
557+
(
558+
DataFusionAsyncClient,
559+
transports.DataFusionGrpcAsyncIOTransport,
560+
"grpc_asyncio",
561+
grpc_helpers_async,
562+
),
563+
],
564+
)
565+
def test_data_fusion_client_create_channel_credentials_file(
566+
client_class, transport_class, transport_name, grpc_helpers
567+
):
568+
# Check the case credentials file is provided.
569+
options = client_options.ClientOptions(credentials_file="credentials.json")
570+
571+
with mock.patch.object(transport_class, "__init__") as patched:
572+
patched.return_value = None
573+
client = client_class(client_options=options, transport=transport_name)
574+
patched.assert_called_once_with(
575+
credentials=None,
576+
credentials_file="credentials.json",
577+
host=client.DEFAULT_ENDPOINT,
578+
scopes=None,
579+
client_cert_source_for_mtls=None,
580+
quota_project_id=None,
581+
client_info=transports.base.DEFAULT_CLIENT_INFO,
582+
always_use_jwt_access=True,
583+
)
584+
585+
# test that the credentials from file are saved and used as the credentials.
586+
with mock.patch.object(
587+
google.auth, "load_credentials_from_file", autospec=True
588+
) as load_creds, mock.patch.object(
589+
google.auth, "default", autospec=True
590+
) as adc, mock.patch.object(
591+
grpc_helpers, "create_channel"
592+
) as create_channel:
593+
creds = ga_credentials.AnonymousCredentials()
594+
file_creds = ga_credentials.AnonymousCredentials()
595+
load_creds.return_value = (file_creds, None)
596+
adc.return_value = (creds, None)
597+
client = client_class(client_options=options, transport=transport_name)
598+
create_channel.assert_called_with(
599+
"datafusion.googleapis.com:443",
600+
credentials=file_creds,
601+
credentials_file=None,
602+
quota_project_id=None,
603+
default_scopes=("https://www.googleapis.com/auth/cloud-platform",),
604+
scopes=None,
605+
default_host="datafusion.googleapis.com",
606+
ssl_credentials=None,
607+
options=[
608+
("grpc.max_send_message_length", -1),
609+
("grpc.max_receive_message_length", -1),
610+
],
611+
)
612+
613+
550614
@pytest.mark.parametrize(
551615
"request_type", [datafusion.ListAvailableVersionsRequest, dict,]
552616
)

0 commit comments

Comments
 (0)