GithubHelp home page GithubHelp logo

linodeapi's Introduction

linodeapi

Gem Version Build Status Coverage Status Code Quality MIT Licensed

Ruby API wrapper for the Linode API

Usage

Create an API object from the LinodeAPI::Raw class, by providing it with either an API key or username and password:

require 'linodeapi'

api_one = LinodeAPI::Raw.new(apikey: 'YOUR_KEY_HERE')
api_two = LinodeAPI::Raw.new(username: 'akerl', password: 'cyberpond')

The Raw API object is a faithful representation of Linode's API spec, parsed directly from the upstream source at runtime. Calls can be made using the methods shown in Linode's API docs:

# cat list.rb
require 'linodeapi'

api = LinodeAPI::Raw.new(apikey: 'KEY')

result = api.linode.list

puts "#{result.size} Linodes found: #{result.map(&:label).join(', ')}"
p result.first
# ruby list.rb
6 Linodes found: miro, olhado, quara, grego, ela, quim
#<OpenStruct alert_cpu_enabled=0, alert_bwin_enabled=0, alert_bwquota_enabled=0, alert_diskio_threshold=1000, backupwindow=4, watchdog=1, distributionvendor="Arch", datacenterid=6, status=1, alert_diskio_enabled=0, create_dt="2014-07-30 20:09:12.0", totalhd=49152, alert_bwquota_threshold=80, totalram=2048, alert_bwin_threshold=5, linodeid=591319, alert_bwout_threshold=5, alert_bwout_enabled=0, backupsenabled=0, alert_cpu_threshold=90, planid=2, backupweeklyday=0, label="miro", lpm_displaygroup="cluster", totalxfer=3000>

Arguments passed in are named just like in the docs:

api.linode.ip.list(linodeid: 591319)

The library will raise an exception if you exclude a required parameter:

api.linode.create
# ArgumentError: linode.create requires planid

Retryable helper

The LinodeAPI::Retryable class automatically handles 429 errors (really, any HTTP error that is accompanied by a Retry-After header).

This class behaves identially to the LinodeAPI::Raw class, with 2 additional parameters at creation: max_retries sets the total number of requests it will attempt per call and max_delay sets the maximum delay between attempts. They default to 3 tries and 60 seconds, respectively.

Installation

gem install linodeapi

License

linodeapi is released under the MIT License. See the bundled LICENSE file for details.

linodeapi's People

Contributors

akerl avatar ctreatma avatar iwada 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.