Files
opensearch-pyd/elasticsearch/client/sql.py
T

48 lines
1.5 KiB
Python
Raw Normal View History

from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH
2019-03-29 09:25:23 -06:00
class SqlClient(NamespacedClient):
@query_params()
def clear_cursor(self, body, params=None):
"""
`<Clear SQL cursor>`_
2019-12-17 22:31:35 +01:00
:arg body: Specify the cursor value in the `cursor` element to
clean the cursor.
2019-03-29 09:25:23 -06:00
"""
if body in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument 'body'.")
2019-12-17 22:31:35 +01:00
2019-03-29 09:25:23 -06:00
return self.transport.perform_request(
"POST", "/_sql/close", params=params, body=body
)
@query_params("format")
def query(self, body, params=None):
"""
`<Execute SQL>`_
2019-12-17 22:31:35 +01:00
:arg body: Use the `query` element to start a query. Use the
`cursor` element to continue a query.
:arg format: a short version of the Accept header, e.g. json,
yaml
2019-03-29 09:25:23 -06:00
"""
if body in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument 'body'.")
2019-12-17 22:31:35 +01:00
2019-03-29 09:25:23 -06:00
return self.transport.perform_request("POST", "/_sql", params=params, body=body)
@query_params()
def translate(self, body, params=None):
"""
`<Translate SQL into Elasticsearch queries>`_
:arg body: Specify the query in the `query` element.
"""
if body in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument 'body'.")
2019-12-17 22:31:35 +01:00
2019-03-29 09:25:23 -06:00
return self.transport.perform_request(
"POST", "/_sql/translate", params=params, body=body
)