Skip to content

Commit

Permalink
Integrated generated APIs into the existing module, ensuring alignmen…
Browse files Browse the repository at this point in the history
…t with the server and maintaining backward compatibility (#508)

Signed-off-by: saimedhi <saimedhi@amazon.com>
  • Loading branch information
saimedhi authored Sep 26, 2023
1 parent c6c7df5 commit 2feccc2
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 73 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- Added generating imports and headers to API generator ([#467](https://github.com/opensearch-project/opensearch-py/pull/467))
- Added point-in-time APIs (create_pit, delete_pit, delete_all_pits, get_all_pits) and Security Client APIs (health and update_audit_configuration) ([#502](https://github.com/opensearch-project/opensearch-py/pull/502))
### Changed
- Integrated generated `tasks client` APIs into the existing module, ensuring alignment with the server and maintaining backward compatibility ([#508](https://github.com/opensearch-project/opensearch-py/pull/508))
### Deprecated
- Deprecated point-in-time APIs (list_all_point_in_time, create_point_in_time, delete_point_in_time) and Security Client APIs (health_check and update_audit_config) ([#502](https://github.com/opensearch-project/opensearch-py/pull/502))
### Removed
Expand Down
64 changes: 30 additions & 34 deletions opensearchpy/_async/client/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@
# 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 .utils import SKIP_IN_PATH, NamespacedClient, _make_path, query_params
Expand All @@ -45,24 +55,20 @@ async def list(self, params=None, headers=None):
Returns a list of tasks.
.. warning::
This API is **experimental** so may include breaking changes
or be removed in a future version
:arg actions: A comma-separated list of actions that should be
:arg actions: Comma-separated list of actions that should be
returned. Leave empty to return all.
:arg detailed: Return detailed task information (default: false)
:arg detailed: Return detailed task information.
:arg group_by: Group tasks by nodes or parent/child
relationships Valid choices: nodes, parents, none Default: nodes
:arg nodes: A comma-separated list of node IDs or names to limit
relationships. Valid choices: 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
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: Explicit operation timeout
:arg wait_for_completion: Wait for the matching tasks to
complete (default: false)
:arg timeout: Operation timeout.
:arg wait_for_completion: Should this request wait until the
operation has completed before returning.
"""
return await self.transport.perform_request(
"GET", "/_tasks", params=params, headers=headers
Expand All @@ -74,23 +80,18 @@ async def cancel(self, task_id=None, params=None, headers=None):
Cancels a task, if it can be cancelled through an API.
.. warning::
This API is **experimental** so may include breaking changes
or be removed in a future version
:arg task_id: Cancel the task with specified task id
(node_id:task_number)
:arg actions: A comma-separated list of actions that should be
(node_id:task_number).
:arg actions: Comma-separated list of actions that should be
cancelled. Leave empty to cancel all.
:arg nodes: A comma-separated list of node IDs or names to limit
: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
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 the request block until the
cancellation of the task and its descendant tasks is completed. Defaults
to false
:arg wait_for_completion: Should this request wait until the
operation has completed before returning.
"""
return await self.transport.perform_request(
"POST",
Expand All @@ -105,16 +106,11 @@ async def get(self, task_id=None, params=None, headers=None):
Returns information about a task.
.. warning::
This API is **experimental** so may include breaking changes
or be removed in a future version
:arg task_id: Return the task with specified id
(node_id:task_number)
:arg timeout: Explicit operation timeout
:arg wait_for_completion: Wait for the matching tasks to
complete (default: false)
(node_id:task_number).
:arg timeout: Operation timeout.
:arg wait_for_completion: Should this request wait until the
operation has completed before returning.
"""
if task_id in SKIP_IN_PATH:
warnings.warn(
Expand Down
9 changes: 9 additions & 0 deletions opensearchpy/_async/client/tasks.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@
# 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
# -----------------------------------------------------

from typing import Any, Collection, MutableMapping, Optional, Tuple, Union

from .utils import NamespacedClient
Expand Down
64 changes: 30 additions & 34 deletions opensearchpy/client/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@
# 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 .utils import SKIP_IN_PATH, NamespacedClient, _make_path, query_params
Expand All @@ -45,24 +55,20 @@ def list(self, params=None, headers=None):
Returns a list of tasks.
.. warning::
This API is **experimental** so may include breaking changes
or be removed in a future version
:arg actions: A comma-separated list of actions that should be
:arg actions: Comma-separated list of actions that should be
returned. Leave empty to return all.
:arg detailed: Return detailed task information (default: false)
:arg detailed: Return detailed task information.
:arg group_by: Group tasks by nodes or parent/child
relationships Valid choices: nodes, parents, none Default: nodes
:arg nodes: A comma-separated list of node IDs or names to limit
relationships. Valid choices: 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
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: Explicit operation timeout
:arg wait_for_completion: Wait for the matching tasks to
complete (default: false)
:arg timeout: Operation timeout.
:arg wait_for_completion: Should this request wait until the
operation has completed before returning.
"""
return self.transport.perform_request(
"GET", "/_tasks", params=params, headers=headers
Expand All @@ -74,23 +80,18 @@ def cancel(self, task_id=None, params=None, headers=None):
Cancels a task, if it can be cancelled through an API.
.. warning::
This API is **experimental** so may include breaking changes
or be removed in a future version
:arg task_id: Cancel the task with specified task id
(node_id:task_number)
:arg actions: A comma-separated list of actions that should be
(node_id:task_number).
:arg actions: Comma-separated list of actions that should be
cancelled. Leave empty to cancel all.
:arg nodes: A comma-separated list of node IDs or names to limit
: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
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 the request block until the
cancellation of the task and its descendant tasks is completed. Defaults
to false
:arg wait_for_completion: Should this request wait until the
operation has completed before returning.
"""
return self.transport.perform_request(
"POST",
Expand All @@ -105,16 +106,11 @@ def get(self, task_id=None, params=None, headers=None):
Returns information about a task.
.. warning::
This API is **experimental** so may include breaking changes
or be removed in a future version
:arg task_id: Return the task with specified id
(node_id:task_number)
:arg timeout: Explicit operation timeout
:arg wait_for_completion: Wait for the matching tasks to
complete (default: false)
(node_id:task_number).
:arg timeout: Operation timeout.
:arg wait_for_completion: Should this request wait until the
operation has completed before returning.
"""
if task_id in SKIP_IN_PATH:
warnings.warn(
Expand Down
9 changes: 9 additions & 0 deletions opensearchpy/client/tasks.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@
# 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
# -----------------------------------------------------

from typing import Any, Collection, MutableMapping, Optional, Tuple, Union

from .utils import NamespacedClient
Expand Down
10 changes: 5 additions & 5 deletions utils/generated_file_headers.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# ----------------------------------------------------
# THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST.
#
# To contribute, please make necessary modifications to either "Python generator":
# 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 "OpenAPI specs":
# or the "OpenSearch API specification" available at:
# https://github.com/opensearch-project/opensearch-api-specification/blob/main/OpenSearch.openapi.json
# -----------------------------------------------------
# -----------------------------------------------------

0 comments on commit 2feccc2

Please sign in to comment.