mirror of
https://github.com/scylladb/scylladb.git
synced 2026-04-28 04:06:59 +00:00
This adds the API implementation to the column family API. After this patch the following API will be supported: /column_family/name /column_family /column_family/name/keyspace
49 lines
1.4 KiB
C++
49 lines
1.4 KiB
C++
/*
|
|
* Copyright 2015 Cloudius Systems
|
|
*/
|
|
|
|
#include "column_family.hh"
|
|
#include "api/api-doc/column_family.json.hh"
|
|
#include <vector>
|
|
|
|
namespace api {
|
|
|
|
using namespace std;
|
|
namespace cf = httpd::column_family_json;
|
|
|
|
auto get_uuid(const sstring& name, const database& db) {
|
|
auto pos = name.find(':');
|
|
return db.find_uuid(name.substr(0, pos), name.substr(pos + 1));
|
|
}
|
|
void set_column_family(http_context& ctx, routes& r) {
|
|
cf::get_column_family_name.set(r, [&ctx] (const_req req){
|
|
vector<sstring> res;
|
|
for (auto i: ctx.db.local().get_column_families_mapping()) {
|
|
res.push_back(i.first.first + ":" + i.first.second);
|
|
}
|
|
return res;
|
|
});
|
|
|
|
cf::get_column_family.set(r, [&ctx] (const_req req){
|
|
vector<cf::column_family_info> res;
|
|
for (auto i: ctx.db.local().get_column_families_mapping()) {
|
|
cf::column_family_info info;
|
|
info.ks = i.first.first;
|
|
info.cf = i.first.second;
|
|
info.type = "ColumnFamilies";
|
|
res.push_back(info);
|
|
}
|
|
return res;
|
|
});
|
|
|
|
cf::get_column_family_name_keyspace.set(r, [&ctx] (const_req req){
|
|
vector<sstring> res;
|
|
for (auto i = ctx.db.local().get_keyspaces().cbegin(); i!= ctx.db.local().get_keyspaces().cend(); i++) {
|
|
res.push_back(i->first);
|
|
}
|
|
return res;
|
|
});
|
|
}
|
|
|
|
}
|