Method: Jamf::Computer.application_installs
- Defined in:
- lib/jamf/api/classic/api_objects/computer.rb
.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.
506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 |
# File 'lib/jamf/api/classic/api_objects/computer.rb', line 506 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 |