# File lib/rhc/rest/domain.rb, line 6 def initialize(args) @id = args[:id] || args["id"] @links = args[:links] || args["links"] end
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
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 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
# 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
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