routes.agent_node
Local Agent Node configuration endpoints.
Configuration (mode, billing entity, sharing) plus the central-service
issued node_uid (ULID) are persisted locally so they survive restarts.
The node_uid is never minted locally — the central
datalayer-runtimes service assigns it on first /register and the
local node persists whatever id the service returns.
register_mode_change_callback
def register_mode_change_callback(callback: Any) -> None
Register a callable invoked whenever the persisted mode changes.
The callback receives the new mode string. Errors are swallowed so a misbehaving subscriber cannot break the configuration update path.
register_credentials_change_callback
def register_credentials_change_callback(callback: Any) -> None
Register a callable invoked whenever the UI-supplied credentials change.
get_runtime_credentials
def get_runtime_credentials() -> dict[str, str | None]
Return UI-supplied runtimes credentials (token, runtimes_url).
set_runtime_credentials
def set_runtime_credentials(token: str | None,
runtimes_url: str | None) -> dict[str, str | None]
Persist UI-supplied credentials so the sync loop can pick them up.
set_agent_node_configuration
def set_agent_node_configuration(
configuration: AgentNodeConfiguration) -> AgentNodeConfiguration
Replace the current configuration, preserving the existing node_uid.
The node_uid is owned by the central service; UI updates must not
overwrite it. Use :func:set_agent_node_uid when the service assigns one.
set_agent_node_uid
def set_agent_node_uid(node_uid: str) -> AgentNodeConfiguration
Persist the ULID assigned by the central datalayer-runtimes service.
set_credentials_endpoint
@router.post("/credentials")
def set_credentials_endpoint(body: AgentNodeCredentialsBody,
request: Request) -> dict[str, Any]
Receive the user's bearer token + runtimes base URL from the UI.
The background sync loop uses these as a fallback when DATALAYER_API_KEY
and DATALAYER_RUNTIMES_URL env vars are not set, so the node can
register and send heartbeats/health once the user signs in.
Security: this endpoint requires an Authorization bearer token to prevent unauthenticated callers from overriding in-memory runtime credentials.
get_sharing_endpoint
@router.get("/sharing")
def get_sharing_endpoint() -> dict[str, Any]
Return the sharing payload in the shape expected by ShareAccessComponent.
set_sharing_endpoint
@router.put("/sharing")
def set_sharing_endpoint(body: dict[str, Any]) -> dict[str, Any]
Replace the sharing portion of the configuration (auto-saved by UI).
auth_bootstrap_endpoint
@router.get("/auth/bootstrap")
async def auth_bootstrap_endpoint() -> dict[str, Any]
Return a session token derived from the env-supplied DATALAYER_API_KEY.
When DATALAYER_API_KEY is set in the container environment, the UI
uses this endpoint to skip the sign-in screen. When it is not set (or the
exchange fails), the response carries has_key=false and the UI shows
its normal sign-in flow.