use reqwest;
use serde::{Deserialize, Serialize, de::Error as _};
use crate::{apis::ResponseContent, models};
use super::{Error, configuration, ContentType};
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum LxcCloneVmError {
Status400(models::PveError),
Status401(models::PveError),
Status403(models::PveError),
Status404(models::PveError),
Status500(models::PveError),
Status501(models::PveError),
Status503(models::PveError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum LxcCreateAliasError {
Status400(models::PveError),
Status401(models::PveError),
Status403(models::PveError),
Status404(models::PveError),
Status500(models::PveError),
Status501(models::PveError),
Status503(models::PveError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum LxcCreateIpError {
Status400(models::PveError),
Status401(models::PveError),
Status403(models::PveError),
Status404(models::PveError),
Status500(models::PveError),
Status501(models::PveError),
Status503(models::PveError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum LxcCreateIpsetError {
Status400(models::PveError),
Status401(models::PveError),
Status403(models::PveError),
Status404(models::PveError),
Status500(models::PveError),
Status501(models::PveError),
Status503(models::PveError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum LxcCreateRuleError {
Status400(models::PveError),
Status401(models::PveError),
Status403(models::PveError),
Status404(models::PveError),
Status500(models::PveError),
Status501(models::PveError),
Status503(models::PveError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum LxcCreateVmError {
Status400(models::PveError),
Status401(models::PveError),
Status403(models::PveError),
Status404(models::PveError),
Status500(models::PveError),
Status501(models::PveError),
Status503(models::PveError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum LxcDeleteIpsetError {
Status400(models::PveError),
Status401(models::PveError),
Status403(models::PveError),
Status404(models::PveError),
Status500(models::PveError),
Status501(models::PveError),
Status503(models::PveError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum LxcDeleteRuleError {
Status400(models::PveError),
Status401(models::PveError),
Status403(models::PveError),
Status404(models::PveError),
Status500(models::PveError),
Status501(models::PveError),
Status503(models::PveError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum LxcDelsnapshotError {
Status400(models::PveError),
Status401(models::PveError),
Status403(models::PveError),
Status404(models::PveError),
Status500(models::PveError),
Status501(models::PveError),
Status503(models::PveError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum LxcDestroyVmError {
Status400(models::PveError),
Status401(models::PveError),
Status403(models::PveError),
Status404(models::PveError),
Status500(models::PveError),
Status501(models::PveError),
Status503(models::PveError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum LxcGetAliasesError {
Status400(models::PveError),
Status401(models::PveError),
Status403(models::PveError),
Status404(models::PveError),
Status500(models::PveError),
Status501(models::PveError),
Status503(models::PveError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum LxcGetFirewallError {
Status400(models::PveError),
Status401(models::PveError),
Status403(models::PveError),
Status404(models::PveError),
Status500(models::PveError),
Status501(models::PveError),
Status503(models::PveError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum LxcGetIpsetError {
Status400(models::PveError),
Status401(models::PveError),
Status403(models::PveError),
Status404(models::PveError),
Status500(models::PveError),
Status501(models::PveError),
Status503(models::PveError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum LxcGetOptionsError {
Status400(models::PveError),
Status401(models::PveError),
Status403(models::PveError),
Status404(models::PveError),
Status500(models::PveError),
Status501(models::PveError),
Status503(models::PveError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum LxcGetRuleError {
Status400(models::PveError),
Status401(models::PveError),
Status403(models::PveError),
Status404(models::PveError),
Status500(models::PveError),
Status501(models::PveError),
Status503(models::PveError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum LxcGetRulesError {
Status400(models::PveError),
Status401(models::PveError),
Status403(models::PveError),
Status404(models::PveError),
Status500(models::PveError),
Status501(models::PveError),
Status503(models::PveError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum LxcGetSnapshotError {
Status400(models::PveError),
Status401(models::PveError),
Status403(models::PveError),
Status404(models::PveError),
Status500(models::PveError),
Status501(models::PveError),
Status503(models::PveError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum LxcGetSnapshotConfigError {
Status400(models::PveError),
Status401(models::PveError),
Status403(models::PveError),
Status404(models::PveError),
Status500(models::PveError),
Status501(models::PveError),
Status503(models::PveError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum LxcIpError {
Status400(models::PveError),
Status401(models::PveError),
Status403(models::PveError),
Status404(models::PveError),
Status500(models::PveError),
Status501(models::PveError),
Status503(models::PveError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum LxcIpsetIndexError {
Status400(models::PveError),
Status401(models::PveError),
Status403(models::PveError),
Status404(models::PveError),
Status500(models::PveError),
Status501(models::PveError),
Status503(models::PveError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum LxcLogError {
Status400(models::PveError),
Status401(models::PveError),
Status403(models::PveError),
Status404(models::PveError),
Status500(models::PveError),
Status501(models::PveError),
Status503(models::PveError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum LxcMigrateVmError {
Status400(models::PveError),
Status401(models::PveError),
Status403(models::PveError),
Status404(models::PveError),
Status500(models::PveError),
Status501(models::PveError),
Status503(models::PveError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum LxcMigrateVmPreconditionError {
Status400(models::PveError),
Status401(models::PveError),
Status403(models::PveError),
Status404(models::PveError),
Status500(models::PveError),
Status501(models::PveError),
Status503(models::PveError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum LxcMoveVolumeError {
Status400(models::PveError),
Status401(models::PveError),
Status403(models::PveError),
Status404(models::PveError),
Status500(models::PveError),
Status501(models::PveError),
Status503(models::PveError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum LxcMtunnelError {
Status400(models::PveError),
Status401(models::PveError),
Status403(models::PveError),
Status404(models::PveError),
Status500(models::PveError),
Status501(models::PveError),
Status503(models::PveError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum LxcMtunnelwebsocketError {
Status400(models::PveError),
Status401(models::PveError),
Status403(models::PveError),
Status404(models::PveError),
Status500(models::PveError),
Status501(models::PveError),
Status503(models::PveError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum LxcReadAliasError {
Status400(models::PveError),
Status401(models::PveError),
Status403(models::PveError),
Status404(models::PveError),
Status500(models::PveError),
Status501(models::PveError),
Status503(models::PveError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum LxcReadIpError {
Status400(models::PveError),
Status401(models::PveError),
Status403(models::PveError),
Status404(models::PveError),
Status500(models::PveError),
Status501(models::PveError),
Status503(models::PveError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum LxcRefsError {
Status400(models::PveError),
Status401(models::PveError),
Status403(models::PveError),
Status404(models::PveError),
Status500(models::PveError),
Status501(models::PveError),
Status503(models::PveError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum LxcRemoteMigrateVmError {
Status400(models::PveError),
Status401(models::PveError),
Status403(models::PveError),
Status404(models::PveError),
Status500(models::PveError),
Status501(models::PveError),
Status503(models::PveError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum LxcRemoveAliasError {
Status400(models::PveError),
Status401(models::PveError),
Status403(models::PveError),
Status404(models::PveError),
Status500(models::PveError),
Status501(models::PveError),
Status503(models::PveError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum LxcRemoveIpError {
Status400(models::PveError),
Status401(models::PveError),
Status403(models::PveError),
Status404(models::PveError),
Status500(models::PveError),
Status501(models::PveError),
Status503(models::PveError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum LxcResizeVmError {
Status400(models::PveError),
Status401(models::PveError),
Status403(models::PveError),
Status404(models::PveError),
Status500(models::PveError),
Status501(models::PveError),
Status503(models::PveError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum LxcRollbackError {
Status400(models::PveError),
Status401(models::PveError),
Status403(models::PveError),
Status404(models::PveError),
Status500(models::PveError),
Status501(models::PveError),
Status503(models::PveError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum LxcRrdError {
Status400(models::PveError),
Status401(models::PveError),
Status403(models::PveError),
Status404(models::PveError),
Status500(models::PveError),
Status501(models::PveError),
Status503(models::PveError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum LxcRrddataError {
Status400(models::PveError),
Status401(models::PveError),
Status403(models::PveError),
Status404(models::PveError),
Status500(models::PveError),
Status501(models::PveError),
Status503(models::PveError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum LxcSetOptionsError {
Status400(models::PveError),
Status401(models::PveError),
Status403(models::PveError),
Status404(models::PveError),
Status500(models::PveError),
Status501(models::PveError),
Status503(models::PveError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum LxcSnapshotError {
Status400(models::PveError),
Status401(models::PveError),
Status403(models::PveError),
Status404(models::PveError),
Status500(models::PveError),
Status501(models::PveError),
Status503(models::PveError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum LxcSnapshotCmdIdxError {
Status400(models::PveError),
Status401(models::PveError),
Status403(models::PveError),
Status404(models::PveError),
Status500(models::PveError),
Status501(models::PveError),
Status503(models::PveError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum LxcSpiceproxyError {
Status400(models::PveError),
Status401(models::PveError),
Status403(models::PveError),
Status404(models::PveError),
Status500(models::PveError),
Status501(models::PveError),
Status503(models::PveError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum LxcTemplateError {
Status400(models::PveError),
Status401(models::PveError),
Status403(models::PveError),
Status404(models::PveError),
Status500(models::PveError),
Status501(models::PveError),
Status503(models::PveError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum LxcTermproxyError {
Status400(models::PveError),
Status401(models::PveError),
Status403(models::PveError),
Status404(models::PveError),
Status500(models::PveError),
Status501(models::PveError),
Status503(models::PveError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum LxcUpdateAliasError {
Status400(models::PveError),
Status401(models::PveError),
Status403(models::PveError),
Status404(models::PveError),
Status500(models::PveError),
Status501(models::PveError),
Status503(models::PveError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum LxcUpdateIpError {
Status400(models::PveError),
Status401(models::PveError),
Status403(models::PveError),
Status404(models::PveError),
Status500(models::PveError),
Status501(models::PveError),
Status503(models::PveError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum LxcUpdateRuleError {
Status400(models::PveError),
Status401(models::PveError),
Status403(models::PveError),
Status404(models::PveError),
Status500(models::PveError),
Status501(models::PveError),
Status503(models::PveError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum LxcUpdateSnapshotConfigError {
Status400(models::PveError),
Status401(models::PveError),
Status403(models::PveError),
Status404(models::PveError),
Status500(models::PveError),
Status501(models::PveError),
Status503(models::PveError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum LxcUpdateVmError {
Status400(models::PveError),
Status401(models::PveError),
Status403(models::PveError),
Status404(models::PveError),
Status500(models::PveError),
Status501(models::PveError),
Status503(models::PveError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum LxcVmConfigError {
Status400(models::PveError),
Status401(models::PveError),
Status403(models::PveError),
Status404(models::PveError),
Status500(models::PveError),
Status501(models::PveError),
Status503(models::PveError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum LxcVmFeatureError {
Status400(models::PveError),
Status401(models::PveError),
Status403(models::PveError),
Status404(models::PveError),
Status500(models::PveError),
Status501(models::PveError),
Status503(models::PveError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum LxcVmPendingError {
Status400(models::PveError),
Status401(models::PveError),
Status403(models::PveError),
Status404(models::PveError),
Status500(models::PveError),
Status501(models::PveError),
Status503(models::PveError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum LxcVmRebootError {
Status400(models::PveError),
Status401(models::PveError),
Status403(models::PveError),
Status404(models::PveError),
Status500(models::PveError),
Status501(models::PveError),
Status503(models::PveError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum LxcVmResumeError {
Status400(models::PveError),
Status401(models::PveError),
Status403(models::PveError),
Status404(models::PveError),
Status500(models::PveError),
Status501(models::PveError),
Status503(models::PveError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum LxcVmShutdownError {
Status400(models::PveError),
Status401(models::PveError),
Status403(models::PveError),
Status404(models::PveError),
Status500(models::PveError),
Status501(models::PveError),
Status503(models::PveError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum LxcVmStartError {
Status400(models::PveError),
Status401(models::PveError),
Status403(models::PveError),
Status404(models::PveError),
Status500(models::PveError),
Status501(models::PveError),
Status503(models::PveError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum LxcVmStatusError {
Status400(models::PveError),
Status401(models::PveError),
Status403(models::PveError),
Status404(models::PveError),
Status500(models::PveError),
Status501(models::PveError),
Status503(models::PveError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum LxcVmStopError {
Status400(models::PveError),
Status401(models::PveError),
Status403(models::PveError),
Status404(models::PveError),
Status500(models::PveError),
Status501(models::PveError),
Status503(models::PveError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum LxcVmSuspendError {
Status400(models::PveError),
Status401(models::PveError),
Status403(models::PveError),
Status404(models::PveError),
Status500(models::PveError),
Status501(models::PveError),
Status503(models::PveError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum LxcVmcmdidxError {
Status400(models::PveError),
Status401(models::PveError),
Status403(models::PveError),
Status404(models::PveError),
Status500(models::PveError),
Status501(models::PveError),
Status503(models::PveError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum LxcVmdiridxError {
Status400(models::PveError),
Status401(models::PveError),
Status403(models::PveError),
Status404(models::PveError),
Status500(models::PveError),
Status501(models::PveError),
Status503(models::PveError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum LxcVmlistError {
Status400(models::PveError),
Status401(models::PveError),
Status403(models::PveError),
Status404(models::PveError),
Status500(models::PveError),
Status501(models::PveError),
Status503(models::PveError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum LxcVncproxyError {
Status400(models::PveError),
Status401(models::PveError),
Status403(models::PveError),
Status404(models::PveError),
Status500(models::PveError),
Status501(models::PveError),
Status503(models::PveError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum LxcVncwebsocketError {
Status400(models::PveError),
Status401(models::PveError),
Status403(models::PveError),
Status404(models::PveError),
Status500(models::PveError),
Status501(models::PveError),
Status503(models::PveError),
UnknownValue(serde_json::Value),
}
pub async fn lxc_clone_vm(configuration: &configuration::Configuration, node: &str, vmid: i32, lxc_clone_vm_request: models::LxcCloneVmRequest) -> Result<models::LxcCloneVmResponse, Error<LxcCloneVmError>> {
let p_path_node = node;
let p_path_vmid = vmid;
let p_body_lxc_clone_vm_request = lxc_clone_vm_request;
let uri_str = format!("{}/nodes/{node}/lxc/{vmid}/clone", configuration.base_path, node=crate::apis::urlencode(p_path_node), vmid=p_path_vmid);
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Authorization", value);
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("CSRFPreventionToken", value);
};
req_builder = req_builder.json(&p_body_lxc_clone_vm_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::LxcCloneVmResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::LxcCloneVmResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<LxcCloneVmError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn lxc_create_alias(configuration: &configuration::Configuration, node: &str, vmid: i32, cluster_firewall_create_alias_request: models::ClusterFirewallCreateAliasRequest) -> Result<models::LxcCreateAliasResponse, Error<LxcCreateAliasError>> {
let p_path_node = node;
let p_path_vmid = vmid;
let p_body_cluster_firewall_create_alias_request = cluster_firewall_create_alias_request;
let uri_str = format!("{}/nodes/{node}/lxc/{vmid}/firewall/aliases", configuration.base_path, node=crate::apis::urlencode(p_path_node), vmid=p_path_vmid);
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Authorization", value);
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("CSRFPreventionToken", value);
};
req_builder = req_builder.json(&p_body_cluster_firewall_create_alias_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::LxcCreateAliasResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::LxcCreateAliasResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<LxcCreateAliasError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn lxc_create_ip(configuration: &configuration::Configuration, name: &str, node: &str, vmid: i32, cluster_firewall_create_ip_request: models::ClusterFirewallCreateIpRequest) -> Result<models::LxcCreateIpResponse, Error<LxcCreateIpError>> {
let p_path_name = name;
let p_path_node = node;
let p_path_vmid = vmid;
let p_body_cluster_firewall_create_ip_request = cluster_firewall_create_ip_request;
let uri_str = format!("{}/nodes/{node}/lxc/{vmid}/firewall/ipset/{name}", configuration.base_path, name=crate::apis::urlencode(p_path_name), node=crate::apis::urlencode(p_path_node), vmid=p_path_vmid);
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Authorization", value);
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("CSRFPreventionToken", value);
};
req_builder = req_builder.json(&p_body_cluster_firewall_create_ip_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::LxcCreateIpResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::LxcCreateIpResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<LxcCreateIpError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn lxc_create_ipset(configuration: &configuration::Configuration, node: &str, vmid: i32, cluster_firewall_create_ipset_request: models::ClusterFirewallCreateIpsetRequest) -> Result<models::LxcCreateIpsetResponse, Error<LxcCreateIpsetError>> {
let p_path_node = node;
let p_path_vmid = vmid;
let p_body_cluster_firewall_create_ipset_request = cluster_firewall_create_ipset_request;
let uri_str = format!("{}/nodes/{node}/lxc/{vmid}/firewall/ipset", configuration.base_path, node=crate::apis::urlencode(p_path_node), vmid=p_path_vmid);
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Authorization", value);
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("CSRFPreventionToken", value);
};
req_builder = req_builder.json(&p_body_cluster_firewall_create_ipset_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::LxcCreateIpsetResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::LxcCreateIpsetResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<LxcCreateIpsetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn lxc_create_rule(configuration: &configuration::Configuration, node: &str, vmid: i32, cluster_firewall_create_rule_request: models::ClusterFirewallCreateRuleRequest) -> Result<models::LxcCreateRuleResponse, Error<LxcCreateRuleError>> {
let p_path_node = node;
let p_path_vmid = vmid;
let p_body_cluster_firewall_create_rule_request = cluster_firewall_create_rule_request;
let uri_str = format!("{}/nodes/{node}/lxc/{vmid}/firewall/rules", configuration.base_path, node=crate::apis::urlencode(p_path_node), vmid=p_path_vmid);
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Authorization", value);
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("CSRFPreventionToken", value);
};
req_builder = req_builder.json(&p_body_cluster_firewall_create_rule_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::LxcCreateRuleResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::LxcCreateRuleResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<LxcCreateRuleError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn lxc_create_vm(configuration: &configuration::Configuration, node: &str, lxc_create_vm_request: models::LxcCreateVmRequest) -> Result<models::LxcCreateVmResponse, Error<LxcCreateVmError>> {
let p_path_node = node;
let p_body_lxc_create_vm_request = lxc_create_vm_request;
let uri_str = format!("{}/nodes/{node}/lxc", configuration.base_path, node=crate::apis::urlencode(p_path_node));
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Authorization", value);
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("CSRFPreventionToken", value);
};
req_builder = req_builder.json(&p_body_lxc_create_vm_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::LxcCreateVmResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::LxcCreateVmResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<LxcCreateVmError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn lxc_delete_ipset(configuration: &configuration::Configuration, name: &str, node: &str, vmid: i32, force: Option<&str>) -> Result<models::LxcDeleteIpsetResponse, Error<LxcDeleteIpsetError>> {
let p_path_name = name;
let p_path_node = node;
let p_path_vmid = vmid;
let p_query_force = force;
let uri_str = format!("{}/nodes/{node}/lxc/{vmid}/firewall/ipset/{name}", configuration.base_path, name=crate::apis::urlencode(p_path_name), node=crate::apis::urlencode(p_path_node), vmid=p_path_vmid);
let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
if let Some(ref param_value) = p_query_force {
req_builder = req_builder.query(&[("force", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Authorization", value);
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("CSRFPreventionToken", value);
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::LxcDeleteIpsetResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::LxcDeleteIpsetResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<LxcDeleteIpsetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn lxc_delete_rule(configuration: &configuration::Configuration, node: &str, pos: i64, vmid: i32, digest: Option<&str>) -> Result<models::LxcDeleteRuleResponse, Error<LxcDeleteRuleError>> {
let p_path_node = node;
let p_path_pos = pos;
let p_path_vmid = vmid;
let p_query_digest = digest;
let uri_str = format!("{}/nodes/{node}/lxc/{vmid}/firewall/rules/{pos}", configuration.base_path, node=crate::apis::urlencode(p_path_node), pos=p_path_pos, vmid=p_path_vmid);
let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
if let Some(ref param_value) = p_query_digest {
req_builder = req_builder.query(&[("digest", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Authorization", value);
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("CSRFPreventionToken", value);
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::LxcDeleteRuleResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::LxcDeleteRuleResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<LxcDeleteRuleError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn lxc_delsnapshot(configuration: &configuration::Configuration, node: &str, snapname: &str, vmid: i32, force: Option<&str>) -> Result<models::LxcDelsnapshotResponse, Error<LxcDelsnapshotError>> {
let p_path_node = node;
let p_path_snapname = snapname;
let p_path_vmid = vmid;
let p_query_force = force;
let uri_str = format!("{}/nodes/{node}/lxc/{vmid}/snapshot/{snapname}", configuration.base_path, node=crate::apis::urlencode(p_path_node), snapname=crate::apis::urlencode(p_path_snapname), vmid=p_path_vmid);
let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
if let Some(ref param_value) = p_query_force {
req_builder = req_builder.query(&[("force", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Authorization", value);
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("CSRFPreventionToken", value);
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::LxcDelsnapshotResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::LxcDelsnapshotResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<LxcDelsnapshotError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn lxc_destroy_vm(configuration: &configuration::Configuration, node: &str, vmid: i32, destroy_unreferenced_disks: Option<&str>, force: Option<&str>, purge: Option<&str>) -> Result<models::LxcDestroyVmResponse, Error<LxcDestroyVmError>> {
let p_path_node = node;
let p_path_vmid = vmid;
let p_query_destroy_unreferenced_disks = destroy_unreferenced_disks;
let p_query_force = force;
let p_query_purge = purge;
let uri_str = format!("{}/nodes/{node}/lxc/{vmid}", configuration.base_path, node=crate::apis::urlencode(p_path_node), vmid=p_path_vmid);
let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
if let Some(ref param_value) = p_query_destroy_unreferenced_disks {
req_builder = req_builder.query(&[("destroy-unreferenced-disks", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_force {
req_builder = req_builder.query(&[("force", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_purge {
req_builder = req_builder.query(&[("purge", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Authorization", value);
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("CSRFPreventionToken", value);
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::LxcDestroyVmResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::LxcDestroyVmResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<LxcDestroyVmError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn lxc_get_aliases(configuration: &configuration::Configuration, node: &str, vmid: i32) -> Result<models::LxcGetAliasesResponse, Error<LxcGetAliasesError>> {
let p_path_node = node;
let p_path_vmid = vmid;
let uri_str = format!("{}/nodes/{node}/lxc/{vmid}/firewall/aliases", configuration.base_path, node=crate::apis::urlencode(p_path_node), vmid=p_path_vmid);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Authorization", value);
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("CSRFPreventionToken", value);
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::LxcGetAliasesResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::LxcGetAliasesResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<LxcGetAliasesError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn lxc_get_firewall(configuration: &configuration::Configuration, node: &str, vmid: i32) -> Result<models::LxcGetFirewallResponse, Error<LxcGetFirewallError>> {
let p_path_node = node;
let p_path_vmid = vmid;
let uri_str = format!("{}/nodes/{node}/lxc/{vmid}/firewall", configuration.base_path, node=crate::apis::urlencode(p_path_node), vmid=p_path_vmid);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Authorization", value);
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("CSRFPreventionToken", value);
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::LxcGetFirewallResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::LxcGetFirewallResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<LxcGetFirewallError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn lxc_get_ipset(configuration: &configuration::Configuration, name: &str, node: &str, vmid: i32) -> Result<models::LxcGetIpsetResponse, Error<LxcGetIpsetError>> {
let p_path_name = name;
let p_path_node = node;
let p_path_vmid = vmid;
let uri_str = format!("{}/nodes/{node}/lxc/{vmid}/firewall/ipset/{name}", configuration.base_path, name=crate::apis::urlencode(p_path_name), node=crate::apis::urlencode(p_path_node), vmid=p_path_vmid);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Authorization", value);
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("CSRFPreventionToken", value);
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::LxcGetIpsetResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::LxcGetIpsetResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<LxcGetIpsetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn lxc_get_options(configuration: &configuration::Configuration, node: &str, vmid: i32) -> Result<models::LxcGetOptionsResponse, Error<LxcGetOptionsError>> {
let p_path_node = node;
let p_path_vmid = vmid;
let uri_str = format!("{}/nodes/{node}/lxc/{vmid}/firewall/options", configuration.base_path, node=crate::apis::urlencode(p_path_node), vmid=p_path_vmid);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Authorization", value);
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("CSRFPreventionToken", value);
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::LxcGetOptionsResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::LxcGetOptionsResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<LxcGetOptionsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn lxc_get_rule(configuration: &configuration::Configuration, node: &str, pos: i64, vmid: i32) -> Result<models::LxcGetRuleResponse, Error<LxcGetRuleError>> {
let p_path_node = node;
let p_path_pos = pos;
let p_path_vmid = vmid;
let uri_str = format!("{}/nodes/{node}/lxc/{vmid}/firewall/rules/{pos}", configuration.base_path, node=crate::apis::urlencode(p_path_node), pos=p_path_pos, vmid=p_path_vmid);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Authorization", value);
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("CSRFPreventionToken", value);
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::LxcGetRuleResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::LxcGetRuleResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<LxcGetRuleError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn lxc_get_rules(configuration: &configuration::Configuration, node: &str, vmid: i32) -> Result<models::LxcGetRulesResponse, Error<LxcGetRulesError>> {
let p_path_node = node;
let p_path_vmid = vmid;
let uri_str = format!("{}/nodes/{node}/lxc/{vmid}/firewall/rules", configuration.base_path, node=crate::apis::urlencode(p_path_node), vmid=p_path_vmid);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Authorization", value);
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("CSRFPreventionToken", value);
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::LxcGetRulesResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::LxcGetRulesResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<LxcGetRulesError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn lxc_get_snapshot(configuration: &configuration::Configuration, node: &str, vmid: i32) -> Result<models::LxcGetSnapshotResponse, Error<LxcGetSnapshotError>> {
let p_path_node = node;
let p_path_vmid = vmid;
let uri_str = format!("{}/nodes/{node}/lxc/{vmid}/snapshot", configuration.base_path, node=crate::apis::urlencode(p_path_node), vmid=p_path_vmid);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Authorization", value);
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("CSRFPreventionToken", value);
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::LxcGetSnapshotResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::LxcGetSnapshotResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<LxcGetSnapshotError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn lxc_get_snapshot_config(configuration: &configuration::Configuration, node: &str, snapname: &str, vmid: i32) -> Result<models::LxcGetSnapshotConfigResponse, Error<LxcGetSnapshotConfigError>> {
let p_path_node = node;
let p_path_snapname = snapname;
let p_path_vmid = vmid;
let uri_str = format!("{}/nodes/{node}/lxc/{vmid}/snapshot/{snapname}/config", configuration.base_path, node=crate::apis::urlencode(p_path_node), snapname=crate::apis::urlencode(p_path_snapname), vmid=p_path_vmid);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Authorization", value);
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("CSRFPreventionToken", value);
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::LxcGetSnapshotConfigResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::LxcGetSnapshotConfigResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<LxcGetSnapshotConfigError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn lxc_ip(configuration: &configuration::Configuration, node: &str, vmid: i32) -> Result<models::LxcIpResponse, Error<LxcIpError>> {
let p_path_node = node;
let p_path_vmid = vmid;
let uri_str = format!("{}/nodes/{node}/lxc/{vmid}/interfaces", configuration.base_path, node=crate::apis::urlencode(p_path_node), vmid=p_path_vmid);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Authorization", value);
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("CSRFPreventionToken", value);
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::LxcIpResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::LxcIpResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<LxcIpError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn lxc_ipset_index(configuration: &configuration::Configuration, node: &str, vmid: i32) -> Result<models::LxcIpsetIndexResponse, Error<LxcIpsetIndexError>> {
let p_path_node = node;
let p_path_vmid = vmid;
let uri_str = format!("{}/nodes/{node}/lxc/{vmid}/firewall/ipset", configuration.base_path, node=crate::apis::urlencode(p_path_node), vmid=p_path_vmid);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Authorization", value);
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("CSRFPreventionToken", value);
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::LxcIpsetIndexResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::LxcIpsetIndexResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<LxcIpsetIndexError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn lxc_log(configuration: &configuration::Configuration, node: &str, vmid: i32, limit: Option<i64>, since: Option<i64>, start: Option<i64>, until: Option<i64>) -> Result<models::LxcLogResponse, Error<LxcLogError>> {
let p_path_node = node;
let p_path_vmid = vmid;
let p_query_limit = limit;
let p_query_since = since;
let p_query_start = start;
let p_query_until = until;
let uri_str = format!("{}/nodes/{node}/lxc/{vmid}/firewall/log", configuration.base_path, node=crate::apis::urlencode(p_path_node), vmid=p_path_vmid);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_limit {
req_builder = req_builder.query(&[("limit", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_since {
req_builder = req_builder.query(&[("since", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_start {
req_builder = req_builder.query(&[("start", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_until {
req_builder = req_builder.query(&[("until", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Authorization", value);
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("CSRFPreventionToken", value);
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::LxcLogResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::LxcLogResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<LxcLogError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn lxc_migrate_vm(configuration: &configuration::Configuration, node: &str, vmid: i32, lxc_migrate_vm_request: models::LxcMigrateVmRequest) -> Result<models::LxcMigrateVmResponse, Error<LxcMigrateVmError>> {
let p_path_node = node;
let p_path_vmid = vmid;
let p_body_lxc_migrate_vm_request = lxc_migrate_vm_request;
let uri_str = format!("{}/nodes/{node}/lxc/{vmid}/migrate", configuration.base_path, node=crate::apis::urlencode(p_path_node), vmid=p_path_vmid);
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Authorization", value);
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("CSRFPreventionToken", value);
};
req_builder = req_builder.json(&p_body_lxc_migrate_vm_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::LxcMigrateVmResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::LxcMigrateVmResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<LxcMigrateVmError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn lxc_migrate_vm_precondition(configuration: &configuration::Configuration, node: &str, vmid: i32, target: Option<&str>) -> Result<models::LxcMigrateVmPreconditionResponse, Error<LxcMigrateVmPreconditionError>> {
let p_path_node = node;
let p_path_vmid = vmid;
let p_query_target = target;
let uri_str = format!("{}/nodes/{node}/lxc/{vmid}/migrate", configuration.base_path, node=crate::apis::urlencode(p_path_node), vmid=p_path_vmid);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_target {
req_builder = req_builder.query(&[("target", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Authorization", value);
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("CSRFPreventionToken", value);
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::LxcMigrateVmPreconditionResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::LxcMigrateVmPreconditionResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<LxcMigrateVmPreconditionError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn lxc_move_volume(configuration: &configuration::Configuration, node: &str, vmid: i32, lxc_move_volume_request: models::LxcMoveVolumeRequest) -> Result<models::LxcMoveVolumeResponse, Error<LxcMoveVolumeError>> {
let p_path_node = node;
let p_path_vmid = vmid;
let p_body_lxc_move_volume_request = lxc_move_volume_request;
let uri_str = format!("{}/nodes/{node}/lxc/{vmid}/move_volume", configuration.base_path, node=crate::apis::urlencode(p_path_node), vmid=p_path_vmid);
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Authorization", value);
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("CSRFPreventionToken", value);
};
req_builder = req_builder.json(&p_body_lxc_move_volume_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::LxcMoveVolumeResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::LxcMoveVolumeResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<LxcMoveVolumeError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn lxc_mtunnel(configuration: &configuration::Configuration, node: &str, vmid: i32, lxc_mtunnel_request: Option<models::LxcMtunnelRequest>) -> Result<models::LxcMtunnelResponse, Error<LxcMtunnelError>> {
let p_path_node = node;
let p_path_vmid = vmid;
let p_body_lxc_mtunnel_request = lxc_mtunnel_request;
let uri_str = format!("{}/nodes/{node}/lxc/{vmid}/mtunnel", configuration.base_path, node=crate::apis::urlencode(p_path_node), vmid=p_path_vmid);
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Authorization", value);
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("CSRFPreventionToken", value);
};
req_builder = req_builder.json(&p_body_lxc_mtunnel_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::LxcMtunnelResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::LxcMtunnelResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<LxcMtunnelError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn lxc_mtunnelwebsocket(configuration: &configuration::Configuration, node: &str, socket: &str, ticket: &str, vmid: i32) -> Result<models::LxcMtunnelwebsocketResponse, Error<LxcMtunnelwebsocketError>> {
let p_path_node = node;
let p_query_socket = socket;
let p_query_ticket = ticket;
let p_path_vmid = vmid;
let uri_str = format!("{}/nodes/{node}/lxc/{vmid}/mtunnelwebsocket", configuration.base_path, node=crate::apis::urlencode(p_path_node), vmid=p_path_vmid);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
req_builder = req_builder.query(&[("socket", &p_query_socket.to_string())]);
req_builder = req_builder.query(&[("ticket", &p_query_ticket.to_string())]);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Authorization", value);
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("CSRFPreventionToken", value);
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::LxcMtunnelwebsocketResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::LxcMtunnelwebsocketResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<LxcMtunnelwebsocketError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn lxc_read_alias(configuration: &configuration::Configuration, name: &str, node: &str, vmid: i32) -> Result<models::LxcReadAliasResponse, Error<LxcReadAliasError>> {
let p_path_name = name;
let p_path_node = node;
let p_path_vmid = vmid;
let uri_str = format!("{}/nodes/{node}/lxc/{vmid}/firewall/aliases/{name}", configuration.base_path, name=crate::apis::urlencode(p_path_name), node=crate::apis::urlencode(p_path_node), vmid=p_path_vmid);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Authorization", value);
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("CSRFPreventionToken", value);
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::LxcReadAliasResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::LxcReadAliasResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<LxcReadAliasError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn lxc_read_ip(configuration: &configuration::Configuration, cidr: &str, name: &str, node: &str, vmid: i32) -> Result<models::LxcReadIpResponse, Error<LxcReadIpError>> {
let p_path_cidr = cidr;
let p_path_name = name;
let p_path_node = node;
let p_path_vmid = vmid;
let uri_str = format!("{}/nodes/{node}/lxc/{vmid}/firewall/ipset/{name}/{cidr}", configuration.base_path, cidr=crate::apis::urlencode(p_path_cidr), name=crate::apis::urlencode(p_path_name), node=crate::apis::urlencode(p_path_node), vmid=p_path_vmid);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Authorization", value);
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("CSRFPreventionToken", value);
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::LxcReadIpResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::LxcReadIpResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<LxcReadIpError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn lxc_refs(configuration: &configuration::Configuration, node: &str, vmid: i32, r#type: Option<models::PveTypeTypeEnum>) -> Result<models::LxcRefsResponse, Error<LxcRefsError>> {
let p_path_node = node;
let p_path_vmid = vmid;
let p_query_type = r#type;
let uri_str = format!("{}/nodes/{node}/lxc/{vmid}/firewall/refs", configuration.base_path, node=crate::apis::urlencode(p_path_node), vmid=p_path_vmid);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_type {
req_builder = req_builder.query(&[("type", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Authorization", value);
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("CSRFPreventionToken", value);
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::LxcRefsResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::LxcRefsResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<LxcRefsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn lxc_remote_migrate_vm(configuration: &configuration::Configuration, node: &str, vmid: i32, lxc_remote_migrate_vm_request: models::LxcRemoteMigrateVmRequest) -> Result<models::LxcRemoteMigrateVmResponse, Error<LxcRemoteMigrateVmError>> {
let p_path_node = node;
let p_path_vmid = vmid;
let p_body_lxc_remote_migrate_vm_request = lxc_remote_migrate_vm_request;
let uri_str = format!("{}/nodes/{node}/lxc/{vmid}/remote_migrate", configuration.base_path, node=crate::apis::urlencode(p_path_node), vmid=p_path_vmid);
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Authorization", value);
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("CSRFPreventionToken", value);
};
req_builder = req_builder.json(&p_body_lxc_remote_migrate_vm_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::LxcRemoteMigrateVmResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::LxcRemoteMigrateVmResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<LxcRemoteMigrateVmError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn lxc_remove_alias(configuration: &configuration::Configuration, name: &str, node: &str, vmid: i32, digest: Option<&str>) -> Result<models::LxcRemoveAliasResponse, Error<LxcRemoveAliasError>> {
let p_path_name = name;
let p_path_node = node;
let p_path_vmid = vmid;
let p_query_digest = digest;
let uri_str = format!("{}/nodes/{node}/lxc/{vmid}/firewall/aliases/{name}", configuration.base_path, name=crate::apis::urlencode(p_path_name), node=crate::apis::urlencode(p_path_node), vmid=p_path_vmid);
let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
if let Some(ref param_value) = p_query_digest {
req_builder = req_builder.query(&[("digest", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Authorization", value);
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("CSRFPreventionToken", value);
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::LxcRemoveAliasResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::LxcRemoveAliasResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<LxcRemoveAliasError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn lxc_remove_ip(configuration: &configuration::Configuration, cidr: &str, name: &str, node: &str, vmid: i32, digest: Option<&str>) -> Result<models::LxcRemoveIpResponse, Error<LxcRemoveIpError>> {
let p_path_cidr = cidr;
let p_path_name = name;
let p_path_node = node;
let p_path_vmid = vmid;
let p_query_digest = digest;
let uri_str = format!("{}/nodes/{node}/lxc/{vmid}/firewall/ipset/{name}/{cidr}", configuration.base_path, cidr=crate::apis::urlencode(p_path_cidr), name=crate::apis::urlencode(p_path_name), node=crate::apis::urlencode(p_path_node), vmid=p_path_vmid);
let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
if let Some(ref param_value) = p_query_digest {
req_builder = req_builder.query(&[("digest", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Authorization", value);
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("CSRFPreventionToken", value);
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::LxcRemoveIpResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::LxcRemoveIpResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<LxcRemoveIpError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn lxc_resize_vm(configuration: &configuration::Configuration, node: &str, vmid: i32, lxc_resize_vm_request: models::LxcResizeVmRequest) -> Result<models::LxcResizeVmResponse, Error<LxcResizeVmError>> {
let p_path_node = node;
let p_path_vmid = vmid;
let p_body_lxc_resize_vm_request = lxc_resize_vm_request;
let uri_str = format!("{}/nodes/{node}/lxc/{vmid}/resize", configuration.base_path, node=crate::apis::urlencode(p_path_node), vmid=p_path_vmid);
let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Authorization", value);
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("CSRFPreventionToken", value);
};
req_builder = req_builder.json(&p_body_lxc_resize_vm_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::LxcResizeVmResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::LxcResizeVmResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<LxcResizeVmError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn lxc_rollback(configuration: &configuration::Configuration, node: &str, snapname: &str, vmid: i32, lxc_rollback_request: Option<models::LxcRollbackRequest>) -> Result<models::LxcRollbackResponse, Error<LxcRollbackError>> {
let p_path_node = node;
let p_path_snapname = snapname;
let p_path_vmid = vmid;
let p_body_lxc_rollback_request = lxc_rollback_request;
let uri_str = format!("{}/nodes/{node}/lxc/{vmid}/snapshot/{snapname}/rollback", configuration.base_path, node=crate::apis::urlencode(p_path_node), snapname=crate::apis::urlencode(p_path_snapname), vmid=p_path_vmid);
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Authorization", value);
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("CSRFPreventionToken", value);
};
req_builder = req_builder.json(&p_body_lxc_rollback_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::LxcRollbackResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::LxcRollbackResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<LxcRollbackError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn lxc_rrd(configuration: &configuration::Configuration, ds: &str, node: &str, timeframe: models::PveTimeframeEnum, vmid: i32, cf: Option<models::PveCfEnum>) -> Result<models::LxcRrdResponse, Error<LxcRrdError>> {
let p_query_ds = ds;
let p_path_node = node;
let p_query_timeframe = timeframe;
let p_path_vmid = vmid;
let p_query_cf = cf;
let uri_str = format!("{}/nodes/{node}/lxc/{vmid}/rrd", configuration.base_path, node=crate::apis::urlencode(p_path_node), vmid=p_path_vmid);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_cf {
req_builder = req_builder.query(&[("cf", ¶m_value.to_string())]);
}
req_builder = req_builder.query(&[("ds", &p_query_ds.to_string())]);
req_builder = req_builder.query(&[("timeframe", &p_query_timeframe.to_string())]);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Authorization", value);
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("CSRFPreventionToken", value);
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::LxcRrdResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::LxcRrdResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<LxcRrdError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn lxc_rrddata(configuration: &configuration::Configuration, node: &str, timeframe: models::PveTimeframeEnum, vmid: i32, cf: Option<models::PveCfEnum>) -> Result<models::LxcRrddataResponse, Error<LxcRrddataError>> {
let p_path_node = node;
let p_query_timeframe = timeframe;
let p_path_vmid = vmid;
let p_query_cf = cf;
let uri_str = format!("{}/nodes/{node}/lxc/{vmid}/rrddata", configuration.base_path, node=crate::apis::urlencode(p_path_node), vmid=p_path_vmid);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_cf {
req_builder = req_builder.query(&[("cf", ¶m_value.to_string())]);
}
req_builder = req_builder.query(&[("timeframe", &p_query_timeframe.to_string())]);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Authorization", value);
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("CSRFPreventionToken", value);
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::LxcRrddataResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::LxcRrddataResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<LxcRrddataError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn lxc_set_options(configuration: &configuration::Configuration, node: &str, vmid: i32, lxc_set_options_request: Option<models::LxcSetOptionsRequest>) -> Result<models::LxcSetOptionsResponse, Error<LxcSetOptionsError>> {
let p_path_node = node;
let p_path_vmid = vmid;
let p_body_lxc_set_options_request = lxc_set_options_request;
let uri_str = format!("{}/nodes/{node}/lxc/{vmid}/firewall/options", configuration.base_path, node=crate::apis::urlencode(p_path_node), vmid=p_path_vmid);
let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Authorization", value);
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("CSRFPreventionToken", value);
};
req_builder = req_builder.json(&p_body_lxc_set_options_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::LxcSetOptionsResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::LxcSetOptionsResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<LxcSetOptionsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn lxc_snapshot(configuration: &configuration::Configuration, node: &str, vmid: i32, lxc_snapshot_request: models::LxcSnapshotRequest) -> Result<models::LxcSnapshotResponse, Error<LxcSnapshotError>> {
let p_path_node = node;
let p_path_vmid = vmid;
let p_body_lxc_snapshot_request = lxc_snapshot_request;
let uri_str = format!("{}/nodes/{node}/lxc/{vmid}/snapshot", configuration.base_path, node=crate::apis::urlencode(p_path_node), vmid=p_path_vmid);
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Authorization", value);
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("CSRFPreventionToken", value);
};
req_builder = req_builder.json(&p_body_lxc_snapshot_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::LxcSnapshotResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::LxcSnapshotResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<LxcSnapshotError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn lxc_snapshot_cmd_idx(configuration: &configuration::Configuration, node: &str, snapname: &str, vmid: i32) -> Result<models::LxcSnapshotCmdIdxResponse, Error<LxcSnapshotCmdIdxError>> {
let p_path_node = node;
let p_path_snapname = snapname;
let p_path_vmid = vmid;
let uri_str = format!("{}/nodes/{node}/lxc/{vmid}/snapshot/{snapname}", configuration.base_path, node=crate::apis::urlencode(p_path_node), snapname=crate::apis::urlencode(p_path_snapname), vmid=p_path_vmid);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Authorization", value);
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("CSRFPreventionToken", value);
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::LxcSnapshotCmdIdxResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::LxcSnapshotCmdIdxResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<LxcSnapshotCmdIdxError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn lxc_spiceproxy(configuration: &configuration::Configuration, node: &str, vmid: i32, lxc_spiceproxy_request: Option<models::LxcSpiceproxyRequest>) -> Result<models::LxcSpiceproxyResponse, Error<LxcSpiceproxyError>> {
let p_path_node = node;
let p_path_vmid = vmid;
let p_body_lxc_spiceproxy_request = lxc_spiceproxy_request;
let uri_str = format!("{}/nodes/{node}/lxc/{vmid}/spiceproxy", configuration.base_path, node=crate::apis::urlencode(p_path_node), vmid=p_path_vmid);
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Authorization", value);
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("CSRFPreventionToken", value);
};
req_builder = req_builder.json(&p_body_lxc_spiceproxy_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::LxcSpiceproxyResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::LxcSpiceproxyResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<LxcSpiceproxyError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn lxc_template(configuration: &configuration::Configuration, node: &str, vmid: i32) -> Result<models::LxcTemplateResponse, Error<LxcTemplateError>> {
let p_path_node = node;
let p_path_vmid = vmid;
let uri_str = format!("{}/nodes/{node}/lxc/{vmid}/template", configuration.base_path, node=crate::apis::urlencode(p_path_node), vmid=p_path_vmid);
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Authorization", value);
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("CSRFPreventionToken", value);
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::LxcTemplateResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::LxcTemplateResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<LxcTemplateError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn lxc_termproxy(configuration: &configuration::Configuration, node: &str, vmid: i32) -> Result<models::LxcTermproxyResponse, Error<LxcTermproxyError>> {
let p_path_node = node;
let p_path_vmid = vmid;
let uri_str = format!("{}/nodes/{node}/lxc/{vmid}/termproxy", configuration.base_path, node=crate::apis::urlencode(p_path_node), vmid=p_path_vmid);
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Authorization", value);
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("CSRFPreventionToken", value);
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::LxcTermproxyResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::LxcTermproxyResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<LxcTermproxyError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn lxc_update_alias(configuration: &configuration::Configuration, name: &str, node: &str, vmid: i32, cluster_firewall_update_alias_request: models::ClusterFirewallUpdateAliasRequest) -> Result<models::LxcUpdateAliasResponse, Error<LxcUpdateAliasError>> {
let p_path_name = name;
let p_path_node = node;
let p_path_vmid = vmid;
let p_body_cluster_firewall_update_alias_request = cluster_firewall_update_alias_request;
let uri_str = format!("{}/nodes/{node}/lxc/{vmid}/firewall/aliases/{name}", configuration.base_path, name=crate::apis::urlencode(p_path_name), node=crate::apis::urlencode(p_path_node), vmid=p_path_vmid);
let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Authorization", value);
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("CSRFPreventionToken", value);
};
req_builder = req_builder.json(&p_body_cluster_firewall_update_alias_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::LxcUpdateAliasResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::LxcUpdateAliasResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<LxcUpdateAliasError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn lxc_update_ip(configuration: &configuration::Configuration, cidr: &str, name: &str, node: &str, vmid: i32, cluster_firewall_update_ip_request: Option<models::ClusterFirewallUpdateIpRequest>) -> Result<models::LxcUpdateIpResponse, Error<LxcUpdateIpError>> {
let p_path_cidr = cidr;
let p_path_name = name;
let p_path_node = node;
let p_path_vmid = vmid;
let p_body_cluster_firewall_update_ip_request = cluster_firewall_update_ip_request;
let uri_str = format!("{}/nodes/{node}/lxc/{vmid}/firewall/ipset/{name}/{cidr}", configuration.base_path, cidr=crate::apis::urlencode(p_path_cidr), name=crate::apis::urlencode(p_path_name), node=crate::apis::urlencode(p_path_node), vmid=p_path_vmid);
let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Authorization", value);
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("CSRFPreventionToken", value);
};
req_builder = req_builder.json(&p_body_cluster_firewall_update_ip_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::LxcUpdateIpResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::LxcUpdateIpResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<LxcUpdateIpError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn lxc_update_rule(configuration: &configuration::Configuration, node: &str, pos: i64, vmid: i32, cluster_firewall_update_rule_request: Option<models::ClusterFirewallUpdateRuleRequest>) -> Result<models::LxcUpdateRuleResponse, Error<LxcUpdateRuleError>> {
let p_path_node = node;
let p_path_pos = pos;
let p_path_vmid = vmid;
let p_body_cluster_firewall_update_rule_request = cluster_firewall_update_rule_request;
let uri_str = format!("{}/nodes/{node}/lxc/{vmid}/firewall/rules/{pos}", configuration.base_path, node=crate::apis::urlencode(p_path_node), pos=p_path_pos, vmid=p_path_vmid);
let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Authorization", value);
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("CSRFPreventionToken", value);
};
req_builder = req_builder.json(&p_body_cluster_firewall_update_rule_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::LxcUpdateRuleResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::LxcUpdateRuleResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<LxcUpdateRuleError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn lxc_update_snapshot_config(configuration: &configuration::Configuration, node: &str, snapname: &str, vmid: i32, lxc_update_snapshot_config_request: Option<models::LxcUpdateSnapshotConfigRequest>) -> Result<models::LxcUpdateSnapshotConfigResponse, Error<LxcUpdateSnapshotConfigError>> {
let p_path_node = node;
let p_path_snapname = snapname;
let p_path_vmid = vmid;
let p_body_lxc_update_snapshot_config_request = lxc_update_snapshot_config_request;
let uri_str = format!("{}/nodes/{node}/lxc/{vmid}/snapshot/{snapname}/config", configuration.base_path, node=crate::apis::urlencode(p_path_node), snapname=crate::apis::urlencode(p_path_snapname), vmid=p_path_vmid);
let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Authorization", value);
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("CSRFPreventionToken", value);
};
req_builder = req_builder.json(&p_body_lxc_update_snapshot_config_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::LxcUpdateSnapshotConfigResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::LxcUpdateSnapshotConfigResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<LxcUpdateSnapshotConfigError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn lxc_update_vm(configuration: &configuration::Configuration, node: &str, vmid: i32, lxc_update_vm_request: Option<models::LxcUpdateVmRequest>) -> Result<models::LxcUpdateVmResponse, Error<LxcUpdateVmError>> {
let p_path_node = node;
let p_path_vmid = vmid;
let p_body_lxc_update_vm_request = lxc_update_vm_request;
let uri_str = format!("{}/nodes/{node}/lxc/{vmid}/config", configuration.base_path, node=crate::apis::urlencode(p_path_node), vmid=p_path_vmid);
let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Authorization", value);
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("CSRFPreventionToken", value);
};
req_builder = req_builder.json(&p_body_lxc_update_vm_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::LxcUpdateVmResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::LxcUpdateVmResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<LxcUpdateVmError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn lxc_vm_config(configuration: &configuration::Configuration, node: &str, vmid: i32, current: Option<&str>, snapshot: Option<&str>) -> Result<models::LxcVmConfigResponse, Error<LxcVmConfigError>> {
let p_path_node = node;
let p_path_vmid = vmid;
let p_query_current = current;
let p_query_snapshot = snapshot;
let uri_str = format!("{}/nodes/{node}/lxc/{vmid}/config", configuration.base_path, node=crate::apis::urlencode(p_path_node), vmid=p_path_vmid);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_current {
req_builder = req_builder.query(&[("current", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_snapshot {
req_builder = req_builder.query(&[("snapshot", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Authorization", value);
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("CSRFPreventionToken", value);
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::LxcVmConfigResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::LxcVmConfigResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<LxcVmConfigError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn lxc_vm_feature(configuration: &configuration::Configuration, feature: models::PveFeatureEnum, node: &str, vmid: i32, snapname: Option<&str>) -> Result<models::LxcVmFeatureResponse, Error<LxcVmFeatureError>> {
let p_query_feature = feature;
let p_path_node = node;
let p_path_vmid = vmid;
let p_query_snapname = snapname;
let uri_str = format!("{}/nodes/{node}/lxc/{vmid}/feature", configuration.base_path, node=crate::apis::urlencode(p_path_node), vmid=p_path_vmid);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
req_builder = req_builder.query(&[("feature", &p_query_feature.to_string())]);
if let Some(ref param_value) = p_query_snapname {
req_builder = req_builder.query(&[("snapname", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Authorization", value);
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("CSRFPreventionToken", value);
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::LxcVmFeatureResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::LxcVmFeatureResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<LxcVmFeatureError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn lxc_vm_pending(configuration: &configuration::Configuration, node: &str, vmid: i32) -> Result<models::LxcVmPendingResponse, Error<LxcVmPendingError>> {
let p_path_node = node;
let p_path_vmid = vmid;
let uri_str = format!("{}/nodes/{node}/lxc/{vmid}/pending", configuration.base_path, node=crate::apis::urlencode(p_path_node), vmid=p_path_vmid);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Authorization", value);
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("CSRFPreventionToken", value);
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::LxcVmPendingResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::LxcVmPendingResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<LxcVmPendingError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn lxc_vm_reboot(configuration: &configuration::Configuration, node: &str, vmid: i32, lxc_vm_reboot_request: Option<models::LxcVmRebootRequest>) -> Result<models::LxcVmRebootResponse, Error<LxcVmRebootError>> {
let p_path_node = node;
let p_path_vmid = vmid;
let p_body_lxc_vm_reboot_request = lxc_vm_reboot_request;
let uri_str = format!("{}/nodes/{node}/lxc/{vmid}/status/reboot", configuration.base_path, node=crate::apis::urlencode(p_path_node), vmid=p_path_vmid);
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Authorization", value);
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("CSRFPreventionToken", value);
};
req_builder = req_builder.json(&p_body_lxc_vm_reboot_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::LxcVmRebootResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::LxcVmRebootResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<LxcVmRebootError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn lxc_vm_resume(configuration: &configuration::Configuration, node: &str, vmid: i32) -> Result<models::LxcVmResumeResponse, Error<LxcVmResumeError>> {
let p_path_node = node;
let p_path_vmid = vmid;
let uri_str = format!("{}/nodes/{node}/lxc/{vmid}/status/resume", configuration.base_path, node=crate::apis::urlencode(p_path_node), vmid=p_path_vmid);
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Authorization", value);
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("CSRFPreventionToken", value);
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::LxcVmResumeResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::LxcVmResumeResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<LxcVmResumeError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn lxc_vm_shutdown(configuration: &configuration::Configuration, node: &str, vmid: i32, lxc_vm_shutdown_request: Option<models::LxcVmShutdownRequest>) -> Result<models::LxcVmShutdownResponse, Error<LxcVmShutdownError>> {
let p_path_node = node;
let p_path_vmid = vmid;
let p_body_lxc_vm_shutdown_request = lxc_vm_shutdown_request;
let uri_str = format!("{}/nodes/{node}/lxc/{vmid}/status/shutdown", configuration.base_path, node=crate::apis::urlencode(p_path_node), vmid=p_path_vmid);
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Authorization", value);
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("CSRFPreventionToken", value);
};
req_builder = req_builder.json(&p_body_lxc_vm_shutdown_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::LxcVmShutdownResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::LxcVmShutdownResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<LxcVmShutdownError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn lxc_vm_start(configuration: &configuration::Configuration, node: &str, vmid: i32, lxc_vm_start_request: Option<models::LxcVmStartRequest>) -> Result<models::LxcVmStartResponse, Error<LxcVmStartError>> {
let p_path_node = node;
let p_path_vmid = vmid;
let p_body_lxc_vm_start_request = lxc_vm_start_request;
let uri_str = format!("{}/nodes/{node}/lxc/{vmid}/status/start", configuration.base_path, node=crate::apis::urlencode(p_path_node), vmid=p_path_vmid);
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Authorization", value);
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("CSRFPreventionToken", value);
};
req_builder = req_builder.json(&p_body_lxc_vm_start_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::LxcVmStartResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::LxcVmStartResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<LxcVmStartError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn lxc_vm_status(configuration: &configuration::Configuration, node: &str, vmid: i32) -> Result<models::LxcVmStatusResponse, Error<LxcVmStatusError>> {
let p_path_node = node;
let p_path_vmid = vmid;
let uri_str = format!("{}/nodes/{node}/lxc/{vmid}/status/current", configuration.base_path, node=crate::apis::urlencode(p_path_node), vmid=p_path_vmid);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Authorization", value);
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("CSRFPreventionToken", value);
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::LxcVmStatusResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::LxcVmStatusResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<LxcVmStatusError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn lxc_vm_stop(configuration: &configuration::Configuration, node: &str, vmid: i32, lxc_vm_stop_request: Option<models::LxcVmStopRequest>) -> Result<models::LxcVmStopResponse, Error<LxcVmStopError>> {
let p_path_node = node;
let p_path_vmid = vmid;
let p_body_lxc_vm_stop_request = lxc_vm_stop_request;
let uri_str = format!("{}/nodes/{node}/lxc/{vmid}/status/stop", configuration.base_path, node=crate::apis::urlencode(p_path_node), vmid=p_path_vmid);
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Authorization", value);
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("CSRFPreventionToken", value);
};
req_builder = req_builder.json(&p_body_lxc_vm_stop_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::LxcVmStopResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::LxcVmStopResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<LxcVmStopError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn lxc_vm_suspend(configuration: &configuration::Configuration, node: &str, vmid: i32) -> Result<models::LxcVmSuspendResponse, Error<LxcVmSuspendError>> {
let p_path_node = node;
let p_path_vmid = vmid;
let uri_str = format!("{}/nodes/{node}/lxc/{vmid}/status/suspend", configuration.base_path, node=crate::apis::urlencode(p_path_node), vmid=p_path_vmid);
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Authorization", value);
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("CSRFPreventionToken", value);
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::LxcVmSuspendResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::LxcVmSuspendResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<LxcVmSuspendError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn lxc_vmcmdidx(configuration: &configuration::Configuration, node: &str, vmid: i32) -> Result<models::LxcVmcmdidxResponse, Error<LxcVmcmdidxError>> {
let p_path_node = node;
let p_path_vmid = vmid;
let uri_str = format!("{}/nodes/{node}/lxc/{vmid}/status", configuration.base_path, node=crate::apis::urlencode(p_path_node), vmid=p_path_vmid);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Authorization", value);
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("CSRFPreventionToken", value);
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::LxcVmcmdidxResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::LxcVmcmdidxResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<LxcVmcmdidxError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn lxc_vmdiridx(configuration: &configuration::Configuration, node: &str, vmid: i32) -> Result<models::LxcVmdiridxResponse, Error<LxcVmdiridxError>> {
let p_path_node = node;
let p_path_vmid = vmid;
let uri_str = format!("{}/nodes/{node}/lxc/{vmid}", configuration.base_path, node=crate::apis::urlencode(p_path_node), vmid=p_path_vmid);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Authorization", value);
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("CSRFPreventionToken", value);
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::LxcVmdiridxResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::LxcVmdiridxResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<LxcVmdiridxError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn lxc_vmlist(configuration: &configuration::Configuration, node: &str) -> Result<models::LxcVmlistResponse, Error<LxcVmlistError>> {
let p_path_node = node;
let uri_str = format!("{}/nodes/{node}/lxc", configuration.base_path, node=crate::apis::urlencode(p_path_node));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Authorization", value);
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("CSRFPreventionToken", value);
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::LxcVmlistResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::LxcVmlistResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<LxcVmlistError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn lxc_vncproxy(configuration: &configuration::Configuration, node: &str, vmid: i32, lxc_vncproxy_request: Option<models::LxcVncproxyRequest>) -> Result<models::LxcVncproxyResponse, Error<LxcVncproxyError>> {
let p_path_node = node;
let p_path_vmid = vmid;
let p_body_lxc_vncproxy_request = lxc_vncproxy_request;
let uri_str = format!("{}/nodes/{node}/lxc/{vmid}/vncproxy", configuration.base_path, node=crate::apis::urlencode(p_path_node), vmid=p_path_vmid);
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Authorization", value);
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("CSRFPreventionToken", value);
};
req_builder = req_builder.json(&p_body_lxc_vncproxy_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::LxcVncproxyResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::LxcVncproxyResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<LxcVncproxyError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn lxc_vncwebsocket(configuration: &configuration::Configuration, node: &str, port: i32, vmid: i32, vncticket: &str) -> Result<models::LxcVncwebsocketResponse, Error<LxcVncwebsocketError>> {
let p_path_node = node;
let p_query_port = port;
let p_path_vmid = vmid;
let p_query_vncticket = vncticket;
let uri_str = format!("{}/nodes/{node}/lxc/{vmid}/vncwebsocket", configuration.base_path, node=crate::apis::urlencode(p_path_node), vmid=p_path_vmid);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
req_builder = req_builder.query(&[("port", &p_query_port.to_string())]);
req_builder = req_builder.query(&[("vncticket", &p_query_vncticket.to_string())]);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Authorization", value);
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("CSRFPreventionToken", value);
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::LxcVncwebsocketResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::LxcVncwebsocketResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<LxcVncwebsocketError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}