The whole Scalingo platform is API-driven, all the tools you are manipulating as a user, are communicating with our public APIs: the dashboard and the command line tool scalingo
. Our APIs are accessible and documented, you can build and use your own tools against them to improve your workflows. To help you doing so, we just released the v2 version of our official Ruby library.
The first version of this library was not an official release, it had been designed by a platform's user in the need of a deeper integration. Later the project was transferred to us, but lacked some love for a few years.
Since then, we revamped our authentication system and we expanded on multiple regions this year, the gem is now compatible with both these major changes of the platform.
Plus, different resources were not yet implemented and couldn't be modified easily with this library, their support has been added:
Find about the different resources you can manipulate in our developers documentation.
To use our Ruby library, you need to add it in your Gemfile
:
gem 'scalingo-ruby-api', '~> 2'
Then it has to be configured in your project. The following snippet would configure
the library to use the API token from the environment in the SCALINGO_API_TOKEN
variable,
and to use the region osc-fr
.
Scalingo.configure do |config|
config.token = ENV['SCALINGO_API_TOKEN']
config.region = 'osc-fr1'
end
For a Ruby on Rails application, create an initializer
`config/initializers/scalingo.rb` to add this configuration
Note that if you need to use different tokens or different regions in your project, you can configure these per client instance in your code:
client_osc_fr1 = Scalingo::Client.new(region: 'osc-fr1')
client_user_1 = Scalingo::Client.new(token: ENV['SCALINGO_USER1_TOKEN'])
client = Scalingo::Client.new
apps = client.apps.all
apps.each do |app|
puts app.name
end
client = Scalingo::Client.new
app = client.apps.find('my-app')
app.domains.create('example.com')
client = Scalingo::Client.new
app = client.apps.find('my-app')
stats = app.stats.all
stats.each do |stat|
puts "Container #{s.id}: Memory: #{s.memory_usage/1024/1024}MB/#{s.memory_limit/1024/1024}MB"
end
Which would output:
Container clock-1: Memory: 147MB/512MB
Container web-1: Memory: 357MB/512MB
Container web-2: Memory: 329MB/512MB
Container web-3: Memory: 275MB/5128MB
Container worker-1: Memory: 167MB/512MB
The project is under MIT license and available on GitHub: https://github.com/Scalingo/scalingo-ruby-api. You'll find more information in the README of the project. If you have any question don't hesitate to open an issue, we'll help you as soon as possible.
You're not working with Ruby? We're officially developing and supporting libraries in other languages:
At Scalingo (with our partners) we use trackers on our website.
Some of those are mandatory for the use of our website and can't be refused.
Some others are used to measure our audience as well as to improve our relationship with you or to send you quality content and advertising.