Project

keycdn

0.01
No release in over 3 years
Low commit activity in last 3 years
This Ruby gem helps you to interact with the KeyCDN API
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

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