Module: Jamf::ChangeLog::ClassMethods
- Defined in:
- lib/jamf/api/jamf_pro/mixins/change_log.rb
Overview
Class Methods
Class Method Summary collapse
Instance Method Summary collapse
-
#add_change_log_note(note, id: nil, cnx: Jamf.cnx) ⇒ Jamf::ChangeLogEntry
Add an entry with a note to this object's change log.
-
#change_log(id: nil, sort: nil, filter: nil, cnx: Jamf.cnx) ⇒ Array<Jamf::ChangeLogEntry>
The entire change and note history for this resource.
-
#change_log_pager(page_size: Jamf::Pager::DEFAULT_PAGE_SIZE, id: nil, sort: nil, filter: nil, cnx: Jamf.cnx) ⇒ Jamf::Pager
Return a Jamf::Pager object for retrieving all change log entries in smaller groups.
-
#change_log_size(id: nil, cnx: Jamf.cnx) ⇒ Integer
how many change log entries are there? needed when using paged #change_log calls.
-
#history_path(id = nil) ⇒ String
The path to get or post change logs for this object.
Class Method Details
Instance Method Details
#add_change_log_note(note, id: nil, cnx: Jamf.cnx) ⇒ Jamf::ChangeLogEntry
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.
115 116 117 118 119 120 121 122 123 |
# File 'lib/jamf/api/jamf_pro/mixins/change_log.rb', line 115 def add_change_log_note(note, id: nil, cnx: Jamf.cnx) note_to_send = POST_NOTE_OBJECT.new note: Jamf::Validate.non_empty_string(note) result = cnx.jp_post history_path(id), note_to_send.to_jamf # flush the cached data, forces reload when next accessed, to get new note @cached_change_log = nil HISTORY_ENTRY_OBJECT.new result end |
#change_log(id: nil, sort: nil, filter: nil, cnx: Jamf.cnx) ⇒ Array<Jamf::ChangeLogEntry>
The entire change and note history for this resource
145 146 147 148 149 150 151 152 153 154 155 156 |
# File 'lib/jamf/api/jamf_pro/mixins/change_log.rb', line 145 def change_log(id: nil, sort: nil, filter: nil, cnx: Jamf.cnx) sort &&= Jamf::Sortable.parse_url_sort_param(sort) filter &&= Jamf::Filterable.parse_url_filter_param(filter) Jamf::Pager.all_pages( list_path: history_path(id), sort: sort, filter: filter, instantiate: Jamf::ChangeLogEntry, cnx: cnx ) end |
#change_log_pager(page_size: Jamf::Pager::DEFAULT_PAGE_SIZE, id: nil, sort: nil, filter: nil, cnx: Jamf.cnx) ⇒ Jamf::Pager
Return a Jamf::Pager object for retrieving all change log entries in smaller groups.
For most parameters, see .change_log
170 171 172 173 174 175 176 177 178 179 180 181 182 |
# File 'lib/jamf/api/jamf_pro/mixins/change_log.rb', line 170 def change_log_pager(page_size: Jamf::Pager::DEFAULT_PAGE_SIZE, id: nil, sort: nil, filter: nil, cnx: Jamf.cnx) sort &&= Jamf::Sortable.parse_url_sort_param(sort) filter &&= Jamf::Filterable.parse_url_filter_param(filter) Jamf::Pager.new( page_size: page_size, list_path: history_path(id), sort: sort, filter: filter, instantiate: Jamf::ChangeLogEntry, cnx: cnx ) end |
#change_log_size(id: nil, cnx: Jamf.cnx) ⇒ Integer
how many change log entries are there? needed when using paged #change_log calls
193 194 195 196 197 |
# File 'lib/jamf/api/jamf_pro/mixins/change_log.rb', line 193 def change_log_size(id: nil, cnx: Jamf.cnx) search_path = "#{history_path(id)}?page=0&page-size=1" search_result = SEARCH_RESULTS_OBJECT.new cnx.jp_get(search_path) search_result.totalCount end |
#history_path(id = nil) ⇒ String
Returns The path to get or post change logs for this object.
201 202 203 204 205 206 207 |
# File 'lib/jamf/api/jamf_pro/mixins/change_log.rb', line 201 def history_path(id = nil) if id "#{get_path}/#{id}/#{DFT_HISTORY_PATH}" else "#{get_path}/#{DFT_HISTORY_PATH}" end end |