From 58885db2f7c28afb9b709b20b1911cfec5377560 Mon Sep 17 00:00:00 2001 From: grnd-alt Date: Wed, 10 Jul 2024 12:00:27 +0200 Subject: [PATCH] add non ocs getscheme endpoint Signed-off-by: grnd-alt --- appinfo/routes.php | 1 + lib/Controller/Api1Controller.php | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/appinfo/routes.php b/appinfo/routes.php index 86e50da00..71e7a8d47 100644 --- a/appinfo/routes.php +++ b/appinfo/routes.php @@ -20,6 +20,7 @@ ['name' => 'api1#createTable', 'url' => '/api/1/tables', 'verb' => 'POST'], ['name' => 'api1#updateTable', 'url' => '/api/1/tables/{tableId}', 'verb' => 'PUT'], ['name' => 'api1#getTable', 'url' => '/api/1/tables/{tableId}', 'verb' => 'GET'], + ['name' => 'api1#showScheme', 'url' => '/api/1/tables/{tableId}/scheme', 'verb' => 'GET'], ['name' => 'api1#deleteTable', 'url' => '/api/1/tables/{tableId}', 'verb' => 'DELETE'], // -> views ['name' => 'api1#indexViews', 'url' => '/api/1/tables/{tableId}/views', 'verb' => 'GET'], diff --git a/lib/Controller/Api1Controller.php b/lib/Controller/Api1Controller.php index 839d71971..cb1181e61 100644 --- a/lib/Controller/Api1Controller.php +++ b/lib/Controller/Api1Controller.php @@ -132,6 +132,18 @@ public function createTable(string $title, ?string $emoji, string $template = 'c } } + /** + * returns table scheme + * @param int $tableId + * @return \OCP\AppFramework\Http\DataResponse + */ + public function showScheme(int $tableId): DataResponse { + return $this->handleError(function () use ($tableId) { + $scheme = $this->tableService->getScheme($tableId); + return new DataResponse($scheme->jsonSerialize(), http::STATUS_OK, ["Content-Disposition" => "attachment", "filename" => $scheme->getTitle() . ".json", "Content-Type" => "application/octet-stream"]); + }); + } + /** * Get a table object *