class Jamf::PatchTitle::Version
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
.
Attributes
@return [Integer] the id of the Jamf::Package
that installs this PatchVersion,
if defined.
@return [String] the name of the Jamf::Package
that installs this PatchVersion,
if defined
@return [String] the software version number for this PatchVersion.
name_id is a unique identfier created from the patch name
Public Class Methods
This should only be instantiated by the Jamf::PatchTitle
that contains this version.
# File lib/jamf/api/classic/api_objects/patch_title/version.rb 66 def initialize(title, data) 67 @title = title 68 @version = data[:software_version].to_s 69 70 return if data[:package].to_s.empty? 71 72 pid = data[:package][:id].to_i 73 74 @package_id = pid < 1 ? :none : pid 75 @package_name = data[:package][:name] 76 end
Public Instance Methods
@return [Array<Integer>] The ids of computers
# File lib/jamf/api/classic/api_objects/patch_title/version.rb 106 def computer_ids 107 computers.map { |c| c[:id] } 108 end
@return [Array<Integer>] The names of computers
# File lib/jamf/api/classic/api_objects/patch_title/version.rb 112 def computer_names 113 computers.map { |c| c[:name] } 114 end
@return [Array<Integer>] The serial_numbers of computers
# File lib/jamf/api/classic/api_objects/patch_title/version.rb 118 def computer_serial_numbers 119 computers.map { |c| c[:serial_number] } 120 end
@return [Array<Integer>] The udids of computers
# File lib/jamf/api/classic/api_objects/patch_title/version.rb 124 def computer_udids 125 computers.map { |c| c[:udid] } 126 end
@return [Array<Hash>] A hash of identifiers for each computer
with this version installed.
# File lib/jamf/api/classic/api_objects/patch_title/version.rb 100 def computers 101 patch_report[:versions][version] 102 end
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
.
@param new_pkg A name or id of a Jamf::Package
.
use :none to unset a package for this version.
# File lib/jamf/api/classic/api_objects/patch_title/version.rb 136 def package=(new_pkg) 137 raise Jamf::UnsupportedError, "Packages can't be assigned to the Unkown version." if version == Jamf::PatchTitle::UNKNOWN_VERSION_ID 138 139 pkgid = 140 if new_pkg == :none 141 :none 142 else 143 Jamf::Package.valid_id new_pkg, :refresh, cnx: @title.cnx 144 end 145 raise Jamf::NoSuchItemError, "No Jamf::Package matches '#{new_pkg}'" unless pkgid 146 147 return if @package_id == pkgid 148 149 @package_id = pkgid 150 @package_name = pkgid == :none ? nil : Jamf::Package.map_all_ids_to(:name, cnx: @title.cnx)[pkgid] 151 @title.changed_pkg_for_version version 152 end
@return [Boolean] Has a package been assigned to this version?
# File lib/jamf/api/classic/api_objects/patch_title/version.rb 80 def package_assigned? 81 package_id != :none 82 end
get the patch report for this version See PatchTitle.patch_report
# File lib/jamf/api/classic/api_objects/patch_title/version.rb 86 def patch_report 87 @title.patch_report version 88 end
Remove the various cached data from the instance_variables used to create pretty-print (pp) output.
@return [Array] the desired instance_variables
# File lib/jamf/api/classic/api_objects/patch_title/version.rb 160 def pretty_print_instance_variables 161 vars = super 162 vars.delete :@title 163 vars 164 end
@return [Integer] How many computers
have this version?
# File lib/jamf/api/classic/api_objects/patch_title/version.rb 94 def total_computers 95 patch_report[:total_computers] 96 end