Bash.gif

Previous: Supported Languages


Contents


64-warn.gif
NOTE: GoGrid Support WILL NOT troubleshoot customer-modified code. The code snippets and examples provided in this API documentation can be modified to customize your own code, but GoGrid Support cannot troubleshoot any errors you may receive due to missing syntax or illegal arguments. We WILL support our API interface and can troubleshoot any API server-side errors you may be receiving. Please note that all of the code snippets and examples provided in this API documentation have been thoroughly tested and verified as properly working.

gogrid_example.sh

#!/bin/bash

APIKEY=YOUR API KEY
SECRET=YOUR SHARED SECRET
GTIME=`date +%s`

SERVER='https://api.gogrid.com/api'
VERSION='1.0'
FORMAT=xml
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

Previous: Supported Languages

Personal tools