class RHC::Rest::Domain

Attributes

id[R]

Public Class Methods

new(args) click to toggle source
# File lib/rhc/rest/domain.rb, line 6
def initialize(args)
  @id = args[:id] || args["id"]
  @links = args[:links] || args["links"]
end

Public Instance Methods

add_application(name, options) click to toggle source

Add Application to this domain

options
cartrdige
template
scale
node_profile
# File lib/rhc/rest/domain.rb, line 17
def add_application(name, options)
  logger.debug "Adding application #{name} to domain #{self.id}" if @mydebug
  url = @links['ADD_APPLICATION']['href']
  method =  @links['ADD_APPLICATION']['method']
  payload = {:name => name}
  options.each do |key, value|
    payload[key] = value
  end
  timeout = nil
  if options[:scale]
    timeout = 300 # 5 minute timeout for scalable app
  end
  request = new_request(:url => url, :method => method, :headers => @@headers, :payload => payload, :timeout => timeout)
  return request(request)
end
applications() click to toggle source

Get all Application for this domain

# File lib/rhc/rest/domain.rb, line 34
def applications
  logger.debug "Getting all applications for domain #{self.id}" if @mydebug
  url = @links['LIST_APPLICATIONS']['href']
  method =  @links['LIST_APPLICATIONS']['method']
  request = new_request(:url => url, :method => method, :headers => @@headers)
  return request(request)
end
delete(force=false) click to toggle source
Alias for: destroy
destroy(force=false) click to toggle source

Delete Domain

# File lib/rhc/rest/domain.rb, line 62
def destroy(force=false)
  logger.debug "Deleting domain #{self.id}" if @mydebug
  url = @links['DELETE']['href']
  method =  @links['DELETE']['method']
  payload = {:force => force}
  request = new_request(:url => url, :method => method, :headers => @@headers, :payload => payload)
  return request(request)
end
Also aliased as: delete
find_application(name) click to toggle source
# File lib/rhc/rest/domain.rb, line 42
def find_application(name)
  logger.debug "Finding application #{name}" if @mydebug
  applications.each { |app| return app if app.name == name }

  raise RHC::ApplicationNotFoundException.new("Application #{name} does not exist")
end
save(new_id) click to toggle source
Alias for: update
update(new_id) click to toggle source

Update Domain

# File lib/rhc/rest/domain.rb, line 50
def update(new_id)
  logger.debug "Updating domain #{self.id} to #{new_id}" if @mydebug
  url = @links['UPDATE']['href']
  method =  @links['UPDATE']['method']
  payload = {:id => new_id}
  # 5 minute timeout as this may take time if there are a lot of apps
  request = new_request(:url => url, :method => method, :headers => @@headers, :payload => payload, :timeout=> 300)
  return request(request)
end
Also aliased as: save