    {%- for path, operation in items %}
    @tracing
    {%- if sync %}
    def {{ operation.fn_name }}(
    {%- else %}
    async def {{ operation.fn_name }}(
    {%- endif %}
        self,
        {%- if operation.request_body and operation.request_body.is_multipart_form_data and operation.request_body.are_files_required %}
        files: Union[Mapping[str, FileTypes], Sequence[Tuple[str, FileTypes]]],
        {%- endif %}
        {#- path params -#}
        {%- for parameter in operation.path_params %}
        {{ parameter.key }}: {{ typerepr(parameter.schema) }},
        {%- endfor %}
        {#- required query params -#}
        {%- for parameter in operation.query_params -%}
        {%- if parameter.required %}
        {{ varname(parameter.key) }}: {{ typerepr(parameter.schema) }},
        {%- endif %}
        {%- endfor %}
        {#- required headers -#}
        {%- for parameter in operation.headers -%}
        {%- if parameter.required %}
        {{ varname(parameter.key) }}: {{ typerepr(parameter.schema) }},
        {%- endif %}
        {%- endfor %}
        {%- if operation.request_body %}
        body: Optional[Union[{{ typerepr(operation.request_body.schema) }}, Dict[str, Any]]] = None,
        {%- endif %}
        {#- optional query params -#}
        {%- for parameter in operation.query_params -%}
        {%- if not parameter.required %}
        {{ varname(parameter.key) }}: Optional[{{ typerepr(parameter.schema) }}] = None,
        {%- endif %}
        {%- endfor %}
        {#- optional headers -#}
        {%- for parameter in operation.headers -%}
        {%- if not parameter.required %}
        {{ varname(parameter.key) }}: Optional[{{ typerepr(parameter.schema) }}] = None,
        {%- endif %}
        {%- endfor %}
        auth: Optional[BasicAuth] = None,
        {%- if operation.request_body and operation.request_body.is_multipart_form_data and not operation.request_body.are_files_required %}
        files: Optional[Union[Mapping[str, FileTypes], Sequence[Tuple[str, FileTypes]]]] = None,
        {%- endif %}
    ) -> {{ responserepr(operation.responses) }}:
        url = self._get_url(f'{{ path }}')

        params = {
            {%- for parameter in operation.query_params %}
            {%- if parameter.required %}
            '{{ parameter.orig_key }}': {{ varname(parameter.key) }},
            {%- endif %}
            {%- endfor %}
        }
        {%- for parameter in operation.query_params %}
        {%- if not parameter.required %}
        if {{ varname(parameter.key) }} is not None:
            params['{{ parameter.orig_key }}'] = {{ varname(parameter.key) }}
        {%- endif %}
        {%- endfor %}

        headers_ = self.headers.copy()

        if self.tracer_integration:
            self.add_tracing_data_to_headers(headers_)

        {%- for parameter in operation.headers %}
        {%- if parameter.required %}
        headers_['{{ parameter.key }}'] = {{ varname(parameter.key) }}
        {%- endif  %}
        {%- endfor %}

        {%- for parameter in operation.headers %}
        {%- if not parameter.required %}
        if {{ varname(parameter.key) }} is not None:
            headers_['{{ parameter.key }}'] = {{ varname(parameter.key) }}
        {%- endif %}
        {%- endfor %}

        if auth is None:
            auth_ = DEFAULT_AUTH
        elif isinstance(auth, httpx.Auth):
            auth_ = auth
        else:
            auth_ = (auth.username, auth.password)
        {% if operation.request_body %}
        if isinstance(body, dict):
            json = body
        elif isinstance(body, {{typerepr(operation.request_body.schema)}}):
            json = body.dict()
        else:
            json = None
        {% endif %}

        {%- if operation.request_body and operation.request_body.is_form_data %}
        headers_.update({'Content-Type': 'application/x-www-form-urlencoded'})
        {%- elif operation.request_body and operation.request_body.is_multipart_form_data %}
        # Content-Type=multipart/form-data doesn't work, because header MUST contain boundaries
        # let library do it for us
        headers_.pop("Content-Type", None)
        {% endif %}


{%- with req_body=operation.request_body -%}
{% include 'client/httpx-request-metrics.j2' %}
{%- endwith -%}

        {%- for code, mapper in iterresponsemap(operation.responses) %}

        if response.status_code == {{ code }}:
            {% if code | int >= 400 -%}
            method = "{{ method }}"
            if response.content is None:
                content = None
            else:
                content = response.content[:500]

            self.log_error(self.client_name, method, url, params, content, headers_)

            {% endif -%}
            return {{ mapper }}
        {%- endfor %}
    {%endfor %}
