|
@@ -10,7 +10,7 @@ void registerCollectionRoutes(ApiServer& s) {
|
|
|
|
|
|
|
|
svr.Post(R"(/api/v1/projects/([^/]+)/collections)", [d](const httplib::Request& req, httplib::Response& res) {
|
|
svr.Post(R"(/api/v1/projects/([^/]+)/collections)", [d](const httplib::Request& req, httplib::Response& res) {
|
|
|
ApiKey k = requireKey(*d, req); std::string project = req.matches[1];
|
|
ApiKey k = requireKey(*d, req); std::string project = req.matches[1];
|
|
|
- requireProjectAccess(k, project);
|
|
|
|
|
|
|
+ requireProjectManage(k, project);
|
|
|
d->db.ensureProject(project); d->registry.ensure(project);
|
|
d->db.ensureProject(project); d->registry.ensure(project);
|
|
|
auto body = bodyJson(req);
|
|
auto body = bodyJson(req);
|
|
|
std::string name = body.value("name", ""), kind = body.value("kind", "json");
|
|
std::string name = body.value("name", ""), kind = body.value("kind", "json");
|
|
@@ -38,7 +38,7 @@ void registerCollectionRoutes(ApiServer& s) {
|
|
|
|
|
|
|
|
svr.Get(R"(/api/v1/projects/([^/]+)/collections)", [d](const httplib::Request& req, httplib::Response& res) {
|
|
svr.Get(R"(/api/v1/projects/([^/]+)/collections)", [d](const httplib::Request& req, httplib::Response& res) {
|
|
|
ApiKey k = requireKey(*d, req); std::string project = req.matches[1];
|
|
ApiKey k = requireKey(*d, req); std::string project = req.matches[1];
|
|
|
- requireProjectAccess(k, project);
|
|
|
|
|
|
|
+ requireProjectManage(k, project);
|
|
|
|
|
|
|
|
auto lower = [](std::string s) {
|
|
auto lower = [](std::string s) {
|
|
|
std::transform(s.begin(), s.end(), s.begin(), [](unsigned char c) { return (char)std::tolower(c); });
|
|
std::transform(s.begin(), s.end(), s.begin(), [](unsigned char c) { return (char)std::tolower(c); });
|
|
@@ -89,7 +89,7 @@ void registerCollectionRoutes(ApiServer& s) {
|
|
|
|
|
|
|
|
svr.Get(R"(/api/v1/projects/([^/]+)/collections/([^/]+))", [d](const httplib::Request& req, httplib::Response& res) {
|
|
svr.Get(R"(/api/v1/projects/([^/]+)/collections/([^/]+))", [d](const httplib::Request& req, httplib::Response& res) {
|
|
|
ApiKey k = requireKey(*d, req); std::string project = req.matches[1], name = req.matches[2];
|
|
ApiKey k = requireKey(*d, req); std::string project = req.matches[1], name = req.matches[2];
|
|
|
- requireProjectAccess(k, project);
|
|
|
|
|
|
|
+ requireProjectManage(k, project);
|
|
|
auto m = d->registry.get(project, name);
|
|
auto m = d->registry.get(project, name);
|
|
|
if (!m) throw ApiError(ErrCode::NotFound, "not_found", "no such collection");
|
|
if (!m) throw ApiError(ErrCode::NotFound, "not_found", "no such collection");
|
|
|
nlohmann::json e = m->toJson();
|
|
nlohmann::json e = m->toJson();
|
|
@@ -101,7 +101,7 @@ void registerCollectionRoutes(ApiServer& s) {
|
|
|
|
|
|
|
|
svr.Delete(R"(/api/v1/projects/([^/]+)/collections/([^/]+))", [d](const httplib::Request& req, httplib::Response& res) {
|
|
svr.Delete(R"(/api/v1/projects/([^/]+)/collections/([^/]+))", [d](const httplib::Request& req, httplib::Response& res) {
|
|
|
ApiKey k = requireKey(*d, req); std::string project = req.matches[1], name = req.matches[2];
|
|
ApiKey k = requireKey(*d, req); std::string project = req.matches[1], name = req.matches[2];
|
|
|
- requireProjectAccess(k, project);
|
|
|
|
|
|
|
+ requireProjectManage(k, project);
|
|
|
if (!d->registry.get(project, name)) throw ApiError(ErrCode::NotFound, "not_found", "no such collection");
|
|
if (!d->registry.get(project, name)) throw ApiError(ErrCode::NotFound, "not_found", "no such collection");
|
|
|
const std::string qc = qualify(project, name);
|
|
const std::string qc = qualify(project, name);
|
|
|
// dropCollection() clears the collection's metadata but does NOT purge the
|
|
// dropCollection() clears the collection's metadata but does NOT purge the
|