1 #ifndef CEPH_RGW_LC_S3_H
2 #define CEPH_RGW_LC_S3_H
7 #include <include/types.h>
9 #include "include/str_list.h"
13 class LCID_S3
: public XMLObj
17 ~LCID_S3() override
{}
18 string
& to_str() { return data
; }
21 class LCPrefix_S3
: public XMLObj
25 ~LCPrefix_S3() override
{}
26 string
& to_str() { return data
; }
29 class LCStatus_S3
: public XMLObj
33 ~LCStatus_S3() override
{}
34 string
& to_str() { return data
; }
37 class LCDays_S3
: public XMLObj
41 ~LCDays_S3() override
{}
42 string
& to_str() { return data
; }
45 class LCDeleteMarker_S3
: public XMLObj
48 LCDeleteMarker_S3() {}
49 ~LCDeleteMarker_S3() override
{}
50 string
& to_str() { return data
; }
53 class LCExpiration_S3
: public LCExpiration
, public XMLObj
58 LCExpiration_S3(): dm_expiration(false) {}
59 LCExpiration_S3(string _days
, bool _dm_expiration
) {
61 dm_expiration
= _dm_expiration
;
63 ~LCExpiration_S3() override
{}
65 bool xml_end(const char *el
) override
;
66 void to_xml(ostream
& out
) {
68 out
<< "<Expiration>" << "<ExpiredObjectDeleteMarker>" << "true" << "</ExpiredObjectDeleteMarker>" << "</Expiration>";
70 out
<< "<Expiration>" << "<Days>" << days
<< "</Days>"<< "</Expiration>";
73 void dump_xml(Formatter
*f
) const {
74 f
->open_object_section("Expiration");
76 encode_xml("ExpiredObjectDeleteMarker", "true", f
);
78 encode_xml("Days", days
, f
);
80 f
->close_section(); // Expiration
83 void set_dm_expiration(bool _dm_expiration
) {
84 dm_expiration
= _dm_expiration
;
87 bool get_dm_expiration() {
92 class LCNoncurExpiration_S3
: public LCExpiration
, public XMLObj
95 LCNoncurExpiration_S3() {}
96 ~LCNoncurExpiration_S3() override
{}
98 bool xml_end(const char *el
) override
;
99 void to_xml(ostream
& out
) {
100 out
<< "<NoncurrentVersionExpiration>" << "<NoncurrentDays>" << days
<< "</NoncurrentDays>"<< "</NoncurrentVersionExpiration>";
102 void dump_xml(Formatter
*f
) const {
103 f
->open_object_section("NoncurrentVersionExpiration");
104 encode_xml("NoncurrentDays", days
, f
);
109 class LCMPExpiration_S3
: public LCExpiration
, public XMLObj
112 LCMPExpiration_S3() {}
113 ~LCMPExpiration_S3() {}
115 bool xml_end(const char *el
);
116 void to_xml(ostream
& out
) {
117 out
<< "<AbortIncompleteMultipartUpload>" << "<DaysAfterInitiation>" << days
<< "</DaysAfterInitiation>" << "</AbortIncompleteMultipartUpload>";
119 void dump_xml(Formatter
*f
) const {
120 f
->open_object_section("AbortIncompleteMultipartUpload");
121 encode_xml("DaysAfterInitiation", days
, f
);
126 class LCRule_S3
: public LCRule
, public XMLObj
130 ~LCRule_S3() override
{}
132 void to_xml(CephContext
*cct
, ostream
& out
);
133 bool xml_end(const char *el
) override
;
134 bool xml_start(const char *el
, const char **attr
);
135 void dump_xml(Formatter
*f
) const {
136 f
->open_object_section("Rule");
137 encode_xml("ID", id
, f
);
138 encode_xml("Prefix", prefix
, f
);
139 encode_xml("Status", status
, f
);
140 if (!expiration
.empty() || dm_expiration
) {
141 LCExpiration_S3
expir(expiration
.get_days_str(), dm_expiration
);
144 if (!noncur_expiration
.empty()) {
145 const LCNoncurExpiration_S3
& noncur_expir
= static_cast<const LCNoncurExpiration_S3
&>(noncur_expiration
);
146 noncur_expir
.dump_xml(f
);
148 if (!mp_expiration
.empty()) {
149 const LCMPExpiration_S3
& mp_expir
= static_cast<const LCMPExpiration_S3
&>(mp_expiration
);
150 mp_expir
.dump_xml(f
);
152 f
->close_section(); // Rule
156 class RGWLCXMLParser_S3
: public RGWXMLParser
160 XMLObj
*alloc_obj(const char *el
) override
;
162 RGWLCXMLParser_S3(CephContext
*_cct
) : cct(_cct
) {}
165 class RGWLifecycleConfiguration_S3
: public RGWLifecycleConfiguration
, public XMLObj
168 RGWLifecycleConfiguration_S3(CephContext
*_cct
) : RGWLifecycleConfiguration(_cct
) {}
169 RGWLifecycleConfiguration_S3() : RGWLifecycleConfiguration(NULL
) {}
170 ~RGWLifecycleConfiguration_S3() override
{}
172 bool xml_end(const char *el
) override
;
174 void to_xml(ostream
& out
) {
175 out
<< "<LifecycleConfiguration xmlns=\"http://s3.amazonaws.com/doc/2006-03-01/\">";
176 multimap
<string
, LCRule
>::iterator iter
;
177 for (iter
= rule_map
.begin(); iter
!= rule_map
.end(); ++iter
) {
178 LCRule_S3
& rule
= static_cast<LCRule_S3
&>(iter
->second
);
179 rule
.to_xml(cct
, out
);
181 out
<< "</LifecycleConfiguration>";
183 int rebuild(RGWRados
*store
, RGWLifecycleConfiguration
& dest
);
184 void dump_xml(Formatter
*f
) const;