Add JSON REST API for MCP integration
Build, Lint, and Test / Build, Lint, and Test (push) Failing after 13m0s
Build, Lint, and Test / Build, Lint, and Test (push) Failing after 13m0s
- Add /api/v1 namespace with Bearer token auth (PINCHFLAT_API_TOKEN env var) - API controllers for sources, media items, media profiles, settings, tasks - Support for all source actions: create, update, delete, force_download_pending, force_redownload, force_index, force_metadata_refresh, sync_files_on_disk - Media item endpoints: list, show, search, force_download, update, delete - Media profile CRUD endpoints - Settings show/update and app_info endpoints - Task listing endpoints - Add Jason.Encoder for Task schema - Comprehensive test suite for all API endpoints - Gitea Actions CI workflow (runs existing checks + API-specific tests) - API documentation in docs/API.md
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
defmodule PinchflatWeb.Api.V1.ApiTaskController do
|
||||
@moduledoc """
|
||||
JSON API controller for Tasks.
|
||||
"""
|
||||
|
||||
use PinchflatWeb, :controller
|
||||
|
||||
alias Pinchflat.Repo
|
||||
alias Pinchflat.Tasks
|
||||
|
||||
def index(conn, params) do
|
||||
tasks =
|
||||
case params do
|
||||
%{"source_id" => source_id} ->
|
||||
source = Pinchflat.Sources.get_source!(source_id)
|
||||
Tasks.list_tasks_for(source)
|
||||
|> Repo.preload(:job)
|
||||
|
||||
_ ->
|
||||
Tasks.list_tasks()
|
||||
|> Repo.preload(:job)
|
||||
end
|
||||
|
||||
json(conn, %{data: tasks})
|
||||
end
|
||||
|
||||
def show(conn, %{"id" => id}) do
|
||||
task = Tasks.get_task!(id) |> Repo.preload(:job)
|
||||
json(conn, %{data: task})
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user