Created
February 18, 2015 20:56
-
-
Save fancyremarker/531ee9423c56cd4bf278 to your computer and use it in GitHub Desktop.
[:octopus:] Grab an app container's internal host and port from the Aptible API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'aptible/auth' | |
require 'aptible/api' | |
HANDLE = 'your-app' | |
EMAIL = '[email protected]' | |
PASSWORD = '' | |
token = Aptible::Auth::Token.create(email: EMAIL, password: PASSWORD) | |
app = Aptible::Api::App.all(token: token).find do |app| | |
app.handle == HANDLE | |
end | |
container = app.services.first.current_release.containers.find do |container| | |
container.layer == 'app' | |
end | |
puts container.host | |
puts container.port |
Added some prompts for the credentials and handle so we don't have to hard code it. In case someone else needs this at some point.
require 'aptible/auth'`
require 'aptible/api'
require 'io/console'
print "Enter the Aptible app handle: "
HANDLE = gets.strip
print "Enter your email address (the one you use to login to aptible): "
EMAIL = gets.strip
print "Enter your password: "
PASSWORD = STDIN.noecho(&:gets).strip
Thanks @tobalsgithub !
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Prerequisities:
gem install -N aptible-api aptible-auth