gogrid api - presented at cloud connect event 2010
DESCRIPTION
This presentation was given by Justin Kitagawa (GoGrid's Lead Senior Software Engineer) at the Cloud Connect Event 2010 as part of a panel "Writing Code for Many Clouds". Video of the presentation is located at: http://blog.gogrid.com/?p=1807 The presentation provides an overview of GoGrid's API.TRANSCRIPT
APIControl the Cloud
Justin Kitagawa
Control the CloudWho and What are we?• GoGrid is a global leader in hybrid cloud infrastructure• We provide cloud datacenters where customers pay on
demand for infrastructure that they use• Our infrastructure consists of inter-connected servers, load
balancers, firewalls, network, and storage
• Cloud Computing = Completely Outsourced IT Infrastructure
All possible through GoGrid’s portal…
and…
GoGrid’s APIHTTP Rest-Like Query API• https://api.gogrid.com• Easy to use stateless API using HTTP GET and POST Requests• Language agnostic• Every API request is a combination of
an action (verb) and an object (noun)
Examples:• Add Server• List Load Balancer
Anatomy of a GoGrid API Call
Common API Request Parameters
Sample API Request
https://api.gogrid.com/api/grid/server/add ?name=My+First+Server &image=centos53_64_none &ram=8GB &ip=192.200.10.101 &api_key=SK1mndkKSjsALKSExdsj30 &sig=Lsmdfj3kw99sdklnasdkjhds &v=1.4
API request adds an 8GB CentOS Linux virtual server accessible at a public ip of 192.200.10.101
Sample Code
#!/bin/bash
APIKEY=a43c234fb2343064SECRET=passwordGTIME=`date +%s` SERVER='https://api.gogrid.com/api' VERSION='1.4' FORMAT=json METHOD='/grid/server/list?'
function getMD5sum { HASH=$1$2$3 SIG=`echo -n $HASH | md5sum | cut -d' ' -f1`
} function buildBaseURL {
#without array, cleaner in bash URL="$1$2&sig=$3&format=$4&v=$5&api_key=$6"
} function getURL {
# have curl fail silently and spit out error code to STDERR curl -f $1
}
# Get to work getMD5sum $APIKEY $SECRET $GTIME buildBaseURL $SERVER $METHOD $SIG $FORMAT $VERSION $APIKEY getURL $URL
Objectsserverimageloadbalancerippasswordjob
Actionsaddeditdeletelistget
Challenges• Keeping it Simple (KISS)• SOAP vs REST vs HTTP• Consistent Terminology (Common Actions/Verbs)• Liberal Inputs > Conservative Output• Flexibility
• Versioning / Backward Compatibility• Rules:• Only add attributes to objects• Never remove attributes to objects• Never remove parameters from API request calls
• Test harnesses to test regressions
Who is this all for?
Who here wants to leverage cloud infrastructure to improve the efficiency of
their engineering team’s development, staging, or production systems?
YOU!
For More Information
• Website – www.GoGrid.com• Wiki – wiki.gogrid.com• Blog – blog.GoGrid.com• Twitter - @GoGrid• Facebook – www.facebook.com/gogrid