]> git.proxmox.com Git - ceph.git/blob - ceph/src/rgw/rgw_role.h
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / rgw / rgw_role.h
1 #ifndef CEPH_RGW_ROLE_H
2 #define CEPH_RGW_ROLE_H
3
4 class RGWRole
5 {
6 static const string role_name_oid_prefix;
7 static const string role_oid_prefix;
8 static const string role_path_oid_prefix;
9 static const string role_arn_prefix;
10
11 CephContext *cct;
12 RGWRados *store;
13 string id;
14 string name;
15 string path;
16 string arn;
17 string creation_date;
18 string trust_policy;
19 map<string, string> perm_policy_map;
20 string uid;
21
22 int store_info(bool exclusive);
23 int store_name(bool exclusive);
24 int store_path(bool exclusive);
25 int read_id(const string& role_name, string& role_id);
26 int read_name();
27 int read_info();
28 void set_id(const string& id) { this->id = id; }
29
30 public:
31 RGWRole(CephContext *cct,
32 RGWRados *store,
33 string name,
34 string path,
35 string trust_policy,
36 string uid)
37 : cct(cct),
38 store(store),
39 name(std::move(name)),
40 path(std::move(path)),
41 trust_policy(std::move(trust_policy)),
42 uid(std::move(uid)) {
43 if (this->path.empty())
44 this->path = "/";
45 }
46
47 RGWRole(CephContext *cct,
48 RGWRados *store,
49 string name)
50 : cct(cct),
51 store(store),
52 name(std::move(name)) {}
53
54 RGWRole(CephContext *cct,
55 RGWRados *store)
56 : cct(cct),
57 store(store) {}
58
59 RGWRole() {}
60
61 ~RGWRole() = default;
62
63 void encode(bufferlist& bl) const {
64 ENCODE_START(1, 1, bl);
65 ::encode(id, bl);
66 ::encode(name, bl);
67 ::encode(path, bl);
68 ::encode(arn, bl);
69 ::encode(creation_date, bl);
70 ::encode(trust_policy, bl);
71 ::encode(perm_policy_map, bl);
72 ENCODE_FINISH(bl);
73 }
74
75 void decode(bufferlist::iterator& bl) {
76 DECODE_START(1, bl);
77 ::decode(id, bl);
78 ::decode(name, bl);
79 ::decode(path, bl);
80 ::decode(arn, bl);
81 ::decode(creation_date, bl);
82 ::decode(trust_policy, bl);
83 ::decode(perm_policy_map, bl);
84 DECODE_FINISH(bl);
85 }
86
87 const string& get_id() const { return id; }
88 const string& get_name() const { return name; }
89 const string& get_path() const { return path; }
90 const string& get_create_date() const { return creation_date; }
91
92 int create(bool exclusive);
93 int delete_obj();
94 int get();
95 int update();
96 void update_trust_policy(string& trust_policy);
97 void set_perm_policy(const string& policy_name, const string& perm_policy);
98 vector<string> get_role_policy_names();
99 int get_role_policy(const string& policy_name, string& perm_policy);
100 int delete_policy(const string& policy_name);
101 void dump(Formatter *f) const;
102 void decode_json(JSONObj *obj);
103
104 static const string& get_names_oid_prefix();
105 static const string& get_info_oid_prefix();
106 static const string& get_path_oid_prefix();
107 static int get_roles_by_path_prefix(RGWRados *store, CephContext *cct, const string& path_prefix, vector<RGWRole>& roles);
108 };
109 WRITE_CLASS_ENCODER(RGWRole)
110 #endif /* CEPH_RGW_ROLE_H */
111