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"
10 class RGWPSCreateTopicOp
: public RGWDefaultResponseOp
{
12 std::optional
<RGWUserPubSub
> ups
;
13 std::string topic_name
;
14 rgw_pubsub_sub_dest dest
;
15 std::string topic_arn
;
17 virtual int get_params() = 0;
20 int verify_permission() override
{
23 void pre_exec() override
{
24 rgw_bucket_object_pre_exec(s
);
26 void execute() override
;
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
; }
34 class RGWPSListTopicsOp
: public RGWOp
{
36 std::optional
<RGWUserPubSub
> ups
;
37 rgw_pubsub_user_topics result
;
40 int verify_permission() override
{
43 void pre_exec() override
{
44 rgw_bucket_object_pre_exec(s
);
46 void execute() override
;
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
; }
53 // get topic information
54 class RGWPSGetTopicOp
: public RGWOp
{
56 std::string topic_name
;
57 std::optional
<RGWUserPubSub
> ups
;
58 rgw_pubsub_topic_subs result
;
60 virtual int get_params() = 0;
63 int verify_permission() override
{
66 void pre_exec() override
{
67 rgw_bucket_object_pre_exec(s
);
69 void execute() override
;
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
; }
77 class RGWPSDeleteTopicOp
: public RGWDefaultResponseOp
{
80 std::optional
<RGWUserPubSub
> ups
;
82 virtual int get_params() = 0;
85 int verify_permission() override
{
88 void pre_exec() override
{
89 rgw_bucket_object_pre_exec(s
);
91 void execute() override
;
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
; }
98 // create a subscription
99 class RGWPSCreateSubOp
: public RGWDefaultResponseOp
{
101 std::string sub_name
;
102 std::string topic_name
;
103 std::optional
<RGWUserPubSub
> ups
;
104 rgw_pubsub_sub_dest dest
;
106 virtual int get_params() = 0;
109 int verify_permission() override
{
112 void pre_exec() override
{
113 rgw_bucket_object_pre_exec(s
);
115 void execute() override
;
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
; }
122 // get subscription information (including push-endpoint if exist)
123 class RGWPSGetSubOp
: public RGWOp
{
125 std::string sub_name
;
126 std::optional
<RGWUserPubSub
> ups
;
127 rgw_pubsub_sub_config result
;
129 virtual int get_params() = 0;
132 int verify_permission() override
{
135 void pre_exec() override
{
136 rgw_bucket_object_pre_exec(s
);
138 void execute() override
;
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
; }
145 // delete subscription
146 class RGWPSDeleteSubOp
: public RGWDefaultResponseOp
{
148 std::string sub_name
;
149 std::string topic_name
;
150 std::optional
<RGWUserPubSub
> ups
;
152 virtual int get_params() = 0;
155 int verify_permission() override
{
158 void pre_exec() override
{
159 rgw_bucket_object_pre_exec(s
);
161 void execute() override
;
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
; }
168 // acking of an event
169 class RGWPSAckSubEventOp
: public RGWDefaultResponseOp
{
171 std::string sub_name
;
172 std::string event_id
;
173 std::optional
<RGWUserPubSub
> ups
;
175 virtual int get_params() = 0;
178 RGWPSAckSubEventOp() {}
180 int verify_permission() override
{
183 void pre_exec() override
{
184 rgw_bucket_object_pre_exec(s
);
186 void execute() override
;
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
; }
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
{
199 std::string sub_name
;
201 std::optional
<RGWUserPubSub
> ups
;
202 RGWUserPubSub::SubRef sub
;
204 virtual int get_params() = 0;
207 RGWPSPullSubEventsOp() {}
209 int verify_permission() override
{
212 void pre_exec() override
{
213 rgw_bucket_object_pre_exec(s
);
215 void execute() override
;
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
; }
222 // notification creation
223 class RGWPSCreateNotifOp
: public RGWDefaultResponseOp
{
225 std::optional
<RGWUserPubSub
> ups
;
227 RGWBucketInfo bucket_info
;
229 virtual int get_params() = 0;
232 int verify_permission() override
;
234 void pre_exec() override
{
235 rgw_bucket_object_pre_exec(s
);
238 RGWOpType
get_type() override
{ return RGW_OP_PUBSUB_NOTIF_CREATE
; }
239 uint32_t op_mask() override
{ return RGW_OP_TYPE_WRITE
; }
242 // delete a notification
243 class RGWPSDeleteNotifOp
: public RGWDefaultResponseOp
{
245 std::optional
<RGWUserPubSub
> ups
;
246 std::string bucket_name
;
247 RGWBucketInfo bucket_info
;
249 virtual int get_params() = 0;
252 int verify_permission() override
;
254 void pre_exec() override
{
255 rgw_bucket_object_pre_exec(s
);
258 RGWOpType
get_type() override
{ return RGW_OP_PUBSUB_NOTIF_DELETE
; }
259 uint32_t op_mask() override
{ return RGW_OP_TYPE_DELETE
; }
262 // get topics/notifications on a bucket
263 class RGWPSListNotifsOp
: public RGWOp
{
265 std::string bucket_name
;
266 RGWBucketInfo bucket_info
;
267 std::optional
<RGWUserPubSub
> ups
;
269 virtual int get_params() = 0;
272 int verify_permission() override
;
274 void pre_exec() override
{
275 rgw_bucket_object_pre_exec(s
);
278 RGWOpType
get_type() override
{ return RGW_OP_PUBSUB_NOTIF_LIST
; }
279 uint32_t op_mask() override
{ return RGW_OP_TYPE_READ
; }