This repository has been archived on 2024-06-24. You can view files and clone it, but cannot push or open issues or pull requests.
balena-device/lib/balena_device.ex
2019-10-19 23:11:28 +08:00

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