Class: Rundeck::Session

Inherits:
Object
  • Object
show all
Defined in:
lib/rundeck-ruby/session.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(server, token, options = {}) ⇒ Session

Returns a new instance of Session.



8
9
10
11
12
13
# File 'lib/rundeck-ruby/session.rb', line 8

def initialize(server, token, options={})
  @server = server
  @token = token
  @options = options
  @resource = RestClient::Resource.new(server, options)
end

Instance Attribute Details

#serverObject (readonly)

Returns the value of attribute server.



15
16
17
# File 'lib/rundeck-ruby/session.rb', line 15

def server
  @server
end

#tokenObject (readonly)

Returns the value of attribute token.



15
16
17
# File 'lib/rundeck-ruby/session.rb', line 15

def token
  @token
end

Instance Method Details

#get(url, *keys) ⇒ Object



17
18
19
20
21
# File 'lib/rundeck-ruby/session.rb', line 17

def get(url, *keys)
  xml = @resource[url].get('X-Rundeck-Auth-Token'=> token)
  hash = Maybe(Hash.from_xml(xml))
  keys.reduce(hash){|acc, cur| acc && acc[cur]}
end

#project(name) ⇒ Object



31
32
33
# File 'lib/rundeck-ruby/session.rb', line 31

def project(name)
  Project.find(self, name)
end

#projectsObject



27
28
29
# File 'lib/rundeck-ruby/session.rb', line 27

def projects
  Project.all(self)
end

#system_infoObject



23
24
25
# File 'lib/rundeck-ruby/session.rb', line 23

def system_info
  get('api/1/system/info', 'result', 'system')
end