ClickHouse/src/IO/S3Common.h

93 lines
1.9 KiB
C++
Raw Normal View History

2019-11-05 07:54:13 +00:00
#pragma once
2019-12-06 14:37:21 +00:00
#include <Common/config.h>
#if USE_AWS_S3
2020-09-15 09:55:57 +00:00
#include <common/types.h>
2019-12-06 14:37:21 +00:00
#include <aws/core/Aws.h>
#include <aws/core/client/ClientConfiguration.h>
#include <IO/S3/PocoHTTPClient.h>
#include <Poco/URI.h>
2019-11-05 07:54:13 +00:00
2019-12-11 14:21:48 +00:00
namespace Aws::S3
{
class S3Client;
}
2019-11-05 07:54:13 +00:00
namespace DB
{
class RemoteHostFilter;
struct HttpHeader;
using HeaderCollection = std::vector<HttpHeader>;
}
2019-12-06 14:37:21 +00:00
namespace DB::S3
2019-11-05 07:54:13 +00:00
{
2019-12-06 14:48:56 +00:00
class ClientFactory
{
2019-12-06 14:37:21 +00:00
public:
~ClientFactory();
2019-12-06 14:48:56 +00:00
2019-12-06 14:37:21 +00:00
static ClientFactory & instance();
2019-12-06 14:48:56 +00:00
2020-05-02 22:34:50 +00:00
std::shared_ptr<Aws::S3::S3Client> create(
2020-05-02 22:25:02 +00:00
const String & endpoint,
bool is_virtual_hosted_style,
2020-05-02 22:25:02 +00:00
const String & access_key_id,
const String & secret_access_key,
bool use_environment_credentials,
2020-11-13 16:31:51 +00:00
const RemoteHostFilter & remote_host_filter,
unsigned int s3_max_redirects);
2020-05-02 22:25:02 +00:00
2020-05-02 22:34:50 +00:00
std::shared_ptr<Aws::S3::S3Client> create(
const PocoHTTPClientConfiguration & cfg,
bool is_virtual_hosted_style,
2020-05-02 22:25:02 +00:00
const String & access_key_id,
const String & secret_access_key,
bool use_environment_credentials);
std::shared_ptr<Aws::S3::S3Client> create(
const PocoHTTPClientConfiguration & cfg,
bool is_virtual_hosted_style,
const String & access_key_id,
const String & secret_access_key,
HeaderCollection headers,
bool use_environment_credentials);
PocoHTTPClientConfiguration createClientConfiguration(
2020-11-13 16:31:51 +00:00
const RemoteHostFilter & remote_host_filter,
unsigned int s3_max_redirects);
2019-12-06 14:37:21 +00:00
private:
2019-12-11 14:21:48 +00:00
ClientFactory();
private:
Aws::SDKOptions aws_options;
2019-12-03 16:23:24 +00:00
};
2019-12-06 14:37:21 +00:00
/**
2019-12-06 14:54:20 +00:00
* Represents S3 URI.
*
2019-12-06 14:37:21 +00:00
* The following patterns are allowed:
* s3://bucket/key
* http(s)://endpoint/bucket/key
*/
2019-12-06 14:48:56 +00:00
struct URI
{
Poco::URI uri;
2019-12-06 14:37:21 +00:00
// Custom endpoint if URI scheme is not S3.
String endpoint;
String bucket;
String key;
String storage_name;
2019-12-03 16:23:24 +00:00
bool is_virtual_hosted_style;
2020-01-18 23:18:23 +00:00
explicit URI(const Poco::URI & uri_);
2019-12-06 14:37:21 +00:00
};
2019-12-03 16:23:24 +00:00
}
2019-11-05 07:54:13 +00:00
#endif