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 LCFilter_S3
: public LCFilter
, public XMLObj
32 ~LCFilter_S3() override
{}
33 string
& to_str() { return data
; }
34 void to_xml(ostream
& out
){
37 out
<< "<Prefix>" << prefix
<< "</Prefix>";
40 void dump_xml(Formatter
*f
) const {
41 f
->open_object_section("Filter");
43 encode_xml("Prefix", prefix
, f
);
44 f
->close_section(); // Filter
48 class LCStatus_S3
: public XMLObj
52 ~LCStatus_S3() override
{}
53 string
& to_str() { return data
; }
56 class LCDays_S3
: public XMLObj
60 ~LCDays_S3() override
{}
61 string
& to_str() { return data
; }
64 class LCDate_S3
: public XMLObj
68 ~LCDate_S3() override
{}
69 string
& to_str() { return data
; }
72 class LCDeleteMarker_S3
: public XMLObj
75 LCDeleteMarker_S3() {}
76 ~LCDeleteMarker_S3() override
{}
77 string
& to_str() { return data
; }
80 class LCExpiration_S3
: public LCExpiration
, public XMLObj
85 LCExpiration_S3(): dm_expiration(false) {}
86 LCExpiration_S3(string _days
, string _date
, bool _dm_expiration
) {
89 dm_expiration
= _dm_expiration
;
91 ~LCExpiration_S3() override
{}
93 bool xml_end(const char *el
) override
;
94 void to_xml(ostream
& out
) {
95 out
<< "<Expiration>";
97 out
<< "<ExpiredObjectDeleteMarker>" << "true" << "</ExpiredObjectDeleteMarker>";
98 } else if (!days
.empty()){
99 out
<< "<Days>" << days
<< "</Days>";
101 out
<< "<Date>" << date
<< "</Date>";
103 out
<< "</Expiration>";
105 void dump_xml(Formatter
*f
) const {
106 f
->open_object_section("Expiration");
108 encode_xml("ExpiredObjectDeleteMarker", "true", f
);
109 } else if (!days
.empty()) {
110 encode_xml("Days", days
, f
);
112 encode_xml("Date", date
, f
);
114 f
->close_section(); // Expiration
117 void set_dm_expiration(bool _dm_expiration
) {
118 dm_expiration
= _dm_expiration
;
121 bool get_dm_expiration() {
122 return dm_expiration
;
126 class LCNoncurExpiration_S3
: public LCExpiration
, public XMLObj
129 LCNoncurExpiration_S3() {}
130 ~LCNoncurExpiration_S3() override
{}
132 bool xml_end(const char *el
) override
;
133 void to_xml(ostream
& out
) {
134 out
<< "<NoncurrentVersionExpiration>" << "<NoncurrentDays>" << days
<< "</NoncurrentDays>"<< "</NoncurrentVersionExpiration>";
136 void dump_xml(Formatter
*f
) const {
137 f
->open_object_section("NoncurrentVersionExpiration");
138 encode_xml("NoncurrentDays", days
, f
);
143 class LCMPExpiration_S3
: public LCExpiration
, public XMLObj
146 LCMPExpiration_S3() {}
147 ~LCMPExpiration_S3() {}
149 bool xml_end(const char *el
);
150 void to_xml(ostream
& out
) {
151 out
<< "<AbortIncompleteMultipartUpload>" << "<DaysAfterInitiation>" << days
<< "</DaysAfterInitiation>" << "</AbortIncompleteMultipartUpload>";
153 void dump_xml(Formatter
*f
) const {
154 f
->open_object_section("AbortIncompleteMultipartUpload");
155 encode_xml("DaysAfterInitiation", days
, f
);
160 class LCRule_S3
: public LCRule
, public XMLObj
165 LCRule_S3(): cct(nullptr) {}
166 LCRule_S3(CephContext
*_cct
): cct(_cct
) {}
167 ~LCRule_S3() override
{}
169 void to_xml(ostream
& out
);
170 bool xml_end(const char *el
) override
;
171 bool xml_start(const char *el
, const char **attr
);
172 void dump_xml(Formatter
*f
) const {
173 f
->open_object_section("Rule");
174 encode_xml("ID", id
, f
);
175 // In case of an empty filter and an empty Prefix, we defer to Prefix.
176 if (!filter
.empty()) {
177 const LCFilter_S3
& lc_filter
= static_cast<const LCFilter_S3
&>(filter
);
178 lc_filter
.dump_xml(f
);
180 encode_xml("Prefix", prefix
, f
);
182 encode_xml("Status", status
, f
);
183 if (!expiration
.empty() || dm_expiration
) {
184 LCExpiration_S3
expir(expiration
.get_days_str(), expiration
.get_date(), dm_expiration
);
187 if (!noncur_expiration
.empty()) {
188 const LCNoncurExpiration_S3
& noncur_expir
= static_cast<const LCNoncurExpiration_S3
&>(noncur_expiration
);
189 noncur_expir
.dump_xml(f
);
191 if (!mp_expiration
.empty()) {
192 const LCMPExpiration_S3
& mp_expir
= static_cast<const LCMPExpiration_S3
&>(mp_expiration
);
193 mp_expir
.dump_xml(f
);
196 f
->close_section(); // Rule
199 void set_ctx(CephContext
*ctx
) {
204 class RGWLCXMLParser_S3
: public RGWXMLParser
208 XMLObj
*alloc_obj(const char *el
) override
;
210 RGWLCXMLParser_S3(CephContext
*_cct
) : cct(_cct
) {}
213 class RGWLifecycleConfiguration_S3
: public RGWLifecycleConfiguration
, public XMLObj
216 RGWLifecycleConfiguration_S3(CephContext
*_cct
) : RGWLifecycleConfiguration(_cct
) {}
217 RGWLifecycleConfiguration_S3() : RGWLifecycleConfiguration(NULL
) {}
218 ~RGWLifecycleConfiguration_S3() override
{}
220 bool xml_end(const char *el
) override
;
222 void to_xml(ostream
& out
) {
223 out
<< "<LifecycleConfiguration xmlns=\"http://s3.amazonaws.com/doc/2006-03-01/\">";
224 multimap
<string
, LCRule
>::iterator iter
;
225 for (iter
= rule_map
.begin(); iter
!= rule_map
.end(); ++iter
) {
226 LCRule_S3
& rule
= static_cast<LCRule_S3
&>(iter
->second
);
229 out
<< "</LifecycleConfiguration>";
231 int rebuild(RGWRados
*store
, RGWLifecycleConfiguration
& dest
);
232 void dump_xml(Formatter
*f
) const;