Module: Jamf::BulkDeletable

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

Overview

This mixin implements the …/delete-multiple endpoints that some collection resources have (and eventually all will??) It should be extended into classes representing those resources

Constant Summary collapse

DELETE_MULTIPLE_ENDPOINT =
'delete-multiple'.freeze

Instance Method Summary collapse

Instance Method Details

#bulk_delete(ids, cnx: Jamf.cnx) ⇒ Array<Jamf::Connection::JamfProAPIError::ErrorInfo] Info about any ids that failed to be deleted.

Delete multiple objects by providing an array of their

TODO: fix this return value, no more ErrorInfo

Parameters:

  • ids (Array<String,Integer>)

    The ids to delete

  • cnx (Jamf::Connection) (defaults to: Jamf.cnx)

    The connection to use, default: Jamf.cnx

Returns:

  • (Array<Jamf::Connection::JamfProAPIError::ErrorInfo] Info about any ids that failed to be deleted.)

    Array<Jamf::Connection::JamfProAPIError::ErrorInfo] Info about any ids that failed to be deleted.



45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/jamf/api/jamf_pro/mixins/bulk_deletable.rb', line 45

def bulk_delete(ids, cnx: Jamf.cnx)
  ids = [ids] unless ids.is_a? Array
  request_body = { ids: ids.map(&:to_s) }

  begin
    cnx.post "#{rsrc_path}/#{DELETE_MULTIPLE_ENDPOINT}", request_body
    []
  rescue Jamf::Connection::JamfProAPIError => e
    raise e unless e.httpStatus == 400

    e.errors
  end
end