File tree Expand file tree Collapse file tree
packages/gapic-generator/gapic
templates/%namespace/%name_%version/%sub/services/%service Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2413,6 +2413,17 @@ def operation_polling_method(self) -> Optional[Method]:
24132413 def is_internal (self ) -> bool :
24142414 return any (m .is_internal for m in self .methods .values ())
24152415
2416+ @utils .cached_property
2417+ def has_auto_populated_fields (self ) -> bool :
2418+ """Returns True if any method in this service has auto-populated fields (e.g. AIP-4235 request_id)."""
2419+ return any (
2420+ bool (
2421+ self .api .all_method_settings .get (m .meta .address .proto )
2422+ and self .api .all_method_settings [m .meta .address .proto ].auto_populated_fields
2423+ )
2424+ for m in self .methods .values ()
2425+ )
2426+
24162427 @cached_proto_context
24172428 def with_context (
24182429 self ,
Original file line number Diff line number Diff line change 44{% import "%namespace/%name_%version/%sub/services/%service/_client_macros.j2" as macros %}
55{% import "%namespace/%name_%version/%sub/services/%service/_shared_macros.j2" as shared_macros %}
66
7- {# Check if any method in this service has auto-populated fields (e.g. AIP-4235 request_id)
8- so setup_request_id is conditionally imported from _compat only when needed. #}
9- {% set has_auto_populated_fields = namespace (value =false ) %}
10- {% for method in service .methods .values () %}
11- {% set method_settings = api .all_method_settings .get (method .meta .address .proto ) %}
12- {% if method_settings and method_settings .auto_populated_fields %}
13- {% set has_auto_populated_fields .value = true %}
14- {% endif %}
15- {% endfor %}
16-
177import logging as std_logging
188from collections import OrderedDict
199import re
@@ -28,7 +18,7 @@ from {{package_path}} import gapic_version as package_version
2818from google.api_core.client_options import ClientOptions
2919from google.api_core import exceptions as core_exceptions
3020from google.api_core import gapic_v1
31- {% if has_auto_populated_fields . value %}
21+ {% if service . has_auto_populated_fields %}
3222from {{package_path}}._compat import setup_request_id
3323{% endif %}
3424from google.api_core import retry_async as retries
Original file line number Diff line number Diff line change 66{% import "%namespace/%name_%version/%sub/services/%service/_client_macros.j2" as macros %}
77{% import "%namespace/%name_%version/%sub/services/%service/_shared_macros.j2" as shared_macros %}
88
9- {# Check if any method in this service has auto-populated fields (e.g. AIP-4235 request_id)
10- so setup_request_id is conditionally imported from _compat only when needed. #}
11- {% set has_auto_populated_fields = namespace (value =false ) %}
12- {% for method in service .methods .values () %}
13- {% set method_settings = api .all_method_settings .get (method .meta .address .proto ) %}
14- {% if method_settings and method_settings .auto_populated_fields %}
15- {% set has_auto_populated_fields .value = true %}
16- {% endif %}
17- {% endfor %}
18-
199from collections import OrderedDict
2010{% if service .any_extended_operations_methods %}
2111import functools
@@ -37,7 +27,7 @@ from google.api_core import exceptions as core_exceptions
3727from google.api_core import extended_operation
3828{% endif %}
3929from google.api_core import gapic_v1
40- {% if has_auto_populated_fields . value %}
30+ {% if service . has_auto_populated_fields %}
4131from {{package_path}}._compat import setup_request_id
4232{% endif %}
4333from google.api_core import retry as retries
You can’t perform that action at this time.
0 commit comments