@@ -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