From 1773bd17becfd085ac79395dde3303e459c77b0b Mon Sep 17 00:00:00 2001 From: Seth Michael Larson Date: Thu, 21 May 2020 14:57:59 -0500 Subject: [PATCH] [7.x] Backport overrides for typeless APIs --- elasticsearch/_async/client/__init__.py | 200 +++++++++--------- elasticsearch/client/__init__.py | 200 +++++++++--------- .../test_client/test_overrides.py | 141 ++++++++++++ utils/templates/overrides/__init__/create | 10 +- utils/templates/overrides/__init__/delete | 8 +- utils/templates/overrides/__init__/exists | 8 +- utils/templates/overrides/__init__/explain | 10 +- utils/templates/overrides/__init__/get | 8 +- utils/templates/overrides/__init__/get_source | 10 +- .../templates/overrides/__init__/mtermvectors | 9 + .../overrides/__init__/single_doc_op | 8 - .../templates/overrides/__init__/termvectors | 10 +- utils/templates/overrides/__init__/update | 10 +- 13 files changed, 408 insertions(+), 224 deletions(-) create mode 100644 test_elasticsearch/test_client/test_overrides.py mode change 120000 => 100644 utils/templates/overrides/__init__/create mode change 120000 => 100644 utils/templates/overrides/__init__/delete mode change 120000 => 100644 utils/templates/overrides/__init__/exists mode change 120000 => 100644 utils/templates/overrides/__init__/explain mode change 120000 => 100644 utils/templates/overrides/__init__/get mode change 120000 => 100644 utils/templates/overrides/__init__/get_source create mode 100644 utils/templates/overrides/__init__/mtermvectors delete mode 100644 utils/templates/overrides/__init__/single_doc_op mode change 120000 => 100644 utils/templates/overrides/__init__/termvectors mode change 120000 => 100644 utils/templates/overrides/__init__/update diff --git a/elasticsearch/_async/client/__init__.py b/elasticsearch/_async/client/__init__.py index 76c9d6f8..443574d6 100644 --- a/elasticsearch/_async/client/__init__.py +++ b/elasticsearch/_async/client/__init__.py @@ -292,11 +292,11 @@ class AsyncElasticsearch(object): :arg refresh: If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then - do nothing with refreshes. Valid choices: true, false, wait_for + do nothing with refreshes. Valid choices: true, false, wait_for :arg routing: Specific routing value :arg timeout: Explicit operation timeout :arg version: Explicit version number for concurrency control - :arg version_type: Specific version type Valid choices: + :arg version_type: Specific version type Valid choices: internal, external, external_gte :arg wait_for_active_shards: Sets the number of shard copies that must be active before proceeding with the index operation. Defaults @@ -309,14 +309,12 @@ class AsyncElasticsearch(object): raise ValueError("Empty value passed for a required argument.") if doc_type in SKIP_IN_PATH: - doc_type = "_doc" + path = _make_path(index, "_create", id) + else: + path = _make_path(index, doc_type, id, "_create") return await self.transport.perform_request( - "PUT", - _make_path(index, doc_type, id, "_create"), - params=params, - headers=headers, - body=body, + "PUT", path, params=params, headers=headers, body=body ) @query_params( @@ -350,17 +348,17 @@ class AsyncElasticsearch(object): number :arg op_type: Explicit operation type. Defaults to `index` for requests with an explicit document ID, and to `create`for requests - without an explicit document ID Valid choices: index, create + without an explicit document ID Valid choices: index, create :arg pipeline: The pipeline id to preprocess incoming documents with :arg refresh: If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then - do nothing with refreshes. Valid choices: true, false, wait_for + do nothing with refreshes. Valid choices: true, false, wait_for :arg routing: Specific routing value :arg timeout: Explicit operation timeout :arg version: Explicit version number for concurrency control - :arg version_type: Specific version type Valid choices: + :arg version_type: Specific version type Valid choices: internal, external, external_gte :arg wait_for_active_shards: Sets the number of shard copies that must be active before proceeding with the index operation. Defaults @@ -415,7 +413,7 @@ class AsyncElasticsearch(object): :arg refresh: If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then - do nothing with refreshes. Valid choices: true, false, wait_for + do nothing with refreshes. Valid choices: true, false, wait_for :arg routing: Specific routing value :arg timeout: Explicit operation timeout :arg wait_for_active_shards: Sets the number of shard copies @@ -493,12 +491,12 @@ class AsyncElasticsearch(object): queries should be analyzed (default: false) :arg analyzer: The analyzer to use for the query string :arg default_operator: The default operator for query string - query (AND or OR) Valid choices: AND, OR Default: OR + query (AND or OR) Valid choices: AND, OR Default: OR :arg df: The field to use as default where no field prefix is given in the query string :arg expand_wildcards: Whether to expand wildcard expression to - concrete indices that are open, closed or both. Valid choices: open, - closed, hidden, none, all Default: open + concrete indices that are open, closed or both. Valid choices: open, + closed, hidden, none, all Default: open :arg ignore_throttled: Whether specified concrete, expanded or aliased indices should be ignored when throttled :arg ignore_unavailable: Whether specified concrete indices @@ -549,11 +547,11 @@ class AsyncElasticsearch(object): :arg refresh: If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then - do nothing with refreshes. Valid choices: true, false, wait_for + do nothing with refreshes. Valid choices: true, false, wait_for :arg routing: Specific routing value :arg timeout: Explicit operation timeout :arg version: Explicit version number for concurrency control - :arg version_type: Specific version type Valid choices: + :arg version_type: Specific version type Valid choices: internal, external, external_gte, force :arg wait_for_active_shards: Sets the number of shard copies that must be active before proceeding with the delete operation. @@ -632,14 +630,14 @@ class AsyncElasticsearch(object): queries should be analyzed (default: false) :arg analyzer: The analyzer to use for the query string :arg conflicts: What to do when the delete by query hits version - conflicts? Valid choices: abort, proceed Default: abort + conflicts? Valid choices: abort, proceed Default: abort :arg default_operator: The default operator for query string - query (AND or OR) Valid choices: AND, OR Default: OR + query (AND or OR) Valid choices: AND, OR Default: OR :arg df: The field to use as default where no field prefix is given in the query string :arg expand_wildcards: Whether to expand wildcard expression to - concrete indices that are open, closed or both. Valid choices: open, - closed, hidden, none, all Default: open + concrete indices that are open, closed or both. Valid choices: open, + closed, hidden, none, all Default: open :arg from_: Starting offset (default: 0) :arg ignore_unavailable: Whether specified concrete indices should be ignored when unavailable (missing or closed) @@ -659,15 +657,15 @@ class AsyncElasticsearch(object): :arg scroll: Specify how long a consistent view of the index should be maintained for scrolled search :arg scroll_size: Size on the scroll request powering the delete - by query Default: 100 + by query Default: 100 :arg search_timeout: Explicit timeout for each search request. Defaults to no timeout. - :arg search_type: Search operation type Valid choices: + :arg search_type: Search operation type Valid choices: query_then_fetch, dfs_query_then_fetch :arg size: Deprecated, please use `max_docs` instead :arg slices: The number of slices this task should be divided into. Defaults to 1, meaning the task isn't sliced into subtasks. Can be - set to `auto`. Default: 1 + set to `auto`. Default: 1 :arg sort: A comma-separated list of : pairs :arg stats: Specific 'tag' of the request for logging and statistical purposes @@ -675,7 +673,7 @@ class AsyncElasticsearch(object): for each shard, upon reaching which the query execution will terminate early. :arg timeout: Time each individual bulk request should wait for - shards that are unavailable. Default: 1m + shards that are unavailable. Default: 1m :arg version: Specify whether to return document version as part of a hit :arg wait_for_active_shards: Sets the number of shard copies @@ -685,7 +683,7 @@ class AsyncElasticsearch(object): or equal to the total number of copies for the shard (number of replicas + 1) :arg wait_for_completion: Should the request should block until - the delete by query is complete. Default: True + the delete by query is complete. Default: True """ # from is a reserved word so it cannot be used, use from_ instead if "from_" in params: @@ -778,7 +776,7 @@ class AsyncElasticsearch(object): :arg stored_fields: A comma-separated list of stored fields to return in the response :arg version: Explicit version number for concurrency control - :arg version_type: Specific version type Valid choices: + :arg version_type: Specific version type Valid choices: internal, external, external_gte, force """ for param in (index, id): @@ -826,7 +824,7 @@ class AsyncElasticsearch(object): performing the operation :arg routing: Specific routing value :arg version: Explicit version number for concurrency control - :arg version_type: Specific version type Valid choices: + :arg version_type: Specific version type Valid choices: internal, external, external_gte, force """ for param in (index, id): @@ -875,7 +873,7 @@ class AsyncElasticsearch(object): queries in the query string query should be analyzed (default: false) :arg analyzer: The analyzer for the query string query :arg default_operator: The default operator for query string - query (AND or OR) Valid choices: AND, OR Default: OR + query (AND or OR) Valid choices: AND, OR Default: OR :arg df: The default field for query string query (default: _all) :arg lenient: Specify whether format-based query failures (such @@ -892,14 +890,12 @@ class AsyncElasticsearch(object): raise ValueError("Empty value passed for a required argument.") if doc_type in SKIP_IN_PATH: - doc_type = "_doc" + path = _make_path(index, "_explain", id) + else: + path = _make_path(index, doc_type, id, "_explain") return await self.transport.perform_request( - "POST", - _make_path(index, doc_type, id, "_explain"), - params=params, - headers=headers, - body=body, + "POST", path, params=params, headers=headers, body=body ) @query_params( @@ -921,8 +917,8 @@ class AsyncElasticsearch(object): expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) :arg expand_wildcards: Whether to expand wildcard expression to - concrete indices that are open, closed or both. Valid choices: open, - closed, hidden, none, all Default: open + concrete indices that are open, closed or both. Valid choices: open, + closed, hidden, none, all Default: open :arg fields: A comma-separated list of field names :arg ignore_unavailable: Whether specified concrete indices should be ignored when unavailable (missing or closed) @@ -970,7 +966,7 @@ class AsyncElasticsearch(object): :arg stored_fields: A comma-separated list of stored fields to return in the response :arg version: Explicit version number for concurrency control - :arg version_type: Specific version type Valid choices: + :arg version_type: Specific version type Valid choices: internal, external, external_gte, force """ for param in (index, id): @@ -1034,7 +1030,7 @@ class AsyncElasticsearch(object): performing the operation :arg routing: Specific routing value :arg version: Explicit version number for concurrency control - :arg version_type: Specific version type Valid choices: + :arg version_type: Specific version type Valid choices: internal, external, external_gte, force """ for param in (index, id): @@ -1042,13 +1038,12 @@ class AsyncElasticsearch(object): raise ValueError("Empty value passed for a required argument.") if doc_type in SKIP_IN_PATH: - doc_type = "_doc" + path = _make_path(index, "_source", id) + else: + path = _make_path(index, doc_type, id, "_source") return await self.transport.perform_request( - "GET", - _make_path(index, doc_type, id, "_source"), - params=params, - headers=headers, + "GET", path, params=params, headers=headers ) @query_params( @@ -1120,13 +1115,13 @@ class AsyncElasticsearch(object): as default :arg ccs_minimize_roundtrips: Indicates whether network round- trips should be minimized as part of cross-cluster search requests - execution Default: true + execution Default: true :arg max_concurrent_searches: Controls the maximum number of concurrent searches the multi search api will execute :arg max_concurrent_shard_requests: The number of concurrent shard requests each sub search executes concurrently per node. This value should be used to limit the impact of the search on the cluster in - order to limit the number of concurrent shard requests Default: 5 + order to limit the number of concurrent shard requests Default: 5 :arg pre_filter_shard_size: A threshold that enforces a pre- filter roundtrip to prefilter search shards based on query rewriting if the number of shards the search request expands to exceeds the @@ -1136,7 +1131,7 @@ class AsyncElasticsearch(object): shard bounds and the query are disjoint. :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 search_type: Search operation type Valid choices: + :arg search_type: Search operation type Valid choices: query_then_fetch, query_and_fetch, dfs_query_then_fetch, dfs_query_and_fetch :arg typed_keys: Specify whether aggregation and suggester names @@ -1176,12 +1171,12 @@ class AsyncElasticsearch(object): as default :arg ccs_minimize_roundtrips: Indicates whether network round- trips should be minimized as part of cross-cluster search requests - execution Default: true + execution Default: true :arg max_concurrent_searches: Controls the maximum number of concurrent searches the multi search api will execute :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 search_type: Search operation type Valid choices: + :arg search_type: Search operation type Valid choices: query_then_fetch, query_and_fetch, dfs_query_then_fetch, dfs_query_and_fetch :arg typed_keys: Specify whether aggregation and suggester names @@ -1228,7 +1223,7 @@ class AsyncElasticsearch(object): :arg field_statistics: Specifies if document count, sum of document frequencies and sum of total term frequencies should be returned. Applies to all returned documents unless otherwise specified - in body "params" or "docs". Default: True + in body "params" or "docs". Default: True :arg fields: A comma-separated list of fields to return. Applies to all returned documents unless otherwise specified in body "params" or "docs". @@ -1236,13 +1231,13 @@ class AsyncElasticsearch(object): define ids as parameter or set "ids" or "docs" in the request body :arg offsets: Specifies if term offsets should be returned. Applies to all returned documents unless otherwise specified in body - "params" or "docs". Default: True + "params" or "docs". Default: True :arg payloads: Specifies if term payloads should be returned. Applies to all returned documents unless otherwise specified in body - "params" or "docs". Default: True + "params" or "docs". Default: True :arg positions: Specifies if term positions should be returned. Applies to all returned documents unless otherwise specified in body - "params" or "docs". Default: True + "params" or "docs". Default: True :arg preference: Specify the node or shard the operation should be performed on (default: random) .Applies to all returned documents unless otherwise specified in body "params" or "docs". @@ -1254,15 +1249,16 @@ class AsyncElasticsearch(object): document frequency should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs". :arg version: Explicit version number for concurrency control - :arg version_type: Specific version type Valid choices: + :arg version_type: Specific version type Valid choices: internal, external, external_gte, force """ + if doc_type in SKIP_IN_PATH: + path = _make_path(index, "_mtermvectors") + else: + path = _make_path(index, doc_type, "_mtermvectors") + return await self.transport.perform_request( - "POST", - _make_path(index, doc_type, "_mtermvectors"), - params=params, - headers=headers, - body=body, + "POST", path, params=params, headers=headers, body=body ) @query_params("master_timeout", "timeout") @@ -1306,11 +1302,11 @@ class AsyncElasticsearch(object): expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) :arg expand_wildcards: Whether to expand wildcard expression to - concrete indices that are open, closed or both. Valid choices: open, - closed, hidden, none, all Default: open + concrete indices that are open, closed or both. Valid choices: open, + closed, hidden, none, all Default: open :arg ignore_unavailable: Whether specified concrete indices should be ignored when unavailable (missing or closed) - :arg search_type: Search operation type Valid choices: + :arg search_type: Search operation type Valid choices: query_then_fetch, dfs_query_then_fetch """ if body in SKIP_IN_PATH: @@ -1352,16 +1348,16 @@ class AsyncElasticsearch(object): Default: 5m :arg slices: The number of slices this task should be divided into. Defaults to 1, meaning the task isn't sliced into subtasks. Can be - set to `auto`. Default: 1 + set to `auto`. Default: 1 :arg timeout: Time each individual bulk request should wait for - shards that are unavailable. Default: 1m + shards that are unavailable. Default: 1m :arg wait_for_active_shards: Sets the number of shard copies that must be active before proceeding with the reindex operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) :arg wait_for_completion: Should the request should block until - the reindex is complete. Default: True + the reindex is complete. Default: True """ if body in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'body'.") @@ -1516,7 +1512,7 @@ class AsyncElasticsearch(object): expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) :arg allow_partial_search_results: Indicate if an error should - be returned if there is a partial search failure or timeout Default: + be returned if there is a partial search failure or timeout Default: True :arg analyze_wildcard: Specify whether wildcard and prefix queries should be analyzed (default: false) @@ -1528,16 +1524,16 @@ class AsyncElasticsearch(object): Default: 512 :arg ccs_minimize_roundtrips: Indicates whether network round- trips should be minimized as part of cross-cluster search requests - execution Default: true + execution Default: true :arg default_operator: The default operator for query string - query (AND or OR) Valid choices: AND, OR Default: OR + query (AND or OR) Valid choices: AND, OR Default: OR :arg df: The field to use as default where no field prefix is given in the query string :arg docvalue_fields: A comma-separated list of fields to return as the docvalue representation of a field for each hit :arg expand_wildcards: Whether to expand wildcard expression to - concrete indices that are open, closed or both. Valid choices: open, - closed, hidden, none, all Default: open + concrete indices that are open, closed or both. Valid choices: open, + closed, hidden, none, all Default: open :arg explain: Specify whether to return detailed information about score computation as part of a hit :arg from_: Starting offset (default: 0) @@ -1550,7 +1546,7 @@ class AsyncElasticsearch(object): :arg max_concurrent_shard_requests: The number of concurrent shard requests per node this search executes concurrently. This value should be used to limit the impact of the search on the cluster in order - to limit the number of concurrent shard requests Default: 5 + to limit the number of concurrent shard requests Default: 5 :arg pre_filter_shard_size: A threshold that enforces a pre- filter roundtrip to prefilter search shards based on query rewriting if the number of shards the search request expands to exceeds the @@ -1568,7 +1564,7 @@ class AsyncElasticsearch(object): :arg routing: A 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_type: Search operation type Valid choices: + :arg search_type: Search operation type Valid choices: query_then_fetch, dfs_query_then_fetch :arg seq_no_primary_term: Specify whether to return sequence number and primary term of the last modification of each hit @@ -1579,8 +1575,8 @@ class AsyncElasticsearch(object): :arg stored_fields: A comma-separated list of stored fields to return as part of a hit :arg suggest_field: Specify which field to use for suggestions - :arg suggest_mode: Specify suggest mode Valid choices: missing, - popular, always Default: missing + :arg suggest_mode: Specify suggest mode Valid choices: + missing, popular, always Default: missing :arg suggest_size: How many suggestions to return in response :arg suggest_text: The source text for which the suggestions should be returned @@ -1629,8 +1625,8 @@ class AsyncElasticsearch(object): expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) :arg expand_wildcards: Whether to expand wildcard expression to - concrete indices that are open, closed or both. Valid choices: open, - closed, hidden, none, all Default: open + concrete indices that are open, closed or both. Valid choices: open, + closed, hidden, none, all Default: open :arg ignore_unavailable: Whether specified concrete indices should be ignored when unavailable (missing or closed) :arg local: Return local information, do not retrieve the state @@ -1675,10 +1671,10 @@ class AsyncElasticsearch(object): string or when no indices have been specified) :arg ccs_minimize_roundtrips: Indicates whether network round- trips should be minimized as part of cross-cluster search requests - execution Default: true + execution Default: true :arg expand_wildcards: Whether to expand wildcard expression to - concrete indices that are open, closed or both. Valid choices: open, - closed, hidden, none, all Default: open + concrete indices that are open, closed or both. Valid choices: open, + closed, hidden, none, all Default: open :arg explain: Specify whether to return detailed information about score computation as part of a hit :arg ignore_throttled: Whether specified concrete, expanded or @@ -1693,7 +1689,7 @@ class AsyncElasticsearch(object): :arg routing: A 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_type: Search operation type Valid choices: + :arg search_type: Search operation type Valid choices: query_then_fetch, query_and_fetch, dfs_query_then_fetch, dfs_query_and_fetch :arg typed_keys: Specify whether aggregation and suggester names @@ -1739,7 +1735,7 @@ class AsyncElasticsearch(object): should be supplied. :arg field_statistics: Specifies if document count, sum of document frequencies and sum of total term frequencies should be - returned. Default: True + returned. Default: True :arg fields: A comma-separated list of fields to return. :arg offsets: Specifies if term offsets should be returned. Default: True @@ -1755,21 +1751,19 @@ class AsyncElasticsearch(object): :arg term_statistics: Specifies if total term frequency and document frequency should be returned. :arg version: Explicit version number for concurrency control - :arg version_type: Specific version type Valid choices: + :arg version_type: Specific version type Valid choices: internal, external, external_gte, force """ 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" + path = _make_path(index, "_termvectors", id) + else: + path = _make_path(index, doc_type, id, "_termvectors") return await self.transport.perform_request( - "POST", - _make_path(index, doc_type, id, "_termvectors"), - params=params, - headers=headers, - body=body, + "POST", path, params=params, headers=headers, body=body ) @query_params( @@ -1811,7 +1805,7 @@ class AsyncElasticsearch(object): :arg refresh: If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then - do nothing with refreshes. Valid choices: true, false, wait_for + do nothing with refreshes. Valid choices: true, false, wait_for :arg retry_on_conflict: Specify how many times should the operation be retried when a conflict occurs (default: 0) :arg routing: Specific routing value @@ -1827,14 +1821,12 @@ class AsyncElasticsearch(object): raise ValueError("Empty value passed for a required argument.") if doc_type in SKIP_IN_PATH: - doc_type = "_doc" + path = _make_path(index, "_update", id) + else: + path = _make_path(index, doc_type, id, "_update") return await self.transport.perform_request( - "POST", - _make_path(index, doc_type, id, "_update"), - params=params, - headers=headers, - body=body, + "POST", path, params=params, headers=headers, body=body ) @query_params( @@ -1900,14 +1892,14 @@ class AsyncElasticsearch(object): queries should be analyzed (default: false) :arg analyzer: The analyzer to use for the query string :arg conflicts: What to do when the update by query hits version - conflicts? Valid choices: abort, proceed Default: abort + conflicts? Valid choices: abort, proceed Default: abort :arg default_operator: The default operator for query string - query (AND or OR) Valid choices: AND, OR Default: OR + query (AND or OR) Valid choices: AND, OR Default: OR :arg df: The field to use as default where no field prefix is given in the query string :arg expand_wildcards: Whether to expand wildcard expression to - concrete indices that are open, closed or both. Valid choices: open, - closed, hidden, none, all Default: open + concrete indices that are open, closed or both. Valid choices: open, + closed, hidden, none, all Default: open :arg from_: Starting offset (default: 0) :arg ignore_unavailable: Whether specified concrete indices should be ignored when unavailable (missing or closed) @@ -1929,15 +1921,15 @@ class AsyncElasticsearch(object): :arg scroll: Specify how long a consistent view of the index should be maintained for scrolled search :arg scroll_size: Size on the scroll request powering the update - by query Default: 100 + by query Default: 100 :arg search_timeout: Explicit timeout for each search request. Defaults to no timeout. - :arg search_type: Search operation type Valid choices: + :arg search_type: Search operation type Valid choices: query_then_fetch, dfs_query_then_fetch :arg size: Deprecated, please use `max_docs` instead :arg slices: The number of slices this task should be divided into. Defaults to 1, meaning the task isn't sliced into subtasks. Can be - set to `auto`. Default: 1 + set to `auto`. Default: 1 :arg sort: A comma-separated list of : pairs :arg stats: Specific 'tag' of the request for logging and statistical purposes @@ -1945,7 +1937,7 @@ class AsyncElasticsearch(object): for each shard, upon reaching which the query execution will terminate early. :arg timeout: Time each individual bulk request should wait for - shards that are unavailable. Default: 1m + shards that are unavailable. Default: 1m :arg version: Specify whether to return document version as part of a hit :arg version_type: Should the document increment the version @@ -1957,7 +1949,7 @@ class AsyncElasticsearch(object): or equal to the total number of copies for the shard (number of replicas + 1) :arg wait_for_completion: Should the request should block until - the update by query operation is complete. Default: True + the update by query operation is complete. Default: True """ # from is a reserved word so it cannot be used, use from_ instead if "from_" in params: diff --git a/elasticsearch/client/__init__.py b/elasticsearch/client/__init__.py index d6b18800..a93d4ab1 100644 --- a/elasticsearch/client/__init__.py +++ b/elasticsearch/client/__init__.py @@ -292,11 +292,11 @@ class Elasticsearch(object): :arg refresh: If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then - do nothing with refreshes. Valid choices: true, false, wait_for + do nothing with refreshes. Valid choices: true, false, wait_for :arg routing: Specific routing value :arg timeout: Explicit operation timeout :arg version: Explicit version number for concurrency control - :arg version_type: Specific version type Valid choices: + :arg version_type: Specific version type Valid choices: internal, external, external_gte :arg wait_for_active_shards: Sets the number of shard copies that must be active before proceeding with the index operation. Defaults @@ -309,14 +309,12 @@ class Elasticsearch(object): raise ValueError("Empty value passed for a required argument.") if doc_type in SKIP_IN_PATH: - doc_type = "_doc" + path = _make_path(index, "_create", id) + else: + path = _make_path(index, doc_type, id, "_create") return self.transport.perform_request( - "PUT", - _make_path(index, doc_type, id, "_create"), - params=params, - headers=headers, - body=body, + "PUT", path, params=params, headers=headers, body=body ) @query_params( @@ -348,17 +346,17 @@ class Elasticsearch(object): number :arg op_type: Explicit operation type. Defaults to `index` for requests with an explicit document ID, and to `create`for requests - without an explicit document ID Valid choices: index, create + without an explicit document ID Valid choices: index, create :arg pipeline: The pipeline id to preprocess incoming documents with :arg refresh: If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then - do nothing with refreshes. Valid choices: true, false, wait_for + do nothing with refreshes. Valid choices: true, false, wait_for :arg routing: Specific routing value :arg timeout: Explicit operation timeout :arg version: Explicit version number for concurrency control - :arg version_type: Specific version type Valid choices: + :arg version_type: Specific version type Valid choices: internal, external, external_gte :arg wait_for_active_shards: Sets the number of shard copies that must be active before proceeding with the index operation. Defaults @@ -413,7 +411,7 @@ class Elasticsearch(object): :arg refresh: If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then - do nothing with refreshes. Valid choices: true, false, wait_for + do nothing with refreshes. Valid choices: true, false, wait_for :arg routing: Specific routing value :arg timeout: Explicit operation timeout :arg wait_for_active_shards: Sets the number of shard copies @@ -489,12 +487,12 @@ class Elasticsearch(object): queries should be analyzed (default: false) :arg analyzer: The analyzer to use for the query string :arg default_operator: The default operator for query string - query (AND or OR) Valid choices: AND, OR Default: OR + query (AND or OR) Valid choices: AND, OR Default: OR :arg df: The field to use as default where no field prefix is given in the query string :arg expand_wildcards: Whether to expand wildcard expression to - concrete indices that are open, closed or both. Valid choices: open, - closed, hidden, none, all Default: open + concrete indices that are open, closed or both. Valid choices: open, + closed, hidden, none, all Default: open :arg ignore_throttled: Whether specified concrete, expanded or aliased indices should be ignored when throttled :arg ignore_unavailable: Whether specified concrete indices @@ -545,11 +543,11 @@ class Elasticsearch(object): :arg refresh: If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then - do nothing with refreshes. Valid choices: true, false, wait_for + do nothing with refreshes. Valid choices: true, false, wait_for :arg routing: Specific routing value :arg timeout: Explicit operation timeout :arg version: Explicit version number for concurrency control - :arg version_type: Specific version type Valid choices: + :arg version_type: Specific version type Valid choices: internal, external, external_gte, force :arg wait_for_active_shards: Sets the number of shard copies that must be active before proceeding with the delete operation. @@ -626,14 +624,14 @@ class Elasticsearch(object): queries should be analyzed (default: false) :arg analyzer: The analyzer to use for the query string :arg conflicts: What to do when the delete by query hits version - conflicts? Valid choices: abort, proceed Default: abort + conflicts? Valid choices: abort, proceed Default: abort :arg default_operator: The default operator for query string - query (AND or OR) Valid choices: AND, OR Default: OR + query (AND or OR) Valid choices: AND, OR Default: OR :arg df: The field to use as default where no field prefix is given in the query string :arg expand_wildcards: Whether to expand wildcard expression to - concrete indices that are open, closed or both. Valid choices: open, - closed, hidden, none, all Default: open + concrete indices that are open, closed or both. Valid choices: open, + closed, hidden, none, all Default: open :arg from_: Starting offset (default: 0) :arg ignore_unavailable: Whether specified concrete indices should be ignored when unavailable (missing or closed) @@ -653,15 +651,15 @@ class Elasticsearch(object): :arg scroll: Specify how long a consistent view of the index should be maintained for scrolled search :arg scroll_size: Size on the scroll request powering the delete - by query Default: 100 + by query Default: 100 :arg search_timeout: Explicit timeout for each search request. Defaults to no timeout. - :arg search_type: Search operation type Valid choices: + :arg search_type: Search operation type Valid choices: query_then_fetch, dfs_query_then_fetch :arg size: Deprecated, please use `max_docs` instead :arg slices: The number of slices this task should be divided into. Defaults to 1, meaning the task isn't sliced into subtasks. Can be - set to `auto`. Default: 1 + set to `auto`. Default: 1 :arg sort: A comma-separated list of : pairs :arg stats: Specific 'tag' of the request for logging and statistical purposes @@ -669,7 +667,7 @@ class Elasticsearch(object): for each shard, upon reaching which the query execution will terminate early. :arg timeout: Time each individual bulk request should wait for - shards that are unavailable. Default: 1m + shards that are unavailable. Default: 1m :arg version: Specify whether to return document version as part of a hit :arg wait_for_active_shards: Sets the number of shard copies @@ -679,7 +677,7 @@ class Elasticsearch(object): or equal to the total number of copies for the shard (number of replicas + 1) :arg wait_for_completion: Should the request should block until - the delete by query is complete. Default: True + the delete by query is complete. Default: True """ # from is a reserved word so it cannot be used, use from_ instead if "from_" in params: @@ -772,7 +770,7 @@ class Elasticsearch(object): :arg stored_fields: A comma-separated list of stored fields to return in the response :arg version: Explicit version number for concurrency control - :arg version_type: Specific version type Valid choices: + :arg version_type: Specific version type Valid choices: internal, external, external_gte, force """ for param in (index, id): @@ -820,7 +818,7 @@ class Elasticsearch(object): performing the operation :arg routing: Specific routing value :arg version: Explicit version number for concurrency control - :arg version_type: Specific version type Valid choices: + :arg version_type: Specific version type Valid choices: internal, external, external_gte, force """ for param in (index, id): @@ -867,7 +865,7 @@ class Elasticsearch(object): queries in the query string query should be analyzed (default: false) :arg analyzer: The analyzer for the query string query :arg default_operator: The default operator for query string - query (AND or OR) Valid choices: AND, OR Default: OR + query (AND or OR) Valid choices: AND, OR Default: OR :arg df: The default field for query string query (default: _all) :arg lenient: Specify whether format-based query failures (such @@ -884,14 +882,12 @@ class Elasticsearch(object): raise ValueError("Empty value passed for a required argument.") if doc_type in SKIP_IN_PATH: - doc_type = "_doc" + path = _make_path(index, "_explain", id) + else: + path = _make_path(index, doc_type, id, "_explain") return self.transport.perform_request( - "POST", - _make_path(index, doc_type, id, "_explain"), - params=params, - headers=headers, - body=body, + "POST", path, params=params, headers=headers, body=body ) @query_params( @@ -913,8 +909,8 @@ class Elasticsearch(object): expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) :arg expand_wildcards: Whether to expand wildcard expression to - concrete indices that are open, closed or both. Valid choices: open, - closed, hidden, none, all Default: open + concrete indices that are open, closed or both. Valid choices: open, + closed, hidden, none, all Default: open :arg fields: A comma-separated list of field names :arg ignore_unavailable: Whether specified concrete indices should be ignored when unavailable (missing or closed) @@ -962,7 +958,7 @@ class Elasticsearch(object): :arg stored_fields: A comma-separated list of stored fields to return in the response :arg version: Explicit version number for concurrency control - :arg version_type: Specific version type Valid choices: + :arg version_type: Specific version type Valid choices: internal, external, external_gte, force """ for param in (index, id): @@ -1026,7 +1022,7 @@ class Elasticsearch(object): performing the operation :arg routing: Specific routing value :arg version: Explicit version number for concurrency control - :arg version_type: Specific version type Valid choices: + :arg version_type: Specific version type Valid choices: internal, external, external_gte, force """ for param in (index, id): @@ -1034,13 +1030,12 @@ class Elasticsearch(object): raise ValueError("Empty value passed for a required argument.") if doc_type in SKIP_IN_PATH: - doc_type = "_doc" + path = _make_path(index, "_source", id) + else: + path = _make_path(index, doc_type, id, "_source") return self.transport.perform_request( - "GET", - _make_path(index, doc_type, id, "_source"), - params=params, - headers=headers, + "GET", path, params=params, headers=headers ) @query_params( @@ -1112,13 +1107,13 @@ class Elasticsearch(object): as default :arg ccs_minimize_roundtrips: Indicates whether network round- trips should be minimized as part of cross-cluster search requests - execution Default: true + execution Default: true :arg max_concurrent_searches: Controls the maximum number of concurrent searches the multi search api will execute :arg max_concurrent_shard_requests: The number of concurrent shard requests each sub search executes concurrently per node. This value should be used to limit the impact of the search on the cluster in - order to limit the number of concurrent shard requests Default: 5 + order to limit the number of concurrent shard requests Default: 5 :arg pre_filter_shard_size: A threshold that enforces a pre- filter roundtrip to prefilter search shards based on query rewriting if the number of shards the search request expands to exceeds the @@ -1128,7 +1123,7 @@ class Elasticsearch(object): shard bounds and the query are disjoint. :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 search_type: Search operation type Valid choices: + :arg search_type: Search operation type Valid choices: query_then_fetch, query_and_fetch, dfs_query_then_fetch, dfs_query_and_fetch :arg typed_keys: Specify whether aggregation and suggester names @@ -1168,12 +1163,12 @@ class Elasticsearch(object): as default :arg ccs_minimize_roundtrips: Indicates whether network round- trips should be minimized as part of cross-cluster search requests - execution Default: true + execution Default: true :arg max_concurrent_searches: Controls the maximum number of concurrent searches the multi search api will execute :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 search_type: Search operation type Valid choices: + :arg search_type: Search operation type Valid choices: query_then_fetch, query_and_fetch, dfs_query_then_fetch, dfs_query_and_fetch :arg typed_keys: Specify whether aggregation and suggester names @@ -1220,7 +1215,7 @@ class Elasticsearch(object): :arg field_statistics: Specifies if document count, sum of document frequencies and sum of total term frequencies should be returned. Applies to all returned documents unless otherwise specified - in body "params" or "docs". Default: True + in body "params" or "docs". Default: True :arg fields: A comma-separated list of fields to return. Applies to all returned documents unless otherwise specified in body "params" or "docs". @@ -1228,13 +1223,13 @@ class Elasticsearch(object): define ids as parameter or set "ids" or "docs" in the request body :arg offsets: Specifies if term offsets should be returned. Applies to all returned documents unless otherwise specified in body - "params" or "docs". Default: True + "params" or "docs". Default: True :arg payloads: Specifies if term payloads should be returned. Applies to all returned documents unless otherwise specified in body - "params" or "docs". Default: True + "params" or "docs". Default: True :arg positions: Specifies if term positions should be returned. Applies to all returned documents unless otherwise specified in body - "params" or "docs". Default: True + "params" or "docs". Default: True :arg preference: Specify the node or shard the operation should be performed on (default: random) .Applies to all returned documents unless otherwise specified in body "params" or "docs". @@ -1246,15 +1241,16 @@ class Elasticsearch(object): document frequency should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs". :arg version: Explicit version number for concurrency control - :arg version_type: Specific version type Valid choices: + :arg version_type: Specific version type Valid choices: internal, external, external_gte, force """ + if doc_type in SKIP_IN_PATH: + path = _make_path(index, "_mtermvectors") + else: + path = _make_path(index, doc_type, "_mtermvectors") + return self.transport.perform_request( - "POST", - _make_path(index, doc_type, "_mtermvectors"), - params=params, - headers=headers, - body=body, + "POST", path, params=params, headers=headers, body=body ) @query_params("master_timeout", "timeout") @@ -1298,11 +1294,11 @@ class Elasticsearch(object): expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) :arg expand_wildcards: Whether to expand wildcard expression to - concrete indices that are open, closed or both. Valid choices: open, - closed, hidden, none, all Default: open + concrete indices that are open, closed or both. Valid choices: open, + closed, hidden, none, all Default: open :arg ignore_unavailable: Whether specified concrete indices should be ignored when unavailable (missing or closed) - :arg search_type: Search operation type Valid choices: + :arg search_type: Search operation type Valid choices: query_then_fetch, dfs_query_then_fetch """ if body in SKIP_IN_PATH: @@ -1344,16 +1340,16 @@ class Elasticsearch(object): Default: 5m :arg slices: The number of slices this task should be divided into. Defaults to 1, meaning the task isn't sliced into subtasks. Can be - set to `auto`. Default: 1 + set to `auto`. Default: 1 :arg timeout: Time each individual bulk request should wait for - shards that are unavailable. Default: 1m + shards that are unavailable. Default: 1m :arg wait_for_active_shards: Sets the number of shard copies that must be active before proceeding with the reindex operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) :arg wait_for_completion: Should the request should block until - the reindex is complete. Default: True + the reindex is complete. Default: True """ if body in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'body'.") @@ -1504,7 +1500,7 @@ class Elasticsearch(object): expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) :arg allow_partial_search_results: Indicate if an error should - be returned if there is a partial search failure or timeout Default: + be returned if there is a partial search failure or timeout Default: True :arg analyze_wildcard: Specify whether wildcard and prefix queries should be analyzed (default: false) @@ -1516,16 +1512,16 @@ class Elasticsearch(object): Default: 512 :arg ccs_minimize_roundtrips: Indicates whether network round- trips should be minimized as part of cross-cluster search requests - execution Default: true + execution Default: true :arg default_operator: The default operator for query string - query (AND or OR) Valid choices: AND, OR Default: OR + query (AND or OR) Valid choices: AND, OR Default: OR :arg df: The field to use as default where no field prefix is given in the query string :arg docvalue_fields: A comma-separated list of fields to return as the docvalue representation of a field for each hit :arg expand_wildcards: Whether to expand wildcard expression to - concrete indices that are open, closed or both. Valid choices: open, - closed, hidden, none, all Default: open + concrete indices that are open, closed or both. Valid choices: open, + closed, hidden, none, all Default: open :arg explain: Specify whether to return detailed information about score computation as part of a hit :arg from_: Starting offset (default: 0) @@ -1538,7 +1534,7 @@ class Elasticsearch(object): :arg max_concurrent_shard_requests: The number of concurrent shard requests per node this search executes concurrently. This value should be used to limit the impact of the search on the cluster in order - to limit the number of concurrent shard requests Default: 5 + to limit the number of concurrent shard requests Default: 5 :arg pre_filter_shard_size: A threshold that enforces a pre- filter roundtrip to prefilter search shards based on query rewriting if the number of shards the search request expands to exceeds the @@ -1556,7 +1552,7 @@ class Elasticsearch(object): :arg routing: A 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_type: Search operation type Valid choices: + :arg search_type: Search operation type Valid choices: query_then_fetch, dfs_query_then_fetch :arg seq_no_primary_term: Specify whether to return sequence number and primary term of the last modification of each hit @@ -1567,8 +1563,8 @@ class Elasticsearch(object): :arg stored_fields: A comma-separated list of stored fields to return as part of a hit :arg suggest_field: Specify which field to use for suggestions - :arg suggest_mode: Specify suggest mode Valid choices: missing, - popular, always Default: missing + :arg suggest_mode: Specify suggest mode Valid choices: + missing, popular, always Default: missing :arg suggest_size: How many suggestions to return in response :arg suggest_text: The source text for which the suggestions should be returned @@ -1617,8 +1613,8 @@ class Elasticsearch(object): expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) :arg expand_wildcards: Whether to expand wildcard expression to - concrete indices that are open, closed or both. Valid choices: open, - closed, hidden, none, all Default: open + concrete indices that are open, closed or both. Valid choices: open, + closed, hidden, none, all Default: open :arg ignore_unavailable: Whether specified concrete indices should be ignored when unavailable (missing or closed) :arg local: Return local information, do not retrieve the state @@ -1663,10 +1659,10 @@ class Elasticsearch(object): string or when no indices have been specified) :arg ccs_minimize_roundtrips: Indicates whether network round- trips should be minimized as part of cross-cluster search requests - execution Default: true + execution Default: true :arg expand_wildcards: Whether to expand wildcard expression to - concrete indices that are open, closed or both. Valid choices: open, - closed, hidden, none, all Default: open + concrete indices that are open, closed or both. Valid choices: open, + closed, hidden, none, all Default: open :arg explain: Specify whether to return detailed information about score computation as part of a hit :arg ignore_throttled: Whether specified concrete, expanded or @@ -1681,7 +1677,7 @@ class Elasticsearch(object): :arg routing: A 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_type: Search operation type Valid choices: + :arg search_type: Search operation type Valid choices: query_then_fetch, query_and_fetch, dfs_query_then_fetch, dfs_query_and_fetch :arg typed_keys: Specify whether aggregation and suggester names @@ -1727,7 +1723,7 @@ class Elasticsearch(object): should be supplied. :arg field_statistics: Specifies if document count, sum of document frequencies and sum of total term frequencies should be - returned. Default: True + returned. Default: True :arg fields: A comma-separated list of fields to return. :arg offsets: Specifies if term offsets should be returned. Default: True @@ -1743,21 +1739,19 @@ class Elasticsearch(object): :arg term_statistics: Specifies if total term frequency and document frequency should be returned. :arg version: Explicit version number for concurrency control - :arg version_type: Specific version type Valid choices: + :arg version_type: Specific version type Valid choices: internal, external, external_gte, force """ 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" + path = _make_path(index, "_termvectors", id) + else: + path = _make_path(index, doc_type, id, "_termvectors") return self.transport.perform_request( - "POST", - _make_path(index, doc_type, id, "_termvectors"), - params=params, - headers=headers, - body=body, + "POST", path, params=params, headers=headers, body=body ) @query_params( @@ -1799,7 +1793,7 @@ class Elasticsearch(object): :arg refresh: If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then - do nothing with refreshes. Valid choices: true, false, wait_for + do nothing with refreshes. Valid choices: true, false, wait_for :arg retry_on_conflict: Specify how many times should the operation be retried when a conflict occurs (default: 0) :arg routing: Specific routing value @@ -1815,14 +1809,12 @@ class Elasticsearch(object): raise ValueError("Empty value passed for a required argument.") if doc_type in SKIP_IN_PATH: - doc_type = "_doc" + path = _make_path(index, "_update", id) + else: + path = _make_path(index, doc_type, id, "_update") return self.transport.perform_request( - "POST", - _make_path(index, doc_type, id, "_update"), - params=params, - headers=headers, - body=body, + "POST", path, params=params, headers=headers, body=body ) @query_params( @@ -1888,14 +1880,14 @@ class Elasticsearch(object): queries should be analyzed (default: false) :arg analyzer: The analyzer to use for the query string :arg conflicts: What to do when the update by query hits version - conflicts? Valid choices: abort, proceed Default: abort + conflicts? Valid choices: abort, proceed Default: abort :arg default_operator: The default operator for query string - query (AND or OR) Valid choices: AND, OR Default: OR + query (AND or OR) Valid choices: AND, OR Default: OR :arg df: The field to use as default where no field prefix is given in the query string :arg expand_wildcards: Whether to expand wildcard expression to - concrete indices that are open, closed or both. Valid choices: open, - closed, hidden, none, all Default: open + concrete indices that are open, closed or both. Valid choices: open, + closed, hidden, none, all Default: open :arg from_: Starting offset (default: 0) :arg ignore_unavailable: Whether specified concrete indices should be ignored when unavailable (missing or closed) @@ -1917,15 +1909,15 @@ class Elasticsearch(object): :arg scroll: Specify how long a consistent view of the index should be maintained for scrolled search :arg scroll_size: Size on the scroll request powering the update - by query Default: 100 + by query Default: 100 :arg search_timeout: Explicit timeout for each search request. Defaults to no timeout. - :arg search_type: Search operation type Valid choices: + :arg search_type: Search operation type Valid choices: query_then_fetch, dfs_query_then_fetch :arg size: Deprecated, please use `max_docs` instead :arg slices: The number of slices this task should be divided into. Defaults to 1, meaning the task isn't sliced into subtasks. Can be - set to `auto`. Default: 1 + set to `auto`. Default: 1 :arg sort: A comma-separated list of : pairs :arg stats: Specific 'tag' of the request for logging and statistical purposes @@ -1933,7 +1925,7 @@ class Elasticsearch(object): for each shard, upon reaching which the query execution will terminate early. :arg timeout: Time each individual bulk request should wait for - shards that are unavailable. Default: 1m + shards that are unavailable. Default: 1m :arg version: Specify whether to return document version as part of a hit :arg version_type: Should the document increment the version @@ -1945,7 +1937,7 @@ class Elasticsearch(object): or equal to the total number of copies for the shard (number of replicas + 1) :arg wait_for_completion: Should the request should block until - the update by query operation is complete. Default: True + the update by query operation is complete. Default: True """ # from is a reserved word so it cannot be used, use from_ instead if "from_" in params: diff --git a/test_elasticsearch/test_client/test_overrides.py b/test_elasticsearch/test_client/test_overrides.py new file mode 100644 index 00000000..d27c03f9 --- /dev/null +++ b/test_elasticsearch/test_client/test_overrides.py @@ -0,0 +1,141 @@ +# -*- coding: utf-8 -*- +# Licensed to Elasticsearch B.V under one or more agreements. +# Elasticsearch B.V licenses this file to you under the Apache 2.0 License. +# See the LICENSE file in the project root for more information + +import pytest +from test_elasticsearch.test_cases import ElasticsearchTestCase + + +class TestOverriddenUrlTargets(ElasticsearchTestCase): + def test_create(self): + self.client.create(index="test-index", id="test-id", body={}) + self.assert_url_called("PUT", "/test-index/_create/test-id") + + self.client.create( + index="test-index", doc_type="test-type", id="test-id", body={} + ) + self.assert_url_called("PUT", "/test-index/test-type/test-id/_create") + + def test_delete(self): + self.client.delete(index="test-index", id="test-id") + self.assert_url_called("DELETE", "/test-index/_doc/test-id") + + self.client.delete(index="test-index", doc_type="test-type", id="test-id") + self.assert_url_called("DELETE", "/test-index/test-type/test-id") + + def test_exists(self): + self.client.exists(index="test-index", id="test-id") + self.assert_url_called("HEAD", "/test-index/_doc/test-id") + + self.client.exists(index="test-index", doc_type="test-type", id="test-id") + self.assert_url_called("HEAD", "/test-index/test-type/test-id") + + def test_explain(self): + self.client.explain(index="test-index", id="test-id") + self.assert_url_called("POST", "/test-index/_explain/test-id") + + self.client.explain(index="test-index", doc_type="test-type", id="test-id") + self.assert_url_called("POST", "/test-index/test-type/test-id/_explain") + + def test_get(self): + self.client.get(index="test-index", id="test-id") + self.assert_url_called("GET", "/test-index/_doc/test-id") + + self.client.get(index="test-index", doc_type="test-type", id="test-id") + self.assert_url_called("GET", "/test-index/test-type/test-id") + + def test_get_source(self): + self.client.get_source(index="test-index", id="test-id") + self.assert_url_called("GET", "/test-index/_source/test-id") + + self.client.get_source(index="test-index", doc_type="test-type", id="test-id") + self.assert_url_called("GET", "/test-index/test-type/test-id/_source") + + def test_index(self): + self.client.index(index="test-index", body={}) + self.assert_url_called("POST", "/test-index/_doc") + + self.client.index(index="test-index", id="test-id", body={}) + self.assert_url_called("PUT", "/test-index/_doc/test-id") + + self.client.index(index="test-index", doc_type="test-type", body={}) + self.assert_url_called("POST", "/test-index/test-type") + + self.client.index( + index="test-index", doc_type="test-type", id="test-id", body={} + ) + self.assert_url_called("PUT", "/test-index/test-type/test-id") + + self.client.index(index="test-index", doc_type="_doc", body={}) + self.assert_url_called("POST", "/test-index/_doc", count=2) + + self.client.index(index="test-index", doc_type="_doc", id="test-id", body={}) + self.assert_url_called("PUT", "/test-index/_doc/test-id", count=2) + + def test_termvectors(self): + self.client.termvectors(index="test-index", body={}) + self.assert_url_called("POST", "/test-index/_termvectors") + + self.client.termvectors(index="test-index", id="test-id", body={}) + self.assert_url_called("POST", "/test-index/_termvectors/test-id") + + self.client.termvectors(index="test-index", doc_type="test-type", body={}) + self.assert_url_called("POST", "/test-index/test-type/_termvectors") + + self.client.termvectors( + index="test-index", doc_type="test-type", id="test-id", body={} + ) + self.assert_url_called("POST", "/test-index/test-type/test-id/_termvectors") + + def test_mtermvectors(self): + self.client.mtermvectors(index="test-index", body={}) + self.assert_url_called("POST", "/test-index/_mtermvectors") + + self.client.mtermvectors(index="test-index", doc_type="test-type", body={}) + self.assert_url_called("POST", "/test-index/test-type/_mtermvectors") + + def test_update(self): + self.client.update(index="test-index", id="test-id", body={}) + self.assert_url_called("POST", "/test-index/_update/test-id") + + self.client.update( + index="test-index", doc_type="test-type", id="test-id", body={} + ) + self.assert_url_called("POST", "/test-index/test-type/test-id/_update") + + def test_cluster_state(self): + self.client.cluster.state() + self.assert_url_called("GET", "/_cluster/state") + + self.client.cluster.state(index="test-index") + self.assert_url_called("GET", "/_cluster/state/_all/test-index") + + self.client.cluster.state(index="test-index", metric="test-metric") + self.assert_url_called("GET", "/_cluster/state/test-metric/test-index") + + def test_cluster_stats(self): + self.client.cluster.stats() + self.assert_url_called("GET", "/_cluster/stats") + + self.client.cluster.stats(node_id="test-node") + self.assert_url_called("GET", "/_cluster/stats/nodes/test-node") + + def test_indices_put_mapping(self): + self.client.indices.put_mapping(body={}) + self.assert_url_called("PUT", "/_mapping") + + self.client.indices.put_mapping(index="test-index", body={}) + self.assert_url_called("PUT", "/test-index/_mapping") + + self.client.indices.put_mapping( + index="test-index", doc_type="test-type", body={} + ) + self.assert_url_called("PUT", "/test-index/test-type/_mapping") + + self.client.indices.put_mapping(doc_type="test-type", body={}) + self.assert_url_called("PUT", "/_all/test-type/_mapping") + + def test_tasks_get(self): + with pytest.warns(DeprecationWarning): + self.client.tasks.get() diff --git a/utils/templates/overrides/__init__/create b/utils/templates/overrides/__init__/create deleted file mode 120000 index 7df7b009..00000000 --- a/utils/templates/overrides/__init__/create +++ /dev/null @@ -1 +0,0 @@ -single_doc_op \ No newline at end of file diff --git a/utils/templates/overrides/__init__/create b/utils/templates/overrides/__init__/create new file mode 100644 index 00000000..0f9d2f92 --- /dev/null +++ b/utils/templates/overrides/__init__/create @@ -0,0 +1,9 @@ +{% extends "base" %} +{% block request %} + if doc_type in SKIP_IN_PATH: + path = _make_path(index, "_create", id) + else: + path = _make_path(index, doc_type, id, "_create") + + return await self.transport.perform_request("{{ api.method }}", path, params=params, headers=headers, body=body) +{% endblock %} \ No newline at end of file diff --git a/utils/templates/overrides/__init__/delete b/utils/templates/overrides/__init__/delete deleted file mode 120000 index 7df7b009..00000000 --- a/utils/templates/overrides/__init__/delete +++ /dev/null @@ -1 +0,0 @@ -single_doc_op \ No newline at end of file diff --git a/utils/templates/overrides/__init__/delete b/utils/templates/overrides/__init__/delete new file mode 100644 index 00000000..5e6bfd6a --- /dev/null +++ b/utils/templates/overrides/__init__/delete @@ -0,0 +1,7 @@ +{% extends "base" %} +{% block request %} + if doc_type in SKIP_IN_PATH: + doc_type = "_doc" + + {{ super()|trim }} +{% endblock %} \ No newline at end of file diff --git a/utils/templates/overrides/__init__/exists b/utils/templates/overrides/__init__/exists deleted file mode 120000 index 7df7b009..00000000 --- a/utils/templates/overrides/__init__/exists +++ /dev/null @@ -1 +0,0 @@ -single_doc_op \ No newline at end of file diff --git a/utils/templates/overrides/__init__/exists b/utils/templates/overrides/__init__/exists new file mode 100644 index 00000000..5e6bfd6a --- /dev/null +++ b/utils/templates/overrides/__init__/exists @@ -0,0 +1,7 @@ +{% extends "base" %} +{% block request %} + if doc_type in SKIP_IN_PATH: + doc_type = "_doc" + + {{ super()|trim }} +{% endblock %} \ No newline at end of file diff --git a/utils/templates/overrides/__init__/explain b/utils/templates/overrides/__init__/explain deleted file mode 120000 index 7df7b009..00000000 --- a/utils/templates/overrides/__init__/explain +++ /dev/null @@ -1 +0,0 @@ -single_doc_op \ No newline at end of file diff --git a/utils/templates/overrides/__init__/explain b/utils/templates/overrides/__init__/explain new file mode 100644 index 00000000..266789df --- /dev/null +++ b/utils/templates/overrides/__init__/explain @@ -0,0 +1,9 @@ +{% extends "base" %} +{% block request %} + if doc_type in SKIP_IN_PATH: + path = _make_path(index, "_explain", id) + else: + path = _make_path(index, doc_type, id, "_explain") + + return await self.transport.perform_request("{{ api.method }}", path, params=params, headers=headers, body=body) +{% endblock %} \ No newline at end of file diff --git a/utils/templates/overrides/__init__/get b/utils/templates/overrides/__init__/get deleted file mode 120000 index 7df7b009..00000000 --- a/utils/templates/overrides/__init__/get +++ /dev/null @@ -1 +0,0 @@ -single_doc_op \ No newline at end of file diff --git a/utils/templates/overrides/__init__/get b/utils/templates/overrides/__init__/get new file mode 100644 index 00000000..5e6bfd6a --- /dev/null +++ b/utils/templates/overrides/__init__/get @@ -0,0 +1,7 @@ +{% extends "base" %} +{% block request %} + if doc_type in SKIP_IN_PATH: + doc_type = "_doc" + + {{ super()|trim }} +{% endblock %} \ No newline at end of file diff --git a/utils/templates/overrides/__init__/get_source b/utils/templates/overrides/__init__/get_source deleted file mode 120000 index 7df7b009..00000000 --- a/utils/templates/overrides/__init__/get_source +++ /dev/null @@ -1 +0,0 @@ -single_doc_op \ No newline at end of file diff --git a/utils/templates/overrides/__init__/get_source b/utils/templates/overrides/__init__/get_source new file mode 100644 index 00000000..0ca1f55e --- /dev/null +++ b/utils/templates/overrides/__init__/get_source @@ -0,0 +1,9 @@ +{% extends "base" %} +{% block request %} + if doc_type in SKIP_IN_PATH: + path = _make_path(index, "_source", id) + else: + path = _make_path(index, doc_type, id, "_source") + + return await self.transport.perform_request("{{ api.method }}", path, params=params, headers=headers) +{% endblock %} \ No newline at end of file diff --git a/utils/templates/overrides/__init__/mtermvectors b/utils/templates/overrides/__init__/mtermvectors new file mode 100644 index 00000000..3798d4d2 --- /dev/null +++ b/utils/templates/overrides/__init__/mtermvectors @@ -0,0 +1,9 @@ +{% extends "base" %} +{% block request %} + if doc_type in SKIP_IN_PATH: + path = _make_path(index, "_mtermvectors") + else: + path = _make_path(index, doc_type, "_mtermvectors") + + return await self.transport.perform_request("{{ api.method }}", path, params=params, headers=headers, body=body) +{% endblock %} \ No newline at end of file diff --git a/utils/templates/overrides/__init__/single_doc_op b/utils/templates/overrides/__init__/single_doc_op deleted file mode 100644 index 8189fec7..00000000 --- a/utils/templates/overrides/__init__/single_doc_op +++ /dev/null @@ -1,8 +0,0 @@ -{% extends "base" %} -{% block request %} - if doc_type in SKIP_IN_PATH: - doc_type = "_doc" - - {{ super()|trim }} -{% endblock %} - diff --git a/utils/templates/overrides/__init__/termvectors b/utils/templates/overrides/__init__/termvectors deleted file mode 120000 index 7df7b009..00000000 --- a/utils/templates/overrides/__init__/termvectors +++ /dev/null @@ -1 +0,0 @@ -single_doc_op \ No newline at end of file diff --git a/utils/templates/overrides/__init__/termvectors b/utils/templates/overrides/__init__/termvectors new file mode 100644 index 00000000..eea62439 --- /dev/null +++ b/utils/templates/overrides/__init__/termvectors @@ -0,0 +1,9 @@ +{% extends "base" %} +{% block request %} + if doc_type in SKIP_IN_PATH: + path = _make_path(index, "_termvectors", id) + else: + path = _make_path(index, doc_type, id, "_termvectors") + + return await self.transport.perform_request("{{ api.method }}", path, params=params, headers=headers, body=body) +{% endblock %} \ No newline at end of file diff --git a/utils/templates/overrides/__init__/update b/utils/templates/overrides/__init__/update deleted file mode 120000 index 7df7b009..00000000 --- a/utils/templates/overrides/__init__/update +++ /dev/null @@ -1 +0,0 @@ -single_doc_op \ No newline at end of file diff --git a/utils/templates/overrides/__init__/update b/utils/templates/overrides/__init__/update new file mode 100644 index 00000000..85ca2265 --- /dev/null +++ b/utils/templates/overrides/__init__/update @@ -0,0 +1,9 @@ +{% extends "base" %} +{% block request %} + if doc_type in SKIP_IN_PATH: + path = _make_path(index, "_update", id) + else: + path = _make_path(index, doc_type, id, "_update") + + return await self.transport.perform_request("{{ api.method }}", path, params=params, headers=headers, body=body) +{% endblock %} \ No newline at end of file