Send feedback
Class ObjectMetadataPatchBuilder (2.30.0)
Stay organized with collections
Save and categorize content based on your preferences.
Version 2.30.0 keyboard_arrow_down
Prepares a patch for the Bucket resource.
Constructors
Functions
Returns
Type
Description
std::string
Parameter
Name
Description
v
std::vector< ObjectAccessControl > const &
Returns
Type
Description
ObjectMetadataPatchBuilder &
Warning:
Currently the server ignores requests to reset the full ACL.
Returns
Type
Description
ObjectMetadataPatchBuilder &
Parameter
Name
Description
v
std::string const &
Returns
Type
Description
ObjectMetadataPatchBuilder &
Returns
Type
Description
ObjectMetadataPatchBuilder &
Parameter
Name
Description
v
std::string const &
Returns
Type
Description
ObjectMetadataPatchBuilder &
Returns
Type
Description
ObjectMetadataPatchBuilder &
Parameter
Name
Description
v
std::string const &
Returns
Type
Description
ObjectMetadataPatchBuilder &
Returns
Type
Description
ObjectMetadataPatchBuilder &
Parameter
Name
Description
v
std::string const &
Returns
Type
Description
ObjectMetadataPatchBuilder &
Returns
Type
Description
ObjectMetadataPatchBuilder &
Parameter
Name
Description
v
std::string const &
Returns
Type
Description
ObjectMetadataPatchBuilder &
Returns
Type
Description
ObjectMetadataPatchBuilder &
Parameter
Name
Description
v
bool
Returns
Type
Description
ObjectMetadataPatchBuilder &
Returns
Type
Description
ObjectMetadataPatchBuilder &
Parameters
Name
Description
key
std::string const &
value
std::string const &
Returns
Type
Description
ObjectMetadataPatchBuilder &
Parameter
Name
Description
key
std::string const &
Returns
Type
Description
ObjectMetadataPatchBuilder &
Returns
Type
Description
ObjectMetadataPatchBuilder &
Parameter
Name
Description
v
bool
Returns
Type
Description
ObjectMetadataPatchBuilder &
Returns
Type
Description
ObjectMetadataPatchBuilder &
Change the custom_time
field.
Example
namespace gcs = ::google::cloud::storage;
using ::google::cloud::StatusOr;
[](gcs::Client client, std::string const& bucket_name,
std::string const& object_name) {
auto original = client.GetObjectMetadata(bucket_name, object_name);
if (!original) throw std::move(original).status();
auto const tp = std::chrono::system_clock::now() - std::chrono::hours(48);
auto updated =
client.PatchObject(bucket_name, object_name,
gcs::ObjectMetadataPatchBuilder{}.SetCustomTime(tp));
if (!updated) throw std::move(updated).status();
std::cout << "The custom time for object " << updated->name()
<< " in bucket " << updated->bucket() << " was successfully set. "
<< "Full object details: " << *updated << "\n";
}
Parameter
Name
Description
tp
std::chrono::system_clock::time_point
Returns
Type
Description
ObjectMetadataPatchBuilder &
Returns
Type
Description
ObjectMetadataPatchBuilder &
Change the retention
field.
Example
namespace gcs = ::google::cloud::storage;
using ::google::cloud::StatusOr;
[](gcs::Client client, std::string const& bucket_name,
std::string const& object_name) {
auto original = client.GetObjectMetadata(bucket_name, object_name);
if (!original) throw std::move(original).status();
auto const until =
std::chrono::system_clock::now() + std::chrono::hours(24);
auto updated = client.PatchObject(
bucket_name, object_name,
gcs::ObjectMetadataPatchBuilder().SetRetention(
gcs::ObjectRetention{gcs::ObjectRetentionUnlocked(), until}),
gcs::OverrideUnlockedRetention(true),
gcs::IfMetagenerationMatch(original->metageneration()));
if (!updated) throw std::move(updated).status();
std::cout << "Successfully updated object retention configuration: "
<< *updated << "\n";
}
Parameter
Name
Description
tp
ObjectRetention const &
Returns
Type
Description
ObjectMetadataPatchBuilder &
Returns
Type
Description
ObjectMetadataPatchBuilder &
Send feedback
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License , and code samples are licensed under the Apache 2.0 License . For details, see the Google Developers Site Policies . Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-12-19 UTC.
Need to tell us more?
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-12-19 UTC."],[],[]]