Module: Jamf::ComputerRecoveryLock::ClassMethods
- Defined in:
- lib/jamf/api/jamf_pro/mixins/computer_recovery_lock.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
-
#inventory_data(computer, section: 'GENERAL', cnx: Jamf.cnx) ⇒ Jamf::OAPISchemas::ComputerInventory
Get the JPAPI inventory data for a single computer, either by section or all sections.
-
#management_id(computer, cnx: Jamf.cnx) ⇒ String?
Get the MDM ‘managementID’ of a given computer.
-
#recovery_lock_password(computer, cnx: Jamf.cnx) ⇒ String?
Retrieve the recovery lock password for a given computer, if one has been set.
Class Method Details
Instance Method Details
#inventory_data(computer, section: 'GENERAL', cnx: Jamf.cnx) ⇒ Jamf::OAPISchemas::ComputerInventory
Get the JPAPI inventory data for a single computer, either by section or all sections.
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/jamf/api/jamf_pro/mixins/computer_recovery_lock.rb', line 101 def inventory_data(computer, section: 'GENERAL', cnx: Jamf.cnx) # TODO: get this into a constant all = 'ALL' section = section.to_s.upcase id = Jamf::Computer.valid_id computer raise Jamf::NoSuchItemError, "No computer matches identifier '#{computer}'" unless id data = if section == all cnx.jp_get "#{Jamf::Computer::JPAPI_INVENTORY_DETAIL_RSRC}/#{id}" else raise ArgumentError, "Unknown inventory data section '#{section}'" unless Jamf::OAPISchemas::ComputerSection::VALUE_OPTIONS.include?(section) cnx.jp_get("#{Jamf::Computer::JPAPI_INVENTORY_RSRC}?section=#{section}&page=0&page-size=1&filter=id%3D%3D#{id}")[:results].first end Jamf::OAPISchemas::ComputerInventory.new data end |
#management_id(computer, cnx: Jamf.cnx) ⇒ String?
Get the MDM ‘managementID’ of a given computer.
130 131 132 |
# File 'lib/jamf/api/jamf_pro/mixins/computer_recovery_lock.rb', line 130 def management_id(computer, cnx: Jamf.cnx) inventory_data(computer, cnx: cnx).general.managementId end |
#recovery_lock_password(computer, cnx: Jamf.cnx) ⇒ String?
Retrieve the recovery lock password for a given computer, if one has been set.
69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/jamf/api/jamf_pro/mixins/computer_recovery_lock.rb', line 69 def recovery_lock_password(computer, cnx: Jamf.cnx) id = Jamf::Computer.valid_id computer raise Jamf::NoSuchItemError, "No computer matches identifier '#{computer}'" unless id cnx.jp_get("#{Jamf::Computer::JPAPI_INVENTORY_RSRC}/#{id}/#{RECOVERY_LOCK_PW_RSRC_SUFFIX}").dig :recoveryLockPassword # if we get a 404 NOT FOUND error, this given computer has no passwd set, so just return nil rescue Jamf::Connection::JamfProAPIError => e raise unless e.http_status == 404 nil end |