Skip to content

Commit 76802a2

Browse files
therveNouemanKHAL
andauthored
Refactor API client (#1018)
* Refactor API client This moves thread support from the main client, and extract the behavior flags in the configuration. * Small tweak * Implement close * Apply suggestions from code review Co-authored-by: NouemanKHAL <[email protected]> * Rebase * Doc tweak * Fix one docstring escape * Make zstd optional Co-authored-by: NouemanKHAL <[email protected]>
1 parent 7908c27 commit 76802a2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+490
-11170
lines changed

.generator/src/generator/formatter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def header(self, text, level, raw=None):
9595

9696

9797
def docstring(text):
98-
return m2r2.convert(text.replace("\\n", "\\\\n"), renderer=CustomRenderer())[1:-1].replace("\\ ", " ")
98+
return m2r2.convert(text.replace("\\n", "\\\\n"), renderer=CustomRenderer())[1:-1].replace("\\ ", " ").replace("\\`", "\\\\`")
9999

100100

101101
def _merge_imports(a, b):

.generator/src/generator/templates/api.j2

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -139,14 +139,6 @@ class {{ classname }}:
139139
{% if operation.description %}
140140
{{ operation.description|docstring|indent(8) }}
141141
{% endif %}
142-
This method makes a synchronous HTTP request by default. To make an
143-
asynchronous HTTP request, please pass async_req=True.
144-
145-
>>> thread = api.{{ operation.operationId|safe_snake_case }}(
146-
{%- for name, parameter in operation|parameters if parameter.required %}{{name|attribute_name}}, {% endfor %}async_req=True)
147-
>>> result = thread.get()
148-
{# keep new line #}
149-
150142
{%- for name, parameter in operation|parameters if parameter.required %}
151143
{%- if parameter.description %}
152144
:param {{ name|attribute_name }}: {{ parameter.description|docstring|indent(12) }}{% if parameter.default %} Defaults to {{ parameter.default }}.{% endif %}{% endif %}
@@ -157,34 +149,10 @@ class {{ classname }}:
157149
:param {{ name|attribute_name }}: {{ parameter.description|docstring|indent(12) }}{%- if parameter.default %} If omitted the server will use the default value of {{ parameter.default }}.{% endif %}{% endif %}
158150
:type {{ name|attribute_name }}: {{ get_type_for_parameter(parameter) }}, optional
159151
{%- endfor %}
160-
:param _return_http_data_only: Response data without head status
161-
code and headers. Default is True.
162-
:type _return_http_data_only: bool
163-
:param _preload_content: If False, the urllib3.HTTPResponse object
164-
will be returned without reading/decoding response data.
165-
Default is True.
166-
:type _preload_content: bool
167-
:param _request_timeout: Timeout setting for this request. If one
168-
number provided, it will be total request timeout. It can also be a
169-
pair (tuple) of (connection, read) timeouts. Default is None.
170-
:type _request_timeout: float/tuple
171-
:param _check_input_type: Specifies if type checking should be done one
172-
the data sent to the server. Default is True.
173-
:type _check_input_type: bool
174-
:param _check_return_type: Specifies if type checking should be done
175-
one the data received from the server. Default is True.
176-
:type _check_return_type: bool
177-
:param _host_index: Specifies the index of the server that we want to
178-
use. Default is read from the configuration.
179-
:type _host_index: int/None
180-
:param async_req: Execute request asynchronously.
181-
:type async_req: bool
182152

183-
:return: If the method is called asynchronously, returns the request thread.
184153
{%- set returnType = operation|return_type %}
185154
:rtype: {% if returnType %}{{ returnType }}{% else %}None{% endif %}
186155
"""
187-
kwargs = self._{{ operation.operationId|safe_snake_case }}_endpoint.default_arguments(kwargs)
188156
{%- for name, parameter in operation|parameters if parameter.required %}
189157
kwargs["{{ name|attribute_name }}"] = {{ name|attribute_name }}
190158
{% endfor %}
@@ -207,24 +175,10 @@ class {{ classname }}:
207175
:param {{ name|attribute_name }}: {{ parameter.description|docstring|indent(12) }}{%- if parameter.default %} If omitted the server will use the default value of {{ parameter.default }}.{% endif %}{% endif %}
208176
:type {{ name|attribute_name }}: {{ get_type_for_parameter(parameter) }}, optional
209177
{%- endfor %}
210-
:param _request_timeout: Timeout setting for this request. If one
211-
number provided, it will be total request timeout. It can also be a
212-
pair (tuple) of (connection, read) timeouts. Default is None.
213-
:type _request_timeout: float/tuple
214-
:param _check_input_type: Specifies if type checking should be done one
215-
the data sent to the server. Default is True.
216-
:type _check_input_type: bool
217-
:param _check_return_type: Specifies if type checking should be done
218-
one the data received from the server. Default is True.
219-
:type _check_return_type: bool
220-
:param _host_index: Specifies the index of the server that we want to
221-
use. Default is read from the configuration.
222-
:type _host_index: int/None
223178

224179
:return: A generator of paginated results.
225180
:rtype: collections.abc.Iterable[{{ get_type_at_path(operation, pagination.resultsPath) }}]
226181
"""
227-
kwargs = self._{{ operation.operationId|safe_snake_case }}_endpoint.default_arguments(kwargs)
228182
{%- for name, parameter in operation|parameters if parameter.required %}
229183
kwargs["{{ name|attribute_name }}"] = {{ name|attribute_name }}
230184
{% endfor %}

0 commit comments

Comments
 (0)