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 [`access_change_password`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum AccessChangePasswordError {
    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 [`access_get_access`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum AccessGetAccessError {
    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 [`access_permissions`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum AccessPermissionsError {
    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 [`access_verify_vnc_ticket`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum AccessVerifyVncTicketError {
    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),
}


/// Change user password.  Permissions: Each user is allowed to change their own password. A user can change the password of another user if they have 'Realm.AllocateUser' (on the realm of user <userid>) and 'User.Modify' permission on /access/groups/<group> on a group where user <userid> is member of. For the PAM realm, a password change does not take  effect cluster-wide, but only applies to the local node.
pub async fn access_change_password(configuration: &configuration::Configuration, access_change_password_request: models::AccessChangePasswordRequest) -> Result<models::AccessChangePasswordResponse, Error<AccessChangePasswordError>> {
    // add a prefix to parameters to efficiently prevent name collisions
    let p_body_access_change_password_request = access_change_password_request;

    let uri_str = format!("{}/access/password", configuration.base_path);
    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("CSRFPreventionToken", value);
    };
    req_builder = req_builder.json(&p_body_access_change_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::AccessChangePasswordResponse`"))),
            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::AccessChangePasswordResponse`")))),
        }
    } else {
        let content = resp.text().await?;
        let entity: Option<AccessChangePasswordError> = serde_json::from_str(&content).ok();
        Err(Error::ResponseError(ResponseContent { status, content, entity }))
    }
}

/// Directory index.
pub async fn access_get_access(configuration: &configuration::Configuration, ) -> Result<models::AccessGetAccessResponse, Error<AccessGetAccessError>> {

    let uri_str = format!("{}/access", configuration.base_path);
    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::AccessGetAccessResponse`"))),
            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::AccessGetAccessResponse`")))),
        }
    } else {
        let content = resp.text().await?;
        let entity: Option<AccessGetAccessError> = serde_json::from_str(&content).ok();
        Err(Error::ResponseError(ResponseContent { status, content, entity }))
    }
}

/// Retrieve effective permissions of given user/token.  Permissions: Each user/token is allowed to dump their own permissions (or that of owned tokens). A user can dump the permissions of another user or their tokens if they have 'Sys.Audit' permission on /access.
pub async fn access_permissions(configuration: &configuration::Configuration, path: Option<&str>, userid: Option<&str>) -> Result<models::AccessPermissionsResponse, Error<AccessPermissionsError>> {
    // add a prefix to parameters to efficiently prevent name collisions
    let p_query_path = path;
    let p_query_userid = userid;

    let uri_str = format!("{}/access/permissions", configuration.base_path);
    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);

    if let Some(ref param_value) = p_query_path {
        req_builder = req_builder.query(&[("path", &param_value.to_string())]);
    }
    if let Some(ref param_value) = p_query_userid {
        req_builder = req_builder.query(&[("userid", &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::AccessPermissionsResponse`"))),
            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::AccessPermissionsResponse`")))),
        }
    } else {
        let content = resp.text().await?;
        let entity: Option<AccessPermissionsError> = serde_json::from_str(&content).ok();
        Err(Error::ResponseError(ResponseContent { status, content, entity }))
    }
}

/// verify VNC authentication ticket.  Permissions: You need to pass valid credientials.
pub async fn access_verify_vnc_ticket(configuration: &configuration::Configuration, access_verify_vnc_ticket_request: models::AccessVerifyVncTicketRequest) -> Result<models::AccessVerifyVncTicketResponse, Error<AccessVerifyVncTicketError>> {
    // add a prefix to parameters to efficiently prevent name collisions
    let p_body_access_verify_vnc_ticket_request = access_verify_vnc_ticket_request;

    let uri_str = format!("{}/access/vncticket", configuration.base_path);
    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());
    }
    req_builder = req_builder.json(&p_body_access_verify_vnc_ticket_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::AccessVerifyVncTicketResponse`"))),
            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::AccessVerifyVncTicketResponse`")))),
        }
    } else {
        let content = resp.text().await?;
        let entity: Option<AccessVerifyVncTicketError> = serde_json::from_str(&content).ok();
        Err(Error::ResponseError(ResponseContent { status, content, entity }))
    }
}