summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorCasey Bodley <cbodley@redhat.com>2024-02-11 18:17:14 +0100
committerCasey Bodley <cbodley@redhat.com>2024-04-10 19:09:16 +0200
commit6284745661f25c6db0ba5077237c035002153948 (patch)
treeda52ad20817427960fe34a4f69d9f3dc69d4b27e /src
parentrgw/sal: add backend interfaces for group metadata (diff)
downloadceph-6284745661f25c6db0ba5077237c035002153948.tar.xz
ceph-6284745661f25c6db0ba5077237c035002153948.zip
rgw/iam: ListUserPolicies supports Marker/MaxItems
Signed-off-by: Casey Bodley <cbodley@redhat.com>
Diffstat (limited to 'src')
-rw-r--r--src/rgw/rgw_rest_user_policy.cc23
-rw-r--r--src/rgw/rgw_rest_user_policy.h3
2 files changed, 24 insertions, 2 deletions
diff --git a/src/rgw/rgw_rest_user_policy.cc b/src/rgw/rgw_rest_user_policy.cc
index 79d7912d12a..2dc10711ea5 100644
--- a/src/rgw/rgw_rest_user_policy.cc
+++ b/src/rgw/rgw_rest_user_policy.cc
@@ -243,6 +243,19 @@ RGWListUserPolicies::RGWListUserPolicies()
{
}
+int RGWListUserPolicies::get_params()
+{
+ marker = s->info.args.get("Marker");
+
+ int r = s->info.args.get_int("MaxItems", &max_items, max_items);
+ if (r < 0 || max_items > 1000) {
+ s->err.message = "Invalid value for MaxItems";
+ return -EINVAL;
+ }
+
+ return RGWRestUserPolicy::get_params();
+}
+
void RGWListUserPolicies::execute(optional_yield y)
{
std::map<std::string, std::string> policies;
@@ -262,10 +275,16 @@ void RGWListUserPolicies::execute(optional_yield y)
s->formatter->close_section();
s->formatter->open_object_section("ListUserPoliciesResult");
s->formatter->open_array_section("PolicyNames");
- for (const auto& p : policies) {
- s->formatter->dump_string("member", p.first);
+ auto policy = policies.lower_bound(marker);
+ for (; policy != policies.end() && max_items > 0; ++policy, --max_items) {
+ s->formatter->dump_string("member", policy->first);
}
s->formatter->close_section(); // PolicyNames
+ const bool is_truncated = (policy != policies.end());
+ encode_json("IsTruncated", is_truncated, s->formatter);
+ if (is_truncated) {
+ encode_json("Marker", policy->first, s->formatter);
+ }
s->formatter->close_section(); // ListUserPoliciesResult
s->formatter->close_section(); // ListUserPoliciesResponse
}
diff --git a/src/rgw/rgw_rest_user_policy.h b/src/rgw/rgw_rest_user_policy.h
index f4188687f86..117226edc27 100644
--- a/src/rgw/rgw_rest_user_policy.h
+++ b/src/rgw/rgw_rest_user_policy.h
@@ -50,6 +50,9 @@ public:
};
class RGWListUserPolicies : public RGWRestUserPolicy {
+ std::string marker;
+ int max_items = 100;
+ int get_params() override;
public:
RGWListUserPolicies();
void execute(optional_yield y) override;