summaryrefslogtreecommitdiff
path: root/update.exs
diff options
context:
space:
mode:
Diffstat (limited to 'update.exs')
-rw-r--r--update.exs22
1 files changed, 17 insertions, 5 deletions
diff --git a/update.exs b/update.exs
index 6e42198..2387fb8 100644
--- a/update.exs
+++ b/update.exs
@@ -1,19 +1,31 @@
defmodule Instance do
defstruct [
instance_type: nil,
+ instance_test: nil,
instance_list: []
]
end
defmodule Instances do
+ def request(url) do
+ case HTTPoison.get(url) do
+ {:ok, %HTTPoison.Response{status_code: 200}} ->
+ # TODO: Add validation of results, not just status code
+ :good
+ _ ->
+ :bad
+ end
+ end
+
def update(filename) do
{:ok, file} = File.read(filename)
{:ok, json} = Poison.decode(file, as: [%Instance{}])
- for x <- json do
- IO.puts(x.instance_type)
- for y <- x.instance_list do
- IO.puts(" - " <> y)
- end
+ for service <- json do
+ result = Enum.filter(service.instance_list, fn(url) ->
+ request(url <> service.instance_test) == :good
+ end)
+ # TODO: Output result to redis
+ IO.inspect(result)
end
end
end