FSMServiceLevelPolicy: How do I change SpecificTimeRange in a Script?


     We are trying to build a dashboard in PowerBI to report on SLAs for the last day, 7 days, and 30 days. We are trying to us the uptime and downtime properties of FSMServiceLevelPolicy to calculate the availability. I would like to build a custom Rest API to get this information, but I am stuck on just trying to get the script to work. The problem I am having with the script is that I can not figure out how to change the time range to what I want to use. I can create a custom SpacificTimeRange object, but I can't seem to get it to apply to anything. I pass it to getObject, but it still uses what ever is set in the UI if I am using the script console, and if I use function I created in Definitions, if just ignores the time range all together. Below is the script I am using any help would be greatly appreciated. 

import static java.util.Calendar.*;
def cal = Calendar.getInstance();
start = new Date() - 7
end = new Date()

altStart = start
range = end.time - start.time;
altTimeRange = null;
sevenDays = 7 * 24 * 60 * 60 * 1000
altStart = new Date(start.time - sevenDays)

altTimeRange = functionHelper.invokeFunction("system:wcf_common.9", range, altStart, 0)
def altSpecificTimeRange = altTimeRange.createTimeRange(cal);

ts = server.TopologyService
slp = ts.getType("FSMServiceLevelPolicy")
serviceList = ts.getObjectsOfType(slp)

serviceList.each { 
     SevenDObject = ts.getObject(it.uniqueId, altSpecificTimeRange)
     println SevenDObject.uptime

Parents Reply Children
No Data