I have an automator that is to detect devices with low disk space on C:\ by leveraging the component data. API endpoint is my mydomain.freshservice.com/api/v2/assets/{{asset.display_id}}/components.
Data from GET request:
{
"components":
{
"id": 13000768962,
"created_at": "2020-02-02T08:46:06Z",
"updated_at": "2023-04-10T02:18:31Z",
"component_type": "Logical Drive",
"component_data": "
{
"drive_name": "C",
"file_type": "NTFS",
"capacity": "952",
"drive_type": "Local",
"free_space": "764"
}
]
},
{
"id": 13000768963,
"created_at": "2020-02-02T08:46:06Z",
"updated_at": "2020-02-02T08:46:06Z",
"component_type": "Processor",
"component_data": >
{
"model": "Intel(R) Core(TM) i7-8565U CPU @ 1.80GHz",
"manufacturer": "GenuineIntel",
"no_of_cores": "4",
"cpu_speed": "1.992"
}
]
},
{
"id": 13000768964,
"created_at": "2020-02-02T08:46:06Z",
"updated_at": "2023-04-05T11:46:19Z",
"component_type": "Network Adapter",
"component_data":
{
"nic": " Intel(R) Wireless-AC 9560 160MHz",
"mac_address": "AA:BB:CC:DD:EE:FF",
"ip_addr": "192.168.0.33",
"dhcp_enabled": "True"
}
]
},
{
"id": 13000768965,
"created_at": "2020-02-02T08:46:06Z",
"updated_at": "2020-02-02T08:46:06Z",
"component_type": "Memory",
"component_data":
{
"speed": "2133 Mhz",
"capacity": "8",
"socket": "ChannelA-DIMM0",
"memory_type": "RDRAM"
},
{
"speed": "2133 Mhz",
"capacity": "8",
"socket": "ChannelB-DIMM0",
"memory_type": "RDRAM"
}
]
}
]
}
I then use these JSON paths to get two corresponding String values:
$.components.o?(@.drive_name=='C')].free_space
Returns: e“764”]
$.components.?(@.drive_name=='C')].capacity
Returns: >“952”]
I then go to remove the S“ characters with expression builders, so that I can use a mathematical condition, but run into an issue - the {{P1.free_space}} and {{P2.capacity}} placeholders evaluate as “true” for both, as if they were meant to be a boolean, and I can’t figure out why.
Note: I also realise if I could format the JSONpath in a way that I can get just the values 764 and 952 without being in a JSON format, that I could completely bypass this issue.
Thanks in advance for any assistance!
Regards,
Cody