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

Commit f9c770c

Browse files
chore: use gapic-generator-python 0.62.1 (#68)
- [ ] 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 19b0ddd commit f9c770c

File tree

5 files changed

+104
-25
lines changed

5 files changed

+104
-25
lines changed

google/cloud/gkeconnect/gateway_v1beta1/services/gateway_service/async_client.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,8 @@ async def get_resource(
224224
that can't be represented as JSON, such as raw binary or
225225
an HTML page.
226226
227-
This message can be used both in streaming and non-
228-
streaming API methods in the request as well as the
227+
This message can be used both in streaming and
228+
non-streaming API methods in the request as well as the
229229
response.
230230
231231
It can be used as a top-level request field, which is
@@ -358,8 +358,8 @@ async def post_resource(
358358
that can't be represented as JSON, such as raw binary or
359359
an HTML page.
360360
361-
This message can be used both in streaming and non-
362-
streaming API methods in the request as well as the
361+
This message can be used both in streaming and
362+
non-streaming API methods in the request as well as the
363363
response.
364364
365365
It can be used as a top-level request field, which is
@@ -492,8 +492,8 @@ async def delete_resource(
492492
that can't be represented as JSON, such as raw binary or
493493
an HTML page.
494494
495-
This message can be used both in streaming and non-
496-
streaming API methods in the request as well as the
495+
This message can be used both in streaming and
496+
non-streaming API methods in the request as well as the
497497
response.
498498
499499
It can be used as a top-level request field, which is
@@ -626,8 +626,8 @@ async def put_resource(
626626
that can't be represented as JSON, such as raw binary or
627627
an HTML page.
628628
629-
This message can be used both in streaming and non-
630-
streaming API methods in the request as well as the
629+
This message can be used both in streaming and
630+
non-streaming API methods in the request as well as the
631631
response.
632632
633633
It can be used as a top-level request field, which is
@@ -760,8 +760,8 @@ async def patch_resource(
760760
that can't be represented as JSON, such as raw binary or
761761
an HTML page.
762762
763-
This message can be used both in streaming and non-
764-
streaming API methods in the request as well as the
763+
This message can be used both in streaming and
764+
non-streaming API methods in the request as well as the
765765
response.
766766
767767
It can be used as a top-level request field, which is

google/cloud/gkeconnect/gateway_v1beta1/services/gateway_service/client.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -407,8 +407,8 @@ def get_resource(
407407
that can't be represented as JSON, such as raw binary or
408408
an HTML page.
409409
410-
This message can be used both in streaming and non-
411-
streaming API methods in the request as well as the
410+
This message can be used both in streaming and
411+
non-streaming API methods in the request as well as the
412412
response.
413413
414414
It can be used as a top-level request field, which is
@@ -540,8 +540,8 @@ def post_resource(
540540
that can't be represented as JSON, such as raw binary or
541541
an HTML page.
542542
543-
This message can be used both in streaming and non-
544-
streaming API methods in the request as well as the
543+
This message can be used both in streaming and
544+
non-streaming API methods in the request as well as the
545545
response.
546546
547547
It can be used as a top-level request field, which is
@@ -673,8 +673,8 @@ def delete_resource(
673673
that can't be represented as JSON, such as raw binary or
674674
an HTML page.
675675
676-
This message can be used both in streaming and non-
677-
streaming API methods in the request as well as the
676+
This message can be used both in streaming and
677+
non-streaming API methods in the request as well as the
678678
response.
679679
680680
It can be used as a top-level request field, which is
@@ -806,8 +806,8 @@ def put_resource(
806806
that can't be represented as JSON, such as raw binary or
807807
an HTML page.
808808
809-
This message can be used both in streaming and non-
810-
streaming API methods in the request as well as the
809+
This message can be used both in streaming and
810+
non-streaming API methods in the request as well as the
811811
response.
812812
813813
It can be used as a top-level request field, which is
@@ -939,8 +939,8 @@ def patch_resource(
939939
that can't be represented as JSON, such as raw binary or
940940
an HTML page.
941941
942-
This message can be used both in streaming and non-
943-
streaming API methods in the request as well as the
942+
This message can be used both in streaming and
943+
non-streaming API methods in the request as well as the
944944
response.
945945
946946
It can be used as a top-level request field, which is

google/cloud/gkeconnect/gateway_v1beta1/services/gateway_service/transports/grpc.py

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

google/cloud/gkeconnect/gateway_v1beta1/services/gateway_service/transports/grpc_asyncio.py

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

tests/unit/gapic/gateway_v1beta1/test_gateway_service.py

Lines changed: 76 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -512,21 +512,28 @@ def test_gateway_service_client_client_options_scopes(
512512

513513

514514
@pytest.mark.parametrize(
515-
"client_class,transport_class,transport_name",
515+
"client_class,transport_class,transport_name,grpc_helpers",
516516
[
517-
(GatewayServiceClient, transports.GatewayServiceGrpcTransport, "grpc"),
517+
(
518+
GatewayServiceClient,
519+
transports.GatewayServiceGrpcTransport,
520+
"grpc",
521+
grpc_helpers,
522+
),
518523
(
519524
GatewayServiceAsyncClient,
520525
transports.GatewayServiceGrpcAsyncIOTransport,
521526
"grpc_asyncio",
527+
grpc_helpers_async,
522528
),
523529
],
524530
)
525531
def test_gateway_service_client_client_options_credentials_file(
526-
client_class, transport_class, transport_name
532+
client_class, transport_class, transport_name, grpc_helpers
527533
):
528534
# Check the case credentials file is provided.
529535
options = client_options.ClientOptions(credentials_file="credentials.json")
536+
530537
with mock.patch.object(transport_class, "__init__") as patched:
531538
patched.return_value = None
532539
client = client_class(client_options=options, transport=transport_name)
@@ -562,6 +569,72 @@ def test_gateway_service_client_client_options_from_dict():
562569
)
563570

564571

572+
@pytest.mark.parametrize(
573+
"client_class,transport_class,transport_name,grpc_helpers",
574+
[
575+
(
576+
GatewayServiceClient,
577+
transports.GatewayServiceGrpcTransport,
578+
"grpc",
579+
grpc_helpers,
580+
),
581+
(
582+
GatewayServiceAsyncClient,
583+
transports.GatewayServiceGrpcAsyncIOTransport,
584+
"grpc_asyncio",
585+
grpc_helpers_async,
586+
),
587+
],
588+
)
589+
def test_gateway_service_client_create_channel_credentials_file(
590+
client_class, transport_class, transport_name, grpc_helpers
591+
):
592+
# Check the case credentials file is provided.
593+
options = client_options.ClientOptions(credentials_file="credentials.json")
594+
595+
with mock.patch.object(transport_class, "__init__") as patched:
596+
patched.return_value = None
597+
client = client_class(client_options=options, transport=transport_name)
598+
patched.assert_called_once_with(
599+
credentials=None,
600+
credentials_file="credentials.json",
601+
host=client.DEFAULT_ENDPOINT,
602+
scopes=None,
603+
client_cert_source_for_mtls=None,
604+
quota_project_id=None,
605+
client_info=transports.base.DEFAULT_CLIENT_INFO,
606+
always_use_jwt_access=True,
607+
)
608+
609+
# test that the credentials from file are saved and used as the credentials.
610+
with mock.patch.object(
611+
google.auth, "load_credentials_from_file", autospec=True
612+
) as load_creds, mock.patch.object(
613+
google.auth, "default", autospec=True
614+
) as adc, mock.patch.object(
615+
grpc_helpers, "create_channel"
616+
) as create_channel:
617+
creds = ga_credentials.AnonymousCredentials()
618+
file_creds = ga_credentials.AnonymousCredentials()
619+
load_creds.return_value = (file_creds, None)
620+
adc.return_value = (creds, None)
621+
client = client_class(client_options=options, transport=transport_name)
622+
create_channel.assert_called_with(
623+
"connectgateway.googleapis.com:443",
624+
credentials=file_creds,
625+
credentials_file=None,
626+
quota_project_id=None,
627+
default_scopes=("https://www.googleapis.com/auth/cloud-platform",),
628+
scopes=None,
629+
default_host="connectgateway.googleapis.com",
630+
ssl_credentials=None,
631+
options=[
632+
("grpc.max_send_message_length", -1),
633+
("grpc.max_receive_message_length", -1),
634+
],
635+
)
636+
637+
565638
@pytest.mark.parametrize("request_type", [httpbody_pb2.HttpBody, dict,])
566639
def test_get_resource(request_type, transport: str = "grpc"):
567640
client = GatewayServiceClient(

0 commit comments

Comments
 (0)