Class: JSS::PatchTitle::Version
- Defined in:
- lib/jss/api_object/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 JSS::Package, if any, and can report the names and ids of the computers that have it installed.
To set or change the JSS::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 JSS::Package that installs this PatchVersion, if defined.
-
#package_name ⇒ String
readonly
The name of the JSS::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 JSS::PatchTitle that contains this version.
-
#package=(new_pkg) ⇒ Object
Assign a new JSS::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 JSS::PatchTitle that contains this version.
67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/jss/api_object/patch_title/version.rb', line 67 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 JSS::Package that installs this PatchVersion, if defined.
58 59 60 |
# File 'lib/jss/api_object/patch_title/version.rb', line 58 def package_id @package_id end |
#package_name ⇒ String (readonly)
Returns the name of the JSS::Package that installs this PatchVersion, if defined.
62 63 64 |
# File 'lib/jss/api_object/patch_title/version.rb', line 62 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.
54 55 56 |
# File 'lib/jss/api_object/patch_title/version.rb', line 54 def version @version end |
Instance Method Details
#computer_ids ⇒ Array<Integer>
Returns The ids of #computers.
107 108 109 |
# File 'lib/jss/api_object/patch_title/version.rb', line 107 def computer_ids computers.map { |c| c[:id] } end |
#computer_names ⇒ Array<Integer>
Returns The names of #computers.
113 114 115 |
# File 'lib/jss/api_object/patch_title/version.rb', line 113 def computer_names computers.map { |c| c[:name] } end |
#computer_serial_numbers ⇒ Array<Integer>
Returns The serial_numbers of #computers.
119 120 121 |
# File 'lib/jss/api_object/patch_title/version.rb', line 119 def computer_serial_numbers computers.map { |c| c[:serial_number] } end |
#computer_udids ⇒ Array<Integer>
Returns The udids of #computers.
125 126 127 |
# File 'lib/jss/api_object/patch_title/version.rb', line 125 def computer_udids computers.map { |c| c[:udid] } end |
#computers ⇒ Array<Hash>
Returns A hash of identifiers for each computer with this version installed.
101 102 103 |
# File 'lib/jss/api_object/patch_title/version.rb', line 101 def computers patch_report[:versions][version] end |
#package=(new_pkg) ⇒ Object
Assign a new JSS::Package to this PatchTitle::Version. The Package must exist in the JSS. Be sure to call #update on the PatchTitle containing this Version.
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
# File 'lib/jss/api_object/patch_title/version.rb', line 137 def package=(new_pkg) raise JSS::UnsupportedError, "Packages can't be assigned to the Unkown version." if version == JSS::PatchTitle::UNKNOWN_VERSION_ID pkgid = if new_pkg == :none :none else JSS::Package.valid_id new_pkg, :refresh, api: @title.api end raise JSS::NoSuchItemError, "No JSS::Package matches '#{new_pkg}'" unless pkgid return if @package_id == pkgid @package_id = pkgid @package_name = pkgid == :none ? nil : JSS::Package.map_all_ids_to(:name)[pkgid] @title.changed_pkg_for_version version end |
#package_assigned? ⇒ Boolean
Returns Has a package been assigned to this version?.
81 82 83 |
# File 'lib/jss/api_object/patch_title/version.rb', line 81 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
87 88 89 |
# File 'lib/jss/api_object/patch_title/version.rb', line 87 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.
161 162 163 164 165 |
# File 'lib/jss/api_object/patch_title/version.rb', line 161 def pretty_print_instance_variables vars = super vars.delete :@title vars end |
#total_computers ⇒ Integer
Returns How many #computers have this version?.
95 96 97 |
# File 'lib/jss/api_object/patch_title/version.rb', line 95 def total_computers patch_report[:total_computers] end |