The better Ruby client for Heroku API, built on top of official
Add this line to your application's Gemfile:
And then execute:
Or install it yourself as:
$ gem install ruroku
Start by initiating a connection with Heroku API:
heroku = Ruroku::API.new api_key: YOUR_HEROKU_API_KEY
(You can leave out
ENV['HEROKU_API_KEY'] is set
Now you can interact with Heroku API using Ruroku.
Each API object has apps associated with the Heroku account. You can
access an Array of all the associated apps with
heroku.apps # => [#<App>, #<App>, #<App>] app = heroku.apps.first
To get specific app:
app = heroku.app 'app-name'
And access its properties such as:
Maintenance mode can be turned on and off:
To get a list of addons used by a particular app:
addons = app.addons # => [#<Addon>, #<Addon>, #<Addon>] addon = app.addons.first
It's possible perform several actions on addon collections:
# Add an addon addons.add 'addon:plan' # Remove an addon addons.delete 'addon-name' # Upgrade an addon addons.upgrade 'addon:new-plan'
Each addon object is associated with the application. You can delete
addons from the app by calling
#delete method on the addon object as
List all app collaborators:
collaborators = app.collaborators
# Add a collaborator collaborators.add 'firstname.lastname@example.org' # Remove a collaborator collaborators.delete 'email@example.com' # or collaborator.delete!
List all app config vars:
config_vars = app.config_vars
Add or delete a config var:
config_vars.add 'KEY' => 'value' config_vars.delete 'KEY' # or: config_var.delete!
They can also be updated like that:
config_var.value = 'new value'
And it'll instantly get updated.
Access domains used by the application:
domains = app.domains
Same as with other collection objects, they can be added or deleted:
domains.add 'domain.com' domains.delete 'domain.com' # or: domain.delete!
Get current application processes:
processes = app.processes
You can also run, restart, scale, and stop method collections:
processes.run 'rake evolve' processes.restart processes.scale 'worker', 10 processes.stop 'ps' => 'run.1' processes.stop 'type' => 'worker'
List all app releases:
releases = app.releases
And rollback to any release:
List stacks, available for the app:
Migrate the app to available stack:
Get User object associtaed with current heroku account:
Access all keys:
keys = heroku.keys
Add a key:
keys.add 'content of id_rsa.pub here...'
Delete specific key:
keys.delete 'firstname.lastname@example.org' key.delete!
Delete all keys:
For practice or testing you can also use a simulated Heroku:
require 'ruroku' heroku = Ruroku::API.new api_key: API_KEY, mock: true
After that commands should still behave the same, but they will only modify some local data instead of updating the state of things on Heroku.
- Fork it
- Create your feature branch (
git checkout -b my-new-feature)
- Commit your changes (
git commit -am 'Added some feature')
- Push to the branch (
git push origin my-new-feature)
- Create new Pull Request
Released under the MIT license.