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

Commit a4fe64d

Browse files
chore: use gapic-generator-python 0.62.1 (#64)
- [ ] 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 57c2e93 commit a4fe64d

File tree

10 files changed

+170
-26
lines changed

10 files changed

+170
-26
lines changed

google/cloud/debugger_v2/services/controller2/async_client.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ async def register_debuggee(
262262
Response for registering a debuggee.
263263
"""
264264
# Create or coerce a protobuf request object.
265-
# Sanity check: If we got a request object, we should *not* have
265+
# Quick check: If we got a request object, we should *not* have
266266
# gotten any keyword arguments that map to the request.
267267
has_flattened_params = any([debuggee])
268268
if request is not None and has_flattened_params:
@@ -337,7 +337,7 @@ async def list_active_breakpoints(
337337
338338
"""
339339
# Create or coerce a protobuf request object.
340-
# Sanity check: If we got a request object, we should *not* have
340+
# Quick check: If we got a request object, we should *not* have
341341
# gotten any keyword arguments that map to the request.
342342
has_flattened_params = any([debuggee_id])
343343
if request is not None and has_flattened_params:
@@ -430,7 +430,7 @@ async def update_active_breakpoint(
430430
431431
"""
432432
# Create or coerce a protobuf request object.
433-
# Sanity check: If we got a request object, we should *not* have
433+
# Quick check: If we got a request object, we should *not* have
434434
# gotten any keyword arguments that map to the request.
435435
has_flattened_params = any([debuggee_id, breakpoint_])
436436
if request is not None and has_flattened_params:

google/cloud/debugger_v2/services/controller2/client.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ def register_debuggee(
447447
Response for registering a debuggee.
448448
"""
449449
# Create or coerce a protobuf request object.
450-
# Sanity check: If we got a request object, we should *not* have
450+
# Quick check: If we got a request object, we should *not* have
451451
# gotten any keyword arguments that map to the request.
452452
has_flattened_params = any([debuggee])
453453
if request is not None and has_flattened_params:
@@ -522,7 +522,7 @@ def list_active_breakpoints(
522522
523523
"""
524524
# Create or coerce a protobuf request object.
525-
# Sanity check: If we got a request object, we should *not* have
525+
# Quick check: If we got a request object, we should *not* have
526526
# gotten any keyword arguments that map to the request.
527527
has_flattened_params = any([debuggee_id])
528528
if request is not None and has_flattened_params:
@@ -605,7 +605,7 @@ def update_active_breakpoint(
605605
606606
"""
607607
# Create or coerce a protobuf request object.
608-
# Sanity check: If we got a request object, we should *not* have
608+
# Quick check: If we got a request object, we should *not* have
609609
# gotten any keyword arguments that map to the request.
610610
has_flattened_params = any([debuggee_id, breakpoint_])
611611
if request is not None and has_flattened_params:

google/cloud/debugger_v2/services/controller2/transports/grpc.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,11 @@ def __init__(
179179
if not self._grpc_channel:
180180
self._grpc_channel = type(self).create_channel(
181181
self._host,
182+
# use the credentials which are saved
182183
credentials=self._credentials,
183-
credentials_file=credentials_file,
184+
# Set ``credentials_file`` to ``None`` here as
185+
# the credentials that we saved earlier should be used.
186+
credentials_file=None,
184187
scopes=self._scopes,
185188
ssl_credentials=self._ssl_channel_credentials,
186189
quota_project_id=quota_project_id,

google/cloud/debugger_v2/services/controller2/transports/grpc_asyncio.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,11 @@ def __init__(
224224
if not self._grpc_channel:
225225
self._grpc_channel = type(self).create_channel(
226226
self._host,
227+
# use the credentials which are saved
227228
credentials=self._credentials,
228-
credentials_file=credentials_file,
229+
# Set ``credentials_file`` to ``None`` here as
230+
# the credentials that we saved earlier should be used.
231+
credentials_file=None,
229232
scopes=self._scopes,
230233
ssl_credentials=self._ssl_channel_credentials,
231234
quota_project_id=quota_project_id,

google/cloud/debugger_v2/services/debugger2/async_client.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ async def set_breakpoint(
256256
Response for setting a breakpoint.
257257
"""
258258
# Create or coerce a protobuf request object.
259-
# Sanity check: If we got a request object, we should *not* have
259+
# Quick check: If we got a request object, we should *not* have
260260
# gotten any keyword arguments that map to the request.
261261
has_flattened_params = any([debuggee_id, breakpoint_, client_version])
262262
if request is not None and has_flattened_params:
@@ -342,7 +342,7 @@ async def get_breakpoint(
342342
343343
"""
344344
# Create or coerce a protobuf request object.
345-
# Sanity check: If we got a request object, we should *not* have
345+
# Quick check: If we got a request object, we should *not* have
346346
# gotten any keyword arguments that map to the request.
347347
has_flattened_params = any([debuggee_id, breakpoint_id, client_version])
348348
if request is not None and has_flattened_params:
@@ -431,7 +431,7 @@ async def delete_breakpoint(
431431
sent along with the request as metadata.
432432
"""
433433
# Create or coerce a protobuf request object.
434-
# Sanity check: If we got a request object, we should *not* have
434+
# Quick check: If we got a request object, we should *not* have
435435
# gotten any keyword arguments that map to the request.
436436
has_flattened_params = any([debuggee_id, breakpoint_id, client_version])
437437
if request is not None and has_flattened_params:
@@ -515,7 +515,7 @@ async def list_breakpoints(
515515
Response for listing breakpoints.
516516
"""
517517
# Create or coerce a protobuf request object.
518-
# Sanity check: If we got a request object, we should *not* have
518+
# Quick check: If we got a request object, we should *not* have
519519
# gotten any keyword arguments that map to the request.
520520
has_flattened_params = any([debuggee_id, client_version])
521521
if request is not None and has_flattened_params:
@@ -598,7 +598,7 @@ async def list_debuggees(
598598
Response for listing debuggees.
599599
"""
600600
# Create or coerce a protobuf request object.
601-
# Sanity check: If we got a request object, we should *not* have
601+
# Quick check: If we got a request object, we should *not* have
602602
# gotten any keyword arguments that map to the request.
603603
has_flattened_params = any([project, client_version])
604604
if request is not None and has_flattened_params:

google/cloud/debugger_v2/services/debugger2/client.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ def set_breakpoint(
443443
Response for setting a breakpoint.
444444
"""
445445
# Create or coerce a protobuf request object.
446-
# Sanity check: If we got a request object, we should *not* have
446+
# Quick check: If we got a request object, we should *not* have
447447
# gotten any keyword arguments that map to the request.
448448
has_flattened_params = any([debuggee_id, breakpoint_, client_version])
449449
if request is not None and has_flattened_params:
@@ -529,7 +529,7 @@ def get_breakpoint(
529529
530530
"""
531531
# Create or coerce a protobuf request object.
532-
# Sanity check: If we got a request object, we should *not* have
532+
# Quick check: If we got a request object, we should *not* have
533533
# gotten any keyword arguments that map to the request.
534534
has_flattened_params = any([debuggee_id, breakpoint_id, client_version])
535535
if request is not None and has_flattened_params:
@@ -608,7 +608,7 @@ def delete_breakpoint(
608608
sent along with the request as metadata.
609609
"""
610610
# Create or coerce a protobuf request object.
611-
# Sanity check: If we got a request object, we should *not* have
611+
# Quick check: If we got a request object, we should *not* have
612612
# gotten any keyword arguments that map to the request.
613613
has_flattened_params = any([debuggee_id, breakpoint_id, client_version])
614614
if request is not None and has_flattened_params:
@@ -682,7 +682,7 @@ def list_breakpoints(
682682
Response for listing breakpoints.
683683
"""
684684
# Create or coerce a protobuf request object.
685-
# Sanity check: If we got a request object, we should *not* have
685+
# Quick check: If we got a request object, we should *not* have
686686
# gotten any keyword arguments that map to the request.
687687
has_flattened_params = any([debuggee_id, client_version])
688688
if request is not None and has_flattened_params:
@@ -755,7 +755,7 @@ def list_debuggees(
755755
Response for listing debuggees.
756756
"""
757757
# Create or coerce a protobuf request object.
758-
# Sanity check: If we got a request object, we should *not* have
758+
# Quick check: If we got a request object, we should *not* have
759759
# gotten any keyword arguments that map to the request.
760760
has_flattened_params = any([project, client_version])
761761
if request is not None and has_flattened_params:

google/cloud/debugger_v2/services/debugger2/transports/grpc.py

Lines changed: 4 additions & 1 deletion
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,

google/cloud/debugger_v2/services/debugger2/transports/grpc_asyncio.py

Lines changed: 4 additions & 1 deletion
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,

tests/unit/gapic/debugger_v2/test_controller2.py

Lines changed: 69 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -496,21 +496,23 @@ def test_controller2_client_client_options_scopes(
496496

497497

498498
@pytest.mark.parametrize(
499-
"client_class,transport_class,transport_name",
499+
"client_class,transport_class,transport_name,grpc_helpers",
500500
[
501-
(Controller2Client, transports.Controller2GrpcTransport, "grpc"),
501+
(Controller2Client, transports.Controller2GrpcTransport, "grpc", grpc_helpers),
502502
(
503503
Controller2AsyncClient,
504504
transports.Controller2GrpcAsyncIOTransport,
505505
"grpc_asyncio",
506+
grpc_helpers_async,
506507
),
507508
],
508509
)
509510
def test_controller2_client_client_options_credentials_file(
510-
client_class, transport_class, transport_name
511+
client_class, transport_class, transport_name, grpc_helpers
511512
):
512513
# Check the case credentials file is provided.
513514
options = client_options.ClientOptions(credentials_file="credentials.json")
515+
514516
with mock.patch.object(transport_class, "__init__") as patched:
515517
patched.return_value = None
516518
client = client_class(client_options=options, transport=transport_name)
@@ -544,6 +546,70 @@ def test_controller2_client_client_options_from_dict():
544546
)
545547

546548

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

tests/unit/gapic/debugger_v2/test_debugger2.py

Lines changed: 69 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -491,21 +491,23 @@ def test_debugger2_client_client_options_scopes(
491491

492492

493493
@pytest.mark.parametrize(
494-
"client_class,transport_class,transport_name",
494+
"client_class,transport_class,transport_name,grpc_helpers",
495495
[
496-
(Debugger2Client, transports.Debugger2GrpcTransport, "grpc"),
496+
(Debugger2Client, transports.Debugger2GrpcTransport, "grpc", grpc_helpers),
497497
(
498498
Debugger2AsyncClient,
499499
transports.Debugger2GrpcAsyncIOTransport,
500500
"grpc_asyncio",
501+
grpc_helpers_async,
501502
),
502503
],
503504
)
504505
def test_debugger2_client_client_options_credentials_file(
505-
client_class, transport_class, transport_name
506+
client_class, transport_class, transport_name, grpc_helpers
506507
):
507508
# Check the case credentials file is provided.
508509
options = client_options.ClientOptions(credentials_file="credentials.json")
510+
509511
with mock.patch.object(transport_class, "__init__") as patched:
510512
patched.return_value = None
511513
client = client_class(client_options=options, transport=transport_name)
@@ -539,6 +541,70 @@ def test_debugger2_client_client_options_from_dict():
539541
)
540542

541543

544+
@pytest.mark.parametrize(
545+
"client_class,transport_class,transport_name,grpc_helpers",
546+
[
547+
(Debugger2Client, transports.Debugger2GrpcTransport, "grpc", grpc_helpers),
548+
(
549+
Debugger2AsyncClient,
550+
transports.Debugger2GrpcAsyncIOTransport,
551+
"grpc_asyncio",
552+
grpc_helpers_async,
553+
),
554+
],
555+
)
556+
def test_debugger2_client_create_channel_credentials_file(
557+
client_class, transport_class, transport_name, grpc_helpers
558+
):
559+
# Check the case credentials file is provided.
560+
options = client_options.ClientOptions(credentials_file="credentials.json")
561+
562+
with mock.patch.object(transport_class, "__init__") as patched:
563+
patched.return_value = None
564+
client = client_class(client_options=options, transport=transport_name)
565+
patched.assert_called_once_with(
566+
credentials=None,
567+
credentials_file="credentials.json",
568+
host=client.DEFAULT_ENDPOINT,
569+
scopes=None,
570+
client_cert_source_for_mtls=None,
571+
quota_project_id=None,
572+
client_info=transports.base.DEFAULT_CLIENT_INFO,
573+
always_use_jwt_access=True,
574+
)
575+
576+
# test that the credentials from file are saved and used as the credentials.
577+
with mock.patch.object(
578+
google.auth, "load_credentials_from_file", autospec=True
579+
) as load_creds, mock.patch.object(
580+
google.auth, "default", autospec=True
581+
) as adc, mock.patch.object(
582+
grpc_helpers, "create_channel"
583+
) as create_channel:
584+
creds = ga_credentials.AnonymousCredentials()
585+
file_creds = ga_credentials.AnonymousCredentials()
586+
load_creds.return_value = (file_creds, None)
587+
adc.return_value = (creds, None)
588+
client = client_class(client_options=options, transport=transport_name)
589+
create_channel.assert_called_with(
590+
"clouddebugger.googleapis.com:443",
591+
credentials=file_creds,
592+
credentials_file=None,
593+
quota_project_id=None,
594+
default_scopes=(
595+
"https://www.googleapis.com/auth/cloud-platform",
596+
"https://www.googleapis.com/auth/cloud_debugger",
597+
),
598+
scopes=None,
599+
default_host="clouddebugger.googleapis.com",
600+
ssl_credentials=None,
601+
options=[
602+
("grpc.max_send_message_length", -1),
603+
("grpc.max_receive_message_length", -1),
604+
],
605+
)
606+
607+
542608
@pytest.mark.parametrize("request_type", [debugger.SetBreakpointRequest, dict,])
543609
def test_set_breakpoint(request_type, transport: str = "grpc"):
544610
client = Debugger2Client(

0 commit comments

Comments
 (0)