Method: Jamf::Prestage::ClassMethods#assigned?
- Defined in:
- lib/jamf/api/jamf_pro/mixins/prestage.rb
#assigned?(sn, prestage: nil, cnx: Jamf.cnx) ⇒ Boolean
Is the given serialNumber assigned to any prestage, or to the given prestage if a prestage is specified?
This uses .serials_by_prestage_id, the class-level scope path which gets a hash of all assigned SNS => the id of the prestage they are assigned to. The instance#assigned? method uses a different path which returnds more data in an OAPI object.
NOTE: If a serial number isn’t assigned to any prestage, it may really be unassigned or it may not exist in your ADE. To see if a SN exists in one of your Device Enrollment instances, use Jamf::DeviceEnrollment.include?
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 |
# File 'lib/jamf/api/jamf_pro/mixins/prestage.rb', line 149 def assigned?(sn, prestage: nil, cnx: Jamf.cnx) assigned_id = assigned_prestage_id(sn, cnx: cnx) # it isn't assigned at all return false unless assigned_id # we are looking to see if its assigned at all, which it is return true unless prestage # we are looking to see if its in a specific prestage psid = valid_id prestage, cnx: cnx raise Jamf::NoSuchItemError, "No #{self} matching '#{prestage}'" unless psid psid == assigned_id end |