Skip to main content

oxsearch_sql/generated/
get_async.rs

1// Generated by `cargo run -p xtask -- generate` from elastic/elasticsearch-specification 9.5 at
2// 84bf510a907bae62ffe29af35f516af287a79eab. Don't edit it: change the generator.
3
4/// Get async SQL search results.
5///
6/// Get the current status and available results for an async SQL search or stored synchronous SQL search.
7///
8/// If the Elasticsearch security features are enabled, only the user who first submitted the SQL search can retrieve the search using this API.
9#[derive(Clone, Debug, PartialEq)]
10#[non_exhaustive]
11pub struct Request {
12    // Path parameters.
13    /// The identifier for the search.
14    pub id: ::oxsearch_core::Id,
15    // Query parameters.
16    /// The separator for CSV results.
17    /// The API supports this parameter only for CSV responses.
18    pub delimiter: ::core::option::Option<::std::string::String>,
19    /// The format for the response.
20    /// You must specify a format using this parameter or the `Accept` HTTP header.
21    /// If you specify both, the API uses this parameter.
22    pub format: ::core::option::Option<::std::string::String>,
23    /// The retention period for the search and its results.
24    /// It defaults to the `keep_alive` period for the original SQL search.
25    pub keep_alive: ::core::option::Option<::oxsearch_core::Duration>,
26    /// The period to wait for complete results.
27    /// It defaults to no timeout, meaning the request waits for complete search results.
28    pub wait_for_completion_timeout: ::core::option::Option<::oxsearch_core::Duration>,
29}
30
31impl Request {
32    /// A `Request` with its required properties set.
33    pub fn new(id: impl ::core::convert::Into<::oxsearch_core::Id>) -> Self {
34        Self {
35            id: id.into(),
36            delimiter: ::core::option::Option::None,
37            format: ::core::option::Option::None,
38            keep_alive: ::core::option::Option::None,
39            wait_for_completion_timeout: ::core::option::Option::None,
40        }
41    }
42}
43
44impl Request {
45    /// Sets `delimiter`.
46    pub fn delimiter(mut self, value: impl ::core::convert::Into<::std::string::String>) -> Self {
47        self.delimiter = ::core::option::Option::Some(value.into());
48        self
49    }
50    /// Sets `format`.
51    pub fn format(mut self, value: impl ::core::convert::Into<::std::string::String>) -> Self {
52        self.format = ::core::option::Option::Some(value.into());
53        self
54    }
55    /// Sets `keep_alive`.
56    pub fn keep_alive(
57        mut self,
58        value: impl ::core::convert::Into<::oxsearch_core::Duration>,
59    ) -> Self {
60        self.keep_alive = ::core::option::Option::Some(value.into());
61        self
62    }
63    /// Sets `wait_for_completion_timeout`.
64    pub fn wait_for_completion_timeout(
65        mut self,
66        value: impl ::core::convert::Into<::oxsearch_core::Duration>,
67    ) -> Self {
68        self.wait_for_completion_timeout = ::core::option::Option::Some(value.into());
69        self
70    }
71}
72
73#[derive(Clone, Debug, PartialEq, ::serde::Serialize, ::serde::Deserialize)]
74#[non_exhaustive]
75pub struct Response {
76    /// Identifier for the search.
77    /// This value is returned only for async and saved synchronous searches.
78    /// For CSV, TSV, and TXT responses, this value is returned in the `Async-ID` HTTP header.
79    #[serde(skip_serializing_if = "::core::option::Option::is_none")]
80    pub id: ::core::option::Option<::oxsearch_core::Id>,
81    /// If `true`, the search is still running.
82    /// If `false`, the search has finished.
83    /// This value is returned only for async and saved synchronous searches.
84    /// For CSV, TSV, and TXT responses, this value is returned in the `Async-partial` HTTP header.
85    #[serde(skip_serializing_if = "::core::option::Option::is_none")]
86    pub is_running: ::core::option::Option<bool>,
87    /// If `true`, the response does not contain complete search results.
88    /// If `is_partial` is `true` and `is_running` is `true`, the search is still running.
89    /// If `is_partial` is `true` but `is_running` is `false`, the results are partial due to a failure or timeout.
90    /// This value is returned only for async and saved synchronous searches.
91    /// For CSV, TSV, and TXT responses, this value is returned in the `Async-partial` HTTP header.
92    #[serde(skip_serializing_if = "::core::option::Option::is_none")]
93    pub is_partial: ::core::option::Option<bool>,
94    /// Column headings for the search results. Each object is a column.
95    #[serde(skip_serializing_if = "::core::option::Option::is_none")]
96    pub columns: ::core::option::Option<::std::vec::Vec<crate::Column>>,
97    /// The cursor for the next set of paginated results.
98    /// For CSV, TSV, and TXT responses, this value is returned in the `Cursor` HTTP header.
99    #[serde(skip_serializing_if = "::core::option::Option::is_none")]
100    pub cursor: ::core::option::Option<::std::string::String>,
101    /// The values for the search results.
102    #[serde(default = "::core::default::Default::default")]
103    pub rows: ::std::vec::Vec<crate::Row>,
104}
105
106impl Response {
107    /// A `Response` with its required properties set.
108    pub fn new(
109        id: impl ::core::convert::Into<::oxsearch_core::Id>,
110        is_running: bool,
111        is_partial: bool,
112        rows: impl ::core::convert::Into<::std::vec::Vec<crate::Row>>,
113    ) -> Self {
114        Self {
115            id: ::core::option::Option::Some(id.into()),
116            is_running: ::core::option::Option::Some(is_running.into()),
117            is_partial: ::core::option::Option::Some(is_partial.into()),
118            columns: ::core::option::Option::None,
119            cursor: ::core::option::Option::None,
120            rows: rows.into(),
121        }
122    }
123}
124
125impl Response {
126    /// Sets `columns`.
127    pub fn columns(
128        mut self,
129        value: impl ::core::convert::Into<::std::vec::Vec<crate::Column>>,
130    ) -> Self {
131        self.columns = ::core::option::Option::Some(value.into());
132        self
133    }
134    /// Sets `cursor`.
135    pub fn cursor(mut self, value: impl ::core::convert::Into<::std::string::String>) -> Self {
136        self.cursor = ::core::option::Option::Some(value.into());
137        self
138    }
139}
140
141impl ::oxsearch_core::Endpoint for Request {
142    type Response = crate::get_async::Response;
143
144    fn name(&self) -> &'static str {
145        "sql.get_async"
146    }
147
148    fn route(&self) -> ::core::result::Result<::oxsearch_core::Route, ::oxsearch_core::Error> {
149        if let (::core::option::Option::Some(p0),) = (::core::option::Option::Some(&self.id),) {
150            return ::core::result::Result::Ok(::oxsearch_core::Route::new(
151                ::oxsearch_core::Method::Get,
152                format!(
153                    "/_sql/async/{}",
154                    ::oxsearch_core::__private::path_param("id", p0)?
155                ),
156            ));
157        }
158        ::core::result::Result::Err(::oxsearch_core::__private::no_route(self.name()))
159    }
160
161    fn query(
162        &self,
163    ) -> ::core::result::Result<
164        ::std::vec::Vec<(&'static str, ::std::string::String)>,
165        ::oxsearch_core::Error,
166    > {
167        let mut query = ::std::vec::Vec::new();
168        if let ::core::option::Option::Some(value) = &self.delimiter {
169            query.push((
170                "delimiter",
171                ::oxsearch_core::__private::query_param("delimiter", value)?,
172            ));
173        }
174        if let ::core::option::Option::Some(value) = &self.format {
175            query.push((
176                "format",
177                ::oxsearch_core::__private::query_param("format", value)?,
178            ));
179        }
180        if let ::core::option::Option::Some(value) = &self.keep_alive {
181            query.push((
182                "keep_alive",
183                ::oxsearch_core::__private::query_param("keep_alive", value)?,
184            ));
185        }
186        if let ::core::option::Option::Some(value) = &self.wait_for_completion_timeout {
187            query.push((
188                "wait_for_completion_timeout",
189                ::oxsearch_core::__private::query_param("wait_for_completion_timeout", value)?,
190            ));
191        }
192        ::core::result::Result::Ok(query)
193    }
194
195    fn body(
196        &self,
197    ) -> ::core::result::Result<::core::option::Option<::oxsearch_core::Body>, ::oxsearch_core::Error>
198    {
199        ::core::result::Result::Ok(::core::option::Option::None)
200    }
201}