123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646 |
- // Copyright (c) 2017, Tencent Inc.
- // All rights reserved.
- //
- // Author: sevenyou <sevenyou@tencent.com>
- // Created: 07/21/17
- // Description:
- #ifndef BUCKET_RESP_H
- #define BUCKET_RESP_H
- #pragma once
- #include <vector>
- #include "cos_config.h"
- #include "cos_defines.h"
- #include "rapidxml/1.13/rapidxml.hpp"
- #include "rapidxml/1.13/rapidxml_print.hpp"
- #include "rapidxml/1.13/rapidxml_utils.hpp"
- #include "response/base_resp.h"
- namespace qcloud_cos {
- class PutBucketResp : public BaseResp {
- public:
- PutBucketResp() {}
- virtual ~PutBucketResp() {}
- };
- class HeadBucketResp : public BaseResp {
- public:
- HeadBucketResp() {}
- virtual ~HeadBucketResp() {}
- };
- class GetBucketResp : public BaseResp {
- public:
- GetBucketResp() {}
- virtual ~GetBucketResp() {}
- virtual bool ParseFromXmlString(const std::string& body);
- /// \brief 获取Bucket中Object对应的元信息
- std::vector<Content> GetContents() const { return m_contents; }
- /// \brief Bucket名称
- std::string GetName() const { return m_name; }
- /// \brief 获取定界符
- std::string GetDelimiter() const { return m_delimiter; }
- /// \brief 编码格式
- std::string GetEncodingType() const { return m_encoding_type; }
- /// \brief 返回的文件前缀
- std::string GetPrefix() const { return m_prefix; }
- /// \brief 默认以UTF-8二进制顺序列出条目,所有列出条目从marker开始
- std::string GetMarker() const { return m_marker; }
- /// \brief 单次响应请求内返回结果的最大的条目数量
- uint64_t GetMaxKeys() const { return m_max_keys; }
- /// \brief 响应请求条目是否被截断,布尔值:true,false
- bool IsTruncated() const { return m_is_truncated; }
- /// \brief 假如返回条目被截断,则返回 NextMarker 就是下一个条目的起点
- std::string GetNextMarker() const { return m_next_marker; }
- /// \brief 将 Prefix 到 delimiter 之间的相同路径归为一类,定义为 Common Prefix
- std::vector<std::string> GetCommonPrefixes() const {
- return m_common_prefixes;
- }
- private:
- std::vector<Content> m_contents;
- std::string m_name;
- std::string m_encoding_type;
- std::string m_delimiter;
- std::string m_prefix;
- std::string m_marker;
- uint64_t m_max_keys;
- bool m_is_truncated;
- std::string m_next_marker;
- std::vector<std::string> m_common_prefixes;
- };
- class DeleteBucketResp : public BaseResp {
- public:
- DeleteBucketResp() {}
- virtual ~DeleteBucketResp() {}
- };
- class GetBucketVersioningResp : public BaseResp {
- public:
- GetBucketVersioningResp() : m_status(0) {}
- virtual ~GetBucketVersioningResp() {}
- virtual bool ParseFromXmlString(const std::string& body);
- /// \brief 返回bucket的版本状态,0: 从未开启版本管理, 1: 版本管理生效中, 2:
- /// 暂停 区别于PutBucketVersioning, 一个Bucket可能处于三种状态
- int GetStatus() const { return m_status; }
- private:
- int m_status;
- };
- class PutBucketVersioningResp : public BaseResp {
- public:
- PutBucketVersioningResp() {}
- virtual ~PutBucketVersioningResp() {}
- };
- class GetBucketReplicationResp : public BaseResp {
- public:
- GetBucketReplicationResp() {}
- virtual ~GetBucketReplicationResp() {}
- virtual bool ParseFromXmlString(const std::string& body);
- std::string GetRole() const { return m_role; }
- std::vector<ReplicationRule> GetRules() const { return m_rules; }
- private:
- std::string m_role;
- std::vector<ReplicationRule> m_rules;
- };
- class PutBucketReplicationResp : public BaseResp {
- public:
- PutBucketReplicationResp() {}
- virtual ~PutBucketReplicationResp() {}
- };
- class DeleteBucketReplicationResp : public BaseResp {
- public:
- DeleteBucketReplicationResp() {}
- virtual ~DeleteBucketReplicationResp() {}
- };
- class GetBucketLifecycleResp : public BaseResp {
- public:
- GetBucketLifecycleResp() {}
- virtual ~GetBucketLifecycleResp() {}
- virtual bool ParseFromXmlString(const std::string& body);
- std::vector<LifecycleRule> GetRules() const { return m_rules; }
- private:
- std::vector<LifecycleRule> m_rules;
- };
- class PutBucketLifecycleResp : public BaseResp {
- public:
- PutBucketLifecycleResp() {}
- virtual ~PutBucketLifecycleResp() {}
- };
- class DeleteBucketLifecycleResp : public BaseResp {
- public:
- DeleteBucketLifecycleResp() {}
- virtual ~DeleteBucketLifecycleResp() {}
- };
- class GetBucketACLResp : public BaseResp {
- public:
- GetBucketACLResp() {}
- virtual ~GetBucketACLResp() {}
- virtual bool ParseFromXmlString(const std::string& body);
- std::string GetOwnerID() const { return m_owner_id; }
- std::string GetOwnerDisplayName() const { return m_owner_display_name; }
- std::vector<Grant> GetAccessControlList() const { return m_acl; }
- private:
- std::string m_owner_id;
- std::string m_owner_display_name;
- std::vector<Grant> m_acl;
- };
- // TODO
- class ListMultipartUploadResp : public BaseResp {
- public:
- ListMultipartUploadResp() {}
- virtual ~ListMultipartUploadResp() {}
- virtual bool ParseFromXmlString(const std::string& body);
- /// \brief 获取Bucket中Object对应的元信息
- std::vector<Upload> GetUpload() const { return m_upload; }
- /// \brief Bucket名称
- std::string GetName() const { return m_name; }
- /// \brief 编码格式
- std::string GetEncodingType() const { return m_encoding_type; }
- /// \brief 默认以UTF-8二进制顺序列出条目,所有列出条目从marker开始
- std::string GetMarker() const { return m_marker; }
- std::string GetUploadIdMarker() const { return m_uploadid_marker; }
- std::string GetNextKeyMarker() const { return m_nextkey_marker; }
- std::string GetNextUploadIdMarker() const { return m_nextuploadid_marker; }
- std::string GetMaxUploads() const { return m_max_uploads; }
- /// \brief 响应请求条目是否被截断,布尔值:true,false
- bool IsTruncated() const { return m_is_truncated; }
- /// \brief 返回的文件前缀
- std::string GetPrefix() const { return m_prefix; }
- /// \brief 获取定界符
- std::string GetDelimiter() const { return m_delimiter; }
- /// \brief 将 Prefix 到 delimiter 之间的相同路径归为一类,定义为 Common Prefix
- std::vector<std::string> GetCommonPrefixes() const {
- return m_common_prefixes;
- }
- private:
- std::vector<Upload> m_upload;
- std::string m_name;
- std::string m_encoding_type;
- std::string m_delimiter;
- std::string m_prefix;
- std::string m_marker;
- std::string m_uploadid_marker;
- std::string m_nextkey_marker;
- std::string m_nextuploadid_marker;
- std::string m_max_uploads;
- bool m_is_truncated;
- std::vector<std::string> m_common_prefixes;
- };
- class PutBucketACLResp : public BaseResp {
- public:
- PutBucketACLResp() {}
- virtual ~PutBucketACLResp() {}
- };
- class GetBucketPolicyResp : public BaseResp {
- public:
- GetBucketPolicyResp() {}
- virtual ~GetBucketPolicyResp() {}
- std::string GetPolicy() const { return GetBody(); }
- };
- class PutBucketPolicyResp : public BaseResp {
- public:
- PutBucketPolicyResp() {}
- virtual ~PutBucketPolicyResp() {}
- };
- class DeleteBucketPolicyResp : public BaseResp {
- public:
- DeleteBucketPolicyResp() {}
- virtual ~DeleteBucketPolicyResp() {}
- };
- class GetBucketCORSResp : public BaseResp {
- public:
- GetBucketCORSResp() {}
- virtual ~GetBucketCORSResp() {}
- virtual bool ParseFromXmlString(const std::string& body);
- std::vector<CORSRule> GetCORSRules() const { return m_rules; }
- private:
- std::vector<CORSRule> m_rules;
- };
- class PutBucketCORSResp : public BaseResp {
- public:
- PutBucketCORSResp() {}
- virtual ~PutBucketCORSResp() {}
- };
- class DeleteBucketCORSResp : public BaseResp {
- public:
- DeleteBucketCORSResp() {}
- virtual ~DeleteBucketCORSResp() {}
- };
- class GetBucketLocationResp : public BaseResp {
- public:
- GetBucketLocationResp() {}
- virtual ~GetBucketLocationResp() {}
- std::string GetLocation() const { return m_location; }
- virtual bool ParseFromXmlString(const std::string& body);
- private:
- std::string m_location;
- };
- class GetBucketObjectVersionsResp : public BaseResp {
- public:
- GetBucketObjectVersionsResp() {}
- virtual ~GetBucketObjectVersionsResp() {}
- /// \brief 编码格式
- std::string GetEncodingType() const { return m_encoding_type; }
- /// \brief 返回的文件前缀
- std::string GetPrefix() const { return m_prefix; }
- /// \brief 单次响应请求内返回结果的最大的条目数量
- uint64_t GetMaxKeys() const { return m_max_keys; }
- /// \brief 响应请求条目是否被截断,布尔值:true,false
- bool IsTruncated() const { return m_is_truncated; }
- /// \brief 假如返回条目被截断,则返回 NextKeyMarker 就是下一个条目的起点
- std::string GetNextKeyMarker() const { return m_next_key_marker; }
- std::string GetKeyMarker() const { return m_key_marker; }
- std::string GetBucketName() const { return m_bucket_name; }
- std::string GetVersionIdMarker() const { return m_version_id_marker; }
- std::vector<COSVersionSummary> GetVersionSummary() const {
- return m_summaries;
- }
- virtual bool ParseFromXmlString(const std::string& body);
- private:
- std::vector<COSVersionSummary> m_summaries;
- std::string m_encoding_type;
- bool m_is_truncated;
- uint64_t m_max_keys;
- std::string m_bucket_name;
- std::string m_key_marker;
- std::string m_prefix;
- std::string m_version_id_marker;
- std::string m_next_key_marker;
- std::string m_next_version_id_marker;
- };
- class PutBucketLoggingResp : public BaseResp {
- public:
- PutBucketLoggingResp() {}
- virtual ~PutBucketLoggingResp() {}
- };
- class GetBucketLoggingResp : public BaseResp {
- public:
- GetBucketLoggingResp() {}
- virtual ~GetBucketLoggingResp() {}
- virtual bool ParseFromXmlString(const std::string& body);
- LoggingEnabled GetLoggingEnabled() const { return m_rules; }
- private:
- LoggingEnabled m_rules;
- };
- class PutBucketDomainResp : public BaseResp {
- public:
- PutBucketDomainResp() {}
- virtual ~PutBucketDomainResp() {}
- virtual bool ParseFromXmlString(const std::string& body);
- DomainErrorMsg GetDomainErrorMsg() const { return m_rules; }
- private:
- DomainErrorMsg m_rules;
- };
- class GetBucketDomainResp : public BaseResp {
- public:
- GetBucketDomainResp() {}
- virtual ~GetBucketDomainResp() {}
- virtual bool ParseFromXmlString(const std::string& body);
- std::string GetStatus() const { return m_status; }
- std::string GetName() const { return m_name; }
- std::string GetType() const { return m_type; }
- void SetStatus(const std::string& status) { m_status = status; }
- void SetName(const std::string& name) { m_name = name; }
- void SetType(const std::string& type) { m_type = type; }
- private:
- std::string m_status;
- std::string m_name;
- std::string m_type;
- };
- class PutBucketWebsiteResp : public BaseResp {
- public:
- PutBucketWebsiteResp() {}
- virtual ~PutBucketWebsiteResp() {}
- };
- class GetBucketWebsiteResp : public BaseResp {
- public:
- GetBucketWebsiteResp() {}
- virtual ~GetBucketWebsiteResp() {}
- virtual bool ParseFromXmlString(const std::string& body);
- bool ParseFromXmlRoutingRule(rapidxml::xml_node<>* node,
- RoutingRule& tmp_routingrule);
- void SetSuffix(const std::string& suffix) { m_suffix = suffix; }
- void SetProtocol(const std::string& protocol) { m_protocol = protocol; }
- void SetKey(const std::string& key) { m_key = key; }
- std::string GetSuffix() const { return m_suffix; }
- std::string GetProtocol() const { return m_protocol; }
- std::string GetKey() const { return m_key; }
- /// 设置重定向规则
- void SetRoutingRules(const std::vector<RoutingRule>& routingrules) {
- m_routingrules = routingrules;
- }
- std::vector<RoutingRule> GetRoutingRules() const { return m_routingrules; }
- /// 添加单个rule
- void AddRoutingRule(const RoutingRule& routingrule) {
- m_routingrules.push_back(routingrule);
- }
- /// 清空重定向规则
- void ClearRoutingRule() {
- std::vector<RoutingRule> tmp;
- m_routingrules.swap(tmp);
- }
- private:
- std::string m_suffix;
- std::string m_protocol;
- std::string m_key;
- std::vector<RoutingRule> m_routingrules;
- };
- class DeleteBucketWebsiteResp : public BaseResp {
- public:
- DeleteBucketWebsiteResp() {}
- virtual ~DeleteBucketWebsiteResp() {}
- };
- class PutBucketTaggingResp : public BaseResp {
- public:
- PutBucketTaggingResp() {}
- virtual ~PutBucketTaggingResp() {}
- };
- class GetBucketTaggingResp : public BaseResp {
- public:
- GetBucketTaggingResp() {}
- void SetTagSet(std::vector<Tag>& tagset) { m_tagset = tagset; }
- std::vector<Tag> GetTagSet() const { return m_tagset; }
- //清除tag规则.
- void ClearTagSet() {
- std::vector<Tag> temp;
- m_tagset.swap(temp);
- }
- /// 添加单个tag.
- void AddTag(const Tag& tag) { m_tagset.push_back(tag); }
- virtual bool ParseFromXmlString(const std::string& body);
- virtual ~GetBucketTaggingResp() {}
- private:
- std::vector<Tag> m_tagset;
- };
- class DeleteBucketTaggingResp : public BaseResp {
- public:
- DeleteBucketTaggingResp() {}
- virtual ~DeleteBucketTaggingResp() {}
- };
- class PutBucketInventoryResp : public BaseResp {
- public:
- PutBucketInventoryResp() {}
- virtual ~PutBucketInventoryResp() {}
- };
- class GetBucketInventoryResp : public BaseResp {
- public:
- GetBucketInventoryResp() : m_mask(0x00000001u) {}
- void SetInventory(const Inventory& inventory) {
- m_mask = m_mask | 0x00000001u;
- m_inventory = inventory;
- }
- bool HasInventory() const { return (m_mask & 0x00000001u) != 0; }
- const Inventory& GetInventory() const { return m_inventory; }
- bool ParseFromXmlOptionalFields(rapidxml::xml_node<>* node,
- Inventory& temp_inventory);
- bool ParseFromXmlCOSBucketDestination(rapidxml::xml_node<>* node,
- Inventory& temp_inventory);
- bool ParseFromXmlInventoryConfiguration(rapidxml::xml_node<>* node,
- Inventory& temp_inventory);
- virtual bool ParseFromXmlString(const std::string& body);
- virtual ~GetBucketInventoryResp() {}
- private:
- uint64_t m_mask;
- Inventory m_inventory;
- };
- class ListBucketInventoryConfigurationsResp : public GetBucketInventoryResp {
- public:
- ListBucketInventoryConfigurationsResp()
- : m_is_truncated(false),
- m_continuation_token(""),
- m_next_continuation_token("") {}
- virtual bool ParseFromXmlString(const std::string& body);
- virtual ~ListBucketInventoryConfigurationsResp() {}
- /// 添加单个Inventory.
- void AddInventory(const Inventory& inventory) {
- m_inventory_vec.push_back(inventory);
- }
- void SetInventoryVec(std::vector<Inventory>& inventory_vec) {
- m_inventory_vec = inventory_vec;
- }
- void SetIsTruncated(bool is_truncated) { m_is_truncated = is_truncated; }
- void SetContinuationToken(std::string continuation_token) {
- m_continuation_token = continuation_token;
- }
- void SetNextContinuationToken(std::string next_continuation_token) {
- m_next_continuation_token = next_continuation_token;
- }
- std::vector<Inventory> GetInventory() const { return m_inventory_vec; }
- bool GetIsTruncated() const { return m_is_truncated; }
- std::string GetContinuationToken() const { return m_continuation_token; }
- std::string GetNextContinuationToken() const {
- return m_next_continuation_token;
- }
- private:
- std::vector<Inventory> m_inventory_vec;
- bool m_is_truncated;
- std::string m_continuation_token;
- std::string m_next_continuation_token;
- };
- class DeleteBucketInventoryResp : public BaseResp {
- public:
- DeleteBucketInventoryResp() {}
- virtual ~DeleteBucketInventoryResp() {}
- };
- /// \brief: 列举直播通道响应
- class ListLiveChannelResp : public BaseResp {
- public:
- ListLiveChannelResp() {}
- virtual ~ListLiveChannelResp() {}
- virtual bool ParseFromXmlString(const std::string& body);
- const ListLiveChannelResult& GetListResult() const { return result; }
- void ClearResult() { result.Clear(); }
- private:
- ListLiveChannelResult result;
- };
- /// \brief: 配置存储桶智能分层的响应
- class PutBucketIntelligentTieringResp : public BaseResp {
- public:
- PutBucketIntelligentTieringResp() {}
- virtual ~PutBucketIntelligentTieringResp() {}
- };
- /// \brief: 获取配置存储桶智能分层配置的响应
- class GetBucketIntelligentTieringResp : public BaseResp {
- public:
- GetBucketIntelligentTieringResp() {}
- virtual ~GetBucketIntelligentTieringResp() {}
- virtual bool ParseFromXmlString(const std::string& body);
- std::string GetStatus() const { return m_status; }
- uint32_t GetDays() const { return m_days; }
- uint32_t GetRequestFrequent() const { return m_freq; }
- private:
- std::string m_status;
- int m_days;
- int m_freq;
- };
- /// \brief: 配置存储桶Referer响应
- class PutBucketRefererResp : public BaseResp {
- public:
- PutBucketRefererResp() {}
- virtual ~PutBucketRefererResp() {}
- };
- /// \brief: 获取存储桶Referer响应
- class GetBucketRefererResp : public BaseResp {
- public:
- GetBucketRefererResp() {}
- virtual ~GetBucketRefererResp() {}
- virtual bool ParseFromXmlString(const std::string& body);
- std::string GetStatus() const { return m_status; }
- std::string GetRefererType() const { return m_referer_type; }
- std::vector<std::string> GetDomainList() const { return m_domain_list; }
- std::string GetEmptyReferConf() const { return m_empty_refer_conf; }
- std::string GetVerifySignatureUrl() const {return m_verify_signature_url; }
- private:
- std::string m_status;
- std::string m_referer_type;
- std::vector<std::string> m_domain_list;
- std::string m_empty_refer_conf;
- std::string m_verify_signature_url;
- };
- } // namespace qcloud_cos
- #endif // BUCKET_RESP_H
|