module Jamf::ChangeLog::ClassMethods

Class Methods

Public Class Methods

extended(extender) click to toggle source
    # File lib/jamf/api/jamf_pro/mixins/change_log.rb
102 def self.extended(extender)
103   Jamf.load_msg "--> #{extender} is extending Jamf::ChangeLog::ClassMethods"
104 end

Public Instance Methods

add_change_log_note(note, id: nil, cnx: Jamf.cnx) click to toggle source

Add an entry with a note to this object’s change log.

If the change history has been cached already, the cache is flushed after adding the note.

@param note The note to add. It cannot be empty.

@return [Jamf::ChangeLogEntry] the new entry

    # File lib/jamf/api/jamf_pro/mixins/change_log.rb
115 def add_change_log_note(note, id: nil, cnx: Jamf.cnx)
116   note_to_send = POST_NOTE_OBJECT.new note: Jamf::Validate.non_empty_string(note)
117 
118   result = cnx.jp_post history_path(id), note_to_send.to_jamf
119 
120   # flush the cached data, forces reload when next accessed, to get new note
121   @cached_change_log = nil
122   HISTORY_ENTRY_OBJECT.new result
123 end
change_log(id: nil, sort: nil, filter: nil, cnx: Jamf.cnx) click to toggle source

The entire change and note history for this resource

@param id [String, Integer] For Collection Items that have a change log

This is the id of the  item. Omit this param for singletons, or
collections which have a single change log.

@param sort [String, Array<String>] Server-side sorting criteria in the format:

property:direction, where direction is 'asc' or 'desc'. Multiple
properties are supported, either as separate strings in an Array, or
a single string, comma separated.

@param filter [String] An RSQL filter string. Not all change_log resources

currently support filters, and if they don't, this will be ignored.

@param cnx [Jamf::Connection] The API connection to use, default: Jamf.cnx.

If this is an instance of a Collection Resource, this is always
the connection from which it was fetched.

@return [Array<Jamf::ChangeLogEntry>] The change log entries requested

    # File lib/jamf/api/jamf_pro/mixins/change_log.rb
145 def change_log(id: nil, sort: nil, filter: nil, cnx: Jamf.cnx)
146   sort &&= Jamf::Sortable.parse_url_sort_param(sort)
147   filter &&= Jamf::Filterable.parse_url_filter_param(filter)
148 
149   Jamf::Pager.all_pages(
150     list_path: history_path(id),
151     sort: sort,
152     filter: filter,
153     instantiate: Jamf::ChangeLogEntry,
154     cnx: cnx
155   )
156 end
change_log_pager(page_size: Jamf::Pager::DEFAULT_PAGE_SIZE, id: nil, sort: nil, filter: nil, cnx: Jamf.cnx) click to toggle source

Return a Jamf::Pager object for retrieving all change log entries in smaller groups.

For most parameters, see .change_log

@param page_size [Integer] The pager object returns results in groups of

this many entries. Minimum is 1, maximum is 2000, default is 100
Note: the final page of data may contain fewer items than the page_size

@return [Jamf::Pager] An object from which you can retrieve sequential or

arbitrary pages from the collection.
    # File lib/jamf/api/jamf_pro/mixins/change_log.rb
170 def change_log_pager(page_size: Jamf::Pager::DEFAULT_PAGE_SIZE, id: nil, sort: nil, filter: nil, cnx: Jamf.cnx)
171   sort &&= Jamf::Sortable.parse_url_sort_param(sort)
172   filter &&= Jamf::Filterable.parse_url_filter_param(filter)
173 
174   Jamf::Pager.new(
175     page_size: page_size,
176     list_path: history_path(id),
177     sort: sort,
178     filter: filter,
179     instantiate: Jamf::ChangeLogEntry,
180     cnx: cnx
181   )
182 end
change_log_size(id: nil, cnx: Jamf.cnx) click to toggle source

how many change log entries are there? needed when using paged change_log calls

@param cnx [Jamf::Connection] The API connection to use, default: Jamf.cnx

This is ignored for instances of Collection Resources, which always use
the same connection from which they were fetched.

@return [Integer] How many changelog entries exist?

    # File lib/jamf/api/jamf_pro/mixins/change_log.rb
193 def change_log_size(id: nil, cnx: Jamf.cnx)
194   search_path = "#{history_path(id)}?page=0&page-size=1"
195   search_result = SEARCH_RESULTS_OBJECT.new cnx.jp_get(search_path)
196   search_result.totalCount
197 end
history_path(id = nil) click to toggle source

@return [String] The path to get or post change logs for this object

    # File lib/jamf/api/jamf_pro/mixins/change_log.rb
201 def history_path(id = nil)
202   if id
203     "#{get_path}/#{id}/#{DFT_HISTORY_PATH}"
204   else
205     "#{get_path}/#{DFT_HISTORY_PATH}"
206   end
207 end