1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
7 #include "rgw_pubsub.h"
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
);
15 class RGWPSCreateTopicOp
: public RGWDefaultResponseOp
{
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
;
23 virtual int get_params() = 0;
26 int verify_permission(optional_yield
) override
{
29 void pre_exec() override
{
30 rgw_bucket_object_pre_exec(s
);
32 void execute(optional_yield
) override
;
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
; }
40 class RGWPSListTopicsOp
: public RGWOp
{
42 std::optional
<RGWPubSub
> ps
;
43 rgw_pubsub_topics result
;
46 int verify_permission(optional_yield
) override
{
49 void pre_exec() override
{
50 rgw_bucket_object_pre_exec(s
);
52 void execute(optional_yield
) override
;
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
; }
59 // get topic information
60 class RGWPSGetTopicOp
: public RGWOp
{
62 std::string topic_name
;
63 std::optional
<RGWPubSub
> ps
;
64 rgw_pubsub_topic_subs result
;
66 virtual int get_params() = 0;
69 int verify_permission(optional_yield y
) override
{
72 void pre_exec() override
{
73 rgw_bucket_object_pre_exec(s
);
75 void execute(optional_yield y
) override
;
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
; }
83 class RGWPSDeleteTopicOp
: public RGWDefaultResponseOp
{
85 std::string topic_name
;
86 std::optional
<RGWPubSub
> ps
;
88 virtual int get_params() = 0;
91 int verify_permission(optional_yield
) override
{
94 void pre_exec() override
{
95 rgw_bucket_object_pre_exec(s
);
97 void execute(optional_yield y
) override
;
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
; }
104 // create a subscription
105 class RGWPSCreateSubOp
: public RGWDefaultResponseOp
{
107 std::string sub_name
;
108 std::string topic_name
;
109 std::optional
<RGWPubSub
> ps
;
110 rgw_pubsub_sub_dest dest
;
112 virtual int get_params() = 0;
115 int verify_permission(optional_yield
) override
{
118 void pre_exec() override
{
119 rgw_bucket_object_pre_exec(s
);
121 void execute(optional_yield y
) override
;
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
; }
128 // get subscription information (including push-endpoint if exist)
129 class RGWPSGetSubOp
: public RGWOp
{
131 std::string sub_name
;
132 std::optional
<RGWPubSub
> ps
;
133 rgw_pubsub_sub_config result
;
135 virtual int get_params() = 0;
138 int verify_permission(optional_yield
) override
{
141 void pre_exec() override
{
142 rgw_bucket_object_pre_exec(s
);
144 void execute(optional_yield y
) override
;
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
; }
151 // delete subscription
152 class RGWPSDeleteSubOp
: public RGWDefaultResponseOp
{
154 std::string sub_name
;
155 std::string topic_name
;
156 std::optional
<RGWPubSub
> ps
;
158 virtual int get_params() = 0;
161 int verify_permission(optional_yield
) override
{
164 void pre_exec() override
{
165 rgw_bucket_object_pre_exec(s
);
167 void execute(optional_yield y
) override
;
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
; }
174 // acking of an event
175 class RGWPSAckSubEventOp
: public RGWDefaultResponseOp
{
177 std::string sub_name
;
178 std::string event_id
;
179 std::optional
<RGWPubSub
> ps
;
181 virtual int get_params() = 0;
184 RGWPSAckSubEventOp() {}
186 int verify_permission(optional_yield
) override
{
189 void pre_exec() override
{
190 rgw_bucket_object_pre_exec(s
);
192 void execute(optional_yield y
) override
;
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
; }
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
{
205 std::string sub_name
;
207 std::optional
<RGWPubSub
> ps
;
208 RGWPubSub::SubRef sub
;
210 virtual int get_params() = 0;
213 RGWPSPullSubEventsOp() {}
215 int verify_permission(optional_yield
) override
{
218 void pre_exec() override
{
219 rgw_bucket_object_pre_exec(s
);
221 void execute(optional_yield y
) override
;
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
; }
228 // notification creation
229 class RGWPSCreateNotifOp
: public RGWDefaultResponseOp
{
231 std::optional
<RGWPubSub
> ps
;
232 std::string bucket_name
;
233 RGWBucketInfo bucket_info
;
235 virtual int get_params() = 0;
238 int verify_permission(optional_yield y
) override
;
240 void pre_exec() override
{
241 rgw_bucket_object_pre_exec(s
);
244 RGWOpType
get_type() override
{ return RGW_OP_PUBSUB_NOTIF_CREATE
; }
245 uint32_t op_mask() override
{ return RGW_OP_TYPE_WRITE
; }
248 // delete a notification
249 class RGWPSDeleteNotifOp
: public RGWDefaultResponseOp
{
251 std::optional
<RGWPubSub
> ps
;
252 std::string bucket_name
;
253 RGWBucketInfo bucket_info
;
255 virtual int get_params() = 0;
258 int verify_permission(optional_yield y
) override
;
260 void pre_exec() override
{
261 rgw_bucket_object_pre_exec(s
);
264 RGWOpType
get_type() override
{ return RGW_OP_PUBSUB_NOTIF_DELETE
; }
265 uint32_t op_mask() override
{ return RGW_OP_TYPE_DELETE
; }
268 // get topics/notifications on a bucket
269 class RGWPSListNotifsOp
: public RGWOp
{
271 std::string bucket_name
;
272 RGWBucketInfo bucket_info
;
273 std::optional
<RGWPubSub
> ps
;
275 virtual int get_params() = 0;
278 int verify_permission(optional_yield y
) override
;
280 void pre_exec() override
{
281 rgw_bucket_object_pre_exec(s
);
284 RGWOpType
get_type() override
{ return RGW_OP_PUBSUB_NOTIF_LIST
; }
285 uint32_t op_mask() override
{ return RGW_OP_TYPE_READ
; }