GithubHelp home page GithubHelp logo

enstratus_helper's Introduction

enstratus_helper

enstratus_helper is a simple ruby class that helps making request to enStratus web service easier. With enstratus_helper, you only have to specify the resource you want to request, and it will handle the signature generation & HTTP header initialization for you.

Usage

     require 'enstratus_helper'
     access_key = "my_access_key"
     secret_key = "super_secret_key"

     ehelper = EnstratusHelper.new(:access_key => access_key, :secret_key => secret_key)

     # You can specify whether to use json or xml format
     ehelper = EnstratusHelper.new(:access_key => access_key, :secret_key => secret_key, :accept => 'application/json')

     # Example of doing GET requests
     puts ehelper.request :get, 'http://api.enstratus.com/api/enstratus/2011-02-24/geography/Region'
     puts ehelper.request :get, 'http://api.enstratus.com/api/enstratus/2011-02-24/infrastructure/MachineImage?regionId=my_region_id'
     puts ehelper.request :get, 'http://api.enstratus.com/api/enstratus/2011-02-24/infrastructure/Server'

     # You can explicitly define GET request header. Here, we're explicitly specifying the format to be JSON
     #puts ehelper.request :get, 'http://api.enstratus.com/api/enstratus/2011-02-24/admin/BillingCode', :header => {'Accept' => 'application/json'}

     # Example of doing POST requests
     xml_data =<<EOF
     <addBillingCode>
       <billingCode>
         <name>API Dev 1</name>
         <financeCode>API 1</financeCode>
         <description>API Development</description>
         <softQuota>USD50.00</softQuota>
       </billingCode>
     </addBillingCode>
     EOF
     json_data = {:addBillingCode => {:billingCode => {:name => 'API 3', :financeCode => "API 3", :description => "description", :softQuota => 'USD11.01', :hardQuota => 'USD11.11'}}}.to_json

     ehelper.request :post, 'http://api.enstratus.com/api/enstratus/2011-02-24/admin/BillingCode', :data => xml_data
     ehelper.request :post, 'http://api.enstratus.com/api/enstratus/2011-02-24/admin/BillingCode', :data => xml_data, :header => {'Accept' => 'application/xml'}
     ehelper.request :post, 'http://api.enstratus.com/api/enstratus/2011-02-24/admin/BillingCode', :data => json_data, :header => {'Accept' => 'application/json'}

enstratus_helper's People

Contributors

darrendao avatar

Stargazers

 avatar John E. Vincent avatar

Watchers

 avatar 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.