pub mod dump;
#[derive(Debug, Clone)]
pub struct CloudinitClient<T> {
client: T,
path: String,
}
impl<T> CloudinitClient<T>
where
T: crate::client::Client,
{
pub fn new(client: T, parent_path: &str) -> Self {
Self {
client,
path: format!("{}{}", parent_path, "/cloudinit"),
}
}
}
impl<T> CloudinitClient<T>
where
T: crate::client::Client,
{
#[doc = "Get the cloudinit configuration with both current and pending values."]
#[doc = ""]
#[doc = "Permission check: perm(\"/vms/{vmid}\", [\"VM.Audit\"])"]
pub async fn get(&self) -> Result<Vec<GetOutputItems>, T::Error> {
let path = self.path.to_string();
let optional_vec: Option<Vec<GetOutputItems>> = self.client.get(&path, &()).await?;
Ok(optional_vec.unwrap_or_default())
}
}
impl<T> CloudinitClient<T>
where
T: crate::client::Client,
{
#[doc = "Regenerate and change cloudinit config drive."]
#[doc = ""]
#[doc = "Permission check: perm(\"/vms/{vmid}\", [\"VM.Config.Cloudinit\"])"]
pub async fn put(&self) -> Result<(), T::Error> {
let path = self.path.to_string();
self.client.put(&path, &()).await
}
}
impl GetOutputItems {
pub fn new(key: String) -> Self {
Self {
key,
delete: ::std::default::Default::default(),
pending: ::std::default::Default::default(),
value: ::std::default::Default::default(),
additional_properties: ::std::default::Default::default(),
}
}
}
#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
pub struct GetOutputItems {
#[serde(skip_serializing_if = "Option::is_none", default)]
#[doc = "Indicates a pending delete request if present and not 0."]
#[doc = ""]
pub delete: Option<DeleteInt>,
#[doc = "Configuration option name."]
#[doc = ""]
pub key: String,
#[serde(skip_serializing_if = "Option::is_none", default)]
#[doc = "The new pending value."]
#[doc = ""]
pub pending: Option<String>,
#[serde(skip_serializing_if = "Option::is_none", default)]
#[doc = "Value as it was used to generate the current cloudinit image."]
#[doc = ""]
pub value: Option<String>,
#[serde(
flatten,
default,
skip_serializing_if = "::std::collections::HashMap::is_empty"
)]
pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
}
#[derive(Debug, Clone, Copy, PartialEq, PartialOrd)]
pub struct DeleteInt(i128);
impl crate::types::bounded_integer::BoundedInteger for DeleteInt {
const MIN: Option<i128> = Some(0i128);
const MAX: Option<i128> = Some(1i128);
const DEFAULT: Option<i128> = None::<i128>;
const TYPE_DESCRIPTION: &'static str = "an integer between 0 and 1";
fn get(&self) -> i128 {
self.0
}
fn new(value: i128) -> Result<Self, crate::types::bounded_integer::BoundedIntegerError> {
Self::validate(value)?;
Ok(Self(value))
}
}
impl std::convert::TryFrom<i128> for DeleteInt {
type Error = crate::types::bounded_integer::BoundedIntegerError;
fn try_from(value: i128) -> Result<Self, Self::Error> {
crate::types::bounded_integer::BoundedInteger::new(value)
}
}
impl ::serde::Serialize for DeleteInt {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: ::serde::Serializer,
{
crate::types::bounded_integer::serialize_bounded_integer(self, serializer)
}
}
impl<'de> ::serde::Deserialize<'de> for DeleteInt {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
crate::types::bounded_integer::deserialize_bounded_integer(deserializer)
}
}
impl<T> CloudinitClient<T>
where
T: crate::client::Client,
{
pub fn dump(&self) -> dump::DumpClient<T> {
dump::DumpClient::<T>::new(self.client.clone(), &self.path)
}
}