class Jamf::InventoryPreloadRecord
An Inventory Preload record for a Computer
or Mobile Device in Jamf
.
Since the JPAPI offers access to these records via JSON as well as CSV uploads, we are implementing JSON access, to stay in line with the rest of how ruby-jss works, and keep things simple.
If you want to use a CSV as your data source, you should use a ruby CSV library, such as the one built in to ruby, and loop thru your CSV records, creating or fetching instances of this class as needed, manipulating them, and saving them.
Constants
- ALT_IDENTIFIERS
Identifiers not marked in the superclass’s OAPI_PROPERTIES constant which usually only identifies ‘:id’
- DEVICE_TYPE_COMPUTER
- DEVICE_TYPE_MOBILE_DEV
- DEVICE_TYPE_UNKNOWN
- FILTER_KEYS
Must define this when extending
Filterable
- LIST_PATH
The path for GETting the list of all objects in the collection, possibly filtered, sorted, and/or paged REQUIRED for all collection resources
GET_PATH, POST_PATH, PUT_PATH, PATCH_PATH, and DELETE_PATH are automatically assumed from the
LIST_PATH
if they follow the standards:-
GET_PATH = “#{LIST_PATH}/id”
-
fetch an object from the collection
-
-
POST_PATH =
LIST_PATH
-
create a new object in the collection
-
-
PUT_PATH = “#{LIST_PATH}/id”
-
update an object passing all its values back. Most objects use this or PATCH but not both
-
-
PATCH_PATH = “#{LIST_PATH}/id”
-
update an object passing some of its values back Most objects use this or PUT but not both
-
-
DELETE_PATH = “#{LIST_PATH}/id”
-
delete an object from the collection
-
If those paths differ from the standards, the constants must be defined here
-
- POST_OBJECT
The OAPI object class we send with a POST request to make a new member of the collection in
Jamf
. This is usually the same as the parent class.- PUT_OBJECT
The OAPI object class we send with a PUT request to change an object in
Jamf
by specifying all its values. Most updates happen this way, and this is usually the same as the parent class- SEARCH_RESULT_OBJECT
The OAPI object class we get back from a ‘list’ query to get the whole collection, or a subset of it. It contains a :results key which is an array of data for objects of the parent class.
Public Class Methods
InvPreload Recs have a non-standard /history path
# File lib/jamf/api/jamf_pro/api_objects/inventory_preload_record.rb 120 def self.history_path(_id) 121 'v2/inventory-preload/history' 122 end
Public Instance Methods
clear all values for this record except id, serialNumber, and deviceType
# File lib/jamf/api/jamf_pro/api_objects/inventory_preload_record.rb 152 def clear 153 OAPI_PROPERTIES.each do |attr_name, attr_def| 154 next unless attr_def[:nil_ok] 155 156 if attr_name == :extensionAttributes 157 self.extensionAttributes = [] 158 next 159 end 160 send "#{attr}=", nil 161 end 162 end
a Hash
of ea name => ea_value for all eas currently set.
# File lib/jamf/api/jamf_pro/api_objects/inventory_preload_record.rb 145 def ext_attrs 146 eas = {} 147 extensionAttributes.each { |ea| eas[ea.name] = ea.value } 148 eas 149 end
InvPreload Recs have a non-standard /history path
# File lib/jamf/api/jamf_pro/api_objects/inventory_preload_record.rb 165 def history_path(_id) 166 raise Jamf::UnsupportedError, 'InventoryPreloadRecords do not have individual change logs. Use Jamf::InventoryPreloadRecord.change_log' 167 end
remove an EA totally (vs setting its value to nil)
# File lib/jamf/api/jamf_pro/api_objects/inventory_preload_record.rb 139 def remove_ext_attr(ea_name) 140 idx = extensionAttributes.index { |ea| ea.name == ea_name } 141 extensionAttributes_delete_at idx if idx 142 end
@param ea_name The name of the EA being set
@param new_val[String, Integer, Jamf::Timestamp
, Time] The value being set
@return [void]
# File lib/jamf/api/jamf_pro/api_objects/inventory_preload_record.rb 130 def set_ext_attr(ea_name, new_val) 131 remove_ext_attr(ea_name) 132 extensionAttributes_append( 133 Jamf::OAPISchemas::InventoryPreloadExtensionAttribute.new(name: ea_name, value: new_val) 134 ) 135 new_val 136 end