]> git.proxmox.com Git - ceph.git/blob - ceph/src/rgw/rgw_rest_pubsub_common.h
import ceph 14.2.5
[ceph.git] / ceph / src / rgw / rgw_rest_pubsub_common.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
3 #pragma once
4 #include <string>
5 #include <optional>
6 #include "rgw_op.h"
7 #include "rgw_pubsub.h"
8
9 // create a topic
10 class RGWPSCreateTopicOp : public RGWDefaultResponseOp {
11 protected:
12 std::optional<RGWUserPubSub> ups;
13 std::string topic_name;
14 rgw_pubsub_sub_dest dest;
15 std::string topic_arn;
16
17 virtual int get_params() = 0;
18
19 public:
20 int verify_permission() override {
21 return 0;
22 }
23 void pre_exec() override {
24 rgw_bucket_object_pre_exec(s);
25 }
26 void execute() override;
27
28 const char* name() const override { return "pubsub_topic_create"; }
29 RGWOpType get_type() override { return RGW_OP_PUBSUB_TOPIC_CREATE; }
30 uint32_t op_mask() override { return RGW_OP_TYPE_WRITE; }
31 };
32
33 // list all topics
34 class RGWPSListTopicsOp : public RGWOp {
35 protected:
36 std::optional<RGWUserPubSub> ups;
37 rgw_pubsub_user_topics result;
38
39 public:
40 int verify_permission() override {
41 return 0;
42 }
43 void pre_exec() override {
44 rgw_bucket_object_pre_exec(s);
45 }
46 void execute() override;
47
48 const char* name() const override { return "pubsub_topics_list"; }
49 RGWOpType get_type() override { return RGW_OP_PUBSUB_TOPICS_LIST; }
50 uint32_t op_mask() override { return RGW_OP_TYPE_READ; }
51 };
52
53 // get topic information
54 class RGWPSGetTopicOp : public RGWOp {
55 protected:
56 std::string topic_name;
57 std::optional<RGWUserPubSub> ups;
58 rgw_pubsub_topic_subs result;
59
60 virtual int get_params() = 0;
61
62 public:
63 int verify_permission() override {
64 return 0;
65 }
66 void pre_exec() override {
67 rgw_bucket_object_pre_exec(s);
68 }
69 void execute() override;
70
71 const char* name() const override { return "pubsub_topic_get"; }
72 RGWOpType get_type() override { return RGW_OP_PUBSUB_TOPIC_GET; }
73 uint32_t op_mask() override { return RGW_OP_TYPE_READ; }
74 };
75
76 // delete a topic
77 class RGWPSDeleteTopicOp : public RGWDefaultResponseOp {
78 protected:
79 string topic_name;
80 std::optional<RGWUserPubSub> ups;
81
82 virtual int get_params() = 0;
83
84 public:
85 int verify_permission() override {
86 return 0;
87 }
88 void pre_exec() override {
89 rgw_bucket_object_pre_exec(s);
90 }
91 void execute() override;
92
93 const char* name() const override { return "pubsub_topic_delete"; }
94 RGWOpType get_type() override { return RGW_OP_PUBSUB_TOPIC_DELETE; }
95 uint32_t op_mask() override { return RGW_OP_TYPE_DELETE; }
96 };
97
98 // create a subscription
99 class RGWPSCreateSubOp : public RGWDefaultResponseOp {
100 protected:
101 std::string sub_name;
102 std::string topic_name;
103 std::optional<RGWUserPubSub> ups;
104 rgw_pubsub_sub_dest dest;
105
106 virtual int get_params() = 0;
107
108 public:
109 int verify_permission() override {
110 return 0;
111 }
112 void pre_exec() override {
113 rgw_bucket_object_pre_exec(s);
114 }
115 void execute() override;
116
117 const char* name() const override { return "pubsub_subscription_create"; }
118 RGWOpType get_type() override { return RGW_OP_PUBSUB_SUB_CREATE; }
119 uint32_t op_mask() override { return RGW_OP_TYPE_WRITE; }
120 };
121
122 // get subscription information (including push-endpoint if exist)
123 class RGWPSGetSubOp : public RGWOp {
124 protected:
125 std::string sub_name;
126 std::optional<RGWUserPubSub> ups;
127 rgw_pubsub_sub_config result;
128
129 virtual int get_params() = 0;
130
131 public:
132 int verify_permission() override {
133 return 0;
134 }
135 void pre_exec() override {
136 rgw_bucket_object_pre_exec(s);
137 }
138 void execute() override;
139
140 const char* name() const override { return "pubsub_subscription_get"; }
141 RGWOpType get_type() override { return RGW_OP_PUBSUB_SUB_GET; }
142 uint32_t op_mask() override { return RGW_OP_TYPE_READ; }
143 };
144
145 // delete subscription
146 class RGWPSDeleteSubOp : public RGWDefaultResponseOp {
147 protected:
148 std::string sub_name;
149 std::string topic_name;
150 std::optional<RGWUserPubSub> ups;
151
152 virtual int get_params() = 0;
153
154 public:
155 int verify_permission() override {
156 return 0;
157 }
158 void pre_exec() override {
159 rgw_bucket_object_pre_exec(s);
160 }
161 void execute() override;
162
163 const char* name() const override { return "pubsub_subscription_delete"; }
164 RGWOpType get_type() override { return RGW_OP_PUBSUB_SUB_DELETE; }
165 uint32_t op_mask() override { return RGW_OP_TYPE_DELETE; }
166 };
167
168 // acking of an event
169 class RGWPSAckSubEventOp : public RGWDefaultResponseOp {
170 protected:
171 std::string sub_name;
172 std::string event_id;
173 std::optional<RGWUserPubSub> ups;
174
175 virtual int get_params() = 0;
176
177 public:
178 RGWPSAckSubEventOp() {}
179
180 int verify_permission() override {
181 return 0;
182 }
183 void pre_exec() override {
184 rgw_bucket_object_pre_exec(s);
185 }
186 void execute() override;
187
188 const char* name() const override { return "pubsub_subscription_ack"; }
189 RGWOpType get_type() override { return RGW_OP_PUBSUB_SUB_ACK; }
190 uint32_t op_mask() override { return RGW_OP_TYPE_WRITE; }
191 };
192
193 // fetching events from a subscription
194 // dpending on whether the subscription was created via s3 compliant API or not
195 // the matching events will be returned
196 class RGWPSPullSubEventsOp : public RGWOp {
197 protected:
198 int max_entries{0};
199 std::string sub_name;
200 std::string marker;
201 std::optional<RGWUserPubSub> ups;
202 RGWUserPubSub::SubRef sub;
203
204 virtual int get_params() = 0;
205
206 public:
207 RGWPSPullSubEventsOp() {}
208
209 int verify_permission() override {
210 return 0;
211 }
212 void pre_exec() override {
213 rgw_bucket_object_pre_exec(s);
214 }
215 void execute() override;
216
217 const char* name() const override { return "pubsub_subscription_pull"; }
218 RGWOpType get_type() override { return RGW_OP_PUBSUB_SUB_PULL; }
219 uint32_t op_mask() override { return RGW_OP_TYPE_READ; }
220 };
221
222 // notification creation
223 class RGWPSCreateNotifOp : public RGWDefaultResponseOp {
224 protected:
225 std::optional<RGWUserPubSub> ups;
226 string bucket_name;
227 RGWBucketInfo bucket_info;
228
229 virtual int get_params() = 0;
230
231 public:
232 int verify_permission() override;
233
234 void pre_exec() override {
235 rgw_bucket_object_pre_exec(s);
236 }
237
238 RGWOpType get_type() override { return RGW_OP_PUBSUB_NOTIF_CREATE; }
239 uint32_t op_mask() override { return RGW_OP_TYPE_WRITE; }
240 };
241
242 // delete a notification
243 class RGWPSDeleteNotifOp : public RGWDefaultResponseOp {
244 protected:
245 std::optional<RGWUserPubSub> ups;
246 std::string bucket_name;
247 RGWBucketInfo bucket_info;
248
249 virtual int get_params() = 0;
250
251 public:
252 int verify_permission() override;
253
254 void pre_exec() override {
255 rgw_bucket_object_pre_exec(s);
256 }
257
258 RGWOpType get_type() override { return RGW_OP_PUBSUB_NOTIF_DELETE; }
259 uint32_t op_mask() override { return RGW_OP_TYPE_DELETE; }
260 };
261
262 // get topics/notifications on a bucket
263 class RGWPSListNotifsOp : public RGWOp {
264 protected:
265 std::string bucket_name;
266 RGWBucketInfo bucket_info;
267 std::optional<RGWUserPubSub> ups;
268
269 virtual int get_params() = 0;
270
271 public:
272 int verify_permission() override;
273
274 void pre_exec() override {
275 rgw_bucket_object_pre_exec(s);
276 }
277
278 RGWOpType get_type() override { return RGW_OP_PUBSUB_NOTIF_LIST; }
279 uint32_t op_mask() override { return RGW_OP_TYPE_READ; }
280 };
281