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