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"
24 #include "absl/types/optional.h"
32 struct ObjectMetadataParser;
94 std::vector<ObjectAccessControl>
const&
acl()
const {
return acl_; }
95 std::vector<ObjectAccessControl>&
mutable_acl() {
return acl_; }
97 acl_ = std::move(acl);
101 std::string
const&
bucket()
const {
return bucket_; }
105 cache_control_ = std::move(cache_control);
113 content_disposition_ = std::move(value);
119 content_encoding_ = std::move(value);
125 content_language_ = std::move(value);
131 content_type_ = std::move(value);
135 std::string
const&
crc32c()
const {
return crc32c_; }
138 return customer_encryption_.has_value();
141 return customer_encryption_.value();
144 using CommonMetadata::etag;
148 event_based_hold_ = v;
154 using CommonMetadata::id;
155 using CommonMetadata::kind;
158 std::string
const&
md5_hash()
const {
return md5_hash_; }
159 std::string
const&
media_link()
const {
return media_link_; }
162 bool has_metadata(std::string
const& key)
const {
164 return metadata_.end() != metadata_.find(key);
166 std::string
const&
metadata(std::string
const& key)
const {
167 return metadata_.at(key);
172 auto i = metadata_.find(key);
173 if (i == metadata_.end()) {
182 auto i = metadata_.lower_bound(key);
183 if (i == metadata_.end() || i->first != key) {
184 metadata_.emplace_hint(i, std::move(key), std::move(value));
186 i->second = std::move(value);
191 std::map<std::string, std::string>
const&
metadata()
const {
197 using CommonMetadata::has_owner;
198 using CommonMetadata::metageneration;
199 using CommonMetadata::name;
200 using CommonMetadata::owner;
203 return retention_expiration_time_;
206 using CommonMetadata::self_link;
208 std::uint64_t
size()
const {
return size_; }
210 using CommonMetadata::storage_class;
212 CommonMetadata::set_storage_class(std::move(v));
222 using CommonMetadata::time_created;
225 return time_deleted_;
228 return time_storage_class_updated_;
231 using CommonMetadata::updated;
235 return custom_time_.value_or(std::chrono::system_clock::time_point{});
242 custom_time_.reset();
248 return !(lhs == rhs);
252 friend struct internal::ObjectMetadataParser;
253 friend class internal::GrpcClient;
257 std::vector<ObjectAccessControl> acl_;
259 std::string cache_control_;
260 std::int32_t component_count_{0};
261 std::string content_disposition_;
262 std::string content_encoding_;
263 std::string content_language_;
264 std::string content_type_;
266 absl::optional<CustomerEncryption> customer_encryption_;
267 bool event_based_hold_{
false};
268 std::int64_t generation_{0};
269 std::string kms_key_name_;
270 std::string md5_hash_;
271 std::string media_link_;
272 std::map<std::string, std::string> metadata_;
273 std::chrono::system_clock::time_point retention_expiration_time_;
274 std::uint64_t size_{0};
275 bool temporary_hold_{
false};
276 std::chrono::system_clock::time_point time_deleted_;
277 std::chrono::system_clock::time_point time_storage_class_updated_;
278 absl::optional<std::chrono::system_clock::time_point> custom_time_;
281 std::ostream&
operator<<(std::ostream& os, ObjectMetadata
const& rhs);
299 std::string BuildPatch()
const;
324 std::string
const& value);
338 std::chrono::system_clock::time_point tp);
342 internal::PatchBuilder impl_;
343 bool metadata_subpatch_dirty_{
false};
344 internal::PatchBuilder metadata_subpatch_;
351 :
public internal::ComplexOption<WithObjectMetadata, ObjectMetadata> {
352 using ComplexOption<WithObjectMetadata, ObjectMetadata>::ComplexOption;
356 static char const*
name() {
return "object-metadata"; }
364 #endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_STORAGE_OBJECT_METADATA_H