#[derive(Debug, Clone)]
pub struct IdClient<T> {
client: T,
path: String,
}
impl<T> IdClient<T>
where
T: crate::client::Client,
{
pub fn new(client: T, parent_path: &str, id: &str) -> Self {
Self {
client,
path: format!("{}/{}", parent_path, id),
}
}
}
impl<T> IdClient<T>
where
T: crate::client::Client,
{
#[doc = "Mark replication job for removal."]
#[doc = ""]
#[doc = "Requires the VM.Replicate permission on /vms/\\<vmid\\>."]
pub async fn delete(&self, params: DeleteParams) -> Result<(), T::Error> {
let path = self.path.to_string();
self.client.delete(&path, ¶ms).await
}
}
impl<T> IdClient<T>
where
T: crate::client::Client,
{
#[doc = "Read replication job configuration."]
#[doc = ""]
#[doc = "Requires the VM.Audit permission on /vms/\\<vmid\\>."]
pub async fn get(&self) -> Result<GetOutput, T::Error> {
let path = self.path.to_string();
self.client.get(&path, &()).await
}
}
impl<T> IdClient<T>
where
T: crate::client::Client,
{
#[doc = "Update replication job configuration."]
#[doc = ""]
#[doc = "Requires the VM.Replicate permission on /vms/\\<vmid\\>."]
pub async fn put(&self, params: PutParams) -> Result<(), T::Error> {
let path = self.path.to_string();
self.client.put(&path, ¶ms).await
}
}
#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, Default)]
pub struct DeleteParams {
#[serde(
serialize_with = "crate::types::serialize_bool_optional",
deserialize_with = "crate::types::deserialize_bool_optional"
)]
#[serde(skip_serializing_if = "Option::is_none", default)]
#[doc = "Will remove the jobconfig entry, but will not cleanup."]
#[doc = ""]
pub force: Option<bool>,
#[serde(
serialize_with = "crate::types::serialize_bool_optional",
deserialize_with = "crate::types::deserialize_bool_optional"
)]
#[serde(skip_serializing_if = "Option::is_none", default)]
#[doc = "Keep replicated data at target (do not remove)."]
#[doc = ""]
pub keep: Option<bool>,
#[serde(
flatten,
default,
skip_serializing_if = "::std::collections::HashMap::is_empty"
)]
pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
}
impl GetOutput {
pub fn new(guest: i64, id: IdStr, jobnum: i64, target: String, ty: Type) -> Self {
Self {
guest,
id,
jobnum,
target,
ty,
comment: ::std::default::Default::default(),
digest: ::std::default::Default::default(),
disable: ::std::default::Default::default(),
rate: ::std::default::Default::default(),
remove_job: ::std::default::Default::default(),
schedule: ::std::default::Default::default(),
source: ::std::default::Default::default(),
additional_properties: ::std::default::Default::default(),
}
}
}
#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
pub struct GetOutput {
#[serde(skip_serializing_if = "Option::is_none", default)]
#[doc = "Description."]
#[doc = ""]
pub comment: Option<CommentStr>,
#[serde(skip_serializing_if = "Option::is_none", default)]
#[doc = "Prevent changes if current configuration file has a different digest. This can be used to prevent concurrent modifications."]
#[doc = ""]
pub digest: Option<DigestStr>,
#[serde(
serialize_with = "crate::types::serialize_bool_optional",
deserialize_with = "crate::types::deserialize_bool_optional"
)]
#[serde(skip_serializing_if = "Option::is_none", default)]
#[doc = "Flag to disable/deactivate the entry."]
#[doc = ""]
pub disable: Option<bool>,
#[serde(
serialize_with = "crate::types::serialize_int",
deserialize_with = "crate::types::deserialize_int"
)]
#[doc = "Guest ID."]
#[doc = ""]
pub guest: i64,
#[doc = "Replication Job ID. The ID is composed of a Guest ID and a job number, separated by a hyphen, i.e. '\\\\<GUEST\\\\>-\\\\<JOBNUM\\\\>'."]
#[doc = ""]
pub id: IdStr,
#[serde(
serialize_with = "crate::types::serialize_int",
deserialize_with = "crate::types::deserialize_int"
)]
#[doc = "Unique, sequential ID assigned to each job."]
#[doc = ""]
pub jobnum: i64,
#[serde(skip_serializing_if = "Option::is_none", default)]
#[doc = "Rate limit in mbps (megabytes per second) as floating point number."]
#[doc = ""]
pub rate: Option<RateNum>,
#[serde(skip_serializing_if = "Option::is_none", default)]
#[doc = "Mark the replication job for removal. The job will remove all local replication snapshots. When set to 'full', it also tries to remove replicated volumes on the target. The job then removes itself from the configuration file."]
#[doc = ""]
pub remove_job: Option<RemoveJob>,
#[serde(skip_serializing_if = "Option::is_none", default)]
#[doc = "Storage replication schedule. The format is a subset of `systemd` calendar events."]
#[doc = ""]
pub schedule: Option<ScheduleStr>,
#[serde(skip_serializing_if = "Option::is_none", default)]
#[doc = "For internal use, to detect if the guest was stolen."]
#[doc = ""]
pub source: Option<String>,
#[doc = "Target node."]
#[doc = ""]
pub target: String,
#[serde(rename = "type")]
#[doc = "Section type."]
#[doc = ""]
pub ty: Type,
#[serde(
flatten,
default,
skip_serializing_if = "::std::collections::HashMap::is_empty"
)]
pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
}
#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, Default)]
pub struct PutParams {
#[serde(skip_serializing_if = "Option::is_none", default)]
#[doc = "Description."]
#[doc = ""]
pub comment: Option<CommentStr>,
#[serde(skip_serializing_if = "Option::is_none", default)]
#[doc = "A list of settings you want to delete."]
#[doc = ""]
pub delete: Option<DeleteStr>,
#[serde(skip_serializing_if = "Option::is_none", default)]
#[doc = "Prevent changes if current configuration file has a different digest. This can be used to prevent concurrent modifications."]
#[doc = ""]
pub digest: Option<DigestStr>,
#[serde(
serialize_with = "crate::types::serialize_bool_optional",
deserialize_with = "crate::types::deserialize_bool_optional"
)]
#[serde(skip_serializing_if = "Option::is_none", default)]
#[doc = "Flag to disable/deactivate the entry."]
#[doc = ""]
pub disable: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none", default)]
#[doc = "Rate limit in mbps (megabytes per second) as floating point number."]
#[doc = ""]
pub rate: Option<RateNum>,
#[serde(skip_serializing_if = "Option::is_none", default)]
#[doc = "Mark the replication job for removal. The job will remove all local replication snapshots. When set to 'full', it also tries to remove replicated volumes on the target. The job then removes itself from the configuration file."]
#[doc = ""]
pub remove_job: Option<RemoveJob>,
#[serde(skip_serializing_if = "Option::is_none", default)]
#[doc = "Storage replication schedule. The format is a subset of `systemd` calendar events."]
#[doc = ""]
pub schedule: Option<ScheduleStr>,
#[serde(skip_serializing_if = "Option::is_none", default)]
#[doc = "For internal use, to detect if the guest was stolen."]
#[doc = ""]
pub source: Option<String>,
#[serde(
flatten,
default,
skip_serializing_if = "::std::collections::HashMap::is_empty"
)]
pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
}
#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, PartialEq)]
#[doc = "Mark the replication job for removal. The job will remove all local replication snapshots. When set to 'full', it also tries to remove replicated volumes on the target. The job then removes itself from the configuration file."]
#[doc = ""]
pub enum RemoveJob {
#[serde(rename = "full")]
Full,
#[serde(rename = "local")]
Local,
}
impl TryFrom<&str> for RemoveJob {
type Error = String;
fn try_from(value: &str) -> Result<Self, <Self as TryFrom<&str>>::Error> {
match value {
"full" => Ok(Self::Full),
"local" => Ok(Self::Local),
v => Err(format!("Unknown variant {v}")),
}
}
}
#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, PartialEq)]
#[doc = "Section type."]
#[doc = ""]
pub enum Type {
#[serde(rename = "local")]
Local,
}
impl TryFrom<&str> for Type {
type Error = String;
fn try_from(value: &str) -> Result<Self, <Self as TryFrom<&str>>::Error> {
match value {
"local" => Ok(Self::Local),
v => Err(format!("Unknown variant {v}")),
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, PartialOrd)]
pub struct RateNum(f64);
impl crate::types::bounded_number::BoundedNumber for RateNum {
const MIN: Option<f64> = Some(1f64);
const MAX: Option<f64> = None::<f64>;
const DEFAULT: Option<f64> = None::<f64>;
const TYPE_DESCRIPTION: &'static str = "an number greater than or equal to 1";
fn get(&self) -> f64 {
self.0
}
fn new(value: f64) -> Result<Self, crate::types::bounded_number::BoundedNumberError> {
Self::validate(value)?;
Ok(Self(value))
}
}
impl std::convert::TryFrom<f64> for RateNum {
type Error = crate::types::bounded_number::BoundedNumberError;
fn try_from(value: f64) -> Result<Self, Self::Error> {
crate::types::bounded_number::BoundedNumber::new(value)
}
}
impl std::convert::TryFrom<f32> for RateNum {
type Error = crate::types::bounded_number::BoundedNumberError;
fn try_from(value: f32) -> Result<Self, Self::Error> {
crate::types::bounded_number::BoundedNumber::new(value as f64)
}
}
impl std::convert::TryFrom<i32> for RateNum {
type Error = crate::types::bounded_number::BoundedNumberError;
fn try_from(value: i32) -> Result<Self, Self::Error> {
crate::types::bounded_number::BoundedNumber::new(value as f64)
}
}
impl std::convert::TryFrom<i64> for RateNum {
type Error = crate::types::bounded_number::BoundedNumberError;
fn try_from(value: i64) -> Result<Self, Self::Error> {
crate::types::bounded_number::BoundedNumber::new(value as f64)
}
}
impl ::serde::Serialize for RateNum {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: ::serde::Serializer,
{
crate::types::bounded_number::serialize_bounded_number(self, serializer)
}
}
impl<'de> ::serde::Deserialize<'de> for RateNum {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
crate::types::bounded_number::deserialize_bounded_number(deserializer)
}
}
#[derive(Debug, Clone, PartialEq, PartialOrd)]
pub struct CommentStr {
value: String,
}
impl crate::types::bounded_string::BoundedString for CommentStr {
const MIN_LENGTH: Option<usize> = None::<usize>;
const MAX_LENGTH: Option<usize> = Some(4096usize);
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 4096";
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 CommentStr {
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 CommentStr {
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 CommentStr {
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 DeleteStr {
value: String,
}
impl crate::types::bounded_string::BoundedString for DeleteStr {
const MIN_LENGTH: Option<usize> = None::<usize>;
const MAX_LENGTH: Option<usize> = Some(4096usize);
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 4096";
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 DeleteStr {
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 DeleteStr {
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 DeleteStr {
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 DigestStr {
value: String,
}
impl crate::types::bounded_string::BoundedString for DigestStr {
const MIN_LENGTH: Option<usize> = None::<usize>;
const MAX_LENGTH: Option<usize> = Some(64usize);
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 64";
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 DigestStr {
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 DigestStr {
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 DigestStr {
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 IdStr {
value: String,
}
impl crate::types::bounded_string::BoundedString for IdStr {
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("[1-9][0-9]{2,8}-\\d{1,9}");
const TYPE_DESCRIPTION: &'static str =
"a string with pattern r\"[1-9][0-9]{2,8}-\\d{1,9}\" 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 IdStr {
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 IdStr {
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 IdStr {
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 ScheduleStr {
value: String,
}
impl crate::types::bounded_string::BoundedString for ScheduleStr {
const MIN_LENGTH: Option<usize> = None::<usize>;
const MAX_LENGTH: Option<usize> = Some(128usize);
const DEFAULT: Option<&'static str> = Some("*/15");
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 ScheduleStr {
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 ScheduleStr {
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 ScheduleStr {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
crate::types::bounded_string::deserialize_bounded_string(deserializer)
}
}