module Jamf::ComputerRecoveryLock::ClassMethods
Class Methods
Public Class Methods
when this module is included, also extend our Class Methods
# File lib/jamf/api/jamf_pro/mixins/computer_recovery_lock.rb 56 def self.extended(extender) 57 Jamf.load_msg "--> #{extender} is extending #{self}" 58 end
Public Instance Methods
Get the JPAPI inventory data for a single computer, either by section or all sections.
@param computer [Symbol, String
, Integer, Array
<String, Integer>] Identifier for the desired
Computer
@param section [String] One of the data sections listed in Jamf::OAPISchemas::ComputerSection::VALUE_OPTIONS
or 'all'. Default is 'GENERAL'
@param cnx [Jamf::Connection] The API connection to use. Defaults to Jamf.cnx
@return [Jamf::OAPISchemas::ComputerInventory] The inventory data, with the requested sections populated
# File lib/jamf/api/jamf_pro/mixins/computer_recovery_lock.rb 101 def inventory_data(computer, section: 'GENERAL', cnx: Jamf.cnx) 102 # TODO: get this into a constant 103 all = 'ALL' 104 105 section = section.to_s.upcase 106 id = Jamf::Computer.valid_id computer 107 raise Jamf::NoSuchItemError, "No computer matches identifier '#{computer}'" unless id 108 109 data = 110 if section == all 111 cnx.jp_get "#{Jamf::Computer::JPAPI_INVENTORY_DETAIL_RSRC}/#{id}" 112 else 113 raise ArgumentError, "Unknown inventory data section '#{section}'" unless Jamf::OAPISchemas::ComputerSection::VALUE_OPTIONS.include?(section) 114 115 cnx.jp_get("#{Jamf::Computer::JPAPI_INVENTORY_RSRC}?section=#{section}&page=0&page-size=1&filter=id%3D%3D#{id}")[:results].first 116 end 117 118 Jamf::OAPISchemas::ComputerInventory.new data 119 end
Get the MDM
‘managementID’ of a given computer.
@param computer [Symbol, String
, Integer, Array
<String, Integer>] Identifier for the desired
Computer
@param cnx [Jamf::Connection] The API connection to use. Defaults to Jamf.cnx
@return [String, nil] The managementID or nil if not available
# File lib/jamf/api/jamf_pro/mixins/computer_recovery_lock.rb 130 def management_id(computer, cnx: Jamf.cnx) 131 inventory_data(computer, cnx: cnx).general.managementId 132 end
Retrieve the recovery lock password for a given computer, if one has been set.
@param computer [Symbol, String
, Integer, Array
<String, Integer>] Identifier for the desired
Computer
@param cnx [Jamf::Connection] The API connection to use. Defaults to Jamf.cnx
@return [String, nil] The recovery lock password, or nil if none has been set.
# File lib/jamf/api/jamf_pro/mixins/computer_recovery_lock.rb 69 def recovery_lock_password(computer, cnx: Jamf.cnx) 70 id = Jamf::Computer.valid_id computer 71 raise Jamf::NoSuchItemError, "No computer matches identifier '#{computer}'" unless id 72 73 cnx.jp_get("#{Jamf::Computer::JPAPI_INVENTORY_RSRC}/#{id}/#{RECOVERY_LOCK_PW_RSRC_SUFFIX}").dig :recoveryLockPassword 74 75 # if we get a 404 NOT FOUND error, this given computer has no passwd set, so just return nil 76 rescue Jamf::Connection::JamfProAPIError => e 77 raise unless e.http_status == 404 78 79 nil 80 end