Skip to content

Instantly share code, notes, and snippets.

@hecbuma
Created June 11, 2014 06:09
Show Gist options
  • Save hecbuma/418b2cc45cca77f00383 to your computer and use it in GitHub Desktop.
Save hecbuma/418b2cc45cca77f00383 to your computer and use it in GitHub Desktop.
require 'faraday'
require 'json'
conn = Faraday.new
response = conn.get 'https://identity.api.rackspacecloud.com/v2.0/tokens' do |request|
request.headers['Content-Type'] = 'application/json'
request.body = "{\"auth\": {\"RAX-KSKEY:apiKeyCredentials\": { \"username\": \"littlebits\",\"apiKey\": \"96c884d7223f4b85bd3d12c72e7523af\"}}}"
end
res_json = JSON.parse response.body
token = res_json['access']['token']['id’]
response = conn.post "https://ord.databases.api.rackspacecloud.com/v1.0/834500/backups" do |request|
request.headers['Content-Type'] = 'application/json'
request.headers['X-Auth-Token'] = token
request.body = '{ "backup":{ "description":”backup from DigitalOcean", "instance":"7c8a3fe4-8497-4f20-b09b-fd529c5c7c5a", "name”:”Backup from DigitaOcean via API" } }’
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment