Class: Rhc::Rest::Application

Inherits:
Object
  • Object
show all
Includes:
Rhc::Rest
Defined in:
lib/rhc-rest/application.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) ⇒ Application

Returns a new instance of Application.



7
8
9
10
11
12
13
14
15
16
# File 'lib/rhc-rest/application.rb', line 7

def initialize(args)
  #logger.debug args
  @domain_id = args[:domain_id] || args["domain_id"]
  @name = args[:name] || args["name"]
  @creation_time = args[:creation_time] || args["creation_time"]
  @uuid = args[:uuid] || args["uuid"]
  @aliases = args[:aliases] || args["aliases"]
  @server_identity = args[:server_identity] || args["server_identity"]
  @links = args[:links] || args["links"]
end

Instance Attribute Details

#aliasesObject (readonly)

Returns the value of attribute aliases.



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

def aliases
  @aliases
end

#app_urlObject (readonly)

Returns the value of attribute app_url.



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

def app_url
  @app_url
end

#creation_timeObject (readonly)

Returns the value of attribute creation_time.



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

def creation_time
  @creation_time
end

#domain_idObject (readonly)

Returns the value of attribute domain_id.



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

def domain_id
  @domain_id
end

#embeddedObject (readonly)

Returns the value of attribute embedded.



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

def embedded
  @embedded
end

#frameworkObject (readonly)

Returns the value of attribute framework.



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

def framework
  @framework
end

#git_urlObject (readonly)

Returns the value of attribute git_url.



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

def git_url
  @git_url
end

#health_check_pathObject (readonly)

Returns the value of attribute health_check_path.



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

def health_check_path
  @health_check_path
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#node_profileObject (readonly)

Returns the value of attribute node_profile.



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

def node_profile
  @node_profile
end

#scalableObject (readonly)

Returns the value of attribute scalable.



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

def scalable
  @scalable
end

#uuidObject (readonly)

Returns the value of attribute uuid.



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

def uuid
  @uuid
end

Instance Method Details

#add_cartridge(name) ⇒ Object

Add Cartridge



19
20
21
22
23
24
25
26
# File 'lib/rhc-rest/application.rb', line 19

def add_cartridge(name)
  logger.debug "Adding cartridge #{name}" if @mydebug
  url = @links['ADD_CARTRIDGE']['href']
  method =  @links['ADD_CARTRIDGE']['method']
  payload = {:name => name}
  request = RestClient::Request.new(:url => url, :method => method, :headers => @@headers, :payload => payload)
  return send(request)
end

#cartridgesObject

Get all Cartridge for this applications



29
30
31
32
33
34
35
# File 'lib/rhc-rest/application.rb', line 29

def cartridges
  logger.debug "Getting all cartridges for application #{self.name}" if @mydebug
  url = @links['LIST_CARTRIDGES']['href']
  method =  @links['LIST_CARTRIDGES']['method']
  request = RestClient::Request.new(:url => url, :method => method, :headers => @@headers)
  return send(request)
end

#destroyObject Also known as: delete

Delete Application



72
73
74
75
76
77
78
# File 'lib/rhc-rest/application.rb', line 72

def destroy
  logger.debug "Deleting application #{self.name}" if @mydebug
  url = @links['DELETE']['href']
  method =  @links['DELETE']['method']
  request = RestClient::Request.new(:url => url, :method => method, :headers => @@headers)
  return send(request)
end

#restartObject

Restart Application



62
63
64
65
66
67
68
69
# File 'lib/rhc-rest/application.rb', line 62

def restart
  logger.debug "Restarting application #{self.name}" if @mydebug
  url = @links['RESTART']['href']
  method =  @links['RESTART']['method']
  payload = {:event=> "restart"}
  request = RestClient::Request.new(:url => url, :method => method, :headers => @@headers, :payload => payload)
  return send(request)
end

#startObject

Start Application



38
39
40
41
42
43
44
45
# File 'lib/rhc-rest/application.rb', line 38

def start
  logger.debug "Starting application #{self.name}" if @mydebug
  url = @links['START']['href']
  method =  @links['START']['method']
  payload = {:event=> "start"}
  request = RestClient::Request.new(:url => url, :method => method, :headers => @@headers, :payload => payload)
  return send(request)
end

#stop(force = false) ⇒ Object

Stop Application



48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/rhc-rest/application.rb', line 48

def stop(force=false)
  logger.debug "Stopping application #{self.name} force-#{force}" if @mydebug
  url = @links['STOP']['href']
  method =  @links['STOP']['method']
  if force
    payload = {:event=> "force-stop"}
  else
    payload = {:event=> "stop"}
  end
  request = RestClient::Request.new(:url => url, :method => method, :headers => @@headers, :payload => payload)
  return send(request)
end