Class: Arista::EAPI::Request
- Inherits:
-
Object
- Object
- Arista::EAPI::Request
- Defined in:
- lib/arista/eapi/request.rb
Instance Attribute Summary collapse
-
#commands ⇒ Object
Returns the value of attribute commands.
-
#options ⇒ Object
Returns the value of attribute options.
-
#switch ⇒ Object
Returns the value of attribute switch.
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(switch, commands, options = {}) ⇒ Request
constructor
A new instance of Request.
- #payload ⇒ Object
Constructor Details
#initialize(switch, commands, options = {}) ⇒ Request
Returns a new instance of Request.
6 7 8 9 10 11 12 |
# File 'lib/arista/eapi/request.rb', line 6 def initialize(switch, commands, = {}) [:format] ||= 'json' self.switch = switch self.commands = commands self. = end |
Instance Attribute Details
#commands ⇒ Object
Returns the value of attribute commands.
4 5 6 |
# File 'lib/arista/eapi/request.rb', line 4 def commands @commands end |
#options ⇒ Object
Returns the value of attribute options.
4 5 6 |
# File 'lib/arista/eapi/request.rb', line 4 def @options end |
#switch ⇒ Object
Returns the value of attribute switch.
4 5 6 |
# File 'lib/arista/eapi/request.rb', line 4 def switch @switch end |
Instance Method Details
#execute ⇒ Object
27 28 29 |
# File 'lib/arista/eapi/request.rb', line 27 def execute Arista::EAPI::Response.new(commands, RestClient.post(switch.url, payload)) end |
#payload ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/arista/eapi/request.rb', line 14 def payload @payload ||= JSON.generate({ :jsonrpc => '2.0', :method => 'runCmds', :id => 1, :params => { :version => 1, :cmds => commands, :format => [:format] }, }) end |