/*
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include
#include
#include
#include
#include
#include
#include
namespace AlibabaCloud
{
namespace OSS
{
/*Global Init/Deinit*/
void ALIBABACLOUD_OSS_EXPORT InitializeSdk();
bool ALIBABACLOUD_OSS_EXPORT IsSdkInitialized();
void ALIBABACLOUD_OSS_EXPORT ShutdownSdk();
/*Log*/
void ALIBABACLOUD_OSS_EXPORT SetLogLevel(LogLevel level);
void ALIBABACLOUD_OSS_EXPORT SetLogCallback(LogCallback callback);
/*Utils*/
std::string ALIBABACLOUD_OSS_EXPORT ComputeContentMD5(const char *data, size_t size);
std::string ALIBABACLOUD_OSS_EXPORT ComputeContentMD5(std::istream& stream);
std::string ALIBABACLOUD_OSS_EXPORT ComputeContentETag(const char* data, size_t size);
std::string ALIBABACLOUD_OSS_EXPORT ComputeContentETag(std::istream& stream);
std::string ALIBABACLOUD_OSS_EXPORT UrlEncode(const std::string& src);
std::string ALIBABACLOUD_OSS_EXPORT UrlDecode(const std::string& src);
std::string ALIBABACLOUD_OSS_EXPORT Base64Encode(const std::string& src);
std::string ALIBABACLOUD_OSS_EXPORT Base64Encode(const char* src, int len);
std::string ALIBABACLOUD_OSS_EXPORT Base64EncodeUrlSafe(const std::string& src);
std::string ALIBABACLOUD_OSS_EXPORT Base64EncodeUrlSafe(const char* src, int len);
std::string ALIBABACLOUD_OSS_EXPORT ToGmtTime(std::time_t& t);
std::string ALIBABACLOUD_OSS_EXPORT ToUtcTime(std::time_t& t);
std::time_t ALIBABACLOUD_OSS_EXPORT UtcToUnixTime(const std::string& t);
uint64_t ALIBABACLOUD_OSS_EXPORT ComputeCRC64(uint64_t crc, void* buf, size_t len);
uint64_t ALIBABACLOUD_OSS_EXPORT CombineCRC64(uint64_t crc1, uint64_t crc2, uintmax_t len2);
/*Aysnc APIs*/
class OssClient;
using ListObjectAsyncHandler = std::function&)>;
using GetObjectAsyncHandler = std::function&)>;
using PutObjectAsyncHandler = std::function&)>;
using UploadPartAsyncHandler = std::function&)>;
using UploadPartCopyAsyncHandler = std::function&)>;
/*Callable*/
using ListObjectOutcomeCallable = std::future;
using GetObjectOutcomeCallable = std::future;
using PutObjectOutcomeCallable = std::future;
using UploadPartCopyOutcomeCallable = std::future;
class OssClientImpl;
class ALIBABACLOUD_OSS_EXPORT OssClient
{
public:
OssClient(const std::string& endpoint, const std::string& accessKeyId, const std::string& accessKeySecret,
const ClientConfiguration& configuration);
OssClient(const std::string& endpoint, const std::string& accessKeyId, const std::string& accessKeySecret, const std::string& securityToken,
const ClientConfiguration& configuration);
OssClient(const std::string& endpoint, const Credentials& credentials, const ClientConfiguration& configuration);
OssClient(const std::string& endpoint, const std::shared_ptr& credentialsProvider, const ClientConfiguration& configuration);
virtual ~OssClient();
#if !defined(OSS_DISABLE_BUCKET)
/*Service*/
ListBucketsOutcome ListBuckets() const;
ListBucketsOutcome ListBuckets(const ListBucketsRequest& request) const;
/*Bucket*/
CreateBucketOutcome CreateBucket(const std::string& bucket, StorageClass storageClass = StorageClass::Standard) const;
CreateBucketOutcome CreateBucket(const std::string& bucket, StorageClass storageClass, CannedAccessControlList acl) const;
CreateBucketOutcome CreateBucket(const CreateBucketRequest& request) const;
ListBucketInventoryConfigurationsOutcome ListBucketInventoryConfigurations(const ListBucketInventoryConfigurationsRequest& request) const;
VoidOutcome SetBucketAcl(const std::string& bucket, CannedAccessControlList acl) const;
VoidOutcome SetBucketAcl(const SetBucketAclRequest& request) const;
VoidOutcome SetBucketLogging(const std::string& bucket, const std::string& targetBucket, const std::string& targetPrefix) const;
VoidOutcome SetBucketLogging(const SetBucketLoggingRequest& request) const;
VoidOutcome SetBucketWebsite(const std::string& bucket, const std::string& indexDocument) const;
VoidOutcome SetBucketWebsite(const std::string& bucket, const std::string& indexDocument, const std::string& errorDocument) const;
VoidOutcome SetBucketWebsite(const SetBucketWebsiteRequest& request) const;
VoidOutcome SetBucketReferer(const std::string& bucket, const RefererList& refererList, bool allowEmptyReferer) const;
VoidOutcome SetBucketReferer(const SetBucketRefererRequest& request) const;
VoidOutcome SetBucketLifecycle(const SetBucketLifecycleRequest& request) const;
VoidOutcome SetBucketCors(const std::string& bucket, const CORSRuleList& rules) const;
VoidOutcome SetBucketCors(const SetBucketCorsRequest& request) const;
VoidOutcome SetBucketStorageCapacity(const std::string& bucket, int64_t storageCapacity) const;
VoidOutcome SetBucketStorageCapacity(const SetBucketStorageCapacityRequest& request) const;
VoidOutcome SetBucketPolicy(const SetBucketPolicyRequest& request) const;
VoidOutcome SetBucketRequestPayment(const SetBucketRequestPaymentRequest& request) const;
VoidOutcome SetBucketEncryption(const SetBucketEncryptionRequest& request) const;
VoidOutcome SetBucketTagging(const SetBucketTaggingRequest& request) const;
VoidOutcome SetBucketQosInfo(const SetBucketQosInfoRequest& request) const;
VoidOutcome SetBucketVersioning(const SetBucketVersioningRequest& request) const;
VoidOutcome SetBucketInventoryConfiguration(const SetBucketInventoryConfigurationRequest& request) const;
VoidOutcome DeleteBucket(const std::string& bucket) const;
VoidOutcome DeleteBucket(const DeleteBucketRequest& request) const;
VoidOutcome DeleteBucketLogging(const std::string& bucket) const;
VoidOutcome DeleteBucketLogging(const DeleteBucketLoggingRequest& request) const;
VoidOutcome DeleteBucketPolicy(const DeleteBucketPolicyRequest& request) const;
VoidOutcome DeleteBucketWebsite(const std::string& bucket) const;
VoidOutcome DeleteB