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 = 180 # 3 minute timeout for scalable app
  end
  request = RestClient::Request.new(:url => url, :method => method, :headers => @@headers, :payload => payload, :timeout => timeout)
  return send(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 = RestClient::Request.new(:url => url, :method => method, :headers => @@headers)
  return send(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 54
def destroy(force=false)
  logger.debug "Deleting domain #{self.id}" if @mydebug
  url = @links['DELETE']['href']
  method =  @links['DELETE']['method']
  payload = {:force => force}
  request = RestClient::Request.new(:url => url, :method => method, :headers => @@headers, :payload => payload)
  return send(request)
end
Also aliased as: delete
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 43
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}
  request = RestClient::Request.new(:url => url, :method => method, :headers => @@headers, :payload => payload)
  return send(request)
end
Also aliased as: save