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
'v2'.freeze
- RSRC_PATH =
'inventory-preload/records'.freeze
- CHANGE_LOG_RSRC =
"#{RSRC_VERSION}/inventory-preload/history".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: :j_id, 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 vendor # @return [String] vendor: { 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
- #vendor ⇒ 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(sort: nil, filter: nil, paged: nil, page_size: nil, refresh: false, cnx: Jamf.cnx) ⇒ Array<Jamf::ChangeLogEntry>
extended
from ChangeLog
The change and note history for this resource.
-
.change_log_count(cnx: Jamf.cnx) ⇒ Integer
extended
from ChangeLog
how many change log entries are there? needed when using paged #change_log calls.
-
.next_page_of_change_log ⇒ Array<Jamf::ChangeHistoryEntry>
extended
from ChangeLog
Fetch the next page of a paged #change_log request Returns an empty array if there's been no paged request or if the last one has no more pages.
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 170
|
#assetTag ⇒ String
|
# File 'lib/jamf/api/resources/collection_resources/inventory_preload_record.rb', line 218
|
#barCode1 ⇒ String
|
# File 'lib/jamf/api/resources/collection_resources/inventory_preload_record.rb', line 206
|
#barCode2 ⇒ String
|
# File 'lib/jamf/api/resources/collection_resources/inventory_preload_record.rb', line 212
|
#building ⇒ String
|
# File 'lib/jamf/api/resources/collection_resources/inventory_preload_record.rb', line 140
|
#department ⇒ String
|
# File 'lib/jamf/api/resources/collection_resources/inventory_preload_record.rb', line 134
|
#deviceType ⇒ String
|
# File 'lib/jamf/api/resources/collection_resources/inventory_preload_record.rb', line 96
|
#emailAddress ⇒ String
|
# File 'lib/jamf/api/resources/collection_resources/inventory_preload_record.rb', line 116
|
#extensionAttributes ⇒ Jamf::InventoryPreloadExtensionAttribute
|
# File 'lib/jamf/api/resources/collection_resources/inventory_preload_record.rb', line 230
|
#fullName ⇒ String
|
# File 'lib/jamf/api/resources/collection_resources/inventory_preload_record.rb', line 110
|
#id ⇒ Integer (readonly)
|
# File 'lib/jamf/api/resources/collection_resources/inventory_preload_record.rb', line 79
|
#leaseExpiration ⇒ String
|
# File 'lib/jamf/api/resources/collection_resources/inventory_preload_record.rb', line 200
|
#lifeExpectancy ⇒ String
|
# File 'lib/jamf/api/resources/collection_resources/inventory_preload_record.rb', line 176
|
#phoneNumber ⇒ String
|
# File 'lib/jamf/api/resources/collection_resources/inventory_preload_record.rb', line 122
|
#poDate ⇒ String
|
# File 'lib/jamf/api/resources/collection_resources/inventory_preload_record.rb', line 158
|
#poNumber ⇒ String
|
# File 'lib/jamf/api/resources/collection_resources/inventory_preload_record.rb', line 152
|
#position ⇒ String
|
# File 'lib/jamf/api/resources/collection_resources/inventory_preload_record.rb', line 128
|
#purchasePrice ⇒ String
|
# File 'lib/jamf/api/resources/collection_resources/inventory_preload_record.rb', line 182
|
#purchasingAccount ⇒ String
|
# File 'lib/jamf/api/resources/collection_resources/inventory_preload_record.rb', line 194
|
#purchasingContact ⇒ String
|
# File 'lib/jamf/api/resources/collection_resources/inventory_preload_record.rb', line 188
|
#room ⇒ String
|
# File 'lib/jamf/api/resources/collection_resources/inventory_preload_record.rb', line 146
|
#serialNumber ⇒ String
|
# File 'lib/jamf/api/resources/collection_resources/inventory_preload_record.rb', line 87
|
#username ⇒ String
|
# File 'lib/jamf/api/resources/collection_resources/inventory_preload_record.rb', line 104
|
#vendor ⇒ String
|
# File 'lib/jamf/api/resources/collection_resources/inventory_preload_record.rb', line 224
|
#warrantyExpiration ⇒ String
|
# File 'lib/jamf/api/resources/collection_resources/inventory_preload_record.rb', line 164
|
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, the cache is flushed after adding the note.
.change_log(sort: nil, filter: nil, paged: nil, page_size: nil, refresh: false, cnx: Jamf.cnx) ⇒ Array<Jamf::ChangeLogEntry> Originally defined in module ChangeLog
The change and note history for this resource. This is a collection of objects as a sub-resource of some primary resource. As such, retriving the change log returns an array of objects, and can be paged, sorted and filtered.
This method is very similar to CollectionResource.all, see the docs for that method for more details
successive page.
.change_log_count(cnx: Jamf.cnx) ⇒ Integer Originally defined in module ChangeLog
how many change log entries are there? needed when using paged #change_log calls
Instance Method Details
#clear ⇒ Object
clear all values for this record except id, serialNumber, and deviceType
270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 |
# File 'lib/jamf/api/resources/collection_resources/inventory_preload_record.rb', line 270 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.
263 264 265 266 267 |
# File 'lib/jamf/api/resources/collection_resources/inventory_preload_record.rb', line 263 def ext_attrs eas = {} extensionAttributes.each { |ea| eas[ea.name] = ea.value } eas end |
#remove_ext_attr(ea_name) ⇒ Object
remove an EA value
257 258 259 260 |
# File 'lib/jamf/api/resources/collection_resources/inventory_preload_record.rb', line 257 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)
251 252 253 254 |
# File 'lib/jamf/api/resources/collection_resources/inventory_preload_record.rb', line 251 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 |