Struct hrobot::AsyncRobot

source ·
pub struct AsyncRobot { /* private fields */ }
Expand description

Handles authentication and exposes the Hetzner Robot API functionality with a simple interface.

Example

an AsyncRobot using the HROBOT_USERNAME and HROBOT_PASSWORD environment variables:

let robot = hrobot::AsyncRobot::default();

If you want to customize the hyper::Client see:

Implementations§

source§

impl AsyncRobot

source

pub async fn get_cpanel_config( &self, server_number: ServerId ) -> Result<Cpanel, Error>

Retrieve a Server’s ActiveCpanelConfig configuration, or a list of available distributions and languages, if the Cpanel installation system is not currently active.

Example
let robot = hrobot::AsyncRobot::default();
match robot.get_cpanel_config(ServerId(1234567)).await.unwrap() {
    Cpanel::Active(ActiveCpanelConfig { distribution, .. }) => {
        println!("currently active cpanel distribution is: {distribution}");
        // e.g.: currently active cpanel distribution is: CentOS-Stream
    },
    Cpanel::Available(AvailableCpanelConfig { distributions, .. }) => {
        println!("available cpanel distributions are: {:?}", distributions)
        // e.g.: available cpanel distributions are: CentOS-Stream, ...
    }
}
source

pub async fn get_last_cpanel_config( &self, server_number: ServerId ) -> Result<ActiveCpanelConfig, Error>

Get the last ActiveCpanelConfig.

This is the last configuration that was active on the server, not the currently active configuration.

Warning: This is an undocumented part of the Hetzner Robot API and may stop working at any time, without warning.

Example
let robot = hrobot::AsyncRobot::default();
robot.get_last_cpanel_config(ServerId(1234567)).await.unwrap();
source

pub async fn enable_cpanel_config( &self, server_number: ServerId, config: CpanelConfig ) -> Result<ActiveCpanelConfig, Error>

Enable a linux installation configuration.

Example
let robot = hrobot::AsyncRobot::default();
robot.enable_cpanel_config(ServerId(1234567), CpanelConfig {
    distribution: CpanelDistribution::from("CentOS-Stream"),
    language: "en_US".to_string(),
    hostname: "cpanel.example.com".to_string(),
}).await.unwrap();
source

pub async fn disable_cpanel_config( &self, server_number: ServerId ) -> Result<AvailableCpanelConfig, Error>

Disable the active Cpanel installation configuration.

Example
let robot = hrobot::AsyncRobot::default();
robot.disable_cpanel_config(ServerId(1234567)).await.unwrap();
source§

impl AsyncRobot

source

pub async fn get_linux_config( &self, server_number: ServerId ) -> Result<Linux, Error>

Retrieve a Server’s ActiveLinuxConfig configuration, or a list of available operating systems, if the linux installation system is not currently active.

Example
let robot = hrobot::AsyncRobot::default();
match robot.get_linux_config(ServerId(1234567)).await.unwrap() {
    Linux::Active(ActiveLinuxConfig { distribution, .. }) => {
        println!("currently active linux distribution is: {distribution}");
        // e.g.: currently active linux distribution is: Arch Linux latest minimal
    },
    Linux::Available(AvailableLinuxConfig { distributions, .. }) => {
        println!("available linux distributions are: {:?}", distributions)
        // e.g.: available linux distributions are: Alma Linux 8.7, ...
    }
}
source

pub async fn get_last_linux_config( &self, server_number: ServerId ) -> Result<ActiveLinuxConfig, Error>

Get the last ActiveLinuxConfig.

This is the last configuration that was active on the server, not the currently active configuration.

Example
let robot = hrobot::AsyncRobot::default();
robot.get_last_linux_config(ServerId(1234567)).await.unwrap();
source

pub async fn enable_linux_config( &self, server_number: ServerId, config: LinuxConfig ) -> Result<ActiveLinuxConfig, Error>

Enable a linux installation configuration.

Example
let robot = hrobot::AsyncRobot::default();
robot.enable_linux_config(ServerId(1234567), LinuxConfig {
    distribution: LinuxDistribution::from("Arch Linux latest minimal"),
    authorized_keys: vec!["d7:34:1c:8c:4e:20:e0:1f:07:66:45:d9:97:22:ec:07".to_string()],
    language: "en".to_string(),
}).await.unwrap();
source

pub async fn disable_linux_config( &self, server_number: ServerId ) -> Result<AvailableLinuxConfig, Error>

Disable the active linux installation configuration.

Example
let robot = hrobot::AsyncRobot::default();
robot.disable_linux_config(ServerId(1234567)).await.unwrap();
source§

impl AsyncRobot

source

pub async fn get_plesk_config( &self, server_number: ServerId ) -> Result<Plesk, Error>

Retrieve a Server’s ActivePleskConfig configuration, or a list of available distributions and languages, if the Plesk installation system is not currently active.

Example
let robot = hrobot::AsyncRobot::default();
match robot.get_plesk_config(ServerId(1234567)).await.unwrap() {
    Plesk::Active(ActivePleskConfig { distribution, .. }) => {
        println!("currently active plesk distribution is: {distribution}");
        // e.g.: currently active plesk distribution is: CentOS-Stream
    },
    Plesk::Available(AvailablePleskConfig { distributions, .. }) => {
        println!("available plesk distributions are: {:?}", distributions)
        // e.g.: available plesk distributions are: CentOS-Stream, ...
    }
}
source

pub async fn get_last_plesk_config( &self, server_number: ServerId ) -> Result<ActivePleskConfig, Error>

Get the last ActivePleskConfig.

This is the last configuration that was active on the server, not the currently active configuration.

Warning: This is an undocumented part of the Hetzner Robot API and may stop working at any time, without warning.

Example
let robot = hrobot::AsyncRobot::default();
robot.get_last_plesk_config(ServerId(1234567)).await.unwrap();
source

pub async fn enable_plesk_config( &self, server_number: ServerId, config: PleskConfig ) -> Result<ActivePleskConfig, Error>

Enable a linux installation configuration.

Example
let robot = hrobot::AsyncRobot::default();
robot.enable_plesk_config(ServerId(1234567), PleskConfig {
    distribution: PleskDistribution::from("CentOS-Stream"),
    language: "en_US".to_string(),
    hostname: "plesk.example.com".to_string(),
}).await.unwrap();
source

pub async fn disable_plesk_config( &self, server_number: ServerId ) -> Result<AvailablePleskConfig, Error>

Disable the active Plesk installation configuration.

Example
let robot = hrobot::AsyncRobot::default();
robot.disable_plesk_config(ServerId(1234567)).await.unwrap();
source§

impl AsyncRobot

source

pub async fn get_rescue_config( &self, server_number: ServerId ) -> Result<Rescue, Error>

Retrieve a Server’s ActiveRescueConfig configuration, or a list of available operating systems, if the rescue system is not currently active.

Example
let robot = hrobot::AsyncRobot::default();
match robot.get_rescue_config(ServerId(1234567)).await.unwrap() {
    Rescue::Active(ActiveRescueConfig { operating_system, .. }) => {
        println!("currently active rescue system is: {operating_system}");
        // e.g.: currently active rescue system is: vkvm
    },
    Rescue::Available(AvailableRescueConfig { operating_systems, .. }) => {
        println!("available rescue systems are: {:?}", operating_systems)
        // e.g.: available rescue systems are: linux, linuxold, vkvm
    }
}
source

pub async fn get_last_rescue_config( &self, server_number: ServerId ) -> Result<ActiveRescueConfig, Error>

Get the last ActiveRescueConfig.

This is the last configuration that was active on the server, not the currently active configuration.

Example
let robot = hrobot::AsyncRobot::default();
robot.get_last_rescue_config(ServerId(1234567)).await.unwrap();
source

pub async fn enable_rescue_config( &self, server_number: ServerId, config: RescueConfig ) -> Result<ActiveRescueConfig, Error>

Enable a rescue configuration.

Example
let robot = hrobot::AsyncRobot::default();
robot.enable_rescue_config(ServerId(1234567), RescueConfig {
    operating_system: RescueOperatingSystem::from("vkvm"),
    authorized_keys: vec!["d7:34:1c:8c:4e:20:e0:1f:07:66:45:d9:97:22:ec:07".to_string()],
    keyboard: Keyboard::German,
}).await.unwrap();
source

pub async fn disable_rescue_config( &self, server_number: ServerId ) -> Result<AvailableRescueConfig, Error>

Disable the active rescue configuration.

Example
let robot = hrobot::AsyncRobot::default();
robot.disable_rescue_config(ServerId(1234567)).await.unwrap();
source§

impl AsyncRobot

source

pub async fn get_vnc_config( &self, server_number: ServerId ) -> Result<Vnc, Error>

Retrieve a Server’s ActiveVncConfig configuration, or a list of available distributions and languages, if the vnc installation system is not currently active.

Example
let robot = hrobot::AsyncRobot::default();
match robot.get_vnc_config(ServerId(1234567)).await.unwrap() {
    Vnc::Active(ActiveVncConfig { distribution, .. }) => {
        println!("currently active vnc distribution is: {distribution}");
        // e.g.: currently active vnc distribution is: Fedora-37
    },
    Vnc::Available(AvailableVncConfig { distributions, .. }) => {
        println!("available vnc distributions are: {:?}", distributions)
        // e.g.: available vnc distributions are: Fedora-37, ...
    }
}
source

pub async fn get_last_vnc_config( &self, server_number: ServerId ) -> Result<ActiveVncConfig, Error>

Get the last ActiveVncConfig.

This is the last configuration that was active on the server, not the currently active configuration.

Warning: This is an undocumented part of the Hetzner Robot API and may stop working at any time, without warning.

Example
let robot = hrobot::AsyncRobot::default();
robot.get_last_vnc_config(ServerId(1234567)).await.unwrap();
source

pub async fn enable_vnc_config( &self, server_number: ServerId, config: VncConfig ) -> Result<ActiveVncConfig, Error>

Enable a VNC installation configuration.

Example
let robot = hrobot::AsyncRobot::default();
robot.enable_vnc_config(ServerId(1234567), VncConfig {
    distribution: VncDistribution::from("Fedora-37"),
    language: "en_US".to_string(),
}).await.unwrap();
source

pub async fn disable_vnc_config( &self, server_number: ServerId ) -> Result<AvailableVncConfig, Error>

Disable the active VNC installation configuration.

Example
let robot = hrobot::AsyncRobot::default();
robot.disable_vnc_config(ServerId(1234567)).await.unwrap();
source§

impl AsyncRobot

source

pub async fn get_windows_config( &self, server_number: ServerId ) -> Result<Windows, Error>

Retrieve a Server’s ActiveWindowsConfig configuration, or a list of available distributions and languages, if the Windows installation system is not currently active.

Example
let robot = hrobot::AsyncRobot::default();
match robot.get_windows_config(ServerId(1234567)).await.unwrap() {
    Windows::Active(ActiveWindowsConfig { distribution, .. }) => {
        println!("currently active windows installation distribution is: {distribution}");
        // e.g.: currently active rescue system is: vkvm
    },
    Windows::Available(AvailableWindowsConfig { distributions, .. }) => {
        println!("available windows installation distributions are: {:?}", distributions)
        // e.g.: available rescue systems are: linux, linuxold, vkvm
    }
}
source

pub async fn get_last_windows_config( &self, server_number: ServerId ) -> Result<ActiveWindowsConfig, Error>

Get the last ActiveWindowsConfig.

This is the last configuration that was active on the server, not the currently active configuration.

Warning: This is an undocumented part of the Hetzner Robot API and may stop working at any time, without warning.

Example
let robot = hrobot::AsyncRobot::default();
robot.get_last_rescue_config(ServerId(1234567)).await.unwrap();
source

pub async fn enable_windows_config( &self, server_number: ServerId, config: WindowsConfig ) -> Result<ActiveWindowsConfig, Error>

Enable the Windows installation system.

Example
let robot = hrobot::AsyncRobot::default();
robot.enable_windows_config(ServerId(1234567), WindowsConfig {
    distribution: WindowsDistribution::from("standard"),
    language: "en".to_string()
}).await.unwrap();
source

pub async fn disable_windows_config( &self, server_number: ServerId ) -> Result<AvailableWindowsConfig, Error>

Disable the active Windows installation configuration.

Example
let robot = hrobot::AsyncRobot::default();
robot.disable_windows_config(ServerId(1234567)).await.unwrap();
source§

impl AsyncRobot

source

pub async fn get_boot_config( &self, server_number: ServerId ) -> Result<Config, Error>

Retrieve the status of all boot configuration systems, whether active or available or a server.

Example
let robot = hrobot::AsyncRobot::default();
let config = robot.get_boot_config(ServerId(1234567)).await.unwrap();
// Make sure no boot configurations are currently active.
assert!(config.active().is_none());
source§

impl AsyncRobot

source

pub async fn list_failover_ips(&self) -> Result<Vec<Failover>, Error>

List all failover IP addresses.

Example
let robot = hrobot::AsyncRobot::default();
robot.list_failover_ips().await.unwrap();
source

pub async fn get_failover_ip(&self, ip: IpAddr) -> Result<Failover, Error>

Get information about a single failover IP address.

Example
let robot = hrobot::AsyncRobot::default();
robot.get_failover_ip("123.123.123.123".parse().unwrap()).await.unwrap();
source

pub async fn switch_failover_routing( &self, failover: IpAddr, target: IpAddr ) -> Result<Failover, Error>

Switch the routing of the failover IP to instead route to the given target IP.

Example
let robot = hrobot::AsyncRobot::default();
robot.switch_failover_routing(
    "2a01:4f8:fff1::".parse().unwrap(),
    "2a01:4f8:0:5176::".parse().unwrap()
).await.unwrap();
source

pub async fn disable_failover_routing( &self, failover: IpAddr ) -> Result<Failover, Error>

Switch the routing of the failover IP to instead route to the given target IP.

Example
let robot = hrobot::AsyncRobot::default();
robot.disable_failover_routing("2a01:4f8:fff1::".parse().unwrap()).await.unwrap();
source§

impl AsyncRobot

source

pub async fn get_firewall( &self, server_number: ServerId ) -> Result<Firewall, Error>

Retrieve a Server’s Firewall.

Example
let robot = hrobot::AsyncRobot::default();
let firewall = robot.get_firewall(ServerId(1234567)).await.unwrap();
println!("Ingress rule count: {}", firewall.rules.ingress.len());
source

pub async fn set_firewall_config( &self, server_number: ServerId, firewall: &FirewallConfig ) -> Result<Firewall, Error>

Replace a Server’s Firewall configuration.

Warning: This replaces the entire firewall for both directions! If you don’t define any ingress or egress rules, only the default-deny rule will apply!

Example
let robot = hrobot::AsyncRobot::default();

let firewall = FirewallConfig {
   status: State::Active,
   filter_ipv6: false,
   whitelist_hetzner_services: true,
   rules: Rules {
       ingress: vec![
           Rule::accept("Allow from home").matching(
                Ipv4Filter::tcp(None)
                    .from_ip(Ipv4Addr::new(123, 123, 123, 123))
                    .to_port(27015..=27016)
           )
       ],
       egress: vec![
           Rule::accept("Allow all")
       ]
   },
};

robot.set_firewall_config(ServerId(1234567), &firewall).await.unwrap();
source

pub async fn apply_firewall_template( &self, server_number: ServerId, template_id: TemplateId ) -> Result<Firewall, Error>

Replace a Server’s Firewall configuration with the one defined in the given template.

Example
let robot = hrobot::AsyncRobot::default();
robot.apply_firewall_template(ServerId(1234567), TemplateId(1234)).await.unwrap();
source

pub async fn delete_firewall( &self, server_number: ServerId ) -> Result<Firewall, Error>

Clear a Servers Firewall configuration.

This reverts the server’s firewall configuration to default Hetzner firewall, which has “Allow all” rules in both directions.

Example
let robot = hrobot::AsyncRobot::default();
robot.delete_firewall(ServerId(1234567)).await.unwrap();
source

pub async fn list_firewall_templates( &self ) -> Result<Vec<FirewallTemplateReference>, Error>

List all firewall templates.

This only returns a list of FirewallTemplateReference, which do not include the complete firewall configuration.

use AsyncRobot::get_firewall_template() with the returned template ID, if you want to get the configuration.

Example
let robot = hrobot::AsyncRobot::default();
let templates = robot.list_firewall_templates().await.unwrap();
source

pub async fn get_firewall_template( &self, template_number: TemplateId ) -> Result<FirewallTemplate, Error>

Retrieve a complete FirewallTemplate.

This returns the entire template, including its rules.

Example
let robot = hrobot::AsyncRobot::default();
let template = robot.get_firewall_template(TemplateId(1234)).await.unwrap();
source

pub async fn create_firewall_template( &self, template: FirewallTemplateConfig ) -> Result<FirewallTemplate, Error>

Create a new FirewallTemplate.

Example
};
let robot = hrobot::AsyncRobot::default();
robot.create_firewall_template(FirewallTemplateConfig {
    name: "My First Template".to_string(),
    filter_ipv6: false,
    whitelist_hetzner_services: true,
    is_default: false,
    rules: Rules {
       ingress: vec![
           Rule::accept("Allow from home").matching(
                Ipv4Filter::tcp(None)
                    .from_ip(Ipv4Addr::new(123, 123, 123, 123))
                    .to_port(27015..=27016)
           )
       ],
       egress: vec![
            Rule::accept("Allow all")
       ]
   },
}).await.unwrap();
source

pub async fn delete_firewall_template( &self, template_number: TemplateId ) -> Result<(), Error>

Delete a FirewallTemplate.

Example
let robot = hrobot::AsyncRobot::default();
robot.delete_firewall_template(TemplateId(1234)).await.unwrap();
source

pub async fn update_firewall_template( &self, template_number: TemplateId, template: FirewallTemplateConfig ) -> Result<FirewallTemplate, Error>

Modify a FirewallTemplate.

Example
let robot = hrobot::AsyncRobot::default();
// Remove all firewall rules
robot.update_firewall_template(TemplateId(1234), FirewallTemplateConfig {
    name: "More like water-wall".to_string(),
    filter_ipv6: false,
    whitelist_hetzner_services: true,
    is_default: false,
    rules: Rules {
       ingress: vec![],
       egress: vec![]
   },
}).await.unwrap();
source§

impl AsyncRobot

source

pub async fn list_ips(&self) -> Result<HashMap<ServerId, Vec<Ip>>, Error>

List all single IP addresses, grouped by server they are assigned to.

Example
let robot = hrobot::AsyncRobot::default();
robot.list_ips().await.unwrap();
source

pub async fn get_ip(&self, ip: Ipv4Addr) -> Result<Ip, Error>

Get information about a single IP address.

Example
let robot = hrobot::AsyncRobot::default();
robot.get_ip("123.123.123.123".parse().unwrap()).await.unwrap();
source

pub async fn enable_ip_traffic_warnings( &self, ip: Ipv4Addr, traffic_warnings: Option<TrafficWarnings> ) -> Result<Ip, Error>

Enable traffic warnings for the IP address, optionally overriding the existing traffic limits.

Example
let robot = hrobot::AsyncRobot::default();
robot.enable_ip_traffic_warnings(
    "123.123.123.123".parse().unwrap(),
    Some(TrafficWarnings {
        hourly:  ByteSize::mib(200),
        daily:   ByteSize::gib(2),
        monthly: ByteSize::gib(20),
    })
).await.unwrap();
source

pub async fn disable_ip_traffic_warnings( &self, ip: Ipv4Addr ) -> Result<Ip, Error>

Disable traffic warnings for the IP address.

Example
let robot = hrobot::AsyncRobot::default();
robot.disable_ip_traffic_warnings("123.123.123.123".parse().unwrap()).await.unwrap();
source

pub async fn get_ip_separate_mac(&self, ip: Ipv4Addr) -> Result<String, Error>

Get the separate MAC address for this IP address.

Note that only non-primary IPv4 addresses can have separate MACs set.

Example
let robot = hrobot::AsyncRobot::default();
robot.get_ip_separate_mac("123.123.123.123".parse().unwrap()).await.unwrap();
source

pub async fn generate_ip_separate_mac( &self, ip: Ipv4Addr ) -> Result<String, Error>

Generate a separate MAC address for an IP address.

Note that only non-primary IPv4 addresses can have separate MACs set.

Example
let robot = hrobot::AsyncRobot::default();
robot.generate_ip_separate_mac("123.123.123.123".parse().unwrap()).await.unwrap();
source

pub async fn remove_ip_separate_mac(&self, ip: Ipv4Addr) -> Result<(), Error>

Remove the separate MAC address for an IP address.

Note that only non-primary IPv4 addresses can have separate MACs set.

Example
let robot = hrobot::AsyncRobot::default();
robot.remove_ip_separate_mac("123.123.123.123".parse().unwrap()).await.unwrap();
source

pub async fn get_ip_cancellation( &self, ip: Ipv4Addr ) -> Result<Cancellation, Error>

Get cancellation status for a single IP address.

Example
let robot = hrobot::AsyncRobot::default();
robot.get_ip_cancellation("123.123.123.123".parse().unwrap()).await.unwrap();
source

pub async fn cancel_ip( &self, ip: Ipv4Addr, date: Date ) -> Result<Cancelled, Error>

Cancel an IP address.

Example
use time::{Date, Month};

let robot = hrobot::AsyncRobot::default();
robot.cancel_ip(
    "123.123.123.123".parse().unwrap(),
    Date::from_calendar_date(2023, Month::July, 17).unwrap()
).await.unwrap();
source

pub async fn revoke_ip_cancellation( &self, ip: Ipv4Addr ) -> Result<Cancellable, Error>

Revoke IP address cancellation.

Example
let robot = hrobot::AsyncRobot::default();
robot.revoke_ip_cancellation("123.123.123.123".parse().unwrap()).await.unwrap();
source§

impl AsyncRobot

source

pub async fn list_ssh_keys(&self) -> Result<Vec<SshKey>, Error>

List all SSH SshKeys.

Example
let robot = hrobot::AsyncRobot::default();
for key in robot.list_ssh_keys().await.unwrap() {
    println!("{}: {}", key.name, key.fingerprint)
}
source

pub async fn get_ssh_key(&self, fingerprint: &str) -> Result<SshKey, Error>

Retrieve a single SSH SshKey.

Example
let robot = hrobot::AsyncRobot::default();
let key = robot.get_ssh_key("d7:34:1c:8c:4e:20:e0:1f:07:66:45:d9:97:22:ec:07").await.unwrap();

println!("{key:#?}");
source

pub async fn create_ssh_key( &self, name: &str, key: &str ) -> Result<SshKey, Error>

Upload a new SSH SshKey.

Example
let robot = hrobot::AsyncRobot::default();
let key = robot.create_ssh_key(
    "hrobot-rs-test-key",
    "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEaQde8iCKizUOiXlowY1iEL1yCufgjb3aiatGQNPcHb"
).await.unwrap();

println!("{key:#?}");
source

pub async fn remove_ssh_key(&self, fingerprint: &str) -> Result<(), Error>

Remove an SSH SshKey.

Example
let robot = hrobot::AsyncRobot::default();
robot.remove_ssh_key(
    "d7:34:1c:8c:4e:20:e0:1f:07:66:45:d9:97:22:ec:07"
).await.unwrap();
source

pub async fn rename_ssh_key( &self, fingerprint: &str, new_name: &str ) -> Result<SshKey, Error>

Rename an SSH SshKey.

Example
let robot = hrobot::AsyncRobot::default();
robot.rename_ssh_key(
    "d7:34:1c:8c:4e:20:e0:1f:07:66:45:d9:97:22:ec:07",
    "new-name"
).await.unwrap();
source§

impl AsyncRobot

source

pub async fn list_products( &self, monthly_price: impl RangeBounds<u32>, setup_price: impl RangeBounds<u32>, location: Option<&Location> ) -> Result<Vec<Product>, Error>

List all available products.

Example
let robot = hrobot::AsyncRobot::default();
for product in robot.list_products(
    30..50,
    ..0,
    Some(&Location::from("FSN1")),
).await.unwrap() {
    println!("{}: {}", product.id, product.name);
}
source

pub async fn get_product(&self, id: &ProductId) -> Result<Product, Error>

Get description of a single product.

Example
let robot = hrobot::AsyncRobot::default();
let product = robot.get_product(
    &ProductId::from("EX44")
).await.unwrap();
source

pub async fn place_product_order( &self, order: ProductOrder ) -> Result<ProductTransaction, Error>

Purchase a standard server product.

Example
let robot = hrobot::AsyncRobot::default();
let transaction = robot.place_product_order(
    ProductOrder {
        id: ProductId::from("EX41"),
        auth: AuthorizationMethod::Keys(vec![
            "15:28:b0:03:95:f0:77:b3:10:56:15:6b:77:22:a5:bb".to_string()
        ]),
        distribution: Some("Rescue system".to_string()),
        language: Some("en".to_string()),
        location: Location::from("FSN1"),
        addons: vec![AddonId::from("primary_ipv4")],
        comment: None,
        // Don't forget to change this line, if you ACTUALLY want to make the purchase!
        i_want_to_spend_money_to_purchase_a_server: ImSeriousAboutSpendingMoney::NoThisIsJustATest,
    }
).await.unwrap();
info!("{transaction:#?}");
source

pub async fn list_recent_product_transactions( &self ) -> Result<Vec<ProductTransaction>, Error>

List product transactions from the last 30 days.

Example
let robot = hrobot::AsyncRobot::default();
for transaction in robot.list_recent_product_transactions().await.unwrap() {
    println!("{}: {}", transaction.product.id, transaction.date);
}
source

pub async fn get_product_transaction( &self, transaction: &TransactionId ) -> Result<ProductTransaction, Error>

Get specific product transactions by ID.

Example
let robot = hrobot::AsyncRobot::default();
robot.get_product_transaction(
    &TransactionId::from("B20150121-344958-251479")
).await.unwrap();
source

pub async fn list_market_products(&self) -> Result<Vec<MarketProduct>, Error>

List market (auction) products.

Example
let robot = hrobot::AsyncRobot::default();
for market_product in robot.list_market_products().await.unwrap() {
    println!("{}: {}", market_product.id, market_product.name);
}
source

pub async fn get_market_product( &self, id: &MarketProductId ) -> Result<MarketProduct, Error>

Get description of a single market (auction) product.

Example
let robot = hrobot::AsyncRobot::default();
let product = robot.get_market_product(
    &MarketProductId(2128654)
).await.unwrap();
source

pub async fn list_recent_market_transactions( &self ) -> Result<Vec<MarketTransaction>, Error>

List market (auction) transactions from the last 30 days.

Example
let robot = hrobot::AsyncRobot::default();
for transaction in robot.list_recent_market_transactions().await.unwrap() {
    println!("{}: {}", transaction.product.id, transaction.date);
}
source

pub async fn get_market_transaction( &self, transaction: &MarketTransactionId ) -> Result<MarketTransaction, Error>

Get specific market (auction) transaction by ID.

Example
let robot = hrobot::AsyncRobot::default();
robot.get_market_transaction(
    &MarketTransactionId::from("B20150121-344958-251479")
).await.unwrap();
source

pub async fn place_market_order( &self, order: MarketProductOrder ) -> Result<MarketTransaction, Error>

Purchase a server product from the market.

Example
let robot = hrobot::AsyncRobot::default();
let transaction = robot.place_market_order(
    MarketProductOrder {
        id: MarketProductId(12345678),
        auth: AuthorizationMethod::Keys(vec![
            "15:28:b0:03:95:f0:77:b3:10:56:15:6b:77:22:a5:bb".to_string()
        ]),
        distribution: Some("Rescue system".to_string()),
        language: Some("en".to_string()),
        addons: vec![AddonId::from("primary_ipv4")],
        comment: None,
        // Don't forget to change this line, if you ACTUALLY want to make the purchase!
        i_want_to_spend_money_to_purchase_a_server: ImSeriousAboutSpendingMoney::NoThisIsJustATest,
    }
).await.unwrap();
info!("{transaction:#?}");
source

pub async fn list_available_addons( &self, id: ServerId ) -> Result<Vec<AvailableAddon>, Error>

List available addons for a server.

Example
let robot = hrobot::AsyncRobot::default();
for addon in robot.list_available_addons(
    ServerId(1234)
).await.unwrap() {
    println!("{addon:#?}");
}
source

pub async fn place_addon_order( &self, order: AddonOrder ) -> Result<AddonTransaction, Error>

Purchase an addon for a server.

Example
let robot = hrobot::AsyncRobot::default();
let transaction = robot.place_addon_order(
    AddonOrder {
        id: AddonId::from("additional_ipv4"),
        server: ServerId(1234567),
        reason: Some("VPS".to_string()),
        gateway: Some("10.0.0.1".parse().unwrap()),
        // Don't forget to change this line, if you ACTUALLY want to make the purchase!
        i_want_to_spend_money_to_purchase_an_addon: ImSeriousAboutSpendingMoney::NoThisIsJustATest,
    }
).await.unwrap();
info!("{transaction:#?}");
source

pub async fn list_recent_addon_transactions( &self ) -> Result<Vec<AddonTransaction>, Error>

List addon transactions from the last 30 days.

Example
let robot = hrobot::AsyncRobot::default();
for transaction in robot.list_recent_product_transactions().await.unwrap() {
    println!("{}: {}", transaction.product.id, transaction.date);
}
source

pub async fn get_addon_transaction( &self, transaction: &AddonTransactionId ) -> Result<AddonTransaction, Error>

Get specific addon transaction by ID.

Example
let robot = hrobot::AsyncRobot::default();
robot.get_addon_transaction(
    &AddonTransactionId::from("B20150121-344958-251479")
).await.unwrap();
source§

impl AsyncRobot

source

pub async fn list_rdns_entries(&self) -> Result<Vec<RdnsEntry>, Error>

List all Reverse DNS entries.

Example
let robot = hrobot::AsyncRobot::default();
robot.list_rdns_entries().await.unwrap();
source

pub async fn get_rdns_entry(&self, ip: IpAddr) -> Result<String, Error>

Get Reverse DNS entry for IP address.

Example
let robot = hrobot::AsyncRobot::default();
robot.get_rdns_entry("123.123.123.123".parse().unwrap()).await.unwrap();
source

pub async fn create_rdns_entry( &self, ip: IpAddr, ptr: &str ) -> Result<RdnsEntry, Error>

Create Reverse DNS entry for IP address.

Example
let robot = hrobot::AsyncRobot::default();
robot.create_rdns_entry("123.123.123.123".parse().unwrap(), "test.example.com").await.unwrap();
source

pub async fn update_rdns_entry( &self, ip: IpAddr, ptr: &str ) -> Result<RdnsEntry, Error>

Update Reverse DNS entry for IP address.

Example
let robot = hrobot::AsyncRobot::default();
robot.update_rdns_entry("123.123.123.123".parse().unwrap(), "test.example.com").await.unwrap();
source

pub async fn delete_rdns_entry(&self, ip: IpAddr) -> Result<(), Error>

Delete Reverse DNS entry for IP address.

Example
let robot = hrobot::AsyncRobot::default();
robot.delete_rdns_entry("123.123.123.123".parse().unwrap()).await.unwrap();
source§

impl AsyncRobot

source

pub async fn list_reset_options( &self ) -> Result<HashMap<ServerId, Vec<Reset>>, Error>

List reset options for all servers.

Example
let robot = hrobot::AsyncRobot::default();
robot.list_reset_options().await.unwrap();
source

pub async fn get_reset_options( &self, server_number: ServerId ) -> Result<Vec<Reset>, Error>

Retrieve list of reset options for a single server.

Example
let robot = hrobot::AsyncRobot::default();
robot.get_reset_options(ServerId(1234567)).await.unwrap();
source

pub async fn trigger_reset( &self, server_number: ServerId, reset: Reset ) -> Result<Reset, Error>

Trigger a reset for the server.

Example
let robot = hrobot::AsyncRobot::default();
robot.trigger_reset(ServerId(1234567), Reset::Power).await.unwrap();
source§

impl AsyncRobot

source

pub async fn list_servers(&self) -> Result<Vec<Server>, Error>

List all owned servers.

Example

Print the ids and names of all servers accessible by our credentials.

let robot = hrobot::AsyncRobot::default();
for server in robot.list_servers().await.unwrap() {
    println!("{}: {}", server.id, server.name);
}
source

pub async fn get_server(&self, server_number: ServerId) -> Result<Server, Error>

Retrieve complete information about a specific Server.

Example
let robot = hrobot::AsyncRobot::default();
let server = robot.get_server(ServerId(1234567)).await.unwrap();
assert_eq!(server.id, 1234567);
println!("Name: {}", server.name);
source

pub async fn rename_server( &self, server_number: ServerId, name: &str ) -> Result<Server, Error>

Rename a server.

Example
let robot = hrobot::AsyncRobot::default();
robot.rename_server(ServerId(1234567), "gibson").await.unwrap();
source

pub async fn get_server_cancellation( &self, server_number: ServerId ) -> Result<Cancellation, Error>

Get the current cancellation status of a server.

Example
let robot = hrobot::AsyncRobot::default();
let cancellation = robot.get_server_cancellation(ServerId(1234567)).await.unwrap();
assert!(matches!(
    cancellation,
    Cancellation::Cancellable(_)
));
source

pub async fn cancel_server( &self, server_number: ServerId, cancellation: Cancelled ) -> Result<Cancelled, Error>

Get the current cancellation status of a server.

Example
let robot = hrobot::AsyncRobot::default();
robot.cancel_server(ServerId(1234567), Cancelled {
    date: Date::from_calendar_date(2023, Month::June, 10).unwrap(),
    reason: Some("Server no longer necessary due to project ending".to_string()),
    reserved: false
}).await.unwrap();
source

pub async fn withdraw_server_cancellation( &self, server_number: ServerId ) -> Result<Cancellation, Error>

Withdraw a server cancellation.

Example
let robot = hrobot::AsyncRobot::default();
let cancellation = robot.withdraw_server_cancellation(ServerId(1234567)).await.unwrap();
assert!(matches!(
    cancellation,
    Cancellation::Cancellable(_)
));
source

pub async fn withdraw_server_order( &self, server_number: ServerId, reason: Option<&str> ) -> Result<Cancellation, Error>

Withdraw a server order.

Example
let robot = hrobot::AsyncRobot::default();
let cancellation = robot.withdraw_server_order(ServerId(1234567), Some("Accidental purchase.")).await.unwrap();
assert!(matches!(
    cancellation,
    Cancellation::Cancelled(_)
));
source§

impl AsyncRobot

source

pub async fn list_storageboxes(&self) -> Result<Vec<StorageBoxReference>, Error>

List all storageboxes associated with this account.

Note that this function returns a truncated version of the StorageBox which does not contain disk usage and service accessibility information.

Example
let robot = hrobot::AsyncRobot::default();
robot.list_storageboxes().await.unwrap();
source

pub async fn get_storagebox( &self, id: StorageBoxId ) -> Result<StorageBox, Error>

Get a single storagebox.

Example
let robot = hrobot::AsyncRobot::default();
robot.get_storagebox(StorageBoxId(1234)).await.unwrap();
source

pub async fn rename_storagebox( &self, id: StorageBoxId, name: &str ) -> Result<StorageBox, Error>

Rename storagebox.

Example
let robot = hrobot::AsyncRobot::default();
robot.rename_storagebox(StorageBoxId(1234), "my-backups").await.unwrap();
source

pub async fn configure_storagebox_accessibility( &self, id: StorageBoxId, accessibility: Accessibility ) -> Result<StorageBox, Error>

Configure storagebox accessibility.

Example
let robot = hrobot::AsyncRobot::default();
robot.configure_storagebox_accessibility(StorageBoxId(1234), Accessibility {
    webdav: false,
    samba: false,
    ssh: false,
    external_reachability: false,
}).await.unwrap();
source

pub async fn enable_storagebox_samba( &self, id: StorageBoxId ) -> Result<StorageBox, Error>

Enable Samba (SMB) access to the storagebox.

Example
let robot = hrobot::AsyncRobot::default();
robot.enable_storagebox_samba(StorageBoxId(1234)).await.unwrap();
source

pub async fn disable_storagebox_samba( &self, id: StorageBoxId ) -> Result<StorageBox, Error>

Disable Samba (SMB) access to the storagebox.

Example
let robot = hrobot::AsyncRobot::default();
robot.disable_storagebox_samba(StorageBoxId(1234)).await.unwrap();
source

pub async fn enable_storagebox_webdav( &self, id: StorageBoxId ) -> Result<StorageBox, Error>

Enable WebDAV access to the storagebox.

Example
let robot = hrobot::AsyncRobot::default();
robot.enable_storagebox_webdav(StorageBoxId(1234)).await.unwrap();
source

pub async fn disable_storagebox_webdav( &self, id: StorageBoxId ) -> Result<StorageBox, Error>

Disable WebDAV access to the storagebox.

Example
let robot = hrobot::AsyncRobot::default();
robot.disable_storagebox_webdav(StorageBoxId(1234)).await.unwrap();
source

pub async fn enable_storagebox_ssh( &self, id: StorageBoxId ) -> Result<StorageBox, Error>

Enable SSH access to the storagebox.

Example
let robot = hrobot::AsyncRobot::default();
robot.enable_storagebox_ssh(StorageBoxId(1234)).await.unwrap();
source

pub async fn disable_storagebox_ssh( &self, id: StorageBoxId ) -> Result<StorageBox, Error>

Disable SSH access to the storagebox.

Example
let robot = hrobot::AsyncRobot::default();
robot.disable_storagebox_ssh(StorageBoxId(1234)).await.unwrap();
source

pub async fn enable_storagebox_external_reachability( &self, id: StorageBoxId ) -> Result<StorageBox, Error>

Enable external reachability for the storagebox.

External reachability means that the enabled services are reachable outside of Hetzner’s networks. Without this enabled, you won’t be able to log into the storagebox from anything other than Hetzner Cloud or Hetzner’s Dedicated Servers.

Example
let robot = hrobot::AsyncRobot::default();
robot.enable_storagebox_external_reachability(StorageBoxId(1234)).await.unwrap();
source

pub async fn disable_storagebox_external_reachability( &self, id: StorageBoxId ) -> Result<StorageBox, Error>

Disable external reachability for to the storagebox.

External reachability means that the enabled services are reachable outside of Hetzner’s networks. Without this enabled, you won’t be able to log into the storagebox from anything other than Hetzner Cloud or Hetzner’s Dedicated Servers.

Example
let robot = hrobot::AsyncRobot::default();
robot.disable_storagebox_external_reachability(StorageBoxId(1234)).await.unwrap();
source

pub async fn enable_storagebox_snapshot_directory( &self, id: StorageBoxId ) -> Result<StorageBox, Error>

Enable snapshot directory visibility for the storagebox.

When enabled, mounts a directory containing storage box snapshots in /.zfs or /home/.zfs depending on access method.

Read more at: https://docs.hetzner.com/robot/storage-box/snapshots/

Example
let robot = hrobot::AsyncRobot::default();
robot.enable_storagebox_snapshot_directory(StorageBoxId(1234)).await.unwrap();
source

pub async fn disable_storagebox_snapshot_directory( &self, id: StorageBoxId ) -> Result<StorageBox, Error>

Disable snapshot directory visibility for the storagebox.

When enabled, mounts a directory containing storage box snapshots in /.zfs or /home/.zfs depending on access method.

Read more at: https://docs.hetzner.com/robot/storage-box/snapshots/

Example
let robot = hrobot::AsyncRobot::default();
robot.disable_storagebox_snapshot_directory(StorageBoxId(1234)).await.unwrap();
source

pub async fn reset_storagebox_password( &self, id: StorageBoxId ) -> Result<String, Error>

Reset storagebox password, returning the new password.

Example
let robot = hrobot::AsyncRobot::default();
robot.reset_storagebox_password(StorageBoxId(1234)).await.unwrap();
source

pub async fn list_snapshots( &self, id: StorageBoxId ) -> Result<Vec<Snapshot>, Error>

List snapshots for storagebox.

Example
let robot = hrobot::AsyncRobot::default();
robot.list_snapshots(StorageBoxId(1234)).await.unwrap();
source

pub async fn create_snapshot( &self, id: StorageBoxId ) -> Result<CreatedSnapshot, Error>

Create a new snapshot of the storagebox.

Example
let robot = hrobot::AsyncRobot::default();
robot.create_snapshot(StorageBoxId(1234)).await.unwrap();
source

pub async fn delete_snapshot( &self, id: StorageBoxId, snapshot_name: &str ) -> Result<(), Error>

Delete a snapshot of the storagebox.

Snapshots are named after the timestamp at which they are created with an implicit timezone of UTC. The safest way to target a snapshot for deletion, is to first retrieve it, and use its name from there.

If you otherwise know the timestamp, but not the name of the snapshot, you can format it as “YYYY-MM-DDThh-mm-ss”, with an assumed UTC timezone.

Example
let robot = hrobot::AsyncRobot::default();
robot.delete_snapshot(
    StorageBoxId(1234),
    "2015-12-21T13-13-03"
).await.unwrap();
source

pub async fn revert_to_snapshot( &self, id: StorageBoxId, snapshot_name: &str ) -> Result<(), Error>

Revert storagebox to a snapshot.

Example
let robot = hrobot::AsyncRobot::default();
robot.revert_to_snapshot(
    StorageBoxId(1234),
    "2015-12-21T13-13-03"
).await.unwrap();
source

pub async fn change_snapshot_comment( &self, id: StorageBoxId, snapshot_name: &str, comment: &str ) -> Result<(), Error>

Change snapshot comment.

Example
let robot = hrobot::AsyncRobot::default();
robot.change_snapshot_comment(
    StorageBoxId(1234),
    "2015-12-21T13-13-03",
    "Last backup before upgrade to 2.0"
).await.unwrap();
source

pub async fn get_snapshot_plan( &self, id: StorageBoxId ) -> Result<SnapshotPlan, Error>

Update snapshot plan for storagebox

Example
let robot = hrobot::AsyncRobot::default();
robot.get_snapshot_plan(StorageBoxId(1234)).await.unwrap();
source

pub async fn update_snapshot_plan( &self, id: StorageBoxId, plan: SnapshotPlan ) -> Result<SnapshotPlan, Error>

Update snapshot plan.

Example
let robot = hrobot::AsyncRobot::default();
robot.update_snapshot_plan(
    StorageBoxId(1234),
    SnapshotPlan::weekly(Weekday::Monday, 10, 0)
).await.unwrap();
source

pub async fn list_subaccounts( &self, id: StorageBoxId ) -> Result<Vec<Subaccount>, Error>

List sub-accounts for storagebox.

Example
let robot = hrobot::AsyncRobot::default();
robot.list_subaccounts(StorageBoxId(1234)).await.unwrap();
source

pub async fn create_subaccount( &self, storagebox: StorageBoxId, home_directory: &str, accessibility: Accessibility, permissions: Permission, comment: Option<&str> ) -> Result<CreatedSubaccount, Error>

Create sub-account.

Example
let robot = hrobot::AsyncRobot::default();
robot.create_subaccount(
    StorageBoxId(1234),
    "/home/test-user",
    Accessibility::default(), // default disables all access.
    Permission::ReadOnly,
    None
).await.unwrap();
source

pub async fn set_subaccount_home_directory( &self, storagebox: StorageBoxId, subaccount: &SubaccountId, home_directory: &str ) -> Result<(), Error>

Change home directory of storagebox sub-account

Example
let robot = hrobot::AsyncRobot::default();
robot.set_subaccount_home_directory(
    StorageBoxId(1234),
    &SubaccountId("u1234-sub1".to_string()),
    "/homedirs/sub1"
).await.unwrap();
source

pub async fn update_subaccount( &self, storagebox: StorageBoxId, subaccount: &SubaccountId, home_directory: &str, accessibility: Option<&Accessibility>, permissions: Option<Permission>, comment: Option<&str> ) -> Result<(), Error>

Change sub-account comment/description.

Example
let robot = hrobot::AsyncRobot::default();
robot.update_subaccount(
    StorageBoxId(1234),
    &SubaccountId("u1234-sub1".to_string()),
    "/new/home/dir",
    None, // Keep old accessibility options
    Some(Permission::ReadWrite),
    Some("Sub-account used for accessing backups")
).await.unwrap();
source

pub async fn reset_subaccount_password( &self, storagebox: StorageBoxId, subaccount: &SubaccountId ) -> Result<String, Error>

Reset sub-account password.

Example
let robot = hrobot::AsyncRobot::default();
let password = robot.reset_subaccount_password(
    StorageBoxId(1234),
    &SubaccountId("u1234-sub1".to_string()),
).await.unwrap();

println!("new password: {password}");
source

pub async fn delete_subaccount( &self, storagebox: StorageBoxId, subaccount: SubaccountId ) -> Result<(), Error>

Delete sub-account.

Example
let robot = hrobot::AsyncRobot::default();
robot.delete_subaccount(
    StorageBoxId(1234),
    SubaccountId("u1234-sub1".to_string()),
).await.unwrap();
source§

impl AsyncRobot

source

pub async fn list_subnets( &self ) -> Result<HashMap<ServerId, Vec<Subnet>>, Error>

List all subnets, grouped by server they are assigned to.

Example
let robot = hrobot::AsyncRobot::default();
robot.list_subnets().await.unwrap();
source

pub async fn get_subnet(&self, subnet_addr: IpAddr) -> Result<Subnet, Error>

Get subnet information.

Example
let robot = hrobot::AsyncRobot::default();
robot.get_subnet("2a01:4f8:123:123::".parse().unwrap()).await.unwrap();
source

pub async fn enable_subnet_traffic_warnings( &self, ip: IpAddr, traffic_warnings: Option<TrafficWarnings> ) -> Result<Subnet, Error>

Enable traffic warnings for the subnet, optionally overriding the existing traffic limits.

Example
let robot = hrobot::AsyncRobot::default();
robot.enable_ip_traffic_warnings(
    "2a01:4f8:123:123::".parse().unwrap(),
    Some(TrafficWarnings {
        hourly:  ByteSize::mb(200),
        daily:   ByteSize::gb(2),
        monthly: ByteSize::gb(20),
    })
).await.unwrap();
source

pub async fn disable_subnet_traffic_warnings( &self, ip: IpAddr ) -> Result<Subnet, Error>

Disable traffic warnings for the subnet.

Example
let robot = hrobot::AsyncRobot::default();
robot.disable_subnet_traffic_warnings("2a01:4f8:123:123::".parse().unwrap()).await.unwrap();
source

pub async fn get_subnet_separate_mac(&self, ip: IpAddr) -> Result<String, Error>

Get the separate MAC address for this subnet.

Example
let robot = hrobot::AsyncRobot::default();
robot.get_subnet_separate_mac("2a01:4f8:123:123::".parse().unwrap()).await.unwrap();
source

pub async fn generate_subnet_separate_mac( &self, ip: IpAddr ) -> Result<String, Error>

Generate a separate MAC address for subnet.

Example
let robot = hrobot::AsyncRobot::default();
robot.generate_subnet_separate_mac("2a01:4f8:123:123::".parse().unwrap()).await.unwrap();
source

pub async fn remove_subnet_separate_mac(&self, ip: IpAddr) -> Result<(), Error>

Remove the separate MAC address for a subnet.

Example
let robot = hrobot::AsyncRobot::default();
robot.remove_subnet_separate_mac("2a01:4f8:123:123::".parse().unwrap()).await.unwrap();
source

pub async fn get_subnet_cancellation( &self, ip: Ipv4Addr ) -> Result<Cancellation, Error>

Get cancellation status for a subnet.

Note: Only IPv4 subnets can be cancelled.

Example
let robot = hrobot::AsyncRobot::default();
robot.get_subnet_cancellation("123.123.123.123".parse().unwrap()).await.unwrap();
source

pub async fn cancel_subnet( &self, ip: Ipv4Addr, date: Date ) -> Result<Cancelled, Error>

Cancel a subnet.

Note: Only IPv4 subnets can be cancelled.

Example
use time::{Date, Month};

let robot = hrobot::AsyncRobot::default();
robot.cancel_subnet(
    "123.123.123.123".parse().unwrap(),
    Date::from_calendar_date(2023, Month::July, 17).unwrap()
).await.unwrap();
source

pub async fn revoke_subnet_cancellation( &self, ip: Ipv4Addr ) -> Result<Cancellable, Error>

Revoke subnet cancellation.

Note: Only IPv4 subnets can be cancelled.

Example
let robot = hrobot::AsyncRobot::default();
robot.revoke_ip_cancellation("123.123.123.123".parse().unwrap()).await.unwrap();
source§

impl AsyncRobot

source

pub async fn get_traffic( &self, ips: &[IpNet], range: TimeRange ) -> Result<HashMap<IpNet, Vec<TrafficStatistic>>, Error>

Get traffic statistics for specific IPs

Example
let robot = hrobot::AsyncRobot::default();
let traffic = robot.get_traffic(
    &[
        "123.123.123.123/32".parse().unwrap(),
        "2a01:4f8:123:123::".parse().unwrap(),
    ],
    TimeRange::month(2023, Month::July)
).await.unwrap();
source§

impl AsyncRobot

source

pub async fn list_vswitches(&self) -> Result<Vec<VSwitchReference>, Error>

List all vSwitches.

Example
let robot = hrobot::AsyncRobot::default();
robot.list_vswitches().await.unwrap();
source

pub async fn get_vswitch(&self, vswitch: VSwitchId) -> Result<VSwitch, Error>

Get vSwitch information.

Example
let robot = hrobot::AsyncRobot::default();
robot.get_vswitch(VSwitchId(123456)).await.unwrap();
source

pub async fn create_vswitch( &self, name: &str, vlan_id: VlanId ) -> Result<VSwitchReference, Error>

Create a vSwitch

Example
let robot = hrobot::AsyncRobot::default();
robot.create_vswitch("vswitch-test-1", VlanId(4078)).await.unwrap();
source

pub async fn update_vswitch( &self, vswitch_id: VSwitchId, name: &str, vlan_id: VlanId ) -> Result<(), Error>

Update vSwitch.

Example
let robot = hrobot::AsyncRobot::default();
robot.update_vswitch(
    VSwitchId(124567),
    "vswitch-test-2",
    VlanId(4079)
).await.unwrap();
source

pub async fn cancel_vswitch( &self, vswitch_id: VSwitchId, cancellation_date: Date ) -> Result<(), Error>

Cancel vSwitch.

Example
let robot = hrobot::AsyncRobot::default();
robot.cancel_vswitch(
    VSwitchId(124567),
    Date::from_calendar_date(2023, Month::July, 10).unwrap()
).await.unwrap();
source

pub async fn connect_vswitch_servers( &self, vswitch_id: VSwitchId, server_ids: &[ServerId] ) -> Result<(), Error>

Connect dedicated servers to vSwitch.

Example
let robot = hrobot::AsyncRobot::default();
robot.connect_vswitch_servers(
    VSwitchId(124567),
    &[ServerId(1234567)],
).await.unwrap();
source

pub async fn disconnect_vswitch_servers( &self, vswitch_id: VSwitchId, server_ids: &[ServerId] ) -> Result<(), Error>

Disconnect dedicated servers from vSwitch.

Example
let robot = hrobot::AsyncRobot::default();
robot.disconnect_vswitch_servers(
    VSwitchId(124567),
    &[ServerId(1234567)],
).await.unwrap();
source§

impl AsyncRobot

source

pub async fn is_wake_on_lan_available( &self, server_number: ServerId ) -> Result<bool, Error>

Check if Wake-on-LAN is available for the server.

Example
let robot = hrobot::AsyncRobot::default();
assert!(robot.is_wake_on_lan_available(ServerId(1234567)).await.unwrap());
source

pub async fn trigger_wake_on_lan( &self, server_number: ServerId ) -> Result<(), Error>

Send a Wake-on-LAN packet to the specified server.

Example
let robot = hrobot::AsyncRobot::default();
robot.trigger_wake_on_lan(ServerId(1234567)).await.unwrap();
source§

impl AsyncRobot

source

pub fn from_env( client: Client<HttpsConnector<HttpConnector>, Body> ) -> Result<Self, VarError>

Construct a new AsyncRobot using the environment variables HROBOT_USERNAME and HROBOT_PASSWORD for credentials, and the given client.

Example

Construct an AsyncRobot using a hyper::Client and hyper_rustls.

let https = hyper_rustls::HttpsConnectorBuilder::new()
    .with_native_roots()
    .https_only()
    .enable_http1()
    .build();

let client = hyper::Client::builder().build(https);

let robot = hrobot::AsyncRobot::from_env(client);
source

pub fn new( client: Client<HttpsConnector<HttpConnector>, Body>, username: &str, password: &str ) -> Self

Construct a new AsyncRobot, using the given client, username and password.

Example

Construct an AsyncRobot using a custom hyper::Client.

let https = hyper_rustls::HttpsConnectorBuilder::new()
    .with_native_roots()
    .https_only()
    .enable_http1()
    .build();

let client = hyper::Client::builder().build(https);

let robot = hrobot::AsyncRobot::new(client, "#ws+username", "p@ssw0rd");

Trait Implementations§

source§

impl Clone for AsyncRobot

source§

fn clone(&self) -> AsyncRobot

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for AsyncRobot

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for AsyncRobot

source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more