Skip to content

Commit

Permalink
Stub out the Admin API for transforms
Browse files Browse the repository at this point in the history
Just do the initial wiring up and boilerplate of registering the routes.
Currently all the routes will throw a 404.

Signed-off-by: Tyler Rockwood <rockwood@redpanda.com>
  • Loading branch information
rockwotj committed Sep 12, 2023
1 parent 318b25d commit 5a26ad0
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/v/redpanda/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ set(swags
cluster
debug
usage
shadow_indexing)
shadow_indexing
transform)

set(swag_files)
foreach(swag ${swags})
Expand Down
35 changes: 35 additions & 0 deletions src/v/redpanda/admin_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
#include "redpanda/admin/api-doc/shadow_indexing.json.hh"
#include "redpanda/admin/api-doc/status.json.hh"
#include "redpanda/admin/api-doc/transaction.json.hh"
#include "redpanda/admin/api-doc/transform.json.hh"
#include "redpanda/admin/api-doc/usage.json.hh"
#include "resource_mgmt/memory_sampling.h"
#include "rpc/errc.h"
Expand Down Expand Up @@ -323,6 +324,8 @@ void admin_server::configure_admin_routes() {
rb->register_api_file(_server._routes, "debug");
rb->register_function(_server._routes, insert_comma);
rb->register_api_file(_server._routes, "cluster");
rb->register_function(_server._routes, insert_comma);
rb->register_api_file(_server._routes, "transform");
register_config_routes();
register_cluster_config_routes();
register_raft_routes();
Expand All @@ -339,6 +342,7 @@ void admin_server::configure_admin_routes() {
register_self_test_routes();
register_cluster_routes();
register_shadow_indexing_routes();
register_wasm_transform_routes();
}

namespace {
Expand Down Expand Up @@ -5445,3 +5449,34 @@ admin_server::sampled_memory_profile_handler(
co_return co_await ss::make_ready_future<ss::json::json_return_type>(
std::move(resp));
}

void admin_server::register_wasm_transform_routes() {
register_route_raw_async<superuser>(
ss::httpd::transform_json::deploy_transform,
[this](
std::unique_ptr<ss::http::request> req,
std::unique_ptr<ss::http::reply> rep) {
return deploy_transform(std::move(req), std::move(rep));
});
register_route<user>(
ss::httpd::transform_json::list_transforms,
[this](auto req) { return list_transforms(std::move(req)); });
register_route<superuser>(
ss::httpd::transform_json::delete_transform,
[this](auto req) { return delete_transform(std::move(req)); });
}

ss::future<ss::json::json_return_type>
admin_server::delete_transform(std::unique_ptr<ss::http::request>) {
throw ss::httpd::bad_request_exception("data transforms not enabled");
}

ss::future<ss::json::json_return_type>
admin_server::list_transforms(std::unique_ptr<ss::http::request>) {
throw ss::httpd::bad_request_exception("data transforms not enabled");
}

ss::future<std::unique_ptr<ss::http::reply>> admin_server::deploy_transform(
std::unique_ptr<ss::http::request>, std::unique_ptr<ss::http::reply>) {
throw ss::httpd::bad_request_exception("data transforms not enabled");
}
9 changes: 9 additions & 0 deletions src/v/redpanda/admin_server.h
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@ class admin_server {
void register_self_test_routes();
void register_cluster_routes();
void register_shadow_indexing_routes();
void register_wasm_transform_routes();

ss::future<ss::json::json_return_type> patch_cluster_config_handler(
std::unique_ptr<ss::http::request>, const request_auth_result&);
Expand Down Expand Up @@ -484,6 +485,14 @@ class admin_server {
ss::future<ss::json::json_return_type>
sampled_memory_profile_handler(std::unique_ptr<ss::http::request>);

// Transform routes
ss::future<std::unique_ptr<ss::http::reply>> deploy_transform(
std::unique_ptr<ss::http::request>, std::unique_ptr<ss::http::reply>);
ss::future<ss::json::json_return_type>
list_transforms(std::unique_ptr<ss::http::request>);
ss::future<ss::json::json_return_type>
delete_transform(std::unique_ptr<ss::http::request>);

ss::future<> throw_on_error(
ss::http::request& req,
std::error_code ec,
Expand Down

0 comments on commit 5a26ad0

Please sign in to comment.