in flex/engines/http_server/handler/admin_http_handler.cc [691:943]
seastar::future<> admin_http_handler::set_routes() {
return server_.set_routes([&](seastar::httpd::routes& r) {
////Procedure management ///
{
auto match_rule =
new seastar::httpd::match_rule(new admin_http_procedure_handler_impl(
interactive_admin_group_id, shard_admin_concurrency,
exclusive_shard_id_));
match_rule->add_str("/v1/graph")
.add_param("graph_id")
.add_str("/procedure");
// Get All procedures
r.add(match_rule, seastar::httpd::operation_type::GET);
}
{
auto match_rule =
new seastar::httpd::match_rule(new admin_http_procedure_handler_impl(
interactive_admin_group_id, shard_admin_concurrency,
exclusive_shard_id_));
match_rule->add_str("/v1/graph")
.add_param("graph_id")
.add_str("/procedure");
// Create a new procedure
r.add(match_rule, seastar::httpd::operation_type::POST);
}
{
// Each procedure's handling
auto match_rule =
new seastar::httpd::match_rule(new admin_http_procedure_handler_impl(
interactive_admin_group_id, shard_admin_concurrency,
exclusive_shard_id_));
match_rule->add_str("/v1/graph")
.add_param("graph_id")
.add_str("/procedure")
.add_param("procedure_id");
// Get a procedure
r.add(new seastar::httpd::match_rule(*match_rule),
seastar::httpd::operation_type::GET);
}
{
// Each procedure's handling
auto match_rule =
new seastar::httpd::match_rule(new admin_http_procedure_handler_impl(
interactive_admin_group_id, shard_admin_concurrency,
exclusive_shard_id_));
match_rule->add_str("/v1/graph")
.add_param("graph_id")
.add_str("/procedure")
.add_param("procedure_id");
// Delete a procedure
r.add(new seastar::httpd::match_rule(*match_rule), SEASTAR_DELETE);
}
{
// Each procedure's handling
auto match_rule =
new seastar::httpd::match_rule(new admin_http_procedure_handler_impl(
interactive_admin_group_id, shard_admin_concurrency,
exclusive_shard_id_));
match_rule->add_str("/v1/graph")
.add_param("graph_id")
.add_str("/procedure")
.add_param("procedure_id");
// Update a procedure
r.add(new seastar::httpd::match_rule(*match_rule),
seastar::httpd::operation_type::PUT);
}
// List all graphs.
r.add(seastar::httpd::operation_type::GET, seastar::httpd::url("/v1/graph"),
new admin_http_graph_handler_impl(interactive_admin_group_id,
shard_admin_concurrency,
exclusive_shard_id_));
// Create a new Graph
r.add(seastar::httpd::operation_type::POST,
seastar::httpd::url("/v1/graph"),
new admin_http_graph_handler_impl(interactive_admin_group_id,
shard_admin_concurrency,
exclusive_shard_id_));
// Delete a graph
r.add(SEASTAR_DELETE,
seastar::httpd::url("/v1/graph").remainder("graph_id"),
new admin_http_graph_handler_impl(interactive_admin_group_id,
shard_admin_concurrency,
exclusive_shard_id_));
{
// uploading file to server
r.add(seastar::httpd::operation_type::POST,
seastar::httpd::url("/v1/file/upload"),
new admin_file_upload_handler_impl(interactive_admin_group_id,
shard_admin_concurrency,
exclusive_shard_id_));
}
// Get graph metadata
{
// by setting full_path = false, we can match /v1/graph/{graph_id}/ and
// /v1/graph/{graph_id}/schema
auto match_rule =
new seastar::httpd::match_rule(new admin_http_graph_handler_impl(
interactive_admin_group_id, shard_admin_concurrency,
exclusive_shard_id_));
match_rule->add_str("/v1/graph").add_param("graph_id", false);
// Get graph schema
r.add(match_rule, seastar::httpd::operation_type::GET);
}
{ // load data to graph
auto match_rule =
new seastar::httpd::match_rule(new admin_http_graph_handler_impl(
interactive_admin_group_id, shard_admin_concurrency,
exclusive_shard_id_));
match_rule->add_str("/v1/graph")
.add_param("graph_id")
.add_str("/dataloading");
r.add(match_rule, seastar::httpd::operation_type::POST);
}
{ // Get Graph Schema
auto match_rule =
new seastar::httpd::match_rule(new admin_http_graph_handler_impl(
interactive_admin_group_id, shard_admin_concurrency,
exclusive_shard_id_));
match_rule->add_str("/v1/graph").add_param("graph_id").add_str("/schema");
r.add(match_rule, seastar::httpd::operation_type::GET);
}
{
// Get running graph statistics
auto match_rule =
new seastar::httpd::match_rule(new admin_http_graph_handler_impl(
interactive_admin_group_id, shard_admin_concurrency,
exclusive_shard_id_));
match_rule->add_str("/v1/graph")
.add_param("graph_id")
.add_str("/statistics");
r.add(match_rule, seastar::httpd::operation_type::GET);
}
{
// Node and service management
r.add(seastar::httpd::operation_type::GET,
seastar::httpd::url("/v1/node/status"),
new admin_http_node_handler_impl(interactive_admin_group_id,
shard_admin_concurrency,
exclusive_shard_id_));
auto match_rule =
new seastar::httpd::match_rule(new admin_http_service_handler_impl(
interactive_admin_group_id, shard_admin_concurrency,
exclusive_shard_id_));
match_rule->add_str("/v1/service").add_param("action");
r.add(match_rule, seastar::httpd::operation_type::POST);
r.add(seastar::httpd::operation_type::GET,
seastar::httpd::url("/v1/service/status"),
new admin_http_service_handler_impl(interactive_admin_group_id,
shard_admin_concurrency,
exclusive_shard_id_));
r.add(seastar::httpd::operation_type::GET,
seastar::httpd::url("/v1/service/ready"),
new admin_http_service_handler_impl(interactive_admin_group_id,
shard_admin_concurrency,
exclusive_shard_id_));
}
{
seastar::httpd::parameters params;
auto test_handler = r.get_handler(seastar::httpd::operation_type::POST,
"/v1/graph/abc/dataloading", params);
CHECK(test_handler);
CHECK(params.exists("graph_id"));
CHECK(params.at("graph_id") == "/abc") << params.at("graph_id");
}
{
seastar::httpd::parameters params;
auto test_handler = r.get_handler(seastar::httpd::operation_type::GET,
"/v1/graph/abc/schema", params);
CHECK(test_handler);
CHECK(params.exists("graph_id"));
CHECK(params.at("graph_id") == "/abc") << params.at("graph_id");
}
{
seastar::httpd::parameters params;
auto test_handler = r.get_handler(seastar::httpd::operation_type::GET,
"/v1/graph/abc", params);
CHECK(test_handler);
CHECK(params.exists("graph_id"));
CHECK(params.at("graph_id") == "/abc") << params.at("graph_id");
}
{
seastar::httpd::parameters params;
auto test_handler = r.get_handler(seastar::httpd::operation_type::GET,
"/v1/graph/abc/procedure", params);
CHECK(test_handler);
CHECK(params.exists("graph_id"));
CHECK(params.at("graph_id") == "/abc") << params.at("graph_id");
}
{
seastar::httpd::parameters params;
auto test_handler = r.get_handler(seastar::httpd::operation_type::POST,
"/v1/graph/abc/procedure", params);
CHECK(test_handler);
CHECK(params.exists("graph_id"));
CHECK(params.at("graph_id") == "/abc") << params.at("graph_id");
}
{
seastar::httpd::parameters params;
auto test_handler =
r.get_handler(seastar::httpd::operation_type::GET,
"/v1/graph/abc/procedure/proce1", params);
CHECK(test_handler);
CHECK(params.exists("graph_id"));
CHECK(params.at("graph_id") == "/abc") << params.at("graph_id");
CHECK(params.exists("procedure_id"));
CHECK(params.at("procedure_id") == "/proce1")
<< params.at("procedure_id");
params.clear();
test_handler = r.get_handler(SEASTAR_DELETE,
"/v1/graph/abc/procedure/proce1", params);
CHECK(test_handler);
test_handler = r.get_handler(seastar::httpd::operation_type::PUT,
"/v1/graph/abc/procedure/proce1", params);
CHECK(test_handler);
}
{
// job request handling.
r.add(seastar::httpd::operation_type::GET, seastar::httpd::url("/v1/job"),
new admin_http_job_handler_impl(interactive_admin_group_id,
shard_admin_concurrency,
exclusive_shard_id_));
auto match_rule =
new seastar::httpd::match_rule(new admin_http_job_handler_impl(
interactive_admin_group_id, shard_admin_concurrency,
exclusive_shard_id_));
match_rule->add_str("/v1/job").add_param("job_id");
r.add(match_rule, seastar::httpd::operation_type::GET);
r.add(SEASTAR_DELETE, seastar::httpd::url("/v1/job").remainder("job_id"),
new admin_http_job_handler_impl(interactive_admin_group_id,
shard_admin_concurrency,
exclusive_shard_id_));
}
return seastar::make_ready_future<>();
});
}