lib/jss/api_object/mdm.rb
def mdm_command_xml(command, options, targets)
        raise JSS::MissingDataError, 'Targets cannot be empty' if targets.empty?

        case self::MDM_COMMAND_TARGET
        when *COMPUTER_TARGETS
          command_elem = COMPUTER_COMMAND_ELEMENT
          target_list_elem = JSS::Computer::RSRC_LIST_KEY.to_s
          target_elem = JSS::Computer::RSRC_OBJECT_KEY.to_s
        when *DEVICE_TARGETS
          command_elem = DEVICE_COMMAND_ELEMENT
          target_list_elem = JSS::MobileDevice::RSRC_LIST_KEY.to_s
          target_elem = JSS::MobileDevice::RSRC_OBJECT_KEY.to_s
        else
          raise JSS::NoSuchItemError, "Unknonwn MDM command target: #{self::MDM_COMMAND_TARGET}"
        end # case

        xml = REXML::Document.new JSS::APIConnection::XML_HEADER
        cmd_xml = xml.add_element command_elem

        general = cmd_xml.add_element GENERAL_ELEMENT
        general.add_element(COMMAND_ELEMENT).text = command
        options.each do |opt, val|
          general.add_element(opt.to_s).text = val.to_s
        end # do opt val

        tgt_list = cmd_xml.add_element target_list_elem
        targets.each do |tgt_id|
          tgt = tgt_list.add_element(target_elem)
          tgt.add_element(TARGET_ID_ELEMENT).text = tgt_id.to_s
        end

        xml.to_s
      end
# Generate the XML to send to the API, sending the MDM command to the targets
#
# @param command [Symbol] the command to be sent, a key from COMMANDS
#
# @param options [Hash] different commands require different options,
#   see each command method
#
# @param targets[String,Integer,Array<String,Integer>] @see .send_mdm_command
#
# @return [String] The XML content to send to the API
#
Generate the XML to send to the API, sending the MDM command to the targets
Generate the XML to send to the API sending the MDM command to the targets
def mdm_command_xml(command, options, targets)
        raise JSS::MissingDataError, 'Targets cannot be empty' if targets.empty?
        case self::MDM_COMMAND_TARGET
        when *COMPUTER_TARGETS
          command_elem = COMPUTER_COMMAND_ELEMENT
          target_list_elem = JSS::Computer::RSRC_LIST_KEY.to_s
          target_elem = JSS::Computer::RSRC_OBJECT_KEY.to_s
        when *DEVICE_TARGETS
          command_elem = DEVICE_COMMAND_ELEMENT
          target_list_elem = JSS::MobileDevice::RSRC_LIST_KEY.to_s
          target_elem = JSS::MobileDevice::RSRC_OBJECT_KEY.to_s
        else
          raise JSS::NoSuchItemError, "Unknonwn MDM command target: #{self::MDM_COMMAND_TARGET}"
        end 
        xml = REXML::Document.new JSS::APIConnection::XML_HEADER
        cmd_xml = xml.add_element command_elem
        general = cmd_xml.add_element GENERAL_ELEMENT
        general.add_element(COMMAND_ELEMENT).text = command
        options.each do |opt, val|
          general.add_element(opt.to_s).text = val.to_s
        end 
        tgt_list = cmd_xml.add_element target_list_elem
        targets.each do |tgt_id|
          tgt = tgt_list.add_element(target_elem)
          tgt.add_element(TARGET_ID_ELEMENT).text = tgt_id.to_s
        end
        xml.to_s
      end
def mdm_command_xml ( command , options , targets ) raise JSS :: MissingDataError , 'Targets cannot be empty' if targets . empty? case self :: MDM_COMMAND_TARGET when * COMPUTER_TARGETS command_elem = COMPUTER_COMMAND_ELEMENT target_list_elem = JSS :: Computer :: RSRC_LIST_KEY . to_s target_elem = JSS :: Computer :: RSRC_OBJECT_KEY . to_s when * DEVICE_TARGETS command_elem = DEVICE_COMMAND_ELEMENT target_list_elem = JSS :: MobileDevice :: RSRC_LIST_KEY . to_s target_elem = JSS :: MobileDevice :: RSRC_OBJECT_KEY . to_s else raise JSS :: NoSuchItemError , "Unknonwn MDM command target: #{self::MDM_COMMAND_TARGET}" end xml = REXML :: Document . new JSS :: APIConnection :: XML_HEADER cmd_xml = xml . add_element command_elem general = cmd_xml . add_element GENERAL_ELEMENT general . add_element ( COMMAND_ELEMENT ) . text = command options . each do | opt , val | general . add_element ( opt . to_s ) . text = val . to_s end tgt_list = cmd_xml . add_element target_list_elem targets . each do | tgt_id | tgt = tgt_list . add_element ( target_elem ) tgt . add_element ( TARGET_ID_ELEMENT ) . text = tgt_id . to_s end xml . to_s end
Generate the XML to send to the API, sending the MDM command to the targets
Generate the XML to send to the API sending the MDM command to the targets
# case # do opt val
The XML content to send to the API
The XML content to send to the API
String
command
the command to be sent, a key from COMMANDS
the command to be sent a key from COMMANDS
options
different commands require different options, see each command method
different commands require different options see each command method
targets
None