Module: Jamf::MacOSManagedUpdates::ClassMethods
- Defined in:
- lib/jamf/api/jamf_pro/mixins/macos_managed_updates.rb
Overview
Class Methods
Class Method Summary collapse
-
.extended(extender) ⇒ Object
when this module is included, also extend our Class Methods.
Instance Method Summary collapse
-
#available_os_updates(cnx: Jamf.cnx) ⇒ Array<String>
get the list of available OS versions.
-
#send_managed_os_update(updateAction:, deviceIds: nil, groupId: nil, maxDeferrals: nil, version: nil, skipVersionVerification: false, applyMajorUpdate: false, forceRestart: false, cnx: Jamf.cnx) ⇒ Jamf::OAPISchemas::MacOsManagedSoftwareUpdateResponse
Send the os update command to target Computers or a ComputerGroup.
Class Method Details
Instance Method Details
#available_os_updates(cnx: Jamf.cnx) ⇒ Array<String>
get the list of available OS versions
69 70 71 72 |
# File 'lib/jamf/api/jamf_pro/mixins/macos_managed_updates.rb', line 69 def available_os_updates(cnx: Jamf.cnx) data = cnx.jp_get(MANAGED_SW_UPDATES_AVAILABLE_VERSIONS_RSRC) Jamf::OAPISchemas::AvailableUpdates.new(data).availableUpdates end |
#send_managed_os_update(updateAction:, deviceIds: nil, groupId: nil, maxDeferrals: nil, version: nil, skipVersionVerification: false, applyMajorUpdate: false, forceRestart: false, cnx: Jamf.cnx) ⇒ Jamf::OAPISchemas::MacOsManagedSoftwareUpdateResponse
Send the os update command to target Computers or a ComputerGroup
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
# File 'lib/jamf/api/jamf_pro/mixins/macos_managed_updates.rb', line 111 def send_managed_os_update(updateAction:, deviceIds: nil, groupId: nil, maxDeferrals: nil, version: nil, skipVersionVerification: false, applyMajorUpdate: false, forceRestart: false, cnx: Jamf.cnx) if self == Jamf::Computer raise ArgumentError, 'Must provide one or more deviceIds' unless deviceIds elsif self == Jamf::ComputerGroup raise ArgumentError, 'Must provide a groupId' unless groupId else raise Jamf::UnsupportedError, 'This method is only available for Jamf::Computer and Jamf::ComputerGroup' end if version available_versions = available_os_updates raise ArgumentError, "Invalid version, must be one of: #{available_versions.join ', '}" unless available_versions.include? version end if deviceIds deviceIds = [deviceIds] unless deviceIds.is_a?(Array) deviceIds.map! { |id| valid_id id } end groupId = valid_id groupId if groupId data = {} # ids in the JPAPI are string containing integers data[:deviceIds] = deviceIds.map(&:to_s) if deviceIds data[:groupId] = groupId.to_s if groupId data[:maxDeferrals] = maxDeferrals if maxDeferrals data[:version] = version if version data[:skipVersionVerification] = skipVersionVerification if skipVersionVerification data[:applyMajorUpdate] = applyMajorUpdate if applyMajorUpdate data[:updateAction] = updateAction if updateAction data[:forceRestart] = forceRestart if forceRestart payload = Jamf::OAPISchemas::MacOsManagedSoftwareUpdate.new(data).to_json result = cnx.jp_post MANAGED_SW_UPDATES_SEND_UPDATES_RSRC, payload Jamf::OAPISchemas::MacOsManagedSoftwareUpdateResponse.new result end |