The Cdnetworks Client is a simple wrapper for three Cdnetworks APIs
- Config Open API v1.0
- Cache Purge Open API v2.0 (older cache flushing API)
- Cache Flush Open API v2.3.2 (most current cache flushing API)
- Statistics Open API v2
This gem allows a user to call methods from either of these APIs using the same syntax.
- A CDNetworks OCSP Account
gem install cdnetworks-client
Or, in your Gemfile, add
gem 'cdnetworks-client'
And run
bundle
Create an instance:
cdn = CdnetworksClient.new(:user => [Your CDNetworks User Name], :pass => [Your CDNetworks Password])
CDNetworks uses different access domains for some locations. You can optionally specify a location when you create a new instance.
By default, the location is set to US/Global and uses the access domain https://openapi.us.cdnetworks.com
You can specify the following locations:
- Korea (uses access domain https://openapi.us.cdnetworks.com)
- Japan (uses access domain https://openapi.jp.cdnetworks.com)
- China (uses access domain https://openapi.txnetworks.cn)
cdn = CdnetworksClient.new( :user => [Your CDNetworks User Name], :pass => [Your CDNetworks Password], :location => "Korea" )
Again, the default location is US/Global using the access domain https://openapi.us.cdnetworks.com
Please see the CDNetworks API documentation for a full list of options and parameters for each API call
After each call, the gem will return a hash including the response code and the response body from CDNetworks.
cdn.list
You can also add in parameters
cdn.list(:prod => 1)
cdn.view(:pad => "cache.foo.com")
cdn.add(:pad => "cache.foo.com", :origin => "neworigin.foo.com")
cdn.edit(:pad => "cache.foo.com", :honor_byte_range => "1")
cdn.do_purge(:pad => "cdn.example.com", :type => "all")
cdn.do_purge(:pad => "cdn.example.com", :path => ["images/one.jpg", "images/two.jpg"])
cdn.execute_cache_purge(:purgeUriList => "cdn.example.com")
cdn.execute_cache_purge(:purgeUriList => ["cdn.example.com", "cdn.foo.com"])
cdn.status(:pid => 1234)
cdn.pad_list
cdn.get_cache_domain_list
License is Apache License v2.0 by Blue Box, Inc., Nell Shamrell, unless otherwise noted.