Skip to content

keycdn/ruby-keycdn-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ruby gem for the KeyCDN API

Installation

gem install keycdn

Requires Ruby 1.9.2+

With Bundler

bundle init
echo "gem 'keycdn'" >> Gemfile
bundle install --path vendor/bundle

Usage

Initial

require 'keycdn'

# $ export APIKEY=<your_api_key>
keycdn = KeyCDN::Client.new(ENV["APIKEY"])

Get all zones

keycdn.get("zones.json")

Get a specific zone

keycdn.get("zones/<zoneId>.json")

Generate reports

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)

Add a new zone

zone = {
  :name => @time.to_s,
  :expire  => 1234
}

keycdn.post("zones.json", zone)

Edit a zone

zone_id = '<zoneId>'

zone = {
  :name => '<name>',
  :expire  => 4321
}

keycdn.put("zones/#{zone_id}.json", zone)

Purge zone cache

# purge zone cache
zone_id = '<zoneId>'

keycdn.get("zones/purge/#{zone_id}.json")

Purge URLs

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

About

Ruby gem for the KeyCDN API

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages