perl-rs: add further apt api calls

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
This commit is contained in:
Dietmar Maurer 2024-07-02 14:15:04 +02:00 committed by Wolfgang Bumiller
parent 5c994bf942
commit 89d9debadb
4 changed files with 51 additions and 4 deletions

View File

@ -4,7 +4,8 @@ pub mod export {
use anyhow::Error;
use proxmox_apt_api_types::{
APTChangeRepositoryOptions, APTRepositoriesResult, APTRepositoryHandle,
APTChangeRepositoryOptions, APTGetChangelogOptions, APTRepositoriesResult,
APTRepositoryHandle, APTUpdateInfo, APTUpdateOptions,
};
use proxmox_config_digest::ConfigDigest;
@ -39,4 +40,50 @@ pub mod export {
) -> Result<(), Error> {
proxmox_apt::change_repository(path, index, &options, digest)
}
/// Retrieve the changelog of the specified package.
#[export]
pub fn get_changelog(options: APTGetChangelogOptions) -> Result<String, Error> {
proxmox_apt::get_changelog(&options)
}
/// List available APT updates
///
/// Automatically updates an expired package cache.
#[export]
pub fn list_available_apt_update(apt_state_file: &str) -> Result<Vec<APTUpdateInfo>, Error> {
proxmox_apt::list_available_apt_update(apt_state_file)
}
/// Update the APT database
///
/// You should update the APT proxy configuration before running this.
#[export]
pub fn update_database(apt_state_file: &str, options: APTUpdateOptions) -> Result<(), Error> {
proxmox_apt::update_database(
apt_state_file,
&options,
|_updates: &[&APTUpdateInfo]| -> Result<(), Error> {
// fixme: howto send notifgications?
Ok(())
},
)
}
/// Get package information for a list of important product packages.
#[export]
pub fn get_package_versions(
product_virtual_package: &str,
api_server_package: &str,
running_api_server_version: &str,
package_list: Vec<String>,
) -> Result<Vec<APTUpdateInfo>, Error> {
let package_list: Vec<&str> = package_list.iter().map(|s| s.as_ref()).collect();
proxmox_apt::get_package_versions(
product_virtual_package,
api_server_package,
running_api_server_version,
&package_list,
)
}
}

View File

@ -29,7 +29,7 @@ url = "2"
perlmod = { version = "0.13.4", features = ["exporter"] }
proxmox-acme = { version = "0.5", features = ["client", "api-types"] }
proxmox-apt = "0.11"
proxmox-apt = { version = "0.11", features = ["cache"] }
proxmox-apt-api-types = "1.0"
proxmox-config-digest = "0.1"
proxmox-http = { version = "0.9", features = ["client-sync", "client-trait"] }

View File

@ -31,7 +31,7 @@ url = "2"
perlmod = { version = "0.13", features = ["exporter"] }
proxmox-apt = "0.11"
proxmox-apt = { version = "0.11", features = ["cache"] }
proxmox-apt-api-types = "1.0"
proxmox-config-digest = "0.1"
proxmox-http = { version = "0.9", features = ["client-sync", "client-trait"] }

View File

@ -17,6 +17,6 @@ mod export {
#[export]
pub fn init() {
common::logger::init("PVE_LOG", "info");
proxmox_notify::context::set_context(&PVE_CONTEXT)
proxmox_notify::context::set_context(&PVE_CONTEXT);
}
}