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

Commit 5a37094

Browse files
authored
chore: add template for metadata (#2253)
1 parent 515dc8a commit 5a37094

File tree

9 files changed

+80
-103
lines changed

9 files changed

+80
-103
lines changed

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

Lines changed: 20 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*,
1010
retry: OptionalRetry = gapic_v1.method.DEFAULT,
1111
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
12-
metadata: Sequence[Tuple[str, str]] = (),
12+
{{ shared_macros.client_method_metadata_argument()|indent(8) }} = {{ shared_macros.client_method_metadata_default_value() }},
1313
) -> operations_pb2.ListOperationsResponse:
1414
r"""Lists operations that match the specified filter in the request.
1515

@@ -20,8 +20,7 @@
2020
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors,
2121
if any, should be retried.
2222
timeout (float): The timeout for this request.
23-
metadata (Sequence[Tuple[str, str]]): Strings which should be
24-
sent along with the request as metadata.
23+
{{ shared_macros.client_method_metadata_argument_doc()|indent(4) }}
2524
Returns:
2625
~.operations_pb2.ListOperationsResponse:
2726
Response message for ``ListOperations`` method.
@@ -62,7 +61,7 @@
6261
*,
6362
retry: OptionalRetry = gapic_v1.method.DEFAULT,
6463
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
65-
metadata: Sequence[Tuple[str, str]] = (),
64+
{{ shared_macros.client_method_metadata_argument()|indent(8) }} = {{ shared_macros.client_method_metadata_default_value() }},
6665
) -> operations_pb2.Operation:
6766
r"""Gets the latest state of a long-running operation.
6867

@@ -73,8 +72,7 @@
7372
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors,
7473
if any, should be retried.
7574
timeout (float): The timeout for this request.
76-
metadata (Sequence[Tuple[str, str]]): Strings which should be
77-
sent along with the request as metadata.
75+
{{ shared_macros.client_method_metadata_argument_doc()|indent(4) }}
7876
Returns:
7977
~.operations_pb2.Operation:
8078
An ``Operation`` object.
@@ -114,7 +112,7 @@
114112
*,
115113
retry: OptionalRetry = gapic_v1.method.DEFAULT,
116114
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
117-
metadata: Sequence[Tuple[str, str]] = (),
115+
{{ shared_macros.client_method_metadata_argument()|indent(8) }} = {{ shared_macros.client_method_metadata_default_value() }},
118116
) -> None:
119117
r"""Deletes a long-running operation.
120118

@@ -130,8 +128,7 @@
130128
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors,
131129
if any, should be retried.
132130
timeout (float): The timeout for this request.
133-
metadata (Sequence[Tuple[str, str]]): Strings which should be
134-
sent along with the request as metadata.
131+
{{ shared_macros.client_method_metadata_argument_doc()|indent(4) }}
135132
Returns:
136133
None
137134
"""
@@ -166,7 +163,7 @@
166163
*,
167164
retry: OptionalRetry = gapic_v1.method.DEFAULT,
168165
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
169-
metadata: Sequence[Tuple[str, str]] = (),
166+
{{ shared_macros.client_method_metadata_argument()|indent(8) }} = {{ shared_macros.client_method_metadata_default_value() }},
170167
) -> None:
171168
r"""Starts asynchronous cancellation on a long-running operation.
172169

@@ -181,8 +178,7 @@
181178
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors,
182179
if any, should be retried.
183180
timeout (float): The timeout for this request.
184-
metadata (Sequence[Tuple[str, str]]): Strings which should be
185-
sent along with the request as metadata.
181+
{{ shared_macros.client_method_metadata_argument_doc()|indent(4) }}
186182
Returns:
187183
None
188184
"""
@@ -217,7 +213,7 @@
217213
*,
218214
retry: OptionalRetry = gapic_v1.method.DEFAULT,
219215
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
220-
metadata: Sequence[Tuple[str, str]] = (),
216+
{{ shared_macros.client_method_metadata_argument()|indent(8) }} = {{ shared_macros.client_method_metadata_default_value() }},
221217
) -> operations_pb2.Operation:
222218
r"""Waits until the specified long-running operation is done or reaches at most
223219
a specified timeout, returning the latest state.
@@ -234,8 +230,7 @@
234230
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors,
235231
if any, should be retried.
236232
timeout (float): The timeout for this request.
237-
metadata (Sequence[Tuple[str, str]]): Strings which should be
238-
sent along with the request as metadata.
233+
{{ shared_macros.client_method_metadata_argument_doc()|indent(4) }}
239234
Returns:
240235
~.operations_pb2.Operation:
241236
An ``Operation`` object.
@@ -280,7 +275,7 @@
280275
*,
281276
retry: OptionalRetry = gapic_v1.method.DEFAULT,
282277
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
283-
metadata: Sequence[Tuple[str, str]] = (),
278+
{{ shared_macros.client_method_metadata_argument()|indent(8) }} = {{ shared_macros.client_method_metadata_default_value() }},
284279
) -> policy_pb2.Policy:
285280
r"""Sets the IAM access control policy on the specified function.
286281

@@ -293,8 +288,7 @@
293288
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
294289
should be retried.
295290
timeout (float): The timeout for this request.
296-
metadata (Sequence[Tuple[str, str]]): Strings which should be
297-
sent along with the request as metadata.
291+
{{ shared_macros.client_method_metadata_argument_doc()|indent(4) }}
298292
Returns:
299293
~.policy_pb2.Policy:
300294
Defines an Identity and Access Management (IAM) policy.
@@ -398,7 +392,7 @@
398392
*,
399393
retry: OptionalRetry = gapic_v1.method.DEFAULT,
400394
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
401-
metadata: Sequence[Tuple[str, str]] = (),
395+
{{ shared_macros.client_method_metadata_argument()|indent(8) }} = {{ shared_macros.client_method_metadata_default_value() }},
402396
) -> policy_pb2.Policy:
403397
r"""Gets the IAM access control policy for a function.
404398

@@ -412,8 +406,7 @@
412406
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if
413407
any, should be retried.
414408
timeout (float): The timeout for this request.
415-
metadata (Sequence[Tuple[str, str]]): Strings which should be
416-
sent along with the request as metadata.
409+
{{ shared_macros.client_method_metadata_argument_doc()|indent(4) }}
417410
Returns:
418411
~.policy_pb2.Policy:
419412
Defines an Identity and Access Management (IAM) policy.
@@ -517,7 +510,7 @@
517510
*,
518511
retry: OptionalRetry = gapic_v1.method.DEFAULT,
519512
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
520-
metadata: Sequence[Tuple[str, str]] = (),
513+
{{ shared_macros.client_method_metadata_argument()|indent(8) }} = {{ shared_macros.client_method_metadata_default_value() }},
521514
) -> iam_policy_pb2.TestIamPermissionsResponse:
522515
r"""Tests the specified IAM permissions against the IAM access control
523516
policy for a function.
@@ -532,8 +525,7 @@
532525
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors,
533526
if any, should be retried.
534527
timeout (float): The timeout for this request.
535-
metadata (Sequence[Tuple[str, str]]): Strings which should be
536-
sent along with the request as metadata.
528+
{{ shared_macros.client_method_metadata_argument_doc()|indent(4) }}
537529
Returns:
538530
~.iam_policy_pb2.TestIamPermissionsResponse:
539531
Response message for ``TestIamPermissions`` method.
@@ -578,7 +570,7 @@
578570
*,
579571
retry: OptionalRetry = gapic_v1.method.DEFAULT,
580572
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
581-
metadata: Sequence[Tuple[str, str]] = (),
573+
{{ shared_macros.client_method_metadata_argument()|indent(8) }} = {{ shared_macros.client_method_metadata_default_value() }},
582574
) -> locations_pb2.Location:
583575
r"""Gets information about a location.
584576

@@ -589,8 +581,7 @@
589581
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors,
590582
if any, should be retried.
591583
timeout (float): The timeout for this request.
592-
metadata (Sequence[Tuple[str, str]]): Strings which should be
593-
sent along with the request as metadata.
584+
{{ shared_macros.client_method_metadata_argument_doc()|indent(4) }}
594585
Returns:
595586
~.location_pb2.Location:
596587
Location object.
@@ -630,7 +621,7 @@
630621
*,
631622
retry: OptionalRetry = gapic_v1.method.DEFAULT,
632623
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
633-
metadata: Sequence[Tuple[str, str]] = (),
624+
{{ shared_macros.client_method_metadata_argument()|indent(8) }} = {{ shared_macros.client_method_metadata_default_value() }},
634625
) -> locations_pb2.ListLocationsResponse:
635626
r"""Lists information about the supported locations for this service.
636627

@@ -641,8 +632,7 @@
641632
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors,
642633
if any, should be retried.
643634
timeout (float): The timeout for this request.
644-
metadata (Sequence[Tuple[str, str]]): Strings which should be
645-
sent along with the request as metadata.
635+
{{ shared_macros.client_method_metadata_argument_doc()|indent(4) }}
646636
Returns:
647637
~.location_pb2.ListLocationsResponse:
648638
Response message for ``ListLocations`` method.

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
{% endif %}
3131
retry: OptionalRetry = gapic_v1.method.DEFAULT,
3232
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
33-
metadata: Sequence[Tuple[str, str]] = (),
33+
{{ shared_macros.client_method_metadata_argument()|indent(8) }} = {{ shared_macros.client_method_metadata_default_value() }},
3434
{% if method.extended_lro and not full_extended_lro %}{# This is a hack to preserve backwards compatibility with the "unary" surfaces #}
3535
) -> {{ method.extended_lro.operation_type.ident }}:
3636
{% elif not method.server_streaming %}
@@ -68,8 +68,7 @@
6868
retry (google.api_core.retry.Retry): Designation of what errors, if any,
6969
should be retried.
7070
timeout (float): The timeout for this request.
71-
metadata (Sequence[Tuple[str, str]]): Strings which should be
72-
sent along with the request as metadata.
71+
{{ shared_macros.client_method_metadata_argument_doc()|indent(4) }}
7372
{% if not method.void %}
7473

7574
Returns:

0 commit comments

Comments
 (0)