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

Commit 297c119

Browse files
chore: use gapic-generator-python 0.62.1 (#65)
- [ ] 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 ab2afd2 commit 297c119

File tree

6 files changed

+94
-18
lines changed

6 files changed

+94
-18
lines changed

google/cloud/network_management_v1/services/reachability_service/async_client.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ async def list_connectivity_tests(
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])
266266
if request is not None and has_flattened_params:
@@ -338,7 +338,7 @@ async def get_connectivity_test(
338338
339339
"""
340340
# Create or coerce a protobuf request object.
341-
# Sanity check: If we got a request object, we should *not* have
341+
# Quick check: If we got a request object, we should *not* have
342342
# gotten any keyword arguments that map to the request.
343343
has_flattened_params = any([name])
344344
if request is not None and has_flattened_params:
@@ -446,7 +446,7 @@ async def create_connectivity_test(
446446
447447
"""
448448
# Create or coerce a protobuf request object.
449-
# Sanity check: If we got a request object, we should *not* have
449+
# Quick check: If we got a request object, we should *not* have
450450
# gotten any keyword arguments that map to the request.
451451
has_flattened_params = any([parent, test_id, resource])
452452
if request is not None and has_flattened_params:
@@ -556,7 +556,7 @@ async def update_connectivity_test(
556556
557557
"""
558558
# Create or coerce a protobuf request object.
559-
# Sanity check: If we got a request object, we should *not* have
559+
# Quick check: If we got a request object, we should *not* have
560560
# gotten any keyword arguments that map to the request.
561561
has_flattened_params = any([update_mask, resource])
562562
if request is not None and has_flattened_params:
@@ -726,7 +726,7 @@ async def delete_connectivity_test(
726726
727727
"""
728728
# Create or coerce a protobuf request object.
729-
# Sanity check: If we got a request object, we should *not* have
729+
# Quick check: If we got a request object, we should *not* have
730730
# gotten any keyword arguments that map to the request.
731731
has_flattened_params = any([name])
732732
if request is not None and has_flattened_params:

google/cloud/network_management_v1/services/reachability_service/client.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ def list_connectivity_tests(
454454
455455
"""
456456
# Create or coerce a protobuf request object.
457-
# Sanity check: If we got a request object, we should *not* have
457+
# Quick check: If we got a request object, we should *not* have
458458
# gotten any keyword arguments that map to the request.
459459
has_flattened_params = any([parent])
460460
if request is not None and has_flattened_params:
@@ -532,7 +532,7 @@ def get_connectivity_test(
532532
533533
"""
534534
# Create or coerce a protobuf request object.
535-
# Sanity check: If we got a request object, we should *not* have
535+
# Quick check: If we got a request object, we should *not* have
536536
# gotten any keyword arguments that map to the request.
537537
has_flattened_params = any([name])
538538
if request is not None and has_flattened_params:
@@ -640,7 +640,7 @@ def create_connectivity_test(
640640
641641
"""
642642
# Create or coerce a protobuf request object.
643-
# Sanity check: If we got a request object, we should *not* have
643+
# Quick check: If we got a request object, we should *not* have
644644
# gotten any keyword arguments that map to the request.
645645
has_flattened_params = any([parent, test_id, resource])
646646
if request is not None and has_flattened_params:
@@ -750,7 +750,7 @@ def update_connectivity_test(
750750
751751
"""
752752
# Create or coerce a protobuf request object.
753-
# Sanity check: If we got a request object, we should *not* have
753+
# Quick check: If we got a request object, we should *not* have
754754
# gotten any keyword arguments that map to the request.
755755
has_flattened_params = any([update_mask, resource])
756756
if request is not None and has_flattened_params:
@@ -921,7 +921,7 @@ def delete_connectivity_test(
921921
922922
"""
923923
# Create or coerce a protobuf request object.
924-
# Sanity check: If we got a request object, we should *not* have
924+
# Quick check: If we got a request object, we should *not* have
925925
# gotten any keyword arguments that map to the request.
926926
has_flattened_params = any([name])
927927
if request is not None and has_flattened_params:

google/cloud/network_management_v1/services/reachability_service/transports/grpc.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,11 @@ def __init__(
171171
if not self._grpc_channel:
172172
self._grpc_channel = type(self).create_channel(
173173
self._host,
174+
# use the credentials which are saved
174175
credentials=self._credentials,
175-
credentials_file=credentials_file,
176+
# Set ``credentials_file`` to ``None`` here as
177+
# the credentials that we saved earlier should be used.
178+
credentials_file=None,
176179
scopes=self._scopes,
177180
ssl_credentials=self._ssl_channel_credentials,
178181
quota_project_id=quota_project_id,
@@ -245,7 +248,7 @@ def operations_client(self) -> operations_v1.OperationsClient:
245248
This property caches on the instance; repeated calls return the same
246249
client.
247250
"""
248-
# Sanity check: Only create a new client if we do not already have one.
251+
# Quick check: Only create a new client if we do not already have one.
249252
if self._operations_client is None:
250253
self._operations_client = operations_v1.OperationsClient(self.grpc_channel)
251254

google/cloud/network_management_v1/services/reachability_service/transports/grpc_asyncio.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,11 @@ def __init__(
216216
if not self._grpc_channel:
217217
self._grpc_channel = type(self).create_channel(
218218
self._host,
219+
# use the credentials which are saved
219220
credentials=self._credentials,
220-
credentials_file=credentials_file,
221+
# Set ``credentials_file`` to ``None`` here as
222+
# the credentials that we saved earlier should be used.
223+
credentials_file=None,
221224
scopes=self._scopes,
222225
ssl_credentials=self._ssl_channel_credentials,
223226
quota_project_id=quota_project_id,
@@ -247,7 +250,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient:
247250
This property caches on the instance; repeated calls return the same
248251
client.
249252
"""
250-
# Sanity check: Only create a new client if we do not already have one.
253+
# Quick check: Only create a new client if we do not already have one.
251254
if self._operations_client is None:
252255
self._operations_client = operations_v1.OperationsAsyncClient(
253256
self.grpc_channel

google/cloud/network_management_v1/types/connectivity_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ class ConnectivityTest(proto.Message):
5151
the VPC network. Otherwise, specify the VM
5252
instance, which already contains its internal IP
5353
address and VPC network information.
54-
If the source of the test is within an on-
55-
premises network, then you must provide the
54+
If the source of the test is within an
55+
on-premises network, then you must provide the
5656
destination VPC network.
5757
5858
If the source endpoint is a Compute Engine VM

tests/unit/gapic/network_management_v1/test_reachability_service.py

Lines changed: 72 additions & 2 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
@@ -541,25 +542,28 @@ def test_reachability_service_client_client_options_scopes(
541542

542543

543544
@pytest.mark.parametrize(
544-
"client_class,transport_class,transport_name",
545+
"client_class,transport_class,transport_name,grpc_helpers",
545546
[
546547
(
547548
ReachabilityServiceClient,
548549
transports.ReachabilityServiceGrpcTransport,
549550
"grpc",
551+
grpc_helpers,
550552
),
551553
(
552554
ReachabilityServiceAsyncClient,
553555
transports.ReachabilityServiceGrpcAsyncIOTransport,
554556
"grpc_asyncio",
557+
grpc_helpers_async,
555558
),
556559
],
557560
)
558561
def test_reachability_service_client_client_options_credentials_file(
559-
client_class, transport_class, transport_name
562+
client_class, transport_class, transport_name, grpc_helpers
560563
):
561564
# Check the case credentials file is provided.
562565
options = client_options.ClientOptions(credentials_file="credentials.json")
566+
563567
with mock.patch.object(transport_class, "__init__") as patched:
564568
patched.return_value = None
565569
client = client_class(client_options=options, transport=transport_name)
@@ -595,6 +599,72 @@ def test_reachability_service_client_client_options_from_dict():
595599
)
596600

597601

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

0 commit comments

Comments
 (0)