rust 4
rust 4
With the DNSimple crate you can easily interact our powerful API to administer
domain names, configure DNS records, provision and install SSL certificates, and
more.
Getting Started
1. Install the Rust crate
2. Authenticate
3. Check Authorization
If you want to know which account is associated with the current access token, you can
use #identity . The account ID is required for the majority of API operations.
println!(
"{} (your account ID)",
account_id
);
=> 1234 (your account ID)
Managing Domains
println!(
"Domain: {}\nAvailable: {}\nPremium: {}",
domain_check.domain, domain_check.available, domain_check.premium
);
=> Domain: foo.com
Available: true
Premium: false
Register A Domain
1. To register a domain, you need to specify a registrant_id. This can be fetched via
the Contacts API.
println!(
"{}"
,first_contact.id
);
=> 123
println!(
"State: {}\nAuto Renew: {}\nWhois Privacy: {}\nRegistrant:{}",
domain_registration.state,
domain_registration.auto_renew,
domain_registration.whois_privacy,
domain_registration.registrant_id
);
=>State: registered
Auto Renew: false
Whois Privacy: false
Registrant: 123
DNS
};
println!(
"ID: {}\nZone: {}\nName: {}\nType: {}\nContent: {}",
record.id, record.zone_id, record.type, record.content
);
=>ID: 123
Zone: foo.com
Name: www
Type: A
Content: 137.0.0.1
Update a DNS record
Update a previously created DNS record.
println!(
"ID: {}\nUpdated TTL: {}",
updated_zone_record.id, updated_zone_record.ttl
);
=>ID: 123
Updated TTL: 60
SSL Certificates
println!(
"ID: {}\nState: {}",
cert.id, cert.state
);
=>ID: 123
State: new
Issue an Let's Encrypt Certificate
Issues the pending order. This process is async. A successful response means that the
response is queued.
println!(
"State: {}",
cert_issue.state
);
=>State: requesting
Install the certificate
Download the certificate.
fs::write("www_foo_com.key", key.private_key);