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

Commit 80fe038

Browse files
chore: use gapic-generator-python 0.62.1 (#149)
- [ ] 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 e62d1c8 commit 80fe038

File tree

5 files changed

+96
-24
lines changed

5 files changed

+96
-24
lines changed

google/cloud/functions_v1/services/cloud_functions_service/async_client.py

+6-7
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ async def get_function(
332332
333333
"""
334334
# Create or coerce a protobuf request object.
335-
# Sanity check: If we got a request object, we should *not* have
335+
# Quick check: If we got a request object, we should *not* have
336336
# gotten any keyword arguments that map to the request.
337337
has_flattened_params = any([name])
338338
if request is not None and has_flattened_params:
@@ -425,7 +425,7 @@ async def create_function(
425425
426426
"""
427427
# Create or coerce a protobuf request object.
428-
# Sanity check: If we got a request object, we should *not* have
428+
# Quick check: If we got a request object, we should *not* have
429429
# gotten any keyword arguments that map to the request.
430430
has_flattened_params = any([location, function])
431431
if request is not None and has_flattened_params:
@@ -509,7 +509,7 @@ async def update_function(
509509
510510
"""
511511
# Create or coerce a protobuf request object.
512-
# Sanity check: If we got a request object, we should *not* have
512+
# Quick check: If we got a request object, we should *not* have
513513
# gotten any keyword arguments that map to the request.
514514
has_flattened_params = any([function])
515515
if request is not None and has_flattened_params:
@@ -616,7 +616,7 @@ async def delete_function(
616616
617617
"""
618618
# Create or coerce a protobuf request object.
619-
# Sanity check: If we got a request object, we should *not* have
619+
# Quick check: If we got a request object, we should *not* have
620620
# gotten any keyword arguments that map to the request.
621621
has_flattened_params = any([name])
622622
if request is not None and has_flattened_params:
@@ -714,7 +714,7 @@ async def call_function(
714714
Response of CallFunction method.
715715
"""
716716
# Create or coerce a protobuf request object.
717-
# Sanity check: If we got a request object, we should *not* have
717+
# Quick check: If we got a request object, we should *not* have
718718
# gotten any keyword arguments that map to the request.
719719
has_flattened_params = any([name, data])
720720
if request is not None and has_flattened_params:
@@ -839,8 +839,7 @@ async def generate_download_url(
839839
limited period and should be used within minutes after
840840
generation.
841841
For more information about the signed URL usage see:
842-
https://cloud.google.com/storage/docs/access-
843-
control/signed-urls
842+
https://cloud.google.com/storage/docs/access-control/signed-urls
844843
845844
Args:
846845
request (Union[google.cloud.functions_v1.types.GenerateDownloadUrlRequest, dict]):

google/cloud/functions_v1/services/cloud_functions_service/client.py

+6-7
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ def get_function(
546546
547547
"""
548548
# Create or coerce a protobuf request object.
549-
# Sanity check: If we got a request object, we should *not* have
549+
# Quick check: If we got a request object, we should *not* have
550550
# gotten any keyword arguments that map to the request.
551551
has_flattened_params = any([name])
552552
if request is not None and has_flattened_params:
@@ -629,7 +629,7 @@ def create_function(
629629
630630
"""
631631
# Create or coerce a protobuf request object.
632-
# Sanity check: If we got a request object, we should *not* have
632+
# Quick check: If we got a request object, we should *not* have
633633
# gotten any keyword arguments that map to the request.
634634
has_flattened_params = any([location, function])
635635
if request is not None and has_flattened_params:
@@ -713,7 +713,7 @@ def update_function(
713713
714714
"""
715715
# Create or coerce a protobuf request object.
716-
# Sanity check: If we got a request object, we should *not* have
716+
# Quick check: If we got a request object, we should *not* have
717717
# gotten any keyword arguments that map to the request.
718718
has_flattened_params = any([function])
719719
if request is not None and has_flattened_params:
@@ -810,7 +810,7 @@ def delete_function(
810810
811811
"""
812812
# Create or coerce a protobuf request object.
813-
# Sanity check: If we got a request object, we should *not* have
813+
# Quick check: If we got a request object, we should *not* have
814814
# gotten any keyword arguments that map to the request.
815815
has_flattened_params = any([name])
816816
if request is not None and has_flattened_params:
@@ -898,7 +898,7 @@ def call_function(
898898
Response of CallFunction method.
899899
"""
900900
# Create or coerce a protobuf request object.
901-
# Sanity check: If we got a request object, we should *not* have
901+
# Quick check: If we got a request object, we should *not* have
902902
# gotten any keyword arguments that map to the request.
903903
has_flattened_params = any([name, data])
904904
if request is not None and has_flattened_params:
@@ -1024,8 +1024,7 @@ def generate_download_url(
10241024
limited period and should be used within minutes after
10251025
generation.
10261026
For more information about the signed URL usage see:
1027-
https://cloud.google.com/storage/docs/access-
1028-
control/signed-urls
1027+
https://cloud.google.com/storage/docs/access-control/signed-urls
10291028
10301029
Args:
10311030
request (Union[google.cloud.functions_v1.types.GenerateDownloadUrlRequest, dict]):

google/cloud/functions_v1/services/cloud_functions_service/transports/grpc.py

+6-4
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,
@@ -238,7 +241,7 @@ def operations_client(self) -> operations_v1.OperationsClient:
238241
This property caches on the instance; repeated calls return the same
239242
client.
240243
"""
241-
# Sanity check: Only create a new client if we do not already have one.
244+
# Quick check: Only create a new client if we do not already have one.
242245
if self._operations_client is None:
243246
self._operations_client = operations_v1.OperationsClient(self.grpc_channel)
244247

@@ -479,8 +482,7 @@ def generate_download_url(
479482
limited period and should be used within minutes after
480483
generation.
481484
For more information about the signed URL usage see:
482-
https://cloud.google.com/storage/docs/access-
483-
control/signed-urls
485+
https://cloud.google.com/storage/docs/access-control/signed-urls
484486
485487
Returns:
486488
Callable[[~.GenerateDownloadUrlRequest],

google/cloud/functions_v1/services/cloud_functions_service/transports/grpc_asyncio.py

+6-4
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,
@@ -240,7 +243,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient:
240243
This property caches on the instance; repeated calls return the same
241244
client.
242245
"""
243-
# Sanity check: Only create a new client if we do not already have one.
246+
# Quick check: Only create a new client if we do not already have one.
244247
if self._operations_client is None:
245248
self._operations_client = operations_v1.OperationsAsyncClient(
246249
self.grpc_channel
@@ -495,8 +498,7 @@ def generate_download_url(
495498
limited period and should be used within minutes after
496499
generation.
497500
For more information about the signed URL usage see:
498-
https://cloud.google.com/storage/docs/access-
499-
control/signed-urls
501+
https://cloud.google.com/storage/docs/access-control/signed-urls
500502
501503
Returns:
502504
Callable[[~.GenerateDownloadUrlRequest],

tests/unit/gapic/functions_v1/test_cloud_functions_service.py

+72-2
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
@@ -543,25 +544,28 @@ def test_cloud_functions_service_client_client_options_scopes(
543544

544545

545546
@pytest.mark.parametrize(
546-
"client_class,transport_class,transport_name",
547+
"client_class,transport_class,transport_name,grpc_helpers",
547548
[
548549
(
549550
CloudFunctionsServiceClient,
550551
transports.CloudFunctionsServiceGrpcTransport,
551552
"grpc",
553+
grpc_helpers,
552554
),
553555
(
554556
CloudFunctionsServiceAsyncClient,
555557
transports.CloudFunctionsServiceGrpcAsyncIOTransport,
556558
"grpc_asyncio",
559+
grpc_helpers_async,
557560
),
558561
],
559562
)
560563
def test_cloud_functions_service_client_client_options_credentials_file(
561-
client_class, transport_class, transport_name
564+
client_class, transport_class, transport_name, grpc_helpers
562565
):
563566
# Check the case credentials file is provided.
564567
options = client_options.ClientOptions(credentials_file="credentials.json")
568+
565569
with mock.patch.object(transport_class, "__init__") as patched:
566570
patched.return_value = None
567571
client = client_class(client_options=options, transport=transport_name)
@@ -597,6 +601,72 @@ def test_cloud_functions_service_client_client_options_from_dict():
597601
)
598602

599603

604+
@pytest.mark.parametrize(
605+
"client_class,transport_class,transport_name,grpc_helpers",
606+
[
607+
(
608+
CloudFunctionsServiceClient,
609+
transports.CloudFunctionsServiceGrpcTransport,
610+
"grpc",
611+
grpc_helpers,
612+
),
613+
(
614+
CloudFunctionsServiceAsyncClient,
615+
transports.CloudFunctionsServiceGrpcAsyncIOTransport,
616+
"grpc_asyncio",
617+
grpc_helpers_async,
618+
),
619+
],
620+
)
621+
def test_cloud_functions_service_client_create_channel_credentials_file(
622+
client_class, transport_class, transport_name, grpc_helpers
623+
):
624+
# Check the case credentials file is provided.
625+
options = client_options.ClientOptions(credentials_file="credentials.json")
626+
627+
with mock.patch.object(transport_class, "__init__") as patched:
628+
patched.return_value = None
629+
client = client_class(client_options=options, transport=transport_name)
630+
patched.assert_called_once_with(
631+
credentials=None,
632+
credentials_file="credentials.json",
633+
host=client.DEFAULT_ENDPOINT,
634+
scopes=None,
635+
client_cert_source_for_mtls=None,
636+
quota_project_id=None,
637+
client_info=transports.base.DEFAULT_CLIENT_INFO,
638+
always_use_jwt_access=True,
639+
)
640+
641+
# test that the credentials from file are saved and used as the credentials.
642+
with mock.patch.object(
643+
google.auth, "load_credentials_from_file", autospec=True
644+
) as load_creds, mock.patch.object(
645+
google.auth, "default", autospec=True
646+
) as adc, mock.patch.object(
647+
grpc_helpers, "create_channel"
648+
) as create_channel:
649+
creds = ga_credentials.AnonymousCredentials()
650+
file_creds = ga_credentials.AnonymousCredentials()
651+
load_creds.return_value = (file_creds, None)
652+
adc.return_value = (creds, None)
653+
client = client_class(client_options=options, transport=transport_name)
654+
create_channel.assert_called_with(
655+
"cloudfunctions.googleapis.com:443",
656+
credentials=file_creds,
657+
credentials_file=None,
658+
quota_project_id=None,
659+
default_scopes=("https://www.googleapis.com/auth/cloud-platform",),
660+
scopes=None,
661+
default_host="cloudfunctions.googleapis.com",
662+
ssl_credentials=None,
663+
options=[
664+
("grpc.max_send_message_length", -1),
665+
("grpc.max_receive_message_length", -1),
666+
],
667+
)
668+
669+
600670
@pytest.mark.parametrize("request_type", [functions.ListFunctionsRequest, dict,])
601671
def test_list_functions(request_type, transport: str = "grpc"):
602672
client = CloudFunctionsServiceClient(

0 commit comments

Comments
 (0)