Skip to content

Add x-elastic-client-meta header #171

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Apr 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .ci/test-matrix.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---

STACK_VERSION:
- 7.x-SNAPSHOT
- 7.12.0

TEST_SUITE:
- free
Expand Down
2 changes: 1 addition & 1 deletion api_generator/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "api_generator"
version = "7.11.0-alpha.1"
version = "7.12.0-alpha.1"
publish = false
description = "Generates source code for elasticsearch package, from the Elasticsearch REST API specs"
repository = "https://github.com/elastic/elasticsearch-rs"
Expand Down
3 changes: 3 additions & 0 deletions api_generator/docs/namespaces/features.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Features APIs

Allows [introspecting and managing features](https://www.elastic.co/guide/en/elasticsearch/reference/current/features-apis.html) provided by Elasticsearch and Elasticsearch plugins.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"snapshot.get_features":{
"features.get_features":{
"documentation":{
"url":"https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html",
"description":"Returns a list of features which can be snapshotted in this cluster."
"url":"https://www.elastic.co/guide/en/elasticsearch/reference/master/get-features-api.html",
"description":"Gets a list of features which can be included in snapshots using the feature_states field when creating a snapshot"
},
"stability":"stable",
"visibility":"public",
Expand All @@ -12,7 +12,7 @@
"url":{
"paths":[
{
"path":"/_snapshottable_features",
"path":"/_features",
"methods":[
"GET"
]
Expand Down
2 changes: 1 addition & 1 deletion api_generator/rest_specs/last_downloaded_version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7.x
7.12
2 changes: 1 addition & 1 deletion api_generator/src/generator/code_gen/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ impl GetPath for syn::Ty {
fn get_path(&self) -> &syn::Path {
match *self {
syn::Ty::Path(_, ref p) => &p,
ref p => panic!(format!("Expected syn::Ty::Path, but found {:?}", p)),
ref p => panic!("Expected syn::Ty::Path, but found {:?}", p),
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion elasticsearch/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "elasticsearch"
version = "7.11.0-alpha.1"
version = "7.12.0-alpha.1"
edition = "2018"
authors = ["Elastic and Contributors"]
description = "Official Elasticsearch Rust client"
Expand Down Expand Up @@ -29,6 +29,7 @@ rustls-tls = ["reqwest/rustls-tls"]
base64 = "^0.11"
bytes = "^1.0"
dyn-clone = "~1"
lazy_static = "1.4"
percent-encoding = "2.1.0"
reqwest = { version = "~0.11", default-features = false, features = ["gzip", "json"] }
url = "^2.1"
Expand All @@ -45,6 +46,7 @@ futures = "0.3.1"
http = "0.2"
hyper = { version = "0.14", default-features = false, features = ["tcp", "stream", "server"] }
os_type = "2.2"
regex="1.4"
sysinfo = "0.12.0"
textwrap = "^0.11"
tokio = { version = "1.0", default-features = false, features = ["macros", "net", "time", "rt-multi-thread"] }
Expand Down
10 changes: 9 additions & 1 deletion elasticsearch/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ extern crate rustc_version;
use rustc_version::{version_meta, Channel};

fn main() {
match version_meta().unwrap().channel {
let version = version_meta().unwrap();
match version.channel {
Channel::Stable => {
println!("cargo:rustc-cfg=RUSTC_IS_STABLE");
}
Expand All @@ -34,4 +35,11 @@ fn main() {
println!("cargo:rustc-cfg=RUSTC_IS_DEV");
}
}

let semver = version.semver;
let mut rustcv: String = format!("{}.{}.{}", semver.major, semver.minor, semver.patch);
if version.channel != Channel::Stable {
rustcv.push('p');
}
println!("cargo:rustc-env=RUSTC_VERSION={}", rustcv);
}
1 change: 1 addition & 0 deletions elasticsearch/src/.generated.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ written = [
'dangling_indices.rs',
'enrich.rs',
'eql.rs',
'features.rs',
'graph.rs',
'ilm.rs',
'indices.rs',
Expand Down
190 changes: 190 additions & 0 deletions elasticsearch/src/features.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

// -----------------------------------------------
// This file is generated, Please do not edit it manually.
// Run the following in the root of the repo to regenerate:
//
// cargo make generate-api
// -----------------------------------------------

//! Features APIs
//!
//! Allows [introspecting and managing features](https://www.elastic.co/guide/en/elasticsearch/reference/current/features-apis.html) provided by Elasticsearch and Elasticsearch plugins.

#![allow(unused_imports)]
use crate::{
client::Elasticsearch,
error::Error,
http::{
headers::{HeaderMap, HeaderName, HeaderValue, ACCEPT, CONTENT_TYPE},
request::{Body, JsonBody, NdBody, PARTS_ENCODED},
response::Response,
transport::Transport,
Method,
},
params::*,
};
use percent_encoding::percent_encode;
use serde::Serialize;
use std::{borrow::Cow, time::Duration};
#[derive(Debug, Clone, PartialEq)]
#[doc = "API parts for the Features Get Features API"]
pub enum FeaturesGetFeaturesParts {
#[doc = "No parts"]
None,
}
impl FeaturesGetFeaturesParts {
#[doc = "Builds a relative URL path to the Features Get Features API"]
pub fn url(self) -> Cow<'static, str> {
match self {
FeaturesGetFeaturesParts::None => "/_features".into(),
}
}
}
#[doc = "Builder for the [Features Get Features API](https://www.elastic.co/guide/en/elasticsearch/reference/7.11/get-features-api.html)\n\nGets a list of features which can be included in snapshots using the feature_states field when creating a snapshot"]
#[derive(Clone, Debug)]
pub struct FeaturesGetFeatures<'a, 'b> {
transport: &'a Transport,
parts: FeaturesGetFeaturesParts,
error_trace: Option<bool>,
filter_path: Option<&'b [&'b str]>,
headers: HeaderMap,
human: Option<bool>,
master_timeout: Option<&'b str>,
pretty: Option<bool>,
request_timeout: Option<Duration>,
source: Option<&'b str>,
}
impl<'a, 'b> FeaturesGetFeatures<'a, 'b> {
#[doc = "Creates a new instance of [FeaturesGetFeatures]"]
pub fn new(transport: &'a Transport) -> Self {
let headers = HeaderMap::new();
FeaturesGetFeatures {
transport,
parts: FeaturesGetFeaturesParts::None,
headers,
error_trace: None,
filter_path: None,
human: None,
master_timeout: None,
pretty: None,
request_timeout: None,
source: None,
}
}
#[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 Features Get Features API that can be awaited"]
pub async fn send(self) -> Result<Response, Error> {
let path = self.parts.url();
let method = Method::Get;
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<bool>,
#[serde(serialize_with = "crate::client::serialize_coll_qs")]
filter_path: Option<&'b [&'b str]>,
human: Option<bool>,
master_timeout: Option<&'b str>,
pretty: Option<bool>,
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 = Option::<()>::None;
let response = self
.transport
.send(method, &path, headers, query_string.as_ref(), body, timeout)
.await?;
Ok(response)
}
}
#[doc = "Namespace client for Features APIs"]
pub struct Features<'a> {
transport: &'a Transport,
}
impl<'a> Features<'a> {
#[doc = "Creates a new instance of [Features]"]
pub fn new(transport: &'a Transport) -> Self {
Self { transport }
}
pub fn transport(&self) -> &Transport {
self.transport
}
#[doc = "[Features Get Features API](https://www.elastic.co/guide/en/elasticsearch/reference/7.11/get-features-api.html)\n\nGets a list of features which can be included in snapshots using the feature_states field when creating a snapshot"]
pub fn get_features<'b>(&'a self) -> FeaturesGetFeatures<'a, 'b> {
FeaturesGetFeatures::new(self.transport())
}
}
impl Elasticsearch {
#[doc = "Creates a namespace client for Features APIs"]
pub fn features(&self) -> Features {
Features::new(self.transport())
}
}
Loading