Sha256: 7931d9393d783ab60b8e36c72aeedcc7e0aa765934d8fe1e9a9e6298f293b51b

Contents?: true

Size: 1.33 KB

Versions: 1

Compression:

Stored size: 1.33 KB

Contents

module Nucleus
  module Adapters
    module V1
      class CloudFoundryV2 < Stub
        module Lifecycle
          # @see Stub#start
          def start(application_name_or_id)
            app_guid = app_guid(application_name_or_id)
            # fail if there is no deployment
            unless deployed?(app_guid)
              raise Errors::SemanticAdapterRequestError, 'Application must be deployed before it can be started'
            end

            # start by name or id
            start_response = put("/v2/apps/#{app_guid}", body: { state: 'STARTED' })
            to_nucleus_app(start_response.body)
          end

          # @see Stub#stop
          def stop(application_name_or_id)
            app_guid = app_guid(application_name_or_id)
            # fail if there is no deployment
            unless deployed?(app_guid)
              raise Errors::SemanticAdapterRequestError, 'Application must be deployed before it can be stopped'
            end

            # stop by name or id
            stop_response = put("/v2/apps/#{app_guid}", body: { state: 'STOPPED' })
            to_nucleus_app(stop_response.body)
          end

          # @see Stub#restart
          def restart(application_name_or_id)
            stop(application_name_or_id)
            start(application_name_or_id)
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nucleus-0.3.1 lib/nucleus/adapters/v1/cloud_foundry_v2/lifecycle.rb