Class: Jamf::InventoryPreloadRecord
- Inherits:
-
CollectionResource
- Object
- JSONObject
- Resource
- CollectionResource
- Jamf::InventoryPreloadRecord
- Extended by:
- ChangeLog
- Defined in:
- lib/jamf/api/resources/collection_resources/inventory_preload_record.rb
Overview
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.
Constant Summary collapse
- RSRC_VERSION =
Constants
'v1'.freeze
- RSRC_PATH =
'inventory-preload'.freeze
- DEVICE_TYPE_COMPUTER =
'Computer'.freeze
- DEVICE_TYPE_MOBILE_DEV =
'Mobile Device'.freeze
- DEVICE_TYPE_UNKNOWN =
'Unknown'.freeze
- DEVICE_TYPES =
[ DEVICE_TYPE_COMPUTER, DEVICE_TYPE_MOBILE_DEV, DEVICE_TYPE_UNKNOWN ].freeze
- UNCLEARABLE_ATTRS =
The ‘clear’ instance method won’t change these attrs
%i[id serialNumber deviceType].freeze
- OBJECT_MODEL =
Object Model / Attributes See APIObject class documentation for details of how the OBJECT_MODEL hash works.
{ # @!attribute [r] id # @return [Integer] id: { class: :integer, identifier: :primary, readonly: true }, # @!attribute serialNumber # @return [String] serialNumber: { class: :string, identifier: true, validator: :non_empty_string, required: true }, # @!attribute deviceType # @return [String] deviceType: { class: :string, enum: Jamf::InventoryPreloadRecord::DEVICE_TYPES, required: true }, # @!attribute username # @return [String] username: { class: :string }, # @!attribute fullName # @return [String] fullName: { class: :string }, # @!attribute emailAddress # @return [String] emailAddress: { class: :string }, # @!attribute phoneNumber # @return [String] phoneNumber: { class: :string }, # @!attribute position # @return [String] position: { class: :string }, # @!attribute department # @return [String] department: { class: :string }, # @!attribute building # @return [String] building: { class: :string }, # @!attribute room # @return [String] room: { class: :string }, # @!attribute poNumber # @return [String] poNumber: { class: :string }, # @!attribute poDate # @return [String] poDate: { class: :string }, # @!attribute warrantyExpiration # @return [String] warrantyExpiration: { class: :string }, # @!attribute appleCareId # @return [String] appleCareId: { class: :string }, # @!attribute lifeExpectancy # @return [String] lifeExpectancy: { class: :string }, # @!attribute purchasePrice # @return [String] purchasePrice: { class: :string }, # @!attribute purchasingContact # @return [String] purchasingContact: { class: :string }, # @!attribute purchasingAccount # @return [String] purchasingAccount: { class: :string }, # @!attribute leaseExpiration # @return [String] leaseExpiration: { class: :string }, # @!attribute barCode1 # @return [String] barCode1: { class: :string }, # @!attribute barCode2 # @return [String] barCode2: { class: :string }, # @!attribute assetTag # @return [String] assetTag: { class: :string }, # @!attribute extensionAttributes # @return [Jamf::InventoryPreloadExtensionAttribute] extensionAttributes: { class: Jamf::InventoryPreloadExtensionAttribute, multi: true, aliases: %i[eas] } }.freeze
Instance Attribute Summary collapse
- #appleCareId ⇒ String
- #assetTag ⇒ String
- #barCode1 ⇒ String
- #barCode2 ⇒ String
- #building ⇒ String
- #department ⇒ String
- #deviceType ⇒ String
- #emailAddress ⇒ String
- #extensionAttributes ⇒ Jamf::InventoryPreloadExtensionAttribute
- #fullName ⇒ String
- #id ⇒ Integer readonly
- #leaseExpiration ⇒ String
- #lifeExpectancy ⇒ String
- #phoneNumber ⇒ String
- #poDate ⇒ String
- #poNumber ⇒ String
- #position ⇒ String
- #purchasePrice ⇒ String
- #purchasingAccount ⇒ String
- #purchasingContact ⇒ String
- #room ⇒ String
- #serialNumber ⇒ String
- #username ⇒ String
- #warrantyExpiration ⇒ String
Class Method Summary collapse
-
.add_change_log_note(note, cnx: Jamf.cnx) ⇒ void
extended
from ChangeLog
Add a note to this resource’s change log.
-
.change_log(refresh = false, cnx: Jamf.cnx) ⇒ Array<Jamf::ChangeHistoryEntry>
extended
from ChangeLog
The change and note history for this resource.
Instance Method Summary collapse
-
#clear ⇒ Object
clear all values for this record except id, serialNumber, and deviceType.
-
#ext_attrs ⇒ Object
a Hash of ea name => ea_value for all eas currently set.
-
#remove_ext_attr(ea_name) ⇒ Object
remove an EA value.
-
#set_ext_attr(ea_name, new_val) ⇒ void
TODO: validation for ea’s existance and value data type, once EAs are implemented in JPAPI (see inventory_preload_extension_attribute.rb).
Constructor Details
This class inherits a constructor from Jamf::JSONObject
Instance Attribute Details
#appleCareId ⇒ String
|
|
# File 'lib/jamf/api/resources/collection_resources/inventory_preload_record.rb', line 168
|
#assetTag ⇒ String
|
|
# File 'lib/jamf/api/resources/collection_resources/inventory_preload_record.rb', line 216
|
#barCode1 ⇒ String
|
|
# File 'lib/jamf/api/resources/collection_resources/inventory_preload_record.rb', line 204
|
#barCode2 ⇒ String
|
|
# File 'lib/jamf/api/resources/collection_resources/inventory_preload_record.rb', line 210
|
#building ⇒ String
|
|
# File 'lib/jamf/api/resources/collection_resources/inventory_preload_record.rb', line 138
|
#department ⇒ String
|
|
# File 'lib/jamf/api/resources/collection_resources/inventory_preload_record.rb', line 132
|
#deviceType ⇒ String
|
|
# File 'lib/jamf/api/resources/collection_resources/inventory_preload_record.rb', line 94
|
#emailAddress ⇒ String
|
|
# File 'lib/jamf/api/resources/collection_resources/inventory_preload_record.rb', line 114
|
#extensionAttributes ⇒ Jamf::InventoryPreloadExtensionAttribute
|
|
# File 'lib/jamf/api/resources/collection_resources/inventory_preload_record.rb', line 222
|
#fullName ⇒ String
|
|
# File 'lib/jamf/api/resources/collection_resources/inventory_preload_record.rb', line 108
|
#id ⇒ Integer (readonly)
|
|
# File 'lib/jamf/api/resources/collection_resources/inventory_preload_record.rb', line 77
|
#leaseExpiration ⇒ String
|
|
# File 'lib/jamf/api/resources/collection_resources/inventory_preload_record.rb', line 198
|
#lifeExpectancy ⇒ String
|
|
# File 'lib/jamf/api/resources/collection_resources/inventory_preload_record.rb', line 174
|
#phoneNumber ⇒ String
|
|
# File 'lib/jamf/api/resources/collection_resources/inventory_preload_record.rb', line 120
|
#poDate ⇒ String
|
|
# File 'lib/jamf/api/resources/collection_resources/inventory_preload_record.rb', line 156
|
#poNumber ⇒ String
|
|
# File 'lib/jamf/api/resources/collection_resources/inventory_preload_record.rb', line 150
|
#position ⇒ String
|
|
# File 'lib/jamf/api/resources/collection_resources/inventory_preload_record.rb', line 126
|
#purchasePrice ⇒ String
|
|
# File 'lib/jamf/api/resources/collection_resources/inventory_preload_record.rb', line 180
|
#purchasingAccount ⇒ String
|
|
# File 'lib/jamf/api/resources/collection_resources/inventory_preload_record.rb', line 192
|
#purchasingContact ⇒ String
|
|
# File 'lib/jamf/api/resources/collection_resources/inventory_preload_record.rb', line 186
|
#room ⇒ String
|
|
# File 'lib/jamf/api/resources/collection_resources/inventory_preload_record.rb', line 144
|
#serialNumber ⇒ String
|
|
# File 'lib/jamf/api/resources/collection_resources/inventory_preload_record.rb', line 85
|
#username ⇒ String
|
|
# File 'lib/jamf/api/resources/collection_resources/inventory_preload_record.rb', line 102
|
#warrantyExpiration ⇒ String
|
|
# File 'lib/jamf/api/resources/collection_resources/inventory_preload_record.rb', line 162
|
Class Method Details
.add_change_log_note(note, cnx: Jamf.cnx) ⇒ void Originally defined in module ChangeLog
This method returns an undefined value.
Add a note to this resource’s change log.
If the change history has been cached already, it is recached after adding the note.
Instance Method Details
#clear ⇒ Object
clear all values for this record except id, serialNumber, and deviceType
262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 |
# File 'lib/jamf/api/resources/collection_resources/inventory_preload_record.rb', line 262 def clear OBJECT_MODEL.keys.each do |attr| next if UNCLEARABLE_ATTRS.include? attr if attr == :extensionAttributes extensionAttributes = [] next end # skip nils curr_val = send attr next unless curr_val send "#{attr}=", nil end end |
#ext_attrs ⇒ Object
a Hash of ea name => ea_value for all eas currently set.
255 256 257 258 259 |
# File 'lib/jamf/api/resources/collection_resources/inventory_preload_record.rb', line 255 def ext_attrs eas = {} extensionAttributes.each { |ea| eas[ea.name] = ea.value } eas end |
#remove_ext_attr(ea_name) ⇒ Object
remove an EA value
249 250 251 252 |
# File 'lib/jamf/api/resources/collection_resources/inventory_preload_record.rb', line 249 def remove_ext_attr(ea_name) idx = extensionAttributes.index { |ea| ea.name == ea_name } extensionAttributes_delete_at idx if idx end |
#set_ext_attr(ea_name, new_val) ⇒ void
This method returns an undefined value.
TODO: validation for ea’s existance and value data type, once EAs are implemented in JPAPI (see inventory_preload_extension_attribute.rb)
243 244 245 246 |
# File 'lib/jamf/api/resources/collection_resources/inventory_preload_record.rb', line 243 def set_ext_attr(ea_name, new_val) remove_ext_attr(ea_name) extensionAttributes_append Jamf::InventoryPreloadExtensionAttribute.new(name: ea_name, value: new_val) end |