Commit dab9b4c4 authored by Dzmitry Poloyko (EPAM)'s avatar Dzmitry Poloyko (EPAM)
Browse files

GONRG-498 Specify the storage class in options

parent e8acdd69
......@@ -121,6 +121,7 @@ PyGlobal::initModule(py::module& m)
GoogleOpenOptions_.def_readwrite("bucket" , &GoogleOpenOptions::bucket , OPENVDS_DOCSTRING(GoogleOpenOptions_bucket));
GoogleOpenOptions_.def_readwrite("pathPrefix" , &GoogleOpenOptions::pathPrefix , OPENVDS_DOCSTRING(GoogleOpenOptions_pathPrefix));
GoogleOpenOptions_.def_readwrite("credentials" , &GoogleOpenOptions::credentials, OPENVDS_DOCSTRING(GoogleOpenOptions_credentials));
GoogleOpenOptions_.def_readwrite("storageClass" , &GoogleOpenOptions::storageClass, OPENVDS_DOCSTRING(GoogleOpenOptions_storageClass));
py::enum_<GoogleOpenOptions::CredentialsType>
GoogleOpenOptions_CredentialsType_(GoogleOpenOptions_,"CredentialsType", OPENVDS_DOCSTRING(GoogleOpenOptions_CredentialsType));
......
......@@ -671,6 +671,8 @@ static const char *__doc_OpenVDS_GoogleOpenOptions_credentialsType = R"doc()doc"
static const char *__doc_OpenVDS_GoogleOpenOptions_pathPrefix = R"doc()doc";
static const char *__doc_OpenVDS_GoogleOpenOptions_storageClass = R"doc()doc";
static const char *__doc_OpenVDS_HttpOpenOptions =
R"doc(Options for opening a VDS with a plain http url. If there are query
parameters in then they will be appended to the different sub urls.
......
......@@ -47,6 +47,7 @@ namespace OpenVDS
, m_curlHandler(error)
, m_bucket(openOptions.bucket)
, m_pathPrefix(openOptions.pathPrefix)
, m_storageClass(openOptions.storageClass)
{
if (m_bucket.empty())
{
......@@ -199,6 +200,11 @@ namespace OpenVDS
headers.push_back(fmt::format("Content-Length: {}", uploadSize));
if (!m_storageClass.empty())
{
headers.push_back(fmt::format("x-goog-storage-class: {}", m_storageClass));
}
m_curlHandler.addUploadRequest(request, url, headers, true, std::move(upload_buffers), uploadSize);
return request;
}
......
......@@ -39,6 +39,7 @@ private:
std::string m_bucket;
std::string m_pathPrefix;
std::shared_ptr<google::cloud::storage::v1::oauth2::Credentials> m_credentials;
std::string m_storageClass;
Json::StreamWriterBuilder m_jsonWriterBuilder;
};
}
......
......@@ -248,6 +248,7 @@ struct GoogleOpenOptions : OpenOptions
std::string bucket;
std::string pathPrefix;
std::string credentials;
std::string storageClass;
GoogleOpenOptions() : OpenOptions(GoogleStorage) {}
/// <summary>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment