Skip to content

2023 demo J Deleting Things

Chris Lasell edited this page Aug 24, 2023 · 1 revision

Hands On, Real-time Jamf APIs Using ruby-jss

Deleting Things

Previous           TOC           Next


  • Let's now delete the 5 computers we created for the demo

  • There are two ways to delete API objects in ruby-jss

  1. If you already have a fetched instance of the object, you can just call its delete method
    • Lets delete the computer we just fetched a moment ago:
comp_to_check.delete
# => nil
  1. If you haven't fetched the thing yet, you can use the delete method on the class itself
    • It takes an array of ids, which we happen to have already in group.member_ids
  • This is faster if you haven't fetched, because fetching an object can be slow
Jamf::Computer.delete my_grp.member_ids
# => [568]
  • This method returns another array of the ids that it did not delete, because they didn't exist

  • In this case, that's the id of the individual one we deleted above

  • To confirm they are gone, look for them by name again, and we should get an empty array

pp Jamf::Computer.all_names(:refresh).select { |name| name.start_with? comp_base_name } ;0
# []
# => 0

Previous           TOC           Next

Clone this wiki locally