DX NetOps

 View Only
  • 1.  REST - Referencing alarm filters in request

    Posted May 24, 2017 01:47 PM

    I have heard that with 10.2 we can now utilize named filters in a REST alarm query.  I've scoured through the documentation and searched the RestfulExamples directory, but I can not figure out how I can formation the REST query.  Has anyone tried this?  If so, do you have any examples or suggestions for the syntax of the XML?

     

    Example,

    I have a filter under my account called "spectrum".  This filter displays only those alarms that I am interested in as a Spectrum admin for knowing the health of the Spectrum servers.

    I would like to run a REST query to retrieve those alarms that match the "spectrum" filter.

     

    I tried: 

    <?xml version="1.0" encoding="UTF-8"?>
    <rs:alarm-request
    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:alarm-filter name=spectrum />
    </rs:alarm-request>

    But this returned all alarms.  It didn't act like it even looked at my filter.

     

    What am I doing wrong?



  • 2.  Re: REST - Referencing alarm filters in request
    Best Answer

    Broadcom Employee
    Posted May 24, 2017 10:13 PM

    Please refer to Using Alarm Resources - Post Alarm Filter 

     

    You need to send a POST request, i.e. 

    http://<OneClick Server IP>:<port>/spectrum/restful/alarms/filter?name=<filter name>

     

    e.g. with the following XML

    <?xml version="1.0" encoding="UTF-8"?>
    <rs:alarm-request throttlesize="0"
    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:requested-attribute id="0x10000"/> <!--Model Type Name-->
    <rs:requested-attribute id="0x10001"/> <!--Model Type of Alarmed Model-->
    <rs:requested-attribute id="0x10009"/> <!--Security String-->
    <rs:requested-attribute id="0x1000a"/> <!--Condition-->
    <rs:requested-attribute id="0x1006e"/> <!--Model Name-->
    <rs:requested-attribute id="0x11ee8"/> <!--Model Class-->
    </rs:alarm-request>


  • 3.  Re: REST - Referencing alarm filters in request

    Posted May 25, 2017 10:02 AM

    That worked great.  Thanks for the quick response.



  • 4.  Re: REST - Referencing alarm filters in request

    Posted Mar 14, 2019 10:17 AM

    This does not work for me. I use exactly the same XML and filter name which should return hundreds of alarms, but returns nothing:



  • 5.  Re: REST - Referencing alarm filters in request

    Posted Mar 14, 2019 12:30 PM

    It does not work for me like aurimasp with Postman.

     

    The simple request  "http://<hostname><: portnumber>/spectrum/restful/alarms/filters" produces two different answers depending on the tool used.

    With Firefox:

     

    With Postman:

     



  • 6.  RE: Re: REST - Referencing alarm filters in request

    Posted Jan 07, 2020 12:01 PM

    Not sure if this applies to you, but I was successful on my end using this article.

    https://ca-broadcom.wolkenservicedesk.com/external/article?articleId=77691

    For Spectrum 10.2.2+
    Using a Webservices REST Client under String Body using application/xml, charset=UTF-8
    You will not include the filtername in the URL, but it will be included in the header body instead:
     
    http://<server:port>/spectrum/restful/alarms/filter
     
    Webservices Post with the header info of:

    <?xml version="1.0" encoding="UTF-8"?>
    <rs:alarm-request throttlesize="5"
    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 ">
    <!-- This xml can be posted to the Alarms URL to obtain
    attributes on the specified alarms
    -->
    <!-- Attributes of Interest -->
    <!-- -->
    <rs:requested-attribute id="0x1006e" />
    <rs:requested-attribute id="0x129fa" />
    <rs:requested-attribute id="0x11ee8" />
    <rs:requested-attribute id="0x12d7f" />
    <rs:requested-attribute id="0x10000"/> <!--Model Type Name-->
    <rs:requested-attribute id="0x10001"/> <!--Model Type of Alarmed Model-->
    <rs:requested-attribute id="0x10009"/> <!--Security String-->
    <rs:requested-attribute id="0x1000a"/> <!--Condition-->
    <rs:requested-attribute id="0x1006e"/> <!--Model Name-->
    <rs:requested-attribute id="0x11ee8"/> <!--Model Class-->

    <rs:alarm-filter name="filter_name"/>

    </rs:alarm-request>