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

Commit 85be88d

Browse files
committed
fix: addressing pr comments
1 parent c964fba commit 85be88d

2 files changed

Lines changed: 18 additions & 6 deletions

File tree

gapic/schema/wrappers.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -781,14 +781,15 @@ def path_params(self) -> Sequence[str]:
781781
def query_params(self) -> Set[str]:
782782
"""Return query parameters for API call as determined by http annotation and grpc transcoding"""
783783
# TODO(yon-mg): fully implement grpc transcoding (currently only handles basic case)
784+
# TODO(yon-mg): remove this method and move logic to generated client
784785
if self.http_opt is None:
785786
return set()
786787
params = set(self.path_params)
787788
body = self.http_opt.get('body')
788789
if body:
789790
params.add(body)
790791

791-
return set(self.input.fields) ^ params
792+
return set(self.input.fields) - params
792793

793794
# TODO(yon-mg): refactor as there may be more than one method signature
794795
@utils.cached_property

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

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,15 +133,21 @@ class {{ service.name }}RestTransport({{ service.name }}Transport):
133133
{%- endif %}
134134
"""
135135

136+
{# TODO(yon-mg): refactor when implementing grpc transcoding
137+
- parse request pb & assign body, path params
138+
- shove leftovers into query params
139+
- make sure dotted nested fields preserved
140+
- format url and send the request
141+
#}
136142
{%- if 'body' in method.http_opt %}
137-
# Jsonify the input
143+
# Jsonify the request body
138144
{%- if method.http_opt['body'] != '*' %}
139-
data = {{ method.input.fields[method.http_opt['body']].type.ident }}.to_json(
145+
body = {{ method.input.fields[method.http_opt['body']].type.ident }}.to_json(
140146
request.{{ method.http_opt['body'] }},
141147
including_default_value_fields=False
142148
)
143149
{%- else %}
144-
data = {{ method.input.ident }}.to_json(
150+
body = {{ method.input.ident }}.to_json(
145151
request
146152
)
147153
{%- endif %}
@@ -150,14 +156,18 @@ class {{ service.name }}RestTransport({{ service.name }}Transport):
150156
{# TODO(yon-mg): Write helper method for handling grpc transcoding url #}
151157
# TODO(yon-mg): need to handle grpc transcoding and parse url correctly
152158
# current impl assumes basic case of grpc transcoding
153-
# Send the request
154159
url = 'https://{host}{{ method.http_opt['url'] }}'.format(
155160
host=self._host,
156161
{%- for field in method.path_params %}
157162
{{ field }}=request.{{ field }},
158163
{%- endfor %}
159164
)
160165

166+
{# TODO(yon-mg): move all query param logic out of wrappers into here to handle
167+
nested fields correctly (can't just use set of top level fields
168+
#}
169+
# TODO(yon-mg): handle nested fields corerctly rather than using only top level fields
170+
# not required for GCE
161171
potentialParams = {
162172
{%- for field in method.query_params %}
163173
'{{ field|camel_case }}': request.{{ field }},
@@ -168,10 +178,11 @@ class {{ service.name }}RestTransport({{ service.name }}Transport):
168178
q = '?' if i == 0 else '&'
169179
url += "{q}{name}={value}".format(q=q, name=param_name, value=param_value.replace(' ', '+'))
170180

181+
# Send the request
171182
{% if not method.void %}response = {% endif %}self._session.{{ method.http_opt['verb'] }}(
172183
url
173184
{%- if 'body' in method.http_opt %},
174-
json=data,
185+
json=body,
175186
{%- endif %}
176187
)
177188
{%- if not method.void %}

0 commit comments

Comments
 (0)