]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: usage trim
authorYehuda Sadeh <yehuda@inktank.com>
Mon, 24 Sep 2012 21:55:39 +0000 (14:55 -0700)
committerYehuda Sadeh <yehuda@inktank.com>
Mon, 8 Oct 2012 18:20:18 +0000 (11:20 -0700)
Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
src/rgw/rgw_rest_usage.cc
src/rgw/rgw_rest_usage.h

index fbe6e7e65ca28b440138fc20347282d8f8c5334d..ec9641588ea49742434dbe3b4ee94920145f78d4 100644 (file)
@@ -30,9 +30,49 @@ void RGWOp_Usage_Get::execute() {
   http_ret = RGWUsage::show(rgwstore, uid, start, end, show_entries, show_summary, &categories, flusher);
 }
 
+class RGWOp_Usage_Delete : public RGWRESTOp {
+
+public:
+  RGWOp_Usage_Delete() {}
+
+  int verify_permission() { return 0; }
+  void execute();
+
+  virtual const char *name() { return "trim_usage"; }
+};
+
+void RGWOp_Usage_Delete::execute() {
+  map<std::string, bool> categories;
+
+  string uid;
+  uint64_t start, end;
+
+  RESTArgs::get_string(s, "uid", uid, &uid);
+  RESTArgs::get_epoch(s, "start", 0, &start);
+  RESTArgs::get_epoch(s, "end", (uint64_t)-1, &end);
+
+  if (uid.empty() &&
+      !start &&
+      end == (uint64_t)-1) {
+    bool remove_all;
+    RESTArgs::get_bool(s, "remove-all", false, &remove_all);
+    if (!remove_all) {
+      http_ret = -EINVAL;
+      return;
+    }
+  }
+
+  http_ret = RGWUsage::trim(rgwstore, uid, start, end);
+}
+
 RGWOp *RGWHandler_Usage::op_get()
 {
   return new RGWOp_Usage_Get;
 };
 
+RGWOp *RGWHandler_Usage::op_delete()
+{
+  return new RGWOp_Usage_Delete;
+};
+
 
index ae975f3529db0bf9d5196fe4235ad5bbea6375cc..6e5224ec0af25098451f7abba58f34cb84f188a3 100644 (file)
@@ -8,7 +8,7 @@
 class RGWHandler_Usage : public RGWHandler_Auth_S3 {
 protected:
   RGWOp *op_get();
-//  RGWOp *op_delete();
+  RGWOp *op_delete();
 public:
   RGWHandler_Usage() {}
   virtual ~RGWHandler_Usage() {}