coryan commented on a change in pull request #11550:
URL: https://github.com/apache/arrow/pull/11550#discussion_r743275566
##########
File path: cpp/src/arrow/filesystem/gcsfs_internal.cc
##########
@@ -62,6 +65,133 @@ Status ToArrowStatus(const google::cloud::Status& s) {
return Status::OK();
}
+namespace gcs = ::google::cloud::storage;
+
+Result<google::cloud::storage::EncryptionKey> ToEncryptionKey(
+ const std::shared_ptr<const KeyValueMetadata>& metadata) {
+ if (!metadata) {
+ return gcs::EncryptionKey{};
+ }
+
+ const auto& keys = metadata->keys();
+ const auto& values = metadata->values();
+
+ for (std::size_t i = 0; i < keys.size(); ++i) {
+ if (keys[i] == "encryptionKeyBase64") {
+ return gcs::EncryptionKey::FromBase64Key(values[i]);
+ }
+ }
+ return gcs::EncryptionKey{};
+}
+
+Result<gcs::KmsKeyName> ToKmsKeyName(
+ const std::shared_ptr<const KeyValueMetadata>& metadata) {
+ if (!metadata) {
+ return gcs::KmsKeyName{};
+ }
+
+ const auto& keys = metadata->keys();
+ const auto& values = metadata->values();
+
+ for (std::size_t i = 0; i < keys.size(); ++i) {
+ if (keys[i] == "kmsKeyName") {
+ return gcs::KmsKeyName(values[i]);
+ }
+ }
+ return gcs::KmsKeyName{};
+}
+
+Result<gcs::PredefinedAcl> ToPredefinedAcl(
+ const std::shared_ptr<const KeyValueMetadata>& metadata) {
+ if (!metadata) {
+ return gcs::PredefinedAcl{};
+ }
+
+ const auto& keys = metadata->keys();
+ const auto& values = metadata->values();
+
+ for (std::size_t i = 0; i < keys.size(); ++i) {
+ if (keys[i] == "predefinedAcl") {
+ return gcs::PredefinedAcl(values[i]);
+ }
+ }
+ return gcs::PredefinedAcl{};
+}
+
+Result<gcs::WithObjectMetadata> ToObjectMetadata(
+ const std::shared_ptr<const KeyValueMetadata>& metadata) {
+ if (!metadata) {
+ return gcs::WithObjectMetadata{};
+ }
+
+ static auto const setters = [] {
+ using setter = std::function<Status(gcs::ObjectMetadata&, const
std::string&)>;
+ return std::map<std::string, setter>{
+ {"cacheControl",
Review comment:
SGTM.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]