diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b7767643..af9a4b66 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,6 +18,21 @@ jobs: python3.7 -m pip install nox - name: Lint the code run: nox -s lint + + generate: + runs-on: ubuntu-latest + steps: + - name: Checkout Repository + uses: actions/checkout@v3 + - name: Set up Python 3.7 + uses: actions/setup-python@v4 + with: + python-version: 3.7 + - name: Install dependencies + run: | + python3.7 -m pip install nox + - name: Run the api generator + run: nox -s generate test-build-distribution: runs-on: ubuntu-latest diff --git a/CHANGELOG.md b/CHANGELOG.md index 930003bb..40563c66 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Added pylint `pointless-statement` ([#611](https://github.com/opensearch-project/opensearch-py/pull/611)) - Added a log collection guide ([#579](https://github.com/opensearch-project/opensearch-py/pull/579)) - Added GHA release ([#614](https://github.com/opensearch-project/opensearch-py/pull/614)) +- Incorporated API generation into CI workflow and fixed 'generate' nox session ([#660](https://github.com/opensearch-project/opensearch-py/pull/660)) ### Changed - Updated the `get_policy` API in the index_management plugin to allow the policy_id argument as optional ([#633](https://github.com/opensearch-project/opensearch-py/pull/633)) ### Deprecated diff --git a/noxfile.py b/noxfile.py index e0cbe53f..1b261fe0 100644 --- a/noxfile.py +++ b/noxfile.py @@ -74,7 +74,7 @@ def format(session: Any) -> None: session.run("black", *SOURCE_FILES) session.run("python", "utils/license_headers.py", "fix", *SOURCE_FILES) - lint(session) + session.notify("lint") @nox.session(python=["3.7"]) # type: ignore @@ -146,4 +146,4 @@ def generate(session: Any) -> None: """ session.install("-rdev-requirements.txt") session.run("python", "utils/generate_api.py") - format(session) + session.notify("format") diff --git a/opensearchpy/_async/client/__init__.py b/opensearchpy/_async/client/__init__.py index f88ee0b9..a1e8c80a 100644 --- a/opensearchpy/_async/client/__init__.py +++ b/opensearchpy/_async/client/__init__.py @@ -1610,6 +1610,7 @@ async def scroll( "rest_total_hits_as_int", "routing", "scroll", + "search_pipeline", "search_type", "seq_no_primary_term", "size", @@ -1704,6 +1705,8 @@ async def search( :arg routing: Comma-separated list of specific routing values. :arg scroll: Specify how long a consistent view of the index should be maintained for scrolled search. + :arg search_pipeline: Customizable sequence of processing stages + applied to search queries. :arg search_type: Search operation type. Valid choices are query_then_fetch, dfs_query_then_fetch. :arg seq_no_primary_term: Specify whether to return sequence diff --git a/opensearchpy/_async/client/cat.py b/opensearchpy/_async/client/cat.py index a93fb208..89f7a9a7 100644 --- a/opensearchpy/_async/client/cat.py +++ b/opensearchpy/_async/client/cat.py @@ -70,7 +70,7 @@ async def aliases( "GET", _make_path("_cat", "aliases", name), params=params, headers=headers ) - @query_params() + @query_params("bytes", "format", "h", "help", "s", "v") async def all_pit_segments( self, params: Any = None, @@ -79,6 +79,16 @@ async def all_pit_segments( """ Lists all active point-in-time segments. + + :arg bytes: The unit in which to display byte values. Valid + choices are b, k, kb, m, mb, g, gb, t, tb, p, pb. + :arg format: A short version of the Accept header, e.g. json, + yaml. + :arg h: Comma-separated list of column names to display. + :arg help: Return help information. Default is false. + :arg s: Comma-separated list of column names or column aliases + to sort by. + :arg v: Verbose mode. Display column headers. Default is false. """ return await self.transport.perform_request( "GET", "/_cat/pit_segments/_all", params=params, headers=headers @@ -503,7 +513,7 @@ async def pending_tasks( "GET", "/_cat/pending_tasks", params=params, headers=headers ) - @query_params() + @query_params("bytes", "format", "h", "help", "s", "v") async def pit_segments( self, body: Any = None, @@ -514,6 +524,15 @@ async def pit_segments( List segments for one or several PITs. + :arg bytes: The unit in which to display byte values. Valid + choices are b, k, kb, m, mb, g, gb, t, tb, p, pb. + :arg format: A short version of the Accept header, e.g. json, + yaml. + :arg h: Comma-separated list of column names to display. + :arg help: Return help information. Default is false. + :arg s: Comma-separated list of column names or column aliases + to sort by. + :arg v: Verbose mode. Display column headers. Default is false. """ return await self.transport.perform_request( "GET", "/_cat/pit_segments", params=params, headers=headers, body=body @@ -632,15 +651,20 @@ async def repositories( @query_params( "active_only", + "allow_no_indices", "bytes", "completed_only", "detailed", + "expand_wildcards", "format", "h", "help", + "ignore_throttled", + "ignore_unavailable", "s", "shards", "time", + "timeout", "v", ) async def segment_replication( @@ -658,21 +682,32 @@ async def segment_replication( names to limit the returned information. :arg active_only: If `true`, the response only includes ongoing segment replication events. Default is false. + :arg allow_no_indices: Whether to ignore if a wildcard indices + expression resolves into no concrete indices. (This includes `_all` + string or when no indices have been specified). :arg bytes: The unit in which to display byte values. Valid choices are b, k, kb, m, mb, g, gb, t, tb, p, pb. :arg completed_only: If `true`, the response only includes latest completed segment replication events. Default is false. :arg detailed: If `true`, the response includes detailed information about segment replications. Default is false. + :arg expand_wildcards: Whether to expand wildcard expression to + concrete indices that are open, closed or both. Valid choices are all, + open, closed, hidden, none. :arg format: A short version of the Accept header, e.g. json, yaml. :arg h: Comma-separated list of column names to display. :arg help: Return help information. Default is false. + :arg ignore_throttled: Whether specified concrete, expanded or + aliased indices should be ignored when throttled. + :arg ignore_unavailable: Whether specified concrete indices + should be ignored when unavailable (missing or closed). :arg s: Comma-separated list of column names or column aliases to sort by. :arg shards: Comma-separated list of shards to display. :arg time: The unit in which to display time values. Valid choices are d, h, m, s, ms, micros, nanos. + :arg timeout: Operation timeout. :arg v: Verbose mode. Display column headers. Default is false. """ return await self.transport.perform_request( diff --git a/opensearchpy/_async/client/indices.py b/opensearchpy/_async/client/indices.py index 4e1c45eb..cf86b46f 100644 --- a/opensearchpy/_async/client/indices.py +++ b/opensearchpy/_async/client/indices.py @@ -166,7 +166,12 @@ async def create( ) @query_params( - "cluster_manager_timeout", "master_timeout", "timeout", "wait_for_active_shards" + "cluster_manager_timeout", + "master_timeout", + "task_execution_timeout", + "timeout", + "wait_for_active_shards", + "wait_for_completion", ) async def clone( self, @@ -189,9 +194,13 @@ async def clone( :arg master_timeout (Deprecated: To promote inclusive language, use 'cluster_manager_timeout' instead.): Operation timeout for connection to master node. + :arg task_execution_timeout: Explicit task execution timeout, + only useful when wait_for_completion is false, defaults to 1h. :arg timeout: Operation timeout. :arg wait_for_active_shards: Set the number of active shards to wait for on the cloned index before the operation returns. + :arg wait_for_completion: Should this request wait until the + operation has completed before returning. Default is True. """ for param in (index, target): if param in SKIP_IN_PATH: @@ -260,8 +269,10 @@ async def get( "expand_wildcards", "ignore_unavailable", "master_timeout", + "task_execution_timeout", "timeout", "wait_for_active_shards", + "wait_for_completion", ) async def open( self, @@ -287,9 +298,13 @@ async def open( :arg master_timeout (Deprecated: To promote inclusive language, use 'cluster_manager_timeout' instead.): Operation timeout for connection to master node. + :arg task_execution_timeout: Explicit task execution timeout, + only useful when wait_for_completion is false, defaults to 1h. :arg timeout: Operation timeout. :arg wait_for_active_shards: Sets the number of active shards to wait for before the operation returns. + :arg wait_for_completion: Should this request wait until the + operation has completed before returning. Default is True. """ if index in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'index'.") @@ -1245,6 +1260,7 @@ async def shard_stores( "ignore_unavailable", "max_num_segments", "only_expunge_deletes", + "wait_for_completion", ) async def forcemerge( self, @@ -1272,6 +1288,8 @@ async def forcemerge( be merged into (default: dynamic). :arg only_expunge_deletes: Specify whether the operation should only expunge deleted documents. + :arg wait_for_completion: Should this request wait until the + operation has completed before returning. Default is True. """ return await self.transport.perform_request( "POST", _make_path(index, "_forcemerge"), params=params, headers=headers @@ -1281,8 +1299,10 @@ async def forcemerge( "cluster_manager_timeout", "copy_settings", "master_timeout", + "task_execution_timeout", "timeout", "wait_for_active_shards", + "wait_for_completion", ) async def shrink( self, @@ -1307,9 +1327,13 @@ async def shrink( :arg master_timeout (Deprecated: To promote inclusive language, use 'cluster_manager_timeout' instead.): Operation timeout for connection to master node. + :arg task_execution_timeout: Explicit task execution timeout, + only useful when wait_for_completion is false, defaults to 1h. :arg timeout: Operation timeout. :arg wait_for_active_shards: Set the number of active shards to wait for on the shrunken index before the operation returns. + :arg wait_for_completion: Should this request wait until the + operation has completed before returning. Default is True. """ for param in (index, target): if param in SKIP_IN_PATH: @@ -1327,8 +1351,10 @@ async def shrink( "cluster_manager_timeout", "copy_settings", "master_timeout", + "task_execution_timeout", "timeout", "wait_for_active_shards", + "wait_for_completion", ) async def split( self, @@ -1354,9 +1380,13 @@ async def split( :arg master_timeout (Deprecated: To promote inclusive language, use 'cluster_manager_timeout' instead.): Operation timeout for connection to master node. + :arg task_execution_timeout: Explicit task execution timeout, + only useful when wait_for_completion is false, defaults to 1h. :arg timeout: Operation timeout. :arg wait_for_active_shards: Set the number of active shards to wait for on the shrunken index before the operation returns. + :arg wait_for_completion: Should this request wait until the + operation has completed before returning. Default is True. """ for param in (index, target): if param in SKIP_IN_PATH: diff --git a/opensearchpy/_async/client/nodes.py b/opensearchpy/_async/client/nodes.py index 6afda0d2..f060bd5f 100644 --- a/opensearchpy/_async/client/nodes.py +++ b/opensearchpy/_async/client/nodes.py @@ -122,7 +122,8 @@ async def stats( nodes. :arg metric: Limit the information returned to the specified metrics. Valid choices are _all, breaker, fs, http, indices, jvm, os, - process, thread_pool, transport, discovery, indexing_pressure. + process, thread_pool, transport, discovery, indexing_pressure, + search_pipeline. :arg index_metric: Limit the information returned for `indices` metric to the specific index metrics. Isn't used if `indices` (or `all`) metric isn't specified. Valid choices are _all, store, indexing, get, diff --git a/opensearchpy/client/__init__.py b/opensearchpy/client/__init__.py index 013b1b1b..0dfafab7 100644 --- a/opensearchpy/client/__init__.py +++ b/opensearchpy/client/__init__.py @@ -1610,6 +1610,7 @@ def scroll( "rest_total_hits_as_int", "routing", "scroll", + "search_pipeline", "search_type", "seq_no_primary_term", "size", @@ -1704,6 +1705,8 @@ def search( :arg routing: Comma-separated list of specific routing values. :arg scroll: Specify how long a consistent view of the index should be maintained for scrolled search. + :arg search_pipeline: Customizable sequence of processing stages + applied to search queries. :arg search_type: Search operation type. Valid choices are query_then_fetch, dfs_query_then_fetch. :arg seq_no_primary_term: Specify whether to return sequence diff --git a/opensearchpy/client/cat.py b/opensearchpy/client/cat.py index d30b7b90..a1860813 100644 --- a/opensearchpy/client/cat.py +++ b/opensearchpy/client/cat.py @@ -70,7 +70,7 @@ def aliases( "GET", _make_path("_cat", "aliases", name), params=params, headers=headers ) - @query_params() + @query_params("bytes", "format", "h", "help", "s", "v") def all_pit_segments( self, params: Any = None, @@ -79,6 +79,16 @@ def all_pit_segments( """ Lists all active point-in-time segments. + + :arg bytes: The unit in which to display byte values. Valid + choices are b, k, kb, m, mb, g, gb, t, tb, p, pb. + :arg format: A short version of the Accept header, e.g. json, + yaml. + :arg h: Comma-separated list of column names to display. + :arg help: Return help information. Default is false. + :arg s: Comma-separated list of column names or column aliases + to sort by. + :arg v: Verbose mode. Display column headers. Default is false. """ return self.transport.perform_request( "GET", "/_cat/pit_segments/_all", params=params, headers=headers @@ -503,7 +513,7 @@ def pending_tasks( "GET", "/_cat/pending_tasks", params=params, headers=headers ) - @query_params() + @query_params("bytes", "format", "h", "help", "s", "v") def pit_segments( self, body: Any = None, @@ -514,6 +524,15 @@ def pit_segments( List segments for one or several PITs. + :arg bytes: The unit in which to display byte values. Valid + choices are b, k, kb, m, mb, g, gb, t, tb, p, pb. + :arg format: A short version of the Accept header, e.g. json, + yaml. + :arg h: Comma-separated list of column names to display. + :arg help: Return help information. Default is false. + :arg s: Comma-separated list of column names or column aliases + to sort by. + :arg v: Verbose mode. Display column headers. Default is false. """ return self.transport.perform_request( "GET", "/_cat/pit_segments", params=params, headers=headers, body=body @@ -632,15 +651,20 @@ def repositories( @query_params( "active_only", + "allow_no_indices", "bytes", "completed_only", "detailed", + "expand_wildcards", "format", "h", "help", + "ignore_throttled", + "ignore_unavailable", "s", "shards", "time", + "timeout", "v", ) def segment_replication( @@ -658,21 +682,32 @@ def segment_replication( names to limit the returned information. :arg active_only: If `true`, the response only includes ongoing segment replication events. Default is false. + :arg allow_no_indices: Whether to ignore if a wildcard indices + expression resolves into no concrete indices. (This includes `_all` + string or when no indices have been specified). :arg bytes: The unit in which to display byte values. Valid choices are b, k, kb, m, mb, g, gb, t, tb, p, pb. :arg completed_only: If `true`, the response only includes latest completed segment replication events. Default is false. :arg detailed: If `true`, the response includes detailed information about segment replications. Default is false. + :arg expand_wildcards: Whether to expand wildcard expression to + concrete indices that are open, closed or both. Valid choices are all, + open, closed, hidden, none. :arg format: A short version of the Accept header, e.g. json, yaml. :arg h: Comma-separated list of column names to display. :arg help: Return help information. Default is false. + :arg ignore_throttled: Whether specified concrete, expanded or + aliased indices should be ignored when throttled. + :arg ignore_unavailable: Whether specified concrete indices + should be ignored when unavailable (missing or closed). :arg s: Comma-separated list of column names or column aliases to sort by. :arg shards: Comma-separated list of shards to display. :arg time: The unit in which to display time values. Valid choices are d, h, m, s, ms, micros, nanos. + :arg timeout: Operation timeout. :arg v: Verbose mode. Display column headers. Default is false. """ return self.transport.perform_request( diff --git a/opensearchpy/client/indices.py b/opensearchpy/client/indices.py index 424529f1..ef2eba81 100644 --- a/opensearchpy/client/indices.py +++ b/opensearchpy/client/indices.py @@ -166,7 +166,12 @@ def create( ) @query_params( - "cluster_manager_timeout", "master_timeout", "timeout", "wait_for_active_shards" + "cluster_manager_timeout", + "master_timeout", + "task_execution_timeout", + "timeout", + "wait_for_active_shards", + "wait_for_completion", ) def clone( self, @@ -189,9 +194,13 @@ def clone( :arg master_timeout (Deprecated: To promote inclusive language, use 'cluster_manager_timeout' instead.): Operation timeout for connection to master node. + :arg task_execution_timeout: Explicit task execution timeout, + only useful when wait_for_completion is false, defaults to 1h. :arg timeout: Operation timeout. :arg wait_for_active_shards: Set the number of active shards to wait for on the cloned index before the operation returns. + :arg wait_for_completion: Should this request wait until the + operation has completed before returning. Default is True. """ for param in (index, target): if param in SKIP_IN_PATH: @@ -260,8 +269,10 @@ def get( "expand_wildcards", "ignore_unavailable", "master_timeout", + "task_execution_timeout", "timeout", "wait_for_active_shards", + "wait_for_completion", ) def open( self, @@ -287,9 +298,13 @@ def open( :arg master_timeout (Deprecated: To promote inclusive language, use 'cluster_manager_timeout' instead.): Operation timeout for connection to master node. + :arg task_execution_timeout: Explicit task execution timeout, + only useful when wait_for_completion is false, defaults to 1h. :arg timeout: Operation timeout. :arg wait_for_active_shards: Sets the number of active shards to wait for before the operation returns. + :arg wait_for_completion: Should this request wait until the + operation has completed before returning. Default is True. """ if index in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'index'.") @@ -1245,6 +1260,7 @@ def shard_stores( "ignore_unavailable", "max_num_segments", "only_expunge_deletes", + "wait_for_completion", ) def forcemerge( self, @@ -1272,6 +1288,8 @@ def forcemerge( be merged into (default: dynamic). :arg only_expunge_deletes: Specify whether the operation should only expunge deleted documents. + :arg wait_for_completion: Should this request wait until the + operation has completed before returning. Default is True. """ return self.transport.perform_request( "POST", _make_path(index, "_forcemerge"), params=params, headers=headers @@ -1281,8 +1299,10 @@ def forcemerge( "cluster_manager_timeout", "copy_settings", "master_timeout", + "task_execution_timeout", "timeout", "wait_for_active_shards", + "wait_for_completion", ) def shrink( self, @@ -1307,9 +1327,13 @@ def shrink( :arg master_timeout (Deprecated: To promote inclusive language, use 'cluster_manager_timeout' instead.): Operation timeout for connection to master node. + :arg task_execution_timeout: Explicit task execution timeout, + only useful when wait_for_completion is false, defaults to 1h. :arg timeout: Operation timeout. :arg wait_for_active_shards: Set the number of active shards to wait for on the shrunken index before the operation returns. + :arg wait_for_completion: Should this request wait until the + operation has completed before returning. Default is True. """ for param in (index, target): if param in SKIP_IN_PATH: @@ -1327,8 +1351,10 @@ def shrink( "cluster_manager_timeout", "copy_settings", "master_timeout", + "task_execution_timeout", "timeout", "wait_for_active_shards", + "wait_for_completion", ) def split( self, @@ -1354,9 +1380,13 @@ def split( :arg master_timeout (Deprecated: To promote inclusive language, use 'cluster_manager_timeout' instead.): Operation timeout for connection to master node. + :arg task_execution_timeout: Explicit task execution timeout, + only useful when wait_for_completion is false, defaults to 1h. :arg timeout: Operation timeout. :arg wait_for_active_shards: Set the number of active shards to wait for on the shrunken index before the operation returns. + :arg wait_for_completion: Should this request wait until the + operation has completed before returning. Default is True. """ for param in (index, target): if param in SKIP_IN_PATH: diff --git a/opensearchpy/client/nodes.py b/opensearchpy/client/nodes.py index 73c0f8dd..ea2d4b47 100644 --- a/opensearchpy/client/nodes.py +++ b/opensearchpy/client/nodes.py @@ -122,7 +122,8 @@ def stats( nodes. :arg metric: Limit the information returned to the specified metrics. Valid choices are _all, breaker, fs, http, indices, jvm, os, - process, thread_pool, transport, discovery, indexing_pressure. + process, thread_pool, transport, discovery, indexing_pressure, + search_pipeline. :arg index_metric: Limit the information returned for `indices` metric to the specific index metrics. Isn't used if `indices` (or `all`) metric isn't specified. Valid choices are _all, store, indexing, get,