# note that any comments here will be removed during AST parsing, and formatting will remove any unused imports
from locust import task, run_single_user, events
from locust import FastHttpUser

class {{class_name}}(FastHttpUser):
    host = "{{host}}"
    {%- if default_headers %}
    default_headers = {
        {%- for h in default_headers %}
        '{{ h.name }}': '{{ h.value }}',
        {%- endfor %}
    }
    {%- endif %}

    @task
    def t(self):
        {% for e in entries -%}
        {% set request = e.request %}
        with self.{{request.fname}}("{{ request.method | upper }}", "{{ request.url }}"
        {%- if request.fname == "rest" -%}{%- if request.headers -%}, headers={
            {%- for h in request.headers %}
            {%- if h.name|lower != "content-type" -%}
            '{{ h.name }}': '{{ h.value }}',
            {%- endif -%}    
            {%- endfor %}}
        {%- endif -%}
        {%- if request.postData -%}, json={{ request.postData.text }}
        {%- endif -%}
        {%- else -%}
        {%- if request.headers -%}, headers={
            {%- for h in request.headers %}
            '{{ h.name }}': '{{ h.value }}',
            {%- endfor %}}
        {%- endif -%}
        {%- if request.postData -%}
        , data='{{ request.postData.text }}'
        {%- endif -%}
        {%- for (key, value) in request.extraparams -%}
            ,{{ key }}={{ value }}
        {%- endfor -%}
        {% endif %}) as resp:
            pass
        {% endfor %}

if __name__ == "__main__":
    run_single_user({{class_name}})
