// Action=CreateTopic&Name=<topic-name>[&OpaqueData=data][&push-endpoint=<endpoint>[&persistent][&<arg1>=<value1>]]
class RGWPSCreateTopicOp : public RGWOp {
private:
+ bufferlist bl_post_body;
std::string topic_name;
rgw_pubsub_dest dest;
std::string topic_arn;
return 0;
}
- public:
- int verify_permission(optional_yield y) override {
+ public:
+ explicit RGWPSCreateTopicOp(bufferlist bl_post_body)
+ : bl_post_body(std::move(bl_post_body)) {}
+
+ int verify_permission(optional_yield y) override {
auto ret = get_params();
if (ret < 0) {
return ret;
void RGWPSCreateTopicOp::execute(optional_yield y) {
// master request will replicate the topic creation.
- bufferlist indata;
if (!driver->is_meta_master()) {
op_ret = rgw_forward_request_to_master(
- this, *s->penv.site, s->user->get_id(), &indata, nullptr, s->info, y);
+ this, *s->penv.site, s->user->get_id(), &bl_post_body, nullptr, s->info, y);
if (op_ret < 0) {
ldpp_dout(this, 1)
<< "CreateTopic forward_request_to_master returned ret = " << op_ret
// Action=SetTopicAttributes&TopicArn=<topic-arn>&AttributeName=<attribute-name>&AttributeValue=<attribute-value>
class RGWPSSetTopicAttributesOp : public RGWOp {
private:
+ bufferlist bl_post_body;
std::string topic_name;
std::string topic_arn;
std::string opaque_data;
}
public:
+ explicit RGWPSSetTopicAttributesOp(bufferlist bl_post_body)
+ : bl_post_body(std::move(bl_post_body)) {}
+
int verify_permission(optional_yield y) override {
auto ret = get_params();
if (ret < 0) {
void RGWPSSetTopicAttributesOp::execute(optional_yield y) {
if (!driver->is_meta_master()) {
- bufferlist indata;
op_ret = rgw_forward_request_to_master(
- this, *s->penv.site, s->user->get_id(), &indata, nullptr, s->info, y);
+ this, *s->penv.site, s->user->get_id(), &bl_post_body, nullptr, s->info, y);
if (op_ret < 0) {
ldpp_dout(this, 1)
<< "SetTopicAttributes forward_request_to_master returned ret = "
// Action=DeleteTopic&TopicArn=<topic-arn>
class RGWPSDeleteTopicOp : public RGWOp {
private:
+ bufferlist bl_post_body;
std::string topic_name;
int get_params() {
return 0;
}
- public:
+ public:
+ explicit RGWPSDeleteTopicOp(bufferlist bl_post_body)
+ : bl_post_body(std::move(bl_post_body)) {}
+
int verify_permission(optional_yield) override {
return 0;
}
return;
}
if (!driver->is_meta_master()) {
- bufferlist indata;
op_ret = rgw_forward_request_to_master(
- this, *s->penv.site, s->user->get_id(), &indata, nullptr, s->info, y);
+ this, *s->penv.site, s->user->get_id(), &bl_post_body, nullptr, s->info, y);
if (op_ret < 0) {
ldpp_dout(this, 1)
<< "DeleteTopic forward_request_to_master returned ret = " << op_ret
ldpp_dout(this, 1) << "successfully removed topic '" << topic_name << "'" << dendl;
}
-using op_generator = RGWOp*(*)();
+using op_generator = RGWOp*(*)(bufferlist);
static const std::unordered_map<std::string, op_generator> op_generators = {
- {"CreateTopic", []() -> RGWOp* { return new RGWPSCreateTopicOp; }},
- {"DeleteTopic", []() -> RGWOp* { return new RGWPSDeleteTopicOp; }},
- {"ListTopics", []() -> RGWOp* { return new RGWPSListTopicsOp; }},
- {"GetTopic", []() -> RGWOp* { return new RGWPSGetTopicOp; }},
+ {"CreateTopic", [](bufferlist bl) -> RGWOp* { return new RGWPSCreateTopicOp(std::move(bl)); }},
+ {"DeleteTopic", [](bufferlist bl) -> RGWOp* { return new RGWPSDeleteTopicOp(std::move(bl)); }},
+ {"ListTopics", [](bufferlist bl) -> RGWOp* { return new RGWPSListTopicsOp; }},
+ {"GetTopic", [](bufferlist bl) -> RGWOp* { return new RGWPSGetTopicOp; }},
{"GetTopicAttributes",
- []() -> RGWOp* { return new RGWPSGetTopicAttributesOp; }},
+ [](bufferlist bl) -> RGWOp* { return new RGWPSGetTopicAttributesOp; }},
{"SetTopicAttributes",
- []() -> RGWOp* { return new RGWPSSetTopicAttributesOp; }}};
+ [](bufferlist bl) -> RGWOp* { return new RGWPSSetTopicAttributesOp(std::move(bl)); }}};
-bool RGWHandler_REST_PSTopic_AWS::action_exists(const req_state* s)
+bool RGWHandler_REST_PSTopic_AWS::action_exists(const req_info& info)
{
- if (s->info.args.exists("Action")) {
- const std::string action_name = s->info.args.get("Action");
- return op_generators.contains(action_name);
- }
- return false;
-}
-bool RGWHandler_REST_PSTopic_AWS::action_exists(const req_info& info) {
if (info.args.exists("Action")) {
const std::string action_name = info.args.get("Action");
return op_generators.contains(action_name);
}
return false;
}
+bool RGWHandler_REST_PSTopic_AWS::action_exists(const req_state* s)
+{
+ return action_exists(s->info);
+}
RGWOp *RGWHandler_REST_PSTopic_AWS::op_post()
{
const std::string action_name = s->info.args.get("Action");
const auto action_it = op_generators.find(action_name);
if (action_it != op_generators.end()) {
- return action_it->second();
+ return action_it->second(std::move(bl_post_body));
}
ldpp_dout(s, 10) << "unknown action '" << action_name << "' for Topic handler" << dendl;
} else {