From 869c35f55176be3f80e8166f874a16317b20b7b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Honza=20Kr=C3=A1l?= Date: Tue, 17 Dec 2019 23:23:56 +0100 Subject: [PATCH] Fixed generator, passing tests --- elasticsearch/client/__init__.py | 26 ++++-- elasticsearch/client/cat.py | 13 +-- elasticsearch/client/cluster.py | 8 +- elasticsearch/client/indices.py | 6 +- elasticsearch/client/ml.py | 135 ------------------------------- elasticsearch/client/rollup.py | 90 --------------------- elasticsearch/client/watcher.py | 2 +- elasticsearch/client/xpack.py | 4 - generate_api.py | 28 ++++--- 9 files changed, 52 insertions(+), 260 deletions(-) diff --git a/elasticsearch/client/__init__.py b/elasticsearch/client/__init__.py index cd87af0e..f33c2944 100644 --- a/elasticsearch/client/__init__.py +++ b/elasticsearch/client/__init__.py @@ -341,6 +341,9 @@ class Elasticsearch(object): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") + if doc_type in SKIP_IN_PATH: + doc_type = "_doc" + return self.transport.perform_request( "PUT", _make_path(index, doc_type, id, "_create"), params=params, body=body ) @@ -410,7 +413,6 @@ class Elasticsearch(object): "_source", "_source_excludes", "_source_includes", - "doc_type", "pipeline", "refresh", "routing", @@ -581,7 +583,7 @@ class Elasticsearch(object): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") - if doc_type is None: + if doc_type in SKIP_IN_PATH: doc_type = "_doc" return self.transport.perform_request( @@ -795,7 +797,7 @@ class Elasticsearch(object): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") - if doc_type is None: + if doc_type in SKIP_IN_PATH: doc_type = "_doc" return self.transport.perform_request( @@ -896,6 +898,9 @@ class Elasticsearch(object): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") + if doc_type in SKIP_IN_PATH: + doc_type = "_doc" + return self.transport.perform_request( "GET", _make_path(index, doc_type, id, "_explain"), params=params, body=body ) @@ -975,7 +980,7 @@ class Elasticsearch(object): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") - if doc_type is None: + if doc_type in SKIP_IN_PATH: doc_type = "_doc" return self.transport.perform_request( @@ -1039,6 +1044,9 @@ class Elasticsearch(object): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") + if doc_type in SKIP_IN_PATH: + doc_type = "_doc" + return self.transport.perform_request( "GET", _make_path(index, doc_type, id, "_source"), params=params ) @@ -1236,7 +1244,7 @@ class Elasticsearch(object): body=body, ) - @query_params("context", "master_timeout", "timeout") + @query_params("master_timeout", "timeout") def put_script(self, id, body, context=None, params=None): """ Creates or updates a script. @@ -1372,7 +1380,7 @@ class Elasticsearch(object): "GET", "/_scripts/painless/_execute", params=params, body=body ) - @query_params("rest_total_hits_as_int", "scroll", "scroll_id") + @query_params("rest_total_hits_as_int", "scroll") def scroll(self, body=None, scroll_id=None, params=None): """ Allows to retrieve a large numbers of results from a single search request. @@ -1694,6 +1702,9 @@ class Elasticsearch(object): if index in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'index'.") + if doc_type in SKIP_IN_PATH: + doc_type = "_doc" + return self.transport.perform_request( "GET", _make_path(index, doc_type, id, "_termvectors"), @@ -1755,6 +1766,9 @@ class Elasticsearch(object): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") + if doc_type in SKIP_IN_PATH: + doc_type = "_doc" + return self.transport.perform_request( "POST", _make_path(index, doc_type, id, "_update"), params=params, body=body ) diff --git a/elasticsearch/client/cat.py b/elasticsearch/client/cat.py index 515483e4..409340b6 100644 --- a/elasticsearch/client/cat.py +++ b/elasticsearch/client/cat.py @@ -213,16 +213,7 @@ class CatClient(NamespacedClient): return self.transport.perform_request("GET", "/_cat/nodes", params=params) @query_params( - "active_only", - "bytes", - "detailed", - "format", - "h", - "help", - "index", - "s", - "time", - "v", + "active_only", "bytes", "detailed", "format", "h", "help", "s", "time", "v" ) def recovery(self, index=None, params=None): """ @@ -361,7 +352,7 @@ class CatClient(NamespacedClient): params=params, ) - @query_params("bytes", "fields", "format", "h", "help", "s", "v") + @query_params("bytes", "format", "h", "help", "s", "v") def fielddata(self, fields=None, params=None): """ Shows how much heap memory is currently being used by fielddata on every data diff --git a/elasticsearch/client/cluster.py b/elasticsearch/client/cluster.py index 1a869748..4cf13a26 100644 --- a/elasticsearch/client/cluster.py +++ b/elasticsearch/client/cluster.py @@ -1,4 +1,4 @@ -from .utils import NamespacedClient, query_params, _make_path +from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH class ClusterClient(NamespacedClient): @@ -121,7 +121,11 @@ class ClusterClient(NamespacedClient): :arg timeout: Explicit operation timeout """ return self.transport.perform_request( - "GET", _make_path("_cluster", "stats", "nodes", node_id), params=params + "GET", + "/_cluster/stats" + if node_id in SKIP_IN_PATH + else _make_path("_cluster", "stats", "nodes", node_id), + params=params, ) @query_params( diff --git a/elasticsearch/client/indices.py b/elasticsearch/client/indices.py index 073f2b7f..3444beca 100644 --- a/elasticsearch/client/indices.py +++ b/elasticsearch/client/indices.py @@ -2,7 +2,7 @@ from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH class IndicesClient(NamespacedClient): - @query_params("index") + @query_params() def analyze(self, body=None, index=None, params=None): """ Performs the analysis process on a text and return the tokens breakdown of the @@ -356,6 +356,9 @@ class IndicesClient(NamespacedClient): if body in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'body'.") + if doc_type not in SKIP_IN_PATH and index in SKIP_IN_PATH: + index = "_all" + return self.transport.perform_request( "PUT", _make_path(index, doc_type, "_mapping"), params=params, body=body ) @@ -854,7 +857,6 @@ class IndicesClient(NamespacedClient): "fielddata", "fields", "ignore_unavailable", - "index", "query", "request", ) diff --git a/elasticsearch/client/ml.py b/elasticsearch/client/ml.py index 16a9de76..f3043ca2 100644 --- a/elasticsearch/client/ml.py +++ b/elasticsearch/client/ml.py @@ -29,10 +29,6 @@ class MlClient(NamespacedClient): @query_params() def delete_calendar(self, calendar_id, params=None): """ - :arg calendar_id: The ID of the calendar to delete :arg calendar_id: - The ID of the calendar to delete :arg calendar_id: The ID of the - calendar to delete :arg calendar_id: The ID of the calendar to delete - :arg calendar_id: The ID of the calendar to delete :arg calendar_id: The ID of the calendar to delete """ @@ -48,15 +44,6 @@ class MlClient(NamespacedClient): @query_params() def delete_calendar_event(self, calendar_id, event_id, params=None): """ - :arg calendar_id: The ID of the calendar to modify :arg event_id: The - ID of the event to remove from the calendar :arg calendar_id: The ID - of the calendar to modify :arg event_id: The ID of the event to remove - from the calendar :arg calendar_id: The ID of the calendar to modify - :arg event_id: The ID of the event to remove from the calendar :arg - calendar_id: The ID of the calendar to modify :arg event_id: The ID of - the event to remove from the calendar :arg calendar_id: The ID of the - calendar to modify :arg event_id: The ID of the event to remove from - the calendar :arg calendar_id: The ID of the calendar to modify :arg event_id: The ID of the event to remove from the calendar @@ -74,15 +61,6 @@ class MlClient(NamespacedClient): @query_params() def delete_calendar_job(self, calendar_id, job_id, params=None): """ - :arg calendar_id: The ID of the calendar to modify :arg job_id: The ID - of the job to remove from the calendar :arg calendar_id: The ID of the - calendar to modify :arg job_id: The ID of the job to remove from the - calendar :arg calendar_id: The ID of the calendar to modify - :arg job_id: The ID of the job to remove from the calendar :arg - calendar_id: The ID of the calendar to modify :arg job_id: The ID of - the job to remove from the calendar :arg calendar_id: The ID of the - calendar to modify :arg job_id: The ID of the job to remove from the - calendar :arg calendar_id: The ID of the calendar to modify :arg job_id: The ID of the job to remove from the calendar @@ -126,10 +104,6 @@ class MlClient(NamespacedClient): @query_params() def delete_filter(self, filter_id, params=None): """ - :arg filter_id: The ID of the filter to delete :arg filter_id: The ID - of the filter to delete :arg filter_id: The ID of the filter to delete - :arg filter_id: The ID of the filter to delete :arg filter_id: The ID - of the filter to delete :arg filter_id: The ID of the filter to delete """ @@ -291,23 +265,6 @@ class MlClient(NamespacedClient): @query_params("duration", "expires_in") def forecast(self, job_id, params=None): """ - :arg job_id: The ID of the job to forecast for :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 job_id: The ID of the job to forecast for - :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 job_id: The ID of the job to - forecast for :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 - job_id: The ID of the job to forecast for :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 job_id: The ID of the job to forecast for - :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 job_id: The ID of the job to forecast for :arg duration: The duration of the forecast @@ -371,31 +328,6 @@ class MlClient(NamespacedClient): @query_params("end", "from_", "job_id", "size", "start") def get_calendar_events(self, calendar_id, params=None): """ - :arg calendar_id: The ID of the calendar containing the events :arg - end: Get events before this time :arg from_: Skips a number of events - :arg job_id: Get events for the job. When this option is used - calendar_id must be '_all' :arg size: Specifies a max number of events - to get :arg start: Get events after this time :arg - calendar_id: The ID of the calendar containing the events :arg end: Get - events before this time :arg from_: Skips a number of events - :arg job_id: Get events for the job. When this option is used - calendar_id must be '_all' :arg size: Specifies a max number of events - to get :arg start: Get events after this time :arg - calendar_id: The ID of the calendar containing the events :arg end: Get - events before this time :arg from_: Skips a number of events - :arg job_id: Get events for the job. When this option is used - calendar_id must be '_all' :arg size: Specifies a max number of events - to get :arg start: Get events after this time :arg - calendar_id: The ID of the calendar containing the events :arg end: Get - events before this time :arg from_: Skips a number of events - :arg job_id: Get events for the job. When this option is used - calendar_id must be '_all' :arg size: Specifies a max number of events - to get :arg start: Get events after this time :arg - calendar_id: The ID of the calendar containing the events :arg end: Get - events before this time :arg from_: Skips a number of events - :arg job_id: Get events for the job. When this option is used - calendar_id must be '_all' :arg size: Specifies a max number of events - to get :arg start: Get events after this time :arg calendar_id: The ID of the calendar containing the events :arg end: Get events before this time @@ -421,23 +353,6 @@ class MlClient(NamespacedClient): @query_params("from_", "size") def get_calendars(self, body=None, calendar_id=None, params=None): """ - :arg body: The from and size parameters optionally sent in the body - :arg calendar_id: The ID of the calendar to fetch :arg from_: skips a - number of calendars :arg size: specifies a max number of calendars to - get :arg body: The from and size parameters optionally sent in the - body :arg calendar_id: The ID of the calendar to fetch :arg - from_: skips a number of calendars :arg size: specifies a max number of - calendars to get :arg body: The from and size parameters optionally - sent in the body :arg calendar_id: The ID of the calendar - to fetch :arg from_: skips a number of calendars :arg size: - specifies a max number of calendars to get :arg body: The from and - size parameters optionally sent in the body :arg - calendar_id: The ID of the calendar to fetch :arg from_: skips a number - of calendars :arg size: specifies a max number of calendars to get - :arg body: The from and size parameters optionally sent in the body - :arg calendar_id: The ID of the calendar to fetch :arg from_: skips a - number of calendars :arg size: specifies a max number of calendars to - get :arg body: The from and size parameters optionally sent in the body @@ -512,16 +427,6 @@ class MlClient(NamespacedClient): @query_params("from_", "size") def get_filters(self, filter_id=None, params=None): """ - :arg filter_id: The ID of the filter to fetch :arg from_: skips a - number of filters :arg size: specifies a max number of filters to get - :arg filter_id: The ID of the filter to fetch :arg from_: skips a - number of filters :arg size: specifies a max number of filters to get - :arg filter_id: The ID of the filter to fetch :arg from_: skips a - number of filters :arg size: specifies a max number of filters to get - :arg filter_id: The ID of the filter to fetch :arg from_: skips a - number of filters :arg size: specifies a max number of filters to get - :arg filter_id: The ID of the filter to fetch :arg from_: skips a - number of filters :arg size: specifies a max number of filters to get :arg filter_id: The ID of the filter to fetch :arg from_: skips a number of filters @@ -749,13 +654,6 @@ class MlClient(NamespacedClient): @query_params() def post_calendar_events(self, calendar_id, body, params=None): """ - :arg calendar_id: The ID of the calendar to modify :arg body: A list of - events :arg calendar_id: The ID of the calendar to modify :arg - body: A list of events :arg calendar_id: The ID of the calendar to - modify :arg body: A list of events :arg calendar_id: The ID of - the calendar to modify :arg body: A list of events :arg - calendar_id: The ID of the calendar to modify :arg body: A list of - events :arg calendar_id: The ID of the calendar to modify :arg body: A list of events @@ -816,13 +714,6 @@ class MlClient(NamespacedClient): @query_params() def put_calendar(self, calendar_id, body=None, params=None): """ - :arg calendar_id: The ID of the calendar to create :arg body: The - calendar details :arg calendar_id: The ID of the calendar to create - :arg body: The calendar details :arg calendar_id: The ID of the - calendar to create :arg body: The calendar details :arg - calendar_id: The ID of the calendar to create :arg body: The calendar - details :arg calendar_id: The ID of the calendar to create - :arg body: The calendar details :arg calendar_id: The ID of the calendar to create :arg body: The calendar details @@ -839,15 +730,6 @@ class MlClient(NamespacedClient): @query_params() def put_calendar_job(self, calendar_id, job_id, params=None): """ - :arg calendar_id: The ID of the calendar to modify :arg job_id: The ID - of the job to add to the calendar :arg calendar_id: The ID of the - calendar to modify :arg job_id: The ID of the job to add to the - calendar :arg calendar_id: The ID of the calendar to modify - :arg job_id: The ID of the job to add to the calendar :arg - calendar_id: The ID of the calendar to modify :arg job_id: The ID of - the job to add to the calendar :arg calendar_id: The ID of the - calendar to modify :arg job_id: The ID of the job to add to the - calendar :arg calendar_id: The ID of the calendar to modify :arg job_id: The ID of the job to add to the calendar @@ -881,12 +763,6 @@ class MlClient(NamespacedClient): @query_params() def put_filter(self, filter_id, body, params=None): """ - :arg filter_id: The ID of the filter to create :arg body: The filter - details :arg filter_id: The ID of the filter to create :arg - body: The filter details :arg filter_id: The ID of the filter to - create :arg body: The filter details :arg filter_id: The ID of - the filter to create :arg body: The filter details :arg - filter_id: The ID of the filter to create :arg body: The filter details :arg filter_id: The ID of the filter to create :arg body: The filter details @@ -1030,12 +906,6 @@ class MlClient(NamespacedClient): @query_params() def update_filter(self, filter_id, body, params=None): """ - :arg filter_id: The ID of the filter to update :arg body: The filter - update :arg filter_id: The ID of the filter to update :arg - body: The filter update :arg filter_id: The ID of the filter to update - :arg body: The filter update :arg filter_id: The ID of the filter to - update :arg body: The filter update :arg filter_id: The ID of - the filter to update :arg body: The filter update :arg filter_id: The ID of the filter to update :arg body: The filter update @@ -1100,9 +970,6 @@ class MlClient(NamespacedClient): @query_params() def validate(self, body, params=None): """ - :arg body: The job config :arg body: The job config :arg - body: The job config :arg body: The job config :arg body: The - job config :arg body: The job config """ @@ -1116,8 +983,6 @@ class MlClient(NamespacedClient): @query_params() def validate_detector(self, body, params=None): """ - :arg body: The detector :arg body: The detector :arg body: - The detector :arg body: The detector :arg body: The detector :arg body: The detector """ diff --git a/elasticsearch/client/rollup.py b/elasticsearch/client/rollup.py index 612d0f96..ecb89ab3 100644 --- a/elasticsearch/client/rollup.py +++ b/elasticsearch/client/rollup.py @@ -5,9 +5,6 @@ class RollupClient(NamespacedClient): @query_params() def delete_job(self, id, params=None): """ - :arg id: The ID of the job to delete :arg id: The ID of the job to - delete :arg id: The ID of the job to delete :arg id: The ID - of the job to delete :arg id: The ID of the job to delete :arg id: The ID of the job to delete """ @@ -21,14 +18,6 @@ class RollupClient(NamespacedClient): @query_params() def get_jobs(self, id=None, params=None): """ - :arg id: The ID of the job(s) to fetch. Accepts glob patterns, or - left blank for all jobs :arg id: The ID of the job(s) to fetch. - Accepts glob patterns, or left blank for all jobs :arg id: - The ID of the job(s) to fetch. Accepts glob patterns, or left blank - for all jobs :arg id: The ID of the job(s) to fetch. Accepts glob - patterns, or left blank for all jobs :arg id: The ID of - the job(s) to fetch. Accepts glob patterns, or left blank for all - jobs :arg id: The ID of the job(s) to fetch. Accepts glob patterns, or left blank for all jobs @@ -40,13 +29,6 @@ class RollupClient(NamespacedClient): @query_params() def get_rollup_caps(self, id=None, params=None): """ - :arg id: The ID of the index to check rollup capabilities on, or left - blank for all jobs :arg id: The ID of the index to check rollup - capabilities on, or left blank for all jobs :arg id: The - ID of the index to check rollup capabilities on, or left blank for - all jobs :arg id: The ID of the index to check rollup capabilities on, - or left blank for all jobs :arg id: The ID of the index to - check rollup capabilities on, or left blank for all jobs :arg id: The ID of the index to check rollup capabilities on, or left blank for all jobs @@ -58,13 +40,6 @@ class RollupClient(NamespacedClient): @query_params() def get_rollup_index_caps(self, index, params=None): """ - :arg index: The rollup index or index pattern to obtain rollup - capabilities from. :arg index: The rollup index or index pattern to - obtain rollup capabilities from. :arg index: The rollup - index or index pattern to obtain rollup capabilities from. - :arg index: The rollup index or index pattern to obtain rollup - capabilities from. :arg index: The rollup index or index pattern to - obtain rollup capabilities from. :arg index: The rollup index or index pattern to obtain rollup capabilities from. @@ -79,11 +54,6 @@ class RollupClient(NamespacedClient): @query_params() def put_job(self, id, body, params=None): """ - :arg id: The ID of the job to create :arg body: The job configuration - :arg id: The ID of the job to create :arg body: The job configuration - :arg id: The ID of the job to create :arg body: The job configuration - :arg id: The ID of the job to create :arg body: The job configuration - :arg id: The ID of the job to create :arg body: The job configuration :arg id: The ID of the job to create :arg body: The job configuration @@ -99,40 +69,6 @@ class RollupClient(NamespacedClient): @query_params("rest_total_hits_as_int", "typed_keys") def rollup_search(self, index, body, doc_type=None, params=None): """ - :arg index: The indices or index-pattern(s) (containing rollup or - regular data) that should be searched :arg body: The search request - body :arg doc_type: The doc type inside the index :arg - rest_total_hits_as_int: Indicates whether hits.total should be - rendered as an integer or an object in the rest search response :arg - typed_keys: Specify whether aggregation and suggester names should - be prefixed by their respective types in the response :arg index: The - indices or index-pattern(s) (containing rollup or regular data) - that should be searched :arg body: The search request body :arg - doc_type: The doc type inside the index :arg rest_total_hits_as_int: - Indicates whether hits.total should be rendered as an integer or an - object in the rest search response :arg typed_keys: Specify whether - aggregation and suggester names should be prefixed by their - respective types in the response :arg index: The indices or index- - pattern(s) (containing rollup or regular data) that should be - searched :arg body: The search request body :arg doc_type: The - doc type inside the index :arg rest_total_hits_as_int: Indicates - whether hits.total should be rendered as an integer or an object in - the rest search response :arg typed_keys: Specify whether aggregation - and suggester names should be prefixed by their respective types in - the response :arg index: The indices or index-pattern(s) (containing - rollup or regular data) that should be searched :arg body: - The search request body :arg doc_type: The doc type inside the index - :arg rest_total_hits_as_int: Indicates whether hits.total should be - rendered as an integer or an object in the rest search response :arg - typed_keys: Specify whether aggregation and suggester names should - be prefixed by their respective types in the response :arg index: The - indices or index-pattern(s) (containing rollup or regular data) - that should be searched :arg body: The search request body :arg - doc_type: The doc type inside the index :arg rest_total_hits_as_int: - Indicates whether hits.total should be rendered as an integer or an - object in the rest search response :arg typed_keys: Specify whether - aggregation and suggester names should be prefixed by their - respective types in the response :arg index: The indices or index-pattern(s) (containing rollup or regular data) that should be searched @@ -157,9 +93,6 @@ class RollupClient(NamespacedClient): @query_params() def start_job(self, id, params=None): """ - :arg id: The ID of the job to start :arg id: The ID of the job to - start :arg id: The ID of the job to start :arg id: The ID of - the job to start :arg id: The ID of the job to start :arg id: The ID of the job to start """ @@ -173,29 +106,6 @@ class RollupClient(NamespacedClient): @query_params("timeout", "wait_for_completion") def stop_job(self, id, params=None): """ - :arg id: The ID of the job to stop :arg timeout: Block for (at maximum) - the specified duration while waiting for the job to stop. Defaults - to 30s. :arg wait_for_completion: True if the API should block until - the job has fully stopped, false if should be executed async. - Defaults to false. :arg id: The ID of the job to stop - :arg timeout: Block for (at maximum) the specified duration while - waiting for the job to stop. Defaults to 30s. :arg - wait_for_completion: True if the API should block until the job has - fully stopped, false if should be executed async. Defaults to false. - :arg id: The ID of the job to stop :arg timeout: Block for (at maximum) - the specified duration while waiting for the job to stop. Defaults - to 30s. :arg wait_for_completion: True if the API should block until - the job has fully stopped, false if should be executed async. - Defaults to false. :arg id: The ID of the job to stop - :arg timeout: Block for (at maximum) the specified duration while - waiting for the job to stop. Defaults to 30s. :arg - wait_for_completion: True if the API should block until the job has - fully stopped, false if should be executed async. Defaults to false. - :arg id: The ID of the job to stop :arg timeout: Block for (at maximum) - the specified duration while waiting for the job to stop. Defaults - to 30s. :arg wait_for_completion: True if the API should block until - the job has fully stopped, false if should be executed async. - Defaults to false. :arg id: The ID of the job to stop :arg timeout: Block for (at maximum) the specified duration diff --git a/elasticsearch/client/watcher.py b/elasticsearch/client/watcher.py index 71ba772c..19ddd41a 100644 --- a/elasticsearch/client/watcher.py +++ b/elasticsearch/client/watcher.py @@ -124,7 +124,7 @@ class WatcherClient(NamespacedClient): """ return self.transport.perform_request("POST", "/_watcher/_start", params=params) - @query_params("emit_stacktraces", "metric") + @query_params("emit_stacktraces") def stats(self, metric=None, params=None): """ ``_ diff --git a/elasticsearch/client/xpack.py b/elasticsearch/client/xpack.py index 78d0249f..489fc7b0 100644 --- a/elasticsearch/client/xpack.py +++ b/elasticsearch/client/xpack.py @@ -9,8 +9,6 @@ class XPackClient(NamespacedClient): @query_params("categories") def info(self, params=None): """ - Retrieve information about xpack, including build number/timestamp and license - status ``_ :arg categories: Comma-separated list of info categories. Can be @@ -21,8 +19,6 @@ class XPackClient(NamespacedClient): @query_params("master_timeout") def usage(self, params=None): """ - Retrieve information about xpack features usage :arg master_timeout: - Specify timeout for watch write operation ``_ :arg master_timeout: Specify timeout for watch write operation diff --git a/generate_api.py b/generate_api.py index 2c7aa9bc..1c893476 100644 --- a/generate_api.py +++ b/generate_api.py @@ -93,6 +93,12 @@ BASE_TEMPLATES = { } OVERRIDE_TEMPLATES = { + "cluster.stats": """ + {% extends "base" %} + {% block request %} + return self.transport.perform_request("{{ api.method }}", "/_cluster/stats" if node_id in SKIP_IN_PATH else _make_path("_cluster", "stats", "nodes", node_id), params=params) + {% endblock%} + """, "__init__.ping": """ {% extends "base" %} {% block request %} @@ -138,13 +144,23 @@ OVERRIDE_TEMPLATES = { return self.transport.perform_request("{{ api.method }}", "/_search/scroll", params=params, body=body) {% endblock %} """, + "indices.put_mapping": """ + {% extends "base" %} + {% block request %} + if doc_type not in SKIP_IN_PATH and index in SKIP_IN_PATH: + index = "_all" + + {{ super()|trim }} + {% endblock %} + """ + } -for op in ("get", "delete", "exists"): +for op in ("get", "delete", "exists", "update", "create", "explain", "get_source", "termvectors"): OVERRIDE_TEMPLATES[f"__init__.{op}"] = """ {% extends "base" %} {% block request %} - if doc_type is None: + if doc_type in SKIP_IN_PATH: doc_type = "_doc" {{ super()|trim }} @@ -172,11 +188,8 @@ class Module: def add(self, api): self._apis.append(api) - if api.name in self.descriptions and not api.description: - api.description = self.descriptions[api.name] def parse_orig(self): - self.descriptions = {} self.orders = [] self.header = "class C:" fname = CODE_ROOT / "elasticsearch" / "client" / f"{self.namespace}.py" @@ -201,9 +214,6 @@ class Module: content, re.MULTILINE, ) - self.descriptions = dict( - map(lambda i: (i[0], i[1].strip()), defined_apis) - ) self.orders = list(map(lambda x: x[0], defined_apis)) def _position(self, api): @@ -289,7 +299,7 @@ class API: @property def query_params(self): - return sorted(self._def.get("params", {}).keys()) + return (k for k in sorted(self._def.get("params", {}).keys()) if k not in self._all_parts()) @property def path(self):