Class: Rhc::Rest::Domain

Inherits:
Object
  • Object
show all
Includes:
Rhc::Rest
Defined in:
lib/rhc-rest/domain.rb

Constant Summary

Constants included from Rhc::Rest

VERSION

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Rhc::Rest

#logger, #parse_response, #process_error_response, #send

Constructor Details

#initialize(args) ⇒ Domain

Returns a new instance of Domain.



6
7
8
9
# File 'lib/rhc-rest/domain.rb', line 6

def initialize(args)
  @id = args[:id] || args["id"]
  @links = args[:links] || args["links"]
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



5
6
7
# File 'lib/rhc-rest/domain.rb', line 5

def id
  @id
end

Instance Method Details

#add_application(name, options) ⇒ Object

Add Application to this domain options cartrdige template scale node_profile



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# 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

#applicationsObject

Get all Application for this domain



34
35
36
37
38
39
40
# 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

#destroy(force = false) ⇒ Object Also known as: delete

Delete Domain



54
55
56
57
58
59
60
61
# 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

#update(new_id) ⇒ Object Also known as: save

Update Domain



43
44
45
46
47
48
49
50
# 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 = {:domain_id => new_id}
  request = RestClient::Request.new(:url => url, :method => method, :headers => @@headers, :payload => payload)
  return send(request)
end