15 #ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_STORAGE_OBJECT_METADATA_H
16 #define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_STORAGE_OBJECT_METADATA_H
18 #include "google/cloud/storage/internal/common_metadata.h"
19 #include "google/cloud/storage/internal/complex_option.h"
20 #include "google/cloud/storage/object_access_control.h"
21 #include "google/cloud/storage/version.h"
22 #include "google/cloud/optional.h"
23 #include "google/cloud/status_or.h"
24 #include "absl/types/optional.h"
35 struct ObjectMetadataParser;
36 struct GrpcObjectMetadataParser;
37 struct GrpcObjectRequestParser;
71 return std::rel_ops::operator!=(lhs, rhs);
76 return std::rel_ops::operator>(lhs, rhs);
81 return std::rel_ops::operator<=(lhs, rhs);
86 return std::rel_ops::operator>=(lhs, rhs);
114 acl_ = std::move(acl);
119 std::string
const&
bucket()
const {
return bucket_; }
126 cache_control_ = std::move(cache_control);
138 content_disposition_ = std::move(value);
147 content_encoding_ = std::move(value);
156 content_language_ = std::move(value);
165 content_type_ = std::move(value);
170 std::string
const&
crc32c()
const {
return crc32c_; }
175 return customer_encryption_.has_value();
185 return customer_encryption_.value();
189 using CommonMetadata::etag;
196 event_based_hold_ = v;
210 using CommonMetadata::id;
213 using CommonMetadata::kind;
224 std::string
const&
md5_hash()
const {
return md5_hash_; }
227 std::string
const&
media_link()
const {
return media_link_; }
239 return metadata_.end() != metadata_.find(key);
248 std::string
const&
metadata(std::string
const& key)
const {
249 return metadata_.at(key);
254 auto i = metadata_.find(key);
255 if (i == metadata_.end()) {
264 auto i = metadata_.lower_bound(key);
265 if (i == metadata_.end() || i->first != key) {
266 metadata_.emplace_hint(i, std::move(key), std::move(value));
268 i->second = std::move(value);
274 std::map<std::string, std::string>
const&
metadata()
const {
283 using CommonMetadata::has_owner;
292 using CommonMetadata::metageneration;
295 using CommonMetadata::name;
303 using CommonMetadata::owner;
307 return retention_expiration_time_;
311 using CommonMetadata::self_link;
314 std::uint64_t
size()
const {
return size_; }
317 using CommonMetadata::storage_class;
321 CommonMetadata::set_storage_class(std::move(v));
335 using CommonMetadata::time_created;
339 return time_deleted_;
344 return time_storage_class_updated_;
348 using CommonMetadata::updated;
355 return custom_time_.value_or(std::chrono::system_clock::time_point{});
367 custom_time_.reset();
373 return !(lhs
== rhs);
377 friend struct internal::ObjectMetadataParser;
378 friend struct internal::GrpcObjectMetadataParser;
384 std::string cache_control_;
385 std::int32_t component_count_{0};
386 std::string content_disposition_;
387 std::string content_encoding_;
388 std::string content_language_;
389 std::string content_type_;
392 bool event_based_hold_{
false};
393 std::int64_t generation_{0};
394 std::string kms_key_name_;
395 std::string md5_hash_;
396 std::string media_link_;
397 std::map<std::string, std::string> metadata_;
398 std::chrono::system_clock::time_point retention_expiration_time_;
399 std::uint64_t size_{0};
400 bool temporary_hold_{
false};
401 std::chrono::system_clock::time_point time_deleted_;
402 std::chrono::system_clock::time_point time_storage_class_updated_;
403 absl::optional<std::chrono::system_clock::time_point> custom_time_;
449 std::string
const& value);
463 std::chrono::system_clock::time_point tp);
467 friend struct internal::GrpcObjectRequestParser;
469 internal::PatchBuilder impl_;
470 bool metadata_subpatch_dirty_{
false};
471 internal::PatchBuilder metadata_subpatch_;
483 static char const*
name() {
return "object-metadata"; }