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
.extended(extender) ⇒ Object
84 85 86 |
# File 'lib/jamf/api/jamf_pro/mixins/change_log.rb', line 84 def self.extended(extender) Jamf.load_msg "--> #{extender} is extending Jamf::ChangeLog::ClassMethods" end |
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.
97 98 99 100 101 102 103 104 105 |
# File 'lib/jamf/api/jamf_pro/mixins/change_log.rb', line 97 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
127 128 129 130 131 132 133 134 135 136 137 138 |
# File 'lib/jamf/api/jamf_pro/mixins/change_log.rb', line 127 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
152 153 154 155 156 157 158 159 160 161 162 163 164 |
# File 'lib/jamf/api/jamf_pro/mixins/change_log.rb', line 152 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
175 176 177 178 179 |
# File 'lib/jamf/api/jamf_pro/mixins/change_log.rb', line 175 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.
183 184 185 186 187 188 189 |
# File 'lib/jamf/api/jamf_pro/mixins/change_log.rb', line 183 def history_path(id = nil) if id "#{get_path}/#{id}/#{DFT_HISTORY_PATH}" else "#{get_path}/#{DFT_HISTORY_PATH}" end end |