Skip to content

Commit

Permalink
Add typeless API for exists_source
Browse files Browse the repository at this point in the history
  • Loading branch information
sethmlarson committed Jun 3, 2020
1 parent 99d0265 commit 5db3482
Show file tree
Hide file tree
Showing 9 changed files with 183 additions and 160 deletions.
150 changes: 76 additions & 74 deletions elasticsearch/_async/client/__init__.py

Large diffs are not rendered by default.

7 changes: 3 additions & 4 deletions elasticsearch/_async/client/indices.py
Expand Up @@ -1276,17 +1276,16 @@ async def reload_search_analyzers(self, index, params=None, headers=None):
)

@query_params()
async def create_data_stream(self, name, body, params=None, headers=None):
async def create_data_stream(self, name, body=None, params=None, headers=None):
"""
Creates or updates a data stream
`<https://www.elastic.co/guide/en/elasticsearch/reference/7.x/data-streams.html>`_
:arg name: The name of the data stream
:arg body: The data stream definition
"""
for param in (name, body):
if param in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument.")
if name in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument 'name'.")

return await self.transport.perform_request(
"PUT",
Expand Down
7 changes: 6 additions & 1 deletion elasticsearch/_async/client/ml.py
Expand Up @@ -318,7 +318,7 @@ async def flush_job(self, job_id, body=None, params=None, headers=None):
body=body,
)

@query_params("duration", "expires_in")
@query_params("duration", "expires_in", "max_model_memory")
async def forecast(self, job_id, params=None, headers=None):
"""
Predicts the future behavior of a time series by using its historical behavior.
Expand All @@ -328,6 +328,8 @@ async def forecast(self, job_id, params=None, headers=None):
:arg duration: The duration of the forecast
:arg expires_in: The time interval after which the forecast
expires. Expired forecasts will be deleted at the first opportunity.
:arg max_model_memory: The max memory able to be used by the
forecast. Default is 20mb.
"""
if job_id in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument 'job_id'.")
Expand Down Expand Up @@ -1396,6 +1398,7 @@ async def explain_data_frame_analytics(
@query_params(
"allow_no_match",
"decompress_definition",
"for_export",
"from_",
"include_model_definition",
"size",
Expand All @@ -1413,6 +1416,8 @@ async def get_trained_models(self, model_id=None, params=None, headers=None):
:arg decompress_definition: Should the model definition be
decompressed into valid JSON or returned in a custom compressed format.
Defaults to true. Default: True
:arg for_export: Omits fields that are illegal to set on model
PUT
:arg from_: skips a number of trained models
:arg include_model_definition: Should the full model definition
be included in the results. These definitions can be large. So be
Expand Down
3 changes: 2 additions & 1 deletion elasticsearch/_async/client/snapshot.py
Expand Up @@ -87,7 +87,8 @@ async def delete_repository(self, repository, params=None, headers=None):
Deletes a repository.
`<https://www.elastic.co/guide/en/elasticsearch/reference/7.x/modules-snapshots.html>`_
:arg repository: A comma-separated list of repository names
:arg repository: Name of the snapshot repository to unregister.
Wildcard (`*`) patterns are supported.
:arg master_timeout: Explicit operation timeout for connection
to master node
:arg timeout: Explicit operation timeout
Expand Down
150 changes: 76 additions & 74 deletions elasticsearch/client/__init__.py

Large diffs are not rendered by default.

7 changes: 3 additions & 4 deletions elasticsearch/client/indices.py
Expand Up @@ -1272,17 +1272,16 @@ def reload_search_analyzers(self, index, params=None, headers=None):
)

@query_params()
def create_data_stream(self, name, body, params=None, headers=None):
def create_data_stream(self, name, body=None, params=None, headers=None):
"""
Creates or updates a data stream
`<https://www.elastic.co/guide/en/elasticsearch/reference/7.x/data-streams.html>`_
:arg name: The name of the data stream
:arg body: The data stream definition
"""
for param in (name, body):
if param in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument.")
if name in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument 'name'.")

return self.transport.perform_request(
"PUT",
Expand Down
7 changes: 6 additions & 1 deletion elasticsearch/client/ml.py
Expand Up @@ -312,7 +312,7 @@ def flush_job(self, job_id, body=None, params=None, headers=None):
body=body,
)

@query_params("duration", "expires_in")
@query_params("duration", "expires_in", "max_model_memory")
def forecast(self, job_id, params=None, headers=None):
"""
Predicts the future behavior of a time series by using its historical behavior.
Expand All @@ -322,6 +322,8 @@ def forecast(self, job_id, params=None, headers=None):
:arg duration: The duration of the forecast
:arg expires_in: The time interval after which the forecast
expires. Expired forecasts will be deleted at the first opportunity.
:arg max_model_memory: The max memory able to be used by the
forecast. Default is 20mb.
"""
if job_id in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument 'job_id'.")
Expand Down Expand Up @@ -1384,6 +1386,7 @@ def explain_data_frame_analytics(
@query_params(
"allow_no_match",
"decompress_definition",
"for_export",
"from_",
"include_model_definition",
"size",
Expand All @@ -1401,6 +1404,8 @@ def get_trained_models(self, model_id=None, params=None, headers=None):
:arg decompress_definition: Should the model definition be
decompressed into valid JSON or returned in a custom compressed format.
Defaults to true. Default: True
:arg for_export: Omits fields that are illegal to set on model
PUT
:arg from_: skips a number of trained models
:arg include_model_definition: Should the full model definition
be included in the results. These definitions can be large. So be
Expand Down
3 changes: 2 additions & 1 deletion elasticsearch/client/snapshot.py
Expand Up @@ -87,7 +87,8 @@ def delete_repository(self, repository, params=None, headers=None):
Deletes a repository.
`<https://www.elastic.co/guide/en/elasticsearch/reference/7.x/modules-snapshots.html>`_
:arg repository: A comma-separated list of repository names
:arg repository: Name of the snapshot repository to unregister.
Wildcard (`*`) patterns are supported.
:arg master_timeout: Explicit operation timeout for connection
to master node
:arg timeout: Explicit operation timeout
Expand Down
9 changes: 9 additions & 0 deletions utils/templates/overrides/__init__/exists_source
@@ -0,0 +1,9 @@
{% extends "base" %}
{% block request %}
if doc_type in SKIP_IN_PATH:
path = _make_path(index, "_source", id)
else:
path = _make_path(index, doc_type, id, "_source")

return await self.transport.perform_request("{{ api.method }}", path, params=params, headers=headers)
{% endblock %}

0 comments on commit 5db3482

Please sign in to comment.