Git Product home page Git Product logo

ruby-maxcdn's Introduction

MaxCDN REST Web Services Ruby Client

Build Status ย  Gem Version

Installation

gem install maxcdn

Requires Ruby 2.3+ (see: Travis for passing Ruby versions.)

With Bundler

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

Usage

require 'maxcdn'

api = MaxCDN::Client.new("myalias", "consumer_key", "consumer_secret")

####
# Turn on debugging outputs
#
# api.debug = true

api.get("/account.json")

Methods

It has support for GET, POST, PUT and DELETE OAuth 1.0a signed requests.

# To create a new Pull Zone
api.post("/zones/pull.json", {'name' => 'test_zone', 'url' => 'http://my-test-site.com'})

# To update an existing zone
api.put("/zones/pull.json/1234", {'name' => 'i_didnt_like_test'})

# To delete a zone
api.delete("/zones/pull.json/1234")

# To purge a file (robots.txt) from cache
api.delete("/zones/pull.json/1234/cache", {"file" => "/robots.txt"})

We now have a shortcut for Purge Calls!

zone_id = 12345

# Purge Zone
api.purge(zone_id)

# Purge File
api.purge(zone_id, '/some_file')

# Purge Files
api.purge(zone_id, ['/some_file', '/another_file'])

Example: SSL Upload

max = MaxCDN::Client.new(alias, key, secret)
max.post("zones/pull/12345/ssl.json", {
  :ssl_crt => File.read("/path/to/server.crt").strip,
  :ssl_key  => File.read("/path/to/server.key").strip })

Development Quick Start

# get it
git clone [email protected]:<fork repo>/ruby-maxcdn.git

# setup
cd ruby-maxcdn
bundle install --path vendor/bundle

# unit tests
bundle exec ruby ./test/test.rb

# integration tests
export ALIAS=<your alias>
export KEY=<your key>
export SECRET=<your secret>
bundle exec ruby ./test/integration.rb # requires host's IP be whitelisted

Change Log

0.3.0
  • Replace CurbFu with Faraday (#10).
0.2.1
0.1.5
  • Issue #4: Fixing purge files by array to return a hash of status results.
0.1.4
  • Fixing bug where purging files purges entire zone.
0.1.3
  • Requested changes for debugging and development support. (See issue #2).
0.1.2
  • Fixing an issue with lib loading in 0.1.1.
0.1.1
  • Fixing POST, DELETE and PUT to send data via request body.
  • Adding debugging for CurbFu and Curl::Easy.
  • Fixing/enhancing unit tests.
  • Removing secure_connection handling, as all connections should be secure.
  • Fixing 414 Request-URI Too Large from old netdnarws-ruby client.
0.1.0
  • Initial Release

ruby-maxcdn's People

Contributors

dlitvakb avatar jmervine avatar jdorfman avatar eamonnscu avatar atmos avatar ewoodh2o avatar hiroshi avatar

Watchers

James Cloos 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.