-
Notifications
You must be signed in to change notification settings - Fork 77
Open
Labels
type: cleanupAn internal cleanup or hygiene concern.An internal cleanup or hygiene concern.
Description
See feedback in https://github.com/googleapis/gapic-generator-python/pull/2131/files#r1751065571 from review of PR #2131 which calls out that the logic for explicit routing headers which exists in _client_macros.j2 could be moved to google-api-core, similar to how we have gapic_v1.routing_header.to_grpc_metadata
This logic:
Lines 150 to 164 in 4c5de87
| {% for routing_param in method.routing_rule.routing_parameters %} | |
| {% if routing_param.path_template %} {# Need to match. #} | |
| routing_param_regex = {{ routing_param.to_regex() }} | |
| regex_match = routing_param_regex.match(request.{{ routing_param.field }}) | |
| if regex_match and regex_match.group("{{ routing_param.key }}"): | |
| header_params["{{ routing_param.key }}"] = regex_match.group("{{ routing_param.key }}") | |
| {% else %} | |
| if request.{{ routing_param.field }}: | |
| header_params["{{ routing_param.key }}"] = request.{{ routing_param.field }} | |
| {% endif %} | |
| {% endfor %} {# method.routing_rule.routing_parameters #} |
Could be refactored into a helper function in google-api-core similar to gapic_v1.routing_header.to_grpc_metadata
Lines 167 to 170 in 4c5de87
| if header_params: | |
| metadata = tuple(metadata) + ( | |
| gapic_v1.routing_header.to_grpc_metadata(header_params), | |
| ) |
Metadata
Metadata
Assignees
Labels
type: cleanupAn internal cleanup or hygiene concern.An internal cleanup or hygiene concern.