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

Commit ed0bec5

Browse files
chore: use gapic-generator-python 0.62.1 (#106)
- [ ] 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 91b316a commit ed0bec5

File tree

5 files changed

+102
-26
lines changed

5 files changed

+102
-26
lines changed

google/cloud/managedidentities_v1/services/managed_identities_service/async_client.py

+10-10
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ async def create_microsoft_ad_domain(
316316
317317
"""
318318
# Create or coerce a protobuf request object.
319-
# Sanity check: If we got a request object, we should *not* have
319+
# Quick check: If we got a request object, we should *not* have
320320
# gotten any keyword arguments that map to the request.
321321
has_flattened_params = any([parent, domain_name, domain])
322322
if request is not None and has_flattened_params:
@@ -401,7 +401,7 @@ async def reset_admin_password(
401401
402402
"""
403403
# Create or coerce a protobuf request object.
404-
# Sanity check: If we got a request object, we should *not* have
404+
# Quick check: If we got a request object, we should *not* have
405405
# gotten any keyword arguments that map to the request.
406406
has_flattened_params = any([name])
407407
if request is not None and has_flattened_params:
@@ -475,7 +475,7 @@ async def list_domains(
475475
476476
"""
477477
# Create or coerce a protobuf request object.
478-
# Sanity check: If we got a request object, we should *not* have
478+
# Quick check: If we got a request object, we should *not* have
479479
# gotten any keyword arguments that map to the request.
480480
has_flattened_params = any([parent])
481481
if request is not None and has_flattened_params:
@@ -552,7 +552,7 @@ async def get_domain(
552552
553553
"""
554554
# Create or coerce a protobuf request object.
555-
# Sanity check: If we got a request object, we should *not* have
555+
# Quick check: If we got a request object, we should *not* have
556556
# gotten any keyword arguments that map to the request.
557557
has_flattened_params = any([name])
558558
if request is not None and has_flattened_params:
@@ -640,7 +640,7 @@ async def update_domain(
640640
641641
"""
642642
# Create or coerce a protobuf request object.
643-
# Sanity check: If we got a request object, we should *not* have
643+
# Quick check: If we got a request object, we should *not* have
644644
# gotten any keyword arguments that map to the request.
645645
has_flattened_params = any([domain, update_mask])
646646
if request is not None and has_flattened_params:
@@ -736,7 +736,7 @@ async def delete_domain(
736736
737737
"""
738738
# Create or coerce a protobuf request object.
739-
# Sanity check: If we got a request object, we should *not* have
739+
# Quick check: If we got a request object, we should *not* have
740740
# gotten any keyword arguments that map to the request.
741741
has_flattened_params = any([name])
742742
if request is not None and has_flattened_params:
@@ -825,7 +825,7 @@ async def attach_trust(
825825
826826
"""
827827
# Create or coerce a protobuf request object.
828-
# Sanity check: If we got a request object, we should *not* have
828+
# Quick check: If we got a request object, we should *not* have
829829
# gotten any keyword arguments that map to the request.
830830
has_flattened_params = any([name, trust])
831831
if request is not None and has_flattened_params:
@@ -928,7 +928,7 @@ async def reconfigure_trust(
928928
929929
"""
930930
# Create or coerce a protobuf request object.
931-
# Sanity check: If we got a request object, we should *not* have
931+
# Quick check: If we got a request object, we should *not* have
932932
# gotten any keyword arguments that map to the request.
933933
has_flattened_params = any([name, target_domain_name, target_dns_ip_addresses])
934934
if request is not None and has_flattened_params:
@@ -1023,7 +1023,7 @@ async def detach_trust(
10231023
10241024
"""
10251025
# Create or coerce a protobuf request object.
1026-
# Sanity check: If we got a request object, we should *not* have
1026+
# Quick check: If we got a request object, we should *not* have
10271027
# gotten any keyword arguments that map to the request.
10281028
has_flattened_params = any([name, trust])
10291029
if request is not None and has_flattened_params:
@@ -1118,7 +1118,7 @@ async def validate_trust(
11181118
11191119
"""
11201120
# Create or coerce a protobuf request object.
1121-
# Sanity check: If we got a request object, we should *not* have
1121+
# Quick check: If we got a request object, we should *not* have
11221122
# gotten any keyword arguments that map to the request.
11231123
has_flattened_params = any([name, trust])
11241124
if request is not None and has_flattened_params:

google/cloud/managedidentities_v1/services/managed_identities_service/client.py

+10-10
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@ def create_microsoft_ad_domain(
510510
511511
"""
512512
# Create or coerce a protobuf request object.
513-
# Sanity check: If we got a request object, we should *not* have
513+
# Quick check: If we got a request object, we should *not* have
514514
# gotten any keyword arguments that map to the request.
515515
has_flattened_params = any([parent, domain_name, domain])
516516
if request is not None and has_flattened_params:
@@ -599,7 +599,7 @@ def reset_admin_password(
599599
600600
"""
601601
# Create or coerce a protobuf request object.
602-
# Sanity check: If we got a request object, we should *not* have
602+
# Quick check: If we got a request object, we should *not* have
603603
# gotten any keyword arguments that map to the request.
604604
has_flattened_params = any([name])
605605
if request is not None and has_flattened_params:
@@ -675,7 +675,7 @@ def list_domains(
675675
676676
"""
677677
# Create or coerce a protobuf request object.
678-
# Sanity check: If we got a request object, we should *not* have
678+
# Quick check: If we got a request object, we should *not* have
679679
# gotten any keyword arguments that map to the request.
680680
has_flattened_params = any([parent])
681681
if request is not None and has_flattened_params:
@@ -752,7 +752,7 @@ def get_domain(
752752
753753
"""
754754
# Create or coerce a protobuf request object.
755-
# Sanity check: If we got a request object, we should *not* have
755+
# Quick check: If we got a request object, we should *not* have
756756
# gotten any keyword arguments that map to the request.
757757
has_flattened_params = any([name])
758758
if request is not None and has_flattened_params:
@@ -840,7 +840,7 @@ def update_domain(
840840
841841
"""
842842
# Create or coerce a protobuf request object.
843-
# Sanity check: If we got a request object, we should *not* have
843+
# Quick check: If we got a request object, we should *not* have
844844
# gotten any keyword arguments that map to the request.
845845
has_flattened_params = any([domain, update_mask])
846846
if request is not None and has_flattened_params:
@@ -936,7 +936,7 @@ def delete_domain(
936936
937937
"""
938938
# Create or coerce a protobuf request object.
939-
# Sanity check: If we got a request object, we should *not* have
939+
# Quick check: If we got a request object, we should *not* have
940940
# gotten any keyword arguments that map to the request.
941941
has_flattened_params = any([name])
942942
if request is not None and has_flattened_params:
@@ -1025,7 +1025,7 @@ def attach_trust(
10251025
10261026
"""
10271027
# Create or coerce a protobuf request object.
1028-
# Sanity check: If we got a request object, we should *not* have
1028+
# Quick check: If we got a request object, we should *not* have
10291029
# gotten any keyword arguments that map to the request.
10301030
has_flattened_params = any([name, trust])
10311031
if request is not None and has_flattened_params:
@@ -1128,7 +1128,7 @@ def reconfigure_trust(
11281128
11291129
"""
11301130
# Create or coerce a protobuf request object.
1131-
# Sanity check: If we got a request object, we should *not* have
1131+
# Quick check: If we got a request object, we should *not* have
11321132
# gotten any keyword arguments that map to the request.
11331133
has_flattened_params = any([name, target_domain_name, target_dns_ip_addresses])
11341134
if request is not None and has_flattened_params:
@@ -1223,7 +1223,7 @@ def detach_trust(
12231223
12241224
"""
12251225
# Create or coerce a protobuf request object.
1226-
# Sanity check: If we got a request object, we should *not* have
1226+
# Quick check: If we got a request object, we should *not* have
12271227
# gotten any keyword arguments that map to the request.
12281228
has_flattened_params = any([name, trust])
12291229
if request is not None and has_flattened_params:
@@ -1318,7 +1318,7 @@ def validate_trust(
13181318
13191319
"""
13201320
# Create or coerce a protobuf request object.
1321-
# Sanity check: If we got a request object, we should *not* have
1321+
# Quick check: If we got a request object, we should *not* have
13221322
# gotten any keyword arguments that map to the request.
13231323
has_flattened_params = any([name, trust])
13241324
if request is not None and has_flattened_params:

google/cloud/managedidentities_v1/services/managed_identities_service/transports/grpc.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,11 @@ def __init__(
196196
if not self._grpc_channel:
197197
self._grpc_channel = type(self).create_channel(
198198
self._host,
199+
# use the credentials which are saved
199200
credentials=self._credentials,
200-
credentials_file=credentials_file,
201+
# Set ``credentials_file`` to ``None`` here as
202+
# the credentials that we saved earlier should be used.
203+
credentials_file=None,
201204
scopes=self._scopes,
202205
ssl_credentials=self._ssl_channel_credentials,
203206
quota_project_id=quota_project_id,
@@ -270,7 +273,7 @@ def operations_client(self) -> operations_v1.OperationsClient:
270273
This property caches on the instance; repeated calls return the same
271274
client.
272275
"""
273-
# Sanity check: Only create a new client if we do not already have one.
276+
# Quick check: Only create a new client if we do not already have one.
274277
if self._operations_client is None:
275278
self._operations_client = operations_v1.OperationsClient(self.grpc_channel)
276279

google/cloud/managedidentities_v1/services/managed_identities_service/transports/grpc_asyncio.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,11 @@ def __init__(
241241
if not self._grpc_channel:
242242
self._grpc_channel = type(self).create_channel(
243243
self._host,
244+
# use the credentials which are saved
244245
credentials=self._credentials,
245-
credentials_file=credentials_file,
246+
# Set ``credentials_file`` to ``None`` here as
247+
# the credentials that we saved earlier should be used.
248+
credentials_file=None,
246249
scopes=self._scopes,
247250
ssl_credentials=self._ssl_channel_credentials,
248251
quota_project_id=quota_project_id,
@@ -272,7 +275,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient:
272275
This property caches on the instance; repeated calls return the same
273276
client.
274277
"""
275-
# Sanity check: Only create a new client if we do not already have one.
278+
# Quick check: Only create a new client if we do not already have one.
276279
if self._operations_client is None:
277280
self._operations_client = operations_v1.OperationsAsyncClient(
278281
self.grpc_channel

tests/unit/gapic/managedidentities_v1/test_managed_identities_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
@@ -549,25 +550,28 @@ def test_managed_identities_service_client_client_options_scopes(
549550

550551

551552
@pytest.mark.parametrize(
552-
"client_class,transport_class,transport_name",
553+
"client_class,transport_class,transport_name,grpc_helpers",
553554
[
554555
(
555556
ManagedIdentitiesServiceClient,
556557
transports.ManagedIdentitiesServiceGrpcTransport,
557558
"grpc",
559+
grpc_helpers,
558560
),
559561
(
560562
ManagedIdentitiesServiceAsyncClient,
561563
transports.ManagedIdentitiesServiceGrpcAsyncIOTransport,
562564
"grpc_asyncio",
565+
grpc_helpers_async,
563566
),
564567
],
565568
)
566569
def test_managed_identities_service_client_client_options_credentials_file(
567-
client_class, transport_class, transport_name
570+
client_class, transport_class, transport_name, grpc_helpers
568571
):
569572
# Check the case credentials file is provided.
570573
options = client_options.ClientOptions(credentials_file="credentials.json")
574+
571575
with mock.patch.object(transport_class, "__init__") as patched:
572576
patched.return_value = None
573577
client = client_class(client_options=options, transport=transport_name)
@@ -603,6 +607,72 @@ def test_managed_identities_service_client_client_options_from_dict():
603607
)
604608

605609

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

0 commit comments

Comments
 (0)