Skip to content
This repository was archived by the owner on Mar 26, 2026. It is now read-only.

Commit f394d57

Browse files
committed
updated async mixins
1 parent 6664f75 commit f394d57

File tree

1 file changed

+30
-10
lines changed

1 file changed

+30
-10
lines changed

gapic/templates/%namespace/%name_%version/%sub/services/%service/_async_mixins.py.j2

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
{% if "ListOperations" in api.mixin_api_methods %}
66
async def list_operations(
77
self,
8-
request: Optional[operations_pb2.ListOperationsRequest] = None,
8+
request: Optional[Union[operations_pb2.ListOperationsRequest, dict]] = None,
99
*,
1010
retry: OptionalRetry = gapic_v1.method.DEFAULT,
1111
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
@@ -28,6 +28,8 @@
2828
# Create or coerce a protobuf request object.
2929
# The request isn't a proto-plus wrapped type,
3030
# so it must be constructed via keyword expansion.
31+
if request is None:
32+
request = {}
3133
if isinstance(request, dict):
3234
request = operations_pb2.ListOperationsRequest(**request)
3335

@@ -57,7 +59,7 @@
5759
{% if "GetOperation" in api.mixin_api_methods %}
5860
async def get_operation(
5961
self,
60-
request: Optional[operations_pb2.GetOperationRequest] = None,
62+
request: Optional[Union[operations_pb2.GetOperationRequest, dict]] = None,
6163
*,
6264
retry: OptionalRetry = gapic_v1.method.DEFAULT,
6365
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
@@ -80,6 +82,8 @@
8082
# Create or coerce a protobuf request object.
8183
# The request isn't a proto-plus wrapped type,
8284
# so it must be constructed via keyword expansion.
85+
if request is None:
86+
request = {}
8387
if isinstance(request, dict):
8488
request = operations_pb2.GetOperationRequest(**request)
8589

@@ -108,7 +112,7 @@
108112
{% if "DeleteOperation" in api.mixin_api_methods %}
109113
async def delete_operation(
110114
self,
111-
request: Optional[operations_pb2.DeleteOperationRequest] = None,
115+
request: Optional[Union[operations_pb2.DeleteOperationRequest, dict]] = None,
112116
*,
113117
retry: OptionalRetry = gapic_v1.method.DEFAULT,
114118
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
@@ -135,6 +139,8 @@
135139
# Create or coerce a protobuf request object.
136140
# The request isn't a proto-plus wrapped type,
137141
# so it must be constructed via keyword expansion.
142+
if request is None:
143+
request = {}
138144
if isinstance(request, dict):
139145
request = operations_pb2.DeleteOperationRequest(**request)
140146

@@ -159,7 +165,7 @@
159165
{% if "CancelOperation" in api.mixin_api_methods %}
160166
async def cancel_operation(
161167
self,
162-
request: Optional[operations_pb2.CancelOperationRequest] = None,
168+
request: Optional[Union[operations_pb2.CancelOperationRequest, dict]] = None,
163169
*,
164170
retry: OptionalRetry = gapic_v1.method.DEFAULT,
165171
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
@@ -185,6 +191,8 @@
185191
# Create or coerce a protobuf request object.
186192
# The request isn't a proto-plus wrapped type,
187193
# so it must be constructed via keyword expansion.
194+
if request is None:
195+
request = {}
188196
if isinstance(request, dict):
189197
request = operations_pb2.CancelOperationRequest(**request)
190198

@@ -209,7 +217,7 @@
209217
{% if "WaitOperation" in api.mixin_api_methods %}
210218
async def wait_operation(
211219
self,
212-
request: Optional[operations_pb2.WaitOperationRequest] = None,
220+
request: Optional[Union[operations_pb2.WaitOperationRequest, dict]] = None,
213221
*,
214222
retry: OptionalRetry = gapic_v1.method.DEFAULT,
215223
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
@@ -238,6 +246,8 @@
238246
# Create or coerce a protobuf request object.
239247
# The request isn't a proto-plus wrapped type,
240248
# so it must be constructed via keyword expansion.
249+
if request is None:
250+
request = {}
241251
if isinstance(request, dict):
242252
request = operations_pb2.WaitOperationRequest(**request)
243253

@@ -271,7 +281,7 @@
271281
{% if "SetIamPolicy" in api.mixin_api_methods %}
272282
async def set_iam_policy(
273283
self,
274-
request: Optional[iam_policy_pb2.SetIamPolicyRequest] = None,
284+
request: Optional[Union[iam_policy_pb2.SetIamPolicyRequest, dict]] = None,
275285
*,
276286
retry: OptionalRetry = gapic_v1.method.DEFAULT,
277287
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
@@ -360,6 +370,8 @@
360370

361371
# The request isn't a proto-plus wrapped type,
362372
# so it must be constructed via keyword expansion.
373+
if request is None:
374+
request = {}
363375
if isinstance(request, dict):
364376
request = iam_policy_pb2.SetIamPolicyRequest(**request)
365377

@@ -388,7 +400,7 @@
388400
{% if "GetIamPolicy" in api.mixin_api_methods %}
389401
async def get_iam_policy(
390402
self,
391-
request: Optional[iam_policy_pb2.GetIamPolicyRequest] = None,
403+
request: Optional[Union[iam_policy_pb2.GetIamPolicyRequest, dict]] = None,
392404
*,
393405
retry: OptionalRetry = gapic_v1.method.DEFAULT,
394406
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
@@ -478,6 +490,8 @@
478490

479491
# The request isn't a proto-plus wrapped type,
480492
# so it must be constructed via keyword expansion.
493+
if request is None:
494+
request = {}
481495
if isinstance(request, dict):
482496
request = iam_policy_pb2.GetIamPolicyRequest(**request)
483497

@@ -506,7 +520,7 @@
506520
{% if "TestIamPermissions" in api.mixin_api_methods %}
507521
async def test_iam_permissions(
508522
self,
509-
request: Optional[iam_policy_pb2.TestIamPermissionsRequest] = None,
523+
request: Optional[Union[iam_policy_pb2.TestIamPermissionsRequest, dict]] = None,
510524
*,
511525
retry: OptionalRetry = gapic_v1.method.DEFAULT,
512526
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
@@ -534,6 +548,8 @@
534548

535549
# The request isn't a proto-plus wrapped type,
536550
# so it must be constructed via keyword expansion.
551+
if request is None:
552+
request = {}
537553
if isinstance(request, dict):
538554
request = iam_policy_pb2.TestIamPermissionsRequest(**request)
539555

@@ -566,7 +582,7 @@
566582
{% if "GetLocation" in api.mixin_api_methods %}
567583
async def get_location(
568584
self,
569-
request: Optional[locations_pb2.GetLocationRequest] = None,
585+
request: Optional[Union[locations_pb2.GetLocationRequest, dict]] = None,
570586
*,
571587
retry: OptionalRetry = gapic_v1.method.DEFAULT,
572588
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
@@ -589,6 +605,8 @@
589605
# Create or coerce a protobuf request object.
590606
# The request isn't a proto-plus wrapped type,
591607
# so it must be constructed via keyword expansion.
608+
if request is None:
609+
request = {}
592610
if isinstance(request, dict):
593611
request = locations_pb2.GetLocationRequest(**request)
594612

@@ -617,7 +635,7 @@
617635
{% if "ListLocations" in api.mixin_api_methods %}
618636
async def list_locations(
619637
self,
620-
request: Optional[locations_pb2.ListLocationsRequest] = None,
638+
request: Optional[Union[locations_pb2.ListLocationsRequest, dict]] = None,
621639
*,
622640
retry: OptionalRetry = gapic_v1.method.DEFAULT,
623641
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
@@ -640,6 +658,8 @@
640658
# Create or coerce a protobuf request object.
641659
# The request isn't a proto-plus wrapped type,
642660
# so it must be constructed via keyword expansion.
661+
if request is None:
662+
request = {}
643663
if isinstance(request, dict):
644664
request = locations_pb2.ListLocationsRequest(**request)
645665

0 commit comments

Comments
 (0)