From: Casey Bodley Date: Wed, 1 Nov 2023 19:47:59 +0000 (-0400) Subject: rgw: add struct RGWAccountInfo X-Git-Tag: v19.1.0~99^2~159 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=684877c2320cadc9cd46cc8a69ad0210a2ff84f1;p=ceph.git rgw: add struct RGWAccountInfo initial design and prototype by Abhishek Signed-off-by: Abhishek Lekshmanan Signed-off-by: Casey Bodley (cherry picked from commit 59bbd65bac0ea41ec8cca844b9b65b9def026467) --- diff --git a/src/rgw/rgw_common.cc b/src/rgw/rgw_common.cc index 681fc8e4103..ea93ad889fb 100644 --- a/src/rgw/rgw_common.cc +++ b/src/rgw/rgw_common.cc @@ -2970,6 +2970,51 @@ void RGWAccessKey::decode_json(JSONObj *obj, bool swift) { JSONDecoder::decode_json("active", active, obj); } + +void RGWAccountInfo::dump(Formatter * const f) const +{ + encode_json("id", id, f); + encode_json("tenant", tenant, f); + encode_json("name", name, f); + encode_json("email", email, f); + encode_json("quota", quota, f); + encode_json("max_users", max_users, f); + encode_json("max_roles", max_roles, f); + encode_json("max_groups", max_groups, f); + encode_json("max_buckets", max_buckets, f); + encode_json("max_access_keys", max_access_keys, f); +} + +void RGWAccountInfo::decode_json(JSONObj* obj) +{ + JSONDecoder::decode_json("id", id, obj); + JSONDecoder::decode_json("tenant", tenant, obj); + JSONDecoder::decode_json("name", name, obj); + JSONDecoder::decode_json("email", email, obj); + JSONDecoder::decode_json("quota", quota, obj); + JSONDecoder::decode_json("max_users", max_users, obj); + JSONDecoder::decode_json("max_roles", max_roles, obj); + JSONDecoder::decode_json("max_groups", max_groups, obj); + JSONDecoder::decode_json("max_buckets", max_buckets, obj); + JSONDecoder::decode_json("max_access_keys", max_access_keys, obj); +} + +void RGWAccountInfo::generate_test_instances(std::list& o) +{ + o.push_back(new RGWAccountInfo); + auto p = new RGWAccountInfo; + p->id = "account1"; + p->tenant = "tenant1"; + p->name = "name1"; + p->email = "email@example.com"; + p->max_users = 10; + p->max_roles = 10; + p->max_groups = 10; + p->max_buckets = 10; + p->max_access_keys = 10; + o.push_back(p); +} + void RGWStorageStats::dump(Formatter *f) const { encode_json("size", size, f); diff --git a/src/rgw/rgw_common.h b/src/rgw/rgw_common.h index 897b06ac282..1b84391d713 100644 --- a/src/rgw/rgw_common.h +++ b/src/rgw/rgw_common.h @@ -747,6 +747,65 @@ struct RGWUserInfo }; WRITE_CLASS_ENCODER(RGWUserInfo) +// user account metadata +struct RGWAccountInfo { + rgw_account_id id; + std::string tenant; + std::string name; + std::string email; + RGWQuotaInfo quota; + + static constexpr int32_t DEFAULT_USER_LIMIT = 1000; + int32_t max_users = DEFAULT_USER_LIMIT; + + static constexpr int32_t DEFAULT_ROLE_LIMIT = 1000; + int32_t max_roles = DEFAULT_ROLE_LIMIT; + + static constexpr int32_t DEFAULT_GROUP_LIMIT = 1000; + int32_t max_groups = DEFAULT_GROUP_LIMIT; + + static constexpr int32_t DEFAULT_BUCKET_LIMIT = 1000; + int32_t max_buckets = DEFAULT_BUCKET_LIMIT; + + static constexpr int32_t DEFAULT_ACCESS_KEY_LIMIT = 4; + int32_t max_access_keys = DEFAULT_ACCESS_KEY_LIMIT; + + void encode(bufferlist& bl) const { + ENCODE_START(1, 1, bl); + encode(id, bl); + encode(tenant, bl); + encode(name, bl); + encode(email, bl); + encode(quota, bl); + encode(max_users, bl); + encode(max_roles, bl); + encode(max_groups, bl); + encode(max_buckets, bl); + encode(max_access_keys, bl); + ENCODE_FINISH(bl); + } + + void decode(bufferlist::const_iterator& bl) { + DECODE_START(1, bl); + decode(id, bl); + decode(tenant, bl); + decode(name, bl); + decode(email, bl); + decode(quota, bl); + decode(max_users, bl); + decode(max_roles, bl); + decode(max_groups, bl); + decode(max_buckets, bl); + decode(max_access_keys, bl); + DECODE_FINISH(bl); + } + + void dump(Formatter* f) const; + void decode_json(JSONObj* obj); + static void generate_test_instances(std::list& o); +}; +WRITE_CLASS_ENCODER(RGWAccountInfo) + /// `RGWObjVersionTracker` /// ====================== /// diff --git a/src/tools/ceph-dencoder/rgw_types.h b/src/tools/ceph-dencoder/rgw_types.h index 45d6921c5be..97a3330d7db 100644 --- a/src/tools/ceph-dencoder/rgw_types.h +++ b/src/tools/ceph-dencoder/rgw_types.h @@ -153,6 +153,7 @@ TYPE(obj_version) TYPE(RGWAccessKey) TYPE(RGWSubUser) TYPE(RGWUserInfo) +TYPE(RGWAccountInfo) TYPE(rgw_bucket) TYPE(RGWBucketInfo) TYPE(RGWBucketEnt)