Move templates to files
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
|
||||
@query_params({{ api.query_params|map("tojson")|join(", ")}})
|
||||
def {{ api.name }}(self, {{ api.func_params|join(", ") }}):
|
||||
"""
|
||||
{% if api.description %}
|
||||
{{ api.description|replace("\n", " ")|wordwrap(wrapstring="\n ") }}
|
||||
{% endif %}
|
||||
{% if api.doc_url %}
|
||||
`<{{ api.doc_url }}>`_
|
||||
{% endif %}
|
||||
{% if api.params %}
|
||||
|
||||
{% for p, info in api.params %}
|
||||
{% filter wordwrap(72, wrapstring="\n ") %}
|
||||
:arg {{ p }}: {{ info.description }} {% if info.options %}Valid choices: {{ info.options|join(", ") }}{% endif %} {% if info.default %}Default: {{ info.default }}{% endif %}
|
||||
{% endfilter %}
|
||||
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
"""
|
||||
{% include "substitutions" %}
|
||||
{% include "required" %}
|
||||
{% if api.body.body.serialize == "bulk" %}
|
||||
body = self._bulk_body(body)
|
||||
{% endif %}
|
||||
{% block request %}
|
||||
return self.transport.perform_request("{{ api.method }}", {% include "url" %}, params=params{% if api.body.body %}, body=body{% endif %})
|
||||
{% endblock %}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
{% extends "base" %}
|
||||
{% block request %}
|
||||
if scroll_id in SKIP_IN_PATH and body in SKIP_IN_PATH:
|
||||
raise ValueError("You need to supply scroll_id or body.")
|
||||
elif scroll_id and not body:
|
||||
body = {"scroll_id": [scroll_id]}
|
||||
elif scroll_id:
|
||||
params["scroll_id"] = scroll_id
|
||||
|
||||
return self.transport.perform_request("{{ api.method }}", "/_search/scroll", params=params, body=body)
|
||||
{% endblock %}
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
single_doc_op
|
||||
@@ -0,0 +1 @@
|
||||
single_doc_op
|
||||
@@ -0,0 +1 @@
|
||||
single_doc_op
|
||||
@@ -0,0 +1 @@
|
||||
single_doc_op
|
||||
+1
@@ -0,0 +1 @@
|
||||
single_doc_op
|
||||
@@ -0,0 +1 @@
|
||||
single_doc_op
|
||||
@@ -0,0 +1,9 @@
|
||||
{% extends "base" %}
|
||||
{% block request %}
|
||||
if doc_type is None:
|
||||
doc_type = "_doc"
|
||||
|
||||
|
||||
return self.transport.perform_request("POST" if id in SKIP_IN_PATH else "PUT", {% include "url" %}, params=params, body=body)
|
||||
{% endblock %}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
{% extends "base" %}
|
||||
{% block request %}
|
||||
try:
|
||||
{{ super()|trim }}
|
||||
except TransportError:
|
||||
return False
|
||||
{% endblock %}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
{% extends "base" %}
|
||||
{% block request %}
|
||||
if scroll_id in SKIP_IN_PATH and body in SKIP_IN_PATH:
|
||||
raise ValueError("You need to supply scroll_id or body.")
|
||||
elif scroll_id and not body:
|
||||
body = {"scroll_id": scroll_id}
|
||||
elif scroll_id:
|
||||
params["scroll_id"] = scroll_id
|
||||
|
||||
return self.transport.perform_request("{{ api.method }}", "/_search/scroll", params=params, body=body)
|
||||
{% endblock %}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
{% extends "base" %}
|
||||
{% block request %}
|
||||
if doc_type in SKIP_IN_PATH:
|
||||
doc_type = "_doc"
|
||||
|
||||
{{ super()|trim }}
|
||||
{% endblock %}
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
single_doc_op
|
||||
@@ -0,0 +1 @@
|
||||
single_doc_op
|
||||
@@ -0,0 +1,5 @@
|
||||
{% extends "base" %}
|
||||
{% block request %}
|
||||
return self.transport.perform_request("{{ api.method }}", "/_cluster/stats" if node_id in SKIP_IN_PATH else _make_path("_cluster", "stats", "nodes", node_id), params=params)
|
||||
{% endblock%}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
{% extends "base" %}
|
||||
{% block request %}
|
||||
if doc_type not in SKIP_IN_PATH and index in SKIP_IN_PATH:
|
||||
index = "_all"
|
||||
|
||||
{{ super()|trim }}
|
||||
{% endblock %}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
{% if api.required_parts.1 %}
|
||||
for param in ({{ api.required_parts|join(", ")}}):
|
||||
if param in SKIP_IN_PATH:
|
||||
raise ValueError("Empty value passed for a required argument.")
|
||||
|
||||
{% elif api.required_parts %}
|
||||
if {{ api.required_parts.0 }} in SKIP_IN_PATH:
|
||||
raise ValueError("Empty value passed for a required argument '{{ api.required_parts.0 }}'.")
|
||||
|
||||
{% endif %}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
{% for p, info in api.params %}
|
||||
{% if p in substitutions and p not in api.url_parts.1 %}
|
||||
# {{ substitutions[p] }} is a reserved word so it cannot be used, use {{ p }} instead
|
||||
if "{{ p }}" in params:
|
||||
params["{{ substitutions[p] }}"] = params.pop("{{ p }}")
|
||||
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
{% if api.url_parts.0 %}_make_path({{ api.url_parts.1|join(", ")}}){% else %}{{ api.url_parts.1|tojson }}{% endif %}
|
||||
Reference in New Issue
Block a user