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:
AsyncRobot::from_envif you still want to use the environment variables, orAsyncRobot::newif you want to provide client and credentials yourself.
Implementations§
source§impl AsyncRobot
impl AsyncRobot
sourcepub async fn get_cpanel_config(
&self,
server_number: ServerId
) -> Result<Cpanel, Error>
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, ...
}
}sourcepub async fn get_last_cpanel_config(
&self,
server_number: ServerId
) -> Result<ActiveCpanelConfig, Error>
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();sourcepub async fn enable_cpanel_config(
&self,
server_number: ServerId,
config: CpanelConfig
) -> Result<ActiveCpanelConfig, Error>
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();sourcepub async fn disable_cpanel_config(
&self,
server_number: ServerId
) -> Result<AvailableCpanelConfig, Error>
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
impl AsyncRobot
sourcepub async fn get_linux_config(
&self,
server_number: ServerId
) -> Result<Linux, Error>
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, ...
}
}sourcepub async fn get_last_linux_config(
&self,
server_number: ServerId
) -> Result<ActiveLinuxConfig, Error>
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();sourcepub async fn enable_linux_config(
&self,
server_number: ServerId,
config: LinuxConfig
) -> Result<ActiveLinuxConfig, Error>
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();sourcepub async fn disable_linux_config(
&self,
server_number: ServerId
) -> Result<AvailableLinuxConfig, Error>
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
impl AsyncRobot
sourcepub async fn get_plesk_config(
&self,
server_number: ServerId
) -> Result<Plesk, Error>
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, ...
}
}sourcepub async fn get_last_plesk_config(
&self,
server_number: ServerId
) -> Result<ActivePleskConfig, Error>
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();sourcepub async fn enable_plesk_config(
&self,
server_number: ServerId,
config: PleskConfig
) -> Result<ActivePleskConfig, Error>
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();sourcepub async fn disable_plesk_config(
&self,
server_number: ServerId
) -> Result<AvailablePleskConfig, Error>
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
impl AsyncRobot
sourcepub async fn get_rescue_config(
&self,
server_number: ServerId
) -> Result<Rescue, Error>
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
}
}sourcepub async fn get_last_rescue_config(
&self,
server_number: ServerId
) -> Result<ActiveRescueConfig, Error>
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();sourcepub async fn enable_rescue_config(
&self,
server_number: ServerId,
config: RescueConfig
) -> Result<ActiveRescueConfig, Error>
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();sourcepub async fn disable_rescue_config(
&self,
server_number: ServerId
) -> Result<AvailableRescueConfig, Error>
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
impl AsyncRobot
sourcepub async fn get_vnc_config(
&self,
server_number: ServerId
) -> Result<Vnc, Error>
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, ...
}
}sourcepub async fn get_last_vnc_config(
&self,
server_number: ServerId
) -> Result<ActiveVncConfig, Error>
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();sourcepub async fn enable_vnc_config(
&self,
server_number: ServerId,
config: VncConfig
) -> Result<ActiveVncConfig, Error>
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();sourcepub async fn disable_vnc_config(
&self,
server_number: ServerId
) -> Result<AvailableVncConfig, Error>
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
impl AsyncRobot
sourcepub async fn get_windows_config(
&self,
server_number: ServerId
) -> Result<Windows, Error>
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
}
}sourcepub async fn get_last_windows_config(
&self,
server_number: ServerId
) -> Result<ActiveWindowsConfig, Error>
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();sourcepub async fn enable_windows_config(
&self,
server_number: ServerId,
config: WindowsConfig
) -> Result<ActiveWindowsConfig, Error>
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();sourcepub async fn disable_windows_config(
&self,
server_number: ServerId
) -> Result<AvailableWindowsConfig, Error>
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
impl AsyncRobot
sourcepub async fn get_boot_config(
&self,
server_number: ServerId
) -> Result<Config, Error>
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
impl AsyncRobot
sourcepub async fn list_failover_ips(&self) -> Result<Vec<Failover>, Error>
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();sourcepub async fn get_failover_ip(&self, ip: IpAddr) -> Result<Failover, Error>
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();sourcepub async fn switch_failover_routing(
&self,
failover: IpAddr,
target: IpAddr
) -> Result<Failover, Error>
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();sourcepub async fn disable_failover_routing(
&self,
failover: IpAddr
) -> Result<Failover, Error>
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
impl AsyncRobot
sourcepub async fn set_firewall_config(
&self,
server_number: ServerId,
firewall: &FirewallConfig
) -> Result<Firewall, Error>
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();sourcepub async fn apply_firewall_template(
&self,
server_number: ServerId,
template_id: TemplateId
) -> Result<Firewall, Error>
pub async fn apply_firewall_template( &self, server_number: ServerId, template_id: TemplateId ) -> Result<Firewall, Error>
sourcepub async fn list_firewall_templates(
&self
) -> Result<Vec<FirewallTemplateReference>, Error>
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();sourcepub async fn get_firewall_template(
&self,
template_number: TemplateId
) -> Result<FirewallTemplate, Error>
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();sourcepub async fn create_firewall_template(
&self,
template: FirewallTemplateConfig
) -> Result<FirewallTemplate, Error>
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();sourcepub async fn delete_firewall_template(
&self,
template_number: TemplateId
) -> Result<(), Error>
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();sourcepub async fn update_firewall_template(
&self,
template_number: TemplateId,
template: FirewallTemplateConfig
) -> Result<FirewallTemplate, Error>
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
impl AsyncRobot
sourcepub async fn list_ips(&self) -> Result<HashMap<ServerId, Vec<Ip>>, Error>
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();sourcepub async fn get_ip(&self, ip: Ipv4Addr) -> Result<Ip, Error>
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();sourcepub async fn enable_ip_traffic_warnings(
&self,
ip: Ipv4Addr,
traffic_warnings: Option<TrafficWarnings>
) -> Result<Ip, Error>
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();sourcepub async fn disable_ip_traffic_warnings(
&self,
ip: Ipv4Addr
) -> Result<Ip, Error>
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();sourcepub async fn get_ip_separate_mac(&self, ip: Ipv4Addr) -> Result<String, Error>
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();sourcepub async fn generate_ip_separate_mac(
&self,
ip: Ipv4Addr
) -> Result<String, Error>
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();sourcepub async fn remove_ip_separate_mac(&self, ip: Ipv4Addr) -> Result<(), Error>
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();sourcepub async fn get_ip_cancellation(
&self,
ip: Ipv4Addr
) -> Result<Cancellation, Error>
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();sourcepub async fn cancel_ip(
&self,
ip: Ipv4Addr,
date: Date
) -> Result<Cancelled, Error>
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();sourcepub async fn revoke_ip_cancellation(
&self,
ip: Ipv4Addr
) -> Result<Cancellable, Error>
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
impl AsyncRobot
source§impl AsyncRobot
impl AsyncRobot
sourcepub async fn list_products(
&self,
monthly_price: impl RangeBounds<u32>,
setup_price: impl RangeBounds<u32>,
location: Option<&Location>
) -> Result<Vec<Product>, Error>
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);
}sourcepub async fn get_product(&self, id: &ProductId) -> Result<Product, Error>
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();sourcepub async fn place_product_order(
&self,
order: ProductOrder
) -> Result<ProductTransaction, Error>
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:#?}");sourcepub async fn list_recent_product_transactions(
&self
) -> Result<Vec<ProductTransaction>, Error>
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);
}sourcepub async fn get_product_transaction(
&self,
transaction: &TransactionId
) -> Result<ProductTransaction, Error>
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();sourcepub async fn list_market_products(&self) -> Result<Vec<MarketProduct>, Error>
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);
}sourcepub async fn get_market_product(
&self,
id: &MarketProductId
) -> Result<MarketProduct, Error>
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();sourcepub async fn list_recent_market_transactions(
&self
) -> Result<Vec<MarketTransaction>, Error>
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);
}sourcepub async fn get_market_transaction(
&self,
transaction: &MarketTransactionId
) -> Result<MarketTransaction, Error>
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();sourcepub async fn place_market_order(
&self,
order: MarketProductOrder
) -> Result<MarketTransaction, Error>
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:#?}");sourcepub async fn list_available_addons(
&self,
id: ServerId
) -> Result<Vec<AvailableAddon>, Error>
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:#?}");
}sourcepub async fn place_addon_order(
&self,
order: AddonOrder
) -> Result<AddonTransaction, Error>
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:#?}");sourcepub async fn list_recent_addon_transactions(
&self
) -> Result<Vec<AddonTransaction>, Error>
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);
}sourcepub async fn get_addon_transaction(
&self,
transaction: &AddonTransactionId
) -> Result<AddonTransaction, Error>
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
impl AsyncRobot
sourcepub async fn list_rdns_entries(&self) -> Result<Vec<RdnsEntry>, Error>
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();sourcepub async fn get_rdns_entry(&self, ip: IpAddr) -> Result<String, Error>
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();sourcepub async fn create_rdns_entry(
&self,
ip: IpAddr,
ptr: &str
) -> Result<RdnsEntry, Error>
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§impl AsyncRobot
impl AsyncRobot
sourcepub async fn list_reset_options(
&self
) -> Result<HashMap<ServerId, Vec<Reset>>, Error>
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§impl AsyncRobot
impl AsyncRobot
sourcepub async fn list_servers(&self) -> Result<Vec<Server>, Error>
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);
}sourcepub async fn rename_server(
&self,
server_number: ServerId,
name: &str
) -> Result<Server, Error>
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();sourcepub async fn get_server_cancellation(
&self,
server_number: ServerId
) -> Result<Cancellation, Error>
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(_)
));sourcepub async fn cancel_server(
&self,
server_number: ServerId,
cancellation: Cancelled
) -> Result<Cancelled, Error>
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();sourcepub async fn withdraw_server_cancellation(
&self,
server_number: ServerId
) -> Result<Cancellation, Error>
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(_)
));sourcepub async fn withdraw_server_order(
&self,
server_number: ServerId,
reason: Option<&str>
) -> Result<Cancellation, Error>
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
impl AsyncRobot
sourcepub async fn list_storageboxes(&self) -> Result<Vec<StorageBoxReference>, Error>
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();sourcepub async fn get_storagebox(
&self,
id: StorageBoxId
) -> Result<StorageBox, Error>
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();sourcepub async fn rename_storagebox(
&self,
id: StorageBoxId,
name: &str
) -> Result<StorageBox, Error>
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();sourcepub async fn configure_storagebox_accessibility(
&self,
id: StorageBoxId,
accessibility: Accessibility
) -> Result<StorageBox, Error>
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();sourcepub async fn enable_storagebox_samba(
&self,
id: StorageBoxId
) -> Result<StorageBox, Error>
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();sourcepub async fn disable_storagebox_samba(
&self,
id: StorageBoxId
) -> Result<StorageBox, Error>
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();sourcepub async fn enable_storagebox_webdav(
&self,
id: StorageBoxId
) -> Result<StorageBox, Error>
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();sourcepub async fn disable_storagebox_webdav(
&self,
id: StorageBoxId
) -> Result<StorageBox, Error>
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();sourcepub async fn enable_storagebox_ssh(
&self,
id: StorageBoxId
) -> Result<StorageBox, Error>
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();sourcepub async fn disable_storagebox_ssh(
&self,
id: StorageBoxId
) -> Result<StorageBox, Error>
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();sourcepub async fn enable_storagebox_external_reachability(
&self,
id: StorageBoxId
) -> Result<StorageBox, Error>
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();sourcepub async fn disable_storagebox_external_reachability(
&self,
id: StorageBoxId
) -> Result<StorageBox, Error>
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();sourcepub async fn enable_storagebox_snapshot_directory(
&self,
id: StorageBoxId
) -> Result<StorageBox, Error>
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();sourcepub async fn disable_storagebox_snapshot_directory(
&self,
id: StorageBoxId
) -> Result<StorageBox, Error>
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();sourcepub async fn reset_storagebox_password(
&self,
id: StorageBoxId
) -> Result<String, Error>
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();sourcepub async fn list_snapshots(
&self,
id: StorageBoxId
) -> Result<Vec<Snapshot>, Error>
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();sourcepub async fn create_snapshot(
&self,
id: StorageBoxId
) -> Result<CreatedSnapshot, Error>
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();sourcepub async fn delete_snapshot(
&self,
id: StorageBoxId,
snapshot_name: &str
) -> Result<(), Error>
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();sourcepub async fn revert_to_snapshot(
&self,
id: StorageBoxId,
snapshot_name: &str
) -> Result<(), Error>
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();sourcepub async fn change_snapshot_comment(
&self,
id: StorageBoxId,
snapshot_name: &str,
comment: &str
) -> Result<(), Error>
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();sourcepub async fn get_snapshot_plan(
&self,
id: StorageBoxId
) -> Result<SnapshotPlan, Error>
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();sourcepub async fn update_snapshot_plan(
&self,
id: StorageBoxId,
plan: SnapshotPlan
) -> Result<SnapshotPlan, Error>
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();sourcepub async fn list_subaccounts(
&self,
id: StorageBoxId
) -> Result<Vec<Subaccount>, Error>
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();sourcepub async fn create_subaccount(
&self,
storagebox: StorageBoxId,
home_directory: &str,
accessibility: Accessibility,
permissions: Permission,
comment: Option<&str>
) -> Result<CreatedSubaccount, Error>
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();sourcepub async fn set_subaccount_home_directory(
&self,
storagebox: StorageBoxId,
subaccount: &SubaccountId,
home_directory: &str
) -> Result<(), Error>
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();sourcepub async fn update_subaccount(
&self,
storagebox: StorageBoxId,
subaccount: &SubaccountId,
home_directory: &str,
accessibility: Option<&Accessibility>,
permissions: Option<Permission>,
comment: Option<&str>
) -> Result<(), Error>
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();sourcepub async fn reset_subaccount_password(
&self,
storagebox: StorageBoxId,
subaccount: &SubaccountId
) -> Result<String, Error>
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}");sourcepub async fn delete_subaccount(
&self,
storagebox: StorageBoxId,
subaccount: SubaccountId
) -> Result<(), Error>
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
impl AsyncRobot
sourcepub async fn list_subnets(
&self
) -> Result<HashMap<ServerId, Vec<Subnet>>, Error>
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();sourcepub async fn get_subnet(&self, subnet_addr: IpAddr) -> Result<Subnet, Error>
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();sourcepub async fn enable_subnet_traffic_warnings(
&self,
ip: IpAddr,
traffic_warnings: Option<TrafficWarnings>
) -> Result<Subnet, Error>
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();sourcepub async fn disable_subnet_traffic_warnings(
&self,
ip: IpAddr
) -> Result<Subnet, Error>
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();sourcepub async fn get_subnet_separate_mac(&self, ip: IpAddr) -> Result<String, Error>
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();sourcepub async fn generate_subnet_separate_mac(
&self,
ip: IpAddr
) -> Result<String, Error>
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();sourcepub async fn remove_subnet_separate_mac(&self, ip: IpAddr) -> Result<(), Error>
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();sourcepub async fn get_subnet_cancellation(
&self,
ip: Ipv4Addr
) -> Result<Cancellation, Error>
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();sourcepub async fn cancel_subnet(
&self,
ip: Ipv4Addr,
date: Date
) -> Result<Cancelled, Error>
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();sourcepub async fn revoke_subnet_cancellation(
&self,
ip: Ipv4Addr
) -> Result<Cancellable, Error>
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
impl AsyncRobot
sourcepub async fn get_traffic(
&self,
ips: &[IpNet],
range: TimeRange
) -> Result<HashMap<IpNet, Vec<TrafficStatistic>>, Error>
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
impl AsyncRobot
sourcepub async fn list_vswitches(&self) -> Result<Vec<VSwitchReference>, Error>
pub async fn list_vswitches(&self) -> Result<Vec<VSwitchReference>, Error>
List all vSwitches.
Example
let robot = hrobot::AsyncRobot::default();
robot.list_vswitches().await.unwrap();sourcepub async fn get_vswitch(&self, vswitch: VSwitchId) -> Result<VSwitch, Error>
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();sourcepub async fn create_vswitch(
&self,
name: &str,
vlan_id: VlanId
) -> Result<VSwitchReference, Error>
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();sourcepub async fn update_vswitch(
&self,
vswitch_id: VSwitchId,
name: &str,
vlan_id: VlanId
) -> Result<(), Error>
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();sourcepub async fn cancel_vswitch(
&self,
vswitch_id: VSwitchId,
cancellation_date: Date
) -> Result<(), Error>
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();sourcepub async fn connect_vswitch_servers(
&self,
vswitch_id: VSwitchId,
server_ids: &[ServerId]
) -> Result<(), Error>
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();sourcepub async fn disconnect_vswitch_servers(
&self,
vswitch_id: VSwitchId,
server_ids: &[ServerId]
) -> Result<(), Error>
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
impl AsyncRobot
source§impl AsyncRobot
impl AsyncRobot
sourcepub fn from_env(
client: Client<HttpsConnector<HttpConnector>, Body>
) -> Result<Self, VarError>
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);sourcepub fn new(
client: Client<HttpsConnector<HttpConnector>, Body>,
username: &str,
password: &str
) -> Self
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
impl Clone for AsyncRobot
source§fn clone(&self) -> AsyncRobot
fn clone(&self) -> AsyncRobot
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more