2 Replies Latest reply on Dec 19, 2013 2:50 PM by timothyt

    Suppressing "OK:" Message and Others

    timothyt

      ePO seems to typically respond with an "OK:" message when a command has been successfully issued via the API. Unfortunately, when requesting output in XML or JSON format, using the :output parameter, this message prevents the output from being used as XML or JSON data without first manipulating the output to strip out the "OK:" message.

       

      1. Is there any way to suppress the output of the "OK:" message upon issuance of a successful command?

       

      2. Is there any way to suppress the output of other headers, such as those printed when performing an ad hoc query against the ePO database?

       

      In addition, it has come to my attention that receipt of the "OK:" message does not actually indicate that the operation has completed. For example, when using the repository.changeBranch command to move a package from one branch to another, if a subsequent repository.checkInPackage command is issued too quickly, an error message will be output indicating that repository is busy, despite already having received the "OK:" message following the first command.

       

      3. Is there any way to confirm that the first operation has actually been completed before attempting the second?

        • 1. Re: Suppressing "OK:" Message and Others
          jking

          1. You can't supress it.  I'm not sure what you mean about the other ad-hod queries -- are you using the python client or straight curl?  If you're using the python client, it's handled internally.  If you're hitting the server with curl or some other command line/language you'll need to strip that line yourself.  If you've got tail available, you can do this automatically with a tail -n+2.  e.g. curl -qks -u <name>:<pass> 'https://server:8443/remote/core.help' | tail -n+2

           

          2. I'm not sure which headers you mean, unless you're pulling it in terse mode (adding a :output=terse) on the command line.  If you expect to consume the data with a program, you probably want either xml or json output, so use :output=xml or :output=json. 

           

          3. There are a few (a very few) command whose success basically means "we've successfully kicked off the process".  You'd have to either wait longer than the expected completion time, or use another command to determine whether the command is completed (e.g. using repository.findPackage might work for your use case), or simply loop and sleep until the error condition goes away or you reach a max # of retries.

           

          Jon

          • 2. Re: Suppressing "OK:" Message and Others
            timothyt

            I'm using curl. Unfortunately, I can't use the Python client, as this functionality will eventually be built into existing C++ software; and the customer machines on which the software will be run do not have Python installed.

             

            I believe you have answered my first question--there is no option to suppress the "OK:" message--I must strip that out myself.

             

            For the second question, a good example is the following command to list the IP addresses of all Windows computers:
            core.executeQuery?target=EPOComputerProperties&select=(select (distinct) EPOComputerProperties.IPAddress)&where=(where(contains EPOComputerProperties.OSType "Windows"))&order=(order(asc EPOComputerProperties.IPAddress))&:output=terse

             

            That query will return something similar to the following:

            OK:

            IP Address

            ------------

            192.168.1.1

            192.168.1.2

            192.168.1.3

             

            The headers to which I am referring in the second question are the "IP Address" and "------------" lines just below the "OK:" message. In other words, is there any way to get a query to just return the DATA? It sounds to me like the answer is no--the :output parameter should be set to XML or JSON and those formats processed instead. I believe that answers my second question.

             

            In regard to the third question, thank you for the idea about using repository.findPackage in this scenario. I believe that answers my third question.

             

            If I might make a suggestion, it would be that McAfee make a decision if the "OK:" message means that the operation has been completed, or simply that the process has been kicked off, and do that consistently for all commands. Knowing when an operation has completed seems to be more useful to me; but I have also seen cases where an API offers both a synchronous (I'll wait) and asynchronous (Kick off the process and let me continue) option. Perhaps McAfee would consider adding a parameter to these command giving the choice of synchronous or asynchronous operation. At the very least, if the behavior differs from command to command, please consider documenting that in help for the command.