Git Product home page Git Product logo

heroku.rb's Introduction

Heroku Ruby Client

The Heroku Ruby Client is used to interact with the Heroku Legacy API from Ruby.

Where possible we recommend interacting instead with the Heroku Platform API. You can use the Ruby client with the Platform API (or just install the gem).

Build Status

Usage

Start by creating a connection to Heroku with your credentials:

require 'heroku-api'

heroku = Heroku::API.new(:api_key => API_KEY)                           # use API Key
heroku = Heroku::API.new(:username => USERNAME, :password => PASSWORD)  # use username and password
heroku = Heroku::API.new(:headers => {'User-Agent' => 'custom'})        # use custom header

NOTE: You can leave out the :api_key if ENV['HEROKU_API_KEY'] is set instead.

Now you can make requests to the api.

Requests

What follows is an overview of commands you can run for the client.

For additional details about any of the commands, see the API docs.

Add-ons

heroku.delete_addon(APP, ADD_ON)    # remove the ADD_ON add-on from the app named APP
heroku.post_addon(APP, ADD_ON)      # add ADD_ON add-on to an the app named APP
heroku.put_addon(APP, ADD_ON)       # update the ADD_ON add-on on the app named APP
heroku.get_addons                   # see a listing of all available add-ons
heroku.get_addons(APP)              # see listing of installed add-ons for the app named APP

Apps

heroku.delete_app(APP)                  # delete the app named APP
heroku.get_apps                         # get a list of your apps
heroku.get_app(APP)                     # get info about the app named APP
heroku.get_dyno_types(APP)              # get dyno types for the app named APP    
heroku.post_app                         # create an app with a generated name and the default stack
heroku.post_app_maintenance(APP, '1')   # toggle maintenance mode for the app named APP
heroku.post_app('name' => 'app')        # create an app with a specified name, APP
heroku.put_app('name' => 'myapp')       # update an app to have a different name

Collaborators

heroku.delete_collaborator(APP, '[email protected]')   # remove '[email protected]' collaborator from APP app
heroku.get_collaborators(APP)                          # list collaborators for APP app
heroku.post_collaborator(APP, '[email protected]')     # add '[email protected]' collaborator to APP app

Config Variables

heroku.delete_config_var(APP, KEY)               # remove KEY key from APP app
heroku.get_config_vars(APP)                      # get list of config vars for APP app
heroku.put_config_vars(APP, KEY => 'value')      # set KEY key to 'value' for APP app

Domains

heroku.delete_domain(APP, 'example.com')   # remove the 'example.com' domain from the APP app
heroku.get_domains(APP)                    # list configured domains for the APP app
heroku.post_domain(APP, 'example.com')     # add 'example.com' domain to the APP app

Keys

heroku.delete_key('[email protected]') # remove the '[email protected]' key
heroku.delete_keys                       # remove all keys
heroku.get_keys                          # list configured keys
heroku.post_key('key data')              # add key defined by 'key data'

Logs

heroku.get_logs(APP) # return logs information for APP app

Processes

heroku.get_ps(APP)                               # list current dynos for APP app
heroku.post_ps(APP, 'command')                   # run 'command' command in context of APP app
heroku.post_ps_restart(APP)                      # restart all dynos for APP app
heroku.post_ps_scale(APP, TYPE, QTY)             # scale TYPE type dynos to QTY for APP app
heroku.post_ps_stop(APP, 'ps' => 'web.1')        # stop 'web.1' dyno for APP app
heroku.post_ps_stop(APP, 'type' => 'web')        # stop all 'web' dynos for APP app
heroku.post_ps_restart(APP, 'ps' => 'web.1')     # restart 'web.1' dyno for APP app
heroku.put_dynos(APP, DYNOS)                     # set number of dynos for bamboo app APP to DYNOS
heroku.put_workers(APP, WORKERS)                 # set number of workers for bamboo app APP to WORKERS
heroku.post_ps_scale(APP, 'worker', WORKERS)     # set number of workers for cedar app APP to WORKERS
heroku.put_formation(APP, 'web' => '2X')         # set dyno size to '2X' for all 'web' dynos for APP app

Releases

heroku.get_releases(APP)       # list of releases for the APP app
heroku.get_release(APP, 'v#')  # get details of 'v#' release for APP app
heroku.post_release(APP, 'v#') # rollback APP app to 'v#' release

Stacks

heroku.get_stack(APP)          # list available stacks
heroku.put_stack(APP, STACK) # migrate APP app to STACK stack

User

heroku.get_user                  # list user info

Mock

For testing (or practice) you can also use a simulated Heroku account:

require 'heroku-api'

heroku = Heroku::API.new(:api_key => API_KEY, :mock => true)

Commands will now behave as normal, however, instead of interacting with your actual Heroku account you'll be interacting with a blank test account. Note: test accounts will have NO apps to begin with. You'll need to create one:

heroku.post_app(:name => 'my-test-app')

Tests

To run tests, first set ENV['HEROKU_API_KEY'] to your api key. Then use bundle exec rake to run mock tests or MOCK=false bundle exec rake to run integration tests.

Meta

Released under the MIT license.

heroku.rb's People

Contributors

geemus avatar ddollar avatar ryanbrainard avatar danp avatar will avatar chtrinh avatar hgmnz avatar jassa avatar johnbeynon avatar wuputah avatar kmayer avatar mfine avatar raulb avatar vince avatar amaisaeta avatar brandur avatar brianjriddle avatar csquared avatar catsby avatar asenchi avatar djhopper01 avatar imderek avatar dim avatar fabiokung avatar jkakar avatar jkutner avatar softwaregravy avatar devl avatar mmcgrana avatar friism avatar

Watchers

Michael.Yang avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.