1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab ft=cpp
5 * Ceph - scalable distributed file system
7 * Copyright (C) 2013 eNovance SAS <licensing@enovance.com>
9 * This is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License version 2.1, as published by the Free Software
12 * Foundation. See file COPYING.
18 #include "rgw_metadata.h"
19 #include "rgw_mdlog.h"
21 class RGWOp_BILog_List
: public RGWRESTOp
{
24 RGWOp_BILog_List() : sent_header(false) {}
25 ~RGWOp_BILog_List() override
{}
27 int check_caps(const RGWUserCaps
& caps
) override
{
28 return caps
.check_cap("bilog", RGW_CAP_READ
);
30 int verify_permission() override
{
31 return check_caps(s
->user
->get_caps());
33 void send_response() override
;
34 virtual void send_response(list
<rgw_bi_log_entry
>& entries
, string
& marker
);
35 virtual void send_response_end();
36 void execute() override
;
37 const char* name() const override
{
38 return "list_bucket_index_log";
42 class RGWOp_BILog_Info
: public RGWRESTOp
{
48 RGWOp_BILog_Info() : bucket_ver(), master_ver(), syncstopped(false) {}
49 ~RGWOp_BILog_Info() override
{}
51 int check_caps(const RGWUserCaps
& caps
) override
{
52 return caps
.check_cap("bilog", RGW_CAP_READ
);
54 int verify_permission() override
{
55 return check_caps(s
->user
->get_caps());
57 void send_response() override
;
58 void execute() override
;
59 const char* name() const override
{
60 return "bucket_index_log_info";
64 class RGWOp_BILog_Delete
: public RGWRESTOp
{
66 RGWOp_BILog_Delete() {}
67 ~RGWOp_BILog_Delete() override
{}
69 int check_caps(const RGWUserCaps
& caps
) override
{
70 return caps
.check_cap("bilog", RGW_CAP_WRITE
);
72 void execute() override
;
73 const char* name() const override
{
74 return "trim_bucket_index_log";
78 class RGWOp_MDLog_List
: public RGWRESTOp
{
79 list
<cls_log_entry
> entries
;
83 RGWOp_MDLog_List() : truncated(false) {}
84 ~RGWOp_MDLog_List() override
{}
86 int check_caps(const RGWUserCaps
& caps
) override
{
87 return caps
.check_cap("mdlog", RGW_CAP_READ
);
89 int verify_permission() override
{
90 return check_caps(s
->user
->get_caps());
92 void execute() override
;
93 void send_response() override
;
94 const char* name() const override
{
95 return "list_metadata_log";
99 class RGWOp_MDLog_Info
: public RGWRESTOp
{
100 unsigned num_objects
;
101 RGWPeriodHistory::Cursor period
;
103 RGWOp_MDLog_Info() : num_objects(0) {}
104 ~RGWOp_MDLog_Info() override
{}
106 int check_caps(const RGWUserCaps
& caps
) override
{
107 return caps
.check_cap("mdlog", RGW_CAP_READ
);
109 int verify_permission() override
{
110 return check_caps(s
->user
->get_caps());
112 void execute() override
;
113 void send_response() override
;
114 const char* name() const override
{
115 return "get_metadata_log_info";
119 class RGWOp_MDLog_ShardInfo
: public RGWRESTOp
{
120 RGWMetadataLogInfo info
;
122 RGWOp_MDLog_ShardInfo() {}
123 ~RGWOp_MDLog_ShardInfo() override
{}
125 int check_caps(const RGWUserCaps
& caps
) override
{
126 return caps
.check_cap("mdlog", RGW_CAP_READ
);
128 int verify_permission() override
{
129 return check_caps(s
->user
->get_caps());
131 void execute() override
;
132 void send_response() override
;
133 const char* name() const override
{
134 return "get_metadata_log_shard_info";
138 class RGWOp_MDLog_Lock
: public RGWRESTOp
{
140 RGWOp_MDLog_Lock() {}
141 ~RGWOp_MDLog_Lock() override
{}
143 int check_caps(const RGWUserCaps
& caps
) override
{
144 return caps
.check_cap("mdlog", RGW_CAP_WRITE
);
146 void execute() override
;
147 const char* name() const override
{
148 return "lock_mdlog_object";
152 class RGWOp_MDLog_Unlock
: public RGWRESTOp
{
154 RGWOp_MDLog_Unlock() {}
155 ~RGWOp_MDLog_Unlock() override
{}
157 int check_caps(const RGWUserCaps
& caps
) override
{
158 return caps
.check_cap("mdlog", RGW_CAP_WRITE
);
160 void execute() override
;
161 const char* name() const override
{
162 return "unlock_mdlog_object";
166 class RGWOp_MDLog_Notify
: public RGWRESTOp
{
168 RGWOp_MDLog_Notify() {}
169 ~RGWOp_MDLog_Notify() override
{}
171 int check_caps(const RGWUserCaps
& caps
) override
{
172 return caps
.check_cap("mdlog", RGW_CAP_WRITE
);
174 void execute() override
;
175 const char* name() const override
{
176 return "mdlog_notify";
180 class RGWOp_MDLog_Delete
: public RGWRESTOp
{
182 RGWOp_MDLog_Delete() {}
183 ~RGWOp_MDLog_Delete() override
{}
185 int check_caps(const RGWUserCaps
& caps
) override
{
186 return caps
.check_cap("mdlog", RGW_CAP_WRITE
);
188 void execute() override
;
189 const char* name() const override
{
190 return "trim_metadata_log";
194 class RGWOp_DATALog_List
: public RGWRESTOp
{
195 list
<rgw_data_change_log_entry
> entries
;
200 RGWOp_DATALog_List() : truncated(false), extra_info(false) {}
201 ~RGWOp_DATALog_List() override
{}
203 int check_caps(const RGWUserCaps
& caps
) override
{
204 return caps
.check_cap("datalog", RGW_CAP_READ
);
206 int verify_permission() override
{
207 return check_caps(s
->user
->get_caps());
209 void execute() override
;
210 void send_response() override
;
211 const char* name() const override
{
212 return "list_data_changes_log";
216 class RGWOp_DATALog_Info
: public RGWRESTOp
{
217 unsigned num_objects
;
219 RGWOp_DATALog_Info() : num_objects(0) {}
220 ~RGWOp_DATALog_Info() override
{}
222 int check_caps(const RGWUserCaps
& caps
) override
{
223 return caps
.check_cap("datalog", RGW_CAP_READ
);
225 int verify_permission() override
{
226 return check_caps(s
->user
->get_caps());
228 void execute() override
;
229 void send_response() override
;
230 const char* name() const override
{
231 return "get_data_changes_log_info";
235 class RGWOp_DATALog_ShardInfo
: public RGWRESTOp
{
236 RGWDataChangesLogInfo info
;
238 RGWOp_DATALog_ShardInfo() {}
239 ~RGWOp_DATALog_ShardInfo() override
{}
241 int check_caps(const RGWUserCaps
& caps
) override
{
242 return caps
.check_cap("datalog", RGW_CAP_READ
);
244 int verify_permission() override
{
245 return check_caps(s
->user
->get_caps());
247 void execute() override
;
248 void send_response() override
;
249 const char* name() const override
{
250 return "get_data_changes_log_shard_info";
254 class RGWOp_DATALog_Notify
: public RGWRESTOp
{
256 RGWOp_DATALog_Notify() {}
257 ~RGWOp_DATALog_Notify() override
{}
259 int check_caps(const RGWUserCaps
& caps
) override
{
260 return caps
.check_cap("datalog", RGW_CAP_WRITE
);
262 void execute() override
;
263 const char* name() const override
{
264 return "datalog_notify";
268 class RGWOp_DATALog_Delete
: public RGWRESTOp
{
270 RGWOp_DATALog_Delete() {}
271 ~RGWOp_DATALog_Delete() override
{}
273 int check_caps(const RGWUserCaps
& caps
) override
{
274 return caps
.check_cap("datalog", RGW_CAP_WRITE
);
276 void execute() override
;
277 const char* name() const override
{
278 return "trim_data_changes_log";
282 class RGWHandler_Log
: public RGWHandler_Auth_S3
{
284 RGWOp
*op_get() override
;
285 RGWOp
*op_delete() override
;
286 RGWOp
*op_post() override
;
288 int read_permissions(RGWOp
*) override
{
292 using RGWHandler_Auth_S3::RGWHandler_Auth_S3
;
293 ~RGWHandler_Log() override
= default;
296 class RGWRESTMgr_Log
: public RGWRESTMgr
{
298 RGWRESTMgr_Log() = default;
299 ~RGWRESTMgr_Log() override
= default;
301 RGWHandler_REST
* get_handler(struct req_state
* const,
302 const rgw::auth::StrategyRegistry
& auth_registry
,
303 const std::string
& frontend_prefixs
) override
{
304 return new RGWHandler_Log(auth_registry
);