]> git.proxmox.com Git - ceph.git/blob - ceph/src/rgw/rgw_lc_s3.h
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / rgw / rgw_lc_s3.h
1 #ifndef CEPH_RGW_LC_S3_H
2 #define CEPH_RGW_LC_S3_H
3
4 #include <map>
5 #include <string>
6 #include <iostream>
7 #include <include/types.h>
8
9 #include <expat.h>
10
11 #include "include/str_list.h"
12 #include "rgw_lc.h"
13 #include "rgw_xml.h"
14
15
16
17 using namespace std;
18
19 class LCID_S3 : public XMLObj
20 {
21 public:
22 LCID_S3() {}
23 ~LCID_S3() override {}
24 string& to_str() { return data; }
25 };
26
27 class LCPrefix_S3 : public XMLObj
28 {
29 public:
30 LCPrefix_S3() {}
31 ~LCPrefix_S3() override {}
32 string& to_str() { return data; }
33 };
34
35 class LCStatus_S3 : public XMLObj
36 {
37 public:
38 LCStatus_S3() {}
39 ~LCStatus_S3() override {}
40 string& to_str() { return data; }
41 };
42
43 class LCDays_S3 : public XMLObj
44 {
45 public:
46 LCDays_S3() {}
47 ~LCDays_S3() override {}
48 string& to_str() { return data; }
49 };
50
51 class LCExpiration_S3 : public LCExpiration, public XMLObj
52 {
53 public:
54 LCExpiration_S3() {}
55 ~LCExpiration_S3() override {}
56
57 bool xml_end(const char *el) override;
58 void to_xml(ostream& out) {
59 out << "<Expiration>" << "<Days>" << days << "</Days>"<< "</Expiration>";
60 }
61 void dump_xml(Formatter *f) const {
62 f->open_object_section("Expiration");
63 encode_xml("Days", days, f);
64 f->close_section(); // Expiration
65 }
66 };
67
68 class LCNoncurExpiration_S3 : public LCExpiration, public XMLObj
69 {
70 public:
71 LCNoncurExpiration_S3() {}
72 ~LCNoncurExpiration_S3() override {}
73
74 bool xml_end(const char *el) override;
75 void to_xml(ostream& out) {
76 out << "<NoncurrentVersionExpiration>" << "<NoncurrentDays>" << days << "</NoncurrentDays>"<< "</NoncurrentVersionExpiration>";
77 }
78 void dump_xml(Formatter *f) const {
79 f->open_object_section("NoncurrentVersionExpiration");
80 encode_xml("NoncurrentDays", days, f);
81 f->close_section();
82 }
83 };
84
85 class LCMPExpiration_S3 : public LCExpiration, public XMLObj
86 {
87 public:
88 LCMPExpiration_S3() {}
89 ~LCMPExpiration_S3() {}
90
91 bool xml_end(const char *el);
92 void to_xml(ostream& out) {
93 out << "<AbortIncompleteMultipartUpload>" << "<DaysAfterInitiation>" << days << "</DaysAfterInitiation>" << "</AbortIncompleteMultipartUpload>";
94 }
95 void dump_xml(Formatter *f) const {
96 f->open_object_section("AbortIncompleteMultipartUpload");
97 encode_xml("DaysAfterInitiation", days, f);
98 f->close_section();
99 }
100 };
101
102 class LCRule_S3 : public LCRule, public XMLObj
103 {
104 public:
105 LCRule_S3() {}
106 ~LCRule_S3() override {}
107
108 void to_xml(CephContext *cct, ostream& out);
109 bool xml_end(const char *el) override;
110 bool xml_start(const char *el, const char **attr);
111 void dump_xml(Formatter *f) const {
112 f->open_object_section("Rule");
113 encode_xml("ID", id, f);
114 encode_xml("Prefix", prefix, f);
115 encode_xml("Status", status, f);
116 if (!expiration.empty()) {
117 const LCExpiration_S3& expir = static_cast<const LCExpiration_S3&>(expiration);
118 expir.dump_xml(f);
119 }
120 if (!noncur_expiration.empty()) {
121 const LCNoncurExpiration_S3& noncur_expir = static_cast<const LCNoncurExpiration_S3&>(noncur_expiration);
122 noncur_expir.dump_xml(f);
123 }
124 if (!mp_expiration.empty()) {
125 const LCMPExpiration_S3& mp_expir = static_cast<const LCMPExpiration_S3&>(mp_expiration);
126 mp_expir.dump_xml(f);
127 }
128 f->close_section(); // Rule
129 }
130 };
131
132 class RGWLCXMLParser_S3 : public RGWXMLParser
133 {
134 CephContext *cct;
135
136 XMLObj *alloc_obj(const char *el) override;
137 public:
138 RGWLCXMLParser_S3(CephContext *_cct) : cct(_cct) {}
139 };
140
141 class RGWLifecycleConfiguration_S3 : public RGWLifecycleConfiguration, public XMLObj
142 {
143 public:
144 RGWLifecycleConfiguration_S3(CephContext *_cct) : RGWLifecycleConfiguration(_cct) {}
145 RGWLifecycleConfiguration_S3() : RGWLifecycleConfiguration(NULL) {}
146 ~RGWLifecycleConfiguration_S3() override {}
147
148 bool xml_end(const char *el) override;
149
150 void to_xml(ostream& out) {
151 out << "<LifecycleConfiguration xmlns=\"http://s3.amazonaws.com/doc/2006-03-01/\">";
152 multimap<string, LCRule>::iterator iter;
153 for (iter = rule_map.begin(); iter != rule_map.end(); ++iter) {
154 LCRule_S3& rule = static_cast<LCRule_S3&>(iter->second);
155 rule.to_xml(cct, out);
156 }
157 out << "</LifecycleConfiguration>";
158 }
159 int rebuild(RGWRados *store, RGWLifecycleConfiguration& dest);
160 void dump_xml(Formatter *f) const;
161 };
162
163
164 #endif