#[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())),
)
}
}