mirror of
https://github.com/minio/minio-cpp.git
synced 2025-07-30 05:23:05 +03:00
Include files cleanup and minor API changes (#124)
* use namespace::subnamespace where applicable * make minio::error::SUCCESS declared only once * make more constructors explicit (minio::error) * moved constants that seem private into .cc files * added .clang-format file to enforce more formatting rules Co-authored-by: Petr Kobalicek <petr.kobalicek@min.io>
This commit is contained in:
@ -30,8 +30,7 @@
|
||||
#include "types.h"
|
||||
#include "utils.h"
|
||||
|
||||
namespace minio {
|
||||
namespace s3 {
|
||||
namespace minio::s3 {
|
||||
|
||||
struct BaseArgs {
|
||||
utils::Multimap extra_headers;
|
||||
@ -63,9 +62,9 @@ struct ObjectArgs : public BucketArgs {
|
||||
struct ObjectWriteArgs : public ObjectArgs {
|
||||
utils::Multimap headers;
|
||||
utils::Multimap user_metadata;
|
||||
Sse *sse = nullptr;
|
||||
Sse* sse = nullptr;
|
||||
std::map<std::string, std::string> tags;
|
||||
Retention *retention = nullptr;
|
||||
Retention* retention = nullptr;
|
||||
bool legal_hold = false;
|
||||
|
||||
ObjectWriteArgs() = default;
|
||||
@ -82,15 +81,15 @@ struct ObjectVersionArgs : public ObjectArgs {
|
||||
}; // struct ObjectVersionArgs
|
||||
|
||||
struct ObjectReadArgs : public ObjectVersionArgs {
|
||||
SseCustomerKey *ssec = nullptr;
|
||||
SseCustomerKey* ssec = nullptr;
|
||||
|
||||
ObjectReadArgs() = default;
|
||||
~ObjectReadArgs() = default;
|
||||
}; // struct ObjectReadArgs
|
||||
|
||||
struct ObjectConditionalReadArgs : public ObjectReadArgs {
|
||||
size_t *offset = nullptr;
|
||||
size_t *length = nullptr;
|
||||
size_t* offset = nullptr;
|
||||
size_t* length = nullptr;
|
||||
std::string match_etag;
|
||||
std::string not_match_etag;
|
||||
utils::UtcTime modified_since;
|
||||
@ -158,7 +157,7 @@ struct PutObjectApiArgs : public PutObjectBaseArgs {
|
||||
std::string_view data;
|
||||
utils::Multimap query_params;
|
||||
http::ProgressFunction progressfunc = nullptr;
|
||||
void *progress_userdata = nullptr;
|
||||
void* progress_userdata = nullptr;
|
||||
|
||||
PutObjectApiArgs() = default;
|
||||
~PutObjectApiArgs() = default;
|
||||
@ -169,7 +168,7 @@ struct UploadPartArgs : public ObjectWriteArgs {
|
||||
unsigned int part_number;
|
||||
std::string_view data;
|
||||
http::ProgressFunction progressfunc = nullptr;
|
||||
void *progress_userdata = nullptr;
|
||||
void* progress_userdata = nullptr;
|
||||
|
||||
UploadPartArgs() = default;
|
||||
~UploadPartArgs() = default;
|
||||
@ -196,7 +195,7 @@ struct DownloadObjectArgs : public ObjectReadArgs {
|
||||
std::string filename;
|
||||
bool overwrite;
|
||||
http::ProgressFunction progressfunc = nullptr;
|
||||
void *progress_userdata = nullptr;
|
||||
void* progress_userdata = nullptr;
|
||||
|
||||
DownloadObjectArgs() = default;
|
||||
~DownloadObjectArgs() = default;
|
||||
@ -206,9 +205,9 @@ struct DownloadObjectArgs : public ObjectReadArgs {
|
||||
|
||||
struct GetObjectArgs : public ObjectConditionalReadArgs {
|
||||
http::DataFunction datafunc;
|
||||
void *userdata = nullptr;
|
||||
void* userdata = nullptr;
|
||||
http::ProgressFunction progressfunc = nullptr;
|
||||
void *progress_userdata = nullptr;
|
||||
void* progress_userdata = nullptr;
|
||||
|
||||
GetObjectArgs() = default;
|
||||
~GetObjectArgs() = default;
|
||||
@ -235,11 +234,11 @@ struct ListObjectsArgs : public BucketArgs {
|
||||
ListObjectsArgs() = default;
|
||||
~ListObjectsArgs() = default;
|
||||
|
||||
ListObjectsArgs(const ListObjectsArgs &) = default;
|
||||
ListObjectsArgs &operator=(const ListObjectsArgs &) = default;
|
||||
ListObjectsArgs(const ListObjectsArgs&) = default;
|
||||
ListObjectsArgs& operator=(const ListObjectsArgs&) = default;
|
||||
|
||||
ListObjectsArgs(ListObjectsArgs &&) = default;
|
||||
ListObjectsArgs &operator=(ListObjectsArgs &&) = default;
|
||||
ListObjectsArgs(ListObjectsArgs&&) = default;
|
||||
ListObjectsArgs& operator=(ListObjectsArgs&&) = default;
|
||||
}; // struct ListObjectsArgs
|
||||
|
||||
struct ListObjectsCommonArgs : public BucketArgs {
|
||||
@ -251,11 +250,11 @@ struct ListObjectsCommonArgs : public BucketArgs {
|
||||
ListObjectsCommonArgs() = default;
|
||||
~ListObjectsCommonArgs() = default;
|
||||
|
||||
ListObjectsCommonArgs(const ListObjectsCommonArgs &) = default;
|
||||
ListObjectsCommonArgs &operator=(const ListObjectsCommonArgs &) = default;
|
||||
ListObjectsCommonArgs(const ListObjectsCommonArgs&) = default;
|
||||
ListObjectsCommonArgs& operator=(const ListObjectsCommonArgs&) = default;
|
||||
|
||||
ListObjectsCommonArgs(ListObjectsCommonArgs &&) = default;
|
||||
ListObjectsCommonArgs &operator=(ListObjectsCommonArgs &&) = default;
|
||||
ListObjectsCommonArgs(ListObjectsCommonArgs&&) = default;
|
||||
ListObjectsCommonArgs& operator=(ListObjectsCommonArgs&&) = default;
|
||||
}; // struct ListObjectsCommonArgs
|
||||
|
||||
struct ListObjectsV1Args : public ListObjectsCommonArgs {
|
||||
@ -264,15 +263,15 @@ struct ListObjectsV1Args : public ListObjectsCommonArgs {
|
||||
ListObjectsV1Args();
|
||||
|
||||
explicit ListObjectsV1Args(ListObjectsArgs args);
|
||||
ListObjectsV1Args &operator=(ListObjectsArgs args);
|
||||
ListObjectsV1Args& operator=(ListObjectsArgs args);
|
||||
|
||||
~ListObjectsV1Args() = default;
|
||||
|
||||
ListObjectsV1Args(const ListObjectsV1Args &) = default;
|
||||
ListObjectsV1Args &operator=(const ListObjectsV1Args &) = default;
|
||||
ListObjectsV1Args(const ListObjectsV1Args&) = default;
|
||||
ListObjectsV1Args& operator=(const ListObjectsV1Args&) = default;
|
||||
|
||||
ListObjectsV1Args(ListObjectsV1Args &&) = default;
|
||||
ListObjectsV1Args &operator=(ListObjectsV1Args &&) = default;
|
||||
ListObjectsV1Args(ListObjectsV1Args&&) = default;
|
||||
ListObjectsV1Args& operator=(ListObjectsV1Args&&) = default;
|
||||
}; // struct ListObjectsV1Args
|
||||
|
||||
struct ListObjectsV2Args : public ListObjectsCommonArgs {
|
||||
@ -284,15 +283,15 @@ struct ListObjectsV2Args : public ListObjectsCommonArgs {
|
||||
ListObjectsV2Args();
|
||||
|
||||
explicit ListObjectsV2Args(ListObjectsArgs args);
|
||||
ListObjectsV2Args &operator=(ListObjectsArgs args);
|
||||
ListObjectsV2Args& operator=(ListObjectsArgs args);
|
||||
|
||||
~ListObjectsV2Args() = default;
|
||||
|
||||
ListObjectsV2Args(const ListObjectsV2Args &) = default;
|
||||
ListObjectsV2Args &operator=(const ListObjectsV2Args &) = default;
|
||||
ListObjectsV2Args(const ListObjectsV2Args&) = default;
|
||||
ListObjectsV2Args& operator=(const ListObjectsV2Args&) = default;
|
||||
|
||||
ListObjectsV2Args(ListObjectsV2Args &&) = default;
|
||||
ListObjectsV2Args &operator=(ListObjectsV2Args &&) = default;
|
||||
ListObjectsV2Args(ListObjectsV2Args&&) = default;
|
||||
ListObjectsV2Args& operator=(ListObjectsV2Args&&) = default;
|
||||
}; // struct ListObjectsV2Args
|
||||
|
||||
struct ListObjectVersionsArgs : public ListObjectsCommonArgs {
|
||||
@ -302,23 +301,23 @@ struct ListObjectVersionsArgs : public ListObjectsCommonArgs {
|
||||
ListObjectVersionsArgs();
|
||||
|
||||
explicit ListObjectVersionsArgs(ListObjectsArgs args);
|
||||
ListObjectVersionsArgs &operator=(ListObjectsArgs args);
|
||||
ListObjectVersionsArgs& operator=(ListObjectsArgs args);
|
||||
|
||||
~ListObjectVersionsArgs() = default;
|
||||
|
||||
ListObjectVersionsArgs(const ListObjectVersionsArgs &) = default;
|
||||
ListObjectVersionsArgs &operator=(const ListObjectVersionsArgs &) = default;
|
||||
ListObjectVersionsArgs(const ListObjectVersionsArgs&) = default;
|
||||
ListObjectVersionsArgs& operator=(const ListObjectVersionsArgs&) = default;
|
||||
|
||||
ListObjectVersionsArgs(ListObjectVersionsArgs &&) = default;
|
||||
ListObjectVersionsArgs &operator=(ListObjectVersionsArgs &&) = default;
|
||||
ListObjectVersionsArgs(ListObjectVersionsArgs&&) = default;
|
||||
ListObjectVersionsArgs& operator=(ListObjectVersionsArgs&&) = default;
|
||||
}; // struct ListObjectVersionsArgs
|
||||
|
||||
struct PutObjectArgs : public PutObjectBaseArgs {
|
||||
std::istream &stream;
|
||||
std::istream& stream;
|
||||
http::ProgressFunction progressfunc = nullptr;
|
||||
void *progress_userdata = nullptr;
|
||||
void* progress_userdata = nullptr;
|
||||
|
||||
PutObjectArgs(std::istream &stream, long object_size, long part_size);
|
||||
PutObjectArgs(std::istream& stream, long object_size, long part_size);
|
||||
~PutObjectArgs() = default;
|
||||
|
||||
error::Error Validate();
|
||||
@ -328,8 +327,8 @@ using CopySource = ObjectConditionalReadArgs;
|
||||
|
||||
struct CopyObjectArgs : public ObjectWriteArgs {
|
||||
CopySource source;
|
||||
Directive *metadata_directive = nullptr;
|
||||
Directive *tagging_directive = nullptr;
|
||||
Directive* metadata_directive = nullptr;
|
||||
Directive* tagging_directive = nullptr;
|
||||
|
||||
CopyObjectArgs() = default;
|
||||
~CopyObjectArgs() = default;
|
||||
@ -341,7 +340,7 @@ struct ComposeSource : public ObjectConditionalReadArgs {
|
||||
ComposeSource() = default;
|
||||
~ComposeSource() = default;
|
||||
|
||||
error::Error BuildHeaders(size_t object_size, const std::string &etag);
|
||||
error::Error BuildHeaders(size_t object_size, const std::string& etag);
|
||||
size_t ObjectSize() const;
|
||||
utils::Multimap Headers() const;
|
||||
|
||||
@ -362,7 +361,7 @@ struct ComposeObjectArgs : public ObjectWriteArgs {
|
||||
struct UploadObjectArgs : public PutObjectBaseArgs {
|
||||
std::string filename;
|
||||
http::ProgressFunction progressfunc = nullptr;
|
||||
void *progress_userdata = nullptr;
|
||||
void* progress_userdata = nullptr;
|
||||
|
||||
UploadObjectArgs() = default;
|
||||
~UploadObjectArgs() = default;
|
||||
@ -379,7 +378,7 @@ struct RemoveObjectsApiArgs : public BucketArgs {
|
||||
~RemoveObjectsApiArgs() = default;
|
||||
}; // struct RemoveObjectsApiArgs
|
||||
|
||||
using DeleteObjectFunction = std::function<bool(DeleteObject &)>;
|
||||
using DeleteObjectFunction = std::function<bool(DeleteObject&)>;
|
||||
|
||||
struct RemoveObjectsArgs : public BucketArgs {
|
||||
bool bypass_governance_mode = false;
|
||||
@ -392,10 +391,10 @@ struct RemoveObjectsArgs : public BucketArgs {
|
||||
}; // struct RemoveObjectsArgs
|
||||
|
||||
struct SelectObjectContentArgs : public ObjectReadArgs {
|
||||
SelectRequest &request;
|
||||
SelectRequest& request;
|
||||
SelectResultFunction resultfunc = nullptr;
|
||||
|
||||
SelectObjectContentArgs(SelectRequest &req, SelectResultFunction func)
|
||||
SelectObjectContentArgs(SelectRequest& req, SelectResultFunction func)
|
||||
: request(req), resultfunc(func) {}
|
||||
|
||||
~SelectObjectContentArgs() = default;
|
||||
@ -433,9 +432,9 @@ using DeleteBucketNotificationArgs = BucketArgs;
|
||||
using GetBucketNotificationArgs = BucketArgs;
|
||||
|
||||
struct SetBucketNotificationArgs : public BucketArgs {
|
||||
NotificationConfig &config;
|
||||
NotificationConfig& config;
|
||||
|
||||
explicit SetBucketNotificationArgs(NotificationConfig &configvalue)
|
||||
explicit SetBucketNotificationArgs(NotificationConfig& configvalue)
|
||||
: config(configvalue) {}
|
||||
|
||||
~SetBucketNotificationArgs() = default;
|
||||
@ -446,9 +445,9 @@ using DeleteBucketEncryptionArgs = BucketArgs;
|
||||
using GetBucketEncryptionArgs = BucketArgs;
|
||||
|
||||
struct SetBucketEncryptionArgs : public BucketArgs {
|
||||
SseConfig &config;
|
||||
SseConfig& config;
|
||||
|
||||
explicit SetBucketEncryptionArgs(SseConfig &sseconfig) : config(sseconfig) {}
|
||||
explicit SetBucketEncryptionArgs(SseConfig& sseconfig) : config(sseconfig) {}
|
||||
|
||||
~SetBucketEncryptionArgs() = default;
|
||||
|
||||
@ -472,9 +471,9 @@ using DeleteBucketReplicationArgs = BucketArgs;
|
||||
using GetBucketReplicationArgs = BucketArgs;
|
||||
|
||||
struct SetBucketReplicationArgs : public BucketArgs {
|
||||
ReplicationConfig &config;
|
||||
ReplicationConfig& config;
|
||||
|
||||
explicit SetBucketReplicationArgs(ReplicationConfig &value) : config(value) {}
|
||||
explicit SetBucketReplicationArgs(ReplicationConfig& value) : config(value) {}
|
||||
|
||||
~SetBucketReplicationArgs() = default;
|
||||
}; // struct SetBucketReplication
|
||||
@ -484,9 +483,9 @@ using DeleteBucketLifecycleArgs = BucketArgs;
|
||||
using GetBucketLifecycleArgs = BucketArgs;
|
||||
|
||||
struct SetBucketLifecycleArgs : public BucketArgs {
|
||||
LifecycleConfig &config;
|
||||
LifecycleConfig& config;
|
||||
|
||||
explicit SetBucketLifecycleArgs(LifecycleConfig &value) : config(value) {}
|
||||
explicit SetBucketLifecycleArgs(LifecycleConfig& value) : config(value) {}
|
||||
|
||||
~SetBucketLifecycleArgs() = default;
|
||||
}; // struct SetBucketLifecycle
|
||||
@ -581,14 +580,14 @@ struct PostPolicy {
|
||||
size_t upper_limit);
|
||||
void RemoveContentLengthRangeCondition();
|
||||
|
||||
error::Error FormData(std::map<std::string, std::string> &data,
|
||||
error::Error FormData(std::map<std::string, std::string>& data,
|
||||
std::string access_key, std::string secret_key,
|
||||
std::string session_token, std::string region);
|
||||
|
||||
private:
|
||||
static constexpr const char *eq_ = "eq";
|
||||
static constexpr const char *starts_with_ = "starts-with";
|
||||
static constexpr const char *algorithm_ = "AWS4-HMAC-SHA256";
|
||||
static constexpr const char* eq_ = "eq";
|
||||
static constexpr const char* starts_with_ = "starts-with";
|
||||
static constexpr const char* algorithm_ = "AWS4-HMAC-SHA256";
|
||||
|
||||
utils::UtcTime expiration_;
|
||||
std::map<std::string, std::map<std::string, std::string>> conditions_;
|
||||
@ -601,7 +600,7 @@ struct PostPolicy {
|
||||
std::string region);
|
||||
static bool isReservedElement(std::string element);
|
||||
}; // struct PostPolicy
|
||||
} // namespace s3
|
||||
} // namespace minio
|
||||
|
||||
} // namespace minio::s3
|
||||
|
||||
#endif // _MINIO_CPP_ARGS_H_INCLUDED
|
||||
|
@ -31,8 +31,8 @@
|
||||
#include "response.h"
|
||||
#include "utils.h"
|
||||
|
||||
namespace minio {
|
||||
namespace s3 {
|
||||
namespace minio::s3 {
|
||||
|
||||
utils::Multimap GetCommonListObjectsQueryParams(
|
||||
const std::string& delimiter, const std::string& encoding_type,
|
||||
unsigned int max_keys, const std::string& prefix);
|
||||
@ -151,7 +151,7 @@ class BaseClient {
|
||||
UploadPartResponse UploadPart(UploadPartArgs args);
|
||||
UploadPartCopyResponse UploadPartCopy(UploadPartCopyArgs args);
|
||||
}; // class BaseClient
|
||||
} // namespace s3
|
||||
} // namespace minio
|
||||
|
||||
} // namespace minio::s3
|
||||
|
||||
#endif // MINIO_CPP_BASECLIENT_H_INCLUDED
|
||||
|
@ -28,8 +28,7 @@
|
||||
#include "request.h"
|
||||
#include "response.h"
|
||||
|
||||
namespace minio {
|
||||
namespace s3 {
|
||||
namespace minio::s3 {
|
||||
|
||||
class Client;
|
||||
|
||||
@ -125,7 +124,6 @@ class Client : public BaseClient {
|
||||
RemoveObjectsResult RemoveObjects(RemoveObjectsArgs args);
|
||||
}; // class Client
|
||||
|
||||
} // namespace s3
|
||||
} // namespace minio
|
||||
} // namespace minio::s3
|
||||
|
||||
#endif // MINIO_CPP_CLIENT_H_INCLUDED
|
||||
|
@ -24,8 +24,7 @@
|
||||
#include "error.h"
|
||||
#include "utils.h"
|
||||
|
||||
namespace minio {
|
||||
namespace creds {
|
||||
namespace minio::creds {
|
||||
|
||||
bool expired(const utils::UtcTime& expiration);
|
||||
|
||||
@ -76,7 +75,6 @@ struct Credentials {
|
||||
static Credentials ParseXML(std::string_view data, const std::string& root);
|
||||
}; // class Credentials
|
||||
|
||||
} // namespace creds
|
||||
} // namespace minio
|
||||
} // namespace minio::creds
|
||||
|
||||
#endif // MINIO_CPP_CREDENTIALS_H_INCLUDED
|
||||
|
@ -22,8 +22,7 @@
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
|
||||
namespace minio {
|
||||
namespace error {
|
||||
namespace minio::error {
|
||||
|
||||
class Error {
|
||||
private:
|
||||
@ -31,17 +30,18 @@ class Error {
|
||||
|
||||
public:
|
||||
Error() = default;
|
||||
Error(std::string_view msg) : msg_(msg) {}
|
||||
|
||||
explicit Error(std::string msg) : msg_(std::move(msg)) {}
|
||||
|
||||
Error(const Error&) = default;
|
||||
Error& operator=(const Error&) = default;
|
||||
|
||||
Error(Error&& v) = default;
|
||||
|
||||
Error& operator=(const Error&) = default;
|
||||
Error& operator=(Error&& v) = default;
|
||||
|
||||
~Error() = default;
|
||||
|
||||
std::string String() const { return msg_; }
|
||||
const std::string& String() const { return msg_; }
|
||||
explicit operator bool() const { return !msg_.empty(); }
|
||||
|
||||
friend std::ostream& operator<<(std::ostream& s, const Error& e) {
|
||||
@ -49,14 +49,13 @@ class Error {
|
||||
}
|
||||
}; // class Error
|
||||
|
||||
const static Error SUCCESS;
|
||||
extern const Error SUCCESS;
|
||||
|
||||
template <typename T_RESULT, typename... TA>
|
||||
inline T_RESULT make(TA&&... args) {
|
||||
return T_RESULT{Error(std::forward<TA>(args)...)};
|
||||
}
|
||||
|
||||
} // namespace error
|
||||
} // namespace minio
|
||||
} // namespace minio::error
|
||||
|
||||
#endif // MINIO_CPP_ERROR_H_INCLUDED
|
||||
|
@ -29,32 +29,12 @@
|
||||
#include "error.h"
|
||||
#include "utils.h"
|
||||
|
||||
namespace minio {
|
||||
namespace http {
|
||||
namespace minio::http {
|
||||
|
||||
enum class Method { kGet, kHead, kPost, kPut, kDelete };
|
||||
|
||||
// MethodToString converts http Method enum to string.
|
||||
constexpr const char* MethodToString(Method method) noexcept {
|
||||
switch (method) {
|
||||
case Method::kGet:
|
||||
return "GET";
|
||||
case Method::kHead:
|
||||
return "HEAD";
|
||||
case Method::kPost:
|
||||
return "POST";
|
||||
case Method::kPut:
|
||||
return "PUT";
|
||||
case Method::kDelete:
|
||||
return "DELETE";
|
||||
default: {
|
||||
std::cerr << "ABORT: Unimplemented HTTP method. This should not happen."
|
||||
<< std::endl;
|
||||
std::terminate();
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
//! MethodToString converts http Method enum to string.
|
||||
const char* MethodToString(Method method) noexcept;
|
||||
|
||||
/**
|
||||
* Url represents HTTP URL and it's components.
|
||||
@ -100,11 +80,10 @@ struct DataFunctionArgs {
|
||||
void* userdata = nullptr;
|
||||
|
||||
DataFunctionArgs() = default;
|
||||
explicit DataFunctionArgs(curlpp::Easy* handle, Response* response,
|
||||
void* userdata)
|
||||
DataFunctionArgs(curlpp::Easy* handle, Response* response, void* userdata)
|
||||
: handle(handle), response(response), userdata(userdata) {}
|
||||
explicit DataFunctionArgs(curlpp::Easy* handle, Response* response,
|
||||
std::string datachunk, void* userdata)
|
||||
DataFunctionArgs(curlpp::Easy* handle, Response* response,
|
||||
std::string datachunk, void* userdata)
|
||||
: handle(handle),
|
||||
response(response),
|
||||
datachunk(std::move(datachunk)),
|
||||
@ -121,9 +100,6 @@ struct ProgressFunctionArgs {
|
||||
double download_speed = 0.0;
|
||||
double upload_speed = 0.0;
|
||||
void* userdata = nullptr;
|
||||
|
||||
ProgressFunctionArgs() = default;
|
||||
~ProgressFunctionArgs() = default;
|
||||
}; // struct ProgressFunctionArgs
|
||||
|
||||
struct Request {
|
||||
@ -186,7 +162,6 @@ struct Response {
|
||||
error::Error ReadHeaders();
|
||||
}; // struct Response
|
||||
|
||||
} // namespace http
|
||||
} // namespace minio
|
||||
} // namespace minio::http
|
||||
|
||||
#endif // MINIO_CPP_HTTP_H_INCLUDED
|
||||
|
@ -27,12 +27,16 @@
|
||||
#include "error.h"
|
||||
#include "http.h"
|
||||
|
||||
#define DEFAULT_DURATION_SECONDS (60 * 60 * 24) // 1 day.
|
||||
#define MIN_DURATION_SECONDS (60 * 15) // 15 minutes.
|
||||
#define MAX_DURATION_SECONDS (60 * 60 * 24 * 7) // 7 days.
|
||||
namespace minio::creds {
|
||||
|
||||
namespace minio {
|
||||
namespace creds {
|
||||
// 1 day.
|
||||
static constexpr unsigned DEFAULT_DURATION_SECONDS = 60 * 60 * 24;
|
||||
|
||||
// 15 minutes.
|
||||
static constexpr unsigned MIN_DURATION_SECONDS = 60 * 15;
|
||||
|
||||
// 7 days.
|
||||
static constexpr unsigned MAX_DURATION_SECONDS = 60 * 60 * 24 * 7;
|
||||
|
||||
struct Jwt {
|
||||
std::string token;
|
||||
@ -250,7 +254,6 @@ struct CertificateIdentityProvider : public Provider {
|
||||
virtual Credentials Fetch() override;
|
||||
}; // struct CertificateIdentityProvider
|
||||
|
||||
} // namespace creds
|
||||
} // namespace minio
|
||||
} // namespace minio::creds
|
||||
|
||||
#endif // MINIO_CPP_PROVIDERS_H_INCLUDED
|
||||
|
@ -18,7 +18,6 @@
|
||||
#ifndef MINIO_CPP_REQUEST_H_INCLUDED
|
||||
#define MINIO_CPP_REQUEST_H_INCLUDED
|
||||
|
||||
#include <regex>
|
||||
#include <string>
|
||||
|
||||
#include "error.h"
|
||||
@ -26,36 +25,7 @@
|
||||
#include "providers.h"
|
||||
#include "utils.h"
|
||||
|
||||
namespace minio {
|
||||
namespace s3 {
|
||||
|
||||
const std::string AWS_S3_PREFIX =
|
||||
"^(((bucket\\.|accesspoint\\.)"
|
||||
"vpce(-(?!_)[a-z_\\d]+)+\\.s3\\.)|"
|
||||
"((?!s3)(?!-)(?!_)[a-z_\\d-]{1,63}\\.)"
|
||||
"s3-control(-(?!_)[a-z_\\d]+)*\\.|"
|
||||
"(s3(-(?!_)[a-z_\\d]+)*\\.))";
|
||||
const std::regex HOSTNAME_REGEX(
|
||||
"^((?!-)(?!_)[a-z_\\d-]{1,63}\\.)*"
|
||||
"((?!_)(?!-)[a-z_\\d-]{1,63})$",
|
||||
std::regex_constants::icase);
|
||||
const std::regex AWS_ENDPOINT_REGEX(".*\\.amazonaws\\.com(|\\.cn)$",
|
||||
std::regex_constants::icase);
|
||||
const std::regex AWS_S3_ENDPOINT_REGEX(
|
||||
AWS_S3_PREFIX + "((?!s3)(?!-)(?!_)[a-z_\\d-]{1,63}\\.)*" +
|
||||
"amazonaws\\.com(|\\.cn)$",
|
||||
std::regex_constants::icase);
|
||||
const std::regex AWS_ELB_ENDPOINT_REGEX(
|
||||
"^(?!-)(?!_)[a-z_\\d-]{1,63}\\."
|
||||
"(?!-)(?!_)[a-z_\\d-]{1,63}\\."
|
||||
"elb\\.amazonaws\\.com$",
|
||||
std::regex_constants::icase);
|
||||
const std::regex AWS_S3_PREFIX_REGEX(AWS_S3_PREFIX,
|
||||
std::regex_constants::icase);
|
||||
const std::regex REGION_REGEX("^((?!_)(?!-)[a-z_\\d-]{1,63})$",
|
||||
std::regex_constants::icase);
|
||||
|
||||
bool awsRegexMatch(std::string_view value, const std::regex& regex);
|
||||
namespace minio::s3 {
|
||||
|
||||
error::Error getAwsInfo(const std::string& host, bool https,
|
||||
std::string& region, std::string& aws_s3_prefix,
|
||||
@ -140,7 +110,6 @@ struct Request {
|
||||
void BuildHeaders(http::Url& url, creds::Provider* const provider);
|
||||
}; // struct Request
|
||||
|
||||
} // namespace s3
|
||||
} // namespace minio
|
||||
} // namespace minio::s3
|
||||
|
||||
#endif // MINIO_CPP_REQUEST_H_INCLUDED
|
||||
|
@ -27,10 +27,10 @@
|
||||
#include "types.h"
|
||||
#include "utils.h"
|
||||
|
||||
namespace minio {
|
||||
namespace s3 {
|
||||
namespace minio::s3 {
|
||||
|
||||
struct Response {
|
||||
public:
|
||||
int status_code = 0;
|
||||
utils::Multimap headers;
|
||||
std::string data;
|
||||
@ -43,6 +43,10 @@ struct Response {
|
||||
std::string bucket_name;
|
||||
std::string object_name;
|
||||
|
||||
private:
|
||||
error::Error err_;
|
||||
|
||||
public:
|
||||
Response();
|
||||
explicit Response(error::Error err) : err_(std::move(err)) {}
|
||||
|
||||
@ -63,9 +67,6 @@ struct Response {
|
||||
|
||||
static Response ParseXML(std::string_view data, int status_code,
|
||||
utils::Multimap headers);
|
||||
|
||||
private:
|
||||
error::Error err_;
|
||||
}; // struct Response
|
||||
|
||||
#define MINIO_S3_DERIVE_FROM_RESPONSE(DerivedName) \
|
||||
@ -569,7 +570,6 @@ struct GetPresignedPostFormDataResponse : public Response {
|
||||
#undef MINIO_S3_DERIVE_FROM_PUT_OBJECT_RESPONSE
|
||||
#undef MINIO_S3_DERIVE_FROM_RESPONSE
|
||||
|
||||
} // namespace s3
|
||||
} // namespace minio
|
||||
} // namespace minio::s3
|
||||
|
||||
#endif // MINIO_CPP_RESPONSE_H_INCLUDED
|
||||
|
@ -26,8 +26,8 @@
|
||||
#include "http.h"
|
||||
#include "types.h"
|
||||
|
||||
namespace minio {
|
||||
namespace s3 {
|
||||
namespace minio::s3 {
|
||||
|
||||
class SelectHandler {
|
||||
private:
|
||||
SelectResultFunction result_func_ = nullptr;
|
||||
@ -41,7 +41,7 @@ class SelectHandler {
|
||||
std::string prelude_crc_;
|
||||
bool prelude_crc_read_ = false;
|
||||
|
||||
unsigned int total_length_ = 0;
|
||||
size_t total_length_ = 0;
|
||||
|
||||
std::string data_;
|
||||
bool data_read_ = false;
|
||||
@ -66,7 +66,7 @@ class SelectHandler {
|
||||
|
||||
bool DataFunction(const http::DataFunctionArgs& args);
|
||||
}; // struct SelectHandler
|
||||
} // namespace s3
|
||||
} // namespace minio
|
||||
|
||||
} // namespace minio::s3
|
||||
|
||||
#endif // MINIO_CPP_SELECT_H_INCLUDED
|
||||
|
@ -23,8 +23,7 @@
|
||||
#include "http.h"
|
||||
#include "utils.h"
|
||||
|
||||
namespace minio {
|
||||
namespace signer {
|
||||
namespace minio::signer {
|
||||
|
||||
std::string GetScope(const utils::UtcTime& time, const std::string& region,
|
||||
const std::string& service_name);
|
||||
@ -78,7 +77,7 @@ std::string PostPresignV4(const std::string& data,
|
||||
const std::string& secret_key,
|
||||
const utils::UtcTime& date,
|
||||
const std::string& region);
|
||||
} // namespace signer
|
||||
} // namespace minio
|
||||
|
||||
} // namespace minio::signer
|
||||
|
||||
#endif // MINIO_CPP_SIGNER_H_INCLUDED
|
||||
|
@ -22,8 +22,8 @@
|
||||
|
||||
#include "utils.h"
|
||||
|
||||
namespace minio {
|
||||
namespace s3 {
|
||||
namespace minio::s3 {
|
||||
|
||||
class Sse {
|
||||
protected:
|
||||
utils::Multimap headers_;
|
||||
@ -62,7 +62,7 @@ class SseS3 : public Sse {
|
||||
|
||||
virtual bool TlsRequired() const override;
|
||||
}; // class SseS3
|
||||
} // namespace s3
|
||||
} // namespace minio
|
||||
|
||||
} // namespace minio::s3
|
||||
|
||||
#endif // MINIO_CPP_SSE_H_INCLUDED
|
||||
|
@ -31,8 +31,7 @@
|
||||
#include "error.h"
|
||||
#include "utils.h"
|
||||
|
||||
namespace minio {
|
||||
namespace s3 {
|
||||
namespace minio::s3 {
|
||||
|
||||
enum class RetentionMode { kGovernance, kCompliance };
|
||||
|
||||
@ -767,7 +766,6 @@ struct ObjectLockConfig {
|
||||
error::Error Validate() const;
|
||||
}; // struct ObjectLockConfig
|
||||
|
||||
} // namespace s3
|
||||
} // namespace minio
|
||||
} // namespace minio::s3
|
||||
|
||||
#endif // MINIO_CPP_TYPES_H_INCLUDED
|
||||
|
@ -33,8 +33,7 @@
|
||||
|
||||
#include "error.h"
|
||||
|
||||
namespace minio {
|
||||
namespace utils {
|
||||
namespace minio::utils {
|
||||
|
||||
inline constexpr unsigned int kMaxMultipartCount = 10000; // 10000 parts
|
||||
inline constexpr uint64_t kMaxObjectSize = 5'497'558'138'880; // 5TiB
|
||||
@ -227,7 +226,6 @@ struct CharBuffer : std::streambuf {
|
||||
std::ios_base::openmode which = std::ios_base::in) override;
|
||||
}; // struct CharBuffer
|
||||
|
||||
} // namespace utils
|
||||
} // namespace minio
|
||||
} // namespace minio::utils
|
||||
|
||||
#endif // MINIO_CPP_UTILS_H_INCLUDED
|
||||
|
Reference in New Issue
Block a user