Skip to content

Commit

Permalink
add non ocs getscheme endpoint
Browse files Browse the repository at this point in the history
Signed-off-by: grnd-alt <salimbelakkaf@outlook.de>
  • Loading branch information
grnd-alt committed Jul 10, 2024
1 parent 3f17c8d commit 58885db
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions appinfo/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand Down
12 changes: 12 additions & 0 deletions lib/Controller/Api1Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down

0 comments on commit 58885db

Please sign in to comment.