Skip to content

Instantly share code, notes, and snippets.

@fancyremarker
Created February 18, 2015 20:56
Show Gist options
  • Select an option

  • Save fancyremarker/531ee9423c56cd4bf278 to your computer and use it in GitHub Desktop.

Select an option

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
require 'aptible/auth'
require 'aptible/api'
HANDLE = 'your-app'
EMAIL = 'you@example.com'
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
@tobalsgithub
Copy link
Copy Markdown

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

@fancyremarker
Copy link
Copy Markdown
Author

Thanks @tobalsgithub !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment