# Class ObjectMetadata (3.7.0-rc)

3.7.0-rc 3.6.0 (latest) 3.5.0 3.4.0 3.3.0 3.2.0 2.48.0-rc 2.47.1 2.46.0 2.45.0 2.44.0 2.43.0 2.42.0 2.41.0 2.40.0 2.39.0 2.38.0 2.37.0 2.36.0 2.35.0 2.34.0 2.33.0 2.32.0 2.31.0 2.30.0 2.29.0 2.28.0 2.27.0 2.26.0 2.25.1 2.24.0 2.23.0 2.22.1 2.21.0 2.20.0 2.19.0 2.18.0 2.17.0 2.16.0 2.15.1 2.14.0 2.13.0 2.12.0 2.11.0 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()`](https://docs.cloud.google.com/cpp/docs/reference/storage/latest/classgoogle_1_1cloud_1_1storage_1_1Client#classgoogle_1_1cloud_1_1storage_1_1Client_1a55773d1bc6e4317b04ef0cfe67927cac), 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.

## Constructors

### ObjectMetadata()

## Functions

### has_metadata(std::string const \&) const

Accessors and modifiers for metadata entries.
Returns `true` if the key is present in the object metadata entries.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `key` | `std::string const &` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `bool` |   |

### metadata(std::string const \&) const

Returns the value of `key` in the Object's metadata entries.
It is undefined behavior to call `metadata(key)` if `has_metadata(key) == false`.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `key` | `std::string const &` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `std::string const &` |   |

### delete_metadata(std::string const \&)

Delete a metadata entry. This is a no-op if the key does not exist.
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.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `key` | `std::string const &` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `ObjectMetadata &` |   |

### upsert_metadata(std::string, std::string)

Insert or update the metadata entry.
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.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `key` | `std::string` |
| `value` | `std::string` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `ObjectMetadata &` |   |

### metadata() const

Returns all the Object's 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.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `std::map< std::string, std::string > const &` |   |

### mutable_metadata()

Returns all the Object's 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.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `std::map< std::string, std::string > &` |   |

### acl() const

The access control list for this object.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `std::vector< ObjectAccessControl > const &` |   |

### mutable_acl()

The access control list for this object.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `std::vector< ObjectAccessControl > &` |   |

### set_acl(std::vector\< ObjectAccessControl \>)

Change the access control list.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `acl` | `std::vector< ObjectAccessControl >` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `ObjectMetadata &` |   |

### bucket() const

The name of the bucket containing this object.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `std::string const &` |   |

### set_bucket(std::string)

> [!NOTE]
> **Note:** This is only intended for mocking.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `v` | `std::string` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `ObjectMetadata &` |   |

### cache_control() const

The `cacheControl` attribute.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `std::string const &` |   |

### set_cache_control(std::string)

Set the `cacheControl` attribute.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `cache_control` | `std::string` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `ObjectMetadata &` |   |

### component_count() const

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

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `std::int32_t` |   |

### set_component_count(std::int32_t)

> [!NOTE]
> **Note:** This is only intended for mocking.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `v` | `std::int32_t` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `ObjectMetadata &` |   |

### content_disposition() const

The `contentDisposition` attribute.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `std::string` |   |

### set_content_disposition(std::string)

Change the `contentDisposition` attribute.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `value` | `std::string` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `ObjectMetadata &` |   |

### content_encoding() const

The `contentEncoding` attribute.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `std::string` |   |

### set_content_encoding(std::string)

Change the `contentEncoding` attribute.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `value` | `std::string` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `ObjectMetadata &` |   |

### content_language() const

The `contentLanguage` attribute.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `std::string` |   |

### set_content_language(std::string)

Change the `contentLanguage` attribute.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `value` | `std::string` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `ObjectMetadata &` |   |

### content_type() const

The `contentType` attribute.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `std::string` |   |

### set_content_type(std::string)

Change the `contentLanguage` attribute.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `value` | `std::string` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `ObjectMetadata &` |   |

### crc32c() const

The `CRC32C` checksum for the object contents.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `std::string const &` |   |

### set_crc32c(std::string)

> [!NOTE]
> **Note:** This is only intended for mocking.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `v` | `std::string` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `ObjectMetadata &` |   |

### has_custom_time() const

Returns `true` if the object has a `customTime` attribute.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `bool` |   |

### custom_time() const

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

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `std::chrono::system_clock::time_point` |   |

### set_custom_time(std::chrono::system_clock::time_point)

Changes the `customTime` attribute.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `v` | `std::chrono::system_clock::time_point` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `ObjectMetadata &` |   |

### reset_custom_time()

Reset (clears) the `customTime` attribute.
[`has_custom_time()`](https://docs.cloud.google.com/cpp/docs/reference/storage/latest/classgoogle_1_1cloud_1_1storage_1_1ObjectMetadata#classgoogle_1_1cloud_1_1storage_1_1ObjectMetadata_1a4aec669f2077aed3454542d00f54e552) returns `false` after calling this function.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `ObjectMetadata &` |   |

### has_customer_encryption() const

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

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `bool` |   |

### customer_encryption() const

Returns the CSEK metadata (algorithm and key SHA256).
It is undefined behavior to call this member function if [`has_customer_encryption()`](https://docs.cloud.google.com/cpp/docs/reference/storage/latest/classgoogle_1_1cloud_1_1storage_1_1ObjectMetadata#classgoogle_1_1cloud_1_1storage_1_1ObjectMetadata_1aa0533811d75ed5caf43d876b45b7acb4)`== false`.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `CustomerEncryption const &` |   |

### set_customer_encryption(CustomerEncryption)

> [!NOTE]
> **Note:** This is only intended for mocking.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `v` | `CustomerEncryption` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `ObjectMetadata &` |   |

### reset_customer_encryption()

> [!NOTE]
> **Note:** This is only intended for mocking.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `ObjectMetadata &` |   |

### etag() const

The `Etag` attribute.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `std::string const &` |   |

### set_etag(std::string)

> [!NOTE]
> **Note:** This is only intended for mocking.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `v` | `std::string` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `ObjectMetadata &` |   |

### event_based_hold() const

The `eventBasedHold` attribute.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `bool` |   |

### set_event_based_hold(bool)

Changes the `eventBasedHold` attribute.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `v` | `bool` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `ObjectMetadata &` |   |

### generation() const

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.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `std::int64_t` |   |

### set_generation(std::int64_t)

> [!NOTE]
> **Note:** This is only intended for mocking.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `v` | `std::int64_t` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `ObjectMetadata &` |   |

### id() const

The `id` attribute (the object name)

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `std::string const &` |   |

### set_id(std::string)

> [!NOTE]
> **Note:** This is only intended for mocking.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `v` | `std::string` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `ObjectMetadata &` |   |

### kind() const

The `kind` attribute, that is, `storage#object`.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `std::string const &` |   |

### set_kind(std::string)

> [!NOTE]
> **Note:** This is only intended for mocking.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `v` | `std::string` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `ObjectMetadata &` |   |

### kms_key_name() const

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).

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `std::string const &` |   |

### set_kms_key_name(std::string)

> [!NOTE]
> **Note:** This is only intended for mocking.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `v` | `std::string` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `ObjectMetadata &` |   |

### md5_hash() const

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

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `std::string const &` |   |

### set_md5_hash(std::string)

> [!NOTE]
> **Note:** This is only intended for mocking.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `v` | `std::string` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `ObjectMetadata &` |   |

### media_link() const

The HTTPS link to access the object contents.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `std::string const &` |   |

### set_media_link(std::string)

> [!NOTE]
> **Note:** This is only intended for mocking.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `v` | `std::string` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `ObjectMetadata &` |   |

### metageneration() const

The generation of the object metadata.

> [!NOTE]
> **Note:** Changes to the object metadata (e.g. changing the `cacheControl` attribute) increases the metageneration, but does not change the object generation.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `std::int64_t` |   |

### set_metageneration(std::int64_t)

> [!NOTE]
> **Note:** This is only intended for mocking.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `v` | `std::int64_t` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `ObjectMetadata &` |   |

### name() const

The object name, including bucket and generation.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `std::string const &` |   |

### set_name(std::string)

> [!NOTE]
> **Note:** This is only intended for mocking.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `v` | `std::string` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `ObjectMetadata &` |   |

### has_owner() const

Returns `true` if the object has an `owner` attribute.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `bool` |   |

### owner() const

The object's `owner` attribute.
It is undefined behavior to call this member function if [`has_owner()`](https://docs.cloud.google.com/cpp/docs/reference/storage/latest/classgoogle_1_1cloud_1_1storage_1_1ObjectMetadata#classgoogle_1_1cloud_1_1storage_1_1ObjectMetadata_1ab413c53e2f7f04ce73b5b1d132917742)`== false`.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `Owner const &` |   |

### set_owner(Owner)

> [!NOTE]
> **Note:** This is only intended for mocking.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `v` | `Owner` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `ObjectMetadata &` |   |

### reset_owner()

> [!NOTE]
> **Note:** This is only intended for mocking.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `ObjectMetadata &` |   |

### retention_expiration_time() const

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

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `std::chrono::system_clock::time_point` |   |

### set_retention_expiration_time(std::chrono::system_clock::time_point)

> [!NOTE]
> **Note:** This is only intended for mocking.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `v` | `std::chrono::system_clock::time_point` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `ObjectMetadata &` |   |

### has_retention() const

Returns `true` if the object has a retention configuration.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `bool` |   |

### retention() const

The object's retention configuration.
It is undefined behavior to call this member function if [`has_retention()`](https://docs.cloud.google.com/cpp/docs/reference/storage/latest/classgoogle_1_1cloud_1_1storage_1_1ObjectMetadata#classgoogle_1_1cloud_1_1storage_1_1ObjectMetadata_1aa2f70d11892d62554f2d0e7ae229fea1)`== false`.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `ObjectRetention const &` |   |

### set_retention(ObjectRetention)

Change or set the object retention value.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `v` | `ObjectRetention` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `ObjectMetadata &` |   |

### reset_retention()

Reset the object retention.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `ObjectMetadata &` |   |

### has_contexts() const

Returns `true` if the object has custom contexts.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `bool` |   |

### contexts() const

The object's user custom contexts.
It is undefined behavior to call this member function if [`has_contexts()`](https://docs.cloud.google.com/cpp/docs/reference/storage/latest/classgoogle_1_1cloud_1_1storage_1_1ObjectMetadata#classgoogle_1_1cloud_1_1storage_1_1ObjectMetadata_1a7e8aa5af696cf139da160f8a5a7aa4f0)`== false`.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `ObjectContexts const &` |   |

### set_contexts(ObjectContexts)

Change or set the object's custom contexts.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `v` | `ObjectContexts` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `ObjectMetadata &` |   |

### reset_contexts()

Reset the object contexts.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `ObjectMetadata &` |   |

### self_link() const

An HTTPS link to the object metadata.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `std::string const &` |   |

### set_self_link(std::string)

> [!NOTE]
> **Note:** This is only intended for mocking.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `v` | `std::string` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `ObjectMetadata &` |   |

### size() const

The size of the object's data.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `std::uint64_t` |   |

### set_size(std::uint64_t)

> [!NOTE]
> **Note:** This is only intended for mocking.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `v` | `std::uint64_t` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `ObjectMetadata &` |   |

### storage_class() const

The `storageClass` attribute.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `std::string const &` |   |

### set_storage_class(std::string)

Changes the `storageClass` attribute.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `v` | `std::string` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `ObjectMetadata &` |   |

### temporary_hold() const

The `temporaryHold` attribute.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `bool` |   |

### set_temporary_hold(bool)

Changes the `temporaryHold` attribute.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `v` | `bool` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `ObjectMetadata &` |   |

### time_created() const

The object creation timestamp.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `std::chrono::system_clock::time_point` |   |

### set_time_created(std::chrono::system_clock::time_point)

> [!NOTE]
> **Note:** This is only intended for mocking.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `v` | `std::chrono::system_clock::time_point` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `ObjectMetadata &` |   |

### time_deleted() const

The object's deletion timestamp.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `std::chrono::system_clock::time_point` |   |

### set_time_deleted(std::chrono::system_clock::time_point)

> [!NOTE]
> **Note:** This is only intended for mocking.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `v` | `std::chrono::system_clock::time_point` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `ObjectMetadata &` |   |

### time_storage_class_updated() const

The timestamp for the last storage class change.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `std::chrono::system_clock::time_point` |   |

### set_time_storage_class_updated(std::chrono::system_clock::time_point)

> [!NOTE]
> **Note:** This is only intended for mocking.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `v` | `std::chrono::system_clock::time_point` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `ObjectMetadata &` |   |

### updated() const

The timestamp for the last object *metadata* update.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `std::chrono::system_clock::time_point` |   |

### set_updated(std::chrono::system_clock::time_point)

> [!NOTE]
> **Note:** This is only intended for mocking.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `v` | `std::chrono::system_clock::time_point` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `ObjectMetadata &` |   |

### has_soft_delete_time() const

Returns true if the object has a soft delete timestamp.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `bool` |   |

### soft_delete_time() const

This is the time when the object became soft-deleted.
Soft-deleted objects are only accessible if a `soft_delete_policy` is enabled in their bucket. Also see [`hard_delete_time()`](https://docs.cloud.google.com/cpp/docs/reference/storage/latest/classgoogle_1_1cloud_1_1storage_1_1ObjectMetadata#classgoogle_1_1cloud_1_1storage_1_1ObjectMetadata_1ab8a8d572bae36bf64b97805316c2976e).

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `std::chrono::system_clock::time_point` |   |

### set_soft_delete_time(std::chrono::system_clock::time_point)

> [!NOTE]
> **Note:** This is only intended for mocking.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `v` | `std::chrono::system_clock::time_point` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `ObjectMetadata &` |   |

### reset_soft_delete_time()

> [!NOTE]
> **Note:** This is only intended for mocking.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `ObjectMetadata &` |   |

### has_hard_delete_time() const

Returns true if the object has a hard delete timestamp.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `bool` |   |

### hard_delete_time() const

The time when the object will be permanently deleted.
Soft-deleted objects are permanently deleted after some time, based on the `soft_delete_policy` in their bucket. This is only set on soft-deleted objects, and indicates the earliest time at which the object will be permanently deleted.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `std::chrono::system_clock::time_point` |   |

### set_hard_delete_time(std::chrono::system_clock::time_point)

> [!NOTE]
> **Note:** This is only intended for mocking.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `v` | `std::chrono::system_clock::time_point` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `ObjectMetadata &` |   |

### reset_hard_delete_time()

> [!NOTE]
> **Note:** This is only intended for mocking.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `ObjectMetadata &` |   |