Packages

A Fair Source multi-agent runtime with deterministic agent scoring and replayable run history.

Retired package: Deprecated - superseded — operator console moved to the Syntropy app

Current section

Files

Jump to
syntropy lib syntropy_web controllers api agent_controller.ex
Raw

lib/syntropy_web/controllers/api/agent_controller.ex

defmodule SyntropyWeb.Api.AgentController do
use SyntropyWeb, :controller
alias Syntropy.ClusterInventory
alias SyntropyWeb.Api.{AgentJSON, ControllerHelpers}
@spec index(Plug.Conn.t(), map()) :: Plug.Conn.t()
def index(conn, _params) do
json(conn, %{data: Enum.map(ClusterInventory.cluster_agents(), &AgentJSON.agent/1)})
end
@spec show(Plug.Conn.t(), map()) :: Plug.Conn.t()
def show(conn, %{"id" => agent_id}) do
case ClusterInventory.find_agent(agent_id) do
nil -> ControllerHelpers.not_found(conn, "Agent", agent_id)
agent -> json(conn, %{data: AgentJSON.agent(agent)})
end
end
end