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