clientapi-pve 2026.5.24

Generated from apidoc.js. NOT an official Proxmox specification. See https://pve.proxmox.com/pve-docs/api-viewer/ for the upstream documentation.
Documentation
/*
 * 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 [`nodes_hardware_get_hardware`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum NodesHardwareGetHardwareError {
    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 [`nodes_hardware_mdevscan`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum NodesHardwareMdevscanError {
    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 [`nodes_hardware_pci_index`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum NodesHardwarePciIndexError {
    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 [`nodes_hardware_pci_scan`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum NodesHardwarePciScanError {
    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 [`nodes_hardware_usbscan`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum NodesHardwareUsbscanError {
    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),
}


/// Index of hardware types
pub async fn nodes_hardware_get_hardware(configuration: &configuration::Configuration, node: &str) -> Result<models::NodesHardwareGetHardwareResponse, Error<NodesHardwareGetHardwareError>> {
    // add a prefix to parameters to efficiently prevent name collisions
    let p_path_node = node;

    let uri_str = format!("{}/nodes/{node}/hardware", configuration.base_path, node=crate::apis::urlencode(p_path_node));
    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);

    if let Some(ref user_agent) = configuration.user_agent {
        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
    }
    if let Some(ref apikey) = configuration.api_key {
        let key = apikey.key.clone();
        let value = match apikey.prefix {
            Some(ref prefix) => format!("{} {}", prefix, key),
            None => key,
        };
        req_builder = req_builder.header("Authorization", value);
    };
    if let Some(ref apikey) = configuration.api_key {
        let key = apikey.key.clone();
        let value = match apikey.prefix {
            Some(ref prefix) => format!("{} {}", prefix, key),
            None => key,
        };
        req_builder = req_builder.header("CSRFPreventionToken", value);
    };

    let req = req_builder.build()?;
    let resp = configuration.client.execute(req).await?;

    let status = resp.status();
    let content_type = resp
        .headers()
        .get("content-type")
        .and_then(|v| v.to_str().ok())
        .unwrap_or("application/octet-stream");
    let content_type = super::ContentType::from(content_type);

    if !status.is_client_error() && !status.is_server_error() {
        let content = resp.text().await?;
        match content_type {
            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::NodesHardwareGetHardwareResponse`"))),
            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::NodesHardwareGetHardwareResponse`")))),
        }
    } else {
        let content = resp.text().await?;
        let entity: Option<NodesHardwareGetHardwareError> = serde_json::from_str(&content).ok();
        Err(Error::ResponseError(ResponseContent { status, content, entity }))
    }
}

/// List mediated device types for given PCI device.
pub async fn nodes_hardware_mdevscan(configuration: &configuration::Configuration, node: &str, pci_id_or_mapping: &str) -> Result<models::NodesHardwareMdevscanResponse, Error<NodesHardwareMdevscanError>> {
    // add a prefix to parameters to efficiently prevent name collisions
    let p_path_node = node;
    let p_path_pci_id_or_mapping = pci_id_or_mapping;

    let uri_str = format!("{}/nodes/{node}/hardware/pci/{pci_id_or_mapping}/mdev", configuration.base_path, node=crate::apis::urlencode(p_path_node), pci_id_or_mapping=crate::apis::urlencode(p_path_pci_id_or_mapping));
    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::NodesHardwareMdevscanResponse`"))),
            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::NodesHardwareMdevscanResponse`")))),
        }
    } else {
        let content = resp.text().await?;
        let entity: Option<NodesHardwareMdevscanError> = serde_json::from_str(&content).ok();
        Err(Error::ResponseError(ResponseContent { status, content, entity }))
    }
}

/// Index of available pci methods
pub async fn nodes_hardware_pci_index(configuration: &configuration::Configuration, node: &str, pci_id_or_mapping: &str) -> Result<models::NodesHardwarePciIndexResponse, Error<NodesHardwarePciIndexError>> {
    // add a prefix to parameters to efficiently prevent name collisions
    let p_path_node = node;
    let p_path_pci_id_or_mapping = pci_id_or_mapping;

    let uri_str = format!("{}/nodes/{node}/hardware/pci/{pci_id_or_mapping}", configuration.base_path, node=crate::apis::urlencode(p_path_node), pci_id_or_mapping=crate::apis::urlencode(p_path_pci_id_or_mapping));
    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::NodesHardwarePciIndexResponse`"))),
            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::NodesHardwarePciIndexResponse`")))),
        }
    } else {
        let content = resp.text().await?;
        let entity: Option<NodesHardwarePciIndexError> = serde_json::from_str(&content).ok();
        Err(Error::ResponseError(ResponseContent { status, content, entity }))
    }
}

/// List local PCI devices.
pub async fn nodes_hardware_pci_scan(configuration: &configuration::Configuration, node: &str, pci_class_blacklist: Option<&str>, verbose: Option<&str>) -> Result<models::NodesHardwarePciScanResponse, Error<NodesHardwarePciScanError>> {
    // add a prefix to parameters to efficiently prevent name collisions
    let p_path_node = node;
    let p_query_pci_class_blacklist = pci_class_blacklist;
    let p_query_verbose = verbose;

    let uri_str = format!("{}/nodes/{node}/hardware/pci", 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_pci_class_blacklist {
        req_builder = req_builder.query(&[("pci-class-blacklist", &param_value.to_string())]);
    }
    if let Some(ref param_value) = p_query_verbose {
        req_builder = req_builder.query(&[("verbose", &param_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::NodesHardwarePciScanResponse`"))),
            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::NodesHardwarePciScanResponse`")))),
        }
    } else {
        let content = resp.text().await?;
        let entity: Option<NodesHardwarePciScanError> = serde_json::from_str(&content).ok();
        Err(Error::ResponseError(ResponseContent { status, content, entity }))
    }
}

/// List local USB devices.
pub async fn nodes_hardware_usbscan(configuration: &configuration::Configuration, node: &str) -> Result<models::NodesHardwareUsbscanResponse, Error<NodesHardwareUsbscanError>> {
    // add a prefix to parameters to efficiently prevent name collisions
    let p_path_node = node;

    let uri_str = format!("{}/nodes/{node}/hardware/usb", configuration.base_path, node=crate::apis::urlencode(p_path_node));
    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);

    if let Some(ref user_agent) = configuration.user_agent {
        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
    }
    if let Some(ref apikey) = configuration.api_key {
        let key = apikey.key.clone();
        let value = match apikey.prefix {
            Some(ref prefix) => format!("{} {}", prefix, key),
            None => key,
        };
        req_builder = req_builder.header("Authorization", value);
    };
    if let Some(ref apikey) = configuration.api_key {
        let key = apikey.key.clone();
        let value = match apikey.prefix {
            Some(ref prefix) => format!("{} {}", prefix, key),
            None => key,
        };
        req_builder = req_builder.header("CSRFPreventionToken", value);
    };

    let req = req_builder.build()?;
    let resp = configuration.client.execute(req).await?;

    let status = resp.status();
    let content_type = resp
        .headers()
        .get("content-type")
        .and_then(|v| v.to_str().ok())
        .unwrap_or("application/octet-stream");
    let content_type = super::ContentType::from(content_type);

    if !status.is_client_error() && !status.is_server_error() {
        let content = resp.text().await?;
        match content_type {
            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::NodesHardwareUsbscanResponse`"))),
            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::NodesHardwareUsbscanResponse`")))),
        }
    } else {
        let content = resp.text().await?;
        let entity: Option<NodesHardwareUsbscanError> = serde_json::from_str(&content).ok();
        Err(Error::ResponseError(ResponseContent { status, content, entity }))
    }
}