Method: Jamf::Prestage::ClassMethods#unassign

Defined in:
lib/jamf/api/jamf_pro/mixins/prestage.rb

#unassign(*sns_to_unassign, from_prestage:, cnx: Jamf.cnx) ⇒ Jamf::PrestageScope

Unassign one or more serialNumber from a prestage

Returns:

  • (Jamf::PrestageScope)

    the new scope for the prestage

Raises:



204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
# File 'lib/jamf/api/jamf_pro/mixins/prestage.rb', line 204

def unassign(*sns_to_unassign, from_prestage:, cnx: Jamf.cnx)
  prestage_id = valid_id from_prestage
  raise Jamf::NoSuchItemError, "No #{self} matching '#{from_prestage}'" unless prestage_id

  # upcase all sns
  sns_to_unassign.map!(&:to_s)
  sns_to_unassign.map!(&:upcase)

  # get the current scope of the prestage
  spath = scope_path(prestage_id)
  scope = INSTANCE_SCOPE_OBJECT.new cnx.get(spath)

  new_scope_sns = scope.assignments.map(&:serialNumber)
  new_scope_sns -= sns_to_unassign

  update_scope(spath, new_scope_sns, scope.versionLock, cnx)
end