diff --git a/api_generator/rest_specs/close_point_in_time.json b/api_generator/rest_specs/close_point_in_time.json new file mode 100644 index 00000000..16a4aabd --- /dev/null +++ b/api_generator/rest_specs/close_point_in_time.json @@ -0,0 +1,23 @@ +{ + "close_point_in_time":{ + "documentation":{ + "url":"https://www.elastic.co/guide/en/elasticsearch/reference/master/point-in-time-api.html", + "description":"Close a point in time" + }, + "stability":"stable", + "url":{ + "paths":[ + { + "path":"/_pit", + "methods":[ + "DELETE" + ] + } + ] + }, + "params":{}, + "body":{ + "description": "a point-in-time id to close" + } + } +} diff --git a/api_generator/rest_specs/last_downloaded_version b/api_generator/rest_specs/last_downloaded_version index e28dc5ba..b692764f 100644 --- a/api_generator/rest_specs/last_downloaded_version +++ b/api_generator/rest_specs/last_downloaded_version @@ -1 +1 @@ -7.x \ No newline at end of file +7.10 \ No newline at end of file diff --git a/api_generator/rest_specs/ml.delete_trained_model.json b/api_generator/rest_specs/ml.delete_trained_model.json index 27d24cd7..15c21314 100644 --- a/api_generator/rest_specs/ml.delete_trained_model.json +++ b/api_generator/rest_specs/ml.delete_trained_model.json @@ -1,14 +1,14 @@ { "ml.delete_trained_model":{ "documentation":{ - "url":"https://www.elastic.co/guide/en/elasticsearch/reference/current/delete-inference.html", + "url":"https://www.elastic.co/guide/en/elasticsearch/reference/current/delete-trained-models.html", "description":"Deletes an existing trained inference model that is currently not referenced by an ingest pipeline." }, "stability":"experimental", "url":{ "paths":[ { - "path":"/_ml/inference/{model_id}", + "path":"/_ml/trained_models/{model_id}", "methods":[ "DELETE" ], diff --git a/api_generator/rest_specs/ml.get_trained_models.json b/api_generator/rest_specs/ml.get_trained_models.json index 168d233c..779fe606 100644 --- a/api_generator/rest_specs/ml.get_trained_models.json +++ b/api_generator/rest_specs/ml.get_trained_models.json @@ -1,14 +1,14 @@ { "ml.get_trained_models":{ "documentation":{ - "url":"https://www.elastic.co/guide/en/elasticsearch/reference/current/get-inference.html", + "url":"https://www.elastic.co/guide/en/elasticsearch/reference/current/get-trained-models.html", "description":"Retrieves configuration information for a trained inference model." }, "stability":"experimental", "url":{ "paths":[ { - "path":"/_ml/inference/{model_id}", + "path":"/_ml/trained_models/{model_id}", "methods":[ "GET" ], @@ -20,7 +20,7 @@ } }, { - "path":"/_ml/inference", + "path":"/_ml/trained_models", "methods":[ "GET" ] @@ -34,11 +34,17 @@ "description":"Whether to ignore if a wildcard expression matches no trained models. (This includes `_all` string or when no trained models have been specified)", "default":true }, + "include":{ + "type":"string", + "required":false, + "description":"A comma-separate list of fields to optionally include. Valid options are 'definition' and 'total_feature_importance'. Default is none." + }, "include_model_definition":{ "type":"boolean", "required":false, "description":"Should the full model definition be included in the results. These definitions can be large. So be cautious when including them. Defaults to false.", - "default":false + "default":false, + "deprecated": true }, "decompress_definition":{ "type":"boolean", diff --git a/api_generator/rest_specs/ml.get_trained_models_stats.json b/api_generator/rest_specs/ml.get_trained_models_stats.json index 93e94452..271f167c 100644 --- a/api_generator/rest_specs/ml.get_trained_models_stats.json +++ b/api_generator/rest_specs/ml.get_trained_models_stats.json @@ -1,14 +1,14 @@ { "ml.get_trained_models_stats":{ "documentation":{ - "url":"https://www.elastic.co/guide/en/elasticsearch/reference/current/get-inference-stats.html", + "url":"https://www.elastic.co/guide/en/elasticsearch/reference/current/get-trained-models-stats.html", "description":"Retrieves usage information for trained inference models." }, "stability":"experimental", "url":{ "paths":[ { - "path":"/_ml/inference/{model_id}/_stats", + "path":"/_ml/trained_models/{model_id}/_stats", "methods":[ "GET" ], @@ -20,7 +20,7 @@ } }, { - "path":"/_ml/inference/_stats", + "path":"/_ml/trained_models/_stats", "methods":[ "GET" ] diff --git a/api_generator/rest_specs/ml.put_trained_model.json b/api_generator/rest_specs/ml.put_trained_model.json index f69756b5..094bef3b 100644 --- a/api_generator/rest_specs/ml.put_trained_model.json +++ b/api_generator/rest_specs/ml.put_trained_model.json @@ -1,14 +1,14 @@ { "ml.put_trained_model":{ "documentation":{ - "url":"https://www.elastic.co/guide/en/elasticsearch/reference/current/put-inference.html", + "url":"https://www.elastic.co/guide/en/elasticsearch/reference/current/put-trained-models.html", "description":"Creates an inference trained model." }, "stability":"experimental", "url":{ "paths":[ { - "path":"/_ml/inference/{model_id}", + "path":"/_ml/trained_models/{model_id}", "methods":[ "PUT" ], diff --git a/api_generator/rest_specs/open_point_in_time.json b/api_generator/rest_specs/open_point_in_time.json new file mode 100644 index 00000000..c388235d --- /dev/null +++ b/api_generator/rest_specs/open_point_in_time.json @@ -0,0 +1,61 @@ +{ + "open_point_in_time":{ + "documentation":{ + "url":"https://www.elastic.co/guide/en/elasticsearch/reference/master/point-in-time-api.html", + "description":"Open a point in time that can be used in subsequent searches" + }, + "stability":"stable", + "url":{ + "paths":[ + { + "path":"/_pit", + "methods":[ + "POST" + ] + }, + { + "path":"/{index}/_pit", + "methods":[ + "POST" + ], + "parts":{ + "index":{ + "type":"list", + "description":"A comma-separated list of index names to open point in time; use `_all` or empty string to perform the operation on all indices" + } + } + } + ] + }, + "params":{ + "preference":{ + "type":"string", + "description":"Specify the node or shard the operation should be performed on (default: random)" + }, + "routing":{ + "type":"string", + "description":"Specific routing value" + }, + "ignore_unavailable":{ + "type":"boolean", + "description":"Whether specified concrete indices should be ignored when unavailable (missing or closed)" + }, + "expand_wildcards":{ + "type":"enum", + "options":[ + "open", + "closed", + "hidden", + "none", + "all" + ], + "default":"open", + "description":"Whether to expand wildcard expression to concrete indices that are open, closed or both." + }, + "keep_alive": { + "type": "string", + "description": "Specific the time to live for the point in time" + } + } + } +} diff --git a/api_generator/rest_specs/searchable_snapshots.clear_cache.json b/api_generator/rest_specs/searchable_snapshots.clear_cache.json index 9dc9f424..b5d86103 100644 --- a/api_generator/rest_specs/searchable_snapshots.clear_cache.json +++ b/api_generator/rest_specs/searchable_snapshots.clear_cache.json @@ -1,7 +1,7 @@ { "searchable_snapshots.clear_cache": { "documentation": { - "url": "https://www.elastic.co/guide/en/elasticsearch/reference/current/searchable-snapshots-api-clear-cache.html", + "url": "https://www.elastic.co/guide/en/elasticsearch/reference/current/searchable-snapshots-apis.html", "description" : "Clear the cache of searchable snapshots." }, "stability": "experimental", diff --git a/api_generator/rest_specs/searchable_snapshots.repository_stats.json b/api_generator/rest_specs/searchable_snapshots.repository_stats.json index a04bd0db..4e1008af 100644 --- a/api_generator/rest_specs/searchable_snapshots.repository_stats.json +++ b/api_generator/rest_specs/searchable_snapshots.repository_stats.json @@ -1,8 +1,8 @@ { "searchable_snapshots.repository_stats": { "documentation": { - "url": "https://www.elastic.co/guide/en/elasticsearch/reference/current/searchable-snapshots-repository-stats.html", - "description": "Retrieve usage statistics about a snapshot repository." + "url": "https://www.elastic.co/guide/en/elasticsearch/reference/current/searchable-snapshots-apis.html", + "description": "DEPRECATED: This API is replaced by the Repositories Metering API." }, "stability": "experimental", "url": { diff --git a/api_generator/rest_specs/searchable_snapshots.stats.json b/api_generator/rest_specs/searchable_snapshots.stats.json index b75903a4..db13c126 100644 --- a/api_generator/rest_specs/searchable_snapshots.stats.json +++ b/api_generator/rest_specs/searchable_snapshots.stats.json @@ -1,7 +1,7 @@ { "searchable_snapshots.stats": { "documentation": { - "url": "https://www.elastic.co/guide/en/elasticsearch/reference/current/searchable-snapshots-api-stats.html", + "url": "https://www.elastic.co/guide/en/elasticsearch/reference/current/searchable-snapshots-apis.html", "description": "Retrieve various statistics about searchable snapshots." }, "stability": "experimental", diff --git a/api_generator/rest_specs/security.clear_api_key_cache.json b/api_generator/rest_specs/security.clear_api_key_cache.json new file mode 100644 index 00000000..e87e265e --- /dev/null +++ b/api_generator/rest_specs/security.clear_api_key_cache.json @@ -0,0 +1,26 @@ +{ + "security.clear_api_key_cache":{ + "documentation":{ + "url":"https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-clear-api-key-cache.html", + "description":"Clear a subset or all entries from the API key cache." + }, + "stability":"stable", + "url":{ + "paths":[ + { + "path":"/_security/api_key/{ids}/_clear_cache", + "methods":[ + "POST" + ], + "parts":{ + "ids":{ + "type":"list", + "description":"A comma-separated list of IDs of API keys to clear from the cache" + } + } + } + ] + }, + "params":{} + } +} diff --git a/api_generator/rest_specs/security.get_role.json b/api_generator/rest_specs/security.get_role.json index 9c52878a..530bcfb2 100644 --- a/api_generator/rest_specs/security.get_role.json +++ b/api_generator/rest_specs/security.get_role.json @@ -14,8 +14,8 @@ ], "parts":{ "name":{ - "type":"string", - "description":"Role name" + "type":"list", + "description":"A comma-separated list of role names" } } }, diff --git a/api_generator/rest_specs/security.get_role_mapping.json b/api_generator/rest_specs/security.get_role_mapping.json index 4b98173b..06818b03 100644 --- a/api_generator/rest_specs/security.get_role_mapping.json +++ b/api_generator/rest_specs/security.get_role_mapping.json @@ -14,8 +14,8 @@ ], "parts":{ "name":{ - "type":"string", - "description":"Role-Mapping name" + "type":"list", + "description":"A comma-separated list of role-mapping names" } } }, diff --git a/api_generator/rest_specs/security.grant_api_key.json b/api_generator/rest_specs/security.grant_api_key.json new file mode 100644 index 00000000..a64f0366 --- /dev/null +++ b/api_generator/rest_specs/security.grant_api_key.json @@ -0,0 +1,34 @@ +{ + "security.grant_api_key":{ + "documentation":{ + "url":"https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-grant-api-key.html", + "description":"Creates an API key on behalf of another user." + }, + "stability":"stable", + "url":{ + "paths":[ + { + "path":"/_security/api_key/grant", + "methods":[ + "POST" + ] + } + ] + }, + "params":{ + "refresh":{ + "type":"enum", + "options":[ + "true", + "false", + "wait_for" + ], + "description":"If `true` (the default) 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` then do nothing with refreshes." + } + }, + "body":{ + "description":"The api key request to create an API key", + "required":true + } + } +} diff --git a/api_generator/rest_specs/snapshot.clone.json b/api_generator/rest_specs/snapshot.clone.json new file mode 100644 index 00000000..18122bc2 --- /dev/null +++ b/api_generator/rest_specs/snapshot.clone.json @@ -0,0 +1,43 @@ +{ + "snapshot.clone":{ + "documentation":{ + "url":"https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html", + "description":"Clones indices from one snapshot into another snapshot in the same repository." + }, + "stability":"stable", + "url":{ + "paths":[ + { + "path":"/_snapshot/{repository}/{snapshot}/_clone/{target_snapshot}", + "methods":[ + "PUT" + ], + "parts":{ + "repository":{ + "type":"string", + "description":"A repository name" + }, + "snapshot":{ + "type":"string", + "description":"The name of the snapshot to clone from" + }, + "target_snapshot":{ + "type":"string", + "description":"The name of the cloned snapshot to create" + } + } + } + ] + }, + "params":{ + "master_timeout":{ + "type":"time", + "description":"Explicit operation timeout for connection to master node" + } + }, + "body":{ + "description":"The snapshot clone definition", + "required":true + } + } +} diff --git a/elasticsearch/src/params.rs b/elasticsearch/src/params.rs index 6f902fce..212f358d 100644 --- a/elasticsearch/src/params.rs +++ b/elasticsearch/src/params.rs @@ -120,7 +120,7 @@ pub enum OpType { Create, } #[derive(Debug, PartialEq, Deserialize, Serialize, Clone, Copy)] -#[doc = "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."] +#[doc = "If `true` (the default) 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` then do nothing with refreshes."] pub enum Refresh { #[serde(rename = "true")] True, @@ -200,6 +200,8 @@ pub enum VersionType { External, #[serde(rename = "external_gte")] ExternalGte, + #[serde(rename = "force")] + Force, } #[derive(Debug, PartialEq, Deserialize, Serialize, Clone, Copy)] #[doc = "Wait until all currently queued events with the given priority are processed"] diff --git a/elasticsearch/src/root/mod.rs b/elasticsearch/src/root/mod.rs index 0759632d..da7cd6e4 100644 --- a/elasticsearch/src/root/mod.rs +++ b/elasticsearch/src/root/mod.rs @@ -450,6 +450,141 @@ where } } #[derive(Debug, Clone, PartialEq)] +#[doc = "API parts for the Close Point In Time API"] +pub enum ClosePointInTimeParts { + #[doc = "No parts"] + None, +} +impl ClosePointInTimeParts { + #[doc = "Builds a relative URL path to the Close Point In Time API"] + pub fn url(self) -> Cow<'static, str> { + match self { + ClosePointInTimeParts::None => "/_pit".into(), + } + } +} +#[derive(Clone, Debug)] +#[doc = "Builder for the [Close Point In Time API](https://www.elastic.co/guide/en/elasticsearch/reference/7.10/point-in-time-api.html)\n\nClose a point in time"] +pub struct ClosePointInTime<'a, 'b, B> { + transport: &'a Transport, + parts: ClosePointInTimeParts, + body: Option, + error_trace: Option, + filter_path: Option<&'b [&'b str]>, + headers: HeaderMap, + human: Option, + pretty: Option, + request_timeout: Option, + source: Option<&'b str>, +} +impl<'a, 'b, B> ClosePointInTime<'a, 'b, B> +where + B: Body, +{ + #[doc = "Creates a new instance of [ClosePointInTime]"] + pub fn new(transport: &'a Transport) -> Self { + let headers = HeaderMap::new(); + ClosePointInTime { + transport, + parts: ClosePointInTimeParts::None, + headers, + body: None, + error_trace: None, + filter_path: None, + human: None, + pretty: None, + request_timeout: None, + source: None, + } + } + #[doc = "The body for the API call"] + pub fn body(self, body: T) -> ClosePointInTime<'a, 'b, JsonBody> + where + T: Serialize, + { + ClosePointInTime { + transport: self.transport, + parts: self.parts, + body: Some(body.into()), + error_trace: self.error_trace, + filter_path: self.filter_path, + headers: self.headers, + human: self.human, + pretty: self.pretty, + request_timeout: self.request_timeout, + source: self.source, + } + } + #[doc = "Include the stack trace of returned errors."] + pub fn error_trace(mut self, error_trace: bool) -> Self { + self.error_trace = Some(error_trace); + self + } + #[doc = "A comma-separated list of filters used to reduce the response."] + pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self { + self.filter_path = Some(filter_path); + self + } + #[doc = "Adds a HTTP header"] + pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self { + self.headers.insert(key, value); + self + } + #[doc = "Return human readable values for statistics."] + pub fn human(mut self, human: bool) -> Self { + self.human = Some(human); + self + } + #[doc = "Pretty format the returned JSON response."] + pub fn pretty(mut self, pretty: bool) -> Self { + self.pretty = Some(pretty); + self + } + #[doc = "Sets a request timeout for this API call.\n\nThe timeout is applied from when the request starts connecting until the response body has finished."] + pub fn request_timeout(mut self, timeout: Duration) -> Self { + self.request_timeout = Some(timeout); + self + } + #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."] + pub fn source(mut self, source: &'b str) -> Self { + self.source = Some(source); + self + } + #[doc = "Creates an asynchronous call to the Close Point In Time API that can be awaited"] + pub async fn send(self) -> Result { + let path = self.parts.url(); + let method = Method::Delete; + let headers = self.headers; + let timeout = self.request_timeout; + let query_string = { + #[serde_with::skip_serializing_none] + #[derive(Serialize)] + struct QueryParams<'b> { + error_trace: Option, + #[serde(serialize_with = "crate::client::serialize_coll_qs")] + filter_path: Option<&'b [&'b str]>, + human: Option, + pretty: Option, + source: Option<&'b str>, + } + let query_params = QueryParams { + error_trace: self.error_trace, + filter_path: self.filter_path, + human: self.human, + pretty: self.pretty, + source: self.source, + }; + Some(query_params) + }; + let body = self.body; + let response = self + .transport + .send(method, &path, headers, query_string.as_ref(), body, timeout) + .await?; + Ok(response) + } +} +#[derive(Debug, Clone, PartialEq)] #[doc = "API parts for the Count API"] pub enum CountParts<'b> { #[doc = "No parts"] @@ -4921,6 +5056,204 @@ where } } #[derive(Debug, Clone, PartialEq)] +#[doc = "API parts for the Open Point In Time API"] +pub enum OpenPointInTimeParts<'b> { + #[doc = "No parts"] + None, + #[doc = "Index"] + Index(&'b [&'b str]), +} +impl<'b> OpenPointInTimeParts<'b> { + #[doc = "Builds a relative URL path to the Open Point In Time API"] + pub fn url(self) -> Cow<'static, str> { + match self { + OpenPointInTimeParts::None => "/_pit".into(), + OpenPointInTimeParts::Index(ref index) => { + let index_str = index.join(","); + let encoded_index: Cow = + percent_encode(index_str.as_bytes(), PARTS_ENCODED).into(); + let mut p = String::with_capacity(6usize + encoded_index.len()); + p.push_str("/"); + p.push_str(encoded_index.as_ref()); + p.push_str("/_pit"); + p.into() + } + } + } +} +#[derive(Clone, Debug)] +#[doc = "Builder for the [Open Point In Time API](https://www.elastic.co/guide/en/elasticsearch/reference/7.10/point-in-time-api.html)\n\nOpen a point in time that can be used in subsequent searches"] +pub struct OpenPointInTime<'a, 'b, B> { + transport: &'a Transport, + parts: OpenPointInTimeParts<'b>, + body: Option, + error_trace: Option, + expand_wildcards: Option<&'b [ExpandWildcards]>, + filter_path: Option<&'b [&'b str]>, + headers: HeaderMap, + human: Option, + ignore_unavailable: Option, + keep_alive: Option<&'b str>, + preference: Option<&'b str>, + pretty: Option, + request_timeout: Option, + routing: Option<&'b str>, + source: Option<&'b str>, +} +impl<'a, 'b, B> OpenPointInTime<'a, 'b, B> +where + B: Body, +{ + #[doc = "Creates a new instance of [OpenPointInTime] with the specified API parts"] + pub fn new(transport: &'a Transport, parts: OpenPointInTimeParts<'b>) -> Self { + let headers = HeaderMap::new(); + OpenPointInTime { + transport, + parts, + headers, + body: None, + error_trace: None, + expand_wildcards: None, + filter_path: None, + human: None, + ignore_unavailable: None, + keep_alive: None, + preference: None, + pretty: None, + request_timeout: None, + routing: None, + source: None, + } + } + #[doc = "The body for the API call"] + pub fn body(self, body: T) -> OpenPointInTime<'a, 'b, JsonBody> + where + T: Serialize, + { + OpenPointInTime { + transport: self.transport, + parts: self.parts, + body: Some(body.into()), + error_trace: self.error_trace, + expand_wildcards: self.expand_wildcards, + filter_path: self.filter_path, + headers: self.headers, + human: self.human, + ignore_unavailable: self.ignore_unavailable, + keep_alive: self.keep_alive, + preference: self.preference, + pretty: self.pretty, + request_timeout: self.request_timeout, + routing: self.routing, + source: self.source, + } + } + #[doc = "Include the stack trace of returned errors."] + pub fn error_trace(mut self, error_trace: bool) -> Self { + self.error_trace = Some(error_trace); + self + } + #[doc = "Whether to expand wildcard expression to concrete indices that are open, closed or both."] + pub fn expand_wildcards(mut self, expand_wildcards: &'b [ExpandWildcards]) -> Self { + self.expand_wildcards = Some(expand_wildcards); + self + } + #[doc = "A comma-separated list of filters used to reduce the response."] + pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self { + self.filter_path = Some(filter_path); + self + } + #[doc = "Adds a HTTP header"] + pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self { + self.headers.insert(key, value); + self + } + #[doc = "Return human readable values for statistics."] + pub fn human(mut self, human: bool) -> Self { + self.human = Some(human); + self + } + #[doc = "Whether specified concrete indices should be ignored when unavailable (missing or closed)"] + pub fn ignore_unavailable(mut self, ignore_unavailable: bool) -> Self { + self.ignore_unavailable = Some(ignore_unavailable); + self + } + #[doc = "Specific the time to live for the point in time"] + pub fn keep_alive(mut self, keep_alive: &'b str) -> Self { + self.keep_alive = Some(keep_alive); + self + } + #[doc = "Specify the node or shard the operation should be performed on (default: random)"] + pub fn preference(mut self, preference: &'b str) -> Self { + self.preference = Some(preference); + self + } + #[doc = "Pretty format the returned JSON response."] + pub fn pretty(mut self, pretty: bool) -> Self { + self.pretty = Some(pretty); + self + } + #[doc = "Sets a request timeout for this API call.\n\nThe timeout is applied from when the request starts connecting until the response body has finished."] + pub fn request_timeout(mut self, timeout: Duration) -> Self { + self.request_timeout = Some(timeout); + self + } + #[doc = "Specific routing value"] + pub fn routing(mut self, routing: &'b str) -> Self { + self.routing = Some(routing); + self + } + #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."] + pub fn source(mut self, source: &'b str) -> Self { + self.source = Some(source); + self + } + #[doc = "Creates an asynchronous call to the Open Point In Time API that can be awaited"] + pub async fn send(self) -> Result { + let path = self.parts.url(); + let method = Method::Post; + let headers = self.headers; + let timeout = self.request_timeout; + let query_string = { + #[serde_with::skip_serializing_none] + #[derive(Serialize)] + struct QueryParams<'b> { + error_trace: Option, + #[serde(serialize_with = "crate::client::serialize_coll_qs")] + expand_wildcards: Option<&'b [ExpandWildcards]>, + #[serde(serialize_with = "crate::client::serialize_coll_qs")] + filter_path: Option<&'b [&'b str]>, + human: Option, + ignore_unavailable: Option, + keep_alive: Option<&'b str>, + preference: Option<&'b str>, + pretty: Option, + routing: Option<&'b str>, + source: Option<&'b str>, + } + let query_params = QueryParams { + error_trace: self.error_trace, + expand_wildcards: self.expand_wildcards, + filter_path: self.filter_path, + human: self.human, + ignore_unavailable: self.ignore_unavailable, + keep_alive: self.keep_alive, + preference: self.preference, + pretty: self.pretty, + routing: self.routing, + source: self.source, + }; + Some(query_params) + }; + let body = self.body; + let response = self + .transport + .send(method, &path, headers, query_string.as_ref(), body, timeout) + .await?; + Ok(response) + } +} +#[derive(Debug, Clone, PartialEq)] #[doc = "API parts for the Ping API"] pub enum PingParts { #[doc = "No parts"] @@ -8283,6 +8616,10 @@ impl Elasticsearch { pub fn clear_scroll<'a, 'b>(&'a self, parts: ClearScrollParts<'b>) -> ClearScroll<'a, 'b, ()> { ClearScroll::new(self.transport(), parts) } + #[doc = "[Close Point In Time API](https://www.elastic.co/guide/en/elasticsearch/reference/7.10/point-in-time-api.html)\n\nClose a point in time"] + pub fn close_point_in_time<'a, 'b>(&'a self) -> ClosePointInTime<'a, 'b, ()> { + ClosePointInTime::new(self.transport()) + } #[doc = "[Count API](https://www.elastic.co/guide/en/elasticsearch/reference/7.10/search-count.html)\n\nReturns number of documents matching a query."] pub fn count<'a, 'b>(&'a self, parts: CountParts<'b>) -> Count<'a, 'b, ()> { Count::new(self.transport(), parts) @@ -8371,6 +8708,13 @@ impl Elasticsearch { ) -> Mtermvectors<'a, 'b, ()> { Mtermvectors::new(self.transport(), parts) } + #[doc = "[Open Point In Time API](https://www.elastic.co/guide/en/elasticsearch/reference/7.10/point-in-time-api.html)\n\nOpen a point in time that can be used in subsequent searches"] + pub fn open_point_in_time<'a, 'b>( + &'a self, + parts: OpenPointInTimeParts<'b>, + ) -> OpenPointInTime<'a, 'b, ()> { + OpenPointInTime::new(self.transport(), parts) + } #[doc = "[Ping API](https://www.elastic.co/guide/en/elasticsearch/reference/7.10/index.html)\n\nReturns whether the cluster is running."] pub fn ping<'a, 'b>(&'a self) -> Ping<'a, 'b> { Ping::new(self.transport()) diff --git a/elasticsearch/src/security.rs b/elasticsearch/src/security.rs index 4b670cee..1a1ca7c7 100644 --- a/elasticsearch/src/security.rs +++ b/elasticsearch/src/security.rs @@ -321,6 +321,150 @@ where } } #[derive(Debug, Clone, PartialEq)] +#[doc = "API parts for the Security Clear Api Key Cache API"] +pub enum SecurityClearApiKeyCacheParts<'b> { + #[doc = "Ids"] + Ids(&'b [&'b str]), +} +impl<'b> SecurityClearApiKeyCacheParts<'b> { + #[doc = "Builds a relative URL path to the Security Clear Api Key Cache API"] + pub fn url(self) -> Cow<'static, str> { + match self { + SecurityClearApiKeyCacheParts::Ids(ref ids) => { + let ids_str = ids.join(","); + let encoded_ids: Cow = + percent_encode(ids_str.as_bytes(), PARTS_ENCODED).into(); + let mut p = String::with_capacity(32usize + encoded_ids.len()); + p.push_str("/_security/api_key/"); + p.push_str(encoded_ids.as_ref()); + p.push_str("/_clear_cache"); + p.into() + } + } + } +} +#[derive(Clone, Debug)] +#[doc = "Builder for the [Security Clear Api Key Cache API](https://www.elastic.co/guide/en/elasticsearch/reference/7.10/security-api-clear-api-key-cache.html)\n\nClear a subset or all entries from the API key cache."] +pub struct SecurityClearApiKeyCache<'a, 'b, B> { + transport: &'a Transport, + parts: SecurityClearApiKeyCacheParts<'b>, + body: Option, + error_trace: Option, + filter_path: Option<&'b [&'b str]>, + headers: HeaderMap, + human: Option, + pretty: Option, + request_timeout: Option, + source: Option<&'b str>, +} +impl<'a, 'b, B> SecurityClearApiKeyCache<'a, 'b, B> +where + B: Body, +{ + #[doc = "Creates a new instance of [SecurityClearApiKeyCache] with the specified API parts"] + pub fn new(transport: &'a Transport, parts: SecurityClearApiKeyCacheParts<'b>) -> Self { + let headers = HeaderMap::new(); + SecurityClearApiKeyCache { + transport, + parts, + headers, + body: None, + error_trace: None, + filter_path: None, + human: None, + pretty: None, + request_timeout: None, + source: None, + } + } + #[doc = "The body for the API call"] + pub fn body(self, body: T) -> SecurityClearApiKeyCache<'a, 'b, JsonBody> + where + T: Serialize, + { + SecurityClearApiKeyCache { + transport: self.transport, + parts: self.parts, + body: Some(body.into()), + error_trace: self.error_trace, + filter_path: self.filter_path, + headers: self.headers, + human: self.human, + pretty: self.pretty, + request_timeout: self.request_timeout, + source: self.source, + } + } + #[doc = "Include the stack trace of returned errors."] + pub fn error_trace(mut self, error_trace: bool) -> Self { + self.error_trace = Some(error_trace); + self + } + #[doc = "A comma-separated list of filters used to reduce the response."] + pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self { + self.filter_path = Some(filter_path); + self + } + #[doc = "Adds a HTTP header"] + pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self { + self.headers.insert(key, value); + self + } + #[doc = "Return human readable values for statistics."] + pub fn human(mut self, human: bool) -> Self { + self.human = Some(human); + self + } + #[doc = "Pretty format the returned JSON response."] + pub fn pretty(mut self, pretty: bool) -> Self { + self.pretty = Some(pretty); + self + } + #[doc = "Sets a request timeout for this API call.\n\nThe timeout is applied from when the request starts connecting until the response body has finished."] + pub fn request_timeout(mut self, timeout: Duration) -> Self { + self.request_timeout = Some(timeout); + self + } + #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."] + pub fn source(mut self, source: &'b str) -> Self { + self.source = Some(source); + self + } + #[doc = "Creates an asynchronous call to the Security Clear Api Key Cache API that can be awaited"] + pub async fn send(self) -> Result { + let path = self.parts.url(); + let method = Method::Post; + let headers = self.headers; + let timeout = self.request_timeout; + let query_string = { + #[serde_with::skip_serializing_none] + #[derive(Serialize)] + struct QueryParams<'b> { + error_trace: Option, + #[serde(serialize_with = "crate::client::serialize_coll_qs")] + filter_path: Option<&'b [&'b str]>, + human: Option, + pretty: Option, + source: Option<&'b str>, + } + let query_params = QueryParams { + error_trace: self.error_trace, + filter_path: self.filter_path, + human: self.human, + pretty: self.pretty, + source: self.source, + }; + Some(query_params) + }; + let body = self.body; + let response = self + .transport + .send(method, &path, headers, query_string.as_ref(), body, timeout) + .await?; + Ok(response) + } +} +#[derive(Debug, Clone, PartialEq)] #[doc = "API parts for the Security Clear Cached Privileges API"] pub enum SecurityClearCachedPrivilegesParts<'b> { #[doc = "Application"] @@ -2137,7 +2281,7 @@ impl<'a, 'b> SecurityGetPrivileges<'a, 'b> { #[doc = "API parts for the Security Get Role API"] pub enum SecurityGetRoleParts<'b> { #[doc = "Name"] - Name(&'b str), + Name(&'b [&'b str]), #[doc = "No parts"] None, } @@ -2146,7 +2290,9 @@ impl<'b> SecurityGetRoleParts<'b> { pub fn url(self) -> Cow<'static, str> { match self { SecurityGetRoleParts::Name(ref name) => { - let encoded_name: Cow = percent_encode(name.as_bytes(), PARTS_ENCODED).into(); + let name_str = name.join(","); + let encoded_name: Cow = + percent_encode(name_str.as_bytes(), PARTS_ENCODED).into(); let mut p = String::with_capacity(16usize + encoded_name.len()); p.push_str("/_security/role/"); p.push_str(encoded_name.as_ref()); @@ -2258,7 +2404,7 @@ impl<'a, 'b> SecurityGetRole<'a, 'b> { #[doc = "API parts for the Security Get Role Mapping API"] pub enum SecurityGetRoleMappingParts<'b> { #[doc = "Name"] - Name(&'b str), + Name(&'b [&'b str]), #[doc = "No parts"] None, } @@ -2267,7 +2413,9 @@ impl<'b> SecurityGetRoleMappingParts<'b> { pub fn url(self) -> Cow<'static, str> { match self { SecurityGetRoleMappingParts::Name(ref name) => { - let encoded_name: Cow = percent_encode(name.as_bytes(), PARTS_ENCODED).into(); + let name_str = name.join(","); + let encoded_name: Cow = + percent_encode(name_str.as_bytes(), PARTS_ENCODED).into(); let mut p = String::with_capacity(24usize + encoded_name.len()); p.push_str("/_security/role_mapping/"); p.push_str(encoded_name.as_ref()); @@ -2746,6 +2894,151 @@ impl<'a, 'b> SecurityGetUserPrivileges<'a, 'b> { } } #[derive(Debug, Clone, PartialEq)] +#[doc = "API parts for the Security Grant Api Key API"] +pub enum SecurityGrantApiKeyParts { + #[doc = "No parts"] + None, +} +impl SecurityGrantApiKeyParts { + #[doc = "Builds a relative URL path to the Security Grant Api Key API"] + pub fn url(self) -> Cow<'static, str> { + match self { + SecurityGrantApiKeyParts::None => "/_security/api_key/grant".into(), + } + } +} +#[derive(Clone, Debug)] +#[doc = "Builder for the [Security Grant Api Key API](https://www.elastic.co/guide/en/elasticsearch/reference/7.10/security-api-grant-api-key.html)\n\nCreates an API key on behalf of another user."] +pub struct SecurityGrantApiKey<'a, 'b, B> { + transport: &'a Transport, + parts: SecurityGrantApiKeyParts, + body: Option, + error_trace: Option, + filter_path: Option<&'b [&'b str]>, + headers: HeaderMap, + human: Option, + pretty: Option, + refresh: Option, + request_timeout: Option, + source: Option<&'b str>, +} +impl<'a, 'b, B> SecurityGrantApiKey<'a, 'b, B> +where + B: Body, +{ + #[doc = "Creates a new instance of [SecurityGrantApiKey]"] + pub fn new(transport: &'a Transport) -> Self { + let headers = HeaderMap::new(); + SecurityGrantApiKey { + transport, + parts: SecurityGrantApiKeyParts::None, + headers, + body: None, + error_trace: None, + filter_path: None, + human: None, + pretty: None, + refresh: None, + request_timeout: None, + source: None, + } + } + #[doc = "The body for the API call"] + pub fn body(self, body: T) -> SecurityGrantApiKey<'a, 'b, JsonBody> + where + T: Serialize, + { + SecurityGrantApiKey { + transport: self.transport, + parts: self.parts, + body: Some(body.into()), + error_trace: self.error_trace, + filter_path: self.filter_path, + headers: self.headers, + human: self.human, + pretty: self.pretty, + refresh: self.refresh, + request_timeout: self.request_timeout, + source: self.source, + } + } + #[doc = "Include the stack trace of returned errors."] + pub fn error_trace(mut self, error_trace: bool) -> Self { + self.error_trace = Some(error_trace); + self + } + #[doc = "A comma-separated list of filters used to reduce the response."] + pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self { + self.filter_path = Some(filter_path); + self + } + #[doc = "Adds a HTTP header"] + pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self { + self.headers.insert(key, value); + self + } + #[doc = "Return human readable values for statistics."] + pub fn human(mut self, human: bool) -> Self { + self.human = Some(human); + self + } + #[doc = "Pretty format the returned JSON response."] + pub fn pretty(mut self, pretty: bool) -> Self { + self.pretty = Some(pretty); + self + } + #[doc = "If `true` (the default) 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` then do nothing with refreshes."] + pub fn refresh(mut self, refresh: Refresh) -> Self { + self.refresh = Some(refresh); + self + } + #[doc = "Sets a request timeout for this API call.\n\nThe timeout is applied from when the request starts connecting until the response body has finished."] + pub fn request_timeout(mut self, timeout: Duration) -> Self { + self.request_timeout = Some(timeout); + self + } + #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."] + pub fn source(mut self, source: &'b str) -> Self { + self.source = Some(source); + self + } + #[doc = "Creates an asynchronous call to the Security Grant Api Key API that can be awaited"] + pub async fn send(self) -> Result { + let path = self.parts.url(); + let method = Method::Post; + let headers = self.headers; + let timeout = self.request_timeout; + let query_string = { + #[serde_with::skip_serializing_none] + #[derive(Serialize)] + struct QueryParams<'b> { + error_trace: Option, + #[serde(serialize_with = "crate::client::serialize_coll_qs")] + filter_path: Option<&'b [&'b str]>, + human: Option, + pretty: Option, + refresh: Option, + source: Option<&'b str>, + } + let query_params = QueryParams { + error_trace: self.error_trace, + filter_path: self.filter_path, + human: self.human, + pretty: self.pretty, + refresh: self.refresh, + source: self.source, + }; + Some(query_params) + }; + let body = self.body; + let response = self + .transport + .send(method, &path, headers, query_string.as_ref(), body, timeout) + .await?; + Ok(response) + } +} +#[derive(Debug, Clone, PartialEq)] #[doc = "API parts for the Security Has Privileges API"] pub enum SecurityHasPrivilegesParts<'b> { #[doc = "No parts"] @@ -3785,6 +4078,13 @@ impl<'a> Security<'a> { ) -> SecurityChangePassword<'a, 'b, ()> { SecurityChangePassword::new(self.transport(), parts) } + #[doc = "[Security Clear Api Key Cache API](https://www.elastic.co/guide/en/elasticsearch/reference/7.10/security-api-clear-api-key-cache.html)\n\nClear a subset or all entries from the API key cache."] + pub fn clear_api_key_cache<'b>( + &'a self, + parts: SecurityClearApiKeyCacheParts<'b>, + ) -> SecurityClearApiKeyCache<'a, 'b, ()> { + SecurityClearApiKeyCache::new(self.transport(), parts) + } #[doc = "[Security Clear Cached Privileges API](https://www.elastic.co/guide/en/elasticsearch/reference/7.10/security-api-clear-privilege-cache.html)\n\nEvicts application privileges from the native application privileges cache."] pub fn clear_cached_privileges<'b>( &'a self, @@ -3890,6 +4190,10 @@ impl<'a> Security<'a> { pub fn get_user_privileges<'b>(&'a self) -> SecurityGetUserPrivileges<'a, 'b> { SecurityGetUserPrivileges::new(self.transport()) } + #[doc = "[Security Grant Api Key API](https://www.elastic.co/guide/en/elasticsearch/reference/7.10/security-api-grant-api-key.html)\n\nCreates an API key on behalf of another user."] + pub fn grant_api_key<'b>(&'a self) -> SecurityGrantApiKey<'a, 'b, ()> { + SecurityGrantApiKey::new(self.transport()) + } #[doc = "[Security Has Privileges API](https://www.elastic.co/guide/en/elasticsearch/reference/7.10/security-api-has-privileges.html)\n\nDetermines whether the specified user has a specified list of privileges."] pub fn has_privileges<'b>( &'a self, diff --git a/elasticsearch/src/snapshot.rs b/elasticsearch/src/snapshot.rs index a0318596..b60db029 100644 --- a/elasticsearch/src/snapshot.rs +++ b/elasticsearch/src/snapshot.rs @@ -210,6 +210,175 @@ where } } #[derive(Debug, Clone, PartialEq)] +#[doc = "API parts for the Snapshot Clone API"] +pub enum SnapshotCloneParts<'b> { + #[doc = "Repository, Snapshot and TargetSnapshot"] + RepositorySnapshotTargetSnapshot(&'b str, &'b str, &'b str), +} +impl<'b> SnapshotCloneParts<'b> { + #[doc = "Builds a relative URL path to the Snapshot Clone API"] + pub fn url(self) -> Cow<'static, str> { + match self { + SnapshotCloneParts::RepositorySnapshotTargetSnapshot( + ref repository, + ref snapshot, + ref target_snapshot, + ) => { + let encoded_repository: Cow = + percent_encode(repository.as_bytes(), PARTS_ENCODED).into(); + let encoded_snapshot: Cow = + percent_encode(snapshot.as_bytes(), PARTS_ENCODED).into(); + let encoded_target_snapshot: Cow = + percent_encode(target_snapshot.as_bytes(), PARTS_ENCODED).into(); + let mut p = String::with_capacity( + 20usize + + encoded_repository.len() + + encoded_snapshot.len() + + encoded_target_snapshot.len(), + ); + p.push_str("/_snapshot/"); + p.push_str(encoded_repository.as_ref()); + p.push_str("/"); + p.push_str(encoded_snapshot.as_ref()); + p.push_str("/_clone/"); + p.push_str(encoded_target_snapshot.as_ref()); + p.into() + } + } + } +} +#[derive(Clone, Debug)] +#[doc = "Builder for the [Snapshot Clone API](https://www.elastic.co/guide/en/elasticsearch/reference/7.10/modules-snapshots.html)\n\nClones indices from one snapshot into another snapshot in the same repository."] +pub struct SnapshotClone<'a, 'b, B> { + transport: &'a Transport, + parts: SnapshotCloneParts<'b>, + body: Option, + error_trace: Option, + filter_path: Option<&'b [&'b str]>, + headers: HeaderMap, + human: Option, + master_timeout: Option<&'b str>, + pretty: Option, + request_timeout: Option, + source: Option<&'b str>, +} +impl<'a, 'b, B> SnapshotClone<'a, 'b, B> +where + B: Body, +{ + #[doc = "Creates a new instance of [SnapshotClone] with the specified API parts"] + pub fn new(transport: &'a Transport, parts: SnapshotCloneParts<'b>) -> Self { + let headers = HeaderMap::new(); + SnapshotClone { + transport, + parts, + headers, + body: None, + error_trace: None, + filter_path: None, + human: None, + master_timeout: None, + pretty: None, + request_timeout: None, + source: None, + } + } + #[doc = "The body for the API call"] + pub fn body(self, body: T) -> SnapshotClone<'a, 'b, JsonBody> + where + T: Serialize, + { + SnapshotClone { + transport: self.transport, + parts: self.parts, + body: Some(body.into()), + error_trace: self.error_trace, + filter_path: self.filter_path, + headers: self.headers, + human: self.human, + master_timeout: self.master_timeout, + pretty: self.pretty, + request_timeout: self.request_timeout, + source: self.source, + } + } + #[doc = "Include the stack trace of returned errors."] + pub fn error_trace(mut self, error_trace: bool) -> Self { + self.error_trace = Some(error_trace); + self + } + #[doc = "A comma-separated list of filters used to reduce the response."] + pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self { + self.filter_path = Some(filter_path); + self + } + #[doc = "Adds a HTTP header"] + pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self { + self.headers.insert(key, value); + self + } + #[doc = "Return human readable values for statistics."] + pub fn human(mut self, human: bool) -> Self { + self.human = Some(human); + self + } + #[doc = "Explicit operation timeout for connection to master node"] + pub fn master_timeout(mut self, master_timeout: &'b str) -> Self { + self.master_timeout = Some(master_timeout); + self + } + #[doc = "Pretty format the returned JSON response."] + pub fn pretty(mut self, pretty: bool) -> Self { + self.pretty = Some(pretty); + self + } + #[doc = "Sets a request timeout for this API call.\n\nThe timeout is applied from when the request starts connecting until the response body has finished."] + pub fn request_timeout(mut self, timeout: Duration) -> Self { + self.request_timeout = Some(timeout); + self + } + #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."] + pub fn source(mut self, source: &'b str) -> Self { + self.source = Some(source); + self + } + #[doc = "Creates an asynchronous call to the Snapshot Clone API that can be awaited"] + pub async fn send(self) -> Result { + let path = self.parts.url(); + let method = Method::Put; + let headers = self.headers; + let timeout = self.request_timeout; + let query_string = { + #[serde_with::skip_serializing_none] + #[derive(Serialize)] + struct QueryParams<'b> { + error_trace: Option, + #[serde(serialize_with = "crate::client::serialize_coll_qs")] + filter_path: Option<&'b [&'b str]>, + human: Option, + master_timeout: Option<&'b str>, + pretty: Option, + source: Option<&'b str>, + } + let query_params = QueryParams { + error_trace: self.error_trace, + filter_path: self.filter_path, + human: self.human, + master_timeout: self.master_timeout, + pretty: self.pretty, + source: self.source, + }; + Some(query_params) + }; + let body = self.body; + let response = self + .transport + .send(method, &path, headers, query_string.as_ref(), body, timeout) + .await?; + Ok(response) + } +} +#[derive(Debug, Clone, PartialEq)] #[doc = "API parts for the Snapshot Create API"] pub enum SnapshotCreateParts<'b> { #[doc = "Repository and Snapshot"] @@ -1625,6 +1794,10 @@ impl<'a> Snapshot<'a> { ) -> SnapshotCleanupRepository<'a, 'b, ()> { SnapshotCleanupRepository::new(self.transport(), parts) } + #[doc = "[Snapshot Clone API](https://www.elastic.co/guide/en/elasticsearch/reference/7.10/modules-snapshots.html)\n\nClones indices from one snapshot into another snapshot in the same repository."] + pub fn clone<'b>(&'a self, parts: SnapshotCloneParts<'b>) -> SnapshotClone<'a, 'b, ()> { + SnapshotClone::new(self.transport(), parts) + } #[doc = "[Snapshot Create API](https://www.elastic.co/guide/en/elasticsearch/reference/7.10/modules-snapshots.html)\n\nCreates a snapshot in a repository."] pub fn create<'b>(&'a self, parts: SnapshotCreateParts<'b>) -> SnapshotCreate<'a, 'b, ()> { SnapshotCreate::new(self.transport(), parts)