/*
* Proxmox Virtual Environment API
*
* Generated from apidoc.js. NOT an official Proxmox specification. See https://pve.proxmox.com/pve-docs/api-viewer/ for the upstream documentation.
*
* The version of the OpenAPI document: 9.x
*
* Generated by: https://openapi-generator.tech
*/
use reqwest;
use serde::{Deserialize, Serialize, de::Error as _};
use crate::{apis::ResponseContent, models};
use super::{Error, configuration, ContentType};
/// struct for typed errors of method [`qemu_agent`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QemuAgentError {
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),
}
/// struct for typed errors of method [`qemu_clone_vm`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QemuCloneVmError {
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),
}
/// struct for typed errors of method [`qemu_cloudinit_generated_config_dump`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QemuCloudinitGeneratedConfigDumpError {
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),
}
/// struct for typed errors of method [`qemu_cloudinit_pending`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QemuCloudinitPendingError {
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),
}
/// struct for typed errors of method [`qemu_cloudinit_update`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QemuCloudinitUpdateError {
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),
}
/// struct for typed errors of method [`qemu_create_alias`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QemuCreateAliasError {
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),
}
/// struct for typed errors of method [`qemu_create_ip`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QemuCreateIpError {
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),
}
/// struct for typed errors of method [`qemu_create_ipset`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QemuCreateIpsetError {
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),
}
/// struct for typed errors of method [`qemu_create_rule`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QemuCreateRuleError {
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),
}
/// struct for typed errors of method [`qemu_create_vm`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QemuCreateVmError {
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),
}
/// struct for typed errors of method [`qemu_dbus_vmstate`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QemuDbusVmstateError {
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),
}
/// struct for typed errors of method [`qemu_delete_ipset`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QemuDeleteIpsetError {
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),
}
/// struct for typed errors of method [`qemu_delete_rule`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QemuDeleteRuleError {
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),
}
/// struct for typed errors of method [`qemu_delsnapshot`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QemuDelsnapshotError {
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),
}
/// struct for typed errors of method [`qemu_destroy_vm`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QemuDestroyVmError {
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),
}
/// struct for typed errors of method [`qemu_exec`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QemuExecError {
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),
}
/// struct for typed errors of method [`qemu_exec_status`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QemuExecStatusError {
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),
}
/// struct for typed errors of method [`qemu_file_read`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QemuFileReadError {
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),
}
/// struct for typed errors of method [`qemu_file_write`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QemuFileWriteError {
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),
}
/// struct for typed errors of method [`qemu_fsfreeze_freeze`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QemuFsfreezeFreezeError {
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),
}
/// struct for typed errors of method [`qemu_fsfreeze_status`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QemuFsfreezeStatusError {
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),
}
/// struct for typed errors of method [`qemu_fsfreeze_thaw`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QemuFsfreezeThawError {
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),
}
/// struct for typed errors of method [`qemu_fstrim`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QemuFstrimError {
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),
}
/// struct for typed errors of method [`qemu_get_agent`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QemuGetAgentError {
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),
}
/// struct for typed errors of method [`qemu_get_aliases`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QemuGetAliasesError {
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),
}
/// struct for typed errors of method [`qemu_get_firewall`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QemuGetFirewallError {
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),
}
/// struct for typed errors of method [`qemu_get_fsinfo`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QemuGetFsinfoError {
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),
}
/// struct for typed errors of method [`qemu_get_host_name`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QemuGetHostNameError {
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),
}
/// struct for typed errors of method [`qemu_get_ipset`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QemuGetIpsetError {
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),
}
/// struct for typed errors of method [`qemu_get_memory_block_info`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QemuGetMemoryBlockInfoError {
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),
}
/// struct for typed errors of method [`qemu_get_memory_blocks`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QemuGetMemoryBlocksError {
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),
}
/// struct for typed errors of method [`qemu_get_options`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QemuGetOptionsError {
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),
}
/// struct for typed errors of method [`qemu_get_osinfo`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QemuGetOsinfoError {
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),
}
/// struct for typed errors of method [`qemu_get_rule`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QemuGetRuleError {
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),
}
/// struct for typed errors of method [`qemu_get_rules`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QemuGetRulesError {
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),
}
/// struct for typed errors of method [`qemu_get_snapshot_config`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QemuGetSnapshotConfigError {
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),
}
/// struct for typed errors of method [`qemu_get_time`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QemuGetTimeError {
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),
}
/// struct for typed errors of method [`qemu_get_timezone`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QemuGetTimezoneError {
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),
}
/// struct for typed errors of method [`qemu_get_users`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QemuGetUsersError {
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),
}
/// struct for typed errors of method [`qemu_get_vcpus`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QemuGetVcpusError {
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),
}
/// struct for typed errors of method [`qemu_info`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QemuInfoError {
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),
}
/// struct for typed errors of method [`qemu_ipset_index`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QemuIpsetIndexError {
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),
}
/// struct for typed errors of method [`qemu_log`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QemuLogError {
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),
}
/// struct for typed errors of method [`qemu_migrate_vm`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QemuMigrateVmError {
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),
}
/// struct for typed errors of method [`qemu_migrate_vm_precondition`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QemuMigrateVmPreconditionError {
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),
}
/// struct for typed errors of method [`qemu_monitor`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QemuMonitorError {
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),
}
/// struct for typed errors of method [`qemu_move_vm_disk`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QemuMoveVmDiskError {
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),
}
/// struct for typed errors of method [`qemu_mtunnel`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QemuMtunnelError {
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),
}
/// struct for typed errors of method [`qemu_mtunnelwebsocket`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QemuMtunnelwebsocketError {
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),
}
/// struct for typed errors of method [`qemu_network_get_interfaces`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QemuNetworkGetInterfacesError {
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),
}
/// struct for typed errors of method [`qemu_ping`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QemuPingError {
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),
}
/// struct for typed errors of method [`qemu_read_alias`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QemuReadAliasError {
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),
}
/// struct for typed errors of method [`qemu_read_ip`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QemuReadIpError {
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),
}
/// struct for typed errors of method [`qemu_refs`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QemuRefsError {
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),
}
/// struct for typed errors of method [`qemu_remote_migrate_vm`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QemuRemoteMigrateVmError {
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),
}
/// struct for typed errors of method [`qemu_remove_alias`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QemuRemoveAliasError {
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),
}
/// struct for typed errors of method [`qemu_remove_ip`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QemuRemoveIpError {
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),
}
/// struct for typed errors of method [`qemu_resize_vm`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QemuResizeVmError {
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),
}
/// struct for typed errors of method [`qemu_rollback`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QemuRollbackError {
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),
}
/// struct for typed errors of method [`qemu_rrd`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QemuRrdError {
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),
}
/// struct for typed errors of method [`qemu_rrddata`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QemuRrddataError {
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),
}
/// struct for typed errors of method [`qemu_set_options`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QemuSetOptionsError {
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),
}
/// struct for typed errors of method [`qemu_set_user_password`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QemuSetUserPasswordError {
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),
}
/// struct for typed errors of method [`qemu_shutdown`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QemuShutdownError {
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),
}
/// struct for typed errors of method [`qemu_snapshot`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QemuSnapshotError {
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),
}
/// struct for typed errors of method [`qemu_snapshot_cmd_idx`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QemuSnapshotCmdIdxError {
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),
}
/// struct for typed errors of method [`qemu_snapshot_list`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QemuSnapshotListError {
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),
}
/// struct for typed errors of method [`qemu_spiceproxy`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QemuSpiceproxyError {
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),
}
/// struct for typed errors of method [`qemu_suspend_disk`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QemuSuspendDiskError {
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),
}
/// struct for typed errors of method [`qemu_suspend_hybrid`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QemuSuspendHybridError {
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),
}
/// struct for typed errors of method [`qemu_suspend_ram`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QemuSuspendRamError {
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),
}
/// struct for typed errors of method [`qemu_template`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QemuTemplateError {
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),
}
/// struct for typed errors of method [`qemu_termproxy`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QemuTermproxyError {
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),
}
/// struct for typed errors of method [`qemu_unlink`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QemuUnlinkError {
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),
}
/// struct for typed errors of method [`qemu_update_alias`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QemuUpdateAliasError {
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),
}
/// struct for typed errors of method [`qemu_update_ip`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QemuUpdateIpError {
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),
}
/// struct for typed errors of method [`qemu_update_rule`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QemuUpdateRuleError {
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),
}
/// struct for typed errors of method [`qemu_update_snapshot_config`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QemuUpdateSnapshotConfigError {
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),
}
/// struct for typed errors of method [`qemu_update_vm`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QemuUpdateVmError {
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),
}
/// struct for typed errors of method [`qemu_update_vm_async_op`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QemuUpdateVmAsyncOpError {
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),
}
/// struct for typed errors of method [`qemu_vm_config`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QemuVmConfigError {
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),
}
/// struct for typed errors of method [`qemu_vm_feature`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QemuVmFeatureError {
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),
}
/// struct for typed errors of method [`qemu_vm_pending`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QemuVmPendingError {
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),
}
/// struct for typed errors of method [`qemu_vm_reboot`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QemuVmRebootError {
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),
}
/// struct for typed errors of method [`qemu_vm_reset`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QemuVmResetError {
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),
}
/// struct for typed errors of method [`qemu_vm_resume`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QemuVmResumeError {
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),
}
/// struct for typed errors of method [`qemu_vm_sendkey`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QemuVmSendkeyError {
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),
}
/// struct for typed errors of method [`qemu_vm_shutdown`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QemuVmShutdownError {
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),
}
/// struct for typed errors of method [`qemu_vm_start`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QemuVmStartError {
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),
}
/// struct for typed errors of method [`qemu_vm_status`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QemuVmStatusError {
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),
}
/// struct for typed errors of method [`qemu_vm_stop`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QemuVmStopError {
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),
}
/// struct for typed errors of method [`qemu_vm_suspend`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QemuVmSuspendError {
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),
}
/// struct for typed errors of method [`qemu_vmcmdidx`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QemuVmcmdidxError {
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),
}
/// struct for typed errors of method [`qemu_vmdiridx`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QemuVmdiridxError {
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),
}
/// struct for typed errors of method [`qemu_vmlist`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QemuVmlistError {
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),
}
/// struct for typed errors of method [`qemu_vncproxy`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QemuVncproxyError {
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),
}
/// struct for typed errors of method [`qemu_vncwebsocket`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QemuVncwebsocketError {
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),
}
/// Execute QEMU Guest Agent commands.
pub async fn qemu_agent(configuration: &configuration::Configuration, node: &str, vmid: i32, qemu_agent_request: models::QemuAgentRequest) -> Result<models::QemuAgentResponse, Error<QemuAgentError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_node = node;
let p_path_vmid = vmid;
let p_body_qemu_agent_request = qemu_agent_request;
let uri_str = format!("{}/nodes/{node}/qemu/{vmid}/agent", 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_qemu_agent_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::QemuAgentResponse`"))),
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::QemuAgentResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<QemuAgentError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Create a copy of virtual machine/template. Permissions: You need 'VM.Clone' permissions on /vms/{vmid}, and 'VM.Allocate' permissions on /vms/{newid} (or on the VM pool /pool/{pool}). You also need 'Datastore.AllocateSpace' on any used storage and 'SDN.Use' on any used bridge/vnet
pub async fn qemu_clone_vm(configuration: &configuration::Configuration, node: &str, vmid: i32, qemu_clone_vm_request: models::QemuCloneVmRequest) -> Result<models::QemuCloneVmResponse, Error<QemuCloneVmError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_node = node;
let p_path_vmid = vmid;
let p_body_qemu_clone_vm_request = qemu_clone_vm_request;
let uri_str = format!("{}/nodes/{node}/qemu/{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_qemu_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::QemuCloneVmResponse`"))),
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::QemuCloneVmResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<QemuCloneVmError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Get automatically generated cloudinit config.
pub async fn qemu_cloudinit_generated_config_dump(configuration: &configuration::Configuration, node: &str, r#type: models::PveQemuTypeEnum2, vmid: i32) -> Result<models::QemuCloudinitGeneratedConfigDumpResponse, Error<QemuCloudinitGeneratedConfigDumpError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_node = node;
let p_query_type = r#type;
let p_path_vmid = vmid;
let uri_str = format!("{}/nodes/{node}/qemu/{vmid}/cloudinit/dump", 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(&[("type", &p_query_type.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::QemuCloudinitGeneratedConfigDumpResponse`"))),
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::QemuCloudinitGeneratedConfigDumpResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<QemuCloudinitGeneratedConfigDumpError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Get the cloudinit configuration with both current and pending values.
pub async fn qemu_cloudinit_pending(configuration: &configuration::Configuration, node: &str, vmid: i32) -> Result<models::QemuCloudinitPendingResponse, Error<QemuCloudinitPendingError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_node = node;
let p_path_vmid = vmid;
let uri_str = format!("{}/nodes/{node}/qemu/{vmid}/cloudinit", 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::QemuCloudinitPendingResponse`"))),
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::QemuCloudinitPendingResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<QemuCloudinitPendingError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Regenerate and change cloudinit config drive.
pub async fn qemu_cloudinit_update(configuration: &configuration::Configuration, node: &str, vmid: i32) -> Result<models::QemuCloudinitUpdateResponse, Error<QemuCloudinitUpdateError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_node = node;
let p_path_vmid = vmid;
let uri_str = format!("{}/nodes/{node}/qemu/{vmid}/cloudinit", 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);
};
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::QemuCloudinitUpdateResponse`"))),
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::QemuCloudinitUpdateResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<QemuCloudinitUpdateError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Create IP or Network Alias.
pub async fn qemu_create_alias(configuration: &configuration::Configuration, node: &str, vmid: i32, cluster_firewall_create_alias_request: models::ClusterFirewallCreateAliasRequest) -> Result<models::QemuCreateAliasResponse, Error<QemuCreateAliasError>> {
// add a prefix to parameters to efficiently prevent name collisions
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}/qemu/{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::QemuCreateAliasResponse`"))),
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::QemuCreateAliasResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<QemuCreateAliasError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Add IP or Network to IPSet.
pub async fn qemu_create_ip(configuration: &configuration::Configuration, name: &str, node: &str, vmid: i32, cluster_firewall_create_ip_request: models::ClusterFirewallCreateIpRequest) -> Result<models::QemuCreateIpResponse, Error<QemuCreateIpError>> {
// add a prefix to parameters to efficiently prevent name collisions
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}/qemu/{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::QemuCreateIpResponse`"))),
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::QemuCreateIpResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<QemuCreateIpError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Create new IPSet
pub async fn qemu_create_ipset(configuration: &configuration::Configuration, node: &str, vmid: i32, cluster_firewall_create_ipset_request: models::ClusterFirewallCreateIpsetRequest) -> Result<models::QemuCreateIpsetResponse, Error<QemuCreateIpsetError>> {
// add a prefix to parameters to efficiently prevent name collisions
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}/qemu/{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::QemuCreateIpsetResponse`"))),
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::QemuCreateIpsetResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<QemuCreateIpsetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Create new rule.
pub async fn qemu_create_rule(configuration: &configuration::Configuration, node: &str, vmid: i32, cluster_firewall_create_rule_request: models::ClusterFirewallCreateRuleRequest) -> Result<models::QemuCreateRuleResponse, Error<QemuCreateRuleError>> {
// add a prefix to parameters to efficiently prevent name collisions
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}/qemu/{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::QemuCreateRuleResponse`"))),
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::QemuCreateRuleResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<QemuCreateRuleError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Create or restore a virtual machine. Permissions: You need 'VM.Allocate' permissions on /vms/{vmid} or on the VM pool /pool/{pool}. For restore (option 'archive'), it is enough if the user has 'VM.Backup' permission and the VM already exists. If you create disks you need 'Datastore.AllocateSpace' on any used storage.If you use a bridge/vlan, you need 'SDN.Use' on any used bridge/vlan.
pub async fn qemu_create_vm(configuration: &configuration::Configuration, node: &str, qemu_create_vm_request: models::QemuCreateVmRequest) -> Result<models::QemuCreateVmResponse, Error<QemuCreateVmError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_node = node;
let p_body_qemu_create_vm_request = qemu_create_vm_request;
let uri_str = format!("{}/nodes/{node}/qemu", 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_qemu_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::QemuCreateVmResponse`"))),
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::QemuCreateVmResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<QemuCreateVmError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Control the dbus-vmstate helper for a given running VM.
pub async fn qemu_dbus_vmstate(configuration: &configuration::Configuration, node: &str, vmid: i32, qemu_dbus_vmstate_request: models::QemuDbusVmstateRequest) -> Result<models::QemuDbusVmstateResponse, Error<QemuDbusVmstateError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_node = node;
let p_path_vmid = vmid;
let p_body_qemu_dbus_vmstate_request = qemu_dbus_vmstate_request;
let uri_str = format!("{}/nodes/{node}/qemu/{vmid}/dbus-vmstate", 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_qemu_dbus_vmstate_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::QemuDbusVmstateResponse`"))),
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::QemuDbusVmstateResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<QemuDbusVmstateError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Delete IPSet
pub async fn qemu_delete_ipset(configuration: &configuration::Configuration, name: &str, node: &str, vmid: i32, force: Option<&str>) -> Result<models::QemuDeleteIpsetResponse, Error<QemuDeleteIpsetError>> {
// add a prefix to parameters to efficiently prevent name collisions
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}/qemu/{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::QemuDeleteIpsetResponse`"))),
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::QemuDeleteIpsetResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<QemuDeleteIpsetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Delete rule.
pub async fn qemu_delete_rule(configuration: &configuration::Configuration, node: &str, pos: i64, vmid: i32, digest: Option<&str>) -> Result<models::QemuDeleteRuleResponse, Error<QemuDeleteRuleError>> {
// add a prefix to parameters to efficiently prevent name collisions
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}/qemu/{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::QemuDeleteRuleResponse`"))),
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::QemuDeleteRuleResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<QemuDeleteRuleError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Delete a VM snapshot.
pub async fn qemu_delsnapshot(configuration: &configuration::Configuration, node: &str, snapname: &str, vmid: i32, force: Option<&str>) -> Result<models::QemuDelsnapshotResponse, Error<QemuDelsnapshotError>> {
// add a prefix to parameters to efficiently prevent name collisions
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}/qemu/{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::QemuDelsnapshotResponse`"))),
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::QemuDelsnapshotResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<QemuDelsnapshotError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Destroy the VM and all used/owned volumes. Removes any VM specific permissions and firewall rules
pub async fn qemu_destroy_vm(configuration: &configuration::Configuration, node: &str, vmid: i32, destroy_unreferenced_disks: Option<&str>, purge: Option<&str>, skiplock: Option<&str>) -> Result<models::QemuDestroyVmResponse, Error<QemuDestroyVmError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_node = node;
let p_path_vmid = vmid;
let p_query_destroy_unreferenced_disks = destroy_unreferenced_disks;
let p_query_purge = purge;
let p_query_skiplock = skiplock;
let uri_str = format!("{}/nodes/{node}/qemu/{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_purge {
req_builder = req_builder.query(&[("purge", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_skiplock {
req_builder = req_builder.query(&[("skiplock", ¶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::QemuDestroyVmResponse`"))),
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::QemuDestroyVmResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<QemuDestroyVmError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Executes the given command in the vm via the guest-agent and returns an object with the pid.
pub async fn qemu_exec(configuration: &configuration::Configuration, node: &str, vmid: i32, qemu_exec_request: models::QemuExecRequest) -> Result<models::QemuExecResponse, Error<QemuExecError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_node = node;
let p_path_vmid = vmid;
let p_body_qemu_exec_request = qemu_exec_request;
let uri_str = format!("{}/nodes/{node}/qemu/{vmid}/agent/exec", 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_qemu_exec_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::QemuExecResponse`"))),
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::QemuExecResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<QemuExecError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Gets the status of the given pid started by the guest-agent
pub async fn qemu_exec_status(configuration: &configuration::Configuration, node: &str, pid: i64, vmid: i32) -> Result<models::QemuExecStatusResponse, Error<QemuExecStatusError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_node = node;
let p_query_pid = pid;
let p_path_vmid = vmid;
let uri_str = format!("{}/nodes/{node}/qemu/{vmid}/agent/exec-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);
req_builder = req_builder.query(&[("pid", &p_query_pid.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::QemuExecStatusResponse`"))),
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::QemuExecStatusResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<QemuExecStatusError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Reads the given file via guest agent. Is limited to 16777216 bytes.
pub async fn qemu_file_read(configuration: &configuration::Configuration, file: &str, node: &str, vmid: i32, count: Option<i32>, decode: Option<&str>, offset: Option<i64>) -> Result<models::QemuFileReadResponse, Error<QemuFileReadError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_file = file;
let p_path_node = node;
let p_path_vmid = vmid;
let p_query_count = count;
let p_query_decode = decode;
let p_query_offset = offset;
let uri_str = format!("{}/nodes/{node}/qemu/{vmid}/agent/file-read", 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_count {
req_builder = req_builder.query(&[("count", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_decode {
req_builder = req_builder.query(&[("decode", ¶m_value.to_string())]);
}
req_builder = req_builder.query(&[("file", &p_query_file.to_string())]);
if let Some(ref param_value) = p_query_offset {
req_builder = req_builder.query(&[("offset", ¶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::QemuFileReadResponse`"))),
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::QemuFileReadResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<QemuFileReadError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Writes the given file via guest agent.
pub async fn qemu_file_write(configuration: &configuration::Configuration, node: &str, vmid: i32, qemu_file_write_request: models::QemuFileWriteRequest) -> Result<models::QemuFileWriteResponse, Error<QemuFileWriteError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_node = node;
let p_path_vmid = vmid;
let p_body_qemu_file_write_request = qemu_file_write_request;
let uri_str = format!("{}/nodes/{node}/qemu/{vmid}/agent/file-write", 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_qemu_file_write_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::QemuFileWriteResponse`"))),
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::QemuFileWriteResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<QemuFileWriteError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Execute fsfreeze-freeze.
pub async fn qemu_fsfreeze_freeze(configuration: &configuration::Configuration, node: &str, vmid: i32) -> Result<models::QemuFsfreezeFreezeResponse, Error<QemuFsfreezeFreezeError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_node = node;
let p_path_vmid = vmid;
let uri_str = format!("{}/nodes/{node}/qemu/{vmid}/agent/fsfreeze-freeze", 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::QemuFsfreezeFreezeResponse`"))),
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::QemuFsfreezeFreezeResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<QemuFsfreezeFreezeError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Execute fsfreeze-status.
pub async fn qemu_fsfreeze_status(configuration: &configuration::Configuration, node: &str, vmid: i32) -> Result<models::QemuFsfreezeStatusResponse, Error<QemuFsfreezeStatusError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_node = node;
let p_path_vmid = vmid;
let uri_str = format!("{}/nodes/{node}/qemu/{vmid}/agent/fsfreeze-status", 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::QemuFsfreezeStatusResponse`"))),
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::QemuFsfreezeStatusResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<QemuFsfreezeStatusError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Execute fsfreeze-thaw.
pub async fn qemu_fsfreeze_thaw(configuration: &configuration::Configuration, node: &str, vmid: i32) -> Result<models::QemuFsfreezeThawResponse, Error<QemuFsfreezeThawError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_node = node;
let p_path_vmid = vmid;
let uri_str = format!("{}/nodes/{node}/qemu/{vmid}/agent/fsfreeze-thaw", 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::QemuFsfreezeThawResponse`"))),
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::QemuFsfreezeThawResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<QemuFsfreezeThawError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Execute fstrim.
pub async fn qemu_fstrim(configuration: &configuration::Configuration, node: &str, vmid: i32) -> Result<models::QemuFstrimResponse, Error<QemuFstrimError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_node = node;
let p_path_vmid = vmid;
let uri_str = format!("{}/nodes/{node}/qemu/{vmid}/agent/fstrim", 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::QemuFstrimResponse`"))),
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::QemuFstrimResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<QemuFstrimError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// QEMU Guest Agent command index.
pub async fn qemu_get_agent(configuration: &configuration::Configuration, node: &str, vmid: i32) -> Result<models::QemuGetAgentResponse, Error<QemuGetAgentError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_node = node;
let p_path_vmid = vmid;
let uri_str = format!("{}/nodes/{node}/qemu/{vmid}/agent", 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::QemuGetAgentResponse`"))),
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::QemuGetAgentResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<QemuGetAgentError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// List aliases
pub async fn qemu_get_aliases(configuration: &configuration::Configuration, node: &str, vmid: i32) -> Result<models::QemuGetAliasesResponse, Error<QemuGetAliasesError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_node = node;
let p_path_vmid = vmid;
let uri_str = format!("{}/nodes/{node}/qemu/{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::QemuGetAliasesResponse`"))),
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::QemuGetAliasesResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<QemuGetAliasesError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Directory index.
pub async fn qemu_get_firewall(configuration: &configuration::Configuration, node: &str, vmid: i32) -> Result<models::QemuGetFirewallResponse, Error<QemuGetFirewallError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_node = node;
let p_path_vmid = vmid;
let uri_str = format!("{}/nodes/{node}/qemu/{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::QemuGetFirewallResponse`"))),
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::QemuGetFirewallResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<QemuGetFirewallError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Execute get-fsinfo.
pub async fn qemu_get_fsinfo(configuration: &configuration::Configuration, node: &str, vmid: i32) -> Result<models::QemuGetFsinfoResponse, Error<QemuGetFsinfoError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_node = node;
let p_path_vmid = vmid;
let uri_str = format!("{}/nodes/{node}/qemu/{vmid}/agent/get-fsinfo", 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::QemuGetFsinfoResponse`"))),
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::QemuGetFsinfoResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<QemuGetFsinfoError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Execute get-host-name.
pub async fn qemu_get_host_name(configuration: &configuration::Configuration, node: &str, vmid: i32) -> Result<models::QemuGetHostNameResponse, Error<QemuGetHostNameError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_node = node;
let p_path_vmid = vmid;
let uri_str = format!("{}/nodes/{node}/qemu/{vmid}/agent/get-host-name", 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::QemuGetHostNameResponse`"))),
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::QemuGetHostNameResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<QemuGetHostNameError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// List IPSet content
pub async fn qemu_get_ipset(configuration: &configuration::Configuration, name: &str, node: &str, vmid: i32) -> Result<models::QemuGetIpsetResponse, Error<QemuGetIpsetError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_name = name;
let p_path_node = node;
let p_path_vmid = vmid;
let uri_str = format!("{}/nodes/{node}/qemu/{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::QemuGetIpsetResponse`"))),
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::QemuGetIpsetResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<QemuGetIpsetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Execute get-memory-block-info.
pub async fn qemu_get_memory_block_info(configuration: &configuration::Configuration, node: &str, vmid: i32) -> Result<models::QemuGetMemoryBlockInfoResponse, Error<QemuGetMemoryBlockInfoError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_node = node;
let p_path_vmid = vmid;
let uri_str = format!("{}/nodes/{node}/qemu/{vmid}/agent/get-memory-block-info", 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::QemuGetMemoryBlockInfoResponse`"))),
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::QemuGetMemoryBlockInfoResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<QemuGetMemoryBlockInfoError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Execute get-memory-blocks.
pub async fn qemu_get_memory_blocks(configuration: &configuration::Configuration, node: &str, vmid: i32) -> Result<models::QemuGetMemoryBlocksResponse, Error<QemuGetMemoryBlocksError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_node = node;
let p_path_vmid = vmid;
let uri_str = format!("{}/nodes/{node}/qemu/{vmid}/agent/get-memory-blocks", 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::QemuGetMemoryBlocksResponse`"))),
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::QemuGetMemoryBlocksResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<QemuGetMemoryBlocksError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Get VM firewall options.
pub async fn qemu_get_options(configuration: &configuration::Configuration, node: &str, vmid: i32) -> Result<models::QemuGetOptionsResponse, Error<QemuGetOptionsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_node = node;
let p_path_vmid = vmid;
let uri_str = format!("{}/nodes/{node}/qemu/{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::QemuGetOptionsResponse`"))),
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::QemuGetOptionsResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<QemuGetOptionsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Execute get-osinfo.
pub async fn qemu_get_osinfo(configuration: &configuration::Configuration, node: &str, vmid: i32) -> Result<models::QemuGetOsinfoResponse, Error<QemuGetOsinfoError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_node = node;
let p_path_vmid = vmid;
let uri_str = format!("{}/nodes/{node}/qemu/{vmid}/agent/get-osinfo", 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::QemuGetOsinfoResponse`"))),
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::QemuGetOsinfoResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<QemuGetOsinfoError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Get single rule data.
pub async fn qemu_get_rule(configuration: &configuration::Configuration, node: &str, pos: i64, vmid: i32) -> Result<models::QemuGetRuleResponse, Error<QemuGetRuleError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_node = node;
let p_path_pos = pos;
let p_path_vmid = vmid;
let uri_str = format!("{}/nodes/{node}/qemu/{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::QemuGetRuleResponse`"))),
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::QemuGetRuleResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<QemuGetRuleError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// List rules.
pub async fn qemu_get_rules(configuration: &configuration::Configuration, node: &str, vmid: i32) -> Result<models::QemuGetRulesResponse, Error<QemuGetRulesError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_node = node;
let p_path_vmid = vmid;
let uri_str = format!("{}/nodes/{node}/qemu/{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::QemuGetRulesResponse`"))),
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::QemuGetRulesResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<QemuGetRulesError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Get snapshot configuration
pub async fn qemu_get_snapshot_config(configuration: &configuration::Configuration, node: &str, snapname: &str, vmid: i32) -> Result<models::QemuGetSnapshotConfigResponse, Error<QemuGetSnapshotConfigError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_node = node;
let p_path_snapname = snapname;
let p_path_vmid = vmid;
let uri_str = format!("{}/nodes/{node}/qemu/{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::QemuGetSnapshotConfigResponse`"))),
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::QemuGetSnapshotConfigResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<QemuGetSnapshotConfigError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Execute get-time.
pub async fn qemu_get_time(configuration: &configuration::Configuration, node: &str, vmid: i32) -> Result<models::QemuGetTimeResponse, Error<QemuGetTimeError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_node = node;
let p_path_vmid = vmid;
let uri_str = format!("{}/nodes/{node}/qemu/{vmid}/agent/get-time", 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::QemuGetTimeResponse`"))),
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::QemuGetTimeResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<QemuGetTimeError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Execute get-timezone.
pub async fn qemu_get_timezone(configuration: &configuration::Configuration, node: &str, vmid: i32) -> Result<models::QemuGetTimezoneResponse, Error<QemuGetTimezoneError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_node = node;
let p_path_vmid = vmid;
let uri_str = format!("{}/nodes/{node}/qemu/{vmid}/agent/get-timezone", 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::QemuGetTimezoneResponse`"))),
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::QemuGetTimezoneResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<QemuGetTimezoneError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Execute get-users.
pub async fn qemu_get_users(configuration: &configuration::Configuration, node: &str, vmid: i32) -> Result<models::QemuGetUsersResponse, Error<QemuGetUsersError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_node = node;
let p_path_vmid = vmid;
let uri_str = format!("{}/nodes/{node}/qemu/{vmid}/agent/get-users", 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::QemuGetUsersResponse`"))),
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::QemuGetUsersResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<QemuGetUsersError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Execute get-vcpus.
pub async fn qemu_get_vcpus(configuration: &configuration::Configuration, node: &str, vmid: i32) -> Result<models::QemuGetVcpusResponse, Error<QemuGetVcpusError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_node = node;
let p_path_vmid = vmid;
let uri_str = format!("{}/nodes/{node}/qemu/{vmid}/agent/get-vcpus", 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::QemuGetVcpusResponse`"))),
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::QemuGetVcpusResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<QemuGetVcpusError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Execute info.
pub async fn qemu_info(configuration: &configuration::Configuration, node: &str, vmid: i32) -> Result<models::QemuInfoResponse, Error<QemuInfoError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_node = node;
let p_path_vmid = vmid;
let uri_str = format!("{}/nodes/{node}/qemu/{vmid}/agent/info", 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::QemuInfoResponse`"))),
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::QemuInfoResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<QemuInfoError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// List IPSets
pub async fn qemu_ipset_index(configuration: &configuration::Configuration, node: &str, vmid: i32) -> Result<models::QemuIpsetIndexResponse, Error<QemuIpsetIndexError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_node = node;
let p_path_vmid = vmid;
let uri_str = format!("{}/nodes/{node}/qemu/{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::QemuIpsetIndexResponse`"))),
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::QemuIpsetIndexResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<QemuIpsetIndexError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Read firewall log
pub async fn qemu_log(configuration: &configuration::Configuration, node: &str, vmid: i32, limit: Option<i64>, since: Option<i64>, start: Option<i64>, until: Option<i64>) -> Result<models::QemuLogResponse, Error<QemuLogError>> {
// add a prefix to parameters to efficiently prevent name collisions
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}/qemu/{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::QemuLogResponse`"))),
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::QemuLogResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<QemuLogError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Migrate virtual machine. Creates a new migration task.
pub async fn qemu_migrate_vm(configuration: &configuration::Configuration, node: &str, vmid: i32, qemu_migrate_vm_request: models::QemuMigrateVmRequest) -> Result<models::QemuMigrateVmResponse, Error<QemuMigrateVmError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_node = node;
let p_path_vmid = vmid;
let p_body_qemu_migrate_vm_request = qemu_migrate_vm_request;
let uri_str = format!("{}/nodes/{node}/qemu/{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_qemu_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::QemuMigrateVmResponse`"))),
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::QemuMigrateVmResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<QemuMigrateVmError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Get preconditions for migration.
pub async fn qemu_migrate_vm_precondition(configuration: &configuration::Configuration, node: &str, vmid: i32, target: Option<&str>) -> Result<models::QemuMigrateVmPreconditionResponse, Error<QemuMigrateVmPreconditionError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_node = node;
let p_path_vmid = vmid;
let p_query_target = target;
let uri_str = format!("{}/nodes/{node}/qemu/{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::QemuMigrateVmPreconditionResponse`"))),
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::QemuMigrateVmPreconditionResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<QemuMigrateVmPreconditionError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Execute QEMU monitor commands. Permissions: The following commands do not require any additional privilege: ?, help, info The following commands require 'Sys.Modify': announce_self, backup_cancel, balloon, block_job_cancel, block_job_complete, block_job_pause, block_job_resume, block_job_set_speed, block_resize, block_set_io_throttle, boot_set, c, calc_dirty_rate, cancel_vcpu_dirty_limit, chardev-send-break, closefd, commit, cont, cpu, delvm, eject, exit_preconfig, expire_password, getfd, gpa2hpa, gpa2hva, gva2gpa, i, loadvm, log, migrate_cancel, migrate_continue, migrate_pause, migrate_set_capability, migrate_set_parameter, migrate_start_postcopy, mouse_button, mouse_move, mouse_set, one-insn-per-tb, p, print, q, qemu-io, qom-get, qom-list, quit, replay_break, replay_delete_break, replay_seek, ringbuf_read, ringbuf_write, s, savevm, sendkey, set_link, set_password, set_vcpu_dirty_limit, snapshot_blkdev_internal, snapshot_delete_blkdev_internal, stop, stopcapture, sum, sync-profile, system_powerdown, system_reset, system_wakeup, trace-event, x, x_colo_lost_heartbeat, xp The following commands are root-only: backup, block_stream, change, chardev-add, chardev-change, chardev-remove, client_migrate_info, device_add, device_del, drive_add, drive_backup, drive_del, drive_mirror, dump-guest-memory, dumpdtb, gdbserver, hostfwd_add, hostfwd_remove, logfile, mce, memsave, migrate, migrate_incoming, migrate_recover, nbd_server_add, nbd_server_remove, nbd_server_start, nbd_server_stop, netdev_add, netdev_del, nmi, o, object_add, object_del, pcie_aer_inject_error, pmemsave, qom-set, savevm-end, savevm-start, screendump, snapshot_blkdev, watchdog_action, wavcapture, xen-event-inject, xen-event-list The following commands are deprecated: stopcapture, wavcapture
pub async fn qemu_monitor(configuration: &configuration::Configuration, node: &str, vmid: i32, qemu_monitor_request: models::QemuMonitorRequest) -> Result<models::QemuMonitorResponse, Error<QemuMonitorError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_node = node;
let p_path_vmid = vmid;
let p_body_qemu_monitor_request = qemu_monitor_request;
let uri_str = format!("{}/nodes/{node}/qemu/{vmid}/monitor", 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_qemu_monitor_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::QemuMonitorResponse`"))),
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::QemuMonitorResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<QemuMonitorError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Move volume to different storage or to a different VM. Permissions: You need 'VM.Config.Disk' permissions on /vms/{vmid}, and 'Datastore.AllocateSpace' permissions on the storage. To move a disk to another VM, you need the permissions on the target VM as well.
pub async fn qemu_move_vm_disk(configuration: &configuration::Configuration, node: &str, vmid: i32, qemu_move_vm_disk_request: models::QemuMoveVmDiskRequest) -> Result<models::QemuMoveVmDiskResponse, Error<QemuMoveVmDiskError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_node = node;
let p_path_vmid = vmid;
let p_body_qemu_move_vm_disk_request = qemu_move_vm_disk_request;
let uri_str = format!("{}/nodes/{node}/qemu/{vmid}/move_disk", 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_qemu_move_vm_disk_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::QemuMoveVmDiskResponse`"))),
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::QemuMoveVmDiskResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<QemuMoveVmDiskError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Migration tunnel endpoint - only for internal use by VM migration. Permissions: You need 'VM.Allocate' permissions on '/vms/{vmid}' and Sys.Incoming on '/'. Further permission checks happen during the actual migration.
pub async fn qemu_mtunnel(configuration: &configuration::Configuration, node: &str, vmid: i32, lxc_mtunnel_request: Option<models::LxcMtunnelRequest>) -> Result<models::QemuMtunnelResponse, Error<QemuMtunnelError>> {
// add a prefix to parameters to efficiently prevent name collisions
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}/qemu/{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::QemuMtunnelResponse`"))),
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::QemuMtunnelResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<QemuMtunnelError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Migration tunnel endpoint for websocket upgrade - only for internal use by VM migration. Permissions: You need to pass a ticket valid for the selected socket. Tickets can be created via the mtunnel API call, which will check permissions accordingly.
pub async fn qemu_mtunnelwebsocket(configuration: &configuration::Configuration, node: &str, socket: &str, ticket: &str, vmid: i32) -> Result<models::QemuMtunnelwebsocketResponse, Error<QemuMtunnelwebsocketError>> {
// add a prefix to parameters to efficiently prevent name collisions
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}/qemu/{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::QemuMtunnelwebsocketResponse`"))),
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::QemuMtunnelwebsocketResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<QemuMtunnelwebsocketError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Execute network-get-interfaces.
pub async fn qemu_network_get_interfaces(configuration: &configuration::Configuration, node: &str, vmid: i32) -> Result<models::QemuNetworkGetInterfacesResponse, Error<QemuNetworkGetInterfacesError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_node = node;
let p_path_vmid = vmid;
let uri_str = format!("{}/nodes/{node}/qemu/{vmid}/agent/network-get-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::QemuNetworkGetInterfacesResponse`"))),
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::QemuNetworkGetInterfacesResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<QemuNetworkGetInterfacesError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Execute ping.
pub async fn qemu_ping(configuration: &configuration::Configuration, node: &str, vmid: i32) -> Result<models::QemuPingResponse, Error<QemuPingError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_node = node;
let p_path_vmid = vmid;
let uri_str = format!("{}/nodes/{node}/qemu/{vmid}/agent/ping", 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::QemuPingResponse`"))),
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::QemuPingResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<QemuPingError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Read alias.
pub async fn qemu_read_alias(configuration: &configuration::Configuration, name: &str, node: &str, vmid: i32) -> Result<models::QemuReadAliasResponse, Error<QemuReadAliasError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_name = name;
let p_path_node = node;
let p_path_vmid = vmid;
let uri_str = format!("{}/nodes/{node}/qemu/{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::QemuReadAliasResponse`"))),
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::QemuReadAliasResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<QemuReadAliasError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Read IP or Network settings from IPSet.
pub async fn qemu_read_ip(configuration: &configuration::Configuration, cidr: &str, name: &str, node: &str, vmid: i32) -> Result<models::QemuReadIpResponse, Error<QemuReadIpError>> {
// add a prefix to parameters to efficiently prevent name collisions
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}/qemu/{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::QemuReadIpResponse`"))),
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::QemuReadIpResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<QemuReadIpError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Lists possible IPSet/Alias reference which are allowed in source/dest properties.
pub async fn qemu_refs(configuration: &configuration::Configuration, node: &str, vmid: i32, r#type: Option<models::PveTypeTypeEnum>) -> Result<models::QemuRefsResponse, Error<QemuRefsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_node = node;
let p_path_vmid = vmid;
let p_query_type = r#type;
let uri_str = format!("{}/nodes/{node}/qemu/{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::QemuRefsResponse`"))),
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::QemuRefsResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<QemuRefsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Migrate virtual machine to a remote cluster. Creates a new migration task. EXPERIMENTAL feature!
pub async fn qemu_remote_migrate_vm(configuration: &configuration::Configuration, node: &str, vmid: i32, qemu_remote_migrate_vm_request: models::QemuRemoteMigrateVmRequest) -> Result<models::QemuRemoteMigrateVmResponse, Error<QemuRemoteMigrateVmError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_node = node;
let p_path_vmid = vmid;
let p_body_qemu_remote_migrate_vm_request = qemu_remote_migrate_vm_request;
let uri_str = format!("{}/nodes/{node}/qemu/{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_qemu_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::QemuRemoteMigrateVmResponse`"))),
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::QemuRemoteMigrateVmResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<QemuRemoteMigrateVmError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Remove IP or Network alias.
pub async fn qemu_remove_alias(configuration: &configuration::Configuration, name: &str, node: &str, vmid: i32, digest: Option<&str>) -> Result<models::QemuRemoveAliasResponse, Error<QemuRemoveAliasError>> {
// add a prefix to parameters to efficiently prevent name collisions
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}/qemu/{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::QemuRemoveAliasResponse`"))),
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::QemuRemoveAliasResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<QemuRemoveAliasError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Remove IP or Network from IPSet.
pub async fn qemu_remove_ip(configuration: &configuration::Configuration, cidr: &str, name: &str, node: &str, vmid: i32, digest: Option<&str>) -> Result<models::QemuRemoveIpResponse, Error<QemuRemoveIpError>> {
// add a prefix to parameters to efficiently prevent name collisions
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}/qemu/{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::QemuRemoveIpResponse`"))),
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::QemuRemoveIpResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<QemuRemoveIpError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Extend volume size.
pub async fn qemu_resize_vm(configuration: &configuration::Configuration, node: &str, vmid: i32, qemu_resize_vm_request: models::QemuResizeVmRequest) -> Result<models::QemuResizeVmResponse, Error<QemuResizeVmError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_node = node;
let p_path_vmid = vmid;
let p_body_qemu_resize_vm_request = qemu_resize_vm_request;
let uri_str = format!("{}/nodes/{node}/qemu/{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_qemu_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::QemuResizeVmResponse`"))),
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::QemuResizeVmResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<QemuResizeVmError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Rollback VM state to specified snapshot.
pub async fn qemu_rollback(configuration: &configuration::Configuration, node: &str, snapname: &str, vmid: i32, qemu_rollback_request: Option<models::QemuRollbackRequest>) -> Result<models::QemuRollbackResponse, Error<QemuRollbackError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_node = node;
let p_path_snapname = snapname;
let p_path_vmid = vmid;
let p_body_qemu_rollback_request = qemu_rollback_request;
let uri_str = format!("{}/nodes/{node}/qemu/{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_qemu_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::QemuRollbackResponse`"))),
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::QemuRollbackResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<QemuRollbackError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Read VM RRD statistics (returns PNG)
pub async fn qemu_rrd(configuration: &configuration::Configuration, ds: &str, node: &str, timeframe: models::PveTimeframeEnum, vmid: i32, cf: Option<models::PveCfEnum>) -> Result<models::QemuRrdResponse, Error<QemuRrdError>> {
// add a prefix to parameters to efficiently prevent name collisions
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}/qemu/{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::QemuRrdResponse`"))),
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::QemuRrdResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<QemuRrdError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Read VM RRD statistics
pub async fn qemu_rrddata(configuration: &configuration::Configuration, node: &str, timeframe: models::PveTimeframeEnum, vmid: i32, cf: Option<models::PveCfEnum>) -> Result<models::QemuRrddataResponse, Error<QemuRrddataError>> {
// add a prefix to parameters to efficiently prevent name collisions
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}/qemu/{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::QemuRrddataResponse`"))),
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::QemuRrddataResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<QemuRrddataError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Set Firewall options.
pub async fn qemu_set_options(configuration: &configuration::Configuration, node: &str, vmid: i32, lxc_set_options_request: Option<models::LxcSetOptionsRequest>) -> Result<models::QemuSetOptionsResponse, Error<QemuSetOptionsError>> {
// add a prefix to parameters to efficiently prevent name collisions
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}/qemu/{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::QemuSetOptionsResponse`"))),
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::QemuSetOptionsResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<QemuSetOptionsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Sets the password for the given user to the given password
pub async fn qemu_set_user_password(configuration: &configuration::Configuration, node: &str, vmid: i32, qemu_set_user_password_request: models::QemuSetUserPasswordRequest) -> Result<models::QemuSetUserPasswordResponse, Error<QemuSetUserPasswordError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_node = node;
let p_path_vmid = vmid;
let p_body_qemu_set_user_password_request = qemu_set_user_password_request;
let uri_str = format!("{}/nodes/{node}/qemu/{vmid}/agent/set-user-password", 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_qemu_set_user_password_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::QemuSetUserPasswordResponse`"))),
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::QemuSetUserPasswordResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<QemuSetUserPasswordError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Execute shutdown.
pub async fn qemu_shutdown(configuration: &configuration::Configuration, node: &str, vmid: i32) -> Result<models::QemuShutdownResponse, Error<QemuShutdownError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_node = node;
let p_path_vmid = vmid;
let uri_str = format!("{}/nodes/{node}/qemu/{vmid}/agent/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);
};
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::QemuShutdownResponse`"))),
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::QemuShutdownResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<QemuShutdownError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Snapshot a VM.
pub async fn qemu_snapshot(configuration: &configuration::Configuration, node: &str, vmid: i32, qemu_snapshot_request: models::QemuSnapshotRequest) -> Result<models::QemuSnapshotResponse, Error<QemuSnapshotError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_node = node;
let p_path_vmid = vmid;
let p_body_qemu_snapshot_request = qemu_snapshot_request;
let uri_str = format!("{}/nodes/{node}/qemu/{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_qemu_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::QemuSnapshotResponse`"))),
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::QemuSnapshotResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<QemuSnapshotError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
///
pub async fn qemu_snapshot_cmd_idx(configuration: &configuration::Configuration, node: &str, snapname: &str, vmid: i32) -> Result<models::QemuSnapshotCmdIdxResponse, Error<QemuSnapshotCmdIdxError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_node = node;
let p_path_snapname = snapname;
let p_path_vmid = vmid;
let uri_str = format!("{}/nodes/{node}/qemu/{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::QemuSnapshotCmdIdxResponse`"))),
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::QemuSnapshotCmdIdxResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<QemuSnapshotCmdIdxError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// List all snapshots.
pub async fn qemu_snapshot_list(configuration: &configuration::Configuration, node: &str, vmid: i32) -> Result<models::QemuSnapshotListResponse, Error<QemuSnapshotListError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_node = node;
let p_path_vmid = vmid;
let uri_str = format!("{}/nodes/{node}/qemu/{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::QemuSnapshotListResponse`"))),
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::QemuSnapshotListResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<QemuSnapshotListError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Returns a SPICE configuration to connect to the VM.
pub async fn qemu_spiceproxy(configuration: &configuration::Configuration, node: &str, vmid: i32, lxc_spiceproxy_request: Option<models::LxcSpiceproxyRequest>) -> Result<models::QemuSpiceproxyResponse, Error<QemuSpiceproxyError>> {
// add a prefix to parameters to efficiently prevent name collisions
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}/qemu/{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::QemuSpiceproxyResponse`"))),
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::QemuSpiceproxyResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<QemuSpiceproxyError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Execute suspend-disk.
pub async fn qemu_suspend_disk(configuration: &configuration::Configuration, node: &str, vmid: i32) -> Result<models::QemuSuspendDiskResponse, Error<QemuSuspendDiskError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_node = node;
let p_path_vmid = vmid;
let uri_str = format!("{}/nodes/{node}/qemu/{vmid}/agent/suspend-disk", 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::QemuSuspendDiskResponse`"))),
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::QemuSuspendDiskResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<QemuSuspendDiskError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Execute suspend-hybrid.
pub async fn qemu_suspend_hybrid(configuration: &configuration::Configuration, node: &str, vmid: i32) -> Result<models::QemuSuspendHybridResponse, Error<QemuSuspendHybridError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_node = node;
let p_path_vmid = vmid;
let uri_str = format!("{}/nodes/{node}/qemu/{vmid}/agent/suspend-hybrid", 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::QemuSuspendHybridResponse`"))),
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::QemuSuspendHybridResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<QemuSuspendHybridError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Execute suspend-ram.
pub async fn qemu_suspend_ram(configuration: &configuration::Configuration, node: &str, vmid: i32) -> Result<models::QemuSuspendRamResponse, Error<QemuSuspendRamError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_node = node;
let p_path_vmid = vmid;
let uri_str = format!("{}/nodes/{node}/qemu/{vmid}/agent/suspend-ram", 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::QemuSuspendRamResponse`"))),
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::QemuSuspendRamResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<QemuSuspendRamError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Create a Template. Permissions: You need 'VM.Allocate' permissions on /vms/{vmid}
pub async fn qemu_template(configuration: &configuration::Configuration, node: &str, vmid: i32, qemu_template_request: Option<models::QemuTemplateRequest>) -> Result<models::QemuTemplateResponse, Error<QemuTemplateError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_node = node;
let p_path_vmid = vmid;
let p_body_qemu_template_request = qemu_template_request;
let uri_str = format!("{}/nodes/{node}/qemu/{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);
};
req_builder = req_builder.json(&p_body_qemu_template_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::QemuTemplateResponse`"))),
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::QemuTemplateResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<QemuTemplateError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Creates a TCP proxy connections.
pub async fn qemu_termproxy(configuration: &configuration::Configuration, node: &str, vmid: i32, qemu_termproxy_request: Option<models::QemuTermproxyRequest>) -> Result<models::QemuTermproxyResponse, Error<QemuTermproxyError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_node = node;
let p_path_vmid = vmid;
let p_body_qemu_termproxy_request = qemu_termproxy_request;
let uri_str = format!("{}/nodes/{node}/qemu/{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);
};
req_builder = req_builder.json(&p_body_qemu_termproxy_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::QemuTermproxyResponse`"))),
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::QemuTermproxyResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<QemuTermproxyError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Unlink/delete disk images.
pub async fn qemu_unlink(configuration: &configuration::Configuration, node: &str, vmid: i32, qemu_unlink_request: models::QemuUnlinkRequest) -> Result<models::QemuUnlinkResponse, Error<QemuUnlinkError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_node = node;
let p_path_vmid = vmid;
let p_body_qemu_unlink_request = qemu_unlink_request;
let uri_str = format!("{}/nodes/{node}/qemu/{vmid}/unlink", 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_qemu_unlink_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::QemuUnlinkResponse`"))),
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::QemuUnlinkResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<QemuUnlinkError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Update IP or Network alias.
pub async fn qemu_update_alias(configuration: &configuration::Configuration, name: &str, node: &str, vmid: i32, cluster_firewall_update_alias_request: models::ClusterFirewallUpdateAliasRequest) -> Result<models::QemuUpdateAliasResponse, Error<QemuUpdateAliasError>> {
// add a prefix to parameters to efficiently prevent name collisions
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}/qemu/{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::QemuUpdateAliasResponse`"))),
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::QemuUpdateAliasResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<QemuUpdateAliasError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Update IP or Network settings
pub async fn qemu_update_ip(configuration: &configuration::Configuration, cidr: &str, name: &str, node: &str, vmid: i32, cluster_firewall_update_ip_request: Option<models::ClusterFirewallUpdateIpRequest>) -> Result<models::QemuUpdateIpResponse, Error<QemuUpdateIpError>> {
// add a prefix to parameters to efficiently prevent name collisions
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}/qemu/{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::QemuUpdateIpResponse`"))),
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::QemuUpdateIpResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<QemuUpdateIpError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Modify rule data.
pub async fn qemu_update_rule(configuration: &configuration::Configuration, node: &str, pos: i64, vmid: i32, cluster_firewall_update_rule_request: Option<models::ClusterFirewallUpdateRuleRequest>) -> Result<models::QemuUpdateRuleResponse, Error<QemuUpdateRuleError>> {
// add a prefix to parameters to efficiently prevent name collisions
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}/qemu/{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::QemuUpdateRuleResponse`"))),
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::QemuUpdateRuleResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<QemuUpdateRuleError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Update snapshot metadata.
pub async fn qemu_update_snapshot_config(configuration: &configuration::Configuration, node: &str, snapname: &str, vmid: i32, lxc_update_snapshot_config_request: Option<models::LxcUpdateSnapshotConfigRequest>) -> Result<models::QemuUpdateSnapshotConfigResponse, Error<QemuUpdateSnapshotConfigError>> {
// add a prefix to parameters to efficiently prevent name collisions
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}/qemu/{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::QemuUpdateSnapshotConfigResponse`"))),
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::QemuUpdateSnapshotConfigResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<QemuUpdateSnapshotConfigError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Set virtual machine options (synchronous API) - You should consider using the POST method instead for any actions involving hotplug or storage allocation.
pub async fn qemu_update_vm(configuration: &configuration::Configuration, node: &str, vmid: i32, qemu_update_vm_request: Option<models::QemuUpdateVmRequest>) -> Result<models::QemuUpdateVmResponse, Error<QemuUpdateVmError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_node = node;
let p_path_vmid = vmid;
let p_body_qemu_update_vm_request = qemu_update_vm_request;
let uri_str = format!("{}/nodes/{node}/qemu/{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_qemu_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::QemuUpdateVmResponse`"))),
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::QemuUpdateVmResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<QemuUpdateVmError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Set virtual machine options (asynchronous API).
pub async fn qemu_update_vm_async_op(configuration: &configuration::Configuration, node: &str, vmid: i32, qemu_update_vm_async_op_request: Option<models::QemuUpdateVmAsyncOpRequest>) -> Result<models::QemuUpdateVmAsyncOpResponse, Error<QemuUpdateVmAsyncOpError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_node = node;
let p_path_vmid = vmid;
let p_body_qemu_update_vm_async_op_request = qemu_update_vm_async_op_request;
let uri_str = format!("{}/nodes/{node}/qemu/{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::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_qemu_update_vm_async_op_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::QemuUpdateVmAsyncOpResponse`"))),
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::QemuUpdateVmAsyncOpResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<QemuUpdateVmAsyncOpError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Get the virtual machine configuration with pending configuration changes applied. Set the 'current' parameter to get the current configuration instead.
pub async fn qemu_vm_config(configuration: &configuration::Configuration, node: &str, vmid: i32, current: Option<&str>, snapshot: Option<&str>) -> Result<models::QemuVmConfigResponse, Error<QemuVmConfigError>> {
// add a prefix to parameters to efficiently prevent name collisions
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}/qemu/{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::QemuVmConfigResponse`"))),
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::QemuVmConfigResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<QemuVmConfigError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Check if feature for virtual machine is available.
pub async fn qemu_vm_feature(configuration: &configuration::Configuration, feature: models::PveFeatureEnum, node: &str, vmid: i32, snapname: Option<&str>) -> Result<models::QemuVmFeatureResponse, Error<QemuVmFeatureError>> {
// add a prefix to parameters to efficiently prevent name collisions
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}/qemu/{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::QemuVmFeatureResponse`"))),
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::QemuVmFeatureResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<QemuVmFeatureError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Get the virtual machine configuration with both current and pending values.
pub async fn qemu_vm_pending(configuration: &configuration::Configuration, node: &str, vmid: i32) -> Result<models::QemuVmPendingResponse, Error<QemuVmPendingError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_node = node;
let p_path_vmid = vmid;
let uri_str = format!("{}/nodes/{node}/qemu/{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::QemuVmPendingResponse`"))),
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::QemuVmPendingResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<QemuVmPendingError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Reboot the VM by shutting it down, and starting it again. Applies pending changes.
pub async fn qemu_vm_reboot(configuration: &configuration::Configuration, node: &str, vmid: i32, lxc_vm_reboot_request: Option<models::LxcVmRebootRequest>) -> Result<models::QemuVmRebootResponse, Error<QemuVmRebootError>> {
// add a prefix to parameters to efficiently prevent name collisions
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}/qemu/{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::QemuVmRebootResponse`"))),
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::QemuVmRebootResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<QemuVmRebootError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Reset virtual machine.
pub async fn qemu_vm_reset(configuration: &configuration::Configuration, node: &str, vmid: i32, qemu_vm_reset_request: Option<models::QemuVmResetRequest>) -> Result<models::QemuVmResetResponse, Error<QemuVmResetError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_node = node;
let p_path_vmid = vmid;
let p_body_qemu_vm_reset_request = qemu_vm_reset_request;
let uri_str = format!("{}/nodes/{node}/qemu/{vmid}/status/reset", 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_qemu_vm_reset_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::QemuVmResetResponse`"))),
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::QemuVmResetResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<QemuVmResetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Resume virtual machine.
pub async fn qemu_vm_resume(configuration: &configuration::Configuration, node: &str, vmid: i32, qemu_vm_resume_request: Option<models::QemuVmResumeRequest>) -> Result<models::QemuVmResumeResponse, Error<QemuVmResumeError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_node = node;
let p_path_vmid = vmid;
let p_body_qemu_vm_resume_request = qemu_vm_resume_request;
let uri_str = format!("{}/nodes/{node}/qemu/{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);
};
req_builder = req_builder.json(&p_body_qemu_vm_resume_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::QemuVmResumeResponse`"))),
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::QemuVmResumeResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<QemuVmResumeError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Send key event to virtual machine.
pub async fn qemu_vm_sendkey(configuration: &configuration::Configuration, node: &str, vmid: i32, qemu_vm_sendkey_request: models::QemuVmSendkeyRequest) -> Result<models::QemuVmSendkeyResponse, Error<QemuVmSendkeyError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_node = node;
let p_path_vmid = vmid;
let p_body_qemu_vm_sendkey_request = qemu_vm_sendkey_request;
let uri_str = format!("{}/nodes/{node}/qemu/{vmid}/sendkey", 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_qemu_vm_sendkey_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::QemuVmSendkeyResponse`"))),
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::QemuVmSendkeyResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<QemuVmSendkeyError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Shutdown virtual machine. This is similar to pressing the power button on a physical machine. This will send an ACPI event for the guest OS, which should then proceed to a clean shutdown.
pub async fn qemu_vm_shutdown(configuration: &configuration::Configuration, node: &str, vmid: i32, qemu_vm_shutdown_request: Option<models::QemuVmShutdownRequest>) -> Result<models::QemuVmShutdownResponse, Error<QemuVmShutdownError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_node = node;
let p_path_vmid = vmid;
let p_body_qemu_vm_shutdown_request = qemu_vm_shutdown_request;
let uri_str = format!("{}/nodes/{node}/qemu/{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_qemu_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::QemuVmShutdownResponse`"))),
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::QemuVmShutdownResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<QemuVmShutdownError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Start virtual machine.
pub async fn qemu_vm_start(configuration: &configuration::Configuration, node: &str, vmid: i32, qemu_vm_start_request: Option<models::QemuVmStartRequest>) -> Result<models::QemuVmStartResponse, Error<QemuVmStartError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_node = node;
let p_path_vmid = vmid;
let p_body_qemu_vm_start_request = qemu_vm_start_request;
let uri_str = format!("{}/nodes/{node}/qemu/{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_qemu_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::QemuVmStartResponse`"))),
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::QemuVmStartResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<QemuVmStartError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Get virtual machine status.
pub async fn qemu_vm_status(configuration: &configuration::Configuration, node: &str, vmid: i32) -> Result<models::QemuVmStatusResponse, Error<QemuVmStatusError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_node = node;
let p_path_vmid = vmid;
let uri_str = format!("{}/nodes/{node}/qemu/{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::QemuVmStatusResponse`"))),
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::QemuVmStatusResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<QemuVmStatusError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Stop virtual machine. The qemu process will exit immediately. This is akin to pulling the power plug of a running computer and may damage the VM data.
pub async fn qemu_vm_stop(configuration: &configuration::Configuration, node: &str, vmid: i32, qemu_vm_stop_request: Option<models::QemuVmStopRequest>) -> Result<models::QemuVmStopResponse, Error<QemuVmStopError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_node = node;
let p_path_vmid = vmid;
let p_body_qemu_vm_stop_request = qemu_vm_stop_request;
let uri_str = format!("{}/nodes/{node}/qemu/{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_qemu_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::QemuVmStopResponse`"))),
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::QemuVmStopResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<QemuVmStopError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Suspend virtual machine. Permissions: You need 'VM.PowerMgmt' on /vms/{vmid}, and if you have set 'todisk', you need also 'VM.Config.Disk' on /vms/{vmid} and 'Datastore.AllocateSpace' on the storage for the vmstate.
pub async fn qemu_vm_suspend(configuration: &configuration::Configuration, node: &str, vmid: i32, qemu_vm_suspend_request: Option<models::QemuVmSuspendRequest>) -> Result<models::QemuVmSuspendResponse, Error<QemuVmSuspendError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_node = node;
let p_path_vmid = vmid;
let p_body_qemu_vm_suspend_request = qemu_vm_suspend_request;
let uri_str = format!("{}/nodes/{node}/qemu/{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);
};
req_builder = req_builder.json(&p_body_qemu_vm_suspend_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::QemuVmSuspendResponse`"))),
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::QemuVmSuspendResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<QemuVmSuspendError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Directory index
pub async fn qemu_vmcmdidx(configuration: &configuration::Configuration, node: &str, vmid: i32) -> Result<models::QemuVmcmdidxResponse, Error<QemuVmcmdidxError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_node = node;
let p_path_vmid = vmid;
let uri_str = format!("{}/nodes/{node}/qemu/{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::QemuVmcmdidxResponse`"))),
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::QemuVmcmdidxResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<QemuVmcmdidxError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Directory index
pub async fn qemu_vmdiridx(configuration: &configuration::Configuration, node: &str, vmid: i32) -> Result<models::QemuVmdiridxResponse, Error<QemuVmdiridxError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_node = node;
let p_path_vmid = vmid;
let uri_str = format!("{}/nodes/{node}/qemu/{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::QemuVmdiridxResponse`"))),
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::QemuVmdiridxResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<QemuVmdiridxError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Virtual machine index (per node). Permissions: Only list VMs where you have VM.Audit permissions on /vms/<vmid>.
pub async fn qemu_vmlist(configuration: &configuration::Configuration, node: &str, full: Option<&str>) -> Result<models::QemuVmlistResponse, Error<QemuVmlistError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_node = node;
let p_query_full = full;
let uri_str = format!("{}/nodes/{node}/qemu", 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 param_value) = p_query_full {
req_builder = req_builder.query(&[("full", ¶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::QemuVmlistResponse`"))),
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::QemuVmlistResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<QemuVmlistError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Creates a TCP VNC proxy connections.
pub async fn qemu_vncproxy(configuration: &configuration::Configuration, node: &str, vmid: i32, qemu_vncproxy_request: Option<models::QemuVncproxyRequest>) -> Result<models::QemuVncproxyResponse, Error<QemuVncproxyError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_node = node;
let p_path_vmid = vmid;
let p_body_qemu_vncproxy_request = qemu_vncproxy_request;
let uri_str = format!("{}/nodes/{node}/qemu/{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_qemu_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::QemuVncproxyResponse`"))),
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::QemuVncproxyResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<QemuVncproxyError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Opens a websocket for VNC traffic. Permissions: You also need to pass a valid ticket (vncticket). Wire-level note: this endpoint answers HTTP 101 Upgrade, not a JSON body. The 200 schema below is the apidoc-declared shape for tooling, but real clients perform a WebSocket upgrade and exchange framed messages on the resulting socket. See the `x-pve-websocket` extension for the framing and the list of sibling endpoints that issue tickets.
pub async fn qemu_vncwebsocket(configuration: &configuration::Configuration, node: &str, port: i32, vmid: i32, vncticket: &str) -> Result<models::QemuVncwebsocketResponse, Error<QemuVncwebsocketError>> {
// add a prefix to parameters to efficiently prevent name collisions
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}/qemu/{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::QemuVncwebsocketResponse`"))),
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::QemuVncwebsocketResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<QemuVncwebsocketError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}