Google Cloud Storage C++ Client 2.13.0
A C++ Client Library for Google Cloud Storage
Loading...
Searching...
No Matches
object_metadata.h
1// Copyright 2018 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// https://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_STORAGE_OBJECT_METADATA_H
16#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_STORAGE_OBJECT_METADATA_H
17
18#include "google/cloud/storage/internal/complex_option.h"
19#include "google/cloud/storage/object_access_control.h"
20#include "google/cloud/storage/owner.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"
25#include <chrono>
26#include <map>
27#include <string>
28#include <vector>
29
30namespace google {
31namespace cloud {
32namespace storage {
33GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
34
35/// A simple representation for the customerEncryption field.
36struct CustomerEncryption {
37 // The encryption algorithm name.
38 std::string encryption_algorithm;
39 // The SHA256 hash of the encryption key.
40 std::string key_sha256;
41};
42
43/// Defines one of the source objects for a compose operation.
45 std::string object_name;
46 absl::optional<std::int64_t> generation;
47 absl::optional<std::int64_t> if_generation_match;
48};
49
50std::ostream& operator<<(std::ostream& os, ComposeSourceObject const& r);
51
52inline bool operator==(CustomerEncryption const& lhs,
53 CustomerEncryption const& rhs) {
54 return std::tie(lhs.encryption_algorithm, lhs.key_sha256) ==
55 std::tie(rhs.encryption_algorithm, rhs.key_sha256);
56}
57
58inline bool operator<(CustomerEncryption const& lhs,
59 CustomerEncryption const& rhs) {
60 return std::tie(lhs.encryption_algorithm, lhs.key_sha256) <
61 std::tie(rhs.encryption_algorithm, rhs.key_sha256);
62}
63
64inline bool operator!=(CustomerEncryption const& lhs,
65 CustomerEncryption const& rhs) {
66 return std::rel_ops::operator!=(lhs, rhs);
67}
68
69inline bool operator>(CustomerEncryption const& lhs,
70 CustomerEncryption const& rhs) {
71 return std::rel_ops::operator>(lhs, rhs);
72}
73
74inline bool operator<=(CustomerEncryption const& lhs,
75 CustomerEncryption const& rhs) {
76 return std::rel_ops::operator<=(lhs, rhs);
77}
78
79inline bool operator>=(CustomerEncryption const& lhs,
80 CustomerEncryption const& rhs) {
81 return std::rel_ops::operator>=(lhs, rhs);
82}
83
84/**
85 * Represents the metadata for a Google Cloud Storage Object.
86 *
87 * Note that all modifiers just change the local representation of the Object's
88 * metadata. Applications should use `Client::PatchObject()`, or a similar
89 * operation, to actually modify the metadata stored by GCS.
90 *
91 * @see https://cloud.google.com/storage/docs/json_api/v1/objects for a more
92 * detailed description of each attribute and their effects.
93 */
94class ObjectMetadata {
95 public:
96 ObjectMetadata() = default;
97
98 // Please keep these in alphabetical order, that make it easier to verify we
99 // have actually implemented all of them.
100
101 /// The access control list for this object.
102 std::vector<ObjectAccessControl> const& acl() const { return acl_; }
103
104 /// The access control list for this object.
105 std::vector<ObjectAccessControl>& mutable_acl() { return acl_; }
106
107 /// Change the access control list.
108 ObjectMetadata& set_acl(std::vector<ObjectAccessControl> acl) {
109 acl_ = std::move(acl);
110 return *this;
111 }
112
113 /// The name of the bucket containing this object.
114 std::string const& bucket() const { return bucket_; }
115
116 /// @note This is only intended for mocking.
117 ObjectMetadata& set_bucket(std::string v) {
118 bucket_ = std::move(v);
119 return *this;
120 }
121
122 /// The `cacheControl` attribute.
123 std::string const& cache_control() const { return cache_control_; }
124
125 /// Set the `cacheControl` attribute.
126 ObjectMetadata& set_cache_control(std::string cache_control) {
127 cache_control_ = std::move(cache_control);
128 return *this;
129 }
130
131 /// The number of components, for objects built using `ComposeObject()`.
132 std::int32_t component_count() const { return component_count_; }
133
134 /// @note This is only intended for mocking.
135 ObjectMetadata& set_component_count(std::int32_t v) {
136 component_count_ = v;
137 return *this;
138 }
139
140 /// The `contentDisposition` attribute.
141 std::string content_disposition() const { return content_disposition_; }
142
143 /// Change the `contentDisposition` attribute.
144 ObjectMetadata& set_content_disposition(std::string value) {
145 content_disposition_ = std::move(value);
146 return *this;
147 }
148
149 /// The `contentEncoding` attribute.
150 std::string content_encoding() const { return content_encoding_; }
151
152 /// Change the `contentEncoding` attribute.
153 ObjectMetadata& set_content_encoding(std::string value) {
154 content_encoding_ = std::move(value);
155 return *this;
156 }
157
158 /// The `contentLanguage` attribute.
159 std::string content_language() const { return content_language_; }
160
161 /// Change the `contentLanguage` attribute.
162 ObjectMetadata& set_content_language(std::string value) {
163 content_language_ = std::move(value);
164 return *this;
165 }
166
167 /// The `contentType` attribute.
168 std::string content_type() const { return content_type_; }
169
170 /// Change the `contentLanguage` attribute.
171 ObjectMetadata& set_content_type(std::string value) {
172 content_type_ = std::move(value);
173 return *this;
174 }
175
176 /// The `CRC32C` checksum for the object contents.
177 std::string const& crc32c() const { return crc32c_; }
178
179 /// @note This is only intended for mocking.
180 ObjectMetadata& set_crc32c(std::string v) {
181 crc32c_ = std::move(v);
182 return *this;
183 }
184
185 /// Returns `true` if the object has a `customTime` attribute.
186 bool has_custom_time() const { return custom_time_.has_value(); }
187
188 /// Returns the object's `customTime` or the system clock's epoch.
189 std::chrono::system_clock::time_point custom_time() const {
190 return custom_time_.value_or(std::chrono::system_clock::time_point{});
191 }
192
193 /// Changes the `customTime` attribute.
194 ObjectMetadata& set_custom_time(std::chrono::system_clock::time_point v) {
195 custom_time_ = v;
196 return *this;
197 }
198
199 /// Reset (clears) the `customTime` attribute. `has_custom_time()` returns
200 /// `false` after calling this function.
202 custom_time_.reset();
203 return *this;
204 }
205
206 /// Returns `true` if the object uses CSEK (Customer-Supplied Encryption
207 /// Keys).
208 bool has_customer_encryption() const {
209 return customer_encryption_.has_value();
210 }
211
212 /**
213 * Returns the CSEK metadata (algorithm and key SHA256).
214 *
215 * It is undefined behavior to call this member function if
216 * `has_customer_encryption() == false`.
217 */
219 return customer_encryption_.value();
220 }
221
222 /// @note This is only intended for mocking.
224 customer_encryption_ = std::move(v);
225 return *this;
226 }
227
228 /// @note This is only intended for mocking.
230 customer_encryption_.reset();
231 return *this;
232 }
233
234 /// The `Etag` attribute.
235 std::string const& etag() const { return etag_; }
236
237 /// @note This is only intended for mocking.
238 ObjectMetadata& set_etag(std::string v) {
239 etag_ = std::move(v);
240 return *this;
241 }
242
243 /// The `eventBasedHold` attribute.
244 bool event_based_hold() const { return event_based_hold_; }
245
246 /// Changes the `eventBasedHold` attribute.
248 event_based_hold_ = v;
249 return *this;
250 }
251
252 /**
253 * The object generation.
254 *
255 * In buckets with object versioning enabled, each object may have multiple
256 * generations. Each generation data (the object contents) is immutable, but
257 * the metadata associated with each generation can be changed.
258 */
259 std::int64_t generation() const { return generation_; }
260
261 /// @note This is only intended for mocking.
262 ObjectMetadata& set_generation(std::int64_t v) {
263 generation_ = v;
264 return *this;
265 }
266
267 /// The `id` attribute (the object name)
268 std::string const& id() const { return id_; }
269
270 /// @note This is only intended for mocking.
271 ObjectMetadata& set_id(std::string v) {
272 id_ = std::move(v);
273 return *this;
274 }
275
276 /// The `kind` attribute, that is, `storage#object`.
277 std::string const& kind() const { return kind_; }
278
279 /// @note This is only intended for mocking.
280 ObjectMetadata& set_kind(std::string v) {
281 kind_ = std::move(v);
282 return *this;
283 }
284
285 /**
286 * The name of the KMS (Key Management Service) key used in this object.
287 *
288 * This is empty for objects not using CMEK (Customer Managed Encryption
289 * Keys).
290 */
291 std::string const& kms_key_name() const { return kms_key_name_; }
292
293 /// @note This is only intended for mocking.
294 ObjectMetadata& set_kms_key_name(std::string v) {
295 kms_key_name_ = std::move(v);
296 return *this;
297 }
298
299 /// The MD5 hash of the object contents. Can be empty.
300 std::string const& md5_hash() const { return md5_hash_; }
301
302 /// @note This is only intended for mocking.
303 ObjectMetadata& set_md5_hash(std::string v) {
304 md5_hash_ = std::move(v);
305 return *this;
306 }
307
308 /// The HTTPS link to access the object contents.
309 std::string const& media_link() const { return media_link_; }
310
311 /// @note This is only intended for mocking.
312 ObjectMetadata& set_media_link(std::string v) {
313 media_link_ = std::move(v);
314 return *this;
315 }
316
317 /**
318 * @name Accessors and modifiers for metadata entries.
319 *
320 * The object metadata contains a user-defined set of `key`, `value` pairs,
321 * which are also called "metadata". Applications can use these fields to
322 * add custom annotations to each object.
323 */
324 ///@{
325 /// Returns `true` if the key is present in the object metadata entries.
326 bool has_metadata(std::string const& key) const {
327 return metadata_.end() != metadata_.find(key);
328 }
329
330 /**
331 * Returns the value of @p key in the Object's metadata entries.
332 *
333 * It is undefined behavior to call `metadata(key)` if `has_metadata(key) ==
334 * false`.
335 */
336 std::string const& metadata(std::string const& key) const {
337 return metadata_.at(key);
338 }
339
340 /// Delete a metadata entry. This is a no-op if the key does not exist.
341 ObjectMetadata& delete_metadata(std::string const& key) {
342 auto i = metadata_.find(key);
343 if (i == metadata_.end()) {
344 return *this;
345 }
346 metadata_.erase(i);
347 return *this;
348 }
349
350 /// Insert or update the metadata entry.
351 ObjectMetadata& upsert_metadata(std::string key, std::string value) {
352 auto i = metadata_.lower_bound(key);
353 if (i == metadata_.end() || i->first != key) {
354 metadata_.emplace_hint(i, std::move(key), std::move(value));
355 } else {
356 i->second = std::move(value);
357 }
358 return *this;
359 }
360
361 /// Returns all the Object's metadata entries.
362 std::map<std::string, std::string> const& metadata() const {
363 return metadata_;
364 }
365
366 /// Returns all the Object's metadata entries.
367 std::map<std::string, std::string>& mutable_metadata() { return metadata_; }
368 ///@}
369
370 /**
371 * The generation of the object metadata.
372 *
373 * @note Changes to the object metadata (e.g. changing the `cacheControl`
374 * attribute) increases the metageneration, but does not change the object
375 * generation.
376 */
377 std::int64_t metageneration() const { return metageneration_; }
378
379 /// @note This is only intended for mocking.
380 ObjectMetadata& set_metageneration(std::int64_t v) {
381 metageneration_ = v;
382 return *this;
383 }
384
385 /// The object name, including bucket and generation.
386 std::string const& name() const { return name_; }
387
388 /// @note This is only intended for mocking.
389 ObjectMetadata& set_name(std::string v) {
390 name_ = std::move(v);
391 return *this;
392 }
393
394 /// Returns `true` if the object has an `owner` attribute.
395 bool has_owner() const { return owner_.has_value(); }
396
397 /**
398 * The object's `owner` attribute.
399 *
400 * It is undefined behavior to call this member function if
401 * `has_owner() == false`.
402 */
403 Owner const& owner() const { return *owner_; }
404
405 /// @note This is only intended for mocking.
407 owner_ = std::move(v);
408 return *this;
409 }
410
411 /// @note This is only intended for mocking.
413 owner_.reset();
414 return *this;
415 }
416
417 /// The retention expiration time, or the system clock's epoch, if not set.
418 std::chrono::system_clock::time_point retention_expiration_time() const {
419 return retention_expiration_time_;
420 }
421
422 /// @note This is only intended for mocking.
424 std::chrono::system_clock::time_point v) {
425 retention_expiration_time_ = v;
426 return *this;
427 }
428
429 /// An HTTPS link to the object metadata.
430 std::string const& self_link() const { return self_link_; }
431
432 /// @note This is only intended for mocking.
433 ObjectMetadata& set_self_link(std::string v) {
434 self_link_ = std::move(v);
435 return *this;
436 }
437
438 /// The size of the object's data.
439 std::uint64_t size() const { return size_; }
440
441 /// @note This is only intended for mocking.
442 ObjectMetadata& set_size(std::uint64_t v) {
443 size_ = v;
444 return *this;
445 }
446
447 /// The `storageClass` attribute.
448 std::string const& storage_class() const { return storage_class_; }
449
450 /// Changes the `storageClass` attribute.
451 ObjectMetadata& set_storage_class(std::string v) {
452 storage_class_ = std::move(v);
453 return *this;
454 }
455
456 /// The `temporaryHold` attribute.
457 bool temporary_hold() const { return temporary_hold_; }
458
459 /// Changes the `temporaryHold` attribute.
461 temporary_hold_ = v;
462 return *this;
463 }
464
465 /// The object creation timestamp.
466 std::chrono::system_clock::time_point time_created() const {
467 return time_created_;
468 }
469
470 /// @note This is only intended for mocking.
471 ObjectMetadata& set_time_created(std::chrono::system_clock::time_point v) {
472 time_created_ = v;
473 return *this;
474 }
475
476 /// The object's deletion timestamp.
477 std::chrono::system_clock::time_point time_deleted() const {
478 return time_deleted_;
479 }
480
481 /// @note This is only intended for mocking.
482 ObjectMetadata& set_time_deleted(std::chrono::system_clock::time_point v) {
483 time_deleted_ = v;
484 return *this;
485 }
486
487 /// The timestamp for the last storage class change.
488 std::chrono::system_clock::time_point time_storage_class_updated() const {
489 return time_storage_class_updated_;
490 }
491
492 /// @note This is only intended for mocking.
494 std::chrono::system_clock::time_point v) {
495 time_storage_class_updated_ = v;
496 return *this;
497 }
498
499 /// The timestamp for the last object *metadata* update.
500 std::chrono::system_clock::time_point updated() const { return updated_; }
501
502 /// @note This is only intended for mocking.
503 ObjectMetadata& set_updated(std::chrono::system_clock::time_point v) {
504 updated_ = v;
505 return *this;
506 }
507
508 friend bool operator==(ObjectMetadata const& lhs, ObjectMetadata const& rhs);
509 friend bool operator!=(ObjectMetadata const& lhs, ObjectMetadata const& rhs) {
510 return !(lhs == rhs);
511 }
512
513 private:
514 friend std::ostream& operator<<(std::ostream& os, ObjectMetadata const& rhs);
515 // Keep the fields in alphabetical order.
516 std::vector<ObjectAccessControl> acl_;
517 std::string bucket_;
518 std::string cache_control_;
519 std::int32_t component_count_{0};
520 std::string content_disposition_;
521 std::string content_encoding_;
522 std::string content_language_;
523 std::string content_type_;
524 std::string crc32c_;
525 absl::optional<std::chrono::system_clock::time_point> custom_time_;
526 absl::optional<CustomerEncryption> customer_encryption_;
527 std::string etag_;
528 bool event_based_hold_{false};
529 std::int64_t generation_{0};
530 std::string id_;
531 std::string kind_;
532 std::string kms_key_name_;
533 std::int64_t metageneration_{0};
534 std::string md5_hash_;
535 std::string media_link_;
536 std::map<std::string, std::string> metadata_;
537 std::string name_;
538 absl::optional<Owner> owner_;
539 std::chrono::system_clock::time_point retention_expiration_time_;
540 std::string self_link_;
541 std::uint64_t size_{0};
542 std::string storage_class_;
543 bool temporary_hold_{false};
544 std::chrono::system_clock::time_point time_created_;
545 std::chrono::system_clock::time_point time_deleted_;
546 std::chrono::system_clock::time_point time_storage_class_updated_;
547 std::chrono::system_clock::time_point updated_;
548};
549
550std::ostream& operator<<(std::ostream& os, ObjectMetadata const& rhs);
551
552/**
553 * Prepares a patch for the Bucket resource.
554 *
555 * The Bucket resource has many modifiable fields. The application may send a
556 * patch request to change (or delete) a small fraction of these fields by using
557 * this object.
558 *
559 * @see
560 * https://cloud.google.com/storage/docs/json_api/v1/how-tos/performance#patch
561 * for general information on PATCH requests for the Google Cloud Storage
562 * JSON API.
563 */
565 public:
566 ObjectMetadataPatchBuilder() = default;
567
568 std::string BuildPatch() const;
569
571
572 /**
573 * Clears the ACL.
574 *
575 * @warning Currently the server ignores requests to reset the full ACL.
576 */
578
579 ObjectMetadataPatchBuilder& SetCacheControl(std::string const& v);
583 ObjectMetadataPatchBuilder& SetContentEncoding(std::string const& v);
585 ObjectMetadataPatchBuilder& SetContentLanguage(std::string const& v);
587 ObjectMetadataPatchBuilder& SetContentType(std::string const& v);
591
592 ObjectMetadataPatchBuilder& SetMetadata(std::string const& key,
593 std::string const& value);
594 ObjectMetadataPatchBuilder& ResetMetadata(std::string const& key);
596
599
600 /**
601 * Change the `custom_time` field.
602 *
603 * @par Example
604 * @snippet storage_object_samples.cc object custom time
605 */
607 std::chrono::system_clock::time_point tp);
609
610 private:
611 friend struct internal::PatchBuilderDetails;
612
613 internal::PatchBuilder impl_;
614 bool metadata_subpatch_dirty_{false};
615 internal::PatchBuilder metadata_subpatch_;
616};
617
618/**
619 * A request option to define the object metadata attributes.
620 */
622 : public internal::ComplexOption<WithObjectMetadata, ObjectMetadata> {
623 using ComplexOption<WithObjectMetadata, ObjectMetadata>::ComplexOption;
624 // GCC <= 7.0 does not use the inherited default constructor, redeclare it
625 // explicitly
626 WithObjectMetadata() = default;
627 static char const* name() { return "object-metadata"; }
628};
629
630GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
631} // namespace storage
632} // namespace cloud
633} // namespace google
634
635#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_STORAGE_OBJECT_METADATA_H
Wraps the objectAccessControl resource in Google Cloud Storage.
Definition: object_access_control.h:39
Prepares a patch for the Bucket resource.
Definition: object_metadata.h:564
ObjectMetadataPatchBuilder & ResetMetadata()
ObjectMetadataPatchBuilder & SetContentLanguage(std::string const &v)
ObjectMetadataPatchBuilder & SetMetadata(std::string const &key, std::string const &value)
ObjectMetadataPatchBuilder & ResetEventBasedHold()
ObjectMetadataPatchBuilder & SetContentType(std::string const &v)
ObjectMetadataPatchBuilder & ResetContentLanguage()
ObjectMetadataPatchBuilder & ResetMetadata(std::string const &key)
ObjectMetadataPatchBuilder & SetCacheControl(std::string const &v)
ObjectMetadataPatchBuilder & ResetContentDisposition()
ObjectMetadataPatchBuilder & ResetCustomTime()
ObjectMetadataPatchBuilder & ResetTemporaryHold()
ObjectMetadataPatchBuilder & SetContentDisposition(std::string const &v)
ObjectMetadataPatchBuilder & SetAcl(std::vector< ObjectAccessControl > const &v)
ObjectMetadataPatchBuilder & ResetContentEncoding()
ObjectMetadataPatchBuilder & SetContentEncoding(std::string const &v)
ObjectMetadataPatchBuilder & SetTemporaryHold(bool v)
ObjectMetadataPatchBuilder & SetEventBasedHold(bool v)
ObjectMetadataPatchBuilder & ResetAcl()
Clears the ACL.
ObjectMetadataPatchBuilder & SetCustomTime(std::chrono::system_clock::time_point tp)
Change the custom_time field.
ObjectMetadataPatchBuilder & ResetContentType()
ObjectMetadataPatchBuilder & ResetCacheControl()
Represents the metadata for a Google Cloud Storage Object.
Definition: object_metadata.h:94
friend bool operator!=(ObjectMetadata const &lhs, ObjectMetadata const &rhs)
Definition: object_metadata.h:509
ObjectMetadata & set_time_created(std::chrono::system_clock::time_point v)
Definition: object_metadata.h:471
std::string content_encoding() const
The contentEncoding attribute.
Definition: object_metadata.h:150
friend bool operator==(ObjectMetadata const &lhs, ObjectMetadata const &rhs)
ObjectMetadata & set_component_count(std::int32_t v)
Definition: object_metadata.h:135
ObjectMetadata & set_cache_control(std::string cache_control)
Set the cacheControl attribute.
Definition: object_metadata.h:126
std::string const & etag() const
The Etag attribute.
Definition: object_metadata.h:235
std::string content_type() const
The contentType attribute.
Definition: object_metadata.h:168
std::string const & kms_key_name() const
The name of the KMS (Key Management Service) key used in this object.
Definition: object_metadata.h:291
ObjectMetadata & set_customer_encryption(CustomerEncryption v)
Definition: object_metadata.h:223
ObjectMetadata & set_content_encoding(std::string value)
Change the contentEncoding attribute.
Definition: object_metadata.h:153
std::vector< ObjectAccessControl > & mutable_acl()
The access control list for this object.
Definition: object_metadata.h:105
ObjectMetadata & set_time_deleted(std::chrono::system_clock::time_point v)
Definition: object_metadata.h:482
bool has_metadata(std::string const &key) const
Definition: object_metadata.h:326
std::vector< ObjectAccessControl > const & acl() const
The access control list for this object.
Definition: object_metadata.h:102
std::string content_language() const
The contentLanguage attribute.
Definition: object_metadata.h:159
std::string const & storage_class() const
The storageClass attribute.
Definition: object_metadata.h:448
ObjectMetadata & set_storage_class(std::string v)
Changes the storageClass attribute.
Definition: object_metadata.h:451
ObjectMetadata & set_retention_expiration_time(std::chrono::system_clock::time_point v)
Definition: object_metadata.h:423
ObjectMetadata & set_acl(std::vector< ObjectAccessControl > acl)
Change the access control list.
Definition: object_metadata.h:108
ObjectMetadata & set_self_link(std::string v)
Definition: object_metadata.h:433
bool event_based_hold() const
The eventBasedHold attribute.
Definition: object_metadata.h:244
bool has_custom_time() const
Returns true if the object has a customTime attribute.
Definition: object_metadata.h:186
ObjectMetadata & upsert_metadata(std::string key, std::string value)
Insert or update the metadata entry.
Definition: object_metadata.h:351
ObjectMetadata & set_size(std::uint64_t v)
Definition: object_metadata.h:442
ObjectMetadata & reset_owner()
Definition: object_metadata.h:412
CustomerEncryption const & customer_encryption() const
Returns the CSEK metadata (algorithm and key SHA256).
Definition: object_metadata.h:218
std::chrono::system_clock::time_point custom_time() const
Returns the object's customTime or the system clock's epoch.
Definition: object_metadata.h:189
ObjectMetadata & set_event_based_hold(bool v)
Changes the eventBasedHold attribute.
Definition: object_metadata.h:247
ObjectMetadata & set_temporary_hold(bool v)
Changes the temporaryHold attribute.
Definition: object_metadata.h:460
bool temporary_hold() const
The temporaryHold attribute.
Definition: object_metadata.h:457
std::uint64_t size() const
The size of the object's data.
Definition: object_metadata.h:439
ObjectMetadata & set_owner(Owner v)
Definition: object_metadata.h:406
ObjectMetadata & set_updated(std::chrono::system_clock::time_point v)
Definition: object_metadata.h:503
ObjectMetadata & set_md5_hash(std::string v)
Definition: object_metadata.h:303
ObjectMetadata & set_metageneration(std::int64_t v)
Definition: object_metadata.h:380
Owner const & owner() const
The object's owner attribute.
Definition: object_metadata.h:403
ObjectMetadata & set_time_storage_class_updated(std::chrono::system_clock::time_point v)
Definition: object_metadata.h:493
std::string const & name() const
The object name, including bucket and generation.
Definition: object_metadata.h:386
std::chrono::system_clock::time_point time_storage_class_updated() const
The timestamp for the last storage class change.
Definition: object_metadata.h:488
ObjectMetadata & set_name(std::string v)
Definition: object_metadata.h:389
std::string const & id() const
The id attribute (the object name)
Definition: object_metadata.h:268
ObjectMetadata & set_content_language(std::string value)
Change the contentLanguage attribute.
Definition: object_metadata.h:162
std::string const & crc32c() const
The CRC32C checksum for the object contents.
Definition: object_metadata.h:177
ObjectMetadata & reset_customer_encryption()
Definition: object_metadata.h:229
ObjectMetadata & set_crc32c(std::string v)
Definition: object_metadata.h:180
std::chrono::system_clock::time_point time_created() const
The object creation timestamp.
Definition: object_metadata.h:466
std::string content_disposition() const
The contentDisposition attribute.
Definition: object_metadata.h:141
bool has_customer_encryption() const
Returns true if the object uses CSEK (Customer-Supplied Encryption Keys).
Definition: object_metadata.h:208
std::int64_t metageneration() const
The generation of the object metadata.
Definition: object_metadata.h:377
std::string const & md5_hash() const
The MD5 hash of the object contents. Can be empty.
Definition: object_metadata.h:300
std::map< std::string, std::string > const & metadata() const
Returns all the Object's metadata entries.
Definition: object_metadata.h:362
ObjectMetadata & set_media_link(std::string v)
Definition: object_metadata.h:312
ObjectMetadata & set_etag(std::string v)
Definition: object_metadata.h:238
ObjectMetadata & set_kms_key_name(std::string v)
Definition: object_metadata.h:294
ObjectMetadata & set_custom_time(std::chrono::system_clock::time_point v)
Changes the customTime attribute.
Definition: object_metadata.h:194
std::chrono::system_clock::time_point updated() const
The timestamp for the last object metadata update.
Definition: object_metadata.h:500
ObjectMetadata & set_kind(std::string v)
Definition: object_metadata.h:280
std::string const & kind() const
The kind attribute, that is, storage#object.
Definition: object_metadata.h:277
bool has_owner() const
Returns true if the object has an owner attribute.
Definition: object_metadata.h:395
std::string const & metadata(std::string const &key) const
Returns the value of key in the Object's metadata entries.
Definition: object_metadata.h:336
std::int32_t component_count() const
The number of components, for objects built using ComposeObject().
Definition: object_metadata.h:132
ObjectMetadata & set_content_disposition(std::string value)
Change the contentDisposition attribute.
Definition: object_metadata.h:144
std::string const & bucket() const
The name of the bucket containing this object.
Definition: object_metadata.h:114
ObjectMetadata & delete_metadata(std::string const &key)
Delete a metadata entry. This is a no-op if the key does not exist.
Definition: object_metadata.h:341
ObjectMetadata & set_generation(std::int64_t v)
Definition: object_metadata.h:262
std::string const & self_link() const
An HTTPS link to the object metadata.
Definition: object_metadata.h:430
std::string const & media_link() const
The HTTPS link to access the object contents.
Definition: object_metadata.h:309
ObjectMetadata & set_content_type(std::string value)
Change the contentLanguage attribute.
Definition: object_metadata.h:171
std::map< std::string, std::string > & mutable_metadata()
Returns all the Object's metadata entries.
Definition: object_metadata.h:367
ObjectMetadata & set_bucket(std::string v)
Definition: object_metadata.h:117
ObjectMetadata & set_id(std::string v)
Definition: object_metadata.h:271
ObjectMetadata & reset_custom_time()
Reset (clears) the customTime attribute.
Definition: object_metadata.h:201
std::int64_t generation() const
The object generation.
Definition: object_metadata.h:259
std::chrono::system_clock::time_point retention_expiration_time() const
The retention expiration time, or the system clock's epoch, if not set.
Definition: object_metadata.h:418
std::chrono::system_clock::time_point time_deleted() const
The object's deletion timestamp.
Definition: object_metadata.h:477
std::string const & cache_control() const
The cacheControl attribute.
Definition: object_metadata.h:123
Contains all the Google Cloud Storage C++ client APIs.
Definition: auto_finalize.h:24
bool operator!=(CustomerEncryption const &lhs, CustomerEncryption const &rhs)
Definition: object_metadata.h:64
bool operator<=(CustomerEncryption const &lhs, CustomerEncryption const &rhs)
Definition: object_metadata.h:74
bool operator>(CustomerEncryption const &lhs, CustomerEncryption const &rhs)
Definition: object_metadata.h:69
bool operator<(CustomerEncryption const &lhs, CustomerEncryption const &rhs)
Definition: object_metadata.h:58
bool operator==(CustomerEncryption const &lhs, CustomerEncryption const &rhs)
Definition: object_metadata.h:52
bool operator>=(CustomerEncryption const &lhs, CustomerEncryption const &rhs)
Definition: object_metadata.h:79
Defines one of the source objects for a compose operation.
Definition: object_metadata.h:44
absl::optional< std::int64_t > if_generation_match
Definition: object_metadata.h:47
std::string object_name
Definition: object_metadata.h:45
absl::optional< std::int64_t > generation
Definition: object_metadata.h:46
A simple representation for the customerEncryption field.
Definition: object_metadata.h:36
std::string encryption_algorithm
Definition: object_metadata.h:38
std::string key_sha256
Definition: object_metadata.h:40
A simple wrapper for the owner field in object and bucket metadata.
Definition: owner.h:29
A request option to define the object metadata attributes.
Definition: object_metadata.h:622
static char const * name()
Definition: object_metadata.h:627