oxsearch-sql 0.2.0

SQL for oxsearch, generated from the Elasticsearch specification: queries, cursors and their translation into search requests
Documentation
// Generated by `cargo run -p xtask -- generate` from elastic/elasticsearch-specification 9.5 at
// 84bf510a907bae62ffe29af35f516af287a79eab. Don't edit it: change the generator.

/// Get the async SQL search status.
///
/// Get the current status of an async SQL search or a stored synchronous SQL search.
#[derive(Clone, Debug, PartialEq)]
#[non_exhaustive]
pub struct Request {
    // Path parameters.
    /// The identifier for the search.
    pub id: ::oxsearch_core::Id,
}

impl Request {
    /// A `Request` with its required properties set.
    pub fn new(id: impl ::core::convert::Into<::oxsearch_core::Id>) -> Self {
        Self { id: id.into() }
    }
}

impl Request {}

#[derive(Clone, Debug, PartialEq, ::serde::Serialize, ::serde::Deserialize)]
#[non_exhaustive]
pub struct Response {
    /// The timestamp, in milliseconds since the Unix epoch, when Elasticsearch will delete the search and its results, even if the search is still running.
    #[serde(skip_serializing_if = "::core::option::Option::is_none")]
    pub expiration_time_in_millis: ::core::option::Option<::oxsearch_core::UnitMillis>,
    /// The identifier for the search.
    #[serde(skip_serializing_if = "::core::option::Option::is_none")]
    pub id: ::core::option::Option<::std::string::String>,
    /// If `true`, the search is still running.
    /// If `false`, the search has finished.
    #[serde(skip_serializing_if = "::core::option::Option::is_none")]
    pub is_running: ::core::option::Option<bool>,
    /// If `true`, the response does not contain complete search results.
    /// If `is_partial` is `true` and `is_running` is `true`, the search is still running.
    /// If `is_partial` is `true` but `is_running` is `false`, the results are partial due to a failure or timeout.
    #[serde(skip_serializing_if = "::core::option::Option::is_none")]
    pub is_partial: ::core::option::Option<bool>,
    /// The timestamp, in milliseconds since the Unix epoch, when the search started.
    /// The API returns this property only for running searches.
    #[serde(skip_serializing_if = "::core::option::Option::is_none")]
    pub start_time_in_millis: ::core::option::Option<::oxsearch_core::UnitMillis>,
    /// The HTTP status code for the search.
    /// The API returns this property only for completed searches.
    #[serde(skip_serializing_if = "::core::option::Option::is_none")]
    pub completion_status: ::core::option::Option<u32>,
}

impl Response {
    /// A `Response` with its required properties set.
    pub fn new(
        expiration_time_in_millis: impl ::core::convert::Into<::oxsearch_core::UnitMillis>,
        id: impl ::core::convert::Into<::std::string::String>,
        is_running: bool,
        is_partial: bool,
        start_time_in_millis: impl ::core::convert::Into<::oxsearch_core::UnitMillis>,
    ) -> Self {
        Self {
            expiration_time_in_millis: ::core::option::Option::Some(
                expiration_time_in_millis.into(),
            ),
            id: ::core::option::Option::Some(id.into()),
            is_running: ::core::option::Option::Some(is_running.into()),
            is_partial: ::core::option::Option::Some(is_partial.into()),
            start_time_in_millis: ::core::option::Option::Some(start_time_in_millis.into()),
            completion_status: ::core::option::Option::None,
        }
    }
}

impl Response {
    /// Sets `completion_status`.
    pub fn completion_status(mut self, value: u32) -> Self {
        self.completion_status = ::core::option::Option::Some(value.into());
        self
    }
}

impl ::oxsearch_core::Endpoint for Request {
    type Response = crate::get_async_status::Response;

    fn name(&self) -> &'static str {
        "sql.get_async_status"
    }

    fn route(&self) -> ::core::result::Result<::oxsearch_core::Route, ::oxsearch_core::Error> {
        if let (::core::option::Option::Some(p0),) = (::core::option::Option::Some(&self.id),) {
            return ::core::result::Result::Ok(::oxsearch_core::Route::new(
                ::oxsearch_core::Method::Get,
                format!(
                    "/_sql/async/status/{}",
                    ::oxsearch_core::__private::path_param("id", p0)?
                ),
            ));
        }
        ::core::result::Result::Err(::oxsearch_core::__private::no_route(self.name()))
    }

    fn query(
        &self,
    ) -> ::core::result::Result<
        ::std::vec::Vec<(&'static str, ::std::string::String)>,
        ::oxsearch_core::Error,
    > {
        ::core::result::Result::Ok(::std::vec::Vec::new())
    }

    fn body(
        &self,
    ) -> ::core::result::Result<::core::option::Option<::oxsearch_core::Body>, ::oxsearch_core::Error>
    {
        ::core::result::Result::Ok(::core::option::Option::None)
    }
}