Class: Jamf::Computer

Inherits:
APIObject show all
Extended by:
Matchable
Includes:
ComputerRecoveryLock, Creatable, Extendable, FileVault, Locatable, MDM, MacOSManagedUpdates, MacOSRedeployMgmtFramework, ManagementHistory, Purchasable, Sitable, Updatable, Uploadable
Defined in:
lib/jamf/api/classic/api_objects/computer.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

See Also:

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
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: {
    aliases: %i[uuid guid],
    fetch_rsrc_key: :udid
  },
  serial_number: {
    aliases: %i[serialnumber sn],
    fetch_rsrc_key: :serialnumber
  },
  mac_address: {
    aliases: %i[
      mac_address
      macaddress
      macaddr
    ],
    fetch_rsrc_key: :macaddress
  }

}.freeze
NON_UNIQUE_NAMES =
true
SEARCH_CLASS =

This class lets us seach for computers

Jamf::AdvancedComputerSearch
EXT_ATTRIB_CLASS =

This is the class for relevant Extension Attributes

Jamf::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_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
COMPUTER_APPLICATIONS_RSRC =
'computerapplications/application'.freeze
JPAPI_INVENTORY_RSRC =

The base resource for computer data in the JPAPI

'v1/computers-inventory'
JPAPI_INVENTORY_DETAIL_RSRC =

The resource for getting all inventory data for a computer at once

'v1/computers-inventory-detail'
OBJECT_HISTORY_OBJECT_TYPE =

the object type for this object in the object history table. See APIObject#add_object_history_entry

1

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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:

Parameters:

  • args (Hash)

    the data for looking up, or constructing, a new object.



907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
# File 'lib/jamf/api/classic/api_objects/computer.rb', line 907

def initialize(**args)
  super
  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]

    @management_status = @init_data[:general][:management_status]
    if @management_status
      @enrolled_via_dep = @management_status[:enrolled_via_dep]
      @user_approved_enrollment = @management_status[:user_approved_enrollment]
      @user_approved_mdm = @management_status[:user_approved_mdm]
    end

    @ip_address = @init_data[:general][:ip_address]
    @reported_ip_address = @init_data[:general][:last_reported_ip]
    @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
    @supervised = @init_data[:general][:supervised]
    @mdm_profile_expiration = JSS.epoch_to_time @init_data[:general][:mdm_profile_expiration_epoch]

    @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]

    @security = @init_data[:security] || {}

    @configuration_profiles = @init_data[:configuration_profiles]

    @groups_accounts = @init_data[:groups_accounts]
    @hardware = @init_data[:hardware]
    @peripherals = @init_data[:peripherals]
    @software = @init_data[:software]
    @certificates = @init_data[:certificates].map do |cert|
      {
        expires: JSS.epoch_to_time(cert[:expires_epoch]),
        common_name: cert[:common_name],
        identity: cert[:identity],
        name: cert[:name]
      }
    end # map do cert

    # 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

  # not in jss
  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 # if in jss
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object

Make all the keys of the @hardware hash available as top-level methods on the Computer instance.

This is done by catching method_missing and seeing if the method exists as key of @hardware, and if so, retuning that value, if not, passing on the method_missing call. So:

comp.processor_type

is now the same as:

comp.hardware[:processor_type]

The reason for using ‘method_missing` rather than looping through the speed. When instantiating lots of computers, defining the methods for each one, when those methods may not be needed, just slows things down. This way, they’re only used when needed.

This method may be expanded in the future to handle other ad-hoc, top-level methods.



1011
1012
1013
1014
1015
1016
1017
# File 'lib/jamf/api/classic/api_objects/computer.rb', line 1011

def method_missing(method, *args, &block)
  if @hardware.key? method
    @hardware[method]
  else
    super
  end # if
end

Instance Attribute Details

#alt_mac_addressString Also known as: alt_macaddress

Returns the secondary mac address.

Returns:

  • (String)

    the secondary mac address



624
625
626
# File 'lib/jamf/api/classic/api_objects/computer.rb', line 624

def alt_mac_address
  @alt_mac_address
end

#applecare_idString Originally defined in module Purchasable

Returns:

#asset_tagString

Returns the asset tag.

Returns:



627
628
629
# File 'lib/jamf/api/classic/api_objects/computer.rb', line 627

def asset_tag
  @asset_tag
end

#barcode1String Also known as: bar_code_1, barcode_1

Returns the barcodes.

Returns:



630
631
632
# File 'lib/jamf/api/classic/api_objects/computer.rb', line 630

def barcode1
  @barcode1
end

#barcode2String Also known as: bar_code_2, barcode_2

Returns the barcodes.

Returns:



630
631
632
# File 'lib/jamf/api/classic/api_objects/computer.rb', line 630

def barcode2
  @barcode2
end

#buildingString Originally defined in module Locatable

Returns:

#certificatesArray<Hash> (readonly)

A Hash for each Certificate on the computer

The Hash keys are:

  • :common_name [String] the name of the cert

  • :identity [Boolean] Is this an identiry cert?

  • :expires [Time] the certificate expiration time

  • :name Display name for the certificate, if any

Returns:



754
755
756
# File 'lib/jamf/api/classic/api_objects/computer.rb', line 754

def certificates
  @certificates
end

#configuration_profiles(only: nil) ⇒ Object (readonly)

A shortcut for ‘management_data subset: :os_x_configuration_profiles’



742
743
744
# File 'lib/jamf/api/classic/api_objects/computer.rb', line 742

def configuration_profiles
  @configuration_profiles
end

#departmentString Originally defined in module Locatable

Returns:

#distribution_pointString (readonly)

Returns The name of the distribution point for this computer.

Returns:

  • (String)

    The name of the distribution point for this computer



633
634
635
# File 'lib/jamf/api/classic/api_objects/computer.rb', line 633

def distribution_point
  @distribution_point
end

#email_addressString Originally defined in module Locatable

Returns:

#enrolled_via_depBoolean (readonly) Also known as: enrolled_via_dep?, enrolled_via_ade, enrolled_via_ade?

Returns was the last enrollment via ADE/DEP.

Returns:

  • (Boolean)

    was the last enrollment via ADE/DEP



657
658
659
# File 'lib/jamf/api/classic/api_objects/computer.rb', line 657

def enrolled_via_dep
  @enrolled_via_dep
end

#extension_attributesArray<Hash> (readonly) Originally defined in module Extendable

Returns The extension attribute values for the object.

Returns:

  • (Array<Hash>)

    The extension attribute values for the object

#groups_accountsHash (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

Returns:



772
773
774
# File 'lib/jamf/api/classic/api_objects/computer.rb', line 772

def groups_accounts
  @groups_accounts
end

#hardwareHash (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

Returns:



832
833
834
# File 'lib/jamf/api/classic/api_objects/computer.rb', line 832

def hardware
  @hardware
end

#initial_entry_dateTime (readonly)

Returns when was it added to the JSS.

Returns:

  • (Time)

    when was it added to the JSS



636
637
638
# File 'lib/jamf/api/classic/api_objects/computer.rb', line 636

def 
  @initial_entry_date
end

#ip_addressIPAddr

Returns the last known IP address from the server’s perspective.

Returns:

  • (IPAddr)

    the last known IP address from the server’s perspective



639
640
641
# File 'lib/jamf/api/classic/api_objects/computer.rb', line 639

def ip_address
  @ip_address
end

#is_leasedBoolean Also known as: leased? Originally defined in module Purchasable

Returns:

  • (Boolean)

#is_purchasedBoolean Also known as: purchased? Originally defined in module Purchasable

Returns:

  • (Boolean)

#itunes_store_account_is_activeBoolean (readonly)

Returns:

  • (Boolean)


645
646
647
# File 'lib/jamf/api/classic/api_objects/computer.rb', line 645

def 
  @itunes_store_account_is_active
end

#jamf_versionString (readonly)

Returns the version of the jamf binary.

Returns:

  • (String)

    the version of the jamf binary



648
649
650
# File 'lib/jamf/api/classic/api_objects/computer.rb', line 648

def jamf_version
  @jamf_version
end

#last_contact_timeTime (readonly)

Returns the last contact time.

Returns:

  • (Time)

    the last contact time



651
652
653
# File 'lib/jamf/api/classic/api_objects/computer.rb', line 651

def last_contact_time
  @last_contact_time
end

#last_enrolledTime (readonly)

Returns the last time this machine was enrolled.

Returns:

  • (Time)

    the last time this machine was enrolled



654
655
656
# File 'lib/jamf/api/classic/api_objects/computer.rb', line 654

def last_enrolled
  @last_enrolled
end

#lease_expiresTime Originally defined in module Purchasable

Returns:

#life_expectancyInteger Originally defined in module Purchasable

Returns:

  • (Integer)

#mac_addressString

Returns the primary macaddress.

Returns:

  • (String)

    the primary macaddress



663
664
665
# File 'lib/jamf/api/classic/api_objects/computer.rb', line 663

def mac_address
  @mac_address
end

#managedBoolean (readonly) Also known as: managed?

Returns is this machine “managed” by Casper?.

Returns:

  • (Boolean)

    is this machine “managed” by Casper?



666
667
668
# File 'lib/jamf/api/classic/api_objects/computer.rb', line 666

def managed
  @managed
end

#management_statusHash (readonly)

Returns some MDM status details in general.

Returns:

  • (Hash)

    some MDM status details in general



691
692
693
# File 'lib/jamf/api/classic/api_objects/computer.rb', line 691

def management_status
  @management_status
end

#management_usernameString (readonly)

Returns the name of the management account.

Returns:

  • (String)

    the name of the management account



669
670
671
# File 'lib/jamf/api/classic/api_objects/computer.rb', line 669

def management_username
  @management_username
end

#mdm_capableBoolean (readonly) Also known as: mdm_capable?, mdm?

Returns doesit support MDM?.

Returns:

  • (Boolean)

    doesit support MDM?



672
673
674
# File 'lib/jamf/api/classic/api_objects/computer.rb', line 672

def mdm_capable
  @mdm_capable
end

#mdm_capable_usersArray (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.

Returns:

  • (Array)

    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.



698
699
700
# File 'lib/jamf/api/classic/api_objects/computer.rb', line 698

def mdm_capable_users
  @mdm_capable_users
end

#mdm_profile_expirationTime (readonly)

Returns when does the mdm profile expire.

Returns:

  • (Time)

    when does the mdm profile expire



688
689
690
# File 'lib/jamf/api/classic/api_objects/computer.rb', line 688

def mdm_profile_expiration
  @mdm_profile_expiration
end

#need_to_updateBoolean (readonly) Originally defined in module Updatable

Returns do we have unsaved changes?.

Returns:

  • (Boolean)

    do we have unsaved changes?

#netboot_serverString (readonly)

Returns the name of the netboot server for this machine.

Returns:

  • (String)

    the name of the netboot server for this machine



701
702
703
# File 'lib/jamf/api/classic/api_objects/computer.rb', line 701

def netboot_server
  @netboot_server
end

#peripheralsArray<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=>“”

Returns:



871
872
873
# File 'lib/jamf/api/classic/api_objects/computer.rb', line 871

def peripherals
  @peripherals
end

#phoneString Originally defined in module Locatable

Returns:

#platformString (readonly)

Returns what kind of computer?.

Returns:

  • (String)

    what kind of computer?



704
705
706
# File 'lib/jamf/api/classic/api_objects/computer.rb', line 704

def platform
  @platform
end

#po_dateTime Originally defined in module Purchasable

Returns:

#po_numberString Originally defined in module Purchasable

Returns:

#positionString Originally defined in module Locatable

Returns:

#purchase_priceFloat Originally defined in module Purchasable

Returns:

  • (Float)

#purchasing_accountString Originally defined in module Purchasable

Returns:

#purchasing_contactString Originally defined in module Purchasable

Returns:

#real_nameString Originally defined in module Locatable

Returns:

#report_dateTime (readonly) Also known as: last_recon

Returns the last recon time.

Returns:

  • (Time)

    the last recon time



707
708
709
# File 'lib/jamf/api/classic/api_objects/computer.rb', line 707

def report_date
  @report_date
end

#reported_ip_addressIPAddr (readonly)

Returns the last known IP address from the client’s perspecive.

Returns:

  • (IPAddr)

    the last known IP address from the client’s perspecive



642
643
644
# File 'lib/jamf/api/classic/api_objects/computer.rb', line 642

def reported_ip_address
  @reported_ip_address
end

#roomString Originally defined in module Locatable

Returns:

#securityHash (readonly)

Returns The security settings for this Computer Keys are: activation_lock: Boolean recovery_lock_enabled: Boolean secure_boot_level: String external_boot_level: String firewall_enabled: Boolean.

Returns:

  • (Hash)

    The security settings for this Computer Keys are: activation_lock: Boolean recovery_lock_enabled: Boolean secure_boot_level: String external_boot_level: String firewall_enabled: Boolean



722
723
724
# File 'lib/jamf/api/classic/api_objects/computer.rb', line 722

def security
  @security
end

#serial_numberString Also known as: sn, serialnumber

Returns the serial number.

Returns:

  • (String)

    the serial number



710
711
712
# File 'lib/jamf/api/classic/api_objects/computer.rb', line 710

def serial_number
  @serial_number
end

#siteHash (readonly)

Returns the :name and :id of the site for this machine.

Returns:

  • (Hash)

    the :name and :id of the site for this machine



713
714
715
# File 'lib/jamf/api/classic/api_objects/computer.rb', line 713

def site
  @site
end

#softwareHash (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

Returns:



893
894
895
# File 'lib/jamf/api/classic/api_objects/computer.rb', line 893

def software
  @software
end

#supervisedBoolean (readonly) Also known as: supervised?

Returns Is it supervised?.

Returns:

  • (Boolean)

    Is it supervised?



676
677
678
# File 'lib/jamf/api/classic/api_objects/computer.rb', line 676

def supervised
  @supervised
end

#susString (readonly)

Returns the name of the Software Update Server assigned to this machine.

Returns:

  • (String)

    the name of the Software Update Server assigned to this machine.



725
726
727
# File 'lib/jamf/api/classic/api_objects/computer.rb', line 725

def sus
  @sus
end

#udidString

Returns the UDID of the computer.

Returns:

  • (String)

    the UDID of the computer



728
729
730
# File 'lib/jamf/api/classic/api_objects/computer.rb', line 728

def udid
  @udid
end

#user_approved_enrollmentBoolean (readonly) Also known as: user_approved_enrollment?

Returns was enrollment user-approved.

Returns:

  • (Boolean)

    was enrollment user-approved



680
681
682
# File 'lib/jamf/api/classic/api_objects/computer.rb', line 680

def user_approved_enrollment
  @user_approved_enrollment
end

#user_approved_mdmBoolean (readonly) Also known as: user_approved_mdm?

Returns was MDM user-approved (meaning the User authorized the MDM profile).

Returns:

  • (Boolean)

    was MDM user-approved (meaning the User authorized the MDM profile)



684
685
686
# File 'lib/jamf/api/classic/api_objects/computer.rb', line 684

def user_approved_mdm
  @user_approved_mdm
end

#usernameString Also known as: user Originally defined in module Locatable

Returns:

#vendorString Originally defined in module Purchasable

Returns:

#warranty_expiresTime Originally defined in module Purchasable

Returns:

Class Method Details

.all(refresh = false, api: nil, cnx: Jamf.cnx) ⇒ 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 Jamf::Computer. Hopefully some day the original /computers/ resource will be updated to return this data.

Parameters:

  • refresh (Boolean) (defaults to: false)

    should the data be re-queried from the API?

  • cnx (Jamf::Connection) (defaults to: Jamf.cnx)

    an API connection to use for the query. Defaults to the corrently active API. See Jamf::Connection

Returns:



333
334
335
336
337
338
339
340
341
342
# File 'lib/jamf/api/classic/api_objects/computer.rb', line 333

def self.all(refresh = false, api: nil, cnx: Jamf.cnx)
  cnx = api if api

  cache = cnx.c_object_list_cache
  cache_key = self::RSRC_LIST_KEY
  cache[cache_key] = nil if refresh
  return cache[cache_key] if cache[cache_key]

  cache[cache_key] = cnx.c_get(self::LIST_RSRC)[cache_key]
end

.all_desktops(refresh = false, api: nil, cnx: Jamf.cnx) ⇒ Array<Hash>

Returns all desktop macs in the jss.

Returns:

  • (Array<Hash>)

    all desktop macs in the jss



394
395
396
397
398
# File 'lib/jamf/api/classic/api_objects/computer.rb', line 394

def self.all_desktops(refresh = false, api: nil, cnx: Jamf.cnx)
  cnx = api if api

  all(refresh, cnx: cnx).reject { |d| d[:model] =~ /serve|book/i }
end

.all_imacs(refresh = false, api: nil, cnx: Jamf.cnx) ⇒ Array<Hash>

Returns all imacs in the jss.

Returns:



401
402
403
404
405
# File 'lib/jamf/api/classic/api_objects/computer.rb', line 401

def self.all_imacs(refresh = false, api: nil, cnx: Jamf.cnx)
  cnx = api if api

  all(refresh, cnx: cnx).select { |d| d[:model] =~ /^imac/i }
end

.all_laptops(refresh = false, api: nil, cnx: Jamf.cnx) ⇒ Array<Hash>

Returns all laptop computers in the jss.

Returns:

  • (Array<Hash>)

    all laptop computers in the jss



359
360
361
362
363
# File 'lib/jamf/api/classic/api_objects/computer.rb', line 359

def self.all_laptops(refresh = false, api: nil, cnx: Jamf.cnx)
  cnx = api if api

  all(refresh, cnx: cnx).select { |d| d[:model] =~ /book/i }
end

.all_macbookairs(refresh = false, api: nil, cnx: Jamf.cnx) ⇒ Array<Hash>

Returns all macbookairs in the jss.

Returns:

  • (Array<Hash>)

    all macbookairs in the jss



380
381
382
383
384
# File 'lib/jamf/api/classic/api_objects/computer.rb', line 380

def self.all_macbookairs(refresh = false, api: nil, cnx: Jamf.cnx)
  cnx = api if api

  all(refresh, cnx: cnx).select { |d| d[:model] =~ /^macbookair\d/i }
end

.all_macbookpros(refresh = false, api: nil, cnx: Jamf.cnx) ⇒ Array<Hash>

Returns all macbookpros in the jss.

Returns:

  • (Array<Hash>)

    all macbookpros in the jss



373
374
375
376
377
# File 'lib/jamf/api/classic/api_objects/computer.rb', line 373

def self.all_macbookpros(refresh = false, api: nil, cnx: Jamf.cnx)
  cnx = api if api

  all(refresh, cnx: cnx).select { |d| d[:model] =~ /^macbookpro\d/i }
end

.all_macbooks(refresh = false, api: nil, cnx: Jamf.cnx) ⇒ Array<Hash>

Returns all macbooks in the jss.

Returns:



366
367
368
369
370
# File 'lib/jamf/api/classic/api_objects/computer.rb', line 366

def self.all_macbooks(refresh = false, api: nil, cnx: Jamf.cnx)
  cnx = api if api

  all(refresh, cnx: cnx).select { |d| d[:model] =~ /^macbook\d/i }
end

.all_macpros(refresh = false, api: nil, cnx: Jamf.cnx) ⇒ Array<Hash>

Returns all macpros in the jss.

Returns:



415
416
417
418
419
# File 'lib/jamf/api/classic/api_objects/computer.rb', line 415

def self.all_macpros(refresh = false, api: nil, cnx: Jamf.cnx)
  cnx = api if api

  all(refresh, cnx: cnx).select { |d| d[:model] =~ /^macpro/i }
end

.all_managed(refresh = false, api: nil, cnx: Jamf.cnx) ⇒ Array<Hash>

Returns all managed computers in the jss.

Returns:

  • (Array<Hash>)

    all managed computers in the jss



345
346
347
348
349
# File 'lib/jamf/api/classic/api_objects/computer.rb', line 345

def self.all_managed(refresh = false, api: nil, cnx: Jamf.cnx)
  cnx = api if api

  all(refresh, cnx: cnx).select { |d| d[:managed] }
end

.all_minis(refresh = false, api: nil, cnx: Jamf.cnx) ⇒ Array<Hash>

Returns all mac minis in the jss.

Returns:



408
409
410
411
412
# File 'lib/jamf/api/classic/api_objects/computer.rb', line 408

def self.all_minis(refresh = false, api: nil, cnx: Jamf.cnx)
  cnx = api if api

  all(refresh, cnx: cnx).select { |d| d[:model] =~ /^macmini/i }
end

.all_unmanaged(refresh = false, api: nil, cnx: Jamf.cnx) ⇒ Array<Hash>

Returns all unmanaged computers in the jss.

Returns:

  • (Array<Hash>)

    all unmanaged computers in the jss



352
353
354
355
356
# File 'lib/jamf/api/classic/api_objects/computer.rb', line 352

def self.all_unmanaged(refresh = false, api: nil, cnx: Jamf.cnx)
  cnx = api if api

  all(refresh, cnx: cnx).reject { |d| d[:managed] }
end

.all_xserves(refresh = false, api: nil, cnx: Jamf.cnx) ⇒ Array<Hash>

Returns all xserves in the jss.

Returns:



387
388
389
390
391
# File 'lib/jamf/api/classic/api_objects/computer.rb', line 387

def self.all_xserves(refresh = false, api: nil, cnx: Jamf.cnx)
  cnx = api if api

  all(refresh, cnx: cnx).select { |d| d[:model] =~ /serve/i }
end

.application_installs(appname, fields: [], version: nil, ids_only: false, api: nil, cnx: Jamf.cnx) ⇒ 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 Jamf::Computer instance and call its #apps method.

Parameters:

  • appname (String)

    The name of the app to look for, e.g. ‘Transmogrifier.app’

  • fields (String, Array<String>) (defaults to: [])

    Additional ‘inventory fields’ to return with each computer’s data

  • version (String) (defaults to: nil)

    Limit search to a specific version of the app

  • ids_only (Boolean) (defaults to: false)

    Just return an array of the id’s of computers found with this query. Defaults to false

  • cnx (Jamf::Connection) (defaults to: Jamf.cnx)

    The API connection to use for the query. default: Jamf.cnx

Returns:

  • (Array<Integer>)

    When ids_only == true, the ids of computers with the app installed (possibly limited to version)

  • (Array<Hash>)

    When version is provided, An Array of Hashes, one for each computer, with keys for identifiers plus any requested fields.

  • (Hash{String => Array<Hash>})

    When no version is provided, a Hash with keys for each version, pointing to an array of Hashes, one for each computer with that version. Each computer’s Hash has keys for identifiers plus any requested fields.



524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
# File 'lib/jamf/api/classic/api_objects/computer.rb', line 524

def self.application_installs(appname, fields: [], version: nil, ids_only: false, api: nil, cnx: Jamf.cnx)
  cnx = api if api

  fields = [fields] unless fields.is_a? Array

  rsrc = "#{COMPUTER_APPLICATIONS_RSRC}/#{CGI.escape appname.to_s}"
  rsrc << "/version/#{CGI.escape version.to_s}" if version
  rsrc << "/inventory/#{CGI.escape fields.join(',')}" unless ids_only || fields.empty?

  result = cnx.c_get(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: nil, cnx: Jamf.cnx) ⇒ Hash{Date=>Array<Hash>}

Retrieve Application Usage data for a computer by id, without instantiation.

Parameters:

  • ident (Integer, String)

    An identifier (id, name, serialnumber, macadress or udid) of the computer for which to retrieve Application Usage

  • start_date (Time, Date, DateTime, String)

    The earliest date to retrieve

  • end_date (String, Date, DateTime, Time) (defaults to: nil)

    Defaults to start_date

  • cnx (Jamf::Connection) (defaults to: Jamf.cnx)

    an API connection to use for the query. Defaults to the corrently active API. See Jamf::Connection

Returns:

  • (Hash{Date=>Array<Hash>})

    A Hash with keys (Date instances) for each day in the range.

    Each hash value contains an Array of apps used on that day.

    Each item in the array is a hash of data about the app. Those hash keys are:

    :name => String, the name of the app
    :version => String ,the version of the app
    :foreground => Integer, the minutes it was in the foreground
    :open => Integer, the minutes it was running.
    

Raises:



447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
# File 'lib/jamf/api/classic/api_objects/computer.rb', line 447

def self.application_usage(ident, start_date, end_date = nil, api: nil, cnx: Jamf.cnx)
  cnx = api if api

  id = valid_id ident, cnx: cnx
  raise Jamf::NoSuchItemError, "No computer matches identifier: #{ident}" unless id

  end_date ||= start_date
  start_date = Jamf.parse_time start_date
  end_date = Jamf.parse_time end_date

  start_date = start_date.strftime APPLICATION_USAGE_DATE_FMT
  end_date = end_date.strftime APPLICATION_USAGE_DATE_FMT

  data = cnx.c_get(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: nil, cnx: Jamf.cnx) ⇒ Hash

Display the current Computer CheckIn settings in the JSS. Currently this is read-only in ruby-jss, even tho the API allows updating.

Parameters:

Returns:

  • (Hash)

    the Computer Checkin Settings from the currently connected JSS.



294
295
296
297
# File 'lib/jamf/api/classic/api_objects/computer.rb', line 294

def self.checkin_settings(api: nil, cnx: Jamf.cnx)
  cnx = api if api
  cnx.c_get(CHECKIN_RSRC)[CHECKIN_KEY]
end

.inventory_collection_settings(api: nil, cnx: Jamf.cnx) ⇒ 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.

Parameters:

Returns:

  • (Hash)

    the Computer Inventpry Collection Settings from the currently connected JSS.



309
310
311
312
# File 'lib/jamf/api/classic/api_objects/computer.rb', line 309

def self.inventory_collection_settings(api: nil, cnx: Jamf.cnx)
  cnx = api if api
  cnx.c_get(INV_COLLECTION_RSRC)[INV_COLLECTION_KEY]
end

.management_data(ident, subset: nil, only: nil, api: nil, cnx: Jamf.cnx) ⇒ 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.

Parameters:

  • ident (Integer, String)

    An identifier (id, name, serialnumber, macadress or udid) of the computer for which to retrieve Application Usage

  • subset (Symbol) (defaults to: nil)

    Fetch only a subset of data, as an array. must be one of the symbols in MGMT_DATA_SUBSETS

  • only (Symbol) (defaults to: nil)

    When fetching a subset, only return one value per item in the array. meaningless without a subset.

  • cnx (Jamf::Connection) (defaults to: Jamf.cnx)

    an API connection to use for the query. Defaults to the corrently active API. See Jamf::Connection

Returns:

  • (Hash)

    Without a subset:, a hash of all subsets, each of which is an Array

  • (Array)

    With a subset:, an array of items in that subset, possibly limited to just certain values with only:



577
578
579
580
581
582
583
584
585
586
587
588
# File 'lib/jamf/api/classic/api_objects/computer.rb', line 577

def self.management_data(ident, subset: nil, only: nil, api: nil, cnx: Jamf.cnx)
  cnx = api if api

  id = valid_id ident, cnx: cnx
  raise "No computer matches identifier: #{ident}" unless id

  if subset
    management_data_subset id, subset: subset, only: only, cnx: cnx
  else
    full_management_data id, cnx: cnx
  end
end

.match(term, api: nil, cnx: Jamf.cnx) ⇒ 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.

Parameters:

  • term (String)

    the term to match.

Returns:

Raises:

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

See Also:

  • matching method in {Jamf::ManagementHistory::ClassMethods}

#app_store_apps(only: nil) ⇒ Object

A shortcut for ‘management_data subset: :mac_app_store_apps’



1138
1139
1140
# File 'lib/jamf/api/classic/api_objects/computer.rb', line 1138

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



1090
1091
1092
# File 'lib/jamf/api/classic/api_objects/computer.rb', line 1090

def application_usage(start_date, end_date = nil)
  Jamf::Computer.application_usage @id, start_date, end_date, cnx: @cnx
end

#appsArray<Hash>

Returns all apps installed on this machine. Hash keys are :name, :path, and :version.

Returns:

  • (Array<Hash>)

    all apps installed on this machine. Hash keys are :name, :path, and :version



1075
1076
1077
# File 'lib/jamf/api/classic/api_objects/computer.rb', line 1075

def apps
  @software[:applications]
end

#audit_historyObject Also known as: audits Originally defined in module ManagementHistory

The audit_history for this object

See Also:

  • matching method in {Jamf::ManagementHistory::ClassMethods}

#blank_pushvoid 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_driveHash?

Returns The hardware hash of the boot drive.

Returns:



1061
1062
1063
# File 'lib/jamf/api/classic/api_objects/computer.rb', line 1061

def boot_drive
  drives.select { |d| d[:partition] && d[:partition][:type] == 'boot' }.first
end

#casper_imaging_logsObject Originally defined in module ManagementHistory

The casper_imaging_logs for this computer

See Also:

  • matching method in {Jamf::ManagementHistory::ClassMethods}

#casper_remote_logsObject Originally defined in module ManagementHistory

The casper_remote_logs for this computer

See Also:

  • matching method in {Jamf::ManagementHistory::ClassMethods}

#clear_locationvoid Originally defined in module Locatable

This method returns an undefined value.

Clear all location data

#clear_passcodeObject Originally defined in module MDM

Send an clear_passcode command to this object

#clear_restrictions_passwordObject Originally defined in module MDM

Send an clear_restrictions_password command to this object

#clone(new_name, api: nil, cnx: nil) ⇒ APIObject Originally defined in module Creatable

make a clone of this API object, with a new name. The class must be creatable

Parameters:

  • name (String)

    the name for the new object

  • cnx (Jamf::Connection) (defaults to: nil)

    the API in which to create the object Defaults to the API used to instantiate this object

Returns:

  • (APIObject)

    An unsaved clone of this APIObject with the given name

Raises:

#completed_mdm_commandsObject Also known as: completed_commands Originally defined in module ManagementHistory

The completed_mdm_commands for this object

See Also:

  • matching method in {Jamf::ManagementHistory::ClassMethods}

#completed_policiesObject Originally defined in module ManagementHistory

The array from .policy_logs, limited to status = :completed

See Also:

  • matching method in {Jamf::ManagementHistory::ClassMethods}

#computer_groupsArray

Returns the JSS groups to which thismachine belongs (smart and static).

Returns:

  • (Array)

    the JSS groups to which thismachine belongs (smart and static)



1027
1028
1029
# File 'lib/jamf/api/classic/api_objects/computer.rb', line 1027

def computer_groups
  @groups_accounts[:computer_group_memberships]
end

#computer_usage_logsObject Also known as: usage_logs Originally defined in module ManagementHistory

The computer_usage_logs for this computer

See Also:

  • matching method in {Jamf::ManagementHistory::ClassMethods}

#deletevoid

This method returns an undefined value.

Delete this computer from the JSS



1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
# File 'lib/jamf/api/classic/api_objects/computer.rb', line 1292

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

Parameters:

  • user (String)

    the username of the acct to delete

#device_lock(passcode_or_message = '') ⇒ Object Also known as: lock, lock_device Originally defined in module MDM

Send a dev lock to this object

Parameters:

  • passcode_or_message (String) (defaults to: '')

    a six-char passcode, required for computers & computergroups Or an optional message to display on mobiledevices & mobiledevicegroups

#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

Parameters:

  • name (String)

    The new name

#disable_app_analyticsObject Originally defined in module MDM

Send a disable_app_analytics command to this object

#disable_data_roamingObject Originally defined in module MDM

Send a disable_data_roaming command to this object

#disable_diagnostic_submissionObject Originally defined in module MDM

Send a disable_diagnostic_submission command to this object

#disable_lost_modeObject Originally defined in module MDM

Send a disable_lost_mode command to this object

#disable_remote_desktopObject Originally defined in module MDM

Send a disable_remote_desktop command to this computer or group

#disable_voice_roamingObject Originally defined in module MDM

Send a disable_voice_roaming command to this object

#drivesArray<Hash>

Returns each storage device.

Returns:



1055
1056
1057
# File 'lib/jamf/api/classic/api_objects/computer.rb', line 1055

def drives
  @hardware[:storage]
end

#ea_namesArray<String> Originally defined in module Extendable

Returns the names of all known EAs.

Returns:

#ea_typesHash{String => String} Originally defined in module Extendable

Returns EA names => data type (one of ‘String’, ‘Number’, or ‘Date’).

Returns:

  • (Hash{String => String})

    EA names => data type (one of ‘String’, ‘Number’, or ‘Date’)

#ebook_history(status = nil) ⇒ Object Also known as: managed_ebook_history Originally defined in module ManagementHistory

The ebook_history for this mobile device

See Also:

  • matching method in {Jamf::ManagementHistory::ClassMethods}

#ebooks(only: nil) ⇒ Object

A shortcut for ‘management_data subset: :ebooks’



1132
1133
1134
# File 'lib/jamf/api/classic/api_objects/computer.rb', line 1132

def ebooks(only: nil)
  management_data subset: :ebooks, only: only, refresh: refresh
end

#enable_app_analyticsObject Originally defined in module MDM

Send an enable_app_analytics command to this object

#enable_data_roamingObject Originally defined in module MDM

Send an enable_data_roaming command to this object

#enable_diagnostic_submissionObject Originally defined in module MDM

Send an enable_diagnostic_submission command to this object

#enable_lost_mode(message: nil, phone: nil, footnote: nil, enforce_lost_mode: false, 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

Parameters:

  • message (String) (defaults to: nil)

    The message to display on the lock screen

  • phone_number (String)

    The phone number to display on the lock screen

  • footnote (String) (defaults to: nil)

    Optional footnote to display on the lock screen

  • play_sound (Boolean) (defaults to: false)

    Play a sound when entering lost mode

  • enforce_lost_mode (Boolean) (defaults to: false)

    Re-enable lost mode when re-enrolled after wipe. Default is false

#enable_remote_desktopObject Originally defined in module MDM

Send an enable_remote_desktop command to this computer or group

#enable_voice_roamingObject 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

Parameters:

  • passcode (String) (defaults to: '')

    a six-char passcode, required for computers & computergroups

#ext_attr_xmlREXML::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

Returns:

  • (REXML::Element)

    An <extension_attribute> element to be included in the rest_xml of objects that mix-in this module.

#ext_attrsObject Originally defined in module Extendable

An easier-to-use hash of EA name to EA value. This isn’t created until its needed, to speed up instantiation.

#failed_app_store_appsObject Also known as: failed_managed_apps Originally defined in module ManagementHistory

shortcut for app_store_app_history where status = :failed

See Also:

  • matching method in {Jamf::ManagementHistory::ClassMethods}

#failed_ebooksObject Also known as: failed_managed_ebooks Originally defined in module ManagementHistory

shortcut for ebook_history where status = :failed

See Also:

  • matching method in {Jamf::ManagementHistory::ClassMethods}

#failed_mdm_commandsObject Also known as: failed_commands Originally defined in module ManagementHistory

The failed_mdm_commands for this object

See Also:

  • matching method in {Jamf::ManagementHistory::ClassMethods}

#failed_policiesObject Originally defined in module ManagementHistory

The array from .policy_logs, limited to status = :failed

See Also:

  • matching method in {Jamf::ManagementHistory::ClassMethods}

#filevault1_accountsArray<Hash>

Returns The local_accounts Array that have Legacy FV enabled.

Returns:

  • (Array<Hash>)

    The local_accounts Array that have Legacy FV enabled



1047
1048
1049
1050
1051
# File 'lib/jamf/api/classic/api_objects/computer.rb', line 1047

def filevault1_accounts
  return [] if filevault2_enabled?

  local_accounts.select { |a| a[:filevault_enabled] }
end

#filevault2_enabled?Boolean

Returns is FileVault2 enabled?.

Returns:

  • (Boolean)

    is FileVault2 enabled?



1041
1042
1043
# File 'lib/jamf/api/classic/api_objects/computer.rb', line 1041

def filevault2_enabled?
  boot_drive[:partition][:filevault2_status] != 'Not Encrypted'
end

#filevault_infoObject Originally defined in module FileVault

Get the filevault info for this Computer instance

#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

Parameters:

  • status (String)

    a key from Commandable::FLUSHABLE_STATUSES

#flush_policy_logs(older_than: 0, period: :days) ⇒ Object

Flush all policy logs for this computer older than a given time period.

IMPORTANT: from the Jamf Developer Site:

The ability to flush logs is currently only supported for flushing all logs
for a given policy or all logs for a given computer. There is no support for
flushing logs for a given policy and computer combination.

With no parameters, will flush all logs for the computer

NOTE: Currently the API doesn’t have a way to flush only failed policies.

Parameters:

  • older_than (Integer) (defaults to: 0)

    0, 1, 2, 3, or 6

  • period (Symbol) (defaults to: :days)

    :days, :weeks, :months, or :years

See Also:



1218
1219
1220
1221
1222
1223
1224
1225
# File 'lib/jamf/api/classic/api_objects/computer.rb', line 1218

def flush_policy_logs(older_than: 0, period: :days)
  Jamf::Policy.flush_logs_for_computers(
    [@id],
    older_than: older_than,
    period: period,
    cnx: @cnx
  )
end

#has_location?Boolean Originally defined in module Locatable

Returns Does this item have location data?.

Returns:

  • (Boolean)

    Does this item have location data?

#has_purchasing?Boolean Originally defined in module Purchasable

Returns does this item have any purchasing info?.

Returns:

  • (Boolean)

    does this item have any purchasing info?

#installed_app_store_appsObject Also known as: installed_managed_apps Originally defined in module ManagementHistory

shortcut for app_store_app_history where status = :installed

See Also:

  • matching method in {Jamf::ManagementHistory::ClassMethods}

#installed_ebooksObject Also known as: installed_managed_ebooks Originally defined in module ManagementHistory

shortcut for ebook_history where status = :installed

See Also:

  • matching method in {Jamf::ManagementHistory::ClassMethods}

#inventory_data(section: 'GENERAL') ⇒ Object Originally defined in module ComputerRecoveryLock

Get the JPAPI inventory data for this computer, either by section or all sections.

#last_mdm_contactObject Originally defined in module ManagementHistory

The time of the last completed mdm command for this object

See Also:

  • matching method in {Jamf::ManagementHistory::ClassMethods}

#licensed_swArray<String>

Returns the JSS-defined “licensed software” titles installed on this machine.

Returns:

  • (Array<String>)

    the JSS-defined “licensed software” titles installed on this machine.



1082
1083
1084
# File 'lib/jamf/api/classic/api_objects/computer.rb', line 1082

def licensed_sw
  @software[:licensed_software]
end

#local_accountsArray<Hash> Also known as: accounts, accts

Each item has keys :name, :realname, :uid, :home, :home_size, :administrator, :filevault_enabled

Returns:

  • (Array<Hash>)

    all the local accts on the machine.



1035
1036
1037
# File 'lib/jamf/api/classic/api_objects/computer.rb', line 1035

def local_accounts
  @groups_accounts[:local_accounts]
end

#locationHash<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.

Returns:

#location_xmlREXML::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

Returns:

  • (REXML::Element)

#mac_app_store_app_history(status = nil) ⇒ Object Originally defined in module ManagementHistory

The mac_app_store_app_history for this computer

See Also:

  • matching method in {Jamf::ManagementHistory::ClassMethods}

#make_unmanagedvoid

This method returns an undefined value.

Make the machine unmanaged.

The same as

#set_management_to nil, nil

followed by

Jamf::Computer.send_mdm_command @id, :unmanage_device

which currently isn’t working



1186
1187
1188
1189
1190
1191
# File 'lib/jamf/api/classic/api_objects/computer.rb', line 1186

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

Raises:

See Also:

  • for details


1100
1101
1102
1103
1104
# File 'lib/jamf/api/classic/api_objects/computer.rb', line 1100

def management_data(subset: nil, only: nil)
  raise Jamf::NoSuchItemError, 'Computer not yet saved in the JSS' unless @in_jss

  Jamf::Computer.management_data @id, subset: subset, only: only, cnx: @cnx
end

#management_history(subset = nil) ⇒ Object Also known as: history Originally defined in module ManagementHistory

The raw management history data for this object

See Also:

  • matching method in {Jamf::ManagementHistory::ClassMethods}

#management_idObject Originally defined in module ComputerRecoveryLock

Get the MDM ‘managementID’ of this computer.

#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

See Also:

  • matching method in {Jamf::ManagementHistory::ClassMethods}

#mobile_device_app_history(status = nil) ⇒ Object Originally defined in module ManagementHistory

The mobile_device_app_history for this mobile device

See Also:

  • matching method in {Jamf::ManagementHistory::ClassMethods}

#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.

Parameters:

  • newname (String)

    the new name

Raises:

#parse_ext_attrsvoid 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_locationvoid 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_purchasingObject 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

Parameters:

  • secs (Integer)

    The numer of seconds for the grace period

#patch_titles(only: nil) ⇒ Object

A shortcut for ‘management_data subset: :patch_reporting_software_titles’



1150
1151
1152
# File 'lib/jamf/api/classic/api_objects/computer.rb', line 1150

def patch_titles(only: nil)
  management_data subset: :patch_reporting_software_titles, only: only
end

#pending_app_store_appsObject Also known as: pending_managed_apps Originally defined in module ManagementHistory

shortcut for app_store_app_history where status = :pending

See Also:

  • matching method in {Jamf::ManagementHistory::ClassMethods}

#pending_ebooksObject Also known as: pending_managed_ebooks Originally defined in module ManagementHistory

shortcut for ebook_history where status = :pending

See Also:

  • matching method in {Jamf::ManagementHistory::ClassMethods}

#pending_mdm_commandsObject Also known as: pending_commands Originally defined in module ManagementHistory

The pending_mdm_commands for this object

See Also:

  • matching method in {Jamf::ManagementHistory::ClassMethods}

#play_lost_mode_soundObject 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’



1120
1121
1122
# File 'lib/jamf/api/classic/api_objects/computer.rb', line 1120

def policies(only: nil)
  management_data subset: :policies, only: only
end

#policy_logsObject Originally defined in module ManagementHistory

The policy_logs for this computer

See Also:

  • matching method in {Jamf::ManagementHistory::ClassMethods}

#printersArray<Hash>

Returns each printer on this computer Keys are :name, :uri, :type, :location.

Returns:

  • (Array<Hash>)

    each printer on this computer Keys are :name, :uri, :type, :location



1068
1069
1070
# File 'lib/jamf/api/classic/api_objects/computer.rb', line 1068

def printers
  @hardware[:mapped_printers]
end

#purchasingHash<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.

Returns:

#purchasing_xmlREXML::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.

Returns:

  • (REXML::Element)

    A <purchasing> element to be included in the rest_xml of objects that mix-in this module.

#recovery_lock_passwordObject Originally defined in module ComputerRecoveryLock

Get the recovery lock password for this Computer instance

#redeploy_mgmt_frameworkObject Originally defined in module MacOSRedeployMgmtFramework

Send a managed update command to an instance of Computer or ComputerGroup. This just calls the class method of the same name.

#respond_to_missing?(method) ⇒ Boolean

Companion to method_missing, allows for easier debugging in backtraces that involve missing methods.

Returns:

  • (Boolean)


1021
1022
1023
# File 'lib/jamf/api/classic/api_objects/computer.rb', line 1021

def respond_to_missing?(method, *)
  @hardware.key?(method) || super
end

#restart_deviceObject 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’



1144
1145
1146
# File 'lib/jamf/api/classic/api_objects/computer.rb', line 1144

def restricted_software(only: nil)
  management_data subset: :restricted_software, only: only
end

#screen_sharing_logsObject Originally defined in module ManagementHistory

The screen_sharing_logs for this computer

See Also:

  • matching method in {Jamf::ManagementHistory::ClassMethods}

#send_managed_os_update(updateAction:, maxDeferrals: nil, version: nil, skipVersionVerification: false, applyMajorUpdate: false, forceRestart: false) ⇒ Object Originally defined in module MacOSManagedUpdates

Send a managed update command to an instance of Computer or ComputerGroup. This just calls the class method of the same name.

#set_ext_attr(ea_name, value, validate_popup_choice: true, refresh: false) ⇒ void Originally defined in module Extendable

This method returns an undefined value.

Set the value of an extension attribute

The new value is validated based on the data type of the Ext. Attrib:

  • If the ext. attrib. is defined with a data type of Integer/Number, the value must be an Integer.

  • If defined with a data type of Date, the value will be parsed as a timestamp, and parsing may raise an exception. Dates can’t be blank.

  • If defined wth data type of String, ‘to_s` will be called on the value.

By default, the full EA definition object is fetched to see if the EA’s input type is ‘popup menu’, and if so, the new value must be one of the defined popup choices, or blank.

The EA definitions used for popup validation are cached, so we don’t have to reach out to the server every time. If you expect the definition to have changed since it was cached, provide a truthy value to the refresh: parameter

To bypass popup validation complepletely, provide a falsey value to the validate_popup_choice: parameter. WARNING: beware that your value is the correct type and format, or you might get errors when saving back to the API.

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.

Parameters:

  • name (String)

    the name of the extension attribute to set

  • value (String, Time, Integer)

    the new value for the extension attribute for this user

  • validate_popup_choice (Boolean) (defaults to: true)

    validate the new value against the E.A. definition. Defaults to true.

  • refresh (Boolean) (defaults to: false)

    Re-read the ext. attrib definition from the API, for popup validation.

Raises:

  • (ArgumentError)

#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!

Parameters:

  • name (String)

    the name of the management acct.

  • password (String)

    the password of the management acct



1168
1169
1170
1171
1172
1173
1174
# File 'lib/jamf/api/classic/api_objects/computer.rb', line 1168

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_deviceObject 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

Parameters:

  • new_site (Integer, String)

    The new site

Raises:

#site_assigned?Boolean Originally defined in module Sitable

Does this object have a site assigned?

Returns:

  • (Boolean)

    Does this object have a site assigned?

#site_idInteger Originally defined in module Sitable

The id of the site for this object.

Returns:

  • (Integer)

    The id of the site for this object.

#site_nameString 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’

Returns:

  • (String)

    The name of the site for this object.

#site_objectJamf::Site Originally defined in module Sitable

The Jamf::Site instance for this object’s site

Returns:

  • (Jamf::Site)

    The Jamf::Site instance for this object’s site

#smart_groups(only: nil) ⇒ Object

A shortcut for ‘management_data subset: :smart_groups’



1108
1109
1110
# File 'lib/jamf/api/classic/api_objects/computer.rb', line 1108

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’



1114
1115
1116
# File 'lib/jamf/api/classic/api_objects/computer.rb', line 1114

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

Parameters:

  • user (String)

    the username of the acct to unlock

#unmanage_deviceObject 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?

Returns:

  • (Boolean)

#unset_sitevoid Originally defined in module Sitable

This method returns an undefined value.

Set the site to nothing

#updatevoid

This method returns an undefined value.

Send changes to the API



1282
1283
1284
1285
1286
# File 'lib/jamf/api/classic/api_objects/computer.rb', line 1282

def update
  remove_mdm_profile if mdm_capable && @unmange_at_update
  @unmange_at_update = false
  super
end

#update_inventoryObject Also known as: recon Originally defined in module MDM

Send an update_inventory command to this object

#upload(type, local_file, force_ipa_upload: false) ⇒ Boolean Originally defined in module Uploadable

instance method wrapper for class method

Upload a file to the JSS to be stored with this instance of the class mixing in the Uploadable module

Parameters:

  • type (Symbol)

    the type of upload happening. Must be one of the keys defined in the class’s UPLOAD_TYPES Hash.

  • local_file (String, Pathname)

    String or Pathname pointing to the locally-readable file to be uploaded.

  • force_ipa_upload (Boolean) (defaults to: false)

    Should the server upload the .ipa file to JCDS or AWS if such are confgured for use?

Returns:

  • (Boolean)

    was the upload successful?

Raises:

#user_location_historyObject Originally defined in module ManagementHistory

The user_location_history for this object

See Also:

  • matching method in {Jamf::ManagementHistory::ClassMethods}

#validate_ea_value(ea_name, value, validate_popup_choice, refresh) ⇒ Object Originally defined in module Extendable

is the value being passed to set_ext_attr valid? Converts values as needed (e.g. strings to integers or Times)

If the EA is defined to hold a string, any value is accepted and converted with #to_s

Note: All EAs can be blank

Parameters:

  • name (String)

    the name of the extension attribute to set

  • value (String, Time, Integer)

    the new value for the extension attribute for this user

  • validate_popup_choice (Boolean)

    validate the new value against the E.A. definition. Defaults to true.

  • refresh (Boolean)

    Re-read the ext. attrib definition from the API, for popup validation.

Returns:

  • (Object)

    the possibly modified valid value

#validate_integer_ea_value(ea_name, value) ⇒ Object Originally defined in module Extendable

raise error if the value isn’t an integer

#validate_popup_value(ea_name, value, refresh) ⇒ Object Originally defined in module Extendable

Raise an error if the named EA has a popup menu, but the provided value isn’t one of the menu items

#wallpaper(wallpaper_setting: nil, wallpaper_content: nil, wallpaper_id: nil) ⇒ Object Also known as: set_wallpaper Originally defined in module MDM

Send a wallpaper command to this object

Parameters:

  • wallpaper_setting (Symbol) (defaults to: nil)

    :lock_screen, :home_screen, or :lock_and_home_screen

  • wallpaper_content (String, Pathname) (defaults to: nil)

    The local path to a .png or .jpg to use as the walpaper image, required if no wallpaper_id

  • wallpaper_id (Symbol) (defaults to: nil)

    The id of an Icon in Jamf Pro to use as the wallpaper image, required if no wallpaper_content