Class: JSS::Computer
- Extended by:
- Matchable
- Includes:
- Creatable, Extendable, Locatable, MDM, ManagementHistory, Purchasable, Sitable, Updatable, Uploadable
- Defined in:
- lib/jss/api_object/computer.rb,
lib/jss.rb,
lib/jss/api_object/computer/application_installs.rb
Overview
This class represents a Computer in the JSS.
Adding Computers to the JSS
At the moment, this class cannot be used to add new Computers to the JSS. Please use other methods (like the Recon App or QuickAdd package)
Editing values
Any data that arrives in the JSS via an “inventory update” (a.k.a. ‘recon’) cannot be modified through this class, or the API.
Data that can be modified are:
-
Management Account (see #set_management_to)
-
asset_tag
-
barcodes 1 and 2
-
ip_address
-
udid
-
mac_address & alt_mac_address
-
serial_number Note: Even tho the webUI doesn’t allow editing the serial_number, the API does, and it can be useful for dealing with duplicates that arise when a logic-board swap causes a new computer record. to be created.
-
location data via the Locatable module
-
purchasing data via the Purchasable module
-
Extension Attribute values via the Extendable module Note: as with other ‘recon’ generated values, Ext. Attrs. populated by scripts cannot be modified via the API. (the change would be overwritten the next time the machine did a recon)
After making any changes, you must call #update to send those changes to the server.
MDM Commands
See the MDM mixin module for Class and Instance methods for sending MDM commands to computers.
To send MDM commands without fetching Computer instances, use the class methods, which can take multiple computer identifiers at once.
NOTE: the poorly named ‘UnmanageDevice’ mdm command is implemented as MDM#remove_mdm_profile (which is its name in the webUI) as well as MDM#unmanage_device. Calling that method will NOT fully unmanage a computer from the JSS’s point of view, it will just remove the mdm management profile from the machine and all configuration profiles that were installed via the JSS. Those profiles may be re-installed automatically later if the computer is still in scope for them
To properly unmanage a computer, use the #make_unmanaged Instance method which removes the mdm profile, but also makes the machine unmanged by the JSS, setting the management acct to nil, and requring re-enrollment.
Management History & Logs
Computer Management History and logs can now be retrieved both from a Computer instance, and directly via class methods without fetching an instance. This is handled by the mixed-in ManagementHistory module, Q.V. for details.
Appication Usage History
Computer Instances now have access to their Application Usage history via the #application_usage method. Call the method with a start-date value (either a String or a Time object) and an optional end-date value. If you omite the end-date, the start-date is used and you’ll see usage for just that day.
See #application_usage for details about the data returned.
NOTE: your JSS must be gathering Appication Usage data in order for any data to be returned, and the usage history will only go back as far as your setting for flushing of Application Usage Logs.
Management Data
The computers ‘manamgement data’, as presented on the ‘Management’ tab of the computer’s detail page in the JSS web UI, is available from the #management_data method. That method may return a large dataset, unless a subset is requested.
Subsets of management data have their own methods, which are faster and only retrieve the subset requested. See #smart_groups, #static_groups, #policies, #configuration_profiles, #ebooks, #app_store_apps, #restricted_software, and #patch_titles
The subset methods can take an ‘only:’ parameter, which is a symbol specifying the value you care to see. For example #smart_groups returns an array of hashes, one for each smart_group the computer is in. Those hashes have two keys, :name, and :id. However if you only want an array of names, you can call ‘smart_groups only: :name`
When any of the manamgement data methods are used the first time, the data is read from the API and cached internally, the cache is then used for all future calls. To re-read the data from the API and re-cache it, provide ‘refresh: true` to any of the manamgement data methods.
Other Methods
-
#set_management_to change the management acct and passwd for this computer, aliased to #make_managed
-
requires calling #update to push changes to the server
-
-
#make_unmanaged an shortcut method for #set_management_to(nil)
-
requires calling #update to push changes to the server
-
-
#licensed_sw a shortcut to #software [:licensed_software]
-
#computer_groups a shortcut to #groups_accounts [:computer_group_memberships]
-
#local_accounts a shortcut to #groups_accounts [:local_accounts]
Constant Summary collapse
- RSRC_BASE =
The base for REST resources of this class
'computers'.freeze
- LIST_RSRC =
The (temporary?) list-resource
"#{RSRC_BASE}/subset/basic".freeze
- RSRC_LIST_KEY =
the hash key used for the JSON list output of all objects in the JSS
:computers
- RSRC_OBJECT_KEY =
The hash key used for the JSON object output. It’s also used in various error messages
:computer
- SITE_SUBSET =
Where is the Site data in the API JSON?
:general
- VALID_DATA_KEYS =
these keys, as well as :id and :name, are present in valid API JSON data for this class
DEPRECATED, with be removed in a future release.
%i[sus distribution_point alt_mac_address].freeze
- OTHER_LOOKUP_KEYS =
these keys, as well as :id and :name, can be used to look up objects of this class in the JSS
{ udid: { rsrc_key: :udid, list: :all_udids }, serialnumber: { rsrc_key: :serialnumber, list: :all_serial_numbers }, serial_number: { rsrc_key: :serialnumber, list: :all_serial_numbers }, macaddress: { rsrc_key: :macaddress, list: :all_mac_addresses }, mac_address: { rsrc_key: :macaddress, list: :all_mac_addresses } }.freeze
- SEARCH_CLASS =
This class lets us seach for computers
JSS::AdvancedComputerSearch
- EXT_ATTRIB_CLASS =
This is the class for relevant Extension Attributes
JSS::ComputerExtensionAttribute
- BOOT_FLAG =
Boot partitions are noted with the string “(Boot Partition)” at the end
' (Boot Partition)'.freeze
- UPLOAD_TYPES =
file uploads can send attachments to the JSS using :computers as the sub-resource.
{ attachment: :computers }.freeze
- MDM_COMMAND_TARGET =
Tell the MDM module what kind of MDM commands we use.
:computers
- APPLICATION_USAGE_RSRC =
The API resource for app usage
'computerapplicationusage'.freeze
- APPLICATION_USAGE_DATE_FMT =
The date format for retrieving usage data
'%Y-%m-%d'.freeze
- APPLICATION_USAGE_DATE_CLASSES =
The classes that can be used with the date format
[Time, DateTime, Date].freeze
- APPLICATION_USAGE_KEY =
The top-level hash key of the raw app usage data
:computer_application_usage
- MGMT_DATA_RSRC =
The API resource for computer_management data
'computermanagement'.freeze
- MGMT_DATA_KEY =
The top-level hash key of the computer_management data
:computer_management
- MGMT_DATA_SUBSETS =
Thes are both the subset names in the resrouce URLS (when converted to strings) and the second-level hash key of the returned subset data.
%i[ smart_groups static_groups mac_app_store_apps policies ebooks os_x_configuration_profiles restricted_software patch_reporting_software_titles ].freeze
- CHECKIN_RSRC =
The API Resource for the computer checkin settings
'computercheckin'.freeze
- CHECKIN_KEY =
The top-level hash key for the checkin settings
:computer_check_in
- INV_COLLECTION_RSRC =
The API Resource for the computer inventory collection settings
'computerinventorycollection'.freeze
- INV_COLLECTION_KEY =
The top-level hash key for the inventory collection settings
:computer_inventory_collection
- OBJECT_HISTORY_OBJECT_TYPE =
the object type for this object in the object history table. See APIObject#add_object_history_entry
1
- COMPUTER_APPLICATIONS_RSRC =
'computerapplications/application'.freeze
Instance Attribute Summary collapse
-
#alt_mac_address ⇒ String
(also: #alt_macaddress)
The secondary mac address.
- #applecare_id ⇒ String included from Purchasable
-
#asset_tag ⇒ String
The asset tag.
-
#barcode1 ⇒ String
(also: #bar_code_1, #barcode_1)
The barcodes.
-
#barcode2 ⇒ String
(also: #bar_code_2, #barcode_2)
The barcodes.
- #building ⇒ String included from Locatable
-
#configuration_profiles(only: nil) ⇒ Object
readonly
A shortcut for ‘management_data subset: :os_x_configuration_profiles’.
- #department ⇒ String included from Locatable
-
#distribution_point ⇒ String
readonly
The name of the distribution point for this computer.
- #email_address ⇒ String included from Locatable
-
#ext_attrs ⇒ Hash
included
from Extendable
readonly
A mapping of Ext Attrib names to their values.
-
#extension_attributes ⇒ Array<Hash>
included
from Extendable
readonly
The extension attribute values for the object.
-
#groups_accounts ⇒ Hash
readonly
Info about the local accts and ComputerGroups to which this machine beloings.
-
#hardware ⇒ Hash
readonly
A Hash with info about the hardware of this cmoputer.
-
#initial_entry_date ⇒ Time
readonly
When was it added to the JSS.
-
#ip_address ⇒ IPAddr
The last known IP address.
- #is_leased ⇒ Boolean (also: #leased?) included from Purchasable
- #is_purchased ⇒ Boolean (also: #purchased?) included from Purchasable
- #itunes_store_account_is_active ⇒ Boolean readonly
-
#jamf_version ⇒ String
readonly
The version of the jamf binary.
-
#last_contact_time ⇒ Time
readonly
The last contact time.
-
#last_enrolled ⇒ Time
readonly
The last time this machine was enrolled.
- #lease_expires ⇒ Time included from Purchasable
- #life_expectancy ⇒ Integer included from Purchasable
-
#mac_address ⇒ String
The primary macaddress.
-
#managed ⇒ Boolean
(also: #managed?)
readonly
Is this machine “managed” by Casper?.
-
#management_username ⇒ String
readonly
The name of the management account.
-
#mdm_capable ⇒ Boolean
(also: #mdm?)
readonly
Doesit support MDM?.
-
#mdm_capable_users ⇒ Array
readonly
User accts that support MDM? NOTE: This suffers from the JSON-Hash-treated-like_XML-Array-loses-data bug and only shows the last listed user, cuz it comes from the API as a hash, not an array.
-
#need_to_update ⇒ Boolean
included
from Updatable
readonly
Do we have unsaved changes?.
-
#netboot_server ⇒ String
readonly
The name of the netboot server for this machine.
-
#peripherals ⇒ Array<Hash>
readonly
A Hash per peripheral.
- #phone ⇒ String included from Locatable
-
#platform ⇒ String
readonly
What kind of computer?.
- #po_date ⇒ Time included from Purchasable
- #po_number ⇒ String included from Purchasable
- #position ⇒ String included from Locatable
- #purchase_price ⇒ Float included from Purchasable
- #purchasing_account ⇒ String included from Purchasable
- #purchasing_contact ⇒ String included from Purchasable
- #real_name ⇒ String included from Locatable
-
#report_date ⇒ Time
(also: #last_recon)
readonly
The last recon time.
- #room ⇒ String included from Locatable
-
#serial_number ⇒ String
(also: #sn, #serialnumber)
The serial number.
-
#site ⇒ Hash
readonly
The :name and :id of the site for this machine.
-
#software ⇒ Hash
readonly
A Hash of software data.
-
#sus ⇒ String
readonly
The name of the Software Update Server assigned to this machine.
-
#udid ⇒ String
The UDID of the computer.
- #username ⇒ String (also: #user) included from Locatable
- #vendor ⇒ String included from Purchasable
- #warranty_expires ⇒ Time included from Purchasable
Class Method Summary collapse
-
.all(refresh = false, api: JSS.api) ⇒ Array<Hash{:name=>String, :id=> Integer}>
A larger set of info about the computers in the JSS.
-
.all_desktops(refresh = false, api: JSS.api) ⇒ Array<Hash>
All desktop macs in the jss.
-
.all_imacs(refresh = false, api: JSS.api) ⇒ Array<Hash>
All imacs in the jss.
-
.all_laptops(refresh = false, api: JSS.api) ⇒ Array<Hash>
All laptop computers in the jss.
-
.all_mac_addresses(refresh = false, api: JSS.api) ⇒ Array<String>
All computer mac_addresses in the jss.
-
.all_macbookairs(refresh = false, api: JSS.api) ⇒ Array<Hash>
All macbookairs in the jss.
-
.all_macbookpros(refresh = false, api: JSS.api) ⇒ Array<Hash>
All macbookpros in the jss.
-
.all_macbooks(refresh = false, api: JSS.api) ⇒ Array<Hash>
All macbooks in the jss.
-
.all_macpros(refresh = false, api: JSS.api) ⇒ Array<Hash>
All macpros in the jss.
-
.all_managed(refresh = false, api: JSS.api) ⇒ Array<Hash>
All managed computers in the jss.
-
.all_minis(refresh = false, api: JSS.api) ⇒ Array<Hash>
All mac minis in the jss.
-
.all_serial_numbers(refresh = false, api: JSS.api) ⇒ Array<String>
All computer serial numbers in the jss.
-
.all_udids(refresh = false, api: JSS.api) ⇒ Array<String>
All computer udids in the jss.
-
.all_unmanaged(refresh = false, api: JSS.api) ⇒ Array<Hash>
All unmanaged computers in the jss.
-
.all_xserves(refresh = false, api: JSS.api) ⇒ Array<Hash>
All xserves in the jss.
-
.application_installs(appname, fields: [], version: nil, ids_only: false, api: JSS.api) ⇒ Array<Integer>, ...
Query the JSS for computers with some app installed.
-
.application_usage(ident, start_date, end_date = nil, api: JSS.api) ⇒ Hash{Date=>Array<Hash>}
Retrieve Application Usage data for a computer by id, without instantiation.
-
.checkin_settings(api: JSS.api) ⇒ Hash
Display the current Computer CheckIn settings in the JSS.
-
.inventory_collection_settings(api: JSS.api) ⇒ Hash
Display the current Computer Inventory Collection settings in the JSS.
-
.management_data(ident, subset: nil, only: nil, api: JSS.api) ⇒ Hash, Array
The ‘computer management’ data for a given computer by id, looked up on the fly.
-
.match(term, api: JSS.api) ⇒ Array<Hash>
extended
from Matchable
Perform a match, returning an Array of Hashes, one for each item matched.
Instance Method Summary collapse
-
#app_store_app_history(status = nil) ⇒ Object
(also: #managed_app_history)
included
from ManagementHistory
Wrapper for app store history for both computers and mobile devices.
-
#app_store_apps(only: nil) ⇒ Object
A shortcut for ‘management_data subset: :mac_app_store_apps’.
-
#application_usage(start_date, end_date = nil) ⇒ Object
Get application usage data for this computer for a given date range.
-
#apps ⇒ Array<Hash>
All apps installed on this machine.
-
#audit_history ⇒ Object
(also: #audits)
included
from ManagementHistory
The audit_history for this object.
-
#blank_push ⇒ void
(also: #send_blank_push, #noop)
included
from MDM
Send a blank push to this object.
-
#boot_drive ⇒ Hash?
The hardware hash of the boot drive.
-
#casper_imaging_logs ⇒ Object
included
from ManagementHistory
The casper_imaging_logs for this computer.
-
#casper_remote_logs ⇒ Object
included
from ManagementHistory
The casper_remote_logs for this computer.
-
#clear_location ⇒ void
included
from Locatable
Clear all location data.
-
#clear_passcode ⇒ Object
included
from MDM
Send an clear_passcode command to this object.
-
#clear_restrictions_password ⇒ Object
included
from MDM
Send an clear_restrictions_password command to this object.
-
#clone(new_name, api: nil) ⇒ APIObject
included
from Creatable
make a clone of this API object, with a new name.
-
#completed_mdm_commands ⇒ Object
(also: #completed_commands)
included
from ManagementHistory
The completed_mdm_commands for this object.
-
#completed_policies ⇒ Object
included
from ManagementHistory
The array from .policy_logs, limited to status = :completed.
-
#computer_groups ⇒ Array
The JSS groups to which thismachine belongs (smart and static).
-
#computer_usage_logs ⇒ Object
(also: #usage_logs)
included
from ManagementHistory
The computer_usage_logs for this computer.
-
#create(api: nil) ⇒ Integer
included
from Creatable
Create a new object in the JSS.
-
#delete ⇒ void
Delete this computer from the JSS.
-
#delete_user(user) ⇒ Object
included
from MDM
Send a delete_user command to this computer or group.
-
#device_lock(passcode_or_message = '') ⇒ Object
(also: #lock, #lock_device)
included
from MDM
Send a dev lock to this object.
-
#device_name(name) ⇒ Object
(also: #set_name, #set_device_name)
included
from MDM
Send a device_name command to this object.
-
#disable_app_analytics ⇒ Object
included
from MDM
Send a disable_app_analytics command to this object.
-
#disable_data_roaming ⇒ Object
included
from MDM
Send a disable_data_roaming command to this object.
-
#disable_diagnostic_submission ⇒ Object
included
from MDM
Send a disable_diagnostic_submission command to this object.
-
#disable_lost_mode ⇒ Object
included
from MDM
Send a disable_lost_mode command to this object.
-
#disable_voice_roaming ⇒ Object
included
from MDM
Send a disable_voice_roaming command to this object.
-
#drives ⇒ Array<Hash>
Each storage device.
-
#ebook_history(status = nil) ⇒ Object
(also: #managed_ebook_history)
included
from ManagementHistory
The ebook_history for this mobile device.
-
#ebooks(only: nil) ⇒ Object
A shortcut for ‘management_data subset: :ebooks’.
-
#enable_app_analytics ⇒ Object
included
from MDM
Send an enable_app_analytics command to this object.
-
#enable_data_roaming ⇒ Object
included
from MDM
Send an enable_data_roaming command to this object.
-
#enable_diagnostic_submission ⇒ Object
included
from MDM
Send an enable_diagnostic_submission command to this object.
-
#enable_lost_mode(message: nil, phone_number: nil, footnote: nil, enforce_lost_mode: true, play_sound: false) ⇒ Object
included
from MDM
Send a enable_lost_mode command to one or more targets.
-
#enable_voice_roaming ⇒ Object
included
from MDM
Send an enable_voice_roaming command to this object.
-
#erase_device(passcode = '', preserve_data_plan: false) ⇒ Object
(also: #wipe_device, #wipe_computer, #wipe, #erase)
included
from MDM
Send an erase device command to this object.
-
#ext_attr_xml ⇒ REXML::Element
included
from Extendable
private
TODO: make this (and all XML amending) method take the in-progress XML doc and add (or not) the EA xml to it.
-
#failed_app_store_apps ⇒ Object
(also: #failed_managed_apps)
included
from ManagementHistory
shortcut for app_store_app_history where status = :failed.
-
#failed_ebooks ⇒ Object
(also: #failed_managed_ebooks)
included
from ManagementHistory
shortcut for ebook_history where status = :failed.
-
#failed_mdm_commands ⇒ Object
(also: #failed_commands)
included
from ManagementHistory
The failed_mdm_commands for this object.
-
#failed_policies ⇒ Object
included
from ManagementHistory
The array from .policy_logs, limited to status = :failed.
-
#filevault1_accounts ⇒ Array<Hash>
The local_accounts Array that have Legacy FV enabled.
-
#filevault2_enabled? ⇒ Boolean
Is FileVault2 enabled?.
-
#flush_mdm_commands(status) ⇒ void
included
from MDM
flush pending and/or failed MDM commands for this object.
-
#has_location? ⇒ Boolean
included
from Locatable
Does this item have location data?.
-
#has_purchasing? ⇒ Boolean
included
from Purchasable
Does this item have any purchasing info?.
-
#initialize(args = {}) ⇒ Computer
constructor
# When creating new records with .make, these can be provided in the arg, or after instantiation via setter methods: serial_number:, udid:, asset_tag:, mac_address: alt_mac_address:, barcode_1:, barcode_2:.
-
#installed_app_store_apps ⇒ Object
(also: #installed_managed_apps)
included
from ManagementHistory
shortcut for app_store_app_history where status = :installed.
-
#installed_ebooks ⇒ Object
(also: #installed_managed_ebooks)
included
from ManagementHistory
shortcut for ebook_history where status = :installed.
-
#licensed_sw ⇒ Array<String>
The JSS-defined “licensed software” titles installed on this machine.
-
#local_accounts ⇒ Array<Hash>
(also: #accounts, #accts)
Each item has keys :name, :realname, :uid, :home, :home_size, :administrator, :filevault_enabled.
-
#location ⇒ Hash<String>
included
from Locatable
All the location data in a Hash, as it comes from the API.
-
#location_xml ⇒ REXML::Element
included
from Locatable
private
Return a REXML <location> element to be included in the rest_xml of objects that have a Location subset.
-
#mac_app_store_app_history(status = nil) ⇒ Object
included
from ManagementHistory
The mac_app_store_app_history for this computer.
-
#make_unmanaged ⇒ void
Make the machine unmanaged.
-
#management_data(subset: nil, only: nil) ⇒ Object
The ‘computer management’ data for this computer.
-
#management_history(subset = nil) ⇒ Object
(also: #history)
included
from ManagementHistory
The raw management history data for this object.
-
#mdm_command_history(status = nil) ⇒ Object
(also: #commands, #management_command_history)
included
from ManagementHistory
The mdm_command_history for this object.
-
#mobile_device_app_history(status = nil) ⇒ Object
included
from ManagementHistory
The mobile_device_app_history for this mobile device.
-
#name=(newname) ⇒ void
included
from Updatable
Change the name of this item Remember to #update to push changes to the server.
-
#parse_ext_attrs ⇒ void
included
from Extendable
Populate @extension_attributes (the Array of Hashes that comes from the API) and @ext_attr_names, which is a Hash mapping the EA names to their values.
-
#parse_location ⇒ void
included
from Locatable
Call this during initialization of objects that have a Location subset and the location attributes will be populated (as primary attributes) from @init_data.
-
#parse_purchasing ⇒ Object
included
from Purchasable
private
Call this during initialization of objects that have a Purchasing subset and the purchasing attribute will be populated from @init_data.
-
#passcode_lock_grace_period(secs) ⇒ Object
included
from MDM
Send a passcode_lock_grace_period command to this object.
-
#patch_titles(only: nil) ⇒ Object
A shortcut for ‘management_data subset: :patch_reporting_software_titles’.
-
#pending_app_store_apps ⇒ Object
(also: #pending_managed_apps)
included
from ManagementHistory
shortcut for app_store_app_history where status = :pending.
-
#pending_ebooks ⇒ Object
(also: #pending_managed_ebooks)
included
from ManagementHistory
shortcut for ebook_history where status = :pending.
-
#pending_mdm_commands ⇒ Object
(also: #pending_commands)
included
from ManagementHistory
The pending_mdm_commands for this object.
-
#play_lost_mode_sound ⇒ Object
included
from MDM
Send a play_lost_mode_sound command to this object.
-
#policies(only: nil) ⇒ Object
A shortcut for ‘management_data subset: :policies’.
-
#policy_logs ⇒ Object
included
from ManagementHistory
The policy_logs for this computer.
-
#printers ⇒ Array<Hash>
Each printer on this computer Keys are :name, :uri, :type, :location.
-
#purchasing ⇒ Hash<String>
included
from Purchasable
All the purchasing data in a Hash, as it comes from the API.
-
#purchasing_xml ⇒ REXML::Element
included
from Purchasable
private
A <purchasing> element to be included in the rest_xml of objects that mix-in this module.
-
#restart_device ⇒ Object
(also: #restart)
included
from MDM
Send a restart_device command to this object.
-
#restricted_software(only: nil) ⇒ Object
A shortcut for ‘management_data subset: :restricted_software’.
-
#screen_sharing_logs ⇒ Object
included
from ManagementHistory
The screen_sharing_logs for this computer.
-
#set_ext_attr(name, value) ⇒ void
included
from Extendable
Set the value of an extension attribute.
-
#set_management_to(name, password) ⇒ void
(also: #make_managed)
Set or unset management acct and password for this computer.
-
#shut_down_device ⇒ Object
(also: #shutdown_device, #shut_down, #shutdown)
included
from MDM
Send a shut_down_device command to this object.
-
#site=(new_site) ⇒ void
included
from Sitable
Change the site of this object.
-
#site_assigned? ⇒ Boolean
included
from Sitable
Does this object have a site assigned?.
-
#site_id ⇒ Integer
included
from Sitable
The id of the site for this object.
-
#site_name ⇒ String
(also: #site)
included
from Sitable
The name of the site for this object.
-
#site_object ⇒ JSS::Site
included
from Sitable
The JSS::Site instance for this object’s site.
-
#smart_groups(only: nil) ⇒ Object
A shortcut for ‘management_data subset: :smart_groups’.
-
#static_groups(only: nil) ⇒ Object
A shortcut for ‘management_data subset: :static_groups’.
-
#unlock_user_account(user) ⇒ Object
included
from MDM
Send an unlock_user_account command to this computer or group.
-
#unmanage_device ⇒ Object
(also: #remove_mdm_profile)
included
from MDM
Send an unmanage device command to this object.
-
#unsaved_eas? ⇒ Boolean
included
from Extendable
are there any changes in the EAs needing to be saved?.
-
#unset_site ⇒ void
included
from Sitable
Set the site to nothing.
-
#update ⇒ void
Send changes to the API.
-
#update_inventory ⇒ Object
(also: #recon)
included
from MDM
Send an update_inventory command to this object.
-
#upload(type, local_file) ⇒ String
included
from Uploadable
Upload a file to the JSS via the REST Resource of the object to which this module is mixed in.
-
#user_location_history ⇒ Object
included
from ManagementHistory
The user_location_history for this object.
-
#wallpaper(wallpaper_setting: nil, wallpaper_content: nil, wallpaper_id: nil) ⇒ Object
(also: #set_wallpaper)
included
from MDM
Send a wallpaper command to this object.
Constructor Details
#initialize(args = {}) ⇒ Computer
# When creating new records with .make, these can be provided in the arg, or after instantiation via setter methods:
serial_number:, udid:, asset_tag:, mac_address:
alt_mac_address:, barcode_1:, barcode_2:
735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 |
# File 'lib/jss/api_object/computer.rb', line 735 def initialize(args = {}) super args if @in_jss # mutable stuff @alt_mac_address = @init_data[:general][:alt_mac_address] @asset_tag = @init_data[:general][:asset_tag] @barcode1 = @init_data[:general][:barcode_1] @barcode2 = @init_data[:general][:barcode_2] @mac_address = @init_data[:general][:mac_address] @managed = @init_data[:general][:remote_management][:managed] @management_username = @init_data[:general][:remote_management][:management_username] @serial_number = @init_data[:general][:serial_number] @udid = @init_data[:general][:udid] # immutable single-values @distribution_point = @init_data[:general][:distribution_point] @initial_entry_date = JSS.epoch_to_time @init_data[:general][:initial_entry_date_epoch] @last_enrolled = JSS.epoch_to_time @init_data[:general][:last_enrolled_date_epoch] @ip_address = @init_data[:general][:ip_address] @itunes_store_account_is_active = @init_data[:general][:itunes_store_account_is_active] @jamf_version = @init_data[:general][:jamf_version] @last_contact_time = JSS.epoch_to_time @init_data[:general][:last_contact_time_epoch] @mdm_capable = @init_data[:general][:mdm_capable] @mdm_capable_users = @init_data[:general][:mdm_capable_users].values @netboot_server = @init_data[:general][:netboot_server] @platform = @init_data[:general][:platform] @report_date = JSS.epoch_to_time @init_data[:general][:report_date_epoch] @sus = @init_data[:general][:sus] @configuration_profiles = @init_data[:configuration_profiles] @certificates = @init_data[:certificates] @groups_accounts = @init_data[:groups_accounts] @hardware = @init_data[:hardware] @peripherals = @init_data[:peripherals] @software = @init_data[:software] # Freeze immutable things. # These are updated via recon, and aren't sent # with #update, so changing them here is meaningless anyway. @configuration_profiles.freeze @certificates.freeze @groups_accounts.freeze @hardware.freeze @peripherals.freeze @software.freeze @management_password = nil else @udid = args[:udid] @serial_number = args[:serial_number] @asset_tag = args[:asset_tag] @mac_address = args[:mac_address] @alt_mac_address = args[:alt_mac_address] @barcode1 = args[:barcode_1] @barcode2 = args[:barcode_2] end end |
Instance Attribute Details
#alt_mac_address ⇒ String Also known as: alt_macaddress
Returns the secondary mac address.
501 502 503 |
# File 'lib/jss/api_object/computer.rb', line 501 def alt_mac_address @alt_mac_address end |
#applecare_id ⇒ String Originally defined in module Purchasable
#asset_tag ⇒ String
Returns the asset tag.
504 505 506 |
# File 'lib/jss/api_object/computer.rb', line 504 def asset_tag @asset_tag end |
#barcode1 ⇒ String Also known as: bar_code_1, barcode_1
Returns the barcodes.
507 508 509 |
# File 'lib/jss/api_object/computer.rb', line 507 def @barcode1 end |
#barcode2 ⇒ String Also known as: bar_code_2, barcode_2
Returns the barcodes.
507 508 509 |
# File 'lib/jss/api_object/computer.rb', line 507 def @barcode2 end |
#configuration_profiles(only: nil) ⇒ Object (readonly)
A shortcut for ‘management_data subset: :os_x_configuration_profiles’
582 583 584 |
# File 'lib/jss/api_object/computer.rb', line 582 def configuration_profiles @configuration_profiles end |
#distribution_point ⇒ String (readonly)
Returns The name of the distribution point for this computer.
510 511 512 |
# File 'lib/jss/api_object/computer.rb', line 510 def distribution_point @distribution_point end |
#ext_attrs ⇒ Hash (readonly) Originally defined in module Extendable
Returns A mapping of Ext Attrib names to their values.
#extension_attributes ⇒ Array<Hash> (readonly) Originally defined in module Extendable
Returns The extension attribute values for the object.
#groups_accounts ⇒ Hash (readonly)
Info about the local accts and ComputerGroups to which this machine beloings
The Hash keys are:
-
:computer_group_memberships => An Array of names of ComputerGroups to which this computer belongs
-
:local_accounts => An Array of Hashes for each local user acct on this computer. Each hash has these keys:
-
:name => String, the login name of the acct
-
:realname => the real name of the acct
-
:uid => String, the uid of the acct
-
:home => String, the path to the home folder
-
:home_size => String, the size of the homedir as a string like “53245MB”
-
:home_size_mb => Integer, the size of the homedir as an integer like 53245
-
:administrator => Boolean
-
:filevault_enabled => Boolean
-
600 601 602 |
# File 'lib/jss/api_object/computer.rb', line 600 def groups_accounts @groups_accounts end |
#hardware ⇒ Hash (readonly)
A Hash with info about the hardware of this cmoputer.
These are the keys & sample data
-
:number_processors=>2,
-
:processor_speed_mhz=>2530,
-
:make=>“Apple”,
-
:cache_size=>3072,
-
:processor_type=>“Intel Core i5”,
-
:total_ram_mb=>8192,
-
:model=>“15-inch MacBook Pro (Mid 2010)”,
-
:available_ram_slots=>0,
-
:processor_architecture=>“i386”,
-
:bus_speed_mhz=>0,
-
:total_ram=>8192,
-
:os_name=>“Mac OS X”,
-
:optical_drive=>“HL-DT-ST DVDRW GS23N”,
-
:model_identifier=>“MacBookPro6,2”,
-
:cache_size_kb=>3072,
-
:boot_rom=>“MBP61.0057.B0F”,
-
:os_version=>“10.9.3”,
-
:mapped_printers=> An Array of Hashes, one per printer, with these keys
-
:name => the name of the printer
-
:location => the location of the printer
-
:type => the printer model
-
:uri => the uri to reach the printer on the network
-
-
:nic_speed=>“10/100/1000”,
-
:processor_speed=>2530,
-
:active_directory_status=>“Not Bound”,
-
:bus_speed=>0,
-
:os_build=>“13D65”,
-
:smc_version=>“1.58f17”,
-
:service_pack=>“”,
-
:battery_capacity=>87
-
:storage=> An Array of Hashes, one per Drive, with these keys
-
:smart_status=>“Verified”,
-
:connection_type=>“NO”,
-
:model=>“M4-CT256M4SSD2”,
-
:revision=>“040H”,
-
:serial_number=>“00000000130709JH7GhhC”,
-
:size=>262205,
-
:disk=>“disk0”,
-
:drive_capacity_mb=>262205}],
-
:partition=> A Hash with these keys
-
:filevault2_status=>“Encrypted”,
-
:type=>“boot”,
-
:filevault2_percent=>100,
-
:partition_capacity_mb=>38014,
-
:lvgUUID=>“C4883AF5-3E58-4F76-A56C-094D4CEC7E9F”,
-
:percentage_full=>61,
-
:lvUUID=>“745A262E-AEA6-4608-8A3A-6CDC225B4DE6”,
-
:filevault_status=>“Encrypted”,
-
:size=>38014,
-
:pvUUID=>“C38051CF-5066-442F-A442-1035060ED462”,
-
:name=>“KimDrive40 (Boot Partition)”,
-
:filevault_percent=>100
-
-
660 661 662 |
# File 'lib/jss/api_object/computer.rb', line 660 def hardware @hardware end |
#initial_entry_date ⇒ Time (readonly)
Returns when was it added to the JSS.
513 514 515 |
# File 'lib/jss/api_object/computer.rb', line 513 def initial_entry_date @initial_entry_date end |
#ip_address ⇒ IPAddr
Returns the last known IP address.
516 517 518 |
# File 'lib/jss/api_object/computer.rb', line 516 def ip_address @ip_address end |
#is_leased ⇒ Boolean Also known as: leased? Originally defined in module Purchasable
#is_purchased ⇒ Boolean Also known as: purchased? Originally defined in module Purchasable
#itunes_store_account_is_active ⇒ Boolean (readonly)
519 520 521 |
# File 'lib/jss/api_object/computer.rb', line 519 def itunes_store_account_is_active @itunes_store_account_is_active end |
#jamf_version ⇒ String (readonly)
Returns the version of the jamf binary.
522 523 524 |
# File 'lib/jss/api_object/computer.rb', line 522 def jamf_version @jamf_version end |
#last_contact_time ⇒ Time (readonly)
Returns the last contact time.
525 526 527 |
# File 'lib/jss/api_object/computer.rb', line 525 def last_contact_time @last_contact_time end |
#last_enrolled ⇒ Time (readonly)
Returns the last time this machine was enrolled.
528 529 530 |
# File 'lib/jss/api_object/computer.rb', line 528 def last_enrolled @last_enrolled end |
#lease_expires ⇒ Time Originally defined in module Purchasable
#life_expectancy ⇒ Integer Originally defined in module Purchasable
#mac_address ⇒ String
Returns the primary macaddress.
531 532 533 |
# File 'lib/jss/api_object/computer.rb', line 531 def mac_address @mac_address end |
#managed ⇒ Boolean (readonly) Also known as: managed?
Returns is this machine “managed” by Casper?.
534 535 536 |
# File 'lib/jss/api_object/computer.rb', line 534 def managed @managed end |
#management_username ⇒ String (readonly)
Returns the name of the management account.
537 538 539 |
# File 'lib/jss/api_object/computer.rb', line 537 def management_username @management_username end |
#mdm_capable ⇒ Boolean (readonly) Also known as: mdm?
Returns doesit support MDM?.
540 541 542 |
# File 'lib/jss/api_object/computer.rb', line 540 def mdm_capable @mdm_capable end |
#mdm_capable_users ⇒ Array (readonly)
Returns user accts that support MDM? NOTE: This suffers from the JSON-Hash-treated-like_XML-Array-loses-data bug and only shows the last listed user, cuz it comes from the API as a hash, not an array.
547 548 549 |
# File 'lib/jss/api_object/computer.rb', line 547 def mdm_capable_users @mdm_capable_users end |
#need_to_update ⇒ Boolean (readonly) Originally defined in module Updatable
Returns do we have unsaved changes?.
#netboot_server ⇒ String (readonly)
Returns the name of the netboot server for this machine.
550 551 552 |
# File 'lib/jss/api_object/computer.rb', line 550 def netboot_server @netboot_server end |
#peripherals ⇒ Array<Hash> (readonly)
A Hash per peripheral
Each hash has these keys & sample data:
-
:id=>286,
-
:type=>“Display”,
-
:field_0=>“HP”,
-
:field_1=>“HP LP2480zx”,
-
:field_2=>“DreamColor”,
-
:field_3=>“3CM10800F4”,
-
:field_4=>“”,
-
:field_5=>“”
-
:field_6=>“”,
-
:bar_code_1=>“”,
-
:bar_code_2=>“”,
-
:purchasing=> A hash with these keys:
-
:warranty_expires_utc=>“”,
-
:is_leased=>false,
-
:po_date=>“”,
-
:lease_expires=>“”,
-
:po_number=>“”,
-
:po_date_epoch=>0,
-
:lease_expires_epoch=>0,
-
:vendor=>“”,
-
:attachments=>[],
-
:po_date_utc=>“”,
-
:lease_expires_utc=>“”,
-
:applecare_id=>“”,
-
:warranty_expires=>“”,
-
:life_expectancy=>0,
-
:purchase_price=>“”,
-
:warranty_expires_epoch=>0,
-
:is_purchased=>true,
-
:purchasing_contact=>“”,
-
:purchasing_account=>“”
-
699 700 701 |
# File 'lib/jss/api_object/computer.rb', line 699 def peripherals @peripherals end |
#platform ⇒ String (readonly)
Returns what kind of computer?.
553 554 555 |
# File 'lib/jss/api_object/computer.rb', line 553 def platform @platform end |
#po_date ⇒ Time Originally defined in module Purchasable
#po_number ⇒ String Originally defined in module Purchasable
#purchase_price ⇒ Float Originally defined in module Purchasable
#purchasing_account ⇒ String Originally defined in module Purchasable
#purchasing_contact ⇒ String Originally defined in module Purchasable
#report_date ⇒ Time (readonly) Also known as: last_recon
Returns the last recon time.
556 557 558 |
# File 'lib/jss/api_object/computer.rb', line 556 def report_date @report_date end |
#serial_number ⇒ String Also known as: sn, serialnumber
Returns the serial number.
559 560 561 |
# File 'lib/jss/api_object/computer.rb', line 559 def serial_number @serial_number end |
#site ⇒ Hash (readonly)
Returns the :name and :id of the site for this machine.
562 563 564 |
# File 'lib/jss/api_object/computer.rb', line 562 def site @site end |
#software ⇒ Hash (readonly)
A Hash of software data
The Hash has these keys:
-
:running_services => An Array of services running on the computer (if gathered) TODO - is each item a hash?
-
:installed_by_casper => An Array of Package names unstalled on this computer by Casper
-
:fonts => An Array of fonts on this computer (if gathered) TODO - is each item a hash?
-
:installed_by_installer_swu => An Array of pkg IDs for pkgs installed by SoftwareUpdate or the Apple Installer
-
:applications => An Array of Hashes, one per Application on the computer, with these keys:
-
:path => String, the path to the app
-
:name => String, the name of the app, including the .app suffix
-
:version => String, the version of the app at that path.
-
-
:cached_by_casper => An Array of Casper Package names cached on the machine, awaiting installation
-
:available_software_updates => An Array of available SoftwareUpdate (if gathered) TODO - is each item a hash?
-
:plugins => An Array of plugins installed on the machine (if gathered) TODO - is each item a hash?
-
:available_updates => A Hash - Deprecated?
-
:licensed_software => An Array, the names of Licenced Software (as defined in Casper) on this machine
-
:unix_executables => DEPRECATED
721 722 723 |
# File 'lib/jss/api_object/computer.rb', line 721 def software @software end |
#sus ⇒ String (readonly)
Returns the name of the Software Update Server assigned to this machine.
565 566 567 |
# File 'lib/jss/api_object/computer.rb', line 565 def sus @sus end |
#udid ⇒ String
Returns the UDID of the computer.
568 569 570 |
# File 'lib/jss/api_object/computer.rb', line 568 def udid @udid end |
#vendor ⇒ String Originally defined in module Purchasable
#warranty_expires ⇒ Time Originally defined in module Purchasable
Class Method Details
.all(refresh = false, api: JSS.api) ⇒ Array<Hash{:name=>String, :id=> Integer}>
A larger set of info about the computers in the JSS.
Casper 9.4 introduced the API Resource /computers/subset/basic that returns an array of hashes with more data than just /computers/ (which was just :name and :id). Similar to /mobildevices/, this new list includes :udid, :serial_number, and :mac_address, as well as :model, :managed, :building, :department, :username, and :report_date
Because this requires a different, unusual, resource path, we’re completely re-defining APIObject.all for JSS::Computer. Hopefully some day the original /computers/ resource will be updated to return this data.
310 311 312 313 314 |
# File 'lib/jss/api_object/computer.rb', line 310 def self.all(refresh = false, api: JSS.api) api.object_list_cache[RSRC_LIST_KEY] = nil if refresh return api.object_list_cache[RSRC_LIST_KEY] if api.object_list_cache[RSRC_LIST_KEY] api.object_list_cache[RSRC_LIST_KEY] = api.get_rsrc(self::LIST_RSRC)[self::RSRC_LIST_KEY] end |
.all_desktops(refresh = false, api: JSS.api) ⇒ Array<Hash>
Returns all desktop macs in the jss.
367 368 369 |
# File 'lib/jss/api_object/computer.rb', line 367 def self.all_desktops(refresh = false, api: JSS.api) all(refresh, api: api).reject { |d| d[:model] =~ /serve|book/i } end |
.all_imacs(refresh = false, api: JSS.api) ⇒ Array<Hash>
Returns all imacs in the jss.
372 373 374 |
# File 'lib/jss/api_object/computer.rb', line 372 def self.all_imacs(refresh = false, api: JSS.api) all(refresh, api: api).select { |d| d[:model] =~ /^imac/i } end |
.all_laptops(refresh = false, api: JSS.api) ⇒ Array<Hash>
Returns all laptop computers in the jss.
342 343 344 |
# File 'lib/jss/api_object/computer.rb', line 342 def self.all_laptops(refresh = false, api: JSS.api) all(refresh, api: api).select { |d| d[:model] =~ /book/i } end |
.all_mac_addresses(refresh = false, api: JSS.api) ⇒ Array<String>
Returns all computer mac_addresses in the jss.
322 323 324 |
# File 'lib/jss/api_object/computer.rb', line 322 def self.all_mac_addresses(refresh = false, api: JSS.api) all(refresh, api: api).map { |i| i[:mac_address] } end |
.all_macbookairs(refresh = false, api: JSS.api) ⇒ Array<Hash>
Returns all macbookairs in the jss.
357 358 359 |
# File 'lib/jss/api_object/computer.rb', line 357 def self.all_macbookairs(refresh = false, api: JSS.api) all(refresh, api: api).select { |d| d[:model] =~ /^macbookair\d/i } end |
.all_macbookpros(refresh = false, api: JSS.api) ⇒ Array<Hash>
Returns all macbookpros in the jss.
352 353 354 |
# File 'lib/jss/api_object/computer.rb', line 352 def self.all_macbookpros(refresh = false, api: JSS.api) all(refresh, api: api).select { |d| d[:model] =~ /^macbookpro\d/i } end |
.all_macbooks(refresh = false, api: JSS.api) ⇒ Array<Hash>
Returns all macbooks in the jss.
347 348 349 |
# File 'lib/jss/api_object/computer.rb', line 347 def self.all_macbooks(refresh = false, api: JSS.api) all(refresh, api: api).select { |d| d[:model] =~ /^macbook\d/i } end |
.all_macpros(refresh = false, api: JSS.api) ⇒ Array<Hash>
Returns all macpros in the jss.
382 383 384 |
# File 'lib/jss/api_object/computer.rb', line 382 def self.all_macpros(refresh = false, api: JSS.api) all(refresh, api: api).select { |d| d[:model] =~ /^macpro/i } end |
.all_managed(refresh = false, api: JSS.api) ⇒ Array<Hash>
Returns all managed computers in the jss.
332 333 334 |
# File 'lib/jss/api_object/computer.rb', line 332 def self.all_managed(refresh = false, api: JSS.api) all(refresh, api: api).select { |d| d[:managed] } end |
.all_minis(refresh = false, api: JSS.api) ⇒ Array<Hash>
Returns all mac minis in the jss.
377 378 379 |
# File 'lib/jss/api_object/computer.rb', line 377 def self.all_minis(refresh = false, api: JSS.api) all(refresh, api: api).select { |d| d[:model] =~ /^macmini/i } end |
.all_serial_numbers(refresh = false, api: JSS.api) ⇒ Array<String>
Returns all computer serial numbers in the jss.
317 318 319 |
# File 'lib/jss/api_object/computer.rb', line 317 def self.all_serial_numbers(refresh = false, api: JSS.api) all(refresh, api: api).map { |i| i[:serial_number] } end |
.all_udids(refresh = false, api: JSS.api) ⇒ Array<String>
Returns all computer udids in the jss.
327 328 329 |
# File 'lib/jss/api_object/computer.rb', line 327 def self.all_udids(refresh = false, api: JSS.api) all(refresh, api: api).map { |i| i[:udid] } end |
.all_unmanaged(refresh = false, api: JSS.api) ⇒ Array<Hash>
Returns all unmanaged computers in the jss.
337 338 339 |
# File 'lib/jss/api_object/computer.rb', line 337 def self.all_unmanaged(refresh = false, api: JSS.api) all(refresh, api: api).reject { |d| d[:managed] } end |
.all_xserves(refresh = false, api: JSS.api) ⇒ Array<Hash>
Returns all xserves in the jss.
362 363 364 |
# File 'lib/jss/api_object/computer.rb', line 362 def self.all_xserves(refresh = false, api: JSS.api) all(refresh, api: api).select { |d| d[:model] =~ /serve/i } end |
.application_installs(appname, fields: [], version: nil, ids_only: false, api: JSS.api) ⇒ Array<Integer>, ...
Query the JSS for computers with some app installed. An app name is required as the first parameter.
If no other parameters are given, returns a Hash, one key per version of the app. For each version there is an array of Hashes, one Hash for each computer with that version. The sub hashes contain keys for the computer’s identifiers, i.e. :name, :id, :udid, :serial_number, :mac_address.
If one or more inventory fields are provided in the ‘fields’ parameter, each computer’s hash also has keys and values for those fields if they exist in the JSS. These fields are those available in the display options for Advanced Computer Searches (including extention attribute names) and their names are case-sensitive, so ‘Username’, not ‘username’
If a specific version is provided in the ‘version’ parameter, only computers containing that version of the app are returned as an Array of Hashes.
If the ids_only parameter is truthy, an Array of JSS id numbers for computers with this app is returned. In this case the ‘fields’ parameter is ignored, however the ‘version’ parameters is still valid and will restrict the list to those computer ids with that version installed.
This method implements the ‘computerapplications’ API endpoint.
NOTE: To see all the apps installed on a specific computer, fetch the JSS::Computer instance and call its #apps method.
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/jss/api_object/computer/application_installs.rb', line 96 def self.application_installs(appname, fields: [], version: nil, ids_only: false, api: JSS.api) fields = [fields] unless fields.is_a? Array rsrc = "#{COMPUTER_APPLICATIONS_RSRC}/#{appname}" rsrc << "/version/#{version}" if version rsrc << "/inventory/#{fields.join ','}" unless ids_only || fields.empty? # get_rsrc will URI.encode the rsrc result = api.get_rsrc(rsrc)[:computer_applications] return result[:unique_computers].map { |c| c[:id] } if ids_only if version.nil? hash_by_version = {} result[:versions].each { |v| hash_by_version[v[:number]] = v[:computers] } return hash_by_version end result[:versions].first[:computers] end |
.application_usage(ident, start_date, end_date = nil, api: JSS.api) ⇒ Hash{Date=>Array<Hash>}
Retrieve Application Usage data for a computer by id, without instantiation.
412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 |
# File 'lib/jss/api_object/computer.rb', line 412 def self.application_usage(ident, start_date, end_date = nil, api: JSS.api) id = valid_id ident, api: api raise "No computer matches identifier: #{ident}" unless id end_date ||= start_date start_date = Time.parse start_date if start_date.is_a? String end_date = Time.parse end_date if end_date.is_a? String unless ([start_date.class, end_date.class] - APPLICATION_USAGE_DATE_CLASSES).empty? raise JSS::InvalidDataError, 'Invalid Start or End Date' end start_date = start_date.strftime APPLICATION_USAGE_DATE_FMT end_date = end_date.strftime APPLICATION_USAGE_DATE_FMT data = api.get_rsrc(APPLICATION_USAGE_RSRC + "/id/#{id}/#{start_date}_#{end_date}") parsed_data = {} data[APPLICATION_USAGE_KEY].each do |day_hash| date = Date.parse day_hash[:date] parsed_data[date] = day_hash[:apps] end parsed_data end |
.checkin_settings(api: JSS.api) ⇒ Hash
Display the current Computer CheckIn settings in the JSS. Currently this is read-only in ruby-jss, even tho the API allows updating.
273 274 275 |
# File 'lib/jss/api_object/computer.rb', line 273 def self.checkin_settings(api: JSS.api) api.get_rsrc(CHECKIN_RSRC)[CHECKIN_KEY] end |
.inventory_collection_settings(api: JSS.api) ⇒ Hash
Display the current Computer Inventory Collection settings in the JSS. Currently this is read-only in ruby-jss, even tho the API allows updating.
287 288 289 |
# File 'lib/jss/api_object/computer.rb', line 287 def self.inventory_collection_settings(api: JSS.api) api.get_rsrc(INV_COLLECTION_RSRC)[INV_COLLECTION_KEY] end |
.management_data(ident, subset: nil, only: nil, api: JSS.api) ⇒ Hash, Array
The ‘computer management’ data for a given computer by id, looked up on the fly.
Without specifying a subset:, the entire dataset is returned as a hash of arrays, one per subset
If a subset is given then only that array is returned, and it contains hashes with data about each item (usually :name and :id)
If the only: param is provided with a subset, it is used as a hash-key to map the array to just those values, so subset: :smart_groups, only: :name will return an array of names of smartgroups that contain the computer.
463 464 465 466 467 468 469 470 471 |
# File 'lib/jss/api_object/computer.rb', line 463 def self.management_data(ident, subset: nil, only: nil, api: JSS.api) id = valid_id ident, api: api raise "No computer matches identifier: #{ident}" unless id if subset management_data_subset id, subset: subset, only: only, api: api else full_management_data id, api: api end end |
Instance Method Details
#app_store_app_history(status = nil) ⇒ Object Also known as: managed_app_history Originally defined in module ManagementHistory
Wrapper for app store history for both computers and mobile devices
#app_store_apps(only: nil) ⇒ Object
A shortcut for ‘management_data subset: :mac_app_store_apps’
905 906 907 |
# File 'lib/jss/api_object/computer.rb', line 905 def app_store_apps(only: nil) management_data subset: :mac_app_store_apps, only: only end |
#application_usage(start_date, end_date = nil) ⇒ Object
Get application usage data for this computer for a given date range. See application_usage for details
858 859 860 |
# File 'lib/jss/api_object/computer.rb', line 858 def application_usage(start_date, end_date = nil) JSS::Computer.application_usage @id, start_date, end_date, api: @api end |
#apps ⇒ Array<Hash>
Returns all apps installed on this machine. Hash keys are :name, :path, and :version.
843 844 845 |
# File 'lib/jss/api_object/computer.rb', line 843 def apps @software[:applications] end |
#audit_history ⇒ Object Also known as: audits Originally defined in module ManagementHistory
The audit_history for this object
#blank_push ⇒ void Also known as: send_blank_push, noop Originally defined in module MDM
This method returns an undefined value.
Send a blank push to this object
#boot_drive ⇒ Hash?
Returns The hardware hash of the boot drive.
829 830 831 |
# File 'lib/jss/api_object/computer.rb', line 829 def boot_drive drives.select { |d| d[:partition] && d[:partition][:type] == 'boot' }.first end |
#casper_imaging_logs ⇒ Object Originally defined in module ManagementHistory
The casper_imaging_logs for this computer
#casper_remote_logs ⇒ Object Originally defined in module ManagementHistory
The casper_remote_logs for this computer
#clear_location ⇒ void Originally defined in module Locatable
This method returns an undefined value.
Clear all location data
#clear_passcode ⇒ Object Originally defined in module MDM
Send an clear_passcode command to this object
#clear_restrictions_password ⇒ Object Originally defined in module MDM
Send an clear_restrictions_password command to this object
#clone(new_name, api: nil) ⇒ APIObject Originally defined in module Creatable
make a clone of this API object, with a new name. The class must be creatable
#completed_mdm_commands ⇒ Object Also known as: completed_commands Originally defined in module ManagementHistory
The completed_mdm_commands for this object
#completed_policies ⇒ Object Originally defined in module ManagementHistory
The array from .policy_logs, limited to status = :completed
#computer_groups ⇒ Array
Returns the JSS groups to which thismachine belongs (smart and static).
796 797 798 |
# File 'lib/jss/api_object/computer.rb', line 796 def computer_groups @groups_accounts[:computer_group_memberships] end |
#computer_usage_logs ⇒ Object Also known as: usage_logs Originally defined in module ManagementHistory
The computer_usage_logs for this computer
#create(api: nil) ⇒ Integer Originally defined in module Creatable
Create a new object in the JSS.
#delete ⇒ void
This method returns an undefined value.
Delete this computer from the JSS
1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 |
# File 'lib/jss/api_object/computer.rb', line 1032 def delete super @alt_mac_address = nil @asset_tag = nil @barcode1 = nil @barcode2 = nil @distribution_point = nil @initial_entry_date = nil @ip_address = nil @jamf_version = nil @last_contact_time = nil @macaddress = nil @managed = nil @management_username = nil @mdm_capable = nil @netboot_server = nil @platform = nil @report_date = nil @serial_number = nil @site = nil @sus = nil @udid = nil @building = nil @department = nil @email_address = nil @phone = nil @position = nil @real_name = nil @room = nil @username = nil @configuration_profiles = nil @extension_attributes = nil @groups_accounts = nil @hardware = nil @peripherals = nil @purchasing = nil @software = nil end |
#delete_user(user) ⇒ Object Originally defined in module MDM
Send a delete_user command to this computer or group
#device_lock(passcode_or_message = '') ⇒ Object Also known as: lock, lock_device Originally defined in module MDM
Send a dev lock to this object
#device_name(name) ⇒ Object Also known as: set_name, set_device_name Originally defined in module MDM
Send a device_name command to this object
#disable_app_analytics ⇒ Object Originally defined in module MDM
Send a disable_app_analytics command to this object
#disable_data_roaming ⇒ Object Originally defined in module MDM
Send a disable_data_roaming command to this object
#disable_diagnostic_submission ⇒ Object Originally defined in module MDM
Send a disable_diagnostic_submission command to this object
#disable_lost_mode ⇒ Object Originally defined in module MDM
Send a disable_lost_mode command to this object
#disable_voice_roaming ⇒ Object Originally defined in module MDM
Send a disable_voice_roaming command to this object
#drives ⇒ Array<Hash>
Returns each storage device.
823 824 825 |
# File 'lib/jss/api_object/computer.rb', line 823 def drives @hardware[:storage] end |
#ebook_history(status = nil) ⇒ Object Also known as: managed_ebook_history Originally defined in module ManagementHistory
The ebook_history for this mobile device
#ebooks(only: nil) ⇒ Object
A shortcut for ‘management_data subset: :ebooks’
899 900 901 |
# File 'lib/jss/api_object/computer.rb', line 899 def ebooks(only: nil) management_data subset: :ebooks, only: only, refresh: refresh end |
#enable_app_analytics ⇒ Object Originally defined in module MDM
Send an enable_app_analytics command to this object
#enable_data_roaming ⇒ Object Originally defined in module MDM
Send an enable_data_roaming command to this object
#enable_diagnostic_submission ⇒ Object Originally defined in module MDM
Send an enable_diagnostic_submission command to this object
#enable_lost_mode(message: nil, phone_number: nil, footnote: nil, enforce_lost_mode: true, play_sound: false) ⇒ Object Originally defined in module MDM
Send a enable_lost_mode command to one or more targets
Either or both of message and phone number must be provided
#enable_voice_roaming ⇒ Object Originally defined in module MDM
Send an enable_voice_roaming command to this object
#erase_device(passcode = '', preserve_data_plan: false) ⇒ Object Also known as: wipe_device, wipe_computer, wipe, erase Originally defined in module MDM
Send an erase device command to this object
#ext_attr_xml ⇒ REXML::Element Originally defined in module Extendable
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
TODO: make this (and all XML amending) method take the in-progress XML doc and add (or not) the EA xml to it. See how Sitable#add_site_to_xml works, as called from Computer.rest_xml
#failed_app_store_apps ⇒ Object Also known as: failed_managed_apps Originally defined in module ManagementHistory
shortcut for app_store_app_history where status = :failed
#failed_ebooks ⇒ Object Also known as: failed_managed_ebooks Originally defined in module ManagementHistory
shortcut for ebook_history where status = :failed
#failed_mdm_commands ⇒ Object Also known as: failed_commands Originally defined in module ManagementHistory
The failed_mdm_commands for this object
#failed_policies ⇒ Object Originally defined in module ManagementHistory
The array from .policy_logs, limited to status = :failed
#filevault1_accounts ⇒ Array<Hash>
Returns The local_accounts Array that have Legacy FV enabled.
816 817 818 819 |
# File 'lib/jss/api_object/computer.rb', line 816 def filevault1_accounts return [] if filevault2_enabled? local_accounts.select { |a| a[:filevault_enabled] } end |
#filevault2_enabled? ⇒ Boolean
Returns is FileVault2 enabled?.
810 811 812 |
# File 'lib/jss/api_object/computer.rb', line 810 def filevault2_enabled? boot_drive[:partition][:filevault2_status] != 'Not Encrypted' end |
#flush_mdm_commands(status) ⇒ void Originally defined in module MDM
This method returns an undefined value.
flush pending and/or failed MDM commands for this object
#has_location? ⇒ Boolean Originally defined in module Locatable
Returns Does this item have location data?.
#has_purchasing? ⇒ Boolean Originally defined in module Purchasable
Returns does this item have any purchasing info?.
#installed_app_store_apps ⇒ Object Also known as: installed_managed_apps Originally defined in module ManagementHistory
shortcut for app_store_app_history where status = :installed
#installed_ebooks ⇒ Object Also known as: installed_managed_ebooks Originally defined in module ManagementHistory
shortcut for ebook_history where status = :installed
#licensed_sw ⇒ Array<String>
Returns the JSS-defined “licensed software” titles installed on this machine.
850 851 852 |
# File 'lib/jss/api_object/computer.rb', line 850 def licensed_sw @software[:licensed_software] end |
#local_accounts ⇒ Array<Hash> Also known as: accounts, accts
Each item has keys :name, :realname, :uid, :home, :home_size, :administrator, :filevault_enabled
804 805 806 |
# File 'lib/jss/api_object/computer.rb', line 804 def local_accounts @groups_accounts[:local_accounts] end |
#location ⇒ Hash<String> Originally defined in module Locatable
All the location data in a Hash, as it comes from the API.
The reason it isn’t stored this way is to prevent editing of the hash directly.
#location_xml ⇒ REXML::Element Originally defined in module Locatable
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Return a REXML <location> element to be included in the rest_xml of objects that have a Location subset
#mac_app_store_app_history(status = nil) ⇒ Object Originally defined in module ManagementHistory
The mac_app_store_app_history for this computer
#make_unmanaged ⇒ void
953 954 955 956 957 |
# File 'lib/jss/api_object/computer.rb', line 953 def make_unmanaged return nil unless managed? set_management_to(nil, nil) @unmange_at_update = true end |
#management_data(subset: nil, only: nil) ⇒ Object
The ‘computer management’ data for this computer
NOTE: the data isn’t cached locally, and the API is queried every time
868 869 870 871 |
# File 'lib/jss/api_object/computer.rb', line 868 def management_data(subset: nil, only: nil) raise JSS::NoSuchItemError, 'Computer not yet saved in the JSS' unless @in_jss JSS::Computer.management_data @id, subset: subset, only: only, api: @api end |
#management_history(subset = nil) ⇒ Object Also known as: history Originally defined in module ManagementHistory
The raw management history data for this object
#mdm_command_history(status = nil) ⇒ Object Also known as: commands, management_command_history Originally defined in module ManagementHistory
The mdm_command_history for this object
#mobile_device_app_history(status = nil) ⇒ Object Originally defined in module ManagementHistory
The mobile_device_app_history for this mobile device
#name=(newname) ⇒ void Originally defined in module Updatable
This method returns an undefined value.
Change the name of this item Remember to #update to push changes to the server.
#parse_ext_attrs ⇒ void Originally defined in module Extendable
This method returns an undefined value.
Populate @extension_attributes (the Array of Hashes that comes from the API) and @ext_attr_names, which is a Hash mapping the EA names to their values. This is called during initialization for all objects that mix in this module
#parse_location ⇒ void Originally defined in module Locatable
This method returns an undefined value.
Call this during initialization of objects that have a Location subset and the location attributes will be populated (as primary attributes) from @init_data
#parse_purchasing ⇒ Object Originally defined in module Purchasable
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Call this during initialization of objects that have a Purchasing subset and the purchasing attribute will be populated from @init_data
#passcode_lock_grace_period(secs) ⇒ Object Originally defined in module MDM
Send a passcode_lock_grace_period command to this object
#patch_titles(only: nil) ⇒ Object
A shortcut for ‘management_data subset: :patch_reporting_software_titles’
917 918 919 |
# File 'lib/jss/api_object/computer.rb', line 917 def patch_titles(only: nil) management_data subset: :patch_reporting_software_titles, only: only end |
#pending_app_store_apps ⇒ Object Also known as: pending_managed_apps Originally defined in module ManagementHistory
shortcut for app_store_app_history where status = :pending
#pending_ebooks ⇒ Object Also known as: pending_managed_ebooks Originally defined in module ManagementHistory
shortcut for ebook_history where status = :pending
#pending_mdm_commands ⇒ Object Also known as: pending_commands Originally defined in module ManagementHistory
The pending_mdm_commands for this object
#play_lost_mode_sound ⇒ Object Originally defined in module MDM
Send a play_lost_mode_sound command to this object
#policies(only: nil) ⇒ Object
A shortcut for ‘management_data subset: :policies’
887 888 889 |
# File 'lib/jss/api_object/computer.rb', line 887 def policies(only: nil) management_data subset: :policies, only: only end |
#policy_logs ⇒ Object Originally defined in module ManagementHistory
The policy_logs for this computer
#printers ⇒ Array<Hash>
Returns each printer on this computer Keys are :name, :uri, :type, :location.
836 837 838 |
# File 'lib/jss/api_object/computer.rb', line 836 def printers @hardware[:mapped_printers] end |
#purchasing ⇒ Hash<String> Originally defined in module Purchasable
All the purchasing data in a Hash, as it comes from the API.
The reason it isn’t stored this way is to prevent editing of the hash directly.
#purchasing_xml ⇒ REXML::Element Originally defined in module Purchasable
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns A <purchasing> element to be included in the rest_xml of objects that mix-in this module.
#restart_device ⇒ Object Also known as: restart Originally defined in module MDM
Send a restart_device command to this object
#restricted_software(only: nil) ⇒ Object
A shortcut for ‘management_data subset: :restricted_software’
911 912 913 |
# File 'lib/jss/api_object/computer.rb', line 911 def restricted_software(only: nil) management_data subset: :restricted_software, only: only end |
#screen_sharing_logs ⇒ Object Originally defined in module ManagementHistory
The screen_sharing_logs for this computer
#set_ext_attr(name, value) ⇒ void Originally defined in module Extendable
This method returns an undefined value.
Set the value of an extension attribute
If the extension attribute is defined as a popup menu, the value must be one of the defined popup choices, or an empty string
If the ext. attrib. is defined with a data type of Integer, the value must be an Integer.
If the ext. attrib. is defined with a data type of Date, the value will be converted to a Time
Note that while the Jamf Pro Web interface does not allow editing the values of Extension Attributes populated by Scripts or LDAP, the API does allow it. Bear in mind however that those values will be reset again at the next recon.
#set_management_to(name, password) ⇒ void Also known as: make_managed
This method returns an undefined value.
Set or unset management acct and password for this computer
The changes will need to be pushed to the server with #update before they take effect.
CAUTION: this does nothing to confirm the name and password will work on the machine!
935 936 937 938 939 940 941 |
# File 'lib/jss/api_object/computer.rb', line 935 def set_management_to(name, password) password = nil unless name @management_username = name @management_password = password @managed = name ? true : false @need_to_update = true end |
#shut_down_device ⇒ Object Also known as: shutdown_device, shut_down, shutdown Originally defined in module MDM
Send a shut_down_device command to this object
#site=(new_site) ⇒ void Originally defined in module Sitable
This method returns an undefined value.
Change the site of this object. Any of the NON_SITES values will unset the site
#site_assigned? ⇒ Boolean Originally defined in module Sitable
Does this object have a site assigned?
#site_id ⇒ Integer Originally defined in module Sitable
The id of the site for this object.
#site_name ⇒ String Also known as: site Originally defined in module Sitable
The name of the site for this object. For backward compatibility, this is aliased to just ‘site’
#site_object ⇒ JSS::Site Originally defined in module Sitable
The JSS::Site instance for this object’s site
#smart_groups(only: nil) ⇒ Object
A shortcut for ‘management_data subset: :smart_groups’
875 876 877 |
# File 'lib/jss/api_object/computer.rb', line 875 def smart_groups(only: nil) management_data subset: :smart_groups, only: only end |
#static_groups(only: nil) ⇒ Object
A shortcut for ‘management_data subset: :static_groups’
881 882 883 |
# File 'lib/jss/api_object/computer.rb', line 881 def static_groups(only: nil) management_data subset: :static_groups, only: only end |
#unlock_user_account(user) ⇒ Object Originally defined in module MDM
Send an unlock_user_account command to this computer or group
#unmanage_device ⇒ Object Also known as: remove_mdm_profile Originally defined in module MDM
Send an unmanage device command to this object
NOTE: when used with computers, the mdm profile will probably be re-installed immediately unless the computer is also no longer managed by Jamf Pro itself. To fully unmanage a computer, use the Computer#make_unmanaged instance method.
#unsaved_eas? ⇒ Boolean Originally defined in module Extendable
are there any changes in the EAs needing to be saved?
#unset_site ⇒ void Originally defined in module Sitable
This method returns an undefined value.
Set the site to nothing
#update ⇒ void
This method returns an undefined value.
Send changes to the API
1022 1023 1024 1025 1026 |
# File 'lib/jss/api_object/computer.rb', line 1022 def update remove_mdm_profile if mdm_capable && @unmange_at_update @unmange_at_update = false super end |
#update_inventory ⇒ Object Also known as: recon Originally defined in module MDM
Send an update_inventory command to this object
#upload(type, local_file) ⇒ String Originally defined in module Uploadable
Upload a file to the JSS via the REST Resource of the object to which this module is mixed in.
#user_location_history ⇒ Object Originally defined in module ManagementHistory
The user_location_history for this object