Skip to content

Commit 77a1733

Browse files
chore: use gapic-generator-python 0.62.1 (#82)
- [ ] 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 da8f0cf commit 77a1733

File tree

8 files changed

+165
-13
lines changed

8 files changed

+165
-13
lines changed

packages/google-cloud-apigee-connect/google/cloud/apigeeconnect_v1/services/connection_service/async_client.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ async def list_connections(
243243
244244
"""
245245
# Create or coerce a protobuf request object.
246-
# Sanity check: If we got a request object, we should *not* have
246+
# Quick check: If we got a request object, we should *not* have
247247
# gotten any keyword arguments that map to the request.
248248
has_flattened_params = any([parent])
249249
if request is not None and has_flattened_params:

packages/google-cloud-apigee-connect/google/cloud/apigeeconnect_v1/services/connection_service/client.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ def list_connections(
439439
440440
"""
441441
# Create or coerce a protobuf request object.
442-
# Sanity check: If we got a request object, we should *not* have
442+
# Quick check: If we got a request object, we should *not* have
443443
# gotten any keyword arguments that map to the request.
444444
has_flattened_params = any([parent])
445445
if request is not None and has_flattened_params:

packages/google-cloud-apigee-connect/google/cloud/apigeeconnect_v1/services/connection_service/transports/grpc.py

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

packages/google-cloud-apigee-connect/google/cloud/apigeeconnect_v1/services/connection_service/transports/grpc_asyncio.py

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

packages/google-cloud-apigee-connect/google/cloud/apigeeconnect_v1/services/tether/transports/grpc.py

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

packages/google-cloud-apigee-connect/google/cloud/apigeeconnect_v1/services/tether/transports/grpc_asyncio.py

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

packages/google-cloud-apigee-connect/tests/unit/gapic/apigeeconnect_v1/test_connection_service.py

+76-3
Original file line numberDiff line numberDiff line change
@@ -523,21 +523,28 @@ def test_connection_service_client_client_options_scopes(
523523

524524

525525
@pytest.mark.parametrize(
526-
"client_class,transport_class,transport_name",
526+
"client_class,transport_class,transport_name,grpc_helpers",
527527
[
528-
(ConnectionServiceClient, transports.ConnectionServiceGrpcTransport, "grpc"),
528+
(
529+
ConnectionServiceClient,
530+
transports.ConnectionServiceGrpcTransport,
531+
"grpc",
532+
grpc_helpers,
533+
),
529534
(
530535
ConnectionServiceAsyncClient,
531536
transports.ConnectionServiceGrpcAsyncIOTransport,
532537
"grpc_asyncio",
538+
grpc_helpers_async,
533539
),
534540
],
535541
)
536542
def test_connection_service_client_client_options_credentials_file(
537-
client_class, transport_class, transport_name
543+
client_class, transport_class, transport_name, grpc_helpers
538544
):
539545
# Check the case credentials file is provided.
540546
options = client_options.ClientOptions(credentials_file="credentials.json")
547+
541548
with mock.patch.object(transport_class, "__init__") as patched:
542549
patched.return_value = None
543550
client = client_class(client_options=options, transport=transport_name)
@@ -573,6 +580,72 @@ def test_connection_service_client_client_options_from_dict():
573580
)
574581

575582

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

packages/google-cloud-apigee-connect/tests/unit/gapic/apigeeconnect_v1/test_tether.py

+71-4
Original file line numberDiff line numberDiff line change
@@ -474,17 +474,23 @@ def test_tether_client_client_options_scopes(
474474

475475

476476
@pytest.mark.parametrize(
477-
"client_class,transport_class,transport_name",
477+
"client_class,transport_class,transport_name,grpc_helpers",
478478
[
479-
(TetherClient, transports.TetherGrpcTransport, "grpc"),
480-
(TetherAsyncClient, transports.TetherGrpcAsyncIOTransport, "grpc_asyncio"),
479+
(TetherClient, transports.TetherGrpcTransport, "grpc", grpc_helpers),
480+
(
481+
TetherAsyncClient,
482+
transports.TetherGrpcAsyncIOTransport,
483+
"grpc_asyncio",
484+
grpc_helpers_async,
485+
),
481486
],
482487
)
483488
def test_tether_client_client_options_credentials_file(
484-
client_class, transport_class, transport_name
489+
client_class, transport_class, transport_name, grpc_helpers
485490
):
486491
# Check the case credentials file is provided.
487492
options = client_options.ClientOptions(credentials_file="credentials.json")
493+
488494
with mock.patch.object(transport_class, "__init__") as patched:
489495
patched.return_value = None
490496
client = client_class(client_options=options, transport=transport_name)
@@ -518,6 +524,67 @@ def test_tether_client_client_options_from_dict():
518524
)
519525

520526

527+
@pytest.mark.parametrize(
528+
"client_class,transport_class,transport_name,grpc_helpers",
529+
[
530+
(TetherClient, transports.TetherGrpcTransport, "grpc", grpc_helpers),
531+
(
532+
TetherAsyncClient,
533+
transports.TetherGrpcAsyncIOTransport,
534+
"grpc_asyncio",
535+
grpc_helpers_async,
536+
),
537+
],
538+
)
539+
def test_tether_client_create_channel_credentials_file(
540+
client_class, transport_class, transport_name, grpc_helpers
541+
):
542+
# Check the case credentials file is provided.
543+
options = client_options.ClientOptions(credentials_file="credentials.json")
544+
545+
with mock.patch.object(transport_class, "__init__") as patched:
546+
patched.return_value = None
547+
client = client_class(client_options=options, transport=transport_name)
548+
patched.assert_called_once_with(
549+
credentials=None,
550+
credentials_file="credentials.json",
551+
host=client.DEFAULT_ENDPOINT,
552+
scopes=None,
553+
client_cert_source_for_mtls=None,
554+
quota_project_id=None,
555+
client_info=transports.base.DEFAULT_CLIENT_INFO,
556+
always_use_jwt_access=True,
557+
)
558+
559+
# test that the credentials from file are saved and used as the credentials.
560+
with mock.patch.object(
561+
google.auth, "load_credentials_from_file", autospec=True
562+
) as load_creds, mock.patch.object(
563+
google.auth, "default", autospec=True
564+
) as adc, mock.patch.object(
565+
grpc_helpers, "create_channel"
566+
) as create_channel:
567+
creds = ga_credentials.AnonymousCredentials()
568+
file_creds = ga_credentials.AnonymousCredentials()
569+
load_creds.return_value = (file_creds, None)
570+
adc.return_value = (creds, None)
571+
client = client_class(client_options=options, transport=transport_name)
572+
create_channel.assert_called_with(
573+
"apigeeconnect.googleapis.com:443",
574+
credentials=file_creds,
575+
credentials_file=None,
576+
quota_project_id=None,
577+
default_scopes=("https://www.googleapis.com/auth/cloud-platform",),
578+
scopes=None,
579+
default_host="apigeeconnect.googleapis.com",
580+
ssl_credentials=None,
581+
options=[
582+
("grpc.max_send_message_length", -1),
583+
("grpc.max_receive_message_length", -1),
584+
],
585+
)
586+
587+
521588
@pytest.mark.parametrize("request_type", [tether.EgressResponse, dict,])
522589
def test_egress(request_type, transport: str = "grpc"):
523590
client = TetherClient(

0 commit comments

Comments
 (0)