Method: JSS::APIObject.delete
- Defined in:
- lib/jss/api_object.rb
.delete(victims, refresh = true, api: JSS.api) ⇒ Array<Integer>
Delete one or more API objects by jss_id without instantiating them. Non-existent id’s are skipped and an array of skipped ids is returned.
If an Array is provided, it is passed through #uniq! before being processed.
1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 |
# File 'lib/jss/api_object.rb', line 1017 def self.delete(victims, refresh = true, api: JSS.api) (self) raise JSS::InvalidDataError, 'Parameter must be an Integer ID or an Array of them' unless victims.is_a?(Integer) || victims.is_a?(Array) case victims when Integer victims = [victims] when Array victims.uniq! end skipped = [] current_ids = all_ids refresh, api: api victims.each do |vid| if current_ids.include? vid api.delete_rsrc "#{self::RSRC_BASE}/id/#{vid}" else skipped << vid end # if current_ids include vid end # each victim # clear any cached all-lists or id-maps for this class # so they'll re-cache as needed api.flushcache self::RSRC_LIST_KEY # all :refresh, api: api skipped end |