Class: Rundeck::Session

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(server, token) ⇒ Session

Returns a new instance of Session.



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

def initialize(server, token)
  @server = server
  @token = token
end

Instance Attribute Details

#serverObject (readonly)

Returns the value of attribute server.



13
14
15
# File 'lib/rundeck-ruby-client/session.rb', line 13

def server
  @server
end

#tokenObject (readonly)

Returns the value of attribute token.



13
14
15
# File 'lib/rundeck-ruby-client/session.rb', line 13

def token
  @token
end

Instance Method Details

#get(url, *keys) ⇒ Object



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

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

#project(name) ⇒ Object



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

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

#projectsObject



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

def projects
  Project.all(self)
end

#system_infoObject



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

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