#[derive(Debug, Clone)]
pub struct JoinClient<T> {
client: T,
path: String,
}
impl<T> JoinClient<T>
where
T: crate::client::Client,
{
pub fn new(client: T, parent_path: &str) -> Self {
Self {
client,
path: format!("{}{}", parent_path, "/join"),
}
}
}
impl<T> JoinClient<T>
where
T: crate::client::Client,
{
#[doc = "Get information needed to join this cluster over the connected node."]
#[doc = ""]
#[doc = "Permission check: perm(\"/\", [\"Sys.Audit\"])"]
pub async fn get(&self, params: GetParams) -> Result<GetOutput, T::Error> {
let path = self.path.to_string();
self.client.get(&path, ¶ms).await
}
}
impl<T> JoinClient<T>
where
T: crate::client::Client,
{
#[doc = "Joins this node into an existing cluster. If no links are given, default to IP resolved by node's hostname on single link (fallback fails for clusters with multiple links)."]
#[doc = ""]
pub async fn post(&self, params: PostParams) -> Result<String, T::Error> {
let path = self.path.to_string();
self.client.post(&path, ¶ms).await
}
}
impl GetOutput {
pub fn new(
config_digest: String,
nodelist: Vec<NodelistGetOutputNodelistItems>,
preferred_node: String,
totem: TotemGetOutputTotem,
) -> Self {
Self {
config_digest,
nodelist,
preferred_node,
totem,
}
}
}
#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
pub struct GetOutput {
pub config_digest: String,
#[serde(skip_serializing_if = "::std::vec::Vec::is_empty", default)]
pub nodelist: Vec<NodelistGetOutputNodelistItems>,
#[doc = "The cluster node name."]
#[doc = ""]
pub preferred_node: String,
pub totem: TotemGetOutputTotem,
}
#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, Default)]
pub struct GetParams {
#[serde(skip_serializing_if = "Option::is_none", default)]
#[doc = "The node for which the joinee gets the nodeinfo."]
#[doc = ""]
pub node: Option<String>,
#[serde(
flatten,
default,
skip_serializing_if = "::std::collections::HashMap::is_empty"
)]
pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
}
impl NodelistGetOutputNodelistItems {
pub fn new(
name: String,
pve_addr: ::std::net::IpAddr,
pve_fp: PveFpStr,
quorum_votes: u64,
) -> Self {
Self {
name,
pve_addr,
pve_fp,
quorum_votes,
nodeid: ::std::default::Default::default(),
ring0_addr: ::std::default::Default::default(),
additional_properties: ::std::default::Default::default(),
}
}
}
#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
pub struct NodelistGetOutputNodelistItems {
#[doc = "The cluster node name."]
#[doc = ""]
pub name: String,
#[serde(
serialize_with = "crate::types::serialize_non_zero_pos_int_optional",
deserialize_with = "crate::types::deserialize_non_zero_pos_int_optional"
)]
#[serde(skip_serializing_if = "Option::is_none", default)]
#[doc = "Node id for this node."]
#[doc = ""]
pub nodeid: Option<std::num::NonZeroU64>,
pub pve_addr: ::std::net::IpAddr,
#[doc = "Certificate SHA 256 fingerprint."]
#[doc = ""]
pub pve_fp: PveFpStr,
#[serde(
serialize_with = "crate::types::serialize_unsigned_int",
deserialize_with = "crate::types::deserialize_unsigned_int"
)]
pub quorum_votes: u64,
#[serde(skip_serializing_if = "Option::is_none", default)]
#[doc = "Address and priority information of a single corosync link. (up to 8 links supported; link0..link7)"]
#[doc = ""]
pub ring0_addr: Option<String>,
#[serde(
flatten,
default,
skip_serializing_if = "::std::collections::HashMap::is_empty"
)]
pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
}
impl PostParams {
pub fn new(fingerprint: FingerprintStr, hostname: String, password: PasswordStr) -> Self {
Self {
fingerprint,
hostname,
password,
force: ::std::default::Default::default(),
links: ::std::default::Default::default(),
nodeid: ::std::default::Default::default(),
votes: ::std::default::Default::default(),
additional_properties: ::std::default::Default::default(),
}
}
}
#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
pub struct PostParams {
#[doc = "Certificate SHA 256 fingerprint."]
#[doc = ""]
pub fingerprint: FingerprintStr,
#[serde(
serialize_with = "crate::types::serialize_bool_optional",
deserialize_with = "crate::types::deserialize_bool_optional"
)]
#[serde(skip_serializing_if = "Option::is_none", default)]
#[doc = "Do not throw error if node already exists."]
#[doc = ""]
pub force: Option<bool>,
#[doc = "Hostname (or IP) of an existing cluster member."]
#[doc = ""]
pub hostname: String,
#[serde(rename = "link[n]")]
#[serde(
serialize_with = "crate::types::serialize_multi::<NumberedLinks, _>",
deserialize_with = "crate::types::deserialize_multi::<NumberedLinks, _>"
)]
#[serde(skip_serializing_if = "::std::collections::HashMap::is_empty", default)]
#[serde(flatten)]
#[doc = "Address and priority information of a single corosync link. (up to 8 links supported; link0..link7)"]
#[doc = ""]
pub links: ::std::collections::HashMap<u32, String>,
#[serde(
serialize_with = "crate::types::serialize_non_zero_pos_int_optional",
deserialize_with = "crate::types::deserialize_non_zero_pos_int_optional"
)]
#[serde(skip_serializing_if = "Option::is_none", default)]
#[doc = "Node id for this node."]
#[doc = ""]
pub nodeid: Option<std::num::NonZeroU64>,
#[doc = "Superuser (root) password of peer node."]
#[doc = ""]
pub password: PasswordStr,
#[serde(
serialize_with = "crate::types::serialize_unsigned_int_optional",
deserialize_with = "crate::types::deserialize_unsigned_int_optional"
)]
#[serde(skip_serializing_if = "Option::is_none", default)]
#[doc = "Number of votes for this node"]
#[doc = ""]
pub votes: Option<u64>,
#[serde(
flatten,
deserialize_with = "crate::types::multi::deserialize_additional_data::<'_, PostParams, _, _>"
)]
pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
}
impl crate::types::multi::Test for PostParams {
fn test_fn() -> fn(&str) -> bool {
fn the_test(input: &str) -> bool {
let array = [
<NumberedLinks as crate::types::multi::NumberedItems>::key_matches
as fn(&str) -> bool,
];
array.iter().any(|f| f(input))
}
the_test as _
}
}
#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, Default)]
pub struct TotemGetOutputTotem {
#[serde(
flatten,
default,
skip_serializing_if = "::std::collections::HashMap::is_empty"
)]
pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
}
#[derive(Default)]
struct NumberedLinks;
impl crate::types::multi::NumberedItems for NumberedLinks {
type Item = String;
const PREFIX: &'static str = "link";
}
#[derive(Debug, Clone, PartialEq, PartialOrd)]
pub struct FingerprintStr {
value: String,
}
impl crate::types::bounded_string::BoundedString for FingerprintStr {
const MIN_LENGTH: Option<usize> = None::<usize>;
const MAX_LENGTH: Option<usize> = None::<usize>;
const DEFAULT: Option<&'static str> = None::<&'static str>;
const PATTERN: Option<&'static str> = Some("([A-Fa-f0-9]{2}:){31}[A-Fa-f0-9]{2}");
const TYPE_DESCRIPTION: &'static str =
"a string with pattern r\"([A-Fa-f0-9]{2}:){31}[A-Fa-f0-9]{2}\" and no length constraints";
fn get_value(&self) -> &str {
&self.value
}
fn new(value: String) -> Result<Self, crate::types::bounded_string::BoundedStringError> {
Self::validate(&value)?;
Ok(Self { value })
}
}
impl std::convert::TryFrom<String> for FingerprintStr {
type Error = crate::types::bounded_string::BoundedStringError;
fn try_from(value: String) -> Result<Self, Self::Error> {
crate::types::bounded_string::BoundedString::new(value)
}
}
impl ::serde::Serialize for FingerprintStr {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: ::serde::Serializer,
{
crate::types::bounded_string::serialize_bounded_string(self, serializer)
}
}
impl<'de> ::serde::Deserialize<'de> for FingerprintStr {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
crate::types::bounded_string::deserialize_bounded_string(deserializer)
}
}
#[derive(Debug, Clone, PartialEq, PartialOrd)]
pub struct PasswordStr {
value: String,
}
impl crate::types::bounded_string::BoundedString for PasswordStr {
const MIN_LENGTH: Option<usize> = None::<usize>;
const MAX_LENGTH: Option<usize> = Some(128usize);
const DEFAULT: Option<&'static str> = None::<&'static str>;
const PATTERN: Option<&'static str> = None::<&'static str>;
const TYPE_DESCRIPTION: &'static str = "a string with length at most 128";
fn get_value(&self) -> &str {
&self.value
}
fn new(value: String) -> Result<Self, crate::types::bounded_string::BoundedStringError> {
Self::validate(&value)?;
Ok(Self { value })
}
}
impl std::convert::TryFrom<String> for PasswordStr {
type Error = crate::types::bounded_string::BoundedStringError;
fn try_from(value: String) -> Result<Self, Self::Error> {
crate::types::bounded_string::BoundedString::new(value)
}
}
impl ::serde::Serialize for PasswordStr {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: ::serde::Serializer,
{
crate::types::bounded_string::serialize_bounded_string(self, serializer)
}
}
impl<'de> ::serde::Deserialize<'de> for PasswordStr {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
crate::types::bounded_string::deserialize_bounded_string(deserializer)
}
}
#[derive(Debug, Clone, PartialEq, PartialOrd)]
pub struct PveFpStr {
value: String,
}
impl crate::types::bounded_string::BoundedString for PveFpStr {
const MIN_LENGTH: Option<usize> = None::<usize>;
const MAX_LENGTH: Option<usize> = None::<usize>;
const DEFAULT: Option<&'static str> = None::<&'static str>;
const PATTERN: Option<&'static str> = Some("([A-Fa-f0-9]{2}:){31}[A-Fa-f0-9]{2}");
const TYPE_DESCRIPTION: &'static str =
"a string with pattern r\"([A-Fa-f0-9]{2}:){31}[A-Fa-f0-9]{2}\" and no length constraints";
fn get_value(&self) -> &str {
&self.value
}
fn new(value: String) -> Result<Self, crate::types::bounded_string::BoundedStringError> {
Self::validate(&value)?;
Ok(Self { value })
}
}
impl std::convert::TryFrom<String> for PveFpStr {
type Error = crate::types::bounded_string::BoundedStringError;
fn try_from(value: String) -> Result<Self, Self::Error> {
crate::types::bounded_string::BoundedString::new(value)
}
}
impl ::serde::Serialize for PveFpStr {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: ::serde::Serializer,
{
crate::types::bounded_string::serialize_bounded_string(self, serializer)
}
}
impl<'de> ::serde::Deserialize<'de> for PveFpStr {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
crate::types::bounded_string::deserialize_bounded_string(deserializer)
}
}