]> git.proxmox.com Git - ceph.git/blame - ceph/src/rgw/rgw_rest_pubsub_common.h
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / rgw / rgw_rest_pubsub_common.h
CommitLineData
eafe8130
TL
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
9f95a23c
TL
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
12bool validate_and_update_endpoint_secret(rgw_pubsub_sub_dest& dest, CephContext *cct, const RGWEnv& env);
13
eafe8130
TL
14// create a topic
15class RGWPSCreateTopicOp : public RGWDefaultResponseOp {
16protected:
f67539c2 17 std::optional<RGWPubSub> ps;
eafe8130
TL
18 std::string topic_name;
19 rgw_pubsub_sub_dest dest;
20 std::string topic_arn;
9f95a23c 21 std::string opaque_data;
eafe8130
TL
22
23 virtual int get_params() = 0;
24
25public:
f67539c2 26 int verify_permission(optional_yield) override {
eafe8130
TL
27 return 0;
28 }
29 void pre_exec() override {
30 rgw_bucket_object_pre_exec(s);
31 }
f67539c2 32 void execute(optional_yield) override;
eafe8130
TL
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
40class RGWPSListTopicsOp : public RGWOp {
41protected:
f67539c2
TL
42 std::optional<RGWPubSub> ps;
43 rgw_pubsub_topics result;
eafe8130
TL
44
45public:
f67539c2 46 int verify_permission(optional_yield) override {
eafe8130
TL
47 return 0;
48 }
49 void pre_exec() override {
50 rgw_bucket_object_pre_exec(s);
51 }
f67539c2 52 void execute(optional_yield) override;
eafe8130
TL
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
60class RGWPSGetTopicOp : public RGWOp {
61protected:
62 std::string topic_name;
f67539c2 63 std::optional<RGWPubSub> ps;
eafe8130
TL
64 rgw_pubsub_topic_subs result;
65
66 virtual int get_params() = 0;
67
68public:
f67539c2 69 int verify_permission(optional_yield y) override {
eafe8130
TL
70 return 0;
71 }
72 void pre_exec() override {
73 rgw_bucket_object_pre_exec(s);
74 }
f67539c2 75 void execute(optional_yield y) override;
eafe8130
TL
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
83class RGWPSDeleteTopicOp : public RGWDefaultResponseOp {
84protected:
85 string topic_name;
f67539c2 86 std::optional<RGWPubSub> ps;
eafe8130
TL
87
88 virtual int get_params() = 0;
89
90public:
f67539c2 91 int verify_permission(optional_yield) override {
eafe8130
TL
92 return 0;
93 }
94 void pre_exec() override {
95 rgw_bucket_object_pre_exec(s);
96 }
f67539c2 97 void execute(optional_yield y) override;
eafe8130
TL
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
105class RGWPSCreateSubOp : public RGWDefaultResponseOp {
106protected:
107 std::string sub_name;
108 std::string topic_name;
f67539c2 109 std::optional<RGWPubSub> ps;
eafe8130
TL
110 rgw_pubsub_sub_dest dest;
111
112 virtual int get_params() = 0;
113
114public:
f67539c2 115 int verify_permission(optional_yield) override {
eafe8130
TL
116 return 0;
117 }
118 void pre_exec() override {
119 rgw_bucket_object_pre_exec(s);
120 }
f67539c2 121 void execute(optional_yield y) override;
eafe8130
TL
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)
129class RGWPSGetSubOp : public RGWOp {
130protected:
131 std::string sub_name;
f67539c2 132 std::optional<RGWPubSub> ps;
eafe8130
TL
133 rgw_pubsub_sub_config result;
134
135 virtual int get_params() = 0;
136
137public:
f67539c2 138 int verify_permission(optional_yield) override {
eafe8130
TL
139 return 0;
140 }
141 void pre_exec() override {
142 rgw_bucket_object_pre_exec(s);
143 }
f67539c2 144 void execute(optional_yield y) override;
eafe8130
TL
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
152class RGWPSDeleteSubOp : public RGWDefaultResponseOp {
153protected:
154 std::string sub_name;
155 std::string topic_name;
f67539c2 156 std::optional<RGWPubSub> ps;
eafe8130
TL
157
158 virtual int get_params() = 0;
159
160public:
f67539c2 161 int verify_permission(optional_yield) override {
eafe8130
TL
162 return 0;
163 }
164 void pre_exec() override {
165 rgw_bucket_object_pre_exec(s);
166 }
f67539c2 167 void execute(optional_yield y) override;
eafe8130
TL
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
175class RGWPSAckSubEventOp : public RGWDefaultResponseOp {
176protected:
177 std::string sub_name;
178 std::string event_id;
f67539c2 179 std::optional<RGWPubSub> ps;
eafe8130
TL
180
181 virtual int get_params() = 0;
182
183public:
184 RGWPSAckSubEventOp() {}
185
f67539c2 186 int verify_permission(optional_yield) override {
eafe8130
TL
187 return 0;
188 }
189 void pre_exec() override {
190 rgw_bucket_object_pre_exec(s);
191 }
f67539c2 192 void execute(optional_yield y) override;
eafe8130
TL
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
202class RGWPSPullSubEventsOp : public RGWOp {
203protected:
204 int max_entries{0};
205 std::string sub_name;
206 std::string marker;
f67539c2
TL
207 std::optional<RGWPubSub> ps;
208 RGWPubSub::SubRef sub;
eafe8130
TL
209
210 virtual int get_params() = 0;
211
212public:
213 RGWPSPullSubEventsOp() {}
214
f67539c2 215 int verify_permission(optional_yield) override {
eafe8130
TL
216 return 0;
217 }
218 void pre_exec() override {
219 rgw_bucket_object_pre_exec(s);
220 }
f67539c2 221 void execute(optional_yield y) override;
eafe8130
TL
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
229class RGWPSCreateNotifOp : public RGWDefaultResponseOp {
230protected:
f67539c2 231 std::optional<RGWPubSub> ps;
eafe8130
TL
232 string bucket_name;
233 RGWBucketInfo bucket_info;
234
235 virtual int get_params() = 0;
236
237public:
f67539c2 238 int verify_permission(optional_yield y) override;
eafe8130
TL
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
249class RGWPSDeleteNotifOp : public RGWDefaultResponseOp {
250protected:
f67539c2 251 std::optional<RGWPubSub> ps;
eafe8130
TL
252 std::string bucket_name;
253 RGWBucketInfo bucket_info;
254
255 virtual int get_params() = 0;
256
257public:
f67539c2 258 int verify_permission(optional_yield y) override;
eafe8130
TL
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
269class RGWPSListNotifsOp : public RGWOp {
270protected:
271 std::string bucket_name;
272 RGWBucketInfo bucket_info;
f67539c2 273 std::optional<RGWPubSub> ps;
eafe8130
TL
274
275 virtual int get_params() = 0;
276
277public:
f67539c2 278 int verify_permission(optional_yield y) override;
eafe8130
TL
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};