Class: Jamf::PatchTitle::Version
- Defined in:
- lib/jamf/api/classic/api_objects/patch_title/version.rb
Overview
A Patch Software Title Version in the JSS.
This class corresponds to a “version” returned from the ‘patchsoftwaretitles’ resource of the API
Not only does each one have a ‘version’, e.g. ‘8.3.2b12’, but also knows its parent PatchTitle, the matching Jamf::Package, if any, and can report the names and ids of the computers that have it installed.
To set or change the Jamf::Package associated with a PatchTitle::Version, first fetch the corresponding SoftwareTitle, use the #package= method of the Version object in its #versions attribute, then save the PatchTitle back to the JSS.
Instance Attribute Summary collapse
-
#package_id ⇒ Integer
readonly
The id of the Jamf::Package that installs this PatchVersion, if defined.
-
#package_name ⇒ String
readonly
The name of the Jamf::Package that installs this PatchVersion, if defined.
-
#version ⇒ String
readonly
The software version number for this PatchVersion.
Instance Method Summary collapse
-
#computer_ids ⇒ Array<Integer>
The ids of #computers.
-
#computer_names ⇒ Array<Integer>
The names of #computers.
-
#computer_serial_numbers ⇒ Array<Integer>
The serial_numbers of #computers.
-
#computer_udids ⇒ Array<Integer>
The udids of #computers.
-
#computers ⇒ Array<Hash>
A hash of identifiers for each computer with this version installed.
-
#initialize(title, data) ⇒ Version
constructor
This should only be instantiated by the Jamf::PatchTitle that contains this version.
-
#package=(new_pkg) ⇒ Object
Assign a new Jamf::Package to this PatchTitle::Version.
-
#package_assigned? ⇒ Boolean
Has a package been assigned to this version?.
-
#patch_report ⇒ Object
(also: #version_report, #report)
get the patch report for this version See PatchTitle.patch_report.
-
#pretty_print_instance_variables ⇒ Array
Remove the various cached data from the instance_variables used to create pretty-print (pp) output.
-
#total_computers ⇒ Integer
How many #computers have this version?.
Constructor Details
#initialize(title, data) ⇒ Version
This should only be instantiated by the Jamf::PatchTitle that contains this version.
66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/jamf/api/classic/api_objects/patch_title/version.rb', line 66 def initialize(title, data) @title = title @version = data[:software_version].to_s return if data[:package].to_s.empty? pid = data[:package][:id].to_i @package_id = pid < 1 ? :none : pid @package_name = data[:package][:name] end |
Instance Attribute Details
#package_id ⇒ Integer (readonly)
Returns the id of the Jamf::Package that installs this PatchVersion, if defined.
57 58 59 |
# File 'lib/jamf/api/classic/api_objects/patch_title/version.rb', line 57 def package_id @package_id end |
#package_name ⇒ String (readonly)
Returns the name of the Jamf::Package that installs this PatchVersion, if defined.
61 62 63 |
# File 'lib/jamf/api/classic/api_objects/patch_title/version.rb', line 61 def package_name @package_name end |
#version ⇒ String (readonly)
Returns the software version number for this PatchVersion. name_id is a unique identfier created from the patch name.
53 54 55 |
# File 'lib/jamf/api/classic/api_objects/patch_title/version.rb', line 53 def version @version end |
Instance Method Details
#computer_ids ⇒ Array<Integer>
Returns The ids of #computers.
106 107 108 |
# File 'lib/jamf/api/classic/api_objects/patch_title/version.rb', line 106 def computer_ids computers.map { |c| c[:id] } end |
#computer_names ⇒ Array<Integer>
Returns The names of #computers.
112 113 114 |
# File 'lib/jamf/api/classic/api_objects/patch_title/version.rb', line 112 def computer_names computers.map { |c| c[:name] } end |
#computer_serial_numbers ⇒ Array<Integer>
Returns The serial_numbers of #computers.
118 119 120 |
# File 'lib/jamf/api/classic/api_objects/patch_title/version.rb', line 118 def computer_serial_numbers computers.map { |c| c[:serial_number] } end |
#computer_udids ⇒ Array<Integer>
Returns The udids of #computers.
124 125 126 |
# File 'lib/jamf/api/classic/api_objects/patch_title/version.rb', line 124 def computer_udids computers.map { |c| c[:udid] } end |
#computers ⇒ Array<Hash>
Returns A hash of identifiers for each computer with this version installed.
100 101 102 |
# File 'lib/jamf/api/classic/api_objects/patch_title/version.rb', line 100 def computers patch_report[:versions][version] end |
#package=(new_pkg) ⇒ Object
Assign a new Jamf::Package to this PatchTitle::Version. The Package must exist in the JSS. Be sure to call #update on the PatchTitle containing this Version.
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 |
# File 'lib/jamf/api/classic/api_objects/patch_title/version.rb', line 136 def package=(new_pkg) raise Jamf::UnsupportedError, "Packages can't be assigned to the Unkown version." if version == Jamf::PatchTitle::UNKNOWN_VERSION_ID pkgid = if new_pkg == :none :none else Jamf::Package.valid_id new_pkg, :refresh, cnx: @title.cnx end raise Jamf::NoSuchItemError, "No Jamf::Package matches '#{new_pkg}'" unless pkgid return if @package_id == pkgid @package_id = pkgid @package_name = pkgid == :none ? nil : Jamf::Package.map_all_ids_to(:name, cnx: @title.cnx)[pkgid] @title.changed_pkg_for_version version end |
#package_assigned? ⇒ Boolean
Returns Has a package been assigned to this version?.
80 81 82 |
# File 'lib/jamf/api/classic/api_objects/patch_title/version.rb', line 80 def package_assigned? package_id != :none end |
#patch_report ⇒ Object Also known as: version_report, report
get the patch report for this version See PatchTitle.patch_report
86 87 88 |
# File 'lib/jamf/api/classic/api_objects/patch_title/version.rb', line 86 def patch_report @title.patch_report version end |
#pretty_print_instance_variables ⇒ Array
Remove the various cached data from the instance_variables used to create pretty-print (pp) output.
160 161 162 163 164 |
# File 'lib/jamf/api/classic/api_objects/patch_title/version.rb', line 160 def pretty_print_instance_variables vars = super vars.delete :@title vars end |
#total_computers ⇒ Integer
Returns How many #computers have this version?.
94 95 96 |
# File 'lib/jamf/api/classic/api_objects/patch_title/version.rb', line 94 def total_computers patch_report[:total_computers] end |