Class: Rundeck::Session
- Inherits:
-
Object
- Object
- Rundeck::Session
- Defined in:
- lib/rundeck-ruby/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, options = {}) ⇒ Session
constructor
A new instance of Session.
- #project(name) ⇒ Object
- #projects ⇒ Object
- #system_info ⇒ Object
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, ={}) @server = server @token = token @options = @resource = RestClient::Resource.new(server, ) end |
Instance Attribute Details
#server ⇒ Object (readonly)
Returns the value of attribute server.
15 16 17 |
# File 'lib/rundeck-ruby/session.rb', line 15 def server @server end |
#token ⇒ Object (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 |
#projects ⇒ Object
27 28 29 |
# File 'lib/rundeck-ruby/session.rb', line 27 def projects Project.all(self) end |
#system_info ⇒ Object
23 24 25 |
# File 'lib/rundeck-ruby/session.rb', line 23 def system_info get('api/1/system/info', 'result', 'system') end |