Expand description
This library is a wrapper for 3 cloudflare api calls.
The 3 api calls are
list zones
create a dns record for a domain
delete a dns record for a domain
§Authentication
All endpoints need authentication. This library supports authentication using Authorization: Bearer header.
You need to export this key - CLOUDFLARE_API_KEY.
§Usage
use migamake_api_cloudflare::{Cloudflare, dns};
let domain = "example.com".into();
let zoneid = "some id";
// Initialize using an environment variable CLOUDFLARE_API_KEY
let cloudflare = Cloudflare::default(None);
// or the api key could be passed explicitly to the default method
// let cloudflare = Cloudflare::default(Some("api-key").into());
let mut txt_dns_record = dns::TXTRecord::new();
txt_dns_record.name = domain;
txt_dns_record.content = "create a txt record".into();
let response = cloudflare.create_dns_record(txt_dns_record, &zoneid);
let res = response.unwrap();
if res.success {
println!("{}", "Record created");
}
else{
println!("{:?}", res.errors);
}
Modules§
- dns
- Defines various type of DNS record structs to be used with Create DNS record
- parameters
- Declares enums used with Zone and various dns record
- response
- Various response objects for cloudflare API
- zone
- Defines parameters which can be used for filtering with the list API
Structs§
- Cloudflare
- This represents object to talk to cloudflare api
Constants§
- API_
PREFIX - Base url of Cloudflare API