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