]> git.proxmox.com Git - ceph.git/blob - ceph/src/rgw/rgw_rest_log.h
update sources to v12.1.2
[ceph.git] / ceph / src / rgw / rgw_rest_log.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
3 /*
4 * Ceph - scalable distributed file system
5 *
6 * Copyright (C) 2013 eNovance SAS <licensing@enovance.com>
7 *
8 * This is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License version 2.1, as published by the Free Software
11 * Foundation. See file COPYING.
12 *
13 */
14
15 #ifndef RGW_REST_LOG_H
16 #define RGW_REST_LOG_H
17
18 #include "rgw_metadata.h"
19
20 class RGWOp_BILog_List : public RGWRESTOp {
21 bool sent_header;
22 public:
23 RGWOp_BILog_List() : sent_header(false) {}
24 ~RGWOp_BILog_List() override {}
25
26 int check_caps(RGWUserCaps& caps) override {
27 return caps.check_cap("bilog", RGW_CAP_READ);
28 }
29 int verify_permission() override {
30 return check_caps(s->user->caps);
31 }
32 void send_response() override;
33 virtual void send_response(list<rgw_bi_log_entry>& entries, string& marker);
34 virtual void send_response_end();
35 void execute() override;
36 const string name() override {
37 return "list_bucket_index_log";
38 }
39 };
40
41 class RGWOp_BILog_Info : public RGWRESTOp {
42 string bucket_ver;
43 string master_ver;
44 string max_marker;
45 bool syncstopped;
46 public:
47 RGWOp_BILog_Info() : bucket_ver(), master_ver(), syncstopped(false) {}
48 ~RGWOp_BILog_Info() override {}
49
50 int check_caps(RGWUserCaps& caps) override {
51 return caps.check_cap("bilog", RGW_CAP_READ);
52 }
53 int verify_permission() override {
54 return check_caps(s->user->caps);
55 }
56 void send_response() override;
57 void execute() override;
58 const string name() override {
59 return "bucket_index_log_info";
60 }
61 };
62
63 class RGWOp_BILog_Delete : public RGWRESTOp {
64 public:
65 RGWOp_BILog_Delete() {}
66 ~RGWOp_BILog_Delete() override {}
67
68 int check_caps(RGWUserCaps& caps) override {
69 return caps.check_cap("bilog", RGW_CAP_WRITE);
70 }
71 void execute() override;
72 const string name() override {
73 return "trim_bucket_index_log";
74 }
75 };
76
77 class RGWOp_MDLog_List : public RGWRESTOp {
78 list<cls_log_entry> entries;
79 string last_marker;
80 bool truncated;
81 public:
82 RGWOp_MDLog_List() : truncated(false) {}
83 ~RGWOp_MDLog_List() override {}
84
85 int check_caps(RGWUserCaps& caps) override {
86 return caps.check_cap("mdlog", RGW_CAP_READ);
87 }
88 int verify_permission() override {
89 return check_caps(s->user->caps);
90 }
91 void execute() override;
92 void send_response() override;
93 const string name() override {
94 return "list_metadata_log";
95 }
96 };
97
98 class RGWOp_MDLog_Info : public RGWRESTOp {
99 unsigned num_objects;
100 RGWPeriodHistory::Cursor period;
101 public:
102 RGWOp_MDLog_Info() : num_objects(0) {}
103 ~RGWOp_MDLog_Info() override {}
104
105 int check_caps(RGWUserCaps& caps) override {
106 return caps.check_cap("mdlog", RGW_CAP_READ);
107 }
108 int verify_permission() override {
109 return check_caps(s->user->caps);
110 }
111 void execute() override;
112 void send_response() override;
113 const string name() override {
114 return "get_metadata_log_info";
115 }
116 };
117
118 class RGWOp_MDLog_ShardInfo : public RGWRESTOp {
119 RGWMetadataLogInfo info;
120 public:
121 RGWOp_MDLog_ShardInfo() {}
122 ~RGWOp_MDLog_ShardInfo() override {}
123
124 int check_caps(RGWUserCaps& caps) override {
125 return caps.check_cap("mdlog", RGW_CAP_READ);
126 }
127 int verify_permission() override {
128 return check_caps(s->user->caps);
129 }
130 void execute() override;
131 void send_response() override;
132 const string name() override {
133 return "get_metadata_log_shard_info";
134 }
135 };
136
137 class RGWOp_MDLog_Lock : public RGWRESTOp {
138 public:
139 RGWOp_MDLog_Lock() {}
140 ~RGWOp_MDLog_Lock() override {}
141
142 int check_caps(RGWUserCaps& caps) override {
143 return caps.check_cap("mdlog", RGW_CAP_WRITE);
144 }
145 void execute() override;
146 const string name() override {
147 return "lock_mdlog_object";
148 }
149 };
150
151 class RGWOp_MDLog_Unlock : public RGWRESTOp {
152 public:
153 RGWOp_MDLog_Unlock() {}
154 ~RGWOp_MDLog_Unlock() override {}
155
156 int check_caps(RGWUserCaps& caps) override {
157 return caps.check_cap("mdlog", RGW_CAP_WRITE);
158 }
159 void execute() override;
160 const string name() override {
161 return "unlock_mdlog_object";
162 }
163 };
164
165 class RGWOp_MDLog_Notify : public RGWRESTOp {
166 public:
167 RGWOp_MDLog_Notify() {}
168 ~RGWOp_MDLog_Notify() override {}
169
170 int check_caps(RGWUserCaps& caps) override {
171 return caps.check_cap("mdlog", RGW_CAP_WRITE);
172 }
173 void execute() override;
174 const string name() override {
175 return "mdlog_notify";
176 }
177 };
178
179 class RGWOp_MDLog_Delete : public RGWRESTOp {
180 public:
181 RGWOp_MDLog_Delete() {}
182 ~RGWOp_MDLog_Delete() override {}
183
184 int check_caps(RGWUserCaps& caps) override {
185 return caps.check_cap("mdlog", RGW_CAP_WRITE);
186 }
187 void execute() override;
188 const string name() override {
189 return "trim_metadata_log";
190 }
191 };
192
193 class RGWOp_DATALog_List : public RGWRESTOp {
194 list<rgw_data_change_log_entry> entries;
195 string last_marker;
196 bool truncated;
197 bool extra_info;
198 public:
199 RGWOp_DATALog_List() : truncated(false), extra_info(false) {}
200 ~RGWOp_DATALog_List() override {}
201
202 int check_caps(RGWUserCaps& caps) override {
203 return caps.check_cap("datalog", RGW_CAP_READ);
204 }
205 int verify_permission() override {
206 return check_caps(s->user->caps);
207 }
208 void execute() override;
209 void send_response() override;
210 const string name() override {
211 return "list_data_changes_log";
212 }
213 };
214
215 class RGWOp_DATALog_Info : public RGWRESTOp {
216 unsigned num_objects;
217 public:
218 RGWOp_DATALog_Info() : num_objects(0) {}
219 ~RGWOp_DATALog_Info() override {}
220
221 int check_caps(RGWUserCaps& caps) override {
222 return caps.check_cap("datalog", RGW_CAP_READ);
223 }
224 int verify_permission() override {
225 return check_caps(s->user->caps);
226 }
227 void execute() override;
228 void send_response() override;
229 const string name() override {
230 return "get_data_changes_log_info";
231 }
232 };
233
234 class RGWOp_DATALog_ShardInfo : public RGWRESTOp {
235 RGWDataChangesLogInfo info;
236 public:
237 RGWOp_DATALog_ShardInfo() {}
238 ~RGWOp_DATALog_ShardInfo() override {}
239
240 int check_caps(RGWUserCaps& caps) override {
241 return caps.check_cap("datalog", RGW_CAP_READ);
242 }
243 int verify_permission() override {
244 return check_caps(s->user->caps);
245 }
246 void execute() override;
247 void send_response() override;
248 const string name() override {
249 return "get_data_changes_log_shard_info";
250 }
251 };
252
253 class RGWOp_DATALog_Lock : public RGWRESTOp {
254 public:
255 RGWOp_DATALog_Lock() {}
256 ~RGWOp_DATALog_Lock() override {}
257
258 int check_caps(RGWUserCaps& caps) override {
259 return caps.check_cap("datalog", RGW_CAP_WRITE);
260 }
261 void execute() override;
262 const string name() override {
263 return "lock_datalog_object";
264 }
265 };
266
267 class RGWOp_DATALog_Unlock : public RGWRESTOp {
268 public:
269 RGWOp_DATALog_Unlock() {}
270 ~RGWOp_DATALog_Unlock() override {}
271
272 int check_caps(RGWUserCaps& caps) override {
273 return caps.check_cap("datalog", RGW_CAP_WRITE);
274 }
275 void execute() override;
276 const string name() override {
277 return "unlock_datalog_object";
278 }
279 };
280
281 class RGWOp_DATALog_Notify : public RGWRESTOp {
282 public:
283 RGWOp_DATALog_Notify() {}
284 ~RGWOp_DATALog_Notify() override {}
285
286 int check_caps(RGWUserCaps& caps) override {
287 return caps.check_cap("datalog", RGW_CAP_WRITE);
288 }
289 void execute() override;
290 const string name() override {
291 return "datalog_notify";
292 }
293 };
294
295 class RGWOp_DATALog_Delete : public RGWRESTOp {
296 public:
297 RGWOp_DATALog_Delete() {}
298 ~RGWOp_DATALog_Delete() override {}
299
300 int check_caps(RGWUserCaps& caps) override {
301 return caps.check_cap("datalog", RGW_CAP_WRITE);
302 }
303 void execute() override;
304 const string name() override {
305 return "trim_data_changes_log";
306 }
307 };
308
309 class RGWHandler_Log : public RGWHandler_Auth_S3 {
310 protected:
311 RGWOp *op_get() override;
312 RGWOp *op_delete() override;
313 RGWOp *op_post() override;
314
315 int read_permissions(RGWOp*) override {
316 return 0;
317 }
318 public:
319 using RGWHandler_Auth_S3::RGWHandler_Auth_S3;
320 ~RGWHandler_Log() override = default;
321 };
322
323 class RGWRESTMgr_Log : public RGWRESTMgr {
324 public:
325 RGWRESTMgr_Log() = default;
326 ~RGWRESTMgr_Log() override = default;
327
328 RGWHandler_REST* get_handler(struct req_state* const,
329 const rgw::auth::StrategyRegistry& auth_registry,
330 const std::string& frontend_prefixs) override {
331 return new RGWHandler_Log(auth_registry);
332 }
333 };
334
335 #endif /* RGW_REST_LOG_H */