Skip to main content

Examples - api

alarmsjson = '''[{  
"timestamp" : 1525335049 ,
"type" : "Spectrum" ,
"name" : "ES" ,
"id" : "ES" ,
"element" : "Madrid",
"sev" : "3" ,

"eventtype" : "temperature",
"txt": "hello there",
"status": "OK",
"suppressionkey": 1
},

{
"timestamp" : 1525345049 ,
"type" : "Spectrum" ,
"name" : "ES" ,
"id" : "ES" ,
"element" : "Barcelona",
"sev" : "3" ,
"eventtype" : "temperature",
"txt": "hello there",
"status": "NOTOK",
"suppressionkey": 2 }]'''


api.publish(alarmsjson, "Alarm", true)
msg = api.parse("Hello world")
api.publish(msg, "HelloMessageType")

msg = api.newMessage("HelloMessageType")
msg.put("text", "Hello world")

api.publish(msg)

try { res = http.get(url)
} catch (Exception e){
api.sendAlarm("ci","element","eltype","Failed to poll for information","4",5)
}


api.sendMetric("ci", "mount point", "disk", "space", 16)


auth = api.getAuth("1gtw_creds")

println auth.user


api.setMessageType("HelloMessageType")

api.publish("Hello world 1")
api.publish("Hello world 2")
api.publish("Hello world 3")
api.publish("Hello world 4")


res = null
if(res == null)
api.wto("result is null.")


api.addIdmap("Endpoint1", "1", "Endpoint2", "id")

println api.getName()

println api.getEndpoint()

api.audit(parser.asMap(alarmsjson)[0], parser.asMap(alarmsjson)[1], "")

println api.collection()

println api.getConfig(api.getName(), "", "")