Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add body fields and named body to document APIs #1699

Merged
merged 2 commits into from
Aug 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
200 changes: 132 additions & 68 deletions elasticsearch/_async/client/__init__.py

Large diffs are not rendered by default.

162 changes: 89 additions & 73 deletions elasticsearch/_async/client/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -154,17 +154,19 @@ class AsyncElasticsearch(object):
async def create(
self,
*,
index: Any,
id: Any,
body: Mapping[str, Any],
doc_type: Optional[Any] = ...,
pipeline: Optional[Any] = ...,
refresh: Optional[Any] = ...,
routing: Optional[Any] = ...,
timeout: Optional[Any] = ...,
version: Optional[Any] = ...,
version_type: Optional[Any] = ...,
wait_for_active_shards: Optional[Any] = ...,
index: str,
id: str,
document: Any,
doc_type: Optional[str] = ...,
pipeline: Optional[str] = ...,
refresh: Optional[Union[Union[Literal["wait_for"], str], bool]] = ...,
routing: Optional[str] = ...,
timeout: Optional[Union[int, str]] = ...,
version: Optional[int] = ...,
version_type: Optional[
Union[Literal["internal", "external", "external_gte", "force"], str]
] = ...,
wait_for_active_shards: Optional[Union[Union[Literal["all"], str], int]] = ...,
pretty: Optional[bool] = ...,
human: Optional[bool] = ...,
error_trace: Optional[bool] = ...,
Expand All @@ -181,21 +183,23 @@ class AsyncElasticsearch(object):
async def index(
self,
*,
index: Any,
body: Mapping[str, Any],
doc_type: Optional[Any] = ...,
id: Optional[Any] = ...,
if_primary_term: Optional[Any] = ...,
if_seq_no: Optional[Any] = ...,
op_type: Optional[Any] = ...,
pipeline: Optional[Any] = ...,
refresh: Optional[Any] = ...,
index: str,
document: Any,
doc_type: Optional[str] = ...,
id: Optional[str] = ...,
if_primary_term: Optional[int] = ...,
if_seq_no: Optional[int] = ...,
op_type: Optional[Union[Literal["index", "create"], str]] = ...,
pipeline: Optional[str] = ...,
refresh: Optional[Union[Union[Literal["wait_for"], str], bool]] = ...,
require_alias: Optional[bool] = ...,
routing: Optional[Any] = ...,
timeout: Optional[Any] = ...,
version: Optional[Any] = ...,
version_type: Optional[Any] = ...,
wait_for_active_shards: Optional[Any] = ...,
routing: Optional[str] = ...,
timeout: Optional[Union[int, str]] = ...,
version: Optional[int] = ...,
version_type: Optional[
Union[Literal["internal", "external", "external_gte", "force"], str]
] = ...,
wait_for_active_shards: Optional[Union[Union[Literal["all"], str], int]] = ...,
pretty: Optional[bool] = ...,
human: Optional[bool] = ...,
error_trace: Optional[bool] = ...,
Expand Down Expand Up @@ -291,17 +295,19 @@ class AsyncElasticsearch(object):
async def delete(
self,
*,
index: Any,
id: Any,
doc_type: Optional[Any] = ...,
if_primary_term: Optional[Any] = ...,
if_seq_no: Optional[Any] = ...,
refresh: Optional[Any] = ...,
routing: Optional[Any] = ...,
timeout: Optional[Any] = ...,
version: Optional[Any] = ...,
version_type: Optional[Any] = ...,
wait_for_active_shards: Optional[Any] = ...,
index: str,
id: str,
doc_type: Optional[str] = ...,
if_primary_term: Optional[int] = ...,
if_seq_no: Optional[int] = ...,
refresh: Optional[Union[Union[Literal["wait_for"], str], bool]] = ...,
routing: Optional[str] = ...,
timeout: Optional[Union[int, str]] = ...,
version: Optional[int] = ...,
version_type: Optional[
Union[Literal["internal", "external", "external_gte", "force"], str]
] = ...,
wait_for_active_shards: Optional[Union[Union[Literal["all"], str], int]] = ...,
pretty: Optional[bool] = ...,
human: Optional[bool] = ...,
error_trace: Optional[bool] = ...,
Expand Down Expand Up @@ -407,19 +413,21 @@ class AsyncElasticsearch(object):
async def exists(
self,
*,
index: Any,
id: Any,
doc_type: Optional[Any] = ...,
_source: Optional[Any] = ...,
_source_excludes: Optional[Any] = ...,
_source_includes: Optional[Any] = ...,
preference: Optional[Any] = ...,
index: str,
id: str,
doc_type: Optional[str] = ...,
_source: Optional[Union[Union[List[str], str], bool]] = ...,
_source_excludes: Optional[Union[List[str], str]] = ...,
_source_includes: Optional[Union[List[str], str]] = ...,
preference: Optional[str] = ...,
realtime: Optional[bool] = ...,
refresh: Optional[bool] = ...,
routing: Optional[Any] = ...,
stored_fields: Optional[Any] = ...,
version: Optional[Any] = ...,
version_type: Optional[Any] = ...,
routing: Optional[str] = ...,
stored_fields: Optional[Union[List[str], str]] = ...,
version: Optional[int] = ...,
version_type: Optional[
Union[Literal["internal", "external", "external_gte", "force"], str]
] = ...,
pretty: Optional[bool] = ...,
human: Optional[bool] = ...,
error_trace: Optional[bool] = ...,
Expand All @@ -432,7 +440,7 @@ class AsyncElasticsearch(object):
api_key: Optional[Union[str, Tuple[str, str]]] = ...,
params: Optional[MutableMapping[str, Any]] = ...,
headers: Optional[MutableMapping[str, str]] = ...,
) -> bool: ...
) -> Any: ...
async def exists_source(
self,
*,
Expand Down Expand Up @@ -519,19 +527,21 @@ class AsyncElasticsearch(object):
async def get(
self,
*,
index: Any,
id: Any,
doc_type: Optional[Any] = ...,
_source: Optional[Any] = ...,
_source_excludes: Optional[Any] = ...,
_source_includes: Optional[Any] = ...,
preference: Optional[Any] = ...,
index: str,
id: str,
doc_type: Optional[str] = ...,
_source: Optional[Union[Union[List[str], str], bool]] = ...,
_source_excludes: Optional[Union[List[str], str]] = ...,
_source_includes: Optional[Union[List[str], str]] = ...,
preference: Optional[str] = ...,
realtime: Optional[bool] = ...,
refresh: Optional[bool] = ...,
routing: Optional[Any] = ...,
stored_fields: Optional[Any] = ...,
version: Optional[Any] = ...,
version_type: Optional[Any] = ...,
routing: Optional[str] = ...,
stored_fields: Optional[Union[List[str], str]] = ...,
version: Optional[int] = ...,
version_type: Optional[
Union[Literal["internal", "external", "external_gte", "force"], str]
] = ...,
pretty: Optional[bool] = ...,
human: Optional[bool] = ...,
error_trace: Optional[bool] = ...,
Expand Down Expand Up @@ -1020,22 +1030,28 @@ class AsyncElasticsearch(object):
async def update(
self,
*,
index: Any,
id: Any,
index: str,
id: str,
body: Mapping[str, Any],
doc_type: Optional[Any] = ...,
_source: Optional[Any] = ...,
_source_excludes: Optional[Any] = ...,
_source_includes: Optional[Any] = ...,
if_primary_term: Optional[Any] = ...,
if_seq_no: Optional[Any] = ...,
lang: Optional[Any] = ...,
refresh: Optional[Any] = ...,
doc_type: Optional[str] = ...,
_source: Optional[Union[Union[List[str], str], bool]] = ...,
_source_excludes: Optional[Union[List[str], str]] = ...,
_source_includes: Optional[Union[List[str], str]] = ...,
detect_noop: Optional[bool] = ...,
doc: Optional[Any] = ...,
doc_as_upsert: Optional[bool] = ...,
if_primary_term: Optional[int] = ...,
if_seq_no: Optional[int] = ...,
lang: Optional[str] = ...,
refresh: Optional[Union[Union[Literal["wait_for"], str], bool]] = ...,
require_alias: Optional[bool] = ...,
retry_on_conflict: Optional[Any] = ...,
routing: Optional[Any] = ...,
timeout: Optional[Any] = ...,
wait_for_active_shards: Optional[Any] = ...,
retry_on_conflict: Optional[int] = ...,
routing: Optional[str] = ...,
script: Optional[Union[Mapping[str, Any], str]] = ...,
scripted_upsert: Optional[bool] = ...,
timeout: Optional[Union[int, str]] = ...,
upsert: Optional[Any] = ...,
wait_for_active_shards: Optional[Union[Union[Literal["all"], str], int]] = ...,
pretty: Optional[bool] = ...,
human: Optional[bool] = ...,
error_trace: Optional[bool] = ...,
Expand Down
14 changes: 9 additions & 5 deletions elasticsearch/_async/client/transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,19 +104,23 @@ async def get_transform_stats(self, transform_id, params=None, headers=None):
)

@query_params()
async def preview_transform(self, body, params=None, headers=None):
async def preview_transform(
self, body=None, transform_id=None, params=None, headers=None
):
"""
Previews a transform.

`<https://www.elastic.co/guide/en/elasticsearch/reference/7.x/preview-transform.html>`_

:arg body: The definition for the transform to preview
:arg transform_id: The id of the transform to preview.
"""
if body in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument 'body'.")

return await self.transport.perform_request(
"POST", "/_transform/_preview", params=params, headers=headers, body=body
"POST",
_make_path("_transform", transform_id, "_preview"),
params=params,
headers=headers,
body=body,
)

@query_params("defer_validation")
Expand Down
3 changes: 2 additions & 1 deletion elasticsearch/_async/client/transform.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ class TransformClient(NamespacedClient):
async def preview_transform(
self,
*,
body: Mapping[str, Any],
body: Optional[Mapping[str, Any]] = ...,
transform_id: Optional[Any] = ...,
pretty: Optional[bool] = ...,
human: Optional[bool] = ...,
error_trace: Optional[bool] = ...,
Expand Down
Loading