#include "TosClientV2.h"
using namespace VolcengineTos;
std::string region = "Your Region";
std::string accessKey = std::getenv("TOS_ACCESS_KEY");
std::string secretKey = std::getenv("TOS_SECRET_KEY");
std::string bucketName = "examplebucket";
std::string ruleId = "yourCrrRuleId";
TosClientV2 client(region, accessKey, secretKey);
GetBucketReplicationInput input(bucketName);
// input.setRuleId(ruleId);
auto output = client.getBucketReplication(input);
if (!output.isSuccess()) {
std::cout << "GetBucketReplication failed." << output.error().String() << std::endl;
std::cout << "GetBucketReplication success." << std::endl;
std::cout << "Role:" << output.result().getRole() << std::endl;
std::cout << "Get Bucket Crr Rule List:" << std::endl;
for (const auto& rule : output.result().getRules()) {
std::cout << "id:" << rule.getId() << std::endl;
std::cout << "status:" << rule.getStringFormatStatus() << std::endl;
std::cout << "historical object replication:" << rule.getStringFormatHistoricalObjectReplication() << std::endl;
if (rule.getProgress() != nullptr) {
std::cout << "new object speed of progress:" << rule.getProgress()->getHistoricalObject() << std::endl;
std::cout << "historical object speed of progress:" << rule.getProgress()->getHistoricalObject()
for (auto const& prefix : rule.getPrefixSet()) {
std::cout << "prefix is:" << prefix << std::endl;
auto destination = rule.getDestination();
std::cout << "dest bucket is:" << destination.getBucket() << std::endl;
std::cout << "storage class is:" << destination.getStringFormatStorageClass() << std::endl;
std::cout << "storage class inherit directive is:" << destination.getStringFormatStorageClassInheritDirective()
std::cout << "dest location is:" << destination.getLocation() << std::endl;