class RHC::Rest::Domain

Public Instance Methods

add_application(name, options) click to toggle source

Add Application to this domain

options
cartridge
template
scale
gear_profile
# File lib/rhc/rest/domain.rb, line 22
def add_application(name, options)
  debug "Adding application #{name} to domain #{id}"

  payload = {:name => name}
  options.each{ |key, value| payload[key.to_sym] = value }

  cartridges = Array(payload.delete(:cartridge)).concat(Array(payload.delete(:cartridges))).map do |cart|
      if cart.is_a? String or cart.respond_to? :[]
        cart
      else
        cart.url ? {:url => cart.url} : cart.name
      end
    end.compact.uniq

  if cartridges.any?{ |c| c.is_a?(Hash) and c[:url] } and !has_param?('ADD_APPLICATION', 'cartridges[][url]')
    raise RHC::Rest::DownloadingCartridgesNotSupported, "The server does not support downloading cartridges."
  end

  if client.api_version_negotiated >= 1.3
    payload[:cartridges] = cartridges
  else
    raise RHC::Rest::MultipleCartridgeCreationNotSupported, "The server only supports creating an application with a single web cartridge." if cartridges.length > 1
    payload[:cartridge] = cartridges.first
  end

  if payload[:initial_git_url] and !has_param?('ADD_APPLICATION', 'initial_git_url')
    raise RHC::Rest::InitialGitUrlNotSupported, "The server does not support creating applications from a source repository."
  end

  options = {:timeout => options[:scale] && 0 || nil}
  rest_method "ADD_APPLICATION", payload, options
end
allowed_gear_sizes() click to toggle source
# File lib/rhc/rest/domain.rb, line 6
def allowed_gear_sizes
  Array(attribute(:allowed_gear_sizes))
end
applications(options = {}) click to toggle source
# File lib/rhc/rest/domain.rb, line 55
def applications(options = {})
  debug "Getting all applications for domain #{id}"
  rest_method "LIST_APPLICATIONS", options
end
delete(force=false)
Alias for: destroy
destroy(force=false) click to toggle source
# File lib/rhc/rest/domain.rb, line 67
def destroy(force=false)
  debug "Deleting domain #{id}"
  rest_method "DELETE", :force => force
end
Also aliased as: delete
owner() click to toggle source
# File lib/rhc/rest/domain.rb, line 10
def owner
  if o = Array(attribute(:members)).find{ |m| m['owner'] == true }
    o['name']
  end
end
save(new_id)
Alias for: update
supports_add_application_with_env_vars?() click to toggle source
# File lib/rhc/rest/domain.rb, line 73
def supports_add_application_with_env_vars?
  has_param?('ADD_APPLICATION', 'environment_variables')
end
update(new_id) click to toggle source
# File lib/rhc/rest/domain.rb, line 60
def update(new_id)
  debug "Updating domain #{id} to #{new_id}"
  # 5 minute timeout as this may take time if there are a lot of apps
  rest_method "UPDATE", {:id => new_id}, {:timeout => 0}
end
Also aliased as: save