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