Class: JSS::Computer
- Extended by:
- Matchable
- Includes:
- Extendable, Locatable, Purchasable, Updatable, Uploadable
- Defined in:
- lib/jss/api_object/computer.rb,
lib/jss.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
The following methods can be used to send an APNS command to the computer represented by an instance of JSS::Computer, equivalent to clicking one of the buttons on the Management Commands section of the Management tab of the Computer details page in the JSS UI.
-
#blank_push (aliases blank, noop, send_blank_push)
-
#device_lock (aliases lock, lock_device)
-
#erase_device (aliases wipe)
To send an MDM command without making a Computer instance, use the class Computer.send_mdm_command which can take multiple computer identifiers at once.
NOTE: the poorly named ‘UnmanageDevice’ command via the API is implemented as the #remove_mdm_profile method (which is its name in the webUI). Calling that method will NOT unmanage the machine 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
The #make_unmanaged method also removes the mdm profile, but actually does make the machine unmanged by the JSS, setting the management acct to nil, and requring re-enrollment.
Computer History
Computer instances can now retrieve their management history from the JSS.
The full history data is available from the #history method, but beware that it is very large.
Subsets of that history have their own methods, which are faster and only retrieve the subset requested. See #usage_logs, #audits, #policy_los, #completed_policies, #failed_polices, #casper_remote_logs, #screen_sharing_logs, #casper_imaging_logs, #commands, #user_location_history,and #app_store_app_history
When any of the history methods is used the first time, the data is read from the API and cached internally, and that data is used for all future calls.. To re-read the data from the API and re-cache it, provide any non-false parameter to the subset methods , or ‘refresh: true` to the main #history method.
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- 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
- COMPUTER_MDM_RSRC =
The base REST resource for sending computer MDM commands
'computercommands/command'.freeze
- COMPUTER_MDM_COMMANDS =
A mapping of Symbols available to the send_mdm_command class method, to the String commands actuallly sent via the API.
{ blank_push: 'BlankPush', blankpush: 'BlankPush', send_blank_push: 'BlankPush', blank: 'BlankPush', noop: 'BlankPush', device_lock: 'DeviceLock', devicelock: 'DeviceLock', lock: 'DeviceLock', lock_device: 'DeviceLock', erase_device: 'EraseDevice', erasedevice: 'EraseDevice', erase: 'EraseDevice', wipe: 'EraseDevice', unmanage_device: 'UnmanageDevice', unmanagedevice: 'UnmanageDevice', unmanage: 'UnmanageDevice' }.freeze
- COMPUTER_MDM_COMMANDS_NEEDING_PASSCODE =
these MDM commands require a passcode
%w[DeviceLock EraseDevice].freeze
- 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- HISTORY_RSRC =
The API Resource for the computer history data
'computerhistory'.freeze
- HISTORY_KEY =
The top-level hash key for the history data
:computer_history- HISTORY_SUBSETS =
The keys are both the subset names in the resrouce URLS (when converted to strings) and the second-level hash key of the returned subset data.
The values are the key within each history item that contains the ‘epoch’ timestamp, for conver
i[ computer_usage_logs audits policy_logs casper_remote_logs screen_sharing_logs casper_imaging_logs commands user_location mac_app_store_applications ].freeze
- POLICY_STATUS_COMPLETED =
HISTORY_SUBSETS = %i(
computer_usage_logs date_time_epoch audits policy_logs date_completed_epoch casper_remote_logs date_time_epoch screen_sharing_logs date_time_epoch casper_imaging_logs commands completed_epoch user_location mac_app_store_applications).freeze
'Completed'.freeze
- POLICY_STATUS_FAILED =
'Failed'.freeze
- POLICY_STATUS_PENDING =
'Pending'.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.
-
#barcode_1 ⇒ String
(also: #bar_code_1)
The barcodes.
-
#barcode_2 ⇒ String
(also: #bar_code_2)
The barcodes.
- #building ⇒ String included from Locatable
-
#configuration_profiles(only: nil, refresh: false) ⇒ 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
-
#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?.
-
#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.
-
.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.
-
.match(term, api: JSS.api) ⇒ Array<Hash>
extended
from Matchable
Perform a match, returning an Array of Hashes, one for each item matched.
-
.send_mdm_command(targets, command, passcode = nil, api: JSS.api) ⇒ String
Send an MDM command to one or more managed computers by id or name.
Instance Method Summary collapse
-
#app_store_app_history(refresh = false) ⇒ Object
Shortcut for history(:mac_app_store_applications).
-
#app_store_apps(only: nil, refresh: false) ⇒ Object
A shortcut for ‘management_data subset: :mac_app_store_apps’.
-
#application_usage(start_date, end_date = nil) ⇒ Hash{Date=>Array<Hash>}
Get application usage data for this computer for a given date range.
-
#apps ⇒ Array<Hash>
All apps installed on this machine.
-
#audits(refresh = false) ⇒ Object
Shortcut for history(:audits).
-
#blank_push ⇒ Object
(also: #noop, #send_blank_push)
Send a blank_push MDM command.
-
#boot_drive ⇒ Hash?
The hardware hash of the boot drive.
-
#casper_imaging_logs(refresh = false) ⇒ Object
Shortcut for history(:casper_imaging_logs).
-
#casper_remote_logs(refresh = false) ⇒ Object
Shortcut for history(:casper_remote_logs).
-
#clear_location ⇒ void
included
from Locatable
Clear all location data.
-
#commands(refresh = false) ⇒ Object
Shortcut for history(:commands).
-
#completed_policies(refresh = false) ⇒ Object
Shortcut for history(:policy_logs), but just the completed policies.
-
#computer_groups ⇒ Array
The JSS groups to which thismachine belongs (smart and static).
-
#delete ⇒ void
Delete this computer from the JSS.
-
#device_lock(passcode) ⇒ Object
(also: #lock, #lock_device)
Send a device_lock MDM command.
-
#drives ⇒ Array<Hash>
Each storage device.
-
#ebooks(only: nil, refresh: false) ⇒ Object
A shortcut for ‘management_data subset: :ebooks’.
-
#erase_device(passcode) ⇒ Object
(also: #erase, #wipe)
Send an erase_device MDM command.
-
#ext_attr_xml ⇒ REXML::Element
included
from Extendable
private
An <extension_attribute> element to be included in the rest_xml of objects that mix-in this module.
-
#failed_policies(refresh = false) ⇒ Object
Shortcut for history(:policy_logs), but just the failes policies.
-
#filevault1_accounts ⇒ Array<Hash>
The local_accounts Array that have Legacy FV enabled.
-
#filevault2_enabled? ⇒ Boolean
Is FileVault2 enabled?.
-
#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?.
-
#history(subset: nil, refresh: false) ⇒ Hash, Array
Return this computer’s history.
-
#initialize(args = {}) ⇒ Computer
constructor
As well as :id and :name, computers can be queried using :udid, :serialnumber, and :mac_address.
-
#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.
-
#make_unmanaged ⇒ void
Make the machine unmanaged.
-
#management_data(subset: nil, only: nil, refresh: false) ⇒ Hash, Array
The ‘computer management’ data for this computer, looked up on the fly.
-
#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 index in the @extension_attributes Array.
-
#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.
-
#patch_titles(only: nil, refresh: false) ⇒ Object
A shortcut for ‘management_data subset: :patch_reporting_software_titles’.
-
#policies(only: nil, refresh: false) ⇒ Object
A shortcut for ‘management_data subset: :policies’.
-
#policy_logs(refresh = false) ⇒ Object
Shortcut for history(:policy_logs).
-
#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.
-
#remove_mdm_profile ⇒ Object
Remove MDM management profile without un-enrolling from the JSS or resetting the JSS management acct.
-
#restricted_software(only: nil, refresh: false) ⇒ Object
A shortcut for ‘management_data subset: :restricted_software’.
-
#screen_sharing_logs(refresh = false) ⇒ Object
Shortcut for history(:screen_sharing_logs).
-
#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.
-
#smart_groups(only: nil, refresh: false) ⇒ Object
A shortcut for ‘management_data subset: :smart_groups’.
-
#static_groups(only: nil, refresh: false) ⇒ Object
A shortcut for ‘management_data subset: :static_groups’.
-
#update ⇒ void
Send changes to the API.
-
#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.
-
#usage_logs(refresh = false) ⇒ Object
Shortcut for history(:computer_usage_logs).
-
#user_location_history(refresh = false) ⇒ Object
Shortcut for history(:user_location).
Constructor Details
#initialize(args = {}) ⇒ Computer
As well as :id and :name, computers can be queried using :udid, :serialnumber, and :mac_address
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 |
# File 'lib/jss/api_object/computer.rb', line 739 def initialize(args = {}) super args # now we have raw @init_data with something in it, so fill out the instance vars @alt_mac_address = @init_data[:general][:alt_mac_address] @asset_tag = @init_data[:general][:asset_tag] = @init_data[:general][:barcode_1] = @init_data[:general][:barcode_2] @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] @jamf_version = @init_data[:general][:jamf_version] @last_contact_time = JSS.epoch_to_time @init_data[:general][:last_contact_time_epoch] @mac_address = @init_data[:general][:mac_address] @managed = @init_data[:general][:remote_management][:managed] @management_username = @init_data[:general][:remote_management][:management_username] @mdm_capable = @init_data[:general][:mdm_capable] @netboot_server = @init_data[:general][:netboot_server] @platform = @init_data[:general][:platform] @report_date = JSS.epoch_to_time @init_data[:general][:report_date_epoch] @serial_number = @init_data[:general][:serial_number] @site = JSS::APIObject.get_name(@init_data[:general][:site]) @sus = @init_data[:general][:sus] @udid = @init_data[:general][:udid] @configuration_profiles = @init_data[:configuration_profiles] @extension_attributes = @init_data[:extension_attributes] @groups_accounts = @init_data[:groups_accounts] @hardware = @init_data[:hardware] @peripherals = @init_data[:peripherals] @software = @init_data[:software] @management_password = nil end |
Instance Attribute Details
#alt_mac_address ⇒ String Also known as: alt_macaddress
Returns the secondary mac address.
520 521 522 |
# File 'lib/jss/api_object/computer.rb', line 520 def alt_mac_address @alt_mac_address end |
#applecare_id ⇒ String Originally defined in module Purchasable
#asset_tag ⇒ String
Returns the asset tag.
523 524 525 |
# File 'lib/jss/api_object/computer.rb', line 523 def asset_tag @asset_tag end |
#barcode_1 ⇒ String Also known as: bar_code_1
Returns the barcodes.
526 527 528 |
# File 'lib/jss/api_object/computer.rb', line 526 def end |
#barcode_2 ⇒ String Also known as: bar_code_2
Returns the barcodes.
526 527 528 |
# File 'lib/jss/api_object/computer.rb', line 526 def end |
#configuration_profiles(only: nil, refresh: false) ⇒ Object (readonly)
A shortcut for ‘management_data subset: :os_x_configuration_profiles’
591 592 593 |
# File 'lib/jss/api_object/computer.rb', line 591 def configuration_profiles @configuration_profiles end |
#distribution_point ⇒ String (readonly)
Returns The name of the distribution point for this computer.
529 530 531 |
# File 'lib/jss/api_object/computer.rb', line 529 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
-
609 610 611 |
# File 'lib/jss/api_object/computer.rb', line 609 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
-
-
669 670 671 |
# File 'lib/jss/api_object/computer.rb', line 669 def hardware @hardware end |
#initial_entry_date ⇒ Time (readonly)
Returns when was it added to the JSS.
532 533 534 |
# File 'lib/jss/api_object/computer.rb', line 532 def initial_entry_date @initial_entry_date end |
#ip_address ⇒ IPAddr
Returns the last known IP address.
535 536 537 |
# File 'lib/jss/api_object/computer.rb', line 535 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
#jamf_version ⇒ String (readonly)
Returns the version of the jamf binary.
538 539 540 |
# File 'lib/jss/api_object/computer.rb', line 538 def jamf_version @jamf_version end |
#last_contact_time ⇒ Time (readonly)
Returns the last contact time.
541 542 543 |
# File 'lib/jss/api_object/computer.rb', line 541 def last_contact_time @last_contact_time end |
#last_enrolled ⇒ Time (readonly)
Returns the last time this machine was enrolled.
544 545 546 |
# File 'lib/jss/api_object/computer.rb', line 544 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.
547 548 549 |
# File 'lib/jss/api_object/computer.rb', line 547 def mac_address @mac_address end |
#managed ⇒ Boolean (readonly) Also known as: managed?
Returns is this machine “managed” by Casper?.
550 551 552 |
# File 'lib/jss/api_object/computer.rb', line 550 def managed @managed end |
#management_username ⇒ String (readonly)
Returns the name of the management account.
553 554 555 |
# File 'lib/jss/api_object/computer.rb', line 553 def management_username @management_username end |
#mdm_capable ⇒ Boolean (readonly) Also known as: mdm?
Returns doesit support MDM?.
556 557 558 |
# File 'lib/jss/api_object/computer.rb', line 556 def mdm_capable @mdm_capable 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.
559 560 561 |
# File 'lib/jss/api_object/computer.rb', line 559 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=>“”
-
708 709 710 |
# File 'lib/jss/api_object/computer.rb', line 708 def peripherals @peripherals end |
#platform ⇒ String (readonly)
Returns what kind of computer?.
562 563 564 |
# File 'lib/jss/api_object/computer.rb', line 562 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.
565 566 567 |
# File 'lib/jss/api_object/computer.rb', line 565 def report_date @report_date end |
#serial_number ⇒ String Also known as: sn, serialnumber
Returns the serial number.
568 569 570 |
# File 'lib/jss/api_object/computer.rb', line 568 def serial_number @serial_number end |
#site ⇒ Hash (readonly)
Returns the :name and :id of the site for this machine.
571 572 573 |
# File 'lib/jss/api_object/computer.rb', line 571 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
730 731 732 |
# File 'lib/jss/api_object/computer.rb', line 730 def software @software end |
#sus ⇒ String (readonly)
Returns the name of the Software Update Server assigned to this machine.
574 575 576 |
# File 'lib/jss/api_object/computer.rb', line 574 def sus @sus end |
#udid ⇒ String
Returns the UDID of the computer.
577 578 579 |
# File 'lib/jss/api_object/computer.rb', line 577 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.
384 385 386 387 388 |
# File 'lib/jss/api_object/computer.rb', line 384 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.
441 442 443 |
# File 'lib/jss/api_object/computer.rb', line 441 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.
446 447 448 |
# File 'lib/jss/api_object/computer.rb', line 446 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.
416 417 418 |
# File 'lib/jss/api_object/computer.rb', line 416 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.
396 397 398 |
# File 'lib/jss/api_object/computer.rb', line 396 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.
431 432 433 |
# File 'lib/jss/api_object/computer.rb', line 431 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.
426 427 428 |
# File 'lib/jss/api_object/computer.rb', line 426 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.
421 422 423 |
# File 'lib/jss/api_object/computer.rb', line 421 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.
456 457 458 |
# File 'lib/jss/api_object/computer.rb', line 456 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.
406 407 408 |
# File 'lib/jss/api_object/computer.rb', line 406 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.
451 452 453 |
# File 'lib/jss/api_object/computer.rb', line 451 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.
391 392 393 |
# File 'lib/jss/api_object/computer.rb', line 391 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.
401 402 403 |
# File 'lib/jss/api_object/computer.rb', line 401 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.
411 412 413 |
# File 'lib/jss/api_object/computer.rb', line 411 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.
436 437 438 |
# File 'lib/jss/api_object/computer.rb', line 436 def self.all_xserves(refresh = false, api: JSS.api) all(refresh, api: api).select { |d| d[:model] =~ /serve/i } 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.
347 348 349 |
# File 'lib/jss/api_object/computer.rb', line 347 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.
361 362 363 |
# File 'lib/jss/api_object/computer.rb', line 361 def self.inventory_collection_settings(api: JSS.api) api.get_rsrc(INV_COLLECTION_RSRC)[INV_COLLECTION_KEY] end |
.match(term, api: JSS.api) ⇒ Array<Hash> Originally defined in module Matchable
Perform a match, returning an Array of Hashes, one for each item matched
At the moment, it appears the search is an “exact match” search regardless of the prefs of the user connected to the API.
.send_mdm_command(targets, command, passcode = nil, api: JSS.api) ⇒ String
Send an MDM command to one or more managed computers by id or name
478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 |
# File 'lib/jss/api_object/computer.rb', line 478 def self.send_mdm_command(targets, command, passcode = nil, api: JSS.api) raise JSS::NoSuchItemError, "Unknown command '#{command}'" unless COMPUTER_MDM_COMMANDS.keys.include? command command = COMPUTER_MDM_COMMANDS[command] cmd_rsrc = "#{COMPUTER_MDM_RSRC}/#{command}" if COMPUTER_MDM_COMMANDS_NEEDING_PASSCODE.include? command unless passcode && passcode.is_a?(String) && passcode.length == 6 raise JSS::MissingDataError, "Command '#{command}' requires a 6-character passcode" end cmd_rsrc << "/passcode/#{passcode}" end targets = JSS.to_s_and_a(targets.to_s)[:arrayform] unless targets.is_a? Array # make sure its an array of ids targets.map! do |comp| if all_ids(api: api).include? comp.to_i comp.to_i elsif all_names(api: api).include? comp map_all_ids_to(:name, api: api).invert[comp] else raise JSS::NoSuchItemError, "No computer found matching '#{comp}'" end # if end # map! cmd_rsrc << "/id/#{targets.join ','}" result = api.post_rsrc cmd_rsrc, nil result =~ %r{<command_uuid>(.*)</command_uuid>} Regexp.last_match(1) end |
Instance Method Details
#app_store_app_history(refresh = false) ⇒ Object
Shortcut for history(:mac_app_store_applications)
1069 1070 1071 |
# File 'lib/jss/api_object/computer.rb', line 1069 def app_store_app_history(refresh = false) history(subset: :mac_app_store_applications, refresh: refresh) end |
#app_store_apps(only: nil, refresh: false) ⇒ Object
A shortcut for ‘management_data subset: :mac_app_store_apps’
959 960 961 |
# File 'lib/jss/api_object/computer.rb', line 959 def app_store_apps(only: nil, refresh: false) management_data subset: :mac_app_store_apps, only: only, refresh: refresh end |
#application_usage(start_date, end_date = nil) ⇒ Hash{Date=>Array<Hash>}
Get application usage data for this computer for a given date range.
TODO: Make this a class method so we can retrieve it without instantiating the Computer.
853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 |
# File 'lib/jss/api_object/computer.rb', line 853 def application_usage(start_date, end_date = nil) 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 |
#apps ⇒ Array<Hash>
Returns all apps installed on this machine. Hash keys are :name, :path, and :version.
825 826 827 |
# File 'lib/jss/api_object/computer.rb', line 825 def apps @software[:applications] end |
#audits(refresh = false) ⇒ Object
Shortcut for history(:audits)
1024 1025 1026 |
# File 'lib/jss/api_object/computer.rb', line 1024 def audits(refresh = false) history(subset: :audits, refresh: refresh) end |
#blank_push ⇒ Object Also known as: noop, send_blank_push
Send a blank_push MDM command
See JSS::Computer.send_mdm_command
1230 1231 1232 |
# File 'lib/jss/api_object/computer.rb', line 1230 def blank_push self.class.send_mdm_command @id, :blank_push, api: @api end |
#boot_drive ⇒ Hash?
Returns The hardware hash of the boot drive.
810 811 812 813 |
# File 'lib/jss/api_object/computer.rb', line 810 def boot_drive drives.each { |d| return d if d[:partition][:type] == 'boot' } nil end |
#casper_imaging_logs(refresh = false) ⇒ Object
Shortcut for history(:casper_imaging_logs)
1054 1055 1056 |
# File 'lib/jss/api_object/computer.rb', line 1054 def casper_imaging_logs(refresh = false) history(subset: :casper_imaging_logs, refresh: refresh) end |
#casper_remote_logs(refresh = false) ⇒ Object
Shortcut for history(:casper_remote_logs)
1044 1045 1046 |
# File 'lib/jss/api_object/computer.rb', line 1044 def casper_remote_logs(refresh = false) history(subset: :casper_remote_logs, refresh: refresh) end |
#clear_location ⇒ void Originally defined in module Locatable
This method returns an undefined value.
Clear all location data
#commands(refresh = false) ⇒ Object
Shortcut for history(:commands)
1059 1060 1061 |
# File 'lib/jss/api_object/computer.rb', line 1059 def commands(refresh = false) history(subset: :commands, refresh: refresh) end |
#completed_policies(refresh = false) ⇒ Object
Shortcut for history(:policy_logs), but just the completed policies
1034 1035 1036 |
# File 'lib/jss/api_object/computer.rb', line 1034 def completed_policies(refresh = false) policy_logs(refresh).select { |pl| pl[:status] == POLICY_STATUS_COMPLETED } end |
#computer_groups ⇒ Array
Returns the JSS groups to which thismachine belongs (smart and static).
777 778 779 |
# File 'lib/jss/api_object/computer.rb', line 777 def computer_groups @groups_accounts[:computer_group_memberships] end |
#delete ⇒ void
This method returns an undefined value.
Delete this computer from the JSS
1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 |
# File 'lib/jss/api_object/computer.rb', line 1185 def delete super @alt_mac_address = nil @asset_tag = nil = nil = 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 |
#device_lock(passcode) ⇒ Object Also known as: lock, lock_device
Send a device_lock MDM command
See JSS::Computer.send_mdm_command
1240 1241 1242 |
# File 'lib/jss/api_object/computer.rb', line 1240 def device_lock(passcode) self.class.send_mdm_command @id, :device_lock, passcode, api: @api end |
#drives ⇒ Array<Hash>
Returns each storage device.
804 805 806 |
# File 'lib/jss/api_object/computer.rb', line 804 def drives @hardware[:storage] end |
#ebooks(only: nil, refresh: false) ⇒ Object
A shortcut for ‘management_data subset: :ebooks’
953 954 955 |
# File 'lib/jss/api_object/computer.rb', line 953 def ebooks(only: nil, refresh: false) management_data subset: :ebooks, only: only, refresh: refresh end |
#erase_device(passcode) ⇒ Object Also known as: erase, wipe
Send an erase_device MDM command
See JSS::Computer.send_mdm_command
1250 1251 1252 |
# File 'lib/jss/api_object/computer.rb', line 1250 def erase_device(passcode) self.class.send_mdm_command @id, :erase_device, passcode, api: @api end |
#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.
Returns An <extension_attribute> element to be included in the rest_xml of objects that mix-in this module.
#failed_policies(refresh = false) ⇒ Object
Shortcut for history(:policy_logs), but just the failes policies
1039 1040 1041 |
# File 'lib/jss/api_object/computer.rb', line 1039 def failed_policies(refresh = false) policy_log(refresh).select { |pl| pl[:status] == POLICY_STATUS_FAILED } end |
#filevault1_accounts ⇒ Array<Hash>
Returns The local_accounts Array that have Legacy FV enabled.
797 798 799 800 |
# File 'lib/jss/api_object/computer.rb', line 797 def filevault1_accounts return [] if filevault2_enabled? local_accounts.select { |a| a[:filevault_enabled] } end |
#filevault2_enabled? ⇒ Boolean
Returns is FileVault2 enabled?.
791 792 793 |
# File 'lib/jss/api_object/computer.rb', line 791 def filevault2_enabled? boot_drive[:partition][:filevault2_status] != 'Not Encrypted' end |
#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?.
#history(subset: nil, refresh: false) ⇒ Hash, Array
Return this computer’s history. WARNING! Its huge, better to use a subset a nd one of the shortcut methods.
TODO: Make this a class method so we can retrieve it without instantiating the Computer.
990 991 992 993 994 995 996 997 |
# File 'lib/jss/api_object/computer.rb', line 990 def history(subset: nil, refresh: false) @history ||= {} if subset history_subset(subset: subset, refresh: refresh) else full_history refresh end end |
#licensed_sw ⇒ Array<String>
Returns the JSS-defined “licensed software” titles installed on this machine.
832 833 834 |
# File 'lib/jss/api_object/computer.rb', line 832 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
785 786 787 |
# File 'lib/jss/api_object/computer.rb', line 785 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
#make_unmanaged ⇒ void
This method returns an undefined value.
Make the machine unmanaged.
The same as
#set_management_to nil, nil
followed by
JSS::Computer.send_mdm_command @id, :unmanage_device
which currently isn’t working
1105 1106 1107 1108 1109 |
# File 'lib/jss/api_object/computer.rb', line 1105 def make_unmanaged return nil unless managed? set_management_to(nil, nil) @unmange_at_update = true end |
#management_data(subset: nil, only: nil, refresh: false) ⇒ Hash, Array
The ‘computer management’ data for this computer, 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 this computer.
TODO: Make this a class method so we can retrieve it without instantiating the Computer.
898 899 900 901 902 903 904 905 |
# File 'lib/jss/api_object/computer.rb', line 898 def management_data(subset: nil, only: nil, refresh: false) @management_data ||= {} if subset management_data_subset(subset: subset, only: only, refresh: refresh) else full_management_data refresh end end |
#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 index in the @extension_attributes Array.
Classes including this module should call this in #initialize
#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
#patch_titles(only: nil, refresh: false) ⇒ Object
A shortcut for ‘management_data subset: :patch_reporting_software_titles’
971 972 973 |
# File 'lib/jss/api_object/computer.rb', line 971 def patch_titles(only: nil, refresh: false) management_data subset: :patch_reporting_software_titles, only: only, refresh: refresh end |
#policies(only: nil, refresh: false) ⇒ Object
A shortcut for ‘management_data subset: :policies’
941 942 943 |
# File 'lib/jss/api_object/computer.rb', line 941 def policies(only: nil, refresh: false) management_data subset: :policies, only: only, refresh: refresh end |
#policy_logs(refresh = false) ⇒ Object
Shortcut for history(:policy_logs)
1029 1030 1031 |
# File 'lib/jss/api_object/computer.rb', line 1029 def policy_logs(refresh = false) history(subset: :policy_logs, refresh: refresh) end |
#printers ⇒ Array<Hash>
Returns each printer on this computer Keys are :name, :uri, :type, :location.
818 819 820 |
# File 'lib/jss/api_object/computer.rb', line 818 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.
#remove_mdm_profile ⇒ Object
Remove MDM management profile without un-enrolling from the JSS or resetting the JSS management acct.
To do those things as well, see #make_unmanaged
See JSS::Computer.send_mdm_command
1264 1265 1266 |
# File 'lib/jss/api_object/computer.rb', line 1264 def remove_mdm_profile self.class.send_mdm_command @id, :unmanage_device, api: @api end |
#restricted_software(only: nil, refresh: false) ⇒ Object
A shortcut for ‘management_data subset: :restricted_software’
965 966 967 |
# File 'lib/jss/api_object/computer.rb', line 965 def restricted_software(only: nil, refresh: false) management_data subset: :restricted_software, only: only, refresh: refresh end |
#screen_sharing_logs(refresh = false) ⇒ Object
Shortcut for history(:screen_sharing_logs)
1049 1050 1051 |
# File 'lib/jss/api_object/computer.rb', line 1049 def screen_sharing_logs(refresh = false) history(subset: :screen_sharing_logs, refresh: refresh) end |
#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.
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
#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!
1087 1088 1089 1090 1091 1092 1093 |
# File 'lib/jss/api_object/computer.rb', line 1087 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 |
#smart_groups(only: nil, refresh: false) ⇒ Object
A shortcut for ‘management_data subset: :smart_groups’
929 930 931 |
# File 'lib/jss/api_object/computer.rb', line 929 def smart_groups(only: nil, refresh: false) management_data subset: :smart_groups, only: only, refresh: refresh end |
#static_groups(only: nil, refresh: false) ⇒ Object
A shortcut for ‘management_data subset: :static_groups’
935 936 937 |
# File 'lib/jss/api_object/computer.rb', line 935 def static_groups(only: nil, refresh: false) management_data subset: :static_groups, only: only, refresh: refresh end |
#update ⇒ void
This method returns an undefined value.
Send changes to the API
1174 1175 1176 1177 1178 1179 |
# File 'lib/jss/api_object/computer.rb', line 1174 def update id = super remove_mdm_profile if mdm_capable && managed? && @unmange_at_update @unmange_at_update = false id end |
#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.
#usage_logs(refresh = false) ⇒ Object
Shortcut for history(:computer_usage_logs)
1019 1020 1021 |
# File 'lib/jss/api_object/computer.rb', line 1019 def usage_logs(refresh = false) history(subset: :computer_usage_logs, refresh: refresh) end |
#user_location_history(refresh = false) ⇒ Object
Shortcut for history(:user_location)
1064 1065 1066 |
# File 'lib/jss/api_object/computer.rb', line 1064 def user_location_history(refresh = false) history(subset: :user_location, refresh: refresh) end |