| Class | Heroku::Client |
| In: |
lib/heroku/client.rb
|
| Parent: | Object |
| host | [R] | |
| password | [R] | |
| user | [R] |
# File lib/heroku/client.rb, line 18
18: def initialize(user, password, host='heroku.com')
19: @user = user
20: @password = password
21: @host = host
22: end
Invite a person by email address to collaborate on the app. Optional third parameter can be edit or view.
# File lib/heroku/client.rb, line 70
70: def add_collaborator(app_name, email, access='view')
71: xml(post("/apps/#{app_name}/collaborators", { 'collaborator[email]' => email, 'collaborator[access]' => access }))
72: end
Add an ssh public key to the current user.
# File lib/heroku/client.rb, line 93
93: def add_key(key)
94: post("/user/keys", key, { 'Content-Type' => 'text/ssh-authkey' })
95: end
Destroy the app permanently.
# File lib/heroku/client.rb, line 55
55: def destroy(name)
56: delete("/apps/#{name}")
57: end
Show info such as mode, custom domain, and collaborators on an app.
# File lib/heroku/client.rb, line 31
31: def info(name)
32: doc = xml(get("/apps/#{name}"))
33: attrs = { :collaborators => list_collaborators(name) }
34: doc.elements.to_a('//app/*').inject(attrs) do |hash, element|
35: hash[element.name.to_sym] = element.text; hash
36: end
37: end
Get a list of collaborators on the app, returns an array of hashes each of which contain :email and :access (=> edit | view) elements.
# File lib/heroku/client.rb, line 61
61: def list_collaborators(app_name)
62: doc = xml(get("/apps/#{app_name}/collaborators"))
63: doc.elements.to_a("//collaborators/collaborator").map do |a|
64: { :email => a.elements['email'].text, :access => a.elements['access'].text }
65: end
66: end
Remove a collaborator.
# File lib/heroku/client.rb, line 80
80: def remove_collaborator(app_name, email)
81: delete("/apps/#{app_name}/collaborators/#{escape(email)}")
82: end
Remove an existing ssh public key from the current user.
# File lib/heroku/client.rb, line 98
98: def remove_key(key)
99: delete("/user/keys/#{escape(key)}")
100: end
# File lib/heroku/client.rb, line 114
114: def resource(uri)
115: RestClient::Resource.new("http://#{host}", user, password)[uri]
116: end
Update an app. Available attributes:
:name => rename the app (changes http and git urls) :public => true | false :mode => production | development
# File lib/heroku/client.rb, line 50
50: def update(name, attributes)
51: put("/apps/#{name}", :app => attributes)
52: end