Google Cloud Storage C++ Client 2.13.0
A C++ Client Library for Google Cloud Storage
Loading...
Searching...
No Matches
bucket_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_BUCKET_METADATA_H
16#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_STORAGE_BUCKET_METADATA_H
17
18#include "google/cloud/storage/bucket_access_control.h"
19#include "google/cloud/storage/bucket_autoclass.h"
20#include "google/cloud/storage/bucket_billing.h"
21#include "google/cloud/storage/bucket_cors_entry.h"
22#include "google/cloud/storage/bucket_custom_placement_config.h"
23#include "google/cloud/storage/bucket_encryption.h"
24#include "google/cloud/storage/bucket_iam_configuration.h"
25#include "google/cloud/storage/bucket_lifecycle.h"
26#include "google/cloud/storage/bucket_logging.h"
27#include "google/cloud/storage/bucket_retention_policy.h"
28#include "google/cloud/storage/bucket_rpo.h"
29#include "google/cloud/storage/bucket_versioning.h"
30#include "google/cloud/storage/bucket_website.h"
31#include "google/cloud/storage/internal/patch_builder.h"
32#include "google/cloud/storage/lifecycle_rule.h"
33#include "google/cloud/storage/object_access_control.h"
34#include "google/cloud/storage/owner.h"
35#include "google/cloud/storage/version.h"
36#include "google/cloud/optional.h"
37#include "absl/types/optional.h"
38#include <chrono>
39#include <map>
40#include <string>
41#include <tuple>
42#include <utility>
43#include <vector>
44
45namespace google {
46namespace cloud {
47namespace storage {
48GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
49
50/**
51 * Represents a Google Cloud Storage Bucket Metadata object.
52 */
53class BucketMetadata {
54 public:
55 BucketMetadata() = default;
56
57 // Please keep these in alphabetical order, that make it easier to verify we
58 // have actually implemented all of them.
59 /**
60 * @name Get and set Bucket Access Control Lists.
61 *
62 * @see https://cloud.google.com/storage/docs/access-control/lists
63 */
64 ///@{
65 std::vector<BucketAccessControl> const& acl() const { return acl_; }
66 std::vector<BucketAccessControl>& mutable_acl() { return acl_; }
67 BucketMetadata& set_acl(std::vector<BucketAccessControl> acl) {
68 acl_ = std::move(acl);
69 return *this;
70 }
71 ///@}
72
73 /// @name Accessors and modifiers for Autoclass configuration.
74 ///@{
75 bool has_autoclass() const { return autoclass_.has_value(); }
76 BucketAutoclass const& autoclass() const { return *autoclass_; }
77 absl::optional<BucketAutoclass> const& autoclass_as_optional() const {
78 return autoclass_;
79 }
81 autoclass_ = std::move(v);
82 return *this;
83 }
85 autoclass_.reset();
86 return *this;
87 }
88 ///@}
89
90 /**
91 * @name Get and set billing configuration for the Bucket.
92 *
93 * @see https://cloud.google.com/storage/docs/requester-pays
94 */
95 ///@{
96 bool has_billing() const { return billing_.has_value(); }
97 BucketBilling const& billing() const { return *billing_; }
98 absl::optional<BucketBilling> const& billing_as_optional() const {
99 return billing_;
100 }
102 billing_ = v;
103 return *this;
104 }
106 billing_.reset();
107 return *this;
108 }
109 ///@}
110
111 /**
112 * @name Get and set the default event based hold for the Bucket.
113 *
114 * Objects may have an event-based hold associated with them. If a Bucket
115 * has the `default_event_based_hold()` parameter set, and you create a new
116 * object in the bucket without specifying its event-event based hold then the
117 * object gets the value set in the bucket.
118 *
119 * @see https://cloud.google.com/storage/docs/bucket-lock for generation
120 * information on retention policies. The section on
121 * [Object
122 * holds](https://cloud.google.com/storage/docs/bucket-lock#object-holds) is
123 * particularly relevant.
124 *
125 * @see https://cloud.google.com/storage/docs/holding-objects for examples
126 * of using default event-based hold policy.
127 */
128 ///@{
129 bool default_event_based_hold() const { return default_event_based_hold_; }
131 default_event_based_hold_ = v;
132 return *this;
133 }
134 ///@}
135
136 /**
137 * @name Get and set CORS configuration for the Bucket.
138 *
139 * @see https://en.wikipedia.org/wiki/Cross-origin_resource_sharing for
140 * general information on CORS.
141 *
142 * @see https://cloud.google.com/storage/docs/cross-origin for general
143 * information about CORS in the context of Google Cloud Storage.
144 *
145 * @see https://cloud.google.com/storage/docs/configuring-cors for information
146 * on how to set and troubleshoot CORS settings.
147 */
148 ///@{
149 std::vector<CorsEntry> const& cors() const { return cors_; }
150 std::vector<CorsEntry>& mutable_cors() { return cors_; }
151 BucketMetadata& set_cors(std::vector<CorsEntry> cors) {
152 cors_ = std::move(cors);
153 return *this;
154 }
155 ///@}
156
157 /**
158 * @name Get and set the Default Object Access Control Lists.
159 *
160 * @see https://cloud.google.com/storage/docs/access-control/lists#default for
161 * general information of default ACLs.
162 *
163 * @see
164 * https://cloud.google.com/storage/docs/access-control/create-manage-lists#defaultobjects
165 * for information on how to set the default ACLs.
166 */
167 ///@{
168 std::vector<ObjectAccessControl> const& default_acl() const {
169 return default_acl_;
170 }
172 return default_acl_;
173 }
175 default_acl_ = std::move(acl);
176 return *this;
177 }
178 ///@}
179
180 /**
181 * @name Get and set the Default Object Access Control Lists.
182 *
183 * @see https://cloud.google.com/storage/docs/access-control/lists#default for
184 * general information of default ACLs.
185 *
186 * @see
187 * https://cloud.google.com/storage/docs/encryption/customer-managed-keys
188 * for information on Customer-Managed Encryption Keys.
189 */
190 ///@{
191 bool has_encryption() const { return encryption_.has_value(); }
192 BucketEncryption const& encryption() const { return *encryption_; }
193 absl::optional<BucketEncryption> const& encryption_as_optional() const {
194 return encryption_;
195 }
197 encryption_ = std::move(v);
198 return *this;
199 }
201 encryption_.reset();
202 return *this;
203 }
204 ///@}
205
206 std::string const& etag() const { return etag_; }
207
208 /// @note This is only intended for mocking.
209 BucketMetadata& set_etag(std::string v) {
210 etag_ = std::move(v);
211 return *this;
212 }
213
214 /**
215 * @name Get and set the IAM configuration.
216 *
217 * @see Before enabling Uniform Bucket Level Access please review the
218 * [feature documentation][ubla-link], as well as
219 * ["Should you use uniform bucket-level access ?"][ubla-should-link].
220 *
221 * [ubla-link]:
222 * https://cloud.google.com/storage/docs/uniform-bucket-level-access
223 * [ubla-should-link]:
224 * https://cloud.google.com/storage/docs/uniform-bucket-level-access#should-you-use
225 */
226 ///@{
227 bool has_iam_configuration() const { return iam_configuration_.has_value(); }
229 return *iam_configuration_;
230 }
232 const {
233 return iam_configuration_;
234 }
236 iam_configuration_ = std::move(v);
237 return *this;
238 }
240 iam_configuration_.reset();
241 return *this;
242 }
243 ///@}
244
245 /// Return the bucket id.
246 std::string const& id() const { return id_; }
247
248 /// @note This is only intended for mocking.
249 BucketMetadata& set_id(std::string v) {
250 id_ = std::move(v);
251 return *this;
252 }
253
254 std::string const& kind() const { return kind_; }
255
256 /// @note This is only intended for mocking
257 BucketMetadata& set_kind(std::string v) {
258 kind_ = std::move(v);
259 return *this;
260 }
261
262 /// @name Accessors and modifiers to the `labels`.
263 ///@{
264
265 /// Returns `true` if the key is present in the Bucket's metadata labels.
266 bool has_label(std::string const& key) const {
267 return labels_.end() != labels_.find(key);
268 }
269
270 /**
271 * Returns the value of @p key in the Bucket's metadata labels.
272 *
273 * It is undefined behavior to call `label(key)` if `has_label(key) == false`.
274 */
275 std::string const& label(std::string const& key) const {
276 return labels_.at(key);
277 }
278
279 /// Delete a label. This is a no-op if the key does not exist.
280 BucketMetadata& delete_label(std::string const& key) {
281 auto i = labels_.find(key);
282 if (i == labels_.end()) {
283 return *this;
284 }
285 labels_.erase(i);
286 return *this;
287 }
288
289 /// Insert or update the label entry.
290 BucketMetadata& upsert_label(std::string key, std::string value) {
291 auto i = labels_.lower_bound(key);
292 if (i == labels_.end() || i->first != key) {
293 labels_.emplace_hint(i, std::move(key), std::move(value));
294 } else {
295 i->second = std::move(value);
296 }
297 return *this;
298 }
299
300 /// Returns all the Bucket's labels.
301 std::map<std::string, std::string> const& labels() const { return labels_; }
302
303 /// Returns all the Bucket's labels.
304 std::map<std::string, std::string>& mutable_labels() { return labels_; }
305 ///@}
306
307 /**
308 * @name Accessors and modifiers for object lifecycle rules.
309 *
310 * @see https://cloud.google.com/storage/docs/managing-lifecycles for general
311 * information on object lifecycle rules.
312 */
313 ///@{
314 bool has_lifecycle() const { return lifecycle_.has_value(); }
315 BucketLifecycle const& lifecycle() const { return *lifecycle_; }
316 absl::optional<BucketLifecycle> const& lifecycle_as_optional() const {
317 return lifecycle_;
318 }
320 lifecycle_ = std::move(v);
321 return *this;
322 }
324 lifecycle_.reset();
325 return *this;
326 }
327 ///@}
328
329 /// Return the bucket location.
330 std::string const& location() const { return location_; }
331
332 /// Set the bucket location. Only applicable when creating buckets.
333 BucketMetadata& set_location(std::string v) {
334 location_ = std::move(v);
335 return *this;
336 }
337
338 /// Returns the location type (e.g. regional vs. dual region).
339 std::string const& location_type() const { return location_type_; }
340
341 /// @note This is only intended for mocking.
342 BucketMetadata& set_location_type(std::string v) {
343 location_type_ = std::move(v);
344 return *this;
345 }
346
347 /// @name Accessors and modifiers for logging configuration.
348 ///@{
349 bool has_logging() const { return logging_.has_value(); }
350 BucketLogging const& logging() const { return *logging_; }
351 absl::optional<BucketLogging> const& logging_as_optional() const {
352 return logging_;
353 }
355 logging_ = std::move(v);
356 return *this;
357 }
359 logging_.reset();
360 return *this;
361 }
362 ///@}
363
364 /// The bucket metageneration.
365 std::int64_t metageneration() const { return metageneration_; }
366
367 /// @note this is only intended for mocking.
368 BucketMetadata& set_metageneration(std::int64_t v) {
369 metageneration_ = v;
370 return *this;
371 }
372
373 /// The bucket name.
374 std::string const& name() const { return name_; }
375
376 /**
377 * Changes the name.
378 *
379 * @note Bucket names can only be set during bucket creation. This modifier
380 * is used to set the name when using a `BucketMetadata` object that changes
381 * some other attribute.
382 */
383 BucketMetadata& set_name(std::string v) {
384 name_ = std::move(v);
385 return *this;
386 }
387
388 /// Returns true if the bucket `owner` attribute is present.
389 bool has_owner() const { return owner_.has_value(); }
390 /**
391 * Returns the owner.
392 *
393 * It is undefined behavior to call `owner()` if `has_owner()` is false.
394 */
395 Owner const& owner() const { return *owner_; }
396
397 /// @note this is only intended for mocking.
399 owner_ = std::move(v);
400 return *this;
401 }
402 /// @note this is only intended for mocking.
404 owner_.reset();
405 return *this;
406 }
407
408 std::int64_t const& project_number() const { return project_number_; }
409
410 /// @note this is only intended for mocking.
411 BucketMetadata& set_project_number(std::int64_t v) {
412 project_number_ = v;
413 return *this;
414 }
415
416 /// Returns a HTTP link to retrieve the bucket metadata.
417 std::string const& self_link() const { return self_link_; }
418
419 /// @note this is only intended for mocking.
420 BucketMetadata& set_self_link(std::string v) {
421 self_link_ = std::move(v);
422 return *this;
423 }
424
425 /// @name Accessors and modifiers for retention policy configuration.
426 ///@{
427 bool has_retention_policy() const { return retention_policy_.has_value(); }
429 return *retention_policy_;
430 }
432 const {
433 return retention_policy_;
434 }
436 retention_policy_ = std::move(v);
437 return *this;
438 }
439
440 /**
441 * Sets the retention period.
442 *
443 * The retention period is the only writable attribute in a retention policy.
444 * This function makes it easier to set the retention policy when the
445 * `BucketMetadata` object is used to update or patch the bucket.
446 */
447 BucketMetadata& set_retention_policy(std::chrono::seconds retention_period) {
449 retention_period, std::chrono::system_clock::time_point{}, false});
450 }
451
453 retention_policy_.reset();
454 return *this;
455 }
456 ///@}
457
458 /// @name Accessors and modifiers for the Recovery Point Objective.
459 ///@{
460 std::string const& rpo() const { return rpo_; }
461 BucketMetadata& set_rpo(std::string v) {
462 rpo_ = std::move(v);
463 return *this;
464 }
465 ///@}
466
467 /// @name Access and modify the default storage class attribute.
468 ///@{
469 std::string const& storage_class() const { return storage_class_; }
470 BucketMetadata& set_storage_class(std::string v) {
471 storage_class_ = std::move(v);
472 return *this;
473 }
474 ///@}
475
476 /// Returns the bucket creation timestamp.
477 std::chrono::system_clock::time_point time_created() const {
478 return time_created_;
479 }
480
481 /// @note This is only intended for mocking.
482 BucketMetadata& set_time_created(std::chrono::system_clock::time_point v) {
483 time_created_ = v;
484 return *this;
485 }
486
487 /// Returns the timestamp for the last bucket metadata update.
488 std::chrono::system_clock::time_point updated() const { return updated_; }
489
490 /// @note This is only intended for mocking.
491 BucketMetadata& set_updated(std::chrono::system_clock::time_point v) {
492 updated_ = v;
493 return *this;
494 }
495
496 /// @name Accessors and modifiers for versioning configuration.
497 ///@{
498 absl::optional<BucketVersioning> const& versioning() const {
499 return versioning_;
500 }
501 bool has_versioning() const { return versioning_.has_value(); }
503 versioning_.emplace(BucketVersioning{true});
504 return *this;
505 }
507 versioning_.emplace(BucketVersioning{false});
508 return *this;
509 }
511 versioning_.reset();
512 return *this;
513 }
515 versioning_ = std::move(v);
516 return *this;
517 }
518 ///@}
519
520 /// @name Accessors and modifiers for website configuration.
521 ///@{
522 bool has_website() const { return website_.has_value(); }
523 BucketWebsite const& website() const { return *website_; }
524 absl::optional<BucketWebsite> const& website_as_optional() const {
525 return website_;
526 }
528 website_ = std::move(v);
529 return *this;
530 }
532 website_.reset();
533 return *this;
534 }
535 ///@}
536
537 /// @name Accessors and modifiers for custom placement configuration.
538 ///@{
539 bool has_custom_placement_config() const {
540 return custom_placement_config_.has_value();
541 }
543 return *custom_placement_config_;
544 }
545 absl::optional<BucketCustomPlacementConfig> const&
547 return custom_placement_config_;
548 }
549 /// Placement configuration can only be set when the bucket is created.
551 custom_placement_config_ = std::move(v);
552 return *this;
553 }
554 /// Placement configuration can only be set when the bucket is created.
556 custom_placement_config_.reset();
557 return *this;
558 }
559 ///@}
560
561 friend bool operator==(BucketMetadata const& lhs, BucketMetadata const& rhs);
562 friend bool operator!=(BucketMetadata const& lhs, BucketMetadata const& rhs) {
563 return !(lhs == rhs);
564 }
565
566 private:
567 friend std::ostream& operator<<(std::ostream& os, BucketMetadata const& rhs);
568 // Keep the fields in alphabetical order.
569 std::vector<BucketAccessControl> acl_;
570 absl::optional<BucketAutoclass> autoclass_;
571 absl::optional<BucketBilling> billing_;
572 std::vector<CorsEntry> cors_;
573 absl::optional<BucketCustomPlacementConfig> custom_placement_config_;
574 std::vector<ObjectAccessControl> default_acl_;
575 bool default_event_based_hold_ = false;
576 absl::optional<BucketEncryption> encryption_;
577 std::string etag_;
578 absl::optional<BucketIamConfiguration> iam_configuration_;
579 std::string id_;
580 std::string kind_;
581 std::map<std::string, std::string> labels_;
582 absl::optional<BucketLifecycle> lifecycle_;
583 std::string location_;
584 std::string location_type_;
585 absl::optional<BucketLogging> logging_;
586 std::int64_t metageneration_{0};
587 std::string name_;
588 absl::optional<Owner> owner_;
589 std::int64_t project_number_ = 0;
590 absl::optional<BucketRetentionPolicy> retention_policy_;
591 std::string rpo_;
592 std::string self_link_;
593 std::string storage_class_;
594 std::chrono::system_clock::time_point time_created_;
595 std::chrono::system_clock::time_point updated_;
596 absl::optional<BucketVersioning> versioning_;
597 absl::optional<BucketWebsite> website_;
598};
599
600std::ostream& operator<<(std::ostream& os, BucketMetadata const& rhs);
601
602/**
603 * Prepares a patch for the Bucket resource.
604 *
605 * The Bucket resource has many modifiable fields. The application may send a
606 * patch request to change (or delete) a small fraction of these fields by using
607 * this object.
608 *
609 * @see
610 * https://cloud.google.com/storage/docs/json_api/v1/how-tos/performance#patch
611 * for general information on PATCH requests for the Google Cloud Storage
612 * JSON API.
613 */
615 public:
616 BucketMetadataPatchBuilder() = default;
617
618 std::string BuildPatch() const;
619
621
622 /**
623 * Clears the ACL for the Bucket.
624 *
625 * @warning Currently the server ignores requests to reset the full ACL.
626 */
628
631
634
635 BucketMetadataPatchBuilder& SetCors(std::vector<CorsEntry> const& v);
637
640
642 std::vector<ObjectAccessControl> const& v);
643
644 /**
645 * Clears the default object ACL for the Bucket.
646 *
647 * @warning Currently the server ignores requests to reset the full ACL.
648 */
650
652 BucketIamConfiguration const& v);
654
657
658 BucketMetadataPatchBuilder& SetLabel(std::string const& label,
659 std::string const& value);
660 BucketMetadataPatchBuilder& ResetLabel(std::string const& label);
662
665
668
669 BucketMetadataPatchBuilder& SetName(std::string const& v);
671
673 BucketRetentionPolicy const& v);
675 std::chrono::seconds retention_period) {
676 // This is the only parameter that the application can set, so make it easy
677 // for them to set it.
679 retention_period, std::chrono::system_clock::time_point{}, false});
680 }
682
683 BucketMetadataPatchBuilder& SetRpo(std::string const& v);
685
686 BucketMetadataPatchBuilder& SetStorageClass(std::string const& v);
688
691
694
695 private:
696 friend struct internal::PatchBuilderDetails;
697
698 internal::PatchBuilder impl_;
699 bool labels_subpatch_dirty_{false};
700 internal::PatchBuilder labels_subpatch_;
701};
702
703GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
704} // namespace storage
705} // namespace cloud
706} // namespace google
707
708#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_STORAGE_BUCKET_METADATA_H
Wraps the bucketAccessControl resource in Google Cloud Storage.
Definition: bucket_access_control.h:39
Prepares a patch for the Bucket resource.
Definition: bucket_metadata.h:614
BucketMetadataPatchBuilder & ResetBilling()
BucketMetadataPatchBuilder & ResetDefaultEventBasedHold()
BucketMetadataPatchBuilder & ResetVersioning()
BucketMetadataPatchBuilder & SetRetentionPolicy(std::chrono::seconds retention_period)
Definition: bucket_metadata.h:674
BucketMetadataPatchBuilder & SetDefaultEventBasedHold(bool v)
BucketMetadataPatchBuilder & ResetRetentionPolicy()
BucketMetadataPatchBuilder & SetRetentionPolicy(BucketRetentionPolicy const &v)
BucketMetadataPatchBuilder & SetEncryption(BucketEncryption const &v)
BucketMetadataPatchBuilder & ResetEncryption()
BucketMetadataPatchBuilder & SetLogging(BucketLogging const &v)
BucketMetadataPatchBuilder & SetWebsite(BucketWebsite const &v)
BucketMetadataPatchBuilder & SetName(std::string const &v)
BucketMetadataPatchBuilder & ResetStorageClass()
BucketMetadataPatchBuilder & SetLabel(std::string const &label, std::string const &value)
BucketMetadataPatchBuilder & SetAcl(std::vector< BucketAccessControl > const &v)
BucketMetadataPatchBuilder & SetDefaultAcl(std::vector< ObjectAccessControl > const &v)
BucketMetadataPatchBuilder & SetVersioning(BucketVersioning const &v)
BucketMetadataPatchBuilder & ResetLifecycle()
BucketMetadataPatchBuilder & ResetLabel(std::string const &label)
BucketMetadataPatchBuilder & SetAutoclass(BucketAutoclass const &v)
BucketMetadataPatchBuilder & SetBilling(BucketBilling const &v)
BucketMetadataPatchBuilder & SetIamConfiguration(BucketIamConfiguration const &v)
BucketMetadataPatchBuilder & ResetDefaultAcl()
Clears the default object ACL for the Bucket.
BucketMetadataPatchBuilder & ResetAcl()
Clears the ACL for the Bucket.
BucketMetadataPatchBuilder & SetRpo(std::string const &v)
BucketMetadataPatchBuilder & ResetLabels()
BucketMetadataPatchBuilder & ResetWebsite()
BucketMetadataPatchBuilder & ResetLogging()
BucketMetadataPatchBuilder & ResetIamConfiguration()
BucketMetadataPatchBuilder & ResetAutoclass()
BucketMetadataPatchBuilder & SetStorageClass(std::string const &v)
BucketMetadataPatchBuilder & SetLifecycle(BucketLifecycle const &v)
BucketMetadataPatchBuilder & SetCors(std::vector< CorsEntry > const &v)
Represents a Google Cloud Storage Bucket Metadata object.
Definition: bucket_metadata.h:53
friend bool operator!=(BucketMetadata const &lhs, BucketMetadata const &rhs)
Definition: bucket_metadata.h:562
BucketAutoclass const & autoclass() const
Definition: bucket_metadata.h:76
std::string const & rpo() const
Definition: bucket_metadata.h:460
BucketMetadata & set_rpo(std::string v)
Definition: bucket_metadata.h:461
BucketMetadata & set_project_number(std::int64_t v)
Definition: bucket_metadata.h:411
BucketMetadata & set_storage_class(std::string v)
Definition: bucket_metadata.h:470
BucketMetadata & reset_encryption()
Definition: bucket_metadata.h:200
absl::optional< BucketVersioning > const & versioning() const
Definition: bucket_metadata.h:498
absl::optional< BucketEncryption > const & encryption_as_optional() const
Definition: bucket_metadata.h:193
BucketWebsite const & website() const
Definition: bucket_metadata.h:523
BucketMetadata & upsert_label(std::string key, std::string value)
Insert or update the label entry.
Definition: bucket_metadata.h:290
absl::optional< BucketLogging > const & logging_as_optional() const
Definition: bucket_metadata.h:351
BucketMetadata & set_iam_configuration(BucketIamConfiguration v)
Definition: bucket_metadata.h:235
std::string const & storage_class() const
Definition: bucket_metadata.h:469
std::vector< CorsEntry > & mutable_cors()
Definition: bucket_metadata.h:150
std::string const & id() const
Return the bucket id.
Definition: bucket_metadata.h:246
std::string const & location_type() const
Returns the location type (e.g. regional vs. dual region).
Definition: bucket_metadata.h:339
BucketMetadata & set_time_created(std::chrono::system_clock::time_point v)
Definition: bucket_metadata.h:482
BucketMetadata & set_retention_policy(BucketRetentionPolicy v)
Sets the retention period.
Definition: bucket_metadata.h:435
BucketRetentionPolicy const & retention_policy() const
Sets the retention period.
Definition: bucket_metadata.h:428
bool has_autoclass() const
Definition: bucket_metadata.h:75
BucketMetadata & set_website(BucketWebsite v)
Definition: bucket_metadata.h:527
BucketMetadata & reset_autoclass()
Definition: bucket_metadata.h:84
BucketMetadata & reset_logging()
Definition: bucket_metadata.h:358
bool has_label(std::string const &key) const
Returns true if the key is present in the Bucket's metadata labels.
Definition: bucket_metadata.h:266
BucketMetadata & reset_lifecycle()
Definition: bucket_metadata.h:323
absl::optional< BucketRetentionPolicy > const & retention_policy_as_optional() const
Sets the retention period.
Definition: bucket_metadata.h:431
BucketMetadata & set_lifecycle(BucketLifecycle v)
Definition: bucket_metadata.h:319
bool has_lifecycle() const
Definition: bucket_metadata.h:314
absl::optional< BucketLifecycle > const & lifecycle_as_optional() const
Definition: bucket_metadata.h:316
bool has_billing() const
Definition: bucket_metadata.h:96
BucketMetadata & set_owner(Owner v)
Definition: bucket_metadata.h:398
bool has_logging() const
Definition: bucket_metadata.h:349
BucketIamConfiguration const & iam_configuration() const
Definition: bucket_metadata.h:228
std::int64_t metageneration() const
The bucket metageneration.
Definition: bucket_metadata.h:365
bool default_event_based_hold() const
Definition: bucket_metadata.h:129
BucketMetadata & set_default_acl(std::vector< ObjectAccessControl > acl)
Definition: bucket_metadata.h:174
absl::optional< BucketIamConfiguration > const & iam_configuration_as_optional() const
Definition: bucket_metadata.h:231
BucketMetadata & set_cors(std::vector< CorsEntry > cors)
Definition: bucket_metadata.h:151
bool has_versioning() const
Definition: bucket_metadata.h:501
std::string const & label(std::string const &key) const
Returns the value of key in the Bucket's metadata labels.
Definition: bucket_metadata.h:275
BucketMetadata & enable_versioning()
Definition: bucket_metadata.h:502
BucketMetadata & disable_versioning()
Definition: bucket_metadata.h:506
BucketMetadata & set_id(std::string v)
Definition: bucket_metadata.h:249
std::string const & location() const
Return the bucket location.
Definition: bucket_metadata.h:330
bool has_iam_configuration() const
Definition: bucket_metadata.h:227
std::chrono::system_clock::time_point updated() const
Returns the timestamp for the last bucket metadata update.
Definition: bucket_metadata.h:488
BucketMetadata & reset_custom_placement_config()
Placement configuration can only be set when the bucket is created.
Definition: bucket_metadata.h:555
BucketEncryption const & encryption() const
Definition: bucket_metadata.h:192
BucketMetadata & set_location(std::string v)
Set the bucket location. Only applicable when creating buckets.
Definition: bucket_metadata.h:333
bool has_encryption() const
Definition: bucket_metadata.h:191
BucketMetadata & set_encryption(BucketEncryption v)
Definition: bucket_metadata.h:196
bool has_website() const
Definition: bucket_metadata.h:522
BucketMetadata & set_versioning(absl::optional< BucketVersioning > v)
Definition: bucket_metadata.h:514
std::string const & name() const
The bucket name.
Definition: bucket_metadata.h:374
BucketMetadata & reset_retention_policy()
Sets the retention period.
Definition: bucket_metadata.h:452
std::string const & etag() const
Definition: bucket_metadata.h:206
BucketCustomPlacementConfig const & custom_placement_config() const
Placement configuration can only be set when the bucket is created.
Definition: bucket_metadata.h:542
Owner const & owner() const
Returns the owner.
Definition: bucket_metadata.h:395
BucketMetadata & set_autoclass(BucketAutoclass v)
Definition: bucket_metadata.h:80
std::map< std::string, std::string > const & labels() const
Returns all the Bucket's labels.
Definition: bucket_metadata.h:301
BucketMetadata & set_billing(BucketBilling const &v)
Definition: bucket_metadata.h:101
std::vector< ObjectAccessControl > & mutable_default_acl()
Definition: bucket_metadata.h:171
absl::optional< BucketAutoclass > const & autoclass_as_optional() const
Definition: bucket_metadata.h:77
BucketMetadata & set_logging(BucketLogging v)
Definition: bucket_metadata.h:354
std::string const & kind() const
Definition: bucket_metadata.h:254
BucketMetadata & set_name(std::string v)
Changes the name.
Definition: bucket_metadata.h:383
bool has_custom_placement_config() const
Placement configuration can only be set when the bucket is created.
Definition: bucket_metadata.h:539
BucketBilling const & billing() const
Definition: bucket_metadata.h:97
BucketMetadata & reset_iam_configuration()
Definition: bucket_metadata.h:239
BucketMetadata & reset_website()
Definition: bucket_metadata.h:531
absl::optional< BucketBilling > const & billing_as_optional() const
Definition: bucket_metadata.h:98
BucketMetadata & set_acl(std::vector< BucketAccessControl > acl)
Definition: bucket_metadata.h:67
BucketMetadata & set_location_type(std::string v)
Definition: bucket_metadata.h:342
BucketMetadata & set_kind(std::string v)
Definition: bucket_metadata.h:257
std::map< std::string, std::string > & mutable_labels()
Returns all the Bucket's labels.
Definition: bucket_metadata.h:304
BucketMetadata & set_custom_placement_config(BucketCustomPlacementConfig v)
Placement configuration can only be set when the bucket is created.
Definition: bucket_metadata.h:550
bool has_owner() const
Returns true if the bucket owner attribute is present.
Definition: bucket_metadata.h:389
std::vector< BucketAccessControl > & mutable_acl()
Definition: bucket_metadata.h:66
std::vector< CorsEntry > const & cors() const
Definition: bucket_metadata.h:149
BucketMetadata & set_metageneration(std::int64_t v)
Definition: bucket_metadata.h:368
std::int64_t const & project_number() const
Definition: bucket_metadata.h:408
std::chrono::system_clock::time_point time_created() const
Returns the bucket creation timestamp.
Definition: bucket_metadata.h:477
bool has_retention_policy() const
Sets the retention period.
Definition: bucket_metadata.h:427
BucketMetadata & delete_label(std::string const &key)
Delete a label. This is a no-op if the key does not exist.
Definition: bucket_metadata.h:280
absl::optional< BucketWebsite > const & website_as_optional() const
Definition: bucket_metadata.h:524
BucketMetadata & set_self_link(std::string v)
Definition: bucket_metadata.h:420
std::string const & self_link() const
Returns a HTTP link to retrieve the bucket metadata.
Definition: bucket_metadata.h:417
BucketMetadata & reset_versioning()
Definition: bucket_metadata.h:510
BucketLifecycle const & lifecycle() const
Definition: bucket_metadata.h:315
absl::optional< BucketCustomPlacementConfig > const & custom_placement_config_as_optional() const
Placement configuration can only be set when the bucket is created.
Definition: bucket_metadata.h:546
std::vector< ObjectAccessControl > const & default_acl() const
Definition: bucket_metadata.h:168
BucketMetadata & reset_billing()
Definition: bucket_metadata.h:105
std::vector< BucketAccessControl > const & acl() const
Definition: bucket_metadata.h:65
BucketMetadata & set_retention_policy(std::chrono::seconds retention_period)
Sets the retention period.
Definition: bucket_metadata.h:447
friend bool operator==(BucketMetadata const &lhs, BucketMetadata const &rhs)
BucketMetadata & set_default_event_based_hold(bool v)
Definition: bucket_metadata.h:130
BucketMetadata & reset_owner()
Definition: bucket_metadata.h:403
BucketMetadata & set_etag(std::string v)
Definition: bucket_metadata.h:209
BucketMetadata & set_updated(std::chrono::system_clock::time_point v)
Definition: bucket_metadata.h:491
BucketLogging const & logging() const
Definition: bucket_metadata.h:350
Wraps the objectAccessControl resource in Google Cloud Storage.
Definition: object_access_control.h:39
Contains all the Google Cloud Storage C++ client APIs.
Definition: auto_finalize.h:24
The autoclass configuration for a Bucket.
Definition: bucket_autoclass.h:39
The billing configuration for a Bucket.
Definition: bucket_billing.h:32
Configuration for Custom Dual Regions.
Definition: bucket_custom_placement_config.h:39
Describes the default customer managed encryption key for a bucket.
Definition: bucket_encryption.h:38
The IAM configuration for a Bucket.
Definition: bucket_iam_configuration.h:99
The Object Lifecycle configuration for a Bucket.
Definition: bucket_lifecycle.h:34
The Logging configuration for a Bucket.
Definition: bucket_logging.h:35
The retention policy for a bucket.
Definition: bucket_retention_policy.h:41
The versioning configuration for a Bucket.
Definition: bucket_versioning.h:32
BucketVersioning(bool flag)
Definition: bucket_versioning.h:34
The website configuration for a Bucket.
Definition: bucket_website.h:34
An entry in the CORS list.
Definition: bucket_cors_entry.h:48
A simple wrapper for the owner field in object and bucket metadata.
Definition: owner.h:29