Skip to main content

oxsearch_sql/generated/
get_async_status.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 the async SQL search status.
5///
6/// Get the current status of an async SQL search or a stored synchronous SQL search.
7#[derive(Clone, Debug, PartialEq)]
8#[non_exhaustive]
9pub struct Request {
10    // Path parameters.
11    /// The identifier for the search.
12    pub id: ::oxsearch_core::Id,
13}
14
15impl Request {
16    /// A `Request` with its required properties set.
17    pub fn new(id: impl ::core::convert::Into<::oxsearch_core::Id>) -> Self {
18        Self { id: id.into() }
19    }
20}
21
22impl Request {}
23
24#[derive(Clone, Debug, PartialEq, ::serde::Serialize, ::serde::Deserialize)]
25#[non_exhaustive]
26pub struct Response {
27    /// The timestamp, in milliseconds since the Unix epoch, when Elasticsearch will delete the search and its results, even if the search is still running.
28    #[serde(skip_serializing_if = "::core::option::Option::is_none")]
29    pub expiration_time_in_millis: ::core::option::Option<::oxsearch_core::UnitMillis>,
30    /// The identifier for the search.
31    #[serde(skip_serializing_if = "::core::option::Option::is_none")]
32    pub id: ::core::option::Option<::std::string::String>,
33    /// If `true`, the search is still running.
34    /// If `false`, the search has finished.
35    #[serde(skip_serializing_if = "::core::option::Option::is_none")]
36    pub is_running: ::core::option::Option<bool>,
37    /// If `true`, the response does not contain complete search results.
38    /// If `is_partial` is `true` and `is_running` is `true`, the search is still running.
39    /// If `is_partial` is `true` but `is_running` is `false`, the results are partial due to a failure or timeout.
40    #[serde(skip_serializing_if = "::core::option::Option::is_none")]
41    pub is_partial: ::core::option::Option<bool>,
42    /// The timestamp, in milliseconds since the Unix epoch, when the search started.
43    /// The API returns this property only for running searches.
44    #[serde(skip_serializing_if = "::core::option::Option::is_none")]
45    pub start_time_in_millis: ::core::option::Option<::oxsearch_core::UnitMillis>,
46    /// The HTTP status code for the search.
47    /// The API returns this property only for completed searches.
48    #[serde(skip_serializing_if = "::core::option::Option::is_none")]
49    pub completion_status: ::core::option::Option<u32>,
50}
51
52impl Response {
53    /// A `Response` with its required properties set.
54    pub fn new(
55        expiration_time_in_millis: impl ::core::convert::Into<::oxsearch_core::UnitMillis>,
56        id: impl ::core::convert::Into<::std::string::String>,
57        is_running: bool,
58        is_partial: bool,
59        start_time_in_millis: impl ::core::convert::Into<::oxsearch_core::UnitMillis>,
60    ) -> Self {
61        Self {
62            expiration_time_in_millis: ::core::option::Option::Some(
63                expiration_time_in_millis.into(),
64            ),
65            id: ::core::option::Option::Some(id.into()),
66            is_running: ::core::option::Option::Some(is_running.into()),
67            is_partial: ::core::option::Option::Some(is_partial.into()),
68            start_time_in_millis: ::core::option::Option::Some(start_time_in_millis.into()),
69            completion_status: ::core::option::Option::None,
70        }
71    }
72}
73
74impl Response {
75    /// Sets `completion_status`.
76    pub fn completion_status(mut self, value: u32) -> Self {
77        self.completion_status = ::core::option::Option::Some(value.into());
78        self
79    }
80}
81
82impl ::oxsearch_core::Endpoint for Request {
83    type Response = crate::get_async_status::Response;
84
85    fn name(&self) -> &'static str {
86        "sql.get_async_status"
87    }
88
89    fn route(&self) -> ::core::result::Result<::oxsearch_core::Route, ::oxsearch_core::Error> {
90        if let (::core::option::Option::Some(p0),) = (::core::option::Option::Some(&self.id),) {
91            return ::core::result::Result::Ok(::oxsearch_core::Route::new(
92                ::oxsearch_core::Method::Get,
93                format!(
94                    "/_sql/async/status/{}",
95                    ::oxsearch_core::__private::path_param("id", p0)?
96                ),
97            ));
98        }
99        ::core::result::Result::Err(::oxsearch_core::__private::no_route(self.name()))
100    }
101
102    fn query(
103        &self,
104    ) -> ::core::result::Result<
105        ::std::vec::Vec<(&'static str, ::std::string::String)>,
106        ::oxsearch_core::Error,
107    > {
108        ::core::result::Result::Ok(::std::vec::Vec::new())
109    }
110
111    fn body(
112        &self,
113    ) -> ::core::result::Result<::core::option::Option<::oxsearch_core::Body>, ::oxsearch_core::Error>
114    {
115        ::core::result::Result::Ok(::core::option::Option::None)
116    }
117}