#[derive(Clone, Debug, PartialEq, ::serde::Serialize, ::serde::Deserialize)]
#[non_exhaustive]
pub struct UnassignedInformation {
#[serde(skip_serializing_if = "::core::option::Option::is_none")]
pub at: ::core::option::Option<crate::DateTime>,
#[serde(skip_serializing_if = "::core::option::Option::is_none")]
pub last_allocation_status: ::core::option::Option<::std::string::String>,
#[serde(skip_serializing_if = "::core::option::Option::is_none")]
pub reason:
::core::option::Option<crate::cluster::allocation_explain::UnassignedInformationReason>,
#[serde(skip_serializing_if = "::core::option::Option::is_none")]
pub details: ::core::option::Option<::std::string::String>,
#[serde(skip_serializing_if = "::core::option::Option::is_none")]
pub failed_allocation_attempts: ::core::option::Option<i32>,
#[serde(skip_serializing_if = "::core::option::Option::is_none")]
pub delayed: ::core::option::Option<bool>,
#[serde(skip_serializing_if = "::core::option::Option::is_none")]
pub allocation_status: ::core::option::Option<::std::string::String>,
}
impl UnassignedInformation {
pub fn new(
at: impl ::core::convert::Into<crate::DateTime>,
reason: impl ::core::convert::Into<
crate::cluster::allocation_explain::UnassignedInformationReason,
>,
) -> Self {
Self {
at: ::core::option::Option::Some(at.into()),
last_allocation_status: ::core::option::Option::None,
reason: ::core::option::Option::Some(reason.into()),
details: ::core::option::Option::None,
failed_allocation_attempts: ::core::option::Option::None,
delayed: ::core::option::Option::None,
allocation_status: ::core::option::Option::None,
}
}
}
impl UnassignedInformation {
pub fn last_allocation_status(
mut self,
value: impl ::core::convert::Into<::std::string::String>,
) -> Self {
self.last_allocation_status = ::core::option::Option::Some(value.into());
self
}
pub fn details(mut self, value: impl ::core::convert::Into<::std::string::String>) -> Self {
self.details = ::core::option::Option::Some(value.into());
self
}
pub fn failed_allocation_attempts(mut self, value: i32) -> Self {
self.failed_allocation_attempts = ::core::option::Option::Some(value.into());
self
}
pub fn delayed(mut self, value: bool) -> Self {
self.delayed = ::core::option::Option::Some(value.into());
self
}
pub fn allocation_status(
mut self,
value: impl ::core::convert::Into<::std::string::String>,
) -> Self {
self.allocation_status = ::core::option::Option::Some(value.into());
self
}
}
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum UnassignedInformationReason {
INDEXCREATED,
CLUSTERRECOVERED,
INDEXREOPENED,
DANGLINGINDEXIMPORTED,
NEWINDEXRESTORED,
EXISTINGINDEXRESTORED,
REPLICAADDED,
ALLOCATIONFAILED,
NODELEFT,
REROUTECANCELLED,
REINITIALIZED,
REALLOCATEDREPLICA,
PRIMARYFAILED,
FORCEDEMPTYPRIMARY,
MANUALALLOCATION,
Raw(::std::string::String),
}
impl UnassignedInformationReason {
pub fn as_str(&self) -> &str {
match self {
Self::INDEXCREATED => "INDEX_CREATED",
Self::CLUSTERRECOVERED => "CLUSTER_RECOVERED",
Self::INDEXREOPENED => "INDEX_REOPENED",
Self::DANGLINGINDEXIMPORTED => "DANGLING_INDEX_IMPORTED",
Self::NEWINDEXRESTORED => "NEW_INDEX_RESTORED",
Self::EXISTINGINDEXRESTORED => "EXISTING_INDEX_RESTORED",
Self::REPLICAADDED => "REPLICA_ADDED",
Self::ALLOCATIONFAILED => "ALLOCATION_FAILED",
Self::NODELEFT => "NODE_LEFT",
Self::REROUTECANCELLED => "REROUTE_CANCELLED",
Self::REINITIALIZED => "REINITIALIZED",
Self::REALLOCATEDREPLICA => "REALLOCATED_REPLICA",
Self::PRIMARYFAILED => "PRIMARY_FAILED",
Self::FORCEDEMPTYPRIMARY => "FORCED_EMPTY_PRIMARY",
Self::MANUALALLOCATION => "MANUAL_ALLOCATION",
Self::Raw(value) => value,
}
}
pub fn from_known(value: &str) -> ::core::option::Option<Self> {
match value {
"INDEX_CREATED" => ::core::option::Option::Some(Self::INDEXCREATED),
"CLUSTER_RECOVERED" => ::core::option::Option::Some(Self::CLUSTERRECOVERED),
"INDEX_REOPENED" => ::core::option::Option::Some(Self::INDEXREOPENED),
"DANGLING_INDEX_IMPORTED" => ::core::option::Option::Some(Self::DANGLINGINDEXIMPORTED),
"NEW_INDEX_RESTORED" => ::core::option::Option::Some(Self::NEWINDEXRESTORED),
"EXISTING_INDEX_RESTORED" => ::core::option::Option::Some(Self::EXISTINGINDEXRESTORED),
"REPLICA_ADDED" => ::core::option::Option::Some(Self::REPLICAADDED),
"ALLOCATION_FAILED" => ::core::option::Option::Some(Self::ALLOCATIONFAILED),
"NODE_LEFT" => ::core::option::Option::Some(Self::NODELEFT),
"REROUTE_CANCELLED" => ::core::option::Option::Some(Self::REROUTECANCELLED),
"REINITIALIZED" => ::core::option::Option::Some(Self::REINITIALIZED),
"REALLOCATED_REPLICA" => ::core::option::Option::Some(Self::REALLOCATEDREPLICA),
"PRIMARY_FAILED" => ::core::option::Option::Some(Self::PRIMARYFAILED),
"FORCED_EMPTY_PRIMARY" => ::core::option::Option::Some(Self::FORCEDEMPTYPRIMARY),
"MANUAL_ALLOCATION" => ::core::option::Option::Some(Self::MANUALALLOCATION),
_ => ::core::option::Option::None,
}
}
}
impl ::serde::Serialize for UnassignedInformationReason {
fn serialize<S__: ::serde::Serializer>(
&self,
serializer: S__,
) -> ::core::result::Result<S__::Ok, S__::Error> {
serializer.serialize_str(self.as_str())
}
}
impl<'de> ::serde::Deserialize<'de> for UnassignedInformationReason {
fn deserialize<D__: ::serde::Deserializer<'de>>(
deserializer: D__,
) -> ::core::result::Result<Self, D__::Error> {
::oxsearch_core::__private::deserialize_string_enum(
deserializer,
"UnassignedInformationReason",
|value| Self::from_known(value).unwrap_or_else(|| Self::Raw(value.to_owned())),
)
}
}