lib/uppityrobot/cli/commands/monitors/list.rb in uppityrobot-0.4.0 vs lib/uppityrobot/cli/commands/monitors/list.rb in uppityrobot-0.4.1
- old
+ new
@@ -17,24 +17,24 @@
'--filter \'{"friendly_name": "^aspace-"}\'',
'--search aspace --filter \'{"status": 0}\''
]
def call(csv: nil, filter: "{}", search: nil, **)
- filter = JSON.parse(filter)
- filtered = { stat: "ok", total: 0, monitors: [] }
- params = search ? { search: search } : {}
- total = 0
+ filter = JSON.parse(filter)
+ filtered = {stat: "ok", total: 0, monitors: []}
+ params = search ? {search: search} : {}
+ total = 0
UppityRobot::Client.new(:getMonitors, params).filter(filter).each do |m|
filtered[:monitors] << m
total += 1
end
filtered[:total] = total
write_csv(csv, filtered[:monitors])
puts filtered.to_json
rescue JSON::ParserError => e
- puts JSON.generate({ stat: "fail", error: "JSON parser #{e.message}" })
+ puts JSON.generate({stat: "fail", error: "JSON parser #{e.message}"})
end
def write_csv(file, data)
return unless file