appfog_api 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/appfog_api.rb +57 -0
  2. metadata +46 -0
data/lib/appfog_api.rb ADDED
@@ -0,0 +1,57 @@
1
+ require 'json'
2
+ require 'rest_client'
3
+
4
+ class API
5
+ attr_reader :username, :password
6
+ def initialize(username, password)
7
+ @username = username
8
+ @password = password
9
+ @@site = RestClient::Resource.new('https://api.appfog.com')
10
+ end
11
+
12
+ def auth
13
+ password = {'password'=>@password}.to_json
14
+ request = @@site["users/#{@username}/tokens"].post password, :content_type => :json
15
+ raw_token = JSON.parse(request)
16
+ @token = raw_token['token']
17
+ end
18
+
19
+ def get(url)
20
+ if @token == nil
21
+ auth
22
+ end
23
+ @@site[url].get("Authorization"=>@token)
24
+ end
25
+
26
+ def post(url)
27
+ if @token == nil
28
+ auth
29
+ end
30
+ @@site[url].post("Authorization"=>@token)
31
+ end
32
+
33
+ def info
34
+ JSON.parse(get("/info"))
35
+ end
36
+
37
+ def app(app)
38
+ JSON.parse(get("/apps/#{app}"))
39
+ end
40
+
41
+ def app_crash(app)
42
+ JSON.parse(get("/apps/#{app}/crashes"))
43
+ end
44
+
45
+ def app_instances(app)
46
+ JSON.parse(get("/apps/#{app}/instances"))
47
+ end
48
+
49
+ def app_stats(app)
50
+ JSON.parse(get("/apps/#{app}/stats"))
51
+ end
52
+
53
+ def services
54
+ JSON.parse(get("/services"))
55
+ end
56
+ end
57
+
metadata ADDED
@@ -0,0 +1,46 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: appfog_api
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Richard Howard
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2010-04-01 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: A simple API wrapper for AppFog's API. This tool is to allow for fast
15
+ integration with AppFog
16
+ email: richardahoward@gmail.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - lib/appfog_api.rb
22
+ homepage: http://rubygems.org/gems/appfog_api
23
+ licenses: []
24
+ post_install_message:
25
+ rdoc_options: []
26
+ require_paths:
27
+ - lib
28
+ required_ruby_version: !ruby/object:Gem::Requirement
29
+ none: false
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ required_rubygems_version: !ruby/object:Gem::Requirement
35
+ none: false
36
+ requirements:
37
+ - - ! '>='
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ requirements: []
41
+ rubyforge_project:
42
+ rubygems_version: 1.8.24
43
+ signing_key:
44
+ specification_version: 3
45
+ summary: Hmmmm, becasue it needed to be done
46
+ test_files: []