Class: Rundeck::Session
- Inherits:
-
Object
- Object
- Rundeck::Session
- Defined in:
- lib/rundeck-ruby-client/session.rb
Instance Attribute Summary collapse
-
#server ⇒ Object
readonly
Returns the value of attribute server.
-
#token ⇒ Object
readonly
Returns the value of attribute token.
Instance Method Summary collapse
- #get(url, *keys) ⇒ Object
-
#initialize(server, token) ⇒ Session
constructor
A new instance of Session.
- #project(name) ⇒ Object
- #projects ⇒ Object
- #system_info ⇒ Object
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
#server ⇒ Object (readonly)
Returns the value of attribute server.
13 14 15 |
# File 'lib/rundeck-ruby-client/session.rb', line 13 def server @server end |
#token ⇒ Object (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 |
#projects ⇒ Object
26 27 28 |
# File 'lib/rundeck-ruby-client/session.rb', line 26 def projects Project.all(self) end |
#system_info ⇒ Object
22 23 24 |
# File 'lib/rundeck-ruby-client/session.rb', line 22 def system_info get('api/1/system/info', 'result', 'system') end |