lib/jss/api_object/management_history.rb
def mdm_command_history(ident, status = nil, api: JSS.api)
        subset = self == JSS::Computer ? :commands : :management_commands
        hist = management_history(ident, subset, api: api)
        if status
          raise JSS::InvalidDataError, 'status must be one of :completed, :pending, or :failed' unless HIST_MDM_STATUSES.include? status
          statuses_to_do = [status]
        else
          statuses_to_do = HIST_MDM_STATUSES
        end # if status

        result = []

        statuses_to_do.each do |a_status|
          result += hist[a_status].map! do |cmd|
            # failed computer cmds have the error message in cmd[:status]
            # failed mdm commands have them in cmd[:error], where they should be
            cmd[:error] ||= cmd[:status] if a_status == :failed

            # but we always set the :status
            cmd[:status] = a_status

            JSS::ManagementHistory::MDMCommand.new cmd
          end # map do |cmd|
        end # statuses_to_do.each do |a_status|
        result
      end
# The history of mdm commands for a target
#
# @param ident [Type] The identifier for the object - id, name, sn, udid, etc.
#
# @param status [Symbol] Return only the :completed, :pending, or :failed commands
#
# @param api [JSS::APIConnection] The API connection to use for the query
#   defaults to the currently active connection
#
# @return [Array<JSS::ManagementHistory::MDMCommand>] An array of MDMCommands
#
The history of mdm commands for a target
The history of mdm commands for a target
def mdm_command_history(ident, status = nil, api: JSS.api)
        subset = self == JSS::Computer ? :commands : :management_commands
        hist = management_history(ident, subset, api: api)
        if status
          raise JSS::InvalidDataError, 'status must be one of :completed, :pending, or :failed' unless HIST_MDM_STATUSES.include? status
          statuses_to_do = [status]
        else
          statuses_to_do = HIST_MDM_STATUSES
        end 
        result = []
        statuses_to_do.each do |a_status|
          result += hist[a_status].map! do |cmd|
            cmd[:error] ||= cmd[:status] if a_status == :failed
            cmd[:status] = a_status
            JSS::ManagementHistory::MDMCommand.new cmd
          end 
        end 
        result
      end
def mdm_command_history ( ident , status = nil , api : JSS . api ) subset = self == JSS :: Computer ? :commands : :management_commands hist = management_history ( ident , subset , api : api ) if status raise JSS :: InvalidDataError , 'status must be one of :completed, :pending, or :failed' unless HIST_MDM_STATUSES . include? status statuses_to_do = [ status ] else statuses_to_do = HIST_MDM_STATUSES end result = [ ] statuses_to_do . each do | a_status | result += hist [ a_status ] . map! do | cmd | cmd [ :error ] ||= cmd [ :status ] if a_status == :failed cmd [ :status ] = a_status JSS :: ManagementHistory :: MDMCommand . new cmd end end result end
The history of mdm commands for a target
The history of mdm commands for a target
# if status # failed computer cmds have the error message in cmd[:status] # failed mdm commands have them in cmd[:error], where they should be # but we always set the :status # map do |cmd| # statuses_to_do.each do |a_status|
An array of MDMCommands
An array of MDMCommands
Array<JSS::ManagementHistory::MDMCommand>
ident
The identifier for the object - id, name, sn, udid, etc.
The identifier for the object - id name sn udid etc .
status
Return only the :completed, :pending, or :failed commands
Return only the : completed : pending or : failed commands
api
The API connection to use for the query defaults to the currently active connection
The API connection to use for the query defaults to the currently active connection
the currently active connection