Skip to content

Commit f4f616a

Browse files
chore: use gapic-generator-python 0.62.1 (#179)
- [ ] 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 52e4a64 commit f4f616a

File tree

11 files changed

+186
-21
lines changed

11 files changed

+186
-21
lines changed

packages/google-cloud-trace/google/cloud/trace_v1/services/trace_service/async_client.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ async def list_traces(
241241
242242
"""
243243
# Create or coerce a protobuf request object.
244-
# Sanity check: If we got a request object, we should *not* have
244+
# Quick check: If we got a request object, we should *not* have
245245
# gotten any keyword arguments that map to the request.
246246
has_flattened_params = any([project_id])
247247
if request is not None and has_flattened_params:
@@ -331,7 +331,7 @@ async def get_trace(
331331
332332
"""
333333
# Create or coerce a protobuf request object.
334-
# Sanity check: If we got a request object, we should *not* have
334+
# Quick check: If we got a request object, we should *not* have
335335
# gotten any keyword arguments that map to the request.
336336
has_flattened_params = any([project_id, trace_id])
337337
if request is not None and has_flattened_params:
@@ -414,7 +414,7 @@ async def patch_traces(
414414
sent along with the request as metadata.
415415
"""
416416
# Create or coerce a protobuf request object.
417-
# Sanity check: If we got a request object, we should *not* have
417+
# Quick check: If we got a request object, we should *not* have
418418
# gotten any keyword arguments that map to the request.
419419
has_flattened_params = any([project_id, traces])
420420
if request is not None and has_flattened_params:

packages/google-cloud-trace/google/cloud/trace_v1/services/trace_service/client.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ def list_traces(
426426
427427
"""
428428
# Create or coerce a protobuf request object.
429-
# Sanity check: If we got a request object, we should *not* have
429+
# Quick check: If we got a request object, we should *not* have
430430
# gotten any keyword arguments that map to the request.
431431
has_flattened_params = any([project_id])
432432
if request is not None and has_flattened_params:
@@ -506,7 +506,7 @@ def get_trace(
506506
507507
"""
508508
# Create or coerce a protobuf request object.
509-
# Sanity check: If we got a request object, we should *not* have
509+
# Quick check: If we got a request object, we should *not* have
510510
# gotten any keyword arguments that map to the request.
511511
has_flattened_params = any([project_id, trace_id])
512512
if request is not None and has_flattened_params:
@@ -579,7 +579,7 @@ def patch_traces(
579579
sent along with the request as metadata.
580580
"""
581581
# Create or coerce a protobuf request object.
582-
# Sanity check: If we got a request object, we should *not* have
582+
# Quick check: If we got a request object, we should *not* have
583583
# gotten any keyword arguments that map to the request.
584584
has_flattened_params = any([project_id, traces])
585585
if request is not None and has_flattened_params:

packages/google-cloud-trace/google/cloud/trace_v1/services/trace_service/transports/grpc.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,11 @@ def __init__(
164164
if not self._grpc_channel:
165165
self._grpc_channel = type(self).create_channel(
166166
self._host,
167+
# use the credentials which are saved
167168
credentials=self._credentials,
168-
credentials_file=credentials_file,
169+
# Set ``credentials_file`` to ``None`` here as
170+
# the credentials that we saved earlier should be used.
171+
credentials_file=None,
169172
scopes=self._scopes,
170173
ssl_credentials=self._ssl_channel_credentials,
171174
quota_project_id=quota_project_id,

packages/google-cloud-trace/google/cloud/trace_v1/services/trace_service/transports/grpc_asyncio.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,11 @@ def __init__(
209209
if not self._grpc_channel:
210210
self._grpc_channel = type(self).create_channel(
211211
self._host,
212+
# use the credentials which are saved
212213
credentials=self._credentials,
213-
credentials_file=credentials_file,
214+
# Set ``credentials_file`` to ``None`` here as
215+
# the credentials that we saved earlier should be used.
216+
credentials_file=None,
214217
scopes=self._scopes,
215218
ssl_credentials=self._ssl_channel_credentials,
216219
quota_project_id=quota_project_id,

packages/google-cloud-trace/google/cloud/trace_v1/types/trace.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@ class TraceSpan(proto.Message):
8888
bytes. The span name is sanitized and displayed
8989
in the Stackdriver Trace tool in the Google
9090
Cloud Platform Console.
91-
The name may be a method name or some other per-
92-
call site name. For the same executable and the
93-
same call point, a best practice is to use a
91+
The name may be a method name or some other
92+
per-call site name. For the same executable and
93+
the same call point, a best practice is to use a
9494
consistent name, which makes it easier to
9595
correlate cross-trace spans.
9696
start_time (google.protobuf.timestamp_pb2.Timestamp):

packages/google-cloud-trace/google/cloud/trace_v2/services/trace_service/async_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ async def batch_write_spans(
246246
sent along with the request as metadata.
247247
"""
248248
# Create or coerce a protobuf request object.
249-
# Sanity check: If we got a request object, we should *not* have
249+
# Quick check: If we got a request object, we should *not* have
250250
# gotten any keyword arguments that map to the request.
251251
has_flattened_params = any([name, spans])
252252
if request is not None and has_flattened_params:

packages/google-cloud-trace/google/cloud/trace_v2/services/trace_service/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ def batch_write_spans(
445445
sent along with the request as metadata.
446446
"""
447447
# Create or coerce a protobuf request object.
448-
# Sanity check: If we got a request object, we should *not* have
448+
# Quick check: If we got a request object, we should *not* have
449449
# gotten any keyword arguments that map to the request.
450450
has_flattened_params = any([name, spans])
451451
if request is not None and has_flattened_params:

packages/google-cloud-trace/google/cloud/trace_v2/services/trace_service/transports/grpc.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,11 @@ def __init__(
165165
if not self._grpc_channel:
166166
self._grpc_channel = type(self).create_channel(
167167
self._host,
168+
# use the credentials which are saved
168169
credentials=self._credentials,
169-
credentials_file=credentials_file,
170+
# Set ``credentials_file`` to ``None`` here as
171+
# the credentials that we saved earlier should be used.
172+
credentials_file=None,
170173
scopes=self._scopes,
171174
ssl_credentials=self._ssl_channel_credentials,
172175
quota_project_id=quota_project_id,

packages/google-cloud-trace/google/cloud/trace_v2/services/trace_service/transports/grpc_asyncio.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,11 @@ def __init__(
210210
if not self._grpc_channel:
211211
self._grpc_channel = type(self).create_channel(
212212
self._host,
213+
# use the credentials which are saved
213214
credentials=self._credentials,
214-
credentials_file=credentials_file,
215+
# Set ``credentials_file`` to ``None`` here as
216+
# the credentials that we saved earlier should be used.
217+
credentials_file=None,
215218
scopes=self._scopes,
216219
ssl_credentials=self._ssl_channel_credentials,
217220
quota_project_id=quota_project_id,

packages/google-cloud-trace/tests/unit/gapic/trace_v1/test_trace_service.py

Lines changed: 80 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -494,21 +494,28 @@ def test_trace_service_client_client_options_scopes(
494494

495495

496496
@pytest.mark.parametrize(
497-
"client_class,transport_class,transport_name",
497+
"client_class,transport_class,transport_name,grpc_helpers",
498498
[
499-
(TraceServiceClient, transports.TraceServiceGrpcTransport, "grpc"),
499+
(
500+
TraceServiceClient,
501+
transports.TraceServiceGrpcTransport,
502+
"grpc",
503+
grpc_helpers,
504+
),
500505
(
501506
TraceServiceAsyncClient,
502507
transports.TraceServiceGrpcAsyncIOTransport,
503508
"grpc_asyncio",
509+
grpc_helpers_async,
504510
),
505511
],
506512
)
507513
def test_trace_service_client_client_options_credentials_file(
508-
client_class, transport_class, transport_name
514+
client_class, transport_class, transport_name, grpc_helpers
509515
):
510516
# Check the case credentials file is provided.
511517
options = client_options.ClientOptions(credentials_file="credentials.json")
518+
512519
with mock.patch.object(transport_class, "__init__") as patched:
513520
patched.return_value = None
514521
client = client_class(client_options=options, transport=transport_name)
@@ -542,6 +549,76 @@ def test_trace_service_client_client_options_from_dict():
542549
)
543550

544551

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

0 commit comments

Comments
 (0)