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

Commit be9f15e

Browse files
chore: use gapic-generator-python 0.62.1 (#172)
- [x] 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 93a52a9 commit be9f15e

8 files changed

Lines changed: 184 additions & 20 deletions

File tree

google/cloud/billing/budgets_v1/services/budget_service/async_client.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ async def create_budget(
258258
259259
"""
260260
# Create or coerce a protobuf request object.
261-
# Sanity check: If we got a request object, we should *not* have
261+
# Quick check: If we got a request object, we should *not* have
262262
# gotten any keyword arguments that map to the request.
263263
has_flattened_params = any([parent, budget])
264264
if request is not None and has_flattened_params:
@@ -354,7 +354,7 @@ async def update_budget(
354354
355355
"""
356356
# Create or coerce a protobuf request object.
357-
# Sanity check: If we got a request object, we should *not* have
357+
# Quick check: If we got a request object, we should *not* have
358358
# gotten any keyword arguments that map to the request.
359359
has_flattened_params = any([budget, update_mask])
360360
if request is not None and has_flattened_params:
@@ -450,7 +450,7 @@ async def get_budget(
450450
451451
"""
452452
# Create or coerce a protobuf request object.
453-
# Sanity check: If we got a request object, we should *not* have
453+
# Quick check: If we got a request object, we should *not* have
454454
# gotten any keyword arguments that map to the request.
455455
has_flattened_params = any([name])
456456
if request is not None and has_flattened_params:
@@ -538,7 +538,7 @@ async def list_budgets(
538538
539539
"""
540540
# Create or coerce a protobuf request object.
541-
# Sanity check: If we got a request object, we should *not* have
541+
# Quick check: If we got a request object, we should *not* have
542542
# gotten any keyword arguments that map to the request.
543543
has_flattened_params = any([parent])
544544
if request is not None and has_flattened_params:
@@ -620,7 +620,7 @@ async def delete_budget(
620620
sent along with the request as metadata.
621621
"""
622622
# Create or coerce a protobuf request object.
623-
# Sanity check: If we got a request object, we should *not* have
623+
# Quick check: If we got a request object, we should *not* have
624624
# gotten any keyword arguments that map to the request.
625625
has_flattened_params = any([name])
626626
if request is not None and has_flattened_params:

google/cloud/billing/budgets_v1/services/budget_service/client.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ def create_budget(
452452
453453
"""
454454
# Create or coerce a protobuf request object.
455-
# Sanity check: If we got a request object, we should *not* have
455+
# Quick check: If we got a request object, we should *not* have
456456
# gotten any keyword arguments that map to the request.
457457
has_flattened_params = any([parent, budget])
458458
if request is not None and has_flattened_params:
@@ -548,7 +548,7 @@ def update_budget(
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([budget, update_mask])
554554
if request is not None and has_flattened_params:
@@ -634,7 +634,7 @@ def get_budget(
634634
635635
"""
636636
# Create or coerce a protobuf request object.
637-
# Sanity check: If we got a request object, we should *not* have
637+
# Quick check: If we got a request object, we should *not* have
638638
# gotten any keyword arguments that map to the request.
639639
has_flattened_params = any([name])
640640
if request is not None and has_flattened_params:
@@ -712,7 +712,7 @@ def list_budgets(
712712
713713
"""
714714
# Create or coerce a protobuf request object.
715-
# Sanity check: If we got a request object, we should *not* have
715+
# Quick check: If we got a request object, we should *not* have
716716
# gotten any keyword arguments that map to the request.
717717
has_flattened_params = any([parent])
718718
if request is not None and has_flattened_params:
@@ -784,7 +784,7 @@ def delete_budget(
784784
sent along with the request as metadata.
785785
"""
786786
# Create or coerce a protobuf request object.
787-
# Sanity check: If we got a request object, we should *not* have
787+
# Quick check: If we got a request object, we should *not* have
788788
# gotten any keyword arguments that map to the request.
789789
has_flattened_params = any([name])
790790
if request is not None and has_flattened_params:

google/cloud/billing/budgets_v1/services/budget_service/transports/grpc.py

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

google/cloud/billing/budgets_v1/services/budget_service/transports/grpc_asyncio.py

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

google/cloud/billing/budgets_v1beta1/services/budget_service/transports/grpc.py

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

google/cloud/billing/budgets_v1beta1/services/budget_service/transports/grpc_asyncio.py

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

tests/unit/gapic/budgets_v1/test_budget_service.py

Lines changed: 79 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -515,21 +515,28 @@ def test_budget_service_client_client_options_scopes(
515515

516516

517517
@pytest.mark.parametrize(
518-
"client_class,transport_class,transport_name",
518+
"client_class,transport_class,transport_name,grpc_helpers",
519519
[
520-
(BudgetServiceClient, transports.BudgetServiceGrpcTransport, "grpc"),
520+
(
521+
BudgetServiceClient,
522+
transports.BudgetServiceGrpcTransport,
523+
"grpc",
524+
grpc_helpers,
525+
),
521526
(
522527
BudgetServiceAsyncClient,
523528
transports.BudgetServiceGrpcAsyncIOTransport,
524529
"grpc_asyncio",
530+
grpc_helpers_async,
525531
),
526532
],
527533
)
528534
def test_budget_service_client_client_options_credentials_file(
529-
client_class, transport_class, transport_name
535+
client_class, transport_class, transport_name, grpc_helpers
530536
):
531537
# Check the case credentials file is provided.
532538
options = client_options.ClientOptions(credentials_file="credentials.json")
539+
533540
with mock.patch.object(transport_class, "__init__") as patched:
534541
patched.return_value = None
535542
client = client_class(client_options=options, transport=transport_name)
@@ -565,6 +572,75 @@ def test_budget_service_client_client_options_from_dict():
565572
)
566573

567574

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

tests/unit/gapic/budgets_v1beta1/test_budget_service.py

Lines changed: 79 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -517,21 +517,28 @@ def test_budget_service_client_client_options_scopes(
517517

518518

519519
@pytest.mark.parametrize(
520-
"client_class,transport_class,transport_name",
520+
"client_class,transport_class,transport_name,grpc_helpers",
521521
[
522-
(BudgetServiceClient, transports.BudgetServiceGrpcTransport, "grpc"),
522+
(
523+
BudgetServiceClient,
524+
transports.BudgetServiceGrpcTransport,
525+
"grpc",
526+
grpc_helpers,
527+
),
523528
(
524529
BudgetServiceAsyncClient,
525530
transports.BudgetServiceGrpcAsyncIOTransport,
526531
"grpc_asyncio",
532+
grpc_helpers_async,
527533
),
528534
],
529535
)
530536
def test_budget_service_client_client_options_credentials_file(
531-
client_class, transport_class, transport_name
537+
client_class, transport_class, transport_name, grpc_helpers
532538
):
533539
# Check the case credentials file is provided.
534540
options = client_options.ClientOptions(credentials_file="credentials.json")
541+
535542
with mock.patch.object(transport_class, "__init__") as patched:
536543
patched.return_value = None
537544
client = client_class(client_options=options, transport=transport_name)
@@ -567,6 +574,75 @@ def test_budget_service_client_client_options_from_dict():
567574
)
568575

569576

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

0 commit comments

Comments
 (0)