]> git.proxmox.com Git - ceph.git/blame - ceph/src/rgw/rgw_role.h
update sources to v12.1.0
[ceph.git] / ceph / src / rgw / rgw_role.h
CommitLineData
7c673cae
FG
1#ifndef CEPH_RGW_ROLE_H
2#define CEPH_RGW_ROLE_H
3
4class 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;
31f18b77
FG
10 static constexpr int MAX_ROLE_NAME_LEN = 64;
11 static constexpr int MAX_PATH_NAME_LEN = 512;
7c673cae
FG
12
13 CephContext *cct;
14 RGWRados *store;
15 string id;
16 string name;
17 string path;
18 string arn;
19 string creation_date;
20 string trust_policy;
21 map<string, string> perm_policy_map;
31f18b77 22 string tenant;
7c673cae
FG
23
24 int store_info(bool exclusive);
25 int store_name(bool exclusive);
26 int store_path(bool exclusive);
31f18b77 27 int read_id(const string& role_name, const string& tenant, string& role_id);
7c673cae
FG
28 int read_name();
29 int read_info();
30 void set_id(const string& id) { this->id = id; }
31f18b77
FG
31 bool validate_input();
32 void extract_name_tenant(const std::string& str);
7c673cae
FG
33
34public:
35 RGWRole(CephContext *cct,
36 RGWRados *store,
37 string name,
38 string path,
39 string trust_policy,
31f18b77 40 string tenant)
7c673cae
FG
41 : cct(cct),
42 store(store),
43 name(std::move(name)),
44 path(std::move(path)),
45 trust_policy(std::move(trust_policy)),
31f18b77 46 tenant(std::move(tenant)) {
7c673cae
FG
47 if (this->path.empty())
48 this->path = "/";
31f18b77 49 extract_name_tenant(this->name);
7c673cae
FG
50 }
51
52 RGWRole(CephContext *cct,
53 RGWRados *store,
31f18b77
FG
54 string name,
55 string tenant)
56 : cct(cct),
57 store(store),
58 name(std::move(name)),
59 tenant(std::move(tenant)) {
60 extract_name_tenant(this->name);
61 }
62
63 RGWRole(CephContext *cct,
64 RGWRados *store,
65 string id)
7c673cae
FG
66 : cct(cct),
67 store(store),
31f18b77 68 id(std::move(id)) {}
7c673cae
FG
69
70 RGWRole(CephContext *cct,
71 RGWRados *store)
72 : cct(cct),
73 store(store) {}
74
75 RGWRole() {}
76
77 ~RGWRole() = default;
78
79 void encode(bufferlist& bl) const {
31f18b77 80 ENCODE_START(2, 1, bl);
7c673cae
FG
81 ::encode(id, bl);
82 ::encode(name, bl);
83 ::encode(path, bl);
84 ::encode(arn, bl);
85 ::encode(creation_date, bl);
86 ::encode(trust_policy, bl);
87 ::encode(perm_policy_map, bl);
31f18b77 88 ::encode(tenant, bl);
7c673cae
FG
89 ENCODE_FINISH(bl);
90 }
91
92 void decode(bufferlist::iterator& bl) {
31f18b77 93 DECODE_START(2, bl);
7c673cae
FG
94 ::decode(id, bl);
95 ::decode(name, bl);
96 ::decode(path, bl);
97 ::decode(arn, bl);
98 ::decode(creation_date, bl);
99 ::decode(trust_policy, bl);
100 ::decode(perm_policy_map, bl);
31f18b77
FG
101 if (struct_v >= 2) {
102 ::decode(tenant, bl);
103 }
7c673cae
FG
104 DECODE_FINISH(bl);
105 }
106
107 const string& get_id() const { return id; }
108 const string& get_name() const { return name; }
109 const string& get_path() const { return path; }
110 const string& get_create_date() const { return creation_date; }
31f18b77 111 const string& get_assume_role_policy() const { return trust_policy;}
7c673cae
FG
112
113 int create(bool exclusive);
114 int delete_obj();
115 int get();
31f18b77 116 int get_by_id();
7c673cae
FG
117 int update();
118 void update_trust_policy(string& trust_policy);
119 void set_perm_policy(const string& policy_name, const string& perm_policy);
120 vector<string> get_role_policy_names();
121 int get_role_policy(const string& policy_name, string& perm_policy);
122 int delete_policy(const string& policy_name);
123 void dump(Formatter *f) const;
124 void decode_json(JSONObj *obj);
125
126 static const string& get_names_oid_prefix();
127 static const string& get_info_oid_prefix();
128 static const string& get_path_oid_prefix();
31f18b77
FG
129 static int get_roles_by_path_prefix(RGWRados *store,
130 CephContext *cct,
131 const string& path_prefix,
132 const string& tenant,
133 vector<RGWRole>& roles);
7c673cae
FG
134};
135WRITE_CLASS_ENCODER(RGWRole)
136#endif /* CEPH_RGW_ROLE_H */
137