9#include <unordered_set>
12#include <userver/http/header_map.hpp>
14#include <userver/s3api/authenticators/access_key.hpp>
15#include <userver/s3api/authenticators/interface.hpp>
16#include <userver/s3api/models/fwd.hpp>
17#include <userver/s3api/models/s3api_connection_type.hpp>
19USERVER_NAMESPACE_BEGIN
21namespace clients::
http {
31 using runtime_error::runtime_error;
35 using runtime_error::runtime_error;
39 using runtime_error::runtime_error;
44 explicit ConnectionCfg(
45 std::chrono::milliseconds s3timeout,
47 std::optional<std::string> proxy = {}
49 : timeout(s3timeout), retries(s3retries), proxy(proxy) {}
51 std::chrono::milliseconds timeout{1000};
53 std::optional<std::string> proxy{};
61 std::string last_modified;
71 clients::
http::Client& http_client,
72 S3ConnectionType connection_type,
73 std::string server_url,
82 using CiUnorderedMap = USERVER_NAMESPACE::http::
headers::HeaderMap;
83 using Meta = CiUnorderedMap;
84 using Headers = CiUnorderedMap;
87 HeaderDataRequest() {}
88 HeaderDataRequest(std::optional<std::unordered_set<std::string>> headers,
bool need_meta)
89 : headers(std::move(headers)), need_meta(need_meta) {}
90 std::optional<std::unordered_set<std::string>> headers{
std::
nullopt};
95 std::optional<Headers> headers;
96 std::optional<Meta> meta;
104 virtual ~Client() =
default;
108 virtual std::string PutObject(
109 std::string_view path,
111 const std::optional<Meta>& meta = std::nullopt,
112 std::string_view content_type =
"text/plain",
113 const std::optional<std::string>& content_disposition = std::nullopt,
114 const std::optional<std::vector<Tag>>& tags = std::nullopt
117 virtual void DeleteObject(std::string_view path)
const = 0;
119 virtual std::optional<std::string> GetObject(
120 std::string_view path,
121 std::optional<std::string> version = std::nullopt,
126 virtual std::string TryGetObject(
127 std::string_view path,
128 std::optional<std::string> version = std::nullopt,
133 virtual std::optional<std::string> GetPartialObject(
134 std::string_view path,
135 std::string_view range,
136 std::optional<std::string> version = std::nullopt,
141 virtual std::string TryGetPartialObject(
142 std::string_view path,
143 std::string_view range,
144 std::optional<std::string> version = std::nullopt,
149 virtual std::string CopyObject(
150 std::string_view key_from,
151 std::string_view bucket_to,
152 std::string_view key_to,
153 const std::optional<Meta>& meta = std::nullopt
157 CopyObject(std::string_view key_from, std::string_view key_to,
const std::optional<Meta>& meta = std::nullopt) = 0;
162 virtual std::string GenerateDownloadUrl(std::string_view path, time_t expires,
bool use_ssl =
false)
const = 0;
164 virtual std::string GenerateDownloadUrlVirtualHostAddressing(
165 std::string_view path,
166 const std::chrono::system_clock::time_point& expires_at,
167 std::string_view protocol =
"https://"
170 virtual std::string GenerateUploadUrlVirtualHostAddressing(
171 std::string_view data,
172 std::string_view content_type,
173 std::string_view path,
174 const std::chrono::system_clock::time_point& expires_at,
175 std::string_view protocol =
"https://"
178 virtual std::optional<std::string> ListBucketContents(
179 std::string_view path,
181 std::string marker =
"",
182 std::string delimiter =
""
185 virtual std::vector<ObjectMeta> ListBucketContentsParsed(std::string_view path_prefix)
const = 0;
187 virtual std::vector<std::string> ListBucketDirectories(std::string_view path_prefix)
const = 0;
191 virtual std::string_view GetBucketName()
const = 0;
196using ClientPtr = std::shared_ptr<
Client>;
198ClientPtr GetS3Client(
204ClientPtr GetS3Client(