Module: Nucleus::Adapters::V1::CloudControl::Lifecycle

Included in:
Nucleus::Adapters::V1::CloudControl
Defined in:
lib/nucleus/adapters/v1/cloud_control/lifecycle.rb

Instance Method Summary collapse

Instance Method Details

#start(application_id) ⇒ Object

See Also:



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/nucleus/adapters/v1/cloud_control/lifecycle.rb', line 7

def start(application_id)
  deployment = default_deployment(application_id)
  # fail if there is no deployment

  unless data_uploaded?(deployment)
    fail Errors::SemanticAdapterRequestError, 'Application must be deployed before it can be started'
  end

  # if no cloudControl deployment has been made, trigger it

  if deployment[:version] == '-1'
    # deploy via the API, use version identifier -1 to refer a new build

    put("app/#{application_id}/deployment/#{NUCLEUS_DEPLOYMENT}", body: { version: '-1' })
  end

  # return the application object

  to_nucleus_app(get("/app/#{application_id}").body, default_deployment(application_id))
end