Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
This repository was archived by the owner on Mar 15, 2025. It is now read-only.

Commit 0dd6187

Browse filesBrowse files
chore: use gapic-generator-python 0.62.1 (#116)
- [ ] 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 90fa145 commit 0dd6187
Copy full SHA for 0dd6187

File tree

Expand file treeCollapse file tree

6 files changed

+92
-23
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

6 files changed

+92
-23
lines changed
Open diff view settings
Collapse file

‎google/cloud/orgpolicy_v2/services/org_policy/async_client.py‎

Copy file name to clipboardExpand all lines: google/cloud/orgpolicy_v2/services/org_policy/async_client.py
+7-7Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ async def list_constraints(
268268
269269
"""
270270
# Create or coerce a protobuf request object.
271-
# Sanity check: If we got a request object, we should *not* have
271+
# Quick check: If we got a request object, we should *not* have
272272
# gotten any keyword arguments that map to the request.
273273
has_flattened_params = any([parent])
274274
if request is not None and has_flattened_params:
@@ -369,7 +369,7 @@ async def list_policies(
369369
370370
"""
371371
# Create or coerce a protobuf request object.
372-
# Sanity check: If we got a request object, we should *not* have
372+
# Quick check: If we got a request object, we should *not* have
373373
# gotten any keyword arguments that map to the request.
374374
has_flattened_params = any([parent])
375375
if request is not None and has_flattened_params:
@@ -460,7 +460,7 @@ async def get_policy(
460460
461461
"""
462462
# Create or coerce a protobuf request object.
463-
# Sanity check: If we got a request object, we should *not* have
463+
# Quick check: If we got a request object, we should *not* have
464464
# gotten any keyword arguments that map to the request.
465465
has_flattened_params = any([name])
466466
if request is not None and has_flattened_params:
@@ -548,7 +548,7 @@ async def get_effective_policy(
548548
549549
"""
550550
# Create or coerce a protobuf request object.
551-
# Sanity check: If we got a request object, we should *not* have
551+
# Quick check: If we got a request object, we should *not* have
552552
# gotten any keyword arguments that map to the request.
553553
has_flattened_params = any([name])
554554
if request is not None and has_flattened_params:
@@ -648,7 +648,7 @@ async def create_policy(
648648
649649
"""
650650
# Create or coerce a protobuf request object.
651-
# Sanity check: If we got a request object, we should *not* have
651+
# Quick check: If we got a request object, we should *not* have
652652
# gotten any keyword arguments that map to the request.
653653
has_flattened_params = any([parent, policy])
654654
if request is not None and has_flattened_params:
@@ -740,7 +740,7 @@ async def update_policy(
740740
741741
"""
742742
# Create or coerce a protobuf request object.
743-
# Sanity check: If we got a request object, we should *not* have
743+
# Quick check: If we got a request object, we should *not* have
744744
# gotten any keyword arguments that map to the request.
745745
has_flattened_params = any([policy])
746746
if request is not None and has_flattened_params:
@@ -823,7 +823,7 @@ async def delete_policy(
823823
sent along with the request as metadata.
824824
"""
825825
# Create or coerce a protobuf request object.
826-
# Sanity check: If we got a request object, we should *not* have
826+
# Quick check: If we got a request object, we should *not* have
827827
# gotten any keyword arguments that map to the request.
828828
has_flattened_params = any([name])
829829
if request is not None and has_flattened_params:
Collapse file

‎google/cloud/orgpolicy_v2/services/org_policy/client.py‎

Copy file name to clipboardExpand all lines: google/cloud/orgpolicy_v2/services/org_policy/client.py
+7-7Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ def list_constraints(
479479
480480
"""
481481
# Create or coerce a protobuf request object.
482-
# Sanity check: If we got a request object, we should *not* have
482+
# Quick check: If we got a request object, we should *not* have
483483
# gotten any keyword arguments that map to the request.
484484
has_flattened_params = any([parent])
485485
if request is not None and has_flattened_params:
@@ -570,7 +570,7 @@ def list_policies(
570570
571571
"""
572572
# Create or coerce a protobuf request object.
573-
# Sanity check: If we got a request object, we should *not* have
573+
# Quick check: If we got a request object, we should *not* have
574574
# gotten any keyword arguments that map to the request.
575575
has_flattened_params = any([parent])
576576
if request is not None and has_flattened_params:
@@ -651,7 +651,7 @@ def get_policy(
651651
652652
"""
653653
# Create or coerce a protobuf request object.
654-
# Sanity check: If we got a request object, we should *not* have
654+
# Quick check: If we got a request object, we should *not* have
655655
# gotten any keyword arguments that map to the request.
656656
has_flattened_params = any([name])
657657
if request is not None and has_flattened_params:
@@ -729,7 +729,7 @@ def get_effective_policy(
729729
730730
"""
731731
# Create or coerce a protobuf request object.
732-
# Sanity check: If we got a request object, we should *not* have
732+
# Quick check: If we got a request object, we should *not* have
733733
# gotten any keyword arguments that map to the request.
734734
has_flattened_params = any([name])
735735
if request is not None and has_flattened_params:
@@ -819,7 +819,7 @@ def create_policy(
819819
820820
"""
821821
# Create or coerce a protobuf request object.
822-
# Sanity check: If we got a request object, we should *not* have
822+
# Quick check: If we got a request object, we should *not* have
823823
# gotten any keyword arguments that map to the request.
824824
has_flattened_params = any([parent, policy])
825825
if request is not None and has_flattened_params:
@@ -901,7 +901,7 @@ def update_policy(
901901
902902
"""
903903
# Create or coerce a protobuf request object.
904-
# Sanity check: If we got a request object, we should *not* have
904+
# Quick check: If we got a request object, we should *not* have
905905
# gotten any keyword arguments that map to the request.
906906
has_flattened_params = any([policy])
907907
if request is not None and has_flattened_params:
@@ -974,7 +974,7 @@ def delete_policy(
974974
sent along with the request as metadata.
975975
"""
976976
# Create or coerce a protobuf request object.
977-
# Sanity check: If we got a request object, we should *not* have
977+
# Quick check: If we got a request object, we should *not* have
978978
# gotten any keyword arguments that map to the request.
979979
has_flattened_params = any([name])
980980
if request is not None and has_flattened_params:
Collapse file

‎google/cloud/orgpolicy_v2/services/org_policy/transports/grpc.py‎

Copy file name to clipboardExpand all lines: google/cloud/orgpolicy_v2/services/org_policy/transports/grpc.py
+4-1Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,11 @@ def __init__(
180180
if not self._grpc_channel:
181181
self._grpc_channel = type(self).create_channel(
182182
self._host,
183+
# use the credentials which are saved
183184
credentials=self._credentials,
184-
credentials_file=credentials_file,
185+
# Set ``credentials_file`` to ``None`` here as
186+
# the credentials that we saved earlier should be used.
187+
credentials_file=None,
185188
scopes=self._scopes,
186189
ssl_credentials=self._ssl_channel_credentials,
187190
quota_project_id=quota_project_id,
Collapse file

‎google/cloud/orgpolicy_v2/services/org_policy/transports/grpc_asyncio.py‎

Copy file name to clipboardExpand all lines: google/cloud/orgpolicy_v2/services/org_policy/transports/grpc_asyncio.py
+4-1Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,11 @@ def __init__(
225225
if not self._grpc_channel:
226226
self._grpc_channel = type(self).create_channel(
227227
self._host,
228+
# use the credentials which are saved
228229
credentials=self._credentials,
229-
credentials_file=credentials_file,
230+
# Set ``credentials_file`` to ``None`` here as
231+
# the credentials that we saved earlier should be used.
232+
credentials_file=None,
230233
scopes=self._scopes,
231234
ssl_credentials=self._ssl_channel_credentials,
232235
quota_project_id=quota_project_id,
Collapse file

‎google/cloud/orgpolicy_v2/types/orgpolicy.py‎

Copy file name to clipboardExpand all lines: google/cloud/orgpolicy_v2/types/orgpolicy.py
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ class Policy(proto.Message):
6767
be used instead of the baseline policy
6868
configurations as determined by the launch.
6969
Currently the only way the launch can trigger
70-
the alternate configuration is via dry-
71-
run/darklaunch.
70+
the alternate configuration is via
71+
dry-run/darklaunch.
7272
"""
7373

7474
name = proto.Field(proto.STRING, number=1,)
@@ -78,8 +78,8 @@ class Policy(proto.Message):
7878

7979
class AlternatePolicySpec(proto.Message):
8080
r"""Similar to PolicySpec but with an extra 'launch' field for
81-
launch reference. The PolicySpec here is specific for dry-
82-
run/darklaunch.
81+
launch reference. The PolicySpec here is specific for
82+
dry-run/darklaunch.
8383
8484
Attributes:
8585
launch (str):
Collapse file

‎tests/unit/gapic/orgpolicy_v2/test_org_policy.py‎

Copy file name to clipboardExpand all lines: tests/unit/gapic/orgpolicy_v2/test_org_policy.py
+66-3Lines changed: 66 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -494,21 +494,23 @@ def test_org_policy_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-
(OrgPolicyClient, transports.OrgPolicyGrpcTransport, "grpc"),
499+
(OrgPolicyClient, transports.OrgPolicyGrpcTransport, "grpc", grpc_helpers),
500500
(
501501
OrgPolicyAsyncClient,
502502
transports.OrgPolicyGrpcAsyncIOTransport,
503503
"grpc_asyncio",
504+
grpc_helpers_async,
504505
),
505506
],
506507
)
507508
def test_org_policy_client_client_options_credentials_file(
508-
client_class, transport_class, transport_name
509+
client_class, transport_class, transport_name, grpc_helpers
509510
):
510511
# Check the case credentials file is provided.
511512
options = client_options.ClientOptions(credentials_file="credentials.json")
513+
512514
with mock.patch.object(transport_class, "__init__") as patched:
513515
patched.return_value = None
514516
client = client_class(client_options=options, transport=transport_name)
@@ -542,6 +544,67 @@ def test_org_policy_client_client_options_from_dict():
542544
)
543545

544546

547+
@pytest.mark.parametrize(
548+
"client_class,transport_class,transport_name,grpc_helpers",
549+
[
550+
(OrgPolicyClient, transports.OrgPolicyGrpcTransport, "grpc", grpc_helpers),
551+
(
552+
OrgPolicyAsyncClient,
553+
transports.OrgPolicyGrpcAsyncIOTransport,
554+
"grpc_asyncio",
555+
grpc_helpers_async,
556+
),
557+
],
558+
)
559+
def test_org_policy_client_create_channel_credentials_file(
560+
client_class, transport_class, transport_name, grpc_helpers
561+
):
562+
# Check the case credentials file is provided.
563+
options = client_options.ClientOptions(credentials_file="credentials.json")
564+
565+
with mock.patch.object(transport_class, "__init__") as patched:
566+
patched.return_value = None
567+
client = client_class(client_options=options, transport=transport_name)
568+
patched.assert_called_once_with(
569+
credentials=None,
570+
credentials_file="credentials.json",
571+
host=client.DEFAULT_ENDPOINT,
572+
scopes=None,
573+
client_cert_source_for_mtls=None,
574+
quota_project_id=None,
575+
client_info=transports.base.DEFAULT_CLIENT_INFO,
576+
always_use_jwt_access=True,
577+
)
578+
579+
# test that the credentials from file are saved and used as the credentials.
580+
with mock.patch.object(
581+
google.auth, "load_credentials_from_file", autospec=True
582+
) as load_creds, mock.patch.object(
583+
google.auth, "default", autospec=True
584+
) as adc, mock.patch.object(
585+
grpc_helpers, "create_channel"
586+
) as create_channel:
587+
creds = ga_credentials.AnonymousCredentials()
588+
file_creds = ga_credentials.AnonymousCredentials()
589+
load_creds.return_value = (file_creds, None)
590+
adc.return_value = (creds, None)
591+
client = client_class(client_options=options, transport=transport_name)
592+
create_channel.assert_called_with(
593+
"orgpolicy.googleapis.com:443",
594+
credentials=file_creds,
595+
credentials_file=None,
596+
quota_project_id=None,
597+
default_scopes=("https://www.googleapis.com/auth/cloud-platform",),
598+
scopes=None,
599+
default_host="orgpolicy.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+
545608
@pytest.mark.parametrize("request_type", [orgpolicy.ListConstraintsRequest, dict,])
546609
def test_list_constraints(request_type, transport: str = "grpc"):
547610
client = OrgPolicyClient(

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.