return -ret;
}
} else {
- RGWPubSub ps(driver, tenant, *site);
+ const std::string& account = !account_id.empty() ? account_id : tenant;
+ RGWPubSub ps(driver, account, *site);
const RGWPubSub::Bucket b(ps, bucket.get());
ret = b.get_topics(dpp(), result, null_yield);
if (ret < 0 && ret != -ENOENT) {
}
if (opt_cmd == OPT::PUBSUB_TOPIC_LIST) {
- RGWPubSub ps(driver, tenant, *site);
+ const std::string& account = !account_id.empty() ? account_id : tenant;
+ RGWPubSub ps(driver, account, *site);
std::string next_token = marker;
std::optional<rgw_owner> owner;
cerr << "ERROR: topic name was not provided (via --topic)" << std::endl;
return EINVAL;
}
- RGWPubSub ps(driver, tenant, *site);
+ const std::string& account = !account_id.empty() ? account_id : tenant;
+ RGWPubSub ps(driver, account, *site);
rgw_pubsub_topic topic;
std::set<std::string> subscribed_buckets;
return -ret;
}
} else {
- RGWPubSub ps(driver, tenant, *site);
+ const std::string& account = !account_id.empty() ? account_id : tenant;
+ RGWPubSub ps(driver, account, *site);
const RGWPubSub::Bucket b(ps, bucket.get());
ret = b.get_topics(dpp(), bucket_topics, null_yield);
if (ret < 0 && ret != -ENOENT) {
return -EINVAL;
}
- RGWPubSub ps(driver, tenant, *site);
+ const std::string& account = !account_id.empty() ? account_id : tenant;
+ RGWPubSub ps(driver, account, *site);
ret = ps.remove_topic(dpp(), topic_name, null_yield);
if (ret < 0) {
ret = remove_notification_v2(dpp(), driver, bucket.get(), notification_id,
null_yield);
} else {
- RGWPubSub ps(driver, tenant, *site);
+ const std::string& account = !account_id.empty() ? account_id : tenant;
+ RGWPubSub ps(driver, account, *site);
rgw_pubsub_bucket_topics bucket_topics;
const RGWPubSub::Bucket b(ps, bucket.get());
#include <boost/tokenizer.hpp>
#include <optional>
#include <regex>
+#include "include/function2.hpp"
#include "rgw_iam_policy.h"
#include "rgw_rest_pubsub.h"
#include "rgw_pubsub_push.h"
return arn;
}
+const std::string& get_account_or_tenant(const rgw_owner& owner)
+{
+ return std::visit(fu2::overload(
+ [] (const rgw_user& u) -> const std::string& { return u.tenant; },
+ [] (const rgw_account_id& a) -> const std::string& { return a; }
+ ), owner);
+}
+
bool topic_has_endpoint_secret(const rgw_pubsub_topic& topic) {
return topic.dest.stored_secret;
}
// the topic ARN will be sent in the reply
topic_arn = rgw::ARN{rgw::Partition::aws, rgw::Service::sns,
driver->get_zone()->get_zonegroup().get_name(),
- s->user->get_tenant(), topic_name};
+ get_account_or_tenant(s->owner.id), topic_name};
return 0;
}
}
// try to load existing topic for owner and policy
- const RGWPubSub ps(driver, s->auth.identity->get_tenant(), *s->penv.site);
+ const RGWPubSub ps(driver, get_account_or_tenant(s->owner.id), *s->penv.site);
rgw_pubsub_topic result;
ret = ps.get_topic(this, topic_name, result, y, nullptr);
if (ret == -ENOENT) {
return;
}
}
- const RGWPubSub ps(driver, s->auth.identity->get_tenant(), *s->penv.site);
+ const RGWPubSub ps(driver, get_account_or_tenant(s->owner.id), *s->penv.site);
op_ret = ps.create_topic(this, topic_name, dest, topic_arn.to_string(),
opaque_data, s->owner.id, policy_text, y);
if (op_ret < 0) {
void RGWPSListTopicsOp::execute(optional_yield y) {
const std::string start_token = s->info.args.get("NextToken");
- const RGWPubSub ps(driver, s->auth.identity->get_tenant(), *s->penv.site);
+ const RGWPubSub ps(driver, get_account_or_tenant(s->owner.id), *s->penv.site);
constexpr int max_items = 100;
op_ret = ps.get_topics(this, start_token, max_items, result, next_token, y);
// if there are no topics it is not considered an error
if (ret < 0) {
return ret;
}
- const RGWPubSub ps(driver, s->auth.identity->get_tenant(), *s->penv.site);
+ const RGWPubSub ps(driver, get_account_or_tenant(s->owner.id), *s->penv.site);
ret = ps.get_topic(this, topic_name, result, y, nullptr);
if (ret < 0) {
ldpp_dout(this, 4) << "failed to get topic '" << topic_name << "', ret=" << ret << dendl;
if (ret < 0) {
return ret;
}
- const RGWPubSub ps(driver, s->auth.identity->get_tenant(), *s->penv.site);
+ const RGWPubSub ps(driver, get_account_or_tenant(s->owner.id), *s->penv.site);
ret = ps.get_topic(this, topic_name, result, y, nullptr);
if (ret < 0) {
ldpp_dout(this, 4) << "failed to get topic '" << topic_name << "', ret=" << ret << dendl;
return ret;
}
- const RGWPubSub ps(driver, s->auth.identity->get_tenant(), *s->penv.site);
+ const RGWPubSub ps(driver, get_account_or_tenant(s->owner.id), *s->penv.site);
ret = ps.get_topic(this, topic_name, result, y, nullptr);
if (ret < 0) {
ldpp_dout(this, 4) << "failed to get topic '" << topic_name
return;
}
}
- const RGWPubSub ps(driver, s->auth.identity->get_tenant(), *s->penv.site);
+ const RGWPubSub ps(driver, get_account_or_tenant(s->owner.id), *s->penv.site);
op_ret = ps.create_topic(this, topic_name, dest, topic_arn.to_string(),
opaque_data, topic_owner, policy_text, y);
if (op_ret < 0) {
return ret;
}
- const RGWPubSub ps(driver, s->auth.identity->get_tenant(), *s->penv.site);
+ const RGWPubSub ps(driver, get_account_or_tenant(s->owner.id), *s->penv.site);
rgw_pubsub_topic result;
ret = ps.get_topic(this, topic_name, result, y, nullptr);
if (ret == -ENOENT) {
return;
}
- const RGWPubSub ps(driver, s->auth.identity->get_tenant(), *s->penv.site);
+ const RGWPubSub ps(driver, get_account_or_tenant(s->owner.id), *s->penv.site);
op_ret = ps.remove_topic(this, topic_name, y);
if (op_ret < 0 && op_ret != -ENOENT) {
ldpp_dout(this, 4) << "failed to remove topic '" << topic_name << ", ret=" << op_ret << dendl;
return ret;
}
- const RGWPubSub ps(driver, s->auth.identity->get_tenant(), *s->penv.site);
+ const RGWPubSub ps(driver, get_account_or_tenant(s->owner.id), *s->penv.site);
for (const auto& c : configurations.list) {
const auto& notif_name = c.id;
return execute_v2(y);
}
- const RGWPubSub ps(driver, s->auth.identity->get_tenant(), *s->penv.site);
+ const RGWPubSub ps(driver, get_account_or_tenant(s->owner.id), *s->penv.site);
const RGWPubSub::Bucket b(ps, s->bucket.get());
if(configurations.list.empty()) {
<< s->bucket << ", ret = " << op_ret << dendl;
return;
}
- const RGWPubSub ps(driver, s->auth.identity->get_tenant(), *s->penv.site);
+ const RGWPubSub ps(driver, get_account_or_tenant(s->owner.id), *s->penv.site);
for (const auto& c : configurations.list) {
const auto& notif_name = c.id;
return execute_v2(y);
}
- const RGWPubSub ps(driver, s->auth.identity->get_tenant(), *s->penv.site);
+ const RGWPubSub ps(driver, get_account_or_tenant(s->owner.id), *s->penv.site);
const RGWPubSub::Bucket b(ps, s->bucket.get());
// get all topics on a bucket
driver->stat_topics_v1(s->bucket_tenant, y, this) == -ENOENT) {
op_ret = get_bucket_notifications(this, bucket.get(), bucket_topics);
} else {
- const RGWPubSub ps(driver, s->auth.identity->get_tenant(), *s->penv.site);
+ const RGWPubSub ps(driver, get_account_or_tenant(s->owner.id), *s->penv.site);
const RGWPubSub::Bucket b(ps, bucket.get());
op_ret = b.get_topics(this, bucket_topics, y);
}