Class: Proxmox::Application
- Inherits:
-
Object
- Object
- Proxmox::Application
- Defined in:
- lib/proxmox/application.rb,
lib/proxmox/configuration.rb
Defined Under Namespace
Classes: Configuration
Instance Attribute Summary collapse
-
#connector ⇒ Object
readonly
Returns the value of attribute connector.
-
#csrf ⇒ Object
Returns the value of attribute csrf.
-
#role ⇒ Object
readonly
Returns the value of attribute role.
-
#ticket ⇒ Object
Returns the value of attribute ticket.
-
#username ⇒ Object
readonly
Returns the value of attribute username.
Instance Method Summary collapse
- #configuration(&block) ⇒ Object
-
#initialize {|configuration| ... } ⇒ Application
constructor
A new instance of Application.
- #login ⇒ Object
- #ping ⇒ Object
- #version ⇒ Object
Constructor Details
#initialize {|configuration| ... } ⇒ Application
Returns a new instance of Application.
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
#connector ⇒ Object (readonly)
Returns the value of attribute connector.
11 12 13 |
# File 'lib/proxmox/application.rb', line 11 def connector @connector end |
#csrf ⇒ Object
Returns the value of attribute csrf.
10 11 12 |
# File 'lib/proxmox/application.rb', line 10 def csrf @csrf end |
#role ⇒ Object (readonly)
Returns the value of attribute role.
11 12 13 |
# File 'lib/proxmox/application.rb', line 11 def role @role end |
#ticket ⇒ Object
Returns the value of attribute ticket.
10 11 12 |
# File 'lib/proxmox/application.rb', line 10 def ticket @ticket end |
#username ⇒ Object (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 |
#login ⇒ Object
26 27 28 29 |
# File 'lib/proxmox/application.rb', line 26 def login response = connector.post(LOGIN_PATH, need_auth: false, data: configuration.credentials_params) update_tokens(response[:data]) end |
#ping ⇒ Object
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 |
#version ⇒ Object
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 |