Files
scylladb/api/column_family.cc
Amnon Heiman 2be20ff295 API: Add the column familiy implementation
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
2015-06-11 10:12:38 +03:00

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;
});
}
}