29 lines
717 B
Elixir
29 lines
717 B
Elixir
defmodule BalenaDevice do
|
|
alias BalenaDevice.HTTP
|
|
alias HTTPoison.Response
|
|
|
|
@moduledoc """
|
|
Wraps the Balena DBUS and Supervisor HTTP APIs to allow Elixir apps running on
|
|
the Balena platform to manipulate their environment.
|
|
"""
|
|
|
|
# An application ID.
|
|
@type app_id :: non_neg_integer
|
|
|
|
@doc """
|
|
Ping the device supervisor to ensure that it is alive and well.
|
|
"""
|
|
@spec ping() :: :ok | {:error, term}
|
|
def ping do
|
|
case HTTP.get("/ping") do
|
|
{:ok, %Response{body: "OK", status_code: 200}} ->
|
|
:ok
|
|
|
|
{:ok, %Response{body: body, status_code: status}} ->
|
|
{:error, "Status #{status}: #{inspect(body)}"}
|
|
|
|
{:error, reason} ->
|
|
{:error, reason}
|
|
end
|
|
end
|
|
end
|