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:



182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
# File 'lib/jamf/api/jamf_pro/mixins/prestage.rb', line 182

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