-- name: InsertLLMEndpoint :one
INSERT INTO llm_endpoints (id, provider, display_name, base_url, api_key_encrypted, created_by)
VALUES ($1, $2, $3, $4, $5, $6)
RETURNING *;

-- name: GetLLMEndpoint :one
SELECT * FROM llm_endpoints WHERE id = $1;

-- name: ListLLMEndpoints :many
SELECT * FROM llm_endpoints ORDER BY created_at DESC;

-- name: UpdateLLMEndpoint :exec
UPDATE llm_endpoints
SET display_name = COALESCE($2, display_name),
    base_url = COALESCE($3, base_url),
    api_key_encrypted = COALESCE($4, api_key_encrypted),
    updated_at = NOW()
WHERE id = $1;

-- name: DeleteLLMEndpoint :exec
DELETE FROM llm_endpoints WHERE id = $1;
