Giter Club home page Giter Club logo

cdnetworks-client's Introduction

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)

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.

cdnetworks-client's People

Contributors

nellshamrell avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.