]> git.proxmox.com Git - ceph.git/blame - ceph/src/rgw/rgw_lc_s3.h
buildsys: fix parallel builds
[ceph.git] / ceph / src / rgw / rgw_lc_s3.h
CommitLineData
7c673cae
FG
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
7c673cae
FG
9#include "include/str_list.h"
10#include "rgw_lc.h"
11#include "rgw_xml.h"
12
7c673cae
FG
13class LCID_S3 : public XMLObj
14{
15public:
16 LCID_S3() {}
17 ~LCID_S3() override {}
18 string& to_str() { return data; }
19};
20
21class LCPrefix_S3 : public XMLObj
22{
23public:
24 LCPrefix_S3() {}
25 ~LCPrefix_S3() override {}
26 string& to_str() { return data; }
27};
28
29class LCStatus_S3 : public XMLObj
30{
31public:
32 LCStatus_S3() {}
33 ~LCStatus_S3() override {}
34 string& to_str() { return data; }
35};
36
37class LCDays_S3 : public XMLObj
38{
39public:
40 LCDays_S3() {}
41 ~LCDays_S3() override {}
42 string& to_str() { return data; }
43};
44
31f18b77
FG
45class LCDeleteMarker_S3 : public XMLObj
46{
47public:
48 LCDeleteMarker_S3() {}
49 ~LCDeleteMarker_S3() override {}
50 string& to_str() { return data; }
51};
52
7c673cae
FG
53class LCExpiration_S3 : public LCExpiration, public XMLObj
54{
31f18b77
FG
55private:
56 bool dm_expiration;
7c673cae 57public:
31f18b77
FG
58 LCExpiration_S3(): dm_expiration(false) {}
59 LCExpiration_S3(string _days, bool _dm_expiration) {
60 days = _days;
61 dm_expiration = _dm_expiration;
62 }
7c673cae
FG
63 ~LCExpiration_S3() override {}
64
65 bool xml_end(const char *el) override;
66 void to_xml(ostream& out) {
31f18b77
FG
67 if (dm_expiration) {
68 out << "<Expiration>" << "<ExpiredObjectDeleteMarker>" << "true" << "</ExpiredObjectDeleteMarker>" << "</Expiration>";
69 } else {
70 out << "<Expiration>" << "<Days>" << days << "</Days>"<< "</Expiration>";
71 }
7c673cae
FG
72 }
73 void dump_xml(Formatter *f) const {
31f18b77
FG
74 f->open_object_section("Expiration");
75 if (dm_expiration) {
76 encode_xml("ExpiredObjectDeleteMarker", "true", f);
77 } else {
78 encode_xml("Days", days, f);
79 }
80 f->close_section(); // Expiration
81 }
82
83 void set_dm_expiration(bool _dm_expiration) {
84 dm_expiration = _dm_expiration;
85 }
86
87 bool get_dm_expiration() {
88 return dm_expiration;
7c673cae
FG
89 }
90};
91
92class LCNoncurExpiration_S3 : public LCExpiration, public XMLObj
93{
94public:
95 LCNoncurExpiration_S3() {}
96 ~LCNoncurExpiration_S3() override {}
97
98 bool xml_end(const char *el) override;
99 void to_xml(ostream& out) {
100 out << "<NoncurrentVersionExpiration>" << "<NoncurrentDays>" << days << "</NoncurrentDays>"<< "</NoncurrentVersionExpiration>";
101 }
102 void dump_xml(Formatter *f) const {
103 f->open_object_section("NoncurrentVersionExpiration");
104 encode_xml("NoncurrentDays", days, f);
105 f->close_section();
106 }
107};
108
109class LCMPExpiration_S3 : public LCExpiration, public XMLObj
110{
111public:
112 LCMPExpiration_S3() {}
113 ~LCMPExpiration_S3() {}
114
115 bool xml_end(const char *el);
116 void to_xml(ostream& out) {
117 out << "<AbortIncompleteMultipartUpload>" << "<DaysAfterInitiation>" << days << "</DaysAfterInitiation>" << "</AbortIncompleteMultipartUpload>";
118 }
119 void dump_xml(Formatter *f) const {
120 f->open_object_section("AbortIncompleteMultipartUpload");
121 encode_xml("DaysAfterInitiation", days, f);
122 f->close_section();
123 }
124};
125
126class LCRule_S3 : public LCRule, public XMLObj
127{
128public:
129 LCRule_S3() {}
130 ~LCRule_S3() override {}
131
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);
31f18b77
FG
140 if (!expiration.empty() || dm_expiration) {
141 LCExpiration_S3 expir(expiration.get_days_str(), dm_expiration);
7c673cae
FG
142 expir.dump_xml(f);
143 }
144 if (!noncur_expiration.empty()) {
145 const LCNoncurExpiration_S3& noncur_expir = static_cast<const LCNoncurExpiration_S3&>(noncur_expiration);
146 noncur_expir.dump_xml(f);
147 }
148 if (!mp_expiration.empty()) {
149 const LCMPExpiration_S3& mp_expir = static_cast<const LCMPExpiration_S3&>(mp_expiration);
150 mp_expir.dump_xml(f);
151 }
152 f->close_section(); // Rule
153 }
154};
155
156class RGWLCXMLParser_S3 : public RGWXMLParser
157{
158 CephContext *cct;
159
160 XMLObj *alloc_obj(const char *el) override;
161public:
162 RGWLCXMLParser_S3(CephContext *_cct) : cct(_cct) {}
163};
164
165class RGWLifecycleConfiguration_S3 : public RGWLifecycleConfiguration, public XMLObj
166{
167public:
168 RGWLifecycleConfiguration_S3(CephContext *_cct) : RGWLifecycleConfiguration(_cct) {}
169 RGWLifecycleConfiguration_S3() : RGWLifecycleConfiguration(NULL) {}
170 ~RGWLifecycleConfiguration_S3() override {}
171
172 bool xml_end(const char *el) override;
173
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);
180 }
181 out << "</LifecycleConfiguration>";
182 }
183 int rebuild(RGWRados *store, RGWLifecycleConfiguration& dest);
184 void dump_xml(Formatter *f) const;
185};
186
187
188#endif