Class: Moxprox::Ticket
- Inherits:
-
Struct
- Object
- Struct
- Moxprox::Ticket
- Defined in:
- lib/moxprox/ticket.rb
Instance Attribute Summary collapse
-
#connection ⇒ Object
Returns the value of attribute connection.
-
#csrf ⇒ Object
Returns the value of attribute csrf.
-
#ticket ⇒ Object
Returns the value of attribute ticket.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#connection ⇒ Object
Returns the value of attribute connection
2 3 4 |
# File 'lib/moxprox/ticket.rb', line 2 def connection @connection end |
#csrf ⇒ Object
Returns the value of attribute csrf
2 3 4 |
# File 'lib/moxprox/ticket.rb', line 2 def csrf @csrf end |
#ticket ⇒ Object
Returns the value of attribute ticket
2 3 4 |
# File 'lib/moxprox/ticket.rb', line 2 def ticket @ticket end |
Class Method Details
.login(host, username, password) ⇒ Object
3 4 5 6 7 8 |
# File 'lib/moxprox/ticket.rb', line 3 def self.login(host, username, password) connection = Excon.new("https://#{host}:8006") res = connection.post(path: "/api2/json/access/ticket", query: { username: username, password: password }) data = JSON.parse(res.body) self.new(connection, data["data"]["ticket"], data["data"]["CSRFPreventionToken"]) end |
Instance Method Details
#headers ⇒ Object
10 11 12 |
# File 'lib/moxprox/ticket.rb', line 10 def headers { 'Cookie' => "PVEAuthCookie=#{ticket}", "CSRFPreventionToken" => csrf } end |