deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@redhat.com
Subject [PATCH core 3/4] GoGrid: Updated supported API to 1.9 in client
Date Thu, 23 Aug 2012 12:18:36 GMT
From: Michal Fojtik <mfojtik@redhat.com>


Signed-off-by: Michal fojtik <mfojtik@redhat.com>
---
 server/lib/deltacloud/drivers/gogrid/gogrid_client.rb |   15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/server/lib/deltacloud/drivers/gogrid/gogrid_client.rb b/server/lib/deltacloud/drivers/gogrid/gogrid_client.rb
index 76b326e..77fba97 100644
--- a/server/lib/deltacloud/drivers/gogrid/gogrid_client.rb
+++ b/server/lib/deltacloud/drivers/gogrid/gogrid_client.rb
@@ -17,6 +17,7 @@
 require 'digest/md5'
 require 'cgi'
 require 'open-uri'
+require 'json'
 
 module Kernel
   def suppress_warnings
@@ -44,7 +45,7 @@ class GoGridClient
                  apikey='YOUR API KEY',
                  secret='YOUR SHARED SECRET',
                  format='json',
-                 version='1.6')
+                 version='1.9')
     @server = server
     @secret = secret
     @default_params = {'format'=>format, 'v'=>version,'api_key' => apikey}
@@ -52,13 +53,13 @@ class GoGridClient
 
   def getRequestURL(method,params)
     requestURL = @server+'/'+method+'?'
-  	call_params = @default_params.merge(params)
-  	call_params['sig']=getSignature(@default_params['api_key'],@secret)
-  	requestURL = requestURL+encode_params(call_params)
+    call_params = @default_params.merge(params)
+    call_params['sig']=getSignature(@default_params['api_key'],@secret)
+    requestURL = requestURL+encode_params(call_params)
   end
 
   def getSignature(key,secret)
-    Digest::MD5.hexdigest(key+secret+"%.0f"%Time.new.to_f)
+    Digest::MD5.hexdigest(key+secret+"%.0f"%Time.now.to_f)
   end
 
   def sendAPIRequest(method,params={})
@@ -71,8 +72,8 @@ class GoGridClient
     if version
       @default_params['v'] = version
     else
-      @default_params['v'] = '1.5'
-   end
+      @default_params['v'] = '1.9'
+    end
     request = sendAPIRequest(method, params)
     JSON::parse(request)
   end
-- 
1.7.10.2


Mime
View raw message