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
.extended(extender) ⇒ Object
when this module is included, also extend our Class Methods
52 53 54 |
# File 'lib/jamf/api/jamf_pro/mixins/macos_managed_updates.rb', line 52 def self.extended(extender) Jamf.load_msg "--> #{extender} is extending #{self}" end |
Instance Method Details
#available_os_updates(cnx: Jamf.cnx) ⇒ Array<String>
get the list of available OS versions
60 61 62 63 |
# File 'lib/jamf/api/jamf_pro/mixins/macos_managed_updates.rb', line 60 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
101 102 103 104 105 106 107 108 109 110 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 |
# File 'lib/jamf/api/jamf_pro/mixins/macos_managed_updates.rb', line 101 def send_managed_os_update(updateAction:, deviceIds: nil, groupId: nil, maxDeferrals: nil, version: nil, skipVersionVerification: false, applyMajorUpdate: false, forceRestart: false, cnx: Jamf.cnx) action_to_send = UPDATE_ACTIONS.value?(updateAction) ? updateAction : UPDATE_ACTIONS[updateAction] raise ArgumentError, "Unknown updateAction, must be one of: #{UPDATE_ACTIONS.keys.join ', '}" unless action_to_send 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, cnx: cnx } end groupId = valid_id(groupId, cnx: cnx) 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] = action_to_send 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 |