Class: Moxprox::Ticket

Inherits:
Struct
  • Object
show all
Defined in:
lib/moxprox/ticket.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#connectionObject

Returns the value of attribute connection

Returns:

  • (Object)

    the current value of connection



2
3
4
# File 'lib/moxprox/ticket.rb', line 2

def connection
  @connection
end

#csrfObject

Returns the value of attribute csrf

Returns:

  • (Object)

    the current value of csrf



2
3
4
# File 'lib/moxprox/ticket.rb', line 2

def csrf
  @csrf
end

#ticketObject

Returns the value of attribute ticket

Returns:

  • (Object)

    the current value of 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.(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

#headersObject



10
11
12
# File 'lib/moxprox/ticket.rb', line 10

def headers
  { 'Cookie' => "PVEAuthCookie=#{ticket}", "CSRFPreventionToken" => csrf }
end