gem install keycdn
Requires Ruby 1.9.2+
bundle init
echo "gem 'keycdn'" >> Gemfile
bundle install --path vendor/bundle
require 'keycdn'
# $ export APIKEY=<your_api_key>
keycdn = KeyCDN::Client.new(ENV["APIKEY"])
keycdn.get("zones.json")
keycdn.get("zones/<zoneId>.json")
time = Time.now.to_i
report = {
:start => time-3600,
:end => time
}
keycdn.get("reports/traffic.json", report)
keycdn.get("reports/storage.json", report)
keycdn.get("reports/credits.json", report)
zone = {
:name => @time.to_s,
:expire => 1234
}
keycdn.post("zones.json", zone)
zone_id = '<zoneId>'
zone = {
:name => '<name>',
:expire => 4321
}
keycdn.put("zones/#{zone_id}.json", zone)
# purge zone cache
zone_id = '<zoneId>'
keycdn.get("zones/purge/#{zone_id}.json")
zone_id = '<zoneId>'
urls = {
'urls[0]' => 'demo-1.kxcdn.com/lorem.css',
'urls[1]' => 'demo-1.kxcdn.com/lorem.jpg'
};
keycdn.del("zones/purgeurl/#{zone_id}.json", urls)
For more details visit https://www.keycdn.com