Files
opensearch-pyd/opensearchpy/_async/client/tasks.py
T
Daniel (dB.) Doubrovkine dcb79cc322 Merge .pyi type stubs inline (#563)
* Merged types into .py code.

Signed-off-by: dblock <dblock@amazon.com>

* Fix: nox -rs generate.

Signed-off-by: dblock <dblock@amazon.com>

* Updated CHANGELOG.

Signed-off-by: dblock <dblock@amazon.com>

* Use lowest common python version for lint.

Signed-off-by: dblock <dblock@amazon.com>

* Fix: don't typeshed.

Signed-off-by: dblock <dblock@amazon.com>

* Removed unneeded comment.

Signed-off-by: dblock <dblock@amazon.com>

* Simplify OPENSEARCH_URL.

Signed-off-by: dblock <dblock@amazon.com>

* Fix: positional ignore_status used as chunk_size.

Signed-off-by: dblock <dblock@amazon.com>

* Fix: parse version string.

Signed-off-by: dblock <dblock@amazon.com>

* Remove future annotations for Python 3.6.

Signed-off-by: dblock <dblock@amazon.com>

* Fix: types in documentation.

Signed-off-by: dblock <dblock@amazon.com>

* Improve CHANGELOG text.

Signed-off-by: dblock <dblock@amazon.com>

* Re-added missing separator.

Signed-off-by: dblock <dblock@amazon.com>

* Remove duplicate licenses.

Signed-off-by: dblock <dblock@amazon.com>

* Get rid of Optional[Any].

Signed-off-by: dblock <dblock@amazon.com>

* Fix docs with AsyncOpenSearch.

Signed-off-by: dblock <dblock@amazon.com>

* Fix: undo comment.

Signed-off-by: dblock <dblock@amazon.com>

---------

Signed-off-by: dblock <dblock@amazon.com>
2023-11-06 10:08:19 -08:00

143 lines
5.2 KiB
Python

# -*- coding: utf-8 -*-
# SPDX-License-Identifier: Apache-2.0
#
# The OpenSearch Contributors require contributions made to
# this file be licensed under the Apache-2.0 license or a
# compatible open source license.
#
# Modifications Copyright OpenSearch Contributors. See
# GitHub history for details.
#
# Licensed to Elasticsearch B.V. under one or more contributor
# license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright
# ownership. Elasticsearch B.V. licenses this file to you under
# the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# ----------------------------------------------------
# THIS CODE IS GENERATED AND MANUAL EDITS WILL BE LOST.
#
# To contribute, kindly make essential modifications through either the "opensearch-py client generator":
# https://github.com/opensearch-project/opensearch-py/blob/main/utils/generate-api.py
# or the "OpenSearch API specification" available at:
# https://github.com/opensearch-project/opensearch-api-specification/blob/main/OpenSearch.openapi.json
# -----------------------------------------------------
import warnings
from typing import Any
from .utils import SKIP_IN_PATH, NamespacedClient, _make_path, query_params
class TasksClient(NamespacedClient):
@query_params(
"actions",
"detailed",
"group_by",
"nodes",
"parent_task_id",
"timeout",
"wait_for_completion",
)
async def list(
self,
params: Any = None,
headers: Any = None,
) -> Any:
"""
Returns a list of tasks.
:arg actions: Comma-separated list of actions that should be
returned. Leave empty to return all.
:arg detailed: Return detailed task information. Default is
false.
:arg group_by: Group tasks by nodes or parent/child
relationships. Valid choices are nodes, parents, none.
:arg nodes: Comma-separated list of node IDs or names to limit
the returned information; use `_local` to return information from the
node you're connecting to, leave empty to get information from all
nodes.
:arg parent_task_id: Return tasks with specified parent task id
(node_id:task_number). Set to -1 to return all.
:arg timeout: Operation timeout.
:arg wait_for_completion: Should this request wait until the
operation has completed before returning. Default is false.
"""
return await self.transport.perform_request(
"GET", "/_tasks", params=params, headers=headers
)
@query_params("actions", "nodes", "parent_task_id", "wait_for_completion")
async def cancel(
self,
task_id: Any = None,
params: Any = None,
headers: Any = None,
) -> Any:
"""
Cancels a task, if it can be cancelled through an API.
:arg task_id: Cancel the task with specified task id
(node_id:task_number).
:arg actions: Comma-separated list of actions that should be
cancelled. Leave empty to cancel all.
:arg nodes: Comma-separated list of node IDs or names to limit
the returned information; use `_local` to return information from the
node you're connecting to, leave empty to get information from all
nodes.
:arg parent_task_id: Cancel tasks with specified parent task id
(node_id:task_number). Set to -1 to cancel all.
:arg wait_for_completion: Should this request wait until the
operation has completed before returning. Default is false.
"""
return await self.transport.perform_request(
"POST",
_make_path("_tasks", task_id, "_cancel"),
params=params,
headers=headers,
)
@query_params("timeout", "wait_for_completion")
async def get(
self,
task_id: Any = None,
params: Any = None,
headers: Any = None,
) -> Any:
"""
Returns information about a task.
:arg task_id: Return the task with specified id
(node_id:task_number).
:arg timeout: Operation timeout.
:arg wait_for_completion: Should this request wait until the
operation has completed before returning. Default is false.
"""
if task_id in SKIP_IN_PATH:
warnings.warn(
"Calling client.tasks.get() without a task_id is deprecated "
"and will be removed in v8.0. Use client.tasks.list() instead.",
category=DeprecationWarning,
stacklevel=3,
)
return await self.transport.perform_request(
"GET", _make_path("_tasks", task_id), params=params, headers=headers
)