Method: Jamf::Prestage::ClassMethods#assign

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

#assign(*sns_to_assign, to_prestage:, cnx: Jamf.cnx) ⇒ Jamf::OAPISchemas::PrestageScopeResponseV2

Assign one or more serialNumbers to a prestage

Returns:

Raises:



167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
# File 'lib/jamf/api/jamf_pro/mixins/prestage.rb', line 167

def assign(*sns_to_assign, to_prestage:, cnx: Jamf.cnx)
  prestage_id = valid_id to_prestage
  raise Jamf::NoSuchItemError, "No #{self} matching '#{to_prestage}'" unless prestage_id

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

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

  # add the new sns to the existing ones
  new_scope_sns = scope.assignments.map(&:serialNumber)
  new_scope_sns += sns_to_assign
  new_scope_sns.uniq!

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