Creating Applications

You can create applications on an existing cloud by POSTing to /api/clouds/XXXXX/applications

 headers = {"X-Scalarium-Token" => "XXXXX", "Accept" => "application/vnd.scalarium-v1+json", "Content-Type"=>"application/json"}

RestClient.post("https://manage.scalarium.com/api/clouds/XXXXX/applications",
                JSON.dump(:name => 'api app',
                          :application_type => 'rails',
                          :rails_env => 'production',
                          :auto_bundle => true,
                          :scm_type => 'git',
                          :scm_url => 'git://github.com/peritor/photopoll.git'),
                headers)

Accepted attributes in the POST body (encoded as JSON hash) are:

Application Basics

  • name: The name of the application.
  • application_type: Must be one of the following

    • rails
    • php
    • nodejs
    • static
    • other

    if application_type equals rails

    • rails_env: The Rails enviroment, e.g. production, development, or test.
    • auto_bundle: Boolean to choose whether Rails apps should bundle on deploy or not.

    for all application types:

    • document_root: The name of a subfolder of your app to be the document root. Keep blank for the main folder to be the document root. E.g. 'web' or 'public'
  • mounted_at: A prefix for the Load Balancer to decide to which server to route, e.g. if your application is mounted at a subdirectory. Default would be '/' but you could do something like '/my_app'

Domain and SSL

  • domain_name: vhost settings - seperate multiple domains by comma, e.g. 'www.scalarium.com, scalarium.com'
  • ssl_support: Booloean to enable SSL support.
  • ssl_certificate: Required if ssl_support is enabled. Put the content of your domain.crt file in here.
  • ssl_certificate_key: Required if ssl_support is enabled. Put the content of your domain.kex file in here.
  • ssl_certificate_ca: Optional for an intermediate CA key or Client Authentication.

Repository Information

  • scm_type: Must be one of the following or empty
    • git
    • svn
    • archive
    • s3
  • scm_url: Required if scm_type is set. Could be something like git://github.com/peritor/photopoll.git

    if scm_type is git

    • scm_ssh_key: Optional SSH key for your git repository.

    if scm_type is svn or archive

    • scm_user: Optional username for SVN or the http download.
    • scm_password: Optional password for SVN or the http download.

    if scm_type is s3

    • scm_user: AWS Access Key ID required to authenticate to S3 in order to download
    • scm_password: AWS Secret Access Key required to authenticate to S3 in order to download
  • scm_revision: Optional specification of a branch or revision, e.g. staging, master, or fd72e9c99312. If this is empty HEAD is used.

If validation fails, the API will return HTTP status code 412 with the errors included in the body, like so:

{
  "errors": ["Name can't be blank"]
}

If you are using RestClient, you get an exception in case of a 412 HTTP response. To evaluate the response body, you need to catch the exception, e.g.:

  headers = {"X-Scalarium-Token" => "XXXXX", "Accept" => "application/vnd.scalarium-v1+json", "Content-Type"=>"application/json"}
begin
  RestClient.post("https://manage.scalarium.com/api/clouds/XXXXX/applications",
                JSON.dump(:name => 'api app',
                          :application_type => 'rails',
                          :rails_env => 'production',
                          :auto_bundle => true,
                          :scm_type => 'git',
                          :scm_url => 'git://github.com/peritor/photopoll.git'),
                headers)
rescue => e
  e.response
end

If the application was successfully created, the response will include the HTTP location of the new application and its ID in the response body:

{
  "id":"jd75dfgh23s4hjbgsdf6598rhg8wat4ecg83h4fv"
}