Skip to content

Commit

Permalink
fix s3api: clean up clang-tidy issues, fix macos testsuite requirements
Browse files Browse the repository at this point in the history
Testing: current tests
commit_hash:ee11834ab9121ad8bac615698b958c4070082450
  • Loading branch information
aserebriyskiy committed Nov 7, 2024
1 parent 17aee6f commit 6b2b96e
Show file tree
Hide file tree
Showing 11 changed files with 38 additions and 160 deletions.
4 changes: 0 additions & 4 deletions .mapping.json
Original file line number Diff line number Diff line change
Expand Up @@ -2180,13 +2180,9 @@
"libraries/s3api/src/s3api/s3api_methods.cpp":"taxi/uservices/userver/libraries/s3api/src/s3api/s3api_methods.cpp",
"libraries/s3api/src/s3api/s3api_methods.hpp":"taxi/uservices/userver/libraries/s3api/src/s3api/s3api_methods.hpp",
"libraries/s3api/src/s3api/s3api_methods_test.cpp":"taxi/uservices/userver/libraries/s3api/src/s3api/s3api_methods_test.cpp",
"libraries/s3api/tests/ya.make":"taxi/uservices/userver/libraries/s3api/tests/ya.make",
"libraries/s3api/utest/CMakeLists.txt":"taxi/uservices/userver/libraries/s3api/utest/CMakeLists.txt",
"libraries/s3api/utest/include/userver/s3api/utest/client_gmock.hpp":"taxi/uservices/userver/libraries/s3api/utest/include/userver/s3api/utest/client_gmock.hpp",
"libraries/s3api/utest/src/client_gmock.cpp":"taxi/uservices/userver/libraries/s3api/utest/src/client_gmock.cpp",
"libraries/s3api/utest/ya.make":"taxi/uservices/userver/libraries/s3api/utest/ya.make",
"libraries/s3api/ya.make":"taxi/uservices/userver/libraries/s3api/ya.make",
"libraries/s3api/ya.make.ext":"taxi/uservices/userver/libraries/s3api/ya.make.ext",
"mongo/CMakeLists.txt":"taxi/uservices/userver/mongo/CMakeLists.txt",
"mongo/README.md":"taxi/uservices/userver/mongo/README.md",
"mongo/functional_tests/CMakeLists.txt":"taxi/uservices/userver/mongo/functional_tests/CMakeLists.txt",
Expand Down
2 changes: 1 addition & 1 deletion libraries/s3api/src/s3api/clients/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ std::vector<ObjectMeta> ClientImpl::ListBucketContentsParsed(std::string_view pa
std::string marker = "";
bool is_finished = false;
while (!is_finished) {
auto response = ListBucketContents(path_prefix, kMaxS3Keys, marker);
auto response = ListBucketContents(path_prefix, kMaxS3Keys, marker, {});
if (!response) {
LOG_WARNING() << "Empty S3 bucket listing response for path prefix " << path_prefix;
break;
Expand Down
59 changes: 27 additions & 32 deletions libraries/s3api/src/s3api/clients/client.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,84 +45,79 @@ class ClientImpl : public Client {
std::shared_ptr<authenticators::AccessKey> authenticator,
std::string bucket
);
virtual ~ClientImpl() = default;
~ClientImpl() override = default;

std::string PutObject(
std::string_view path,
std::string data,
const std::optional<Meta>& meta = std::nullopt,
std::string_view content_type = "text/plain",
const std::optional<std::string>& content_disposition = std::nullopt,
const std::optional<std::vector<Tag>>& tags = std::nullopt
const std::optional<Meta>& meta,
std::string_view content_type,
const std::optional<std::string>& content_disposition,
const std::optional<std::vector<Tag>>& tags
) const final;

void DeleteObject(std::string_view path) const final;

std::optional<std::string> GetObject(
std::string_view path,
std::optional<std::string> version = std::nullopt,
HeadersDataResponse* headers_data = nullptr,
const HeaderDataRequest& headers_request = HeaderDataRequest()
std::optional<std::string> versiong,
HeadersDataResponse* headers_data,
const HeaderDataRequest& headers_request
) const final;

std::string TryGetObject(
std::string_view path,
std::optional<std::string> version = std::nullopt,
HeadersDataResponse* headers_data = nullptr,
const HeaderDataRequest& headers_request = HeaderDataRequest()
std::optional<std::string> versiong,
HeadersDataResponse* headers_data,
const HeaderDataRequest& headers_request
) const final;

std::optional<std::string> GetPartialObject(
std::string_view path,
std::string_view range,
std::optional<std::string> version = std::nullopt,
HeadersDataResponse* headers_data = nullptr,
const HeaderDataRequest& headers_request = HeaderDataRequest()
std::optional<std::string> versiong,
HeadersDataResponse* headers_data,
const HeaderDataRequest& headers_request
) const final;

std::string TryGetPartialObject(
std::string_view path,
std::string_view range,
std::optional<std::string> version = std::nullopt,
HeadersDataResponse* headers_data = nullptr,
const HeaderDataRequest& headers_request = HeaderDataRequest()
std::optional<std::string> versiong,
HeadersDataResponse* headers_data,
const HeaderDataRequest& headers_request
) const final;

std::string CopyObject(
std::string_view key_from,
std::string_view bucket_to,
std::string_view key_to,
const std::optional<Meta>& meta = std::nullopt
);
const std::optional<Meta>& meta
) final;

std::string
CopyObject(std::string_view key_from, std::string_view key_to, const std::optional<Meta>& meta = std::nullopt);
std::string CopyObject(std::string_view key_from, std::string_view key_to, const std::optional<Meta>& meta) final;

std::optional<HeadersDataResponse>
GetObjectHead(std::string_view path, const HeaderDataRequest& request = HeaderDataRequest()) const final;
std::optional<HeadersDataResponse> GetObjectHead(std::string_view path, const HeaderDataRequest& request)
const final;

std::string GenerateDownloadUrl(std::string_view path, time_t expires, bool use_ssl = false) const final;
std::string GenerateDownloadUrl(std::string_view path, time_t expires, bool use_ssl) const final;

std::string GenerateDownloadUrlVirtualHostAddressing(
std::string_view path,
const std::chrono::system_clock::time_point& expires_at,
std::string_view protocol = "https://"
std::string_view protocol
) const final;

std::string GenerateUploadUrlVirtualHostAddressing(
std::string_view data,
std::string_view content_type,
std::string_view path,
const std::chrono::system_clock::time_point& expires_at,
std::string_view protocol = "https://"
std::string_view protocol
) const final;

std::optional<std::string> ListBucketContents(
std::string_view path,
int max_keys,
std::string marker = "",
std::string delimiter = ""
) const final;
std::optional<std::string>
ListBucketContents(std::string_view path, int max_keys, std::string marker, std::string delimiter) const final;

std::vector<ObjectMeta> ListBucketContentsParsed(std::string_view path_prefix) const final;

Expand Down
21 changes: 7 additions & 14 deletions libraries/s3api/src/s3api/s3_connection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,35 +34,28 @@ class S3Connection : public std::enable_shared_from_this<S3Connection> {
http_client_(http_client),
config_(params) {}

S3Connection(const S3Connection& other)
: std::enable_shared_from_this<S3Connection>(other),
api_url_(other.api_url_),
connection_type_(other.connection_type_),
http_client_(other.http_client_),
config_(other.config_) {}
S3Connection(const S3Connection& other) = default;

virtual ~S3Connection() = default;
~S3Connection() = default;

virtual std::shared_ptr<clients::http::Response> RequestApi(Request& r, std::string_view method_name);
std::shared_ptr<clients::http::Response> RequestApi(Request& r, std::string_view method_name);

virtual std::shared_ptr<clients::http::Response> DoStartApiRequest(const Request& r) const;
std::shared_ptr<clients::http::Response> DoStartApiRequest(const Request& r) const;

virtual std::shared_ptr<clients::http::Response> StartApiRequest(const Request& r) const;
std::shared_ptr<clients::http::Response> StartApiRequest(const Request& r) const;

virtual std::string GetHost() const { return api_url_; }
std::string GetHost() const { return api_url_; }

void UpdateConfig(ConnectionCfg&& config) { config_ = config; }

protected:
private:
std::string GetUrl(const Request& r, S3ConnectionType connection_type) const;

ConnectionCfg GetConfig() const { return config_; }

const std::string api_url_;
S3ConnectionType connection_type_;
clients::http::Client& http_client_;

private:
ConnectionCfg config_;
};

Expand Down
7 changes: 2 additions & 5 deletions libraries/s3api/src/s3api/s3api_methods.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@

USERVER_NAMESPACE_BEGIN

namespace s3api {

namespace api_methods {
namespace s3api::api_methods {

namespace headers {
inline constexpr USERVER_NAMESPACE::http::headers::PredefinedHeader kAmzCopySource{"x-amz-copy-source"};
Expand Down Expand Up @@ -53,8 +51,7 @@ Request CopyObject(
std::string_view dest_key,
std::string_view content_type
);
} // namespace api_methods

} // namespace s3api
} // namespace s3api::api_methods

USERVER_NAMESPACE_END
34 changes: 0 additions & 34 deletions libraries/s3api/tests/ya.make

This file was deleted.

25 changes: 0 additions & 25 deletions libraries/s3api/utest/ya.make

This file was deleted.

34 changes: 0 additions & 34 deletions libraries/s3api/ya.make

This file was deleted.

10 changes: 0 additions & 10 deletions libraries/s3api/ya.make.ext

This file was deleted.

1 change: 0 additions & 1 deletion testsuite/requirements-internal-tests-linux.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
netifaces >= 0.10.0
grpcio-reflection
1 change: 1 addition & 0 deletions testsuite/requirements-internal-tests.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
httpx >= 0.27.0
h2 >= 4.1.0
grpcio-reflection

0 comments on commit 6b2b96e

Please sign in to comment.