No commit activity in last 3 years
No release in over 3 years
Simple wrapper for the CDNetworks Config Open API v1.0 and Cache Purge Open API v2.0
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
 Project Readme

Cdnetworks Client

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.

Requirements

  • A CDNetworks OCSP Account

Installation

 gem install cdnetworks-client 

Or, in your Gemfile, add

 gem 'cdnetworks-client' 

And run

 bundle 

Usage

Creating an instance of Cdnetworks Client

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:

  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.

Listing PADs and their information

  cdn.list

You can also add in parameters

  cdn.list(:prod => 1)

Viewing a PAD

  cdn.view(:pad => "cache.foo.com")

Adding a PAD

  cdn.add(:pad => "cache.foo.com", :origin => "neworigin.foo.com")

Editing a PAD

  cdn.edit(:pad => "cache.foo.com", :honor_byte_range => "1")

Purging a cache

If you are using Cache Flush Open API v2.3.2

  cdn.do_purge(:pad => "cdn.example.com", :type => "all")
  cdn.do_purge(:pad => "cdn.example.com", :path => ["images/one.jpg", "images/two.jpg"])

If you are using Cache Purge Open API v2.0

  cdn.execute_cache_purge(:purgeUriList => "cdn.example.com")
  cdn.execute_cache_purge(:purgeUriList => ["cdn.example.com", "cdn.foo.com"])

Getting the status of a cache purge

  cdn.status(:pid => 1234)

Listing all PAD domain names

If you are using Cache Flush Open API v2.3.2

  cdn.pad_list

If you are using Cache Purge Open API v2.0

  cdn.get_cache_domain_list

License

License is Apache License v2.0 by Blue Box, Inc., Nell Shamrell, unless otherwise noted.