DX NetOps

  • 1.  Initiating Device search from RESTful API

    Posted Oct 23, 2015 05:08 AM

    Hi everyone,

     

    I have a custom search which I launch from the OneClick GUI. I'd like to be able to retrieve the results of this search through the REST API.

     

    The search results are the IP address and hostname (attributes listed below) of a specific model but the API is only giving me the Model Handle.

     

    Any help here would be appreciated.

     

    The URL I'm pointing my request at is http://<oneclick-IP>:8080/spectrum/restful/devices

     

    And my xml request is:

    <rs:model-request throttlesize="10"
      xmlns:rs="http://www.ca.com/spectrum/restful/schema/request"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://www.ca.com/spectrum/restful/schema/request ../../../xsd/Request.xsd ">
        <rs:target-models>
          <rs:models-search>
            <rs:search-criteria-file>
              <$SPECROOT>/custom/console/config/search-5624a63f-01d1-1000-1fdc-0a0101720000.xml
            </rs:search-criteria-file>
          </rs:models-search>
        </rs:target-models>
        <rs:requested-attribute id="0x1027f" />
        <rs:requested-attribute id="0x1006e" />
    </rs:model-request>
    

     

    Thanks.



  • 2.  Re: Initiating Device search from RESTful API
    Best Answer

    Posted Oct 23, 2015 04:04 PM

    Hi,

    only some thoughts.

    rename the search into a more simple name like 'mysearch1.xml'

    the URL should be:  http://<oneclick-IP>:8080/spectrum/restful/models !!!

    Do not forget to specify the encoding of the XML!

     

    Put the XML-Content into a WeBPage like post3.html which is contained in my examples from the DACHSUG 2015 (German Spectrum USergroup) to get the result out of the query via AJAX/Javascript. DACHSUG 2015 - CA Spectrum REST-API Unlimited? Praktischer Einsatz der REST-API

    .. open the ZIP-File and copy all or only some files to the tomcat/webappps/spectrum/ ... and change the XML in the File post3.xml... post3.xml fetches only the alarms, not the models.

    In the file post4.html You could identify how to extract attributes out of alarms. change it to models and YOu will get the 2 attributes out of the XML-Response.

    .. example post5.html explains only how to integrate CSS and styling for mobile devices.

    If You are able to transform it, we would like to see the result here again.

     

     

    <?xml version="1.0" encoding="UTF-8"?>

    <rs:model-request throttlesize="100"

      xmlns:rs="http://www.ca.com/spectrum/restful/schema/request"

      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

      xsi:schemaLocation="http://www.ca.com/spectrum/restful/schema/request ../../../xsd/Request.xsd">

        <rs:target-models>

          <rs:models-search>

            <rs:search-criteria-file>

                topo/config/search-devices-criteria.xml <!-- Name of the custom search criteria file, do not use the complete path  -->

            </rs:search-criteria-file>

          </rs:models-search>

        </rs:target-models>

        <rs:requested-attribute id="0x1006e" />        <!-- Model Name -->

        <rs:requested-attribute id="0x12d7f" />        <!-- Network Address -->

    </rs:model-request>

     

     

    Probably I have to translate my german presentation

    Hopfully the changes help a bit.



  • 3.  Re: Initiating Device search from RESTful API

    Posted Apr 11, 2016 09:52 AM

    Erich, thank you very much for your help. Apologies I did not mark your answer sooner.

     

    I used your suggestion to write a python script which issues a GET with your XML payload to launch the search. It worked perfectly and I was able to manipulate the results as I wanted.

     

    Thanks
    -M