Class: Proxmox::Application

Inherits:
Object
  • Object
show all
Defined in:
lib/proxmox/application.rb,
lib/proxmox/configuration.rb

Defined Under Namespace

Classes: Configuration

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize {|configuration| ... } ⇒ Application

Returns a new instance of Application.

Yields:



13
14
15
16
17
18
19
20
# File 'lib/proxmox/application.rb', line 13

def initialize
  yield(configuration) if block_given?
  @connector = Connector.new(self)
  @csrf = nil
  @ticket = nil
  @username = nil
  @role = nil
end

Instance Attribute Details

#connectorObject (readonly)

Returns the value of attribute connector.



11
12
13
# File 'lib/proxmox/application.rb', line 11

def connector
  @connector
end

#csrfObject

Returns the value of attribute csrf.



10
11
12
# File 'lib/proxmox/application.rb', line 10

def csrf
  @csrf
end

#roleObject (readonly)

Returns the value of attribute role.



11
12
13
# File 'lib/proxmox/application.rb', line 11

def role
  @role
end

#ticketObject

Returns the value of attribute ticket.



10
11
12
# File 'lib/proxmox/application.rb', line 10

def ticket
  @ticket
end

#usernameObject (readonly)

Returns the value of attribute username.



11
12
13
# File 'lib/proxmox/application.rb', line 11

def username
  @username
end

Instance Method Details

#configuration(&block) ⇒ Object



22
23
24
# File 'lib/proxmox/application.rb', line 22

def configuration(&block)
  @configuration ||= Configuration.new(&block)
end

#loginObject



26
27
28
29
# File 'lib/proxmox/application.rb', line 26

def 
  response = connector.post(, need_auth: false, data: configuration.credentials_params)
  update_tokens(response[:data])
end

#pingObject



36
37
38
39
# File 'lib/proxmox/application.rb', line 36

def ping
  response = connector.post(PING_PATH, data: { username: @username, password: @ticket })
  update_tokens(response[:data])
end

#versionObject



31
32
33
34
# File 'lib/proxmox/application.rb', line 31

def version
  response = connector.get(VERSION_PATH, data: { _dc: (Time.now.to_f * 1_000).to_i })
  response.dig(:data, :version)
end