Google Cloud Storage C++ Client  1.40.2
A C++ Client Library for Google Cloud Storage
Public Member Functions | Friends | List of all members
google::cloud::storage::ObjectMetadata Class Reference

Represents the metadata for a Google Cloud Storage Object. More...

#include <google/cloud/storage/object_metadata.h>

Public Member Functions

 ObjectMetadata ()=default
 
std::vector< ObjectAccessControl > const & acl () const
 The access control list for this object. More...
 
std::vector< ObjectAccessControl > & mutable_acl ()
 The access control list for this object. More...
 
ObjectMetadataset_acl (std::vector< ObjectAccessControl > acl)
 Change the access control list. More...
 
std::string const & bucket () const
 The name of the bucket containing this object. More...
 
std::string const & cache_control () const
 The cacheControl attribute. More...
 
ObjectMetadataset_cache_control (std::string cache_control)
 Set the cacheControl attribute. More...
 
std::int32_t component_count () const
 The number of components, for objects built using ComposeObject(). More...
 
std::string content_disposition () const
 The contentDisposition attribute. More...
 
ObjectMetadataset_content_disposition (std::string value)
 Change the contentDisposition attribute. More...
 
std::string content_encoding () const
 The contentEncoding attribute. More...
 
ObjectMetadataset_content_encoding (std::string value)
 Change the contentEncoding attribute. More...
 
std::string content_language () const
 The contentLanguage attribute. More...
 
ObjectMetadataset_content_language (std::string value)
 Change the contentLanguage attribute. More...
 
std::string content_type () const
 The contentType attribute. More...
 
ObjectMetadataset_content_type (std::string value)
 Change the contentLanguage attribute. More...
 
std::string const & crc32c () const
 The CRC32C checksum for the object contents. More...
 
bool has_customer_encryption () const
 Returns true if the object uses CSEK (Customer-Supplied Encryption Keys). More...
 
CustomerEncryption const & customer_encryption () const
 Returns the CSEK metadata (algorithm and key SHA256). More...
 
bool event_based_hold () const
 The eventBasedHold attribute. More...
 
ObjectMetadataset_event_based_hold (bool v)
 Changes the eventBasedHold attribute. More...
 
std::int64_t generation () const
 The object generation. More...
 
std::string const & kms_key_name () const
 The name of the KMS (Key Management Service) key used in this object. More...
 
std::string const & md5_hash () const
 The MD5 hash of the object contents. Can be empty. More...
 
std::string const & media_link () const
 The HTTPS link to access the object contents. More...
 
std::chrono::system_clock::time_point retention_expiration_time () const
 The retention expiration time, or the system clock's epoch, if not set. More...
 
std::uint64_t size () const
 The size of the object's data. More...
 
ObjectMetadataset_storage_class (std::string v)
 Changes the storageClass attribute. More...
 
bool temporary_hold () const
 The temporaryHold attribute. More...
 
ObjectMetadataset_temporary_hold (bool v)
 Changes the temporaryHold attribute. More...
 
std::chrono::system_clock::time_point time_deleted () const
 The object's deletion timestamp. More...
 
std::chrono::system_clock::time_point time_storage_class_updated () const
 The timestamp for the last storage class change. More...
 
bool has_custom_time () const
 Returns true if the object has a customTime attribute. More...
 
std::chrono::system_clock::time_point custom_time () const
 Returns the object's customTime or the system clock's epoch. More...
 
ObjectMetadataset_custom_time (std::chrono::system_clock::time_point v)
 Changes the customTime attribute. More...
 
ObjectMetadatareset_custom_time ()
 Reset (clears) the customTime attribute. More...
 
Accessors and modifiers for metadata entries.

The object metadata contains a user-defined set of key, value pairs, which are also called "metadata".

Applications can use these fields to add custom annotations to each object.

bool has_metadata (std::string const &key) const
 
std::string const & metadata (std::string const &key) const
 Returns the value of key in the Object's metadata entries. More...
 
ObjectMetadatadelete_metadata (std::string const &key)
 Delete a metadata entry. This is a no-op if the key does not exist. More...
 
ObjectMetadataupsert_metadata (std::string key, std::string value)
 Insert or update the metadata entry. More...
 
std::map< std::string, std::string > const & metadata () const
 Returns all the Object's metadata entries. More...
 
std::map< std::string, std::string > & mutable_metadata ()
 Returns all the Object's metadata entries. More...
 

Friends

bool operator== (ObjectMetadata const &lhs, ObjectMetadata const &rhs)
 
bool operator!= (ObjectMetadata const &lhs, ObjectMetadata const &rhs)
 
std::ostream & operator<< (std::ostream &os, ObjectMetadata const &rhs)
 

Detailed Description

Represents the metadata for a Google Cloud Storage Object.

Note that all modifiers just change the local representation of the Object's metadata. Applications should use Client::PatchObject(), or a similar operation, to actually modify the metadata stored by GCS.

See also
https://cloud.google.com/storage/docs/json_api/v1/objects for a more detailed description of each attribute and their effects.

Definition at line 99 of file object_metadata.h.

Constructor & Destructor Documentation

◆ ObjectMetadata()

google::cloud::storage::ObjectMetadata::ObjectMetadata ( )
default

Member Function Documentation

◆ acl()

std::vector<ObjectAccessControl> const& google::cloud::storage::ObjectMetadata::acl ( ) const
inline

The access control list for this object.

Definition at line 107 of file object_metadata.h.

◆ bucket()

std::string const& google::cloud::storage::ObjectMetadata::bucket ( ) const
inline

The name of the bucket containing this object.

Definition at line 119 of file object_metadata.h.

◆ cache_control()

std::string const& google::cloud::storage::ObjectMetadata::cache_control ( ) const
inline

The cacheControl attribute.

Definition at line 122 of file object_metadata.h.

◆ component_count()

std::int32_t google::cloud::storage::ObjectMetadata::component_count ( ) const
inline

The number of components, for objects built using ComposeObject().

Definition at line 131 of file object_metadata.h.

◆ content_disposition()

std::string google::cloud::storage::ObjectMetadata::content_disposition ( ) const
inline

The contentDisposition attribute.

Definition at line 134 of file object_metadata.h.

◆ content_encoding()

std::string google::cloud::storage::ObjectMetadata::content_encoding ( ) const
inline

The contentEncoding attribute.

Definition at line 143 of file object_metadata.h.

◆ content_language()

std::string google::cloud::storage::ObjectMetadata::content_language ( ) const
inline

The contentLanguage attribute.

Definition at line 152 of file object_metadata.h.

◆ content_type()

std::string google::cloud::storage::ObjectMetadata::content_type ( ) const
inline

The contentType attribute.

Definition at line 161 of file object_metadata.h.

◆ crc32c()

std::string const& google::cloud::storage::ObjectMetadata::crc32c ( ) const
inline

The CRC32C checksum for the object contents.

Definition at line 170 of file object_metadata.h.

◆ custom_time()

std::chrono::system_clock::time_point google::cloud::storage::ObjectMetadata::custom_time ( ) const
inline

Returns the object's customTime or the system clock's epoch.

Definition at line 354 of file object_metadata.h.

◆ customer_encryption()

CustomerEncryption const& google::cloud::storage::ObjectMetadata::customer_encryption ( ) const
inline

Returns the CSEK metadata (algorithm and key SHA256).

It is undefined behavior to call this member function if has_customer_encryption() == false.

Definition at line 184 of file object_metadata.h.

◆ delete_metadata()

ObjectMetadata& google::cloud::storage::ObjectMetadata::delete_metadata ( std::string const &  key)
inline

Delete a metadata entry. This is a no-op if the key does not exist.

Definition at line 253 of file object_metadata.h.

◆ event_based_hold()

bool google::cloud::storage::ObjectMetadata::event_based_hold ( ) const
inline

The eventBasedHold attribute.

Definition at line 192 of file object_metadata.h.

◆ generation()

std::int64_t google::cloud::storage::ObjectMetadata::generation ( ) const
inline

The object generation.

In buckets with object versioning enabled, each object may have multiple generations. Each generation data (the object contents) is immutable, but the metadata associated with each generation can be changed.

Definition at line 207 of file object_metadata.h.

◆ has_custom_time()

bool google::cloud::storage::ObjectMetadata::has_custom_time ( ) const
inline

Returns true if the object has a customTime attribute.

Definition at line 351 of file object_metadata.h.

◆ has_customer_encryption()

bool google::cloud::storage::ObjectMetadata::has_customer_encryption ( ) const
inline

Returns true if the object uses CSEK (Customer-Supplied Encryption Keys).

Definition at line 174 of file object_metadata.h.

◆ has_metadata()

bool google::cloud::storage::ObjectMetadata::has_metadata ( std::string const &  key) const
inline

Returns true if the key is present in the object metadata entries.

Definition at line 238 of file object_metadata.h.

◆ kms_key_name()

std::string const& google::cloud::storage::ObjectMetadata::kms_key_name ( ) const
inline

The name of the KMS (Key Management Service) key used in this object.

This is empty for objects not using CMEK (Customer Managed Encryption Keys).

Definition at line 221 of file object_metadata.h.

◆ md5_hash()

std::string const& google::cloud::storage::ObjectMetadata::md5_hash ( ) const
inline

The MD5 hash of the object contents. Can be empty.

Definition at line 224 of file object_metadata.h.

◆ media_link()

std::string const& google::cloud::storage::ObjectMetadata::media_link ( ) const
inline

The HTTPS link to access the object contents.

Definition at line 227 of file object_metadata.h.

◆ metadata() [1/2]

std::map<std::string, std::string> const& google::cloud::storage::ObjectMetadata::metadata ( ) const
inline

Returns all the Object's metadata entries.

Definition at line 274 of file object_metadata.h.

◆ metadata() [2/2]

std::string const& google::cloud::storage::ObjectMetadata::metadata ( std::string const &  key) const
inline

Returns the value of key in the Object's metadata entries.

It is undefined behavior to call metadata(key) if has_metadata(key) == false.

Definition at line 248 of file object_metadata.h.

◆ mutable_acl()

std::vector<ObjectAccessControl>& google::cloud::storage::ObjectMetadata::mutable_acl ( )
inline

The access control list for this object.

Definition at line 110 of file object_metadata.h.

◆ mutable_metadata()

std::map<std::string, std::string>& google::cloud::storage::ObjectMetadata::mutable_metadata ( )
inline

Returns all the Object's metadata entries.

Definition at line 279 of file object_metadata.h.

◆ reset_custom_time()

ObjectMetadata& google::cloud::storage::ObjectMetadata::reset_custom_time ( )
inline

Reset (clears) the customTime attribute.

has_custom_time() returns false after calling this function.

Definition at line 366 of file object_metadata.h.

◆ retention_expiration_time()

std::chrono::system_clock::time_point google::cloud::storage::ObjectMetadata::retention_expiration_time ( ) const
inline

The retention expiration time, or the system clock's epoch, if not set.

Definition at line 306 of file object_metadata.h.

◆ set_acl()

ObjectMetadata& google::cloud::storage::ObjectMetadata::set_acl ( std::vector< ObjectAccessControl acl)
inline

Change the access control list.

Definition at line 113 of file object_metadata.h.

◆ set_cache_control()

ObjectMetadata& google::cloud::storage::ObjectMetadata::set_cache_control ( std::string  cache_control)
inline

Set the cacheControl attribute.

Definition at line 125 of file object_metadata.h.

◆ set_content_disposition()

ObjectMetadata& google::cloud::storage::ObjectMetadata::set_content_disposition ( std::string  value)
inline

Change the contentDisposition attribute.

Definition at line 137 of file object_metadata.h.

◆ set_content_encoding()

ObjectMetadata& google::cloud::storage::ObjectMetadata::set_content_encoding ( std::string  value)
inline

Change the contentEncoding attribute.

Definition at line 146 of file object_metadata.h.

◆ set_content_language()

ObjectMetadata& google::cloud::storage::ObjectMetadata::set_content_language ( std::string  value)
inline

Change the contentLanguage attribute.

Definition at line 155 of file object_metadata.h.

◆ set_content_type()

ObjectMetadata& google::cloud::storage::ObjectMetadata::set_content_type ( std::string  value)
inline

Change the contentLanguage attribute.

Definition at line 164 of file object_metadata.h.

◆ set_custom_time()

ObjectMetadata& google::cloud::storage::ObjectMetadata::set_custom_time ( std::chrono::system_clock::time_point  v)
inline

Changes the customTime attribute.

Definition at line 359 of file object_metadata.h.

◆ set_event_based_hold()

ObjectMetadata& google::cloud::storage::ObjectMetadata::set_event_based_hold ( bool  v)
inline

Changes the eventBasedHold attribute.

Definition at line 195 of file object_metadata.h.

◆ set_storage_class()

ObjectMetadata& google::cloud::storage::ObjectMetadata::set_storage_class ( std::string  v)
inline

Changes the storageClass attribute.

Definition at line 320 of file object_metadata.h.

◆ set_temporary_hold()

ObjectMetadata& google::cloud::storage::ObjectMetadata::set_temporary_hold ( bool  v)
inline

Changes the temporaryHold attribute.

Definition at line 329 of file object_metadata.h.

◆ size()

std::uint64_t google::cloud::storage::ObjectMetadata::size ( ) const
inline

The size of the object's data.

Definition at line 314 of file object_metadata.h.

◆ temporary_hold()

bool google::cloud::storage::ObjectMetadata::temporary_hold ( ) const
inline

The temporaryHold attribute.

Definition at line 326 of file object_metadata.h.

◆ time_deleted()

std::chrono::system_clock::time_point google::cloud::storage::ObjectMetadata::time_deleted ( ) const
inline

The object's deletion timestamp.

Definition at line 338 of file object_metadata.h.

◆ time_storage_class_updated()

std::chrono::system_clock::time_point google::cloud::storage::ObjectMetadata::time_storage_class_updated ( ) const
inline

The timestamp for the last storage class change.

Definition at line 343 of file object_metadata.h.

◆ upsert_metadata()

ObjectMetadata& google::cloud::storage::ObjectMetadata::upsert_metadata ( std::string  key,
std::string  value 
)
inline

Insert or update the metadata entry.

Definition at line 263 of file object_metadata.h.

Friends And Related Function Documentation

◆ operator!=

bool operator!= ( ObjectMetadata const &  lhs,
ObjectMetadata const &  rhs 
)
friend

Definition at line 372 of file object_metadata.h.

◆ operator<<

std::ostream& operator<< ( std::ostream &  os,
ObjectMetadata const &  rhs 
)
friend

◆ operator==

bool operator== ( ObjectMetadata const &  lhs,
ObjectMetadata const &  rhs 
)
friend