Class: Pvectl::Models::AptPackage
- Defined in:
- lib/pvectl/models/apt_package.rb
Overview
Represents an APT package on a Proxmox node.
Single model serves both pending updates (‘/apt/update`) and installed package versions (`/apt/versions`). Some attributes only apply to one API: `notify_status` to pending updates, `current_state`, `manager_version`, `running_kernel` to versions.
Instance Attribute Summary collapse
-
#arch ⇒ String?
readonly
Architecture (amd64, arm64, all, …).
-
#current_state ⇒ String?
readonly
Current installed state (versions only).
-
#description ⇒ String?
readonly
Package description.
-
#manager_version ⇒ String?
readonly
Pve-manager API server version (versions only).
-
#node ⇒ String?
readonly
Node name this package belongs to.
-
#notify_status ⇒ String?
readonly
Notify status (pending updates only).
-
#old_version ⇒ String?
readonly
Currently installed version.
-
#origin ⇒ String?
readonly
Package origin (e.g., “Proxmox”, “Debian”).
-
#package ⇒ String?
readonly
Package name.
-
#priority ⇒ String?
readonly
Package priority.
-
#running_kernel ⇒ String?
readonly
Running kernel (proxmox-ve package, versions only).
-
#section ⇒ String?
readonly
Package section.
-
#title ⇒ String?
readonly
Short package title.
-
#version ⇒ String?
readonly
Available / target version.
Instance Method Summary collapse
-
#initialize(attrs = {}) ⇒ AptPackage
constructor
Creates a new AptPackage instance.
-
#installed_state ⇒ String
Returns the installed package state, defaults to “Installed” when not provided.
-
#upgrade? ⇒ Boolean
Returns true if a different version is available.
Constructor Details
#initialize(attrs = {}) ⇒ AptPackage
Creates a new AptPackage instance.
Accepts Proxmox API capitalized keys (‘Package`, `OldVersion`, …) as well as snake_case / dasherized variants. Indifferent access on keys.
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/pvectl/models/apt_package.rb', line 74 def initialize(attrs = {}) super @package = attributes[:Package] || attributes[:package] @title = attributes[:Title] || attributes[:title] @version = attributes[:Version] || attributes[:version] @old_version = attributes[:OldVersion] || attributes[:old_version] || attributes[:"old-version"] @origin = attributes[:Origin] || attributes[:origin] @section = attributes[:Section] || attributes[:section] @priority = attributes[:Priority] || attributes[:priority] @arch = attributes[:Arch] || attributes[:arch] @description = attributes[:Description] || attributes[:description] @notify_status = attributes[:NotifyStatus] || attributes[:notify_status] || attributes[:"notify-status"] @current_state = attributes[:CurrentState] || attributes[:current_state] || attributes[:"current-state"] @manager_version = attributes[:ManagerVersion] || attributes[:manager_version] || attributes[:"manager-version"] @running_kernel = attributes[:RunningKernel] || attributes[:running_kernel] || attributes[:"running-kernel"] @node = attributes[:node] end |
Instance Attribute Details
#arch ⇒ String? (readonly)
Returns architecture (amd64, arm64, all, …).
48 49 50 |
# File 'lib/pvectl/models/apt_package.rb', line 48 def arch @arch end |
#current_state ⇒ String? (readonly)
Returns current installed state (versions only).
57 58 59 |
# File 'lib/pvectl/models/apt_package.rb', line 57 def current_state @current_state end |
#description ⇒ String? (readonly)
Returns package description.
51 52 53 |
# File 'lib/pvectl/models/apt_package.rb', line 51 def description @description end |
#manager_version ⇒ String? (readonly)
Returns pve-manager API server version (versions only).
60 61 62 |
# File 'lib/pvectl/models/apt_package.rb', line 60 def manager_version @manager_version end |
#node ⇒ String? (readonly)
Returns node name this package belongs to.
66 67 68 |
# File 'lib/pvectl/models/apt_package.rb', line 66 def node @node end |
#notify_status ⇒ String? (readonly)
Returns notify status (pending updates only).
54 55 56 |
# File 'lib/pvectl/models/apt_package.rb', line 54 def notify_status @notify_status end |
#old_version ⇒ String? (readonly)
Returns currently installed version.
36 37 38 |
# File 'lib/pvectl/models/apt_package.rb', line 36 def old_version @old_version end |
#origin ⇒ String? (readonly)
Returns package origin (e.g., “Proxmox”, “Debian”).
39 40 41 |
# File 'lib/pvectl/models/apt_package.rb', line 39 def origin @origin end |
#package ⇒ String? (readonly)
Returns package name.
27 28 29 |
# File 'lib/pvectl/models/apt_package.rb', line 27 def package @package end |
#priority ⇒ String? (readonly)
Returns package priority.
45 46 47 |
# File 'lib/pvectl/models/apt_package.rb', line 45 def priority @priority end |
#running_kernel ⇒ String? (readonly)
Returns running kernel (proxmox-ve package, versions only).
63 64 65 |
# File 'lib/pvectl/models/apt_package.rb', line 63 def running_kernel @running_kernel end |
#section ⇒ String? (readonly)
Returns package section.
42 43 44 |
# File 'lib/pvectl/models/apt_package.rb', line 42 def section @section end |
#title ⇒ String? (readonly)
Returns short package title.
30 31 32 |
# File 'lib/pvectl/models/apt_package.rb', line 30 def title @title end |
#version ⇒ String? (readonly)
Returns available / target version.
33 34 35 |
# File 'lib/pvectl/models/apt_package.rb', line 33 def version @version end |
Instance Method Details
#installed_state ⇒ String
Returns the installed package state, defaults to “Installed” when not provided.
102 103 104 |
# File 'lib/pvectl/models/apt_package.rb', line 102 def installed_state current_state || "Installed" end |
#upgrade? ⇒ Boolean
Returns true if a different version is available.
95 96 97 |
# File 'lib/pvectl/models/apt_package.rb', line 95 def upgrade? !old_version.nil? && !version.nil? && old_version != version end |