Skip to content

Commit c102fed

Browse files
chore: use gapic-generator-python 0.62.1 (#18)
- [ ] 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 bc3f542 commit c102fed

File tree

5 files changed

+90
-16
lines changed

5 files changed

+90
-16
lines changed

packages/google-cloud-ids/google/cloud/ids_v1/services/ids/async_client.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ async def list_endpoints(
231231
232232
"""
233233
# Create or coerce a protobuf request object.
234-
# Sanity check: If we got a request object, we should *not* have
234+
# Quick check: If we got a request object, we should *not* have
235235
# gotten any keyword arguments that map to the request.
236236
has_flattened_params = any([parent])
237237
if request is not None and has_flattened_params:
@@ -318,7 +318,7 @@ async def get_endpoint(
318318
319319
"""
320320
# Create or coerce a protobuf request object.
321-
# Sanity check: If we got a request object, we should *not* have
321+
# Quick check: If we got a request object, we should *not* have
322322
# gotten any keyword arguments that map to the request.
323323
has_flattened_params = any([name])
324324
if request is not None and has_flattened_params:
@@ -416,7 +416,7 @@ async def create_endpoint(
416416
417417
"""
418418
# Create or coerce a protobuf request object.
419-
# Sanity check: If we got a request object, we should *not* have
419+
# Quick check: If we got a request object, we should *not* have
420420
# gotten any keyword arguments that map to the request.
421421
has_flattened_params = any([parent, endpoint, endpoint_id])
422422
if request is not None and has_flattened_params:
@@ -511,7 +511,7 @@ async def delete_endpoint(
511511
512512
"""
513513
# Create or coerce a protobuf request object.
514-
# Sanity check: If we got a request object, we should *not* have
514+
# Quick check: If we got a request object, we should *not* have
515515
# gotten any keyword arguments that map to the request.
516516
has_flattened_params = any([name])
517517
if request is not None and has_flattened_params:

packages/google-cloud-ids/google/cloud/ids_v1/services/ids/client.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ def list_endpoints(
436436
437437
"""
438438
# Create or coerce a protobuf request object.
439-
# Sanity check: If we got a request object, we should *not* have
439+
# Quick check: If we got a request object, we should *not* have
440440
# gotten any keyword arguments that map to the request.
441441
has_flattened_params = any([parent])
442442
if request is not None and has_flattened_params:
@@ -514,7 +514,7 @@ def get_endpoint(
514514
515515
"""
516516
# Create or coerce a protobuf request object.
517-
# Sanity check: If we got a request object, we should *not* have
517+
# Quick check: If we got a request object, we should *not* have
518518
# gotten any keyword arguments that map to the request.
519519
has_flattened_params = any([name])
520520
if request is not None and has_flattened_params:
@@ -603,7 +603,7 @@ def create_endpoint(
603603
604604
"""
605605
# Create or coerce a protobuf request object.
606-
# Sanity check: If we got a request object, we should *not* have
606+
# Quick check: If we got a request object, we should *not* have
607607
# gotten any keyword arguments that map to the request.
608608
has_flattened_params = any([parent, endpoint, endpoint_id])
609609
if request is not None and has_flattened_params:
@@ -698,7 +698,7 @@ def delete_endpoint(
698698
699699
"""
700700
# Create or coerce a protobuf request object.
701-
# Sanity check: If we got a request object, we should *not* have
701+
# Quick check: If we got a request object, we should *not* have
702702
# gotten any keyword arguments that map to the request.
703703
has_flattened_params = any([name])
704704
if request is not None and has_flattened_params:

packages/google-cloud-ids/google/cloud/ids_v1/services/ids/transports/grpc.py

Lines changed: 5 additions & 2 deletions
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,
@@ -235,7 +238,7 @@ def operations_client(self) -> operations_v1.OperationsClient:
235238
This property caches on the instance; repeated calls return the same
236239
client.
237240
"""
238-
# Sanity check: Only create a new client if we do not already have one.
241+
# Quick check: Only create a new client if we do not already have one.
239242
if self._operations_client is None:
240243
self._operations_client = operations_v1.OperationsClient(self.grpc_channel)
241244

packages/google-cloud-ids/google/cloud/ids_v1/services/ids/transports/grpc_asyncio.py

Lines changed: 5 additions & 2 deletions
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,
@@ -237,7 +240,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient:
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.OperationsAsyncClient(
243246
self.grpc_channel

packages/google-cloud-ids/tests/unit/gapic/ids_v1/test_ids.py

Lines changed: 72 additions & 4 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
@@ -458,17 +459,23 @@ def test_ids_client_client_options_scopes(
458459

459460

460461
@pytest.mark.parametrize(
461-
"client_class,transport_class,transport_name",
462+
"client_class,transport_class,transport_name,grpc_helpers",
462463
[
463-
(IDSClient, transports.IDSGrpcTransport, "grpc"),
464-
(IDSAsyncClient, transports.IDSGrpcAsyncIOTransport, "grpc_asyncio"),
464+
(IDSClient, transports.IDSGrpcTransport, "grpc", grpc_helpers),
465+
(
466+
IDSAsyncClient,
467+
transports.IDSGrpcAsyncIOTransport,
468+
"grpc_asyncio",
469+
grpc_helpers_async,
470+
),
465471
],
466472
)
467473
def test_ids_client_client_options_credentials_file(
468-
client_class, transport_class, transport_name
474+
client_class, transport_class, transport_name, grpc_helpers
469475
):
470476
# Check the case credentials file is provided.
471477
options = client_options.ClientOptions(credentials_file="credentials.json")
478+
472479
with mock.patch.object(transport_class, "__init__") as patched:
473480
patched.return_value = None
474481
client = client_class(client_options=options, transport=transport_name)
@@ -502,6 +509,67 @@ def test_ids_client_client_options_from_dict():
502509
)
503510

504511

512+
@pytest.mark.parametrize(
513+
"client_class,transport_class,transport_name,grpc_helpers",
514+
[
515+
(IDSClient, transports.IDSGrpcTransport, "grpc", grpc_helpers),
516+
(
517+
IDSAsyncClient,
518+
transports.IDSGrpcAsyncIOTransport,
519+
"grpc_asyncio",
520+
grpc_helpers_async,
521+
),
522+
],
523+
)
524+
def test_ids_client_create_channel_credentials_file(
525+
client_class, transport_class, transport_name, grpc_helpers
526+
):
527+
# Check the case credentials file is provided.
528+
options = client_options.ClientOptions(credentials_file="credentials.json")
529+
530+
with mock.patch.object(transport_class, "__init__") as patched:
531+
patched.return_value = None
532+
client = client_class(client_options=options, transport=transport_name)
533+
patched.assert_called_once_with(
534+
credentials=None,
535+
credentials_file="credentials.json",
536+
host=client.DEFAULT_ENDPOINT,
537+
scopes=None,
538+
client_cert_source_for_mtls=None,
539+
quota_project_id=None,
540+
client_info=transports.base.DEFAULT_CLIENT_INFO,
541+
always_use_jwt_access=True,
542+
)
543+
544+
# test that the credentials from file are saved and used as the credentials.
545+
with mock.patch.object(
546+
google.auth, "load_credentials_from_file", autospec=True
547+
) as load_creds, mock.patch.object(
548+
google.auth, "default", autospec=True
549+
) as adc, mock.patch.object(
550+
grpc_helpers, "create_channel"
551+
) as create_channel:
552+
creds = ga_credentials.AnonymousCredentials()
553+
file_creds = ga_credentials.AnonymousCredentials()
554+
load_creds.return_value = (file_creds, None)
555+
adc.return_value = (creds, None)
556+
client = client_class(client_options=options, transport=transport_name)
557+
create_channel.assert_called_with(
558+
"ids.googleapis.com:443",
559+
credentials=file_creds,
560+
credentials_file=None,
561+
quota_project_id=None,
562+
default_scopes=("https://www.googleapis.com/auth/cloud-platform",),
563+
scopes=None,
564+
default_host="ids.googleapis.com",
565+
ssl_credentials=None,
566+
options=[
567+
("grpc.max_send_message_length", -1),
568+
("grpc.max_receive_message_length", -1),
569+
],
570+
)
571+
572+
505573
@pytest.mark.parametrize("request_type", [ids.ListEndpointsRequest, dict,])
506574
def test_list_endpoints(request_type, transport: str = "grpc"):
507575
client = IDSClient(

0 commit comments

Comments
 (0)