Is there a way to use the Rest API to get the events generated on a specific device?
Release : 20.2.x, 21.2.x
Component : Spectrum Applications
see POST events (GET Tunneling) chapter on
https://techdocs.broadcom.com/us/en/ca-enterprise-software/it-operations-management/spectrum/21-2/programming/web-services-api-reference/how-to-use-the-ca-spectrum-web-services-api/restful-resources-nouns/events.html
Sample of application/xml body to be used in the POST call of URL: http://<OneClick_server>:<portnumber>/spectrum/restful/events/getEvents
<?xml version="1.0" encoding="UTF-8"?>
<rs:get-event-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:get-events-filter start-time="1641738889000" end-time="1641823962000" subcomponents-events="false" exclude-events="0x10005,0x10219,0x10706" />
<rs:requested-attribute id="0x11f56"/>
<rs:requested-attribute id="0x11f4e"/>
<rs:requested-attribute id="0x129fa"/>
<rs:requested-attribute id="0x1006e"/>
<rs:requested-attribute id="0x4820007"/>
<rs:requested-attribute id="0x11fb9"/>
<rs:requested-attribute id="0x482001b"/>
<rs:requested-attribute id="0x482001c"/>
<rs:requested-attribute id="0x10000"/>
<rs:requested-attribute id="0x11fb8"/>
<rs:requested-attribute id="0x12c0a"/>
<!-- Models of Interest -->
<rs:target-models>
<rs:model mh="0x5012dcb"/>
</rs:target-models>
<rs:landscape id="0x5000000" />
</rs:get-event-request>
-------------------------
Specify:
start-time= and end-time= in the epoch format. Note: The difference between end time and start time should be less than 7 days.
subcomponents-events Specifies the events for subcomponents. Set to True if sub-components events are needed.
exclude-events Specifies the events which are excluded. These events if more than one are separated by coma.
model mh= model_handle of the device you want to get the events
landscape id= landscape handle
You can use CURL to launch the above POST rest as follows:
- copy your body in a .xml file (in my example I copied my resful api Body in a file called getEventfunction.xml in the folder C:\Users\Documents
- launch the CURL command from the windows command prompt as follow:
curl -H "Content-Type: application/xml" -X POST http://<OC_server>:<port>/spectrum/restful/events/getEvents -u spectrum:spectrum --data @C:\Users\Documents\getEventfunction.xml -o output.txt
-H is the Header
-X POST (you are running a POST rest API call)
http specify your OC server getEvents API functions
-u specify your user/password to login to the OC server
--data specify the file that contains the body of your call (it should be prefixed by @)
-o specify the output file that will contain the result of your call