Google Cloud Storage C++ Client  1.27.0
A C++ Client Library for Google Cloud Storage
bucket_metadata.h
Go to the documentation of this file.
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 // http://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 
19 #include "google/cloud/storage/internal/common_metadata.h"
20 #include "google/cloud/storage/internal/patch_builder.h"
24 #include "google/cloud/optional.h"
25 #include "absl/types/optional.h"
26 #include <chrono>
27 #include <map>
28 #include <string>
29 #include <tuple>
30 #include <utility>
31 #include <vector>
32 
33 namespace google {
34 namespace cloud {
35 namespace storage {
36 inline namespace STORAGE_CLIENT_NS {
37 namespace internal {
38 struct BucketMetadataParser;
39 class GrpcClient;
40 } // namespace internal
41 
48 struct BucketBilling {
49  BucketBilling() = default;
50  // NOLINTNEXTLINE(google-explicit-constructor)
51  BucketBilling(bool v) : requester_pays(v) {}
52 
53  bool requester_pays{false};
54 };
55 
56 inline bool operator==(BucketBilling const& lhs, BucketBilling const& rhs) {
57  return lhs.requester_pays == rhs.requester_pays;
58 }
59 
60 inline bool operator<(BucketBilling const& lhs, BucketBilling const& rhs) {
61  return !lhs.requester_pays && rhs.requester_pays;
62 }
63 
64 inline bool operator!=(BucketBilling const& lhs, BucketBilling const& rhs) {
65  return std::rel_ops::operator!=(lhs, rhs);
66 }
67 
68 inline bool operator>(BucketBilling const& lhs, BucketBilling const& rhs) {
69  return std::rel_ops::operator>(lhs, rhs);
70 }
71 
72 inline bool operator<=(BucketBilling const& lhs, BucketBilling const& rhs) {
73  return std::rel_ops::operator<=(lhs, rhs);
74 }
75 
76 inline bool operator>=(BucketBilling const& lhs, BucketBilling const& rhs) {
77  return std::rel_ops::operator>=(lhs, rhs);
78 }
79 
97 struct CorsEntry {
98  absl::optional<std::int64_t> max_age_seconds;
99  std::vector<std::string> method;
100  std::vector<std::string> origin;
101  std::vector<std::string> response_header;
102 };
103 
105 inline bool operator==(CorsEntry const& lhs, CorsEntry const& rhs) {
107  return std::tie(lhs.max_age_seconds, lhs.method, lhs.origin,
108  lhs.response_header) == std::tie(rhs.max_age_seconds,
109  rhs.method, rhs.origin,
110  rhs.response_header);
111 }
112 
113 inline bool operator<(CorsEntry const& lhs, CorsEntry const& rhs) {
114  return std::tie(lhs.max_age_seconds, lhs.method, lhs.origin,
115  lhs.response_header) < std::tie(rhs.max_age_seconds,
116  rhs.method, rhs.origin,
117  rhs.response_header);
118 }
119 
120 inline bool operator!=(CorsEntry const& lhs, CorsEntry const& rhs) {
121  return std::rel_ops::operator!=(lhs, rhs);
122 }
123 
124 inline bool operator>(CorsEntry const& lhs, CorsEntry const& rhs) {
125  return std::rel_ops::operator>(lhs, rhs);
126 }
127 
128 inline bool operator<=(CorsEntry const& lhs, CorsEntry const& rhs) {
129  return std::rel_ops::operator<=(lhs, rhs);
130 }
131 
132 inline bool operator>=(CorsEntry const& lhs, CorsEntry const& rhs) {
133  return std::rel_ops::operator>=(lhs, rhs);
134 }
136 
137 std::ostream& operator<<(std::ostream& os, CorsEntry const& rhs);
138 
152  bool enabled;
153  std::chrono::system_clock::time_point locked_time;
154 };
156 
158 inline bool operator==(UniformBucketLevelAccess const& lhs,
160  UniformBucketLevelAccess const& rhs) {
161  return std::tie(lhs.enabled, lhs.locked_time) ==
162  std::tie(rhs.enabled, rhs.locked_time);
163 }
164 
165 inline bool operator<(UniformBucketLevelAccess const& lhs,
166  UniformBucketLevelAccess const& rhs) {
167  return std::tie(lhs.enabled, lhs.locked_time) <
168  std::tie(rhs.enabled, rhs.locked_time);
169 }
170 
171 inline bool operator!=(UniformBucketLevelAccess const& lhs,
172  UniformBucketLevelAccess const& rhs) {
173  return std::rel_ops::operator!=(lhs, rhs);
174 }
175 
176 inline bool operator>(UniformBucketLevelAccess const& lhs,
177  UniformBucketLevelAccess const& rhs) {
178  return std::rel_ops::operator>(lhs, rhs);
179 }
180 
181 inline bool operator<=(UniformBucketLevelAccess const& lhs,
182  UniformBucketLevelAccess const& rhs) {
183  return std::rel_ops::operator<=(lhs, rhs);
184 }
185 
186 inline bool operator>=(UniformBucketLevelAccess const& lhs,
187  UniformBucketLevelAccess const& rhs) {
188  return std::rel_ops::operator>=(lhs, rhs);
189 }
191 
192 std::ostream& operator<<(std::ostream& os, UniformBucketLevelAccess const& rhs);
193 
210  absl::optional<UniformBucketLevelAccess> uniform_bucket_level_access;
211 };
212 
214 inline bool operator==(BucketIamConfiguration const& lhs,
216  BucketIamConfiguration const& rhs) {
218 }
219 
220 inline bool operator<(BucketIamConfiguration const& lhs,
221  BucketIamConfiguration const& rhs) {
223 }
224 
225 inline bool operator!=(BucketIamConfiguration const& lhs,
226  BucketIamConfiguration const& rhs) {
227  return std::rel_ops::operator!=(lhs, rhs);
228 }
229 
230 inline bool operator>(BucketIamConfiguration const& lhs,
231  BucketIamConfiguration const& rhs) {
232  return std::rel_ops::operator>(lhs, rhs);
233 }
234 
235 inline bool operator<=(BucketIamConfiguration const& lhs,
236  BucketIamConfiguration const& rhs) {
237  return std::rel_ops::operator<=(lhs, rhs);
238 }
239 
240 inline bool operator>=(BucketIamConfiguration const& lhs,
241  BucketIamConfiguration const& rhs) {
242  return std::rel_ops::operator>=(lhs, rhs);
243 }
245 
246 std::ostream& operator<<(std::ostream& os, BucketIamConfiguration const& rhs);
247 
255  std::vector<LifecycleRule> rule;
256 };
257 
259 inline bool operator==(BucketLifecycle const& lhs, BucketLifecycle const& rhs) {
261  return lhs.rule == rhs.rule;
262 }
263 
264 inline bool operator<(BucketLifecycle const& lhs, BucketLifecycle const& rhs) {
265  return lhs.rule < rhs.rule;
266 }
267 
268 inline bool operator!=(BucketLifecycle const& lhs, BucketLifecycle const& rhs) {
269  return std::rel_ops::operator!=(lhs, rhs);
270 }
271 
272 inline bool operator>(BucketLifecycle const& lhs, BucketLifecycle const& rhs) {
273  return std::rel_ops::operator>(lhs, rhs);
274 }
275 
276 inline bool operator<=(BucketLifecycle const& lhs, BucketLifecycle const& rhs) {
277  return std::rel_ops::operator<=(lhs, rhs);
278 }
279 
280 inline bool operator>=(BucketLifecycle const& lhs, BucketLifecycle const& rhs) {
281  return std::rel_ops::operator>=(lhs, rhs);
282 }
284 
292  std::string log_bucket;
293  std::string log_object_prefix;
294 };
295 
296 inline bool operator==(BucketLogging const& lhs, BucketLogging const& rhs) {
297  return std::tie(lhs.log_bucket, lhs.log_object_prefix) ==
298  std::tie(rhs.log_bucket, rhs.log_object_prefix);
299 }
300 
301 inline bool operator<(BucketLogging const& lhs, BucketLogging const& rhs) {
302  return std::tie(lhs.log_bucket, lhs.log_object_prefix) <
303  std::tie(rhs.log_bucket, rhs.log_object_prefix);
304 }
305 
306 inline bool operator!=(BucketLogging const& lhs, BucketLogging const& rhs) {
307  return std::rel_ops::operator!=(lhs, rhs);
308 }
309 
310 inline bool operator>(BucketLogging const& lhs, BucketLogging const& rhs) {
311  return std::rel_ops::operator>(lhs, rhs);
312 }
313 
314 inline bool operator<=(BucketLogging const& lhs, BucketLogging const& rhs) {
315  return std::rel_ops::operator<=(lhs, rhs);
316 }
317 
318 inline bool operator>=(BucketLogging const& lhs, BucketLogging const& rhs) {
319  return std::rel_ops::operator>=(lhs, rhs);
320 }
321 
322 std::ostream& operator<<(std::ostream& os, BucketLogging const& rhs);
323 
337  std::string default_kms_key_name;
338 };
339 
340 inline bool operator==(BucketEncryption const& lhs,
341  BucketEncryption const& rhs) {
342  return lhs.default_kms_key_name == rhs.default_kms_key_name;
343 }
344 
345 inline bool operator<(BucketEncryption const& lhs,
346  BucketEncryption const& rhs) {
348 }
349 
350 inline bool operator!=(BucketEncryption const& lhs,
351  BucketEncryption const& rhs) {
352  return std::rel_ops::operator!=(lhs, rhs);
353 }
354 
355 inline bool operator>(BucketEncryption const& lhs,
356  BucketEncryption const& rhs) {
357  return std::rel_ops::operator>(lhs, rhs);
358 }
359 
360 inline bool operator<=(BucketEncryption const& lhs,
361  BucketEncryption const& rhs) {
362  return std::rel_ops::operator<=(lhs, rhs);
363 }
364 
365 inline bool operator>=(BucketEncryption const& lhs,
366  BucketEncryption const& rhs) {
367  return std::rel_ops::operator>=(lhs, rhs);
368 }
369 
383  std::chrono::seconds retention_period;
384  std::chrono::system_clock::time_point effective_time;
385  bool is_locked;
386 };
387 
388 inline bool operator==(BucketRetentionPolicy const& lhs,
389  BucketRetentionPolicy const& rhs) {
390  return std::tie(lhs.retention_period, lhs.effective_time, lhs.is_locked) ==
391  std::tie(rhs.retention_period, rhs.effective_time, rhs.is_locked);
392 }
393 
394 inline bool operator<(BucketRetentionPolicy const& lhs,
395  BucketRetentionPolicy const& rhs) {
396  return std::tie(lhs.retention_period, lhs.effective_time, lhs.is_locked) <
397  std::tie(rhs.retention_period, rhs.effective_time, rhs.is_locked);
398 }
399 
400 inline bool operator!=(BucketRetentionPolicy const& lhs,
401  BucketRetentionPolicy const& rhs) {
402  return std::rel_ops::operator!=(lhs, rhs);
403 }
404 
405 inline bool operator>(BucketRetentionPolicy const& lhs,
406  BucketRetentionPolicy const& rhs) {
407  return std::rel_ops::operator>(lhs, rhs);
408 }
409 
410 inline bool operator<=(BucketRetentionPolicy const& lhs,
411  BucketRetentionPolicy const& rhs) {
412  return std::rel_ops::operator<=(lhs, rhs);
413 }
414 
415 inline bool operator>=(BucketRetentionPolicy const& lhs,
416  BucketRetentionPolicy const& rhs) {
417  return std::rel_ops::operator>=(lhs, rhs);
418 }
419 
420 std::ostream& operator<<(std::ostream& os, BucketRetentionPolicy const& rhs);
421 
429  BucketVersioning() = default;
430  explicit BucketVersioning(bool flag) : enabled(flag) {}
431 
432  bool enabled{true};
433 };
434 
435 inline bool operator==(BucketVersioning const& lhs,
436  BucketVersioning const& rhs) {
437  return lhs.enabled == rhs.enabled;
438 }
439 
440 inline bool operator<(BucketVersioning const& lhs,
441  BucketVersioning const& rhs) {
442  return !lhs.enabled && rhs.enabled;
443 }
444 
445 inline bool operator!=(BucketVersioning const& lhs,
446  BucketVersioning const& rhs) {
447  return std::rel_ops::operator!=(lhs, rhs);
448 }
449 
450 inline bool operator>(BucketVersioning const& lhs,
451  BucketVersioning const& rhs) {
452  return std::rel_ops::operator>(lhs, rhs);
453 }
454 
455 inline bool operator<=(BucketVersioning const& lhs,
456  BucketVersioning const& rhs) {
457  return std::rel_ops::operator<=(lhs, rhs);
458 }
459 
460 inline bool operator>=(BucketVersioning const& lhs,
461  BucketVersioning const& rhs) {
462  return std::rel_ops::operator>=(lhs, rhs);
463 }
464 
472  std::string main_page_suffix;
473  std::string not_found_page;
474 };
475 
476 inline bool operator==(BucketWebsite const& lhs, BucketWebsite const& rhs) {
477  return std::tie(lhs.main_page_suffix, lhs.not_found_page) ==
478  std::tie(rhs.main_page_suffix, rhs.not_found_page);
479 }
480 
481 inline bool operator<(BucketWebsite const& lhs, BucketWebsite const& rhs) {
482  return std::tie(lhs.main_page_suffix, lhs.not_found_page) <
483  std::tie(rhs.main_page_suffix, rhs.not_found_page);
484 }
485 
486 inline bool operator!=(BucketWebsite const& lhs, BucketWebsite const& rhs) {
487  return std::rel_ops::operator!=(lhs, rhs);
488 }
489 
490 inline bool operator>(BucketWebsite const& lhs, BucketWebsite const& rhs) {
491  return std::rel_ops::operator>(lhs, rhs);
492 }
493 
494 inline bool operator<=(BucketWebsite const& lhs, BucketWebsite const& rhs) {
495  return std::rel_ops::operator<=(lhs, rhs);
496 }
497 
498 inline bool operator>=(BucketWebsite const& lhs, BucketWebsite const& rhs) {
499  return std::rel_ops::operator>=(lhs, rhs);
500 }
501 
505 class BucketMetadata : private internal::CommonMetadata<BucketMetadata> {
506  public:
507  BucketMetadata() = default;
508 
509  // Please keep these in alphabetical order, that make it easier to verify we
510  // have actually implemented all of them.
512 
517  std::vector<BucketAccessControl> const& acl() const { return acl_; }
518  std::vector<BucketAccessControl>& mutable_acl() { return acl_; }
519  BucketMetadata& set_acl(std::vector<BucketAccessControl> acl) {
520  acl_ = std::move(acl);
521  return *this;
522  }
524 
526 
531  bool has_billing() const { return billing_.has_value(); }
532  BucketBilling const& billing() const { return *billing_; }
533  absl::optional<BucketBilling> const& billing_as_optional() const {
534  return billing_;
535  }
537  billing_ = v;
538  return *this;
539  }
541  billing_.reset();
542  return *this;
543  }
545 
547 
564  bool default_event_based_hold() const { return default_event_based_hold_; }
566  default_event_based_hold_ = v;
567  return *this;
568  }
570 
572 
584  std::vector<CorsEntry> const& cors() const { return cors_; }
585  std::vector<CorsEntry>& mutable_cors() { return cors_; }
586  BucketMetadata& set_cors(std::vector<CorsEntry> cors) {
587  cors_ = std::move(cors);
588  return *this;
589  }
591 
593 
603  std::vector<ObjectAccessControl> const& default_acl() const {
604  return default_acl_;
605  }
606  std::vector<ObjectAccessControl>& mutable_default_acl() {
607  return default_acl_;
608  }
609  BucketMetadata& set_default_acl(std::vector<ObjectAccessControl> acl) {
610  default_acl_ = std::move(acl);
611  return *this;
612  }
614 
616 
626  bool has_encryption() const { return encryption_.has_value(); }
627  BucketEncryption const& encryption() const { return *encryption_; }
628  absl::optional<BucketEncryption> const& encryption_as_optional() const {
629  return encryption_;
630  }
632  encryption_ = std::move(v);
633  return *this;
634  }
636  encryption_.reset();
637  return *this;
638  }
640 
641  using CommonMetadata::etag;
642 
644 
656  bool has_iam_configuration() const { return iam_configuration_.has_value(); }
658  return *iam_configuration_;
659  }
660  absl::optional<BucketIamConfiguration> const& iam_configuration_as_optional()
661  const {
662  return iam_configuration_;
663  }
665  iam_configuration_ = std::move(v);
666  return *this;
667  }
669  iam_configuration_.reset();
670  return *this;
671  }
673 
674  using CommonMetadata::id;
675  using CommonMetadata::kind;
676 
678  bool has_label(std::string const& key) const {
680  return labels_.end() != labels_.find(key);
681  }
682  std::string const& label(std::string const& key) const {
683  return labels_.at(key);
684  }
686  BucketMetadata& delete_label(std::string const& key) {
687  auto i = labels_.find(key);
688  if (i == labels_.end()) {
689  return *this;
690  }
691  labels_.erase(i);
692  return *this;
693  }
694 
696  BucketMetadata& upsert_label(std::string key, std::string value) {
697  auto i = labels_.lower_bound(key);
698  if (i == labels_.end() || i->first != key) {
699  labels_.emplace_hint(i, std::move(key), std::move(value));
700  } else {
701  i->second = std::move(value);
702  }
703  return *this;
704  }
705 
706  std::map<std::string, std::string> const& labels() const { return labels_; }
707  std::map<std::string, std::string>& mutable_labels() { return labels_; }
709 
711 
717  bool has_lifecycle() const { return lifecycle_.has_value(); }
718  BucketLifecycle const& lifecycle() const { return *lifecycle_; }
719  absl::optional<BucketLifecycle> const& lifecycle_as_optional() const {
720  return lifecycle_;
721  }
723  lifecycle_ = std::move(v);
724  return *this;
725  }
727  lifecycle_.reset();
728  return *this;
729  }
731 
732  std::string const& location() const { return location_; }
733  BucketMetadata& set_location(std::string v) {
734  location_ = std::move(v);
735  return *this;
736  }
737 
738  std::string const& location_type() const { return location_type_; }
739 
741  bool has_logging() const { return logging_.has_value(); }
743  BucketLogging const& logging() const { return *logging_; }
744  absl::optional<BucketLogging> const& logging_as_optional() const {
745  return logging_;
746  }
748  logging_ = std::move(v);
749  return *this;
750  }
752  logging_.reset();
753  return *this;
754  }
756 
757  using CommonMetadata::metageneration;
758  using CommonMetadata::name;
759  BucketMetadata& set_name(std::string v) {
760  CommonMetadata::set_name(std::move(v));
761  return *this;
762  }
763 
764  using CommonMetadata::has_owner;
765  using CommonMetadata::owner;
766 
767  std::int64_t const& project_number() const { return project_number_; }
768 
769  using CommonMetadata::self_link;
770 
772  bool has_retention_policy() const { return retention_policy_.has_value(); }
775  return *retention_policy_;
776  }
777  absl::optional<BucketRetentionPolicy> const& retention_policy_as_optional()
778  const {
779  return retention_policy_;
780  }
782  retention_policy_ = std::move(v);
783  return *this;
784  }
785 
793  BucketMetadata& set_retention_policy(std::chrono::seconds retention_period) {
794  return set_retention_policy(BucketRetentionPolicy{
795  retention_period, std::chrono::system_clock::time_point{}, false});
796  }
797 
799  retention_policy_.reset();
800  return *this;
801  }
803 
804  using CommonMetadata::storage_class;
806  CommonMetadata::set_storage_class(std::move(v));
807  return *this;
808  }
809 
810  using CommonMetadata::time_created;
811  using CommonMetadata::updated;
812 
814  absl::optional<BucketVersioning> const& versioning() const {
816  return versioning_;
817  }
818  bool has_versioning() const { return versioning_.has_value(); }
820  versioning_.emplace(BucketVersioning{true});
821  return *this;
822  }
824  versioning_.emplace(BucketVersioning{false});
825  return *this;
826  }
828  versioning_.reset();
829  return *this;
830  }
831  BucketMetadata& set_versioning(absl::optional<BucketVersioning> v) {
832  versioning_ = std::move(v);
833  return *this;
834  }
836 
838  bool has_website() const { return website_.has_value(); }
840  BucketWebsite const& website() const { return *website_; }
841  absl::optional<BucketWebsite> const& website_as_optional() const {
842  return website_;
843  }
845  website_ = std::move(v);
846  return *this;
847  }
849  website_.reset();
850  return *this;
851  }
853 
854  friend bool operator==(BucketMetadata const& lhs, BucketMetadata const& rhs);
855  friend bool operator!=(BucketMetadata const& lhs, BucketMetadata const& rhs) {
856  return !(lhs == rhs);
857  }
858 
859  private:
860  friend struct internal::BucketMetadataParser;
861  friend class internal::GrpcClient;
862 
863  friend std::ostream& operator<<(std::ostream& os, BucketMetadata const& rhs);
864  // Keep the fields in alphabetical order.
865  std::vector<BucketAccessControl> acl_;
866  absl::optional<BucketBilling> billing_;
867  std::vector<CorsEntry> cors_;
868  bool default_event_based_hold_ = false;
869  std::vector<ObjectAccessControl> default_acl_;
870  absl::optional<BucketEncryption> encryption_;
871  absl::optional<BucketIamConfiguration> iam_configuration_;
872  std::map<std::string, std::string> labels_;
873  absl::optional<BucketLifecycle> lifecycle_;
874  std::string location_;
875  std::string location_type_;
876  absl::optional<BucketLogging> logging_;
877  std::int64_t project_number_ = 0;
878  absl::optional<BucketRetentionPolicy> retention_policy_;
879  absl::optional<BucketVersioning> versioning_;
880  absl::optional<BucketWebsite> website_;
881 };
882 
883 std::ostream& operator<<(std::ostream& os, BucketMetadata const& rhs);
884 
898  public:
900 
901  std::string BuildPatch() const;
902 
903  BucketMetadataPatchBuilder& SetAcl(std::vector<BucketAccessControl> const& v);
904 
910  BucketMetadataPatchBuilder& ResetAcl();
911 
912  BucketMetadataPatchBuilder& SetBilling(BucketBilling const& v);
913  BucketMetadataPatchBuilder& ResetBilling();
914 
915  BucketMetadataPatchBuilder& SetCors(std::vector<CorsEntry> const& v);
916  BucketMetadataPatchBuilder& ResetCors();
917 
918  BucketMetadataPatchBuilder& SetDefaultEventBasedHold(bool v);
919  BucketMetadataPatchBuilder& ResetDefaultEventBasedHold();
920 
921  BucketMetadataPatchBuilder& SetDefaultAcl(
922  std::vector<ObjectAccessControl> const& v);
923 
929  BucketMetadataPatchBuilder& ResetDefaultAcl();
930 
931  BucketMetadataPatchBuilder& SetIamConfiguration(
932  BucketIamConfiguration const& v);
933  BucketMetadataPatchBuilder& ResetIamConfiguration();
934 
935  BucketMetadataPatchBuilder& SetEncryption(BucketEncryption const& v);
936  BucketMetadataPatchBuilder& ResetEncryption();
937 
938  BucketMetadataPatchBuilder& SetLabel(std::string const& label,
939  std::string const& value);
940  BucketMetadataPatchBuilder& ResetLabel(std::string const& label);
941  BucketMetadataPatchBuilder& ResetLabels();
942 
943  BucketMetadataPatchBuilder& SetLifecycle(BucketLifecycle const& v);
944  BucketMetadataPatchBuilder& ResetLifecycle();
945 
946  BucketMetadataPatchBuilder& SetLogging(BucketLogging const& v);
947  BucketMetadataPatchBuilder& ResetLogging();
948 
949  BucketMetadataPatchBuilder& SetName(std::string const& v);
950  BucketMetadataPatchBuilder& ResetName();
951 
952  BucketMetadataPatchBuilder& SetRetentionPolicy(
953  BucketRetentionPolicy const& v);
955  std::chrono::seconds retention_period) {
956  // This is the only parameter that the application can set, so make it easy
957  // for them to set it.
958  return SetRetentionPolicy(BucketRetentionPolicy{
959  retention_period, std::chrono::system_clock::time_point{}, false});
960  }
961  BucketMetadataPatchBuilder& ResetRetentionPolicy();
962 
963  BucketMetadataPatchBuilder& SetStorageClass(std::string const& v);
964  BucketMetadataPatchBuilder& ResetStorageClass();
965 
966  BucketMetadataPatchBuilder& SetVersioning(BucketVersioning const& v);
967  BucketMetadataPatchBuilder& ResetVersioning();
968 
969  BucketMetadataPatchBuilder& SetWebsite(BucketWebsite const& v);
970  BucketMetadataPatchBuilder& ResetWebsite();
971 
972  private:
973  internal::PatchBuilder impl_;
974  bool labels_subpatch_dirty_{false};
975  internal::PatchBuilder labels_subpatch_;
976 };
977 
978 } // namespace STORAGE_CLIENT_NS
979 } // namespace storage
980 } // namespace cloud
981 } // namespace google
982 
983 #endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_STORAGE_BUCKET_METADATA_H
google::cloud::storage::v1::BucketMetadata::reset_versioning
BucketMetadata & reset_versioning()
Definition: bucket_metadata.h:827
google::cloud::storage::v1::UniformBucketLevelAccess::enabled
bool enabled
Definition: bucket_metadata.h:152
google::cloud::storage::v1::BucketMetadata::upsert_label
BucketMetadata & upsert_label(std::string key, std::string value)
Insert or update the label entry.
Definition: bucket_metadata.h:696
google::cloud::storage::v1::BucketLogging::log_bucket
std::string log_bucket
Definition: bucket_metadata.h:292
google::cloud::storage::v1::BucketMetadata::billing
BucketBilling const & billing() const
Definition: bucket_metadata.h:532
google::cloud::storage::v1::BucketMetadata::has_encryption
bool has_encryption() const
Definition: bucket_metadata.h:626
google::cloud::storage::v1::BucketVersioning::enabled
bool enabled
Definition: bucket_metadata.h:432
google::cloud::storage::v1::BucketMetadata::reset_retention_policy
BucketMetadata & reset_retention_policy()
Sets the retention period.
Definition: bucket_metadata.h:798
google::cloud::storage::v1::BucketBilling::BucketBilling
BucketBilling(bool v)
Definition: bucket_metadata.h:51
google::cloud::storage::v1::BucketMetadata::iam_configuration_as_optional
absl::optional< BucketIamConfiguration > const & iam_configuration_as_optional() const
Definition: bucket_metadata.h:660
google::cloud::storage::v1::BucketMetadata::labels
std::map< std::string, std::string > const & labels() const
Delete a label. This is a no-op if the key does not exist.
Definition: bucket_metadata.h:706
google::cloud::storage::v1::BucketWebsite
The website configuration for a Bucket.
Definition: bucket_metadata.h:471
google::cloud::storage::v1::BucketMetadata::project_number
std::int64_t const & project_number() const
Definition: bucket_metadata.h:767
google::cloud::storage::v1::BucketLogging
The Logging configuration for a Bucket.
Definition: bucket_metadata.h:291
google::cloud::storage::v1::operator<
bool operator<(BucketBilling const &lhs, BucketBilling const &rhs)
Definition: bucket_metadata.h:60
google::cloud::storage::v1::operator<<
std::ostream & operator<<(std::ostream &os, BucketAccessControl const &rhs)
Definition: bucket_access_control.cc:27
google::cloud::storage::v1::BucketMetadata::location_type
std::string const & location_type() const
Definition: bucket_metadata.h:738
google::cloud::storage::v1::BucketMetadata::set_retention_policy
BucketMetadata & set_retention_policy(std::chrono::seconds retention_period)
Sets the retention period.
Definition: bucket_metadata.h:793
optional.h
google::cloud::storage::v1::BucketMetadata::set_website
BucketMetadata & set_website(BucketWebsite v)
Definition: bucket_metadata.h:844
google::cloud::storage::v1::BucketVersioning::BucketVersioning
BucketVersioning(bool flag)
Definition: bucket_metadata.h:430
google::cloud::storage::v1::operator>
bool operator>(BucketWebsite const &lhs, BucketWebsite const &rhs)
Definition: bucket_metadata.h:490
google::cloud::storage::v1::BucketMetadata::location
std::string const & location() const
Definition: bucket_metadata.h:732
google::cloud::storage::v1::BucketMetadata::cors
std::vector< CorsEntry > const & cors() const
Definition: bucket_metadata.h:584
google::cloud::storage::v1::BucketMetadata::website_as_optional
absl::optional< BucketWebsite > const & website_as_optional() const
Definition: bucket_metadata.h:841
google::cloud::storage::v1::operator>=
bool operator>=(BucketWebsite const &lhs, BucketWebsite const &rhs)
Definition: bucket_metadata.h:498
google::cloud::storage::v1::BucketMetadata::set_acl
BucketMetadata & set_acl(std::vector< BucketAccessControl > acl)
Definition: bucket_metadata.h:519
google::cloud::storage::v1::operator>
bool operator>(BucketBilling const &lhs, BucketBilling const &rhs)
Definition: bucket_metadata.h:68
google::cloud::storage::v1::BucketVersioning::BucketVersioning
BucketVersioning()=default
google::cloud::storage::v1::BucketMetadata::reset_billing
BucketMetadata & reset_billing()
Definition: bucket_metadata.h:540
google::cloud::storage::v1::BucketMetadata::encryption_as_optional
absl::optional< BucketEncryption > const & encryption_as_optional() const
Definition: bucket_metadata.h:628
google::cloud::storage::v1::BucketMetadata::enable_versioning
BucketMetadata & enable_versioning()
Definition: bucket_metadata.h:819
version.h
google::cloud::storage::v1::BucketMetadata::logging
BucketLogging const & logging() const
Definition: bucket_metadata.h:743
object_access_control.h
google::cloud::storage::v1::BucketMetadata::mutable_acl
std::vector< BucketAccessControl > & mutable_acl()
Definition: bucket_metadata.h:518
google::cloud::storage::v1::BucketRetentionPolicy::effective_time
std::chrono::system_clock::time_point effective_time
Definition: bucket_metadata.h:384
google::cloud::storage::v1::BucketMetadata::mutable_default_acl
std::vector< ObjectAccessControl > & mutable_default_acl()
Definition: bucket_metadata.h:606
google::cloud::storage::v1::BucketRetentionPolicy::retention_period
std::chrono::seconds retention_period
Definition: bucket_metadata.h:383
google::cloud::storage::v1::operator!=
bool operator!=(BucketBilling const &lhs, BucketBilling const &rhs)
Definition: bucket_metadata.h:64
google::cloud::storage::v1::BucketLogging::log_object_prefix
std::string log_object_prefix
Definition: bucket_metadata.h:293
google::cloud::storage::v1::BucketMetadata::label
std::string const & label(std::string const &key) const
Delete a label. This is a no-op if the key does not exist.
Definition: bucket_metadata.h:682
google::cloud::storage::v1::BucketMetadata::retention_policy
BucketRetentionPolicy const & retention_policy() const
Sets the retention period.
Definition: bucket_metadata.h:774
google::cloud::storage::v1::BucketMetadata::website
BucketWebsite const & website() const
Definition: bucket_metadata.h:840
google::cloud::storage::v1::BucketEncryption
Describes the default customer managed encryption key for a bucket.
Definition: bucket_metadata.h:336
google::cloud::storage::v1::BucketMetadata::operator!=
friend bool operator!=(BucketMetadata const &lhs, BucketMetadata const &rhs)
Definition: bucket_metadata.h:855
google::cloud::storage::v1::BucketMetadata::default_acl
std::vector< ObjectAccessControl > const & default_acl() const
Definition: bucket_metadata.h:603
google::cloud::storage::v1::BucketMetadata::lifecycle_as_optional
absl::optional< BucketLifecycle > const & lifecycle_as_optional() const
Definition: bucket_metadata.h:719
google::cloud::storage::v1::BucketMetadata::has_billing
bool has_billing() const
Definition: bucket_metadata.h:531
google::cloud::storage::v1::BucketIamConfiguration
The IAM configuration for a Bucket.
Definition: bucket_metadata.h:209
google::cloud::storage::v1::BucketVersioning
The versioning configuration for a Bucket.
Definition: bucket_metadata.h:428
google::cloud::storage::v1::BucketMetadata::default_event_based_hold
bool default_event_based_hold() const
Definition: bucket_metadata.h:564
google::cloud::storage::v1::BucketMetadata::BucketMetadata
BucketMetadata()=default
google::cloud::storage::v1::BucketMetadata::set_logging
BucketMetadata & set_logging(BucketLogging v)
Definition: bucket_metadata.h:747
google::cloud::storage::v1::BucketMetadata::reset_website
BucketMetadata & reset_website()
Definition: bucket_metadata.h:848
google::cloud::storage::v1::BucketMetadata::set_lifecycle
BucketMetadata & set_lifecycle(BucketLifecycle v)
Definition: bucket_metadata.h:722
google::cloud::storage::v1::BucketMetadata
Represents a Google Cloud Storage Bucket Metadata object.
Definition: bucket_metadata.h:505
google::cloud::storage::v1::operator<=
bool operator<=(BucketWebsite const &lhs, BucketWebsite const &rhs)
Definition: bucket_metadata.h:494
google::cloud::storage::v1::BucketEncryption::default_kms_key_name
std::string default_kms_key_name
Definition: bucket_metadata.h:337
google::cloud::storage::v1::operator!=
bool operator!=(BucketWebsite const &lhs, BucketWebsite const &rhs)
Definition: bucket_metadata.h:486
google::cloud::storage::v1::BucketMetadata::mutable_cors
std::vector< CorsEntry > & mutable_cors()
Definition: bucket_metadata.h:585
google::cloud::storage::v1::BucketMetadataPatchBuilder
Prepares a patch for the Bucket resource.
Definition: bucket_metadata.h:897
google::cloud::storage::v1::BucketLifecycle
The Object Lifecycle configuration for a Bucket.
Definition: bucket_metadata.h:254
google::cloud::storage::v1::CorsEntry::max_age_seconds
absl::optional< std::int64_t > max_age_seconds
Definition: bucket_metadata.h:98
google::cloud::storage::v1::BucketWebsite::not_found_page
std::string not_found_page
Definition: bucket_metadata.h:473
google::cloud::storage::v1::BucketMetadata::reset_encryption
BucketMetadata & reset_encryption()
Definition: bucket_metadata.h:635
google::cloud::storage::v1::BucketMetadata::retention_policy_as_optional
absl::optional< BucketRetentionPolicy > const & retention_policy_as_optional() const
Sets the retention period.
Definition: bucket_metadata.h:777
google::cloud::storage::v1::BucketMetadataPatchBuilder::SetRetentionPolicy
BucketMetadataPatchBuilder & SetRetentionPolicy(std::chrono::seconds retention_period)
Definition: bucket_metadata.h:954
google::cloud::storage::v1::BucketBilling::requester_pays
bool requester_pays
Definition: bucket_metadata.h:53
bucket_access_control.h
google::cloud::storage::v1::BucketMetadataPatchBuilder::BucketMetadataPatchBuilder
BucketMetadataPatchBuilder()=default
google::cloud::storage::v1::BucketMetadata::lifecycle
BucketLifecycle const & lifecycle() const
Definition: bucket_metadata.h:718
google::cloud::storage::v1::BucketMetadata::has_versioning
bool has_versioning() const
Definition: bucket_metadata.h:818
google::cloud::storage::v1::BucketMetadata::disable_versioning
BucketMetadata & disable_versioning()
Definition: bucket_metadata.h:823
google::cloud::storage::v1::BucketMetadata::set_encryption
BucketMetadata & set_encryption(BucketEncryption v)
Definition: bucket_metadata.h:631
google::cloud::storage::v1::BucketMetadata::reset_iam_configuration
BucketMetadata & reset_iam_configuration()
Definition: bucket_metadata.h:668
google::cloud::storage::v1::BucketBilling
The billing configuration for a Bucket.
Definition: bucket_metadata.h:48
google::cloud::storage::v1::BucketMetadata::set_versioning
BucketMetadata & set_versioning(absl::optional< BucketVersioning > v)
Definition: bucket_metadata.h:831
STORAGE_CLIENT_NS
#define STORAGE_CLIENT_NS
Definition: version.h:30
google::cloud::storage::v1::BucketMetadata::encryption
BucketEncryption const & encryption() const
Definition: bucket_metadata.h:627
lifecycle_rule.h
google::cloud::storage::v1::CorsEntry
An entry in the CORS list.
Definition: bucket_metadata.h:97
google::cloud::storage::v1::BucketMetadata::set_location
BucketMetadata & set_location(std::string v)
Definition: bucket_metadata.h:733
google::cloud::storage::v1::CorsEntry::origin
std::vector< std::string > origin
Definition: bucket_metadata.h:100
google::cloud::storage::v1::BucketRetentionPolicy::is_locked
bool is_locked
Definition: bucket_metadata.h:385
google::cloud::storage::v1::BucketMetadata::set_default_event_based_hold
BucketMetadata & set_default_event_based_hold(bool v)
Definition: bucket_metadata.h:565
google::cloud::storage::v1::BucketMetadata::set_billing
BucketMetadata & set_billing(BucketBilling const &v)
Definition: bucket_metadata.h:536
google::cloud::storage::v1::BucketMetadata::set_storage_class
BucketMetadata & set_storage_class(std::string v)
Sets the retention period.
Definition: bucket_metadata.h:805
google::cloud::storage::v1::BucketMetadata::set_cors
BucketMetadata & set_cors(std::vector< CorsEntry > cors)
Definition: bucket_metadata.h:586
google::cloud::storage::v1::BucketMetadata::billing_as_optional
absl::optional< BucketBilling > const & billing_as_optional() const
Definition: bucket_metadata.h:533
google::cloud::storage::v1::BucketMetadata::mutable_labels
std::map< std::string, std::string > & mutable_labels()
Delete a label. This is a no-op if the key does not exist.
Definition: bucket_metadata.h:707
google::cloud::storage::v1::BucketMetadata::delete_label
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:686
google::cloud::storage::v1::BucketMetadata::reset_lifecycle
BucketMetadata & reset_lifecycle()
Definition: bucket_metadata.h:726
google::cloud::storage::v1::BucketMetadata::set_retention_policy
BucketMetadata & set_retention_policy(BucketRetentionPolicy v)
Sets the retention period.
Definition: bucket_metadata.h:781
google::cloud::storage::v1::BucketBilling::BucketBilling
BucketBilling()=default
google::cloud::storage::v1::operator>=
bool operator>=(BucketBilling const &lhs, BucketBilling const &rhs)
Definition: bucket_metadata.h:76
google::cloud::storage::v1::operator==
bool operator==(BucketAccessControl const &lhs, BucketAccessControl const &rhs)
Definition: bucket_access_control.cc:22
google::cloud::storage::v1::BucketIamConfiguration::uniform_bucket_level_access
absl::optional< UniformBucketLevelAccess > uniform_bucket_level_access
Definition: bucket_metadata.h:210
google::cloud::storage::v1::BucketMetadata::set_name
BucketMetadata & set_name(std::string v)
Definition: bucket_metadata.h:759
google::cloud::storage::v1::UniformBucketLevelAccess::locked_time
std::chrono::system_clock::time_point locked_time
Definition: bucket_metadata.h:153
google::cloud::storage::v1::BucketLifecycle::rule
std::vector< LifecycleRule > rule
Definition: bucket_metadata.h:255
google::cloud::storage::v1::BucketMetadata::reset_logging
BucketMetadata & reset_logging()
Definition: bucket_metadata.h:751
google::cloud::storage::v1::BucketMetadata::iam_configuration
BucketIamConfiguration const & iam_configuration() const
Definition: bucket_metadata.h:657
google::cloud::storage::v1::BucketMetadata::set_default_acl
BucketMetadata & set_default_acl(std::vector< ObjectAccessControl > acl)
Definition: bucket_metadata.h:609
google::cloud::storage::v1::BucketMetadata::has_lifecycle
bool has_lifecycle() const
Definition: bucket_metadata.h:717
google::cloud::storage::v1::BucketRetentionPolicy
The retention policy for a bucket.
Definition: bucket_metadata.h:382
google::cloud::storage::v1::CorsEntry::response_header
std::vector< std::string > response_header
Definition: bucket_metadata.h:101
google::cloud::storage::v1::UniformBucketLevelAccess
Configure if only the IAM policies are used for access control.
Definition: bucket_metadata.h:151
google::cloud::storage::v1::BucketMetadata::acl
std::vector< BucketAccessControl > const & acl() const
Definition: bucket_metadata.h:517
google::cloud::storage::v1::BucketMetadata::set_iam_configuration
BucketMetadata & set_iam_configuration(BucketIamConfiguration v)
Definition: bucket_metadata.h:664
google::cloud::storage::v1::BucketMetadata::has_iam_configuration
bool has_iam_configuration() const
Definition: bucket_metadata.h:656
google::cloud::storage::v1::BucketMetadata::logging_as_optional
absl::optional< BucketLogging > const & logging_as_optional() const
Definition: bucket_metadata.h:744
google
google::cloud::storage::v1::BucketWebsite::main_page_suffix
std::string main_page_suffix
Definition: bucket_metadata.h:472
google::cloud::storage::v1::operator<=
bool operator<=(BucketBilling const &lhs, BucketBilling const &rhs)
Definition: bucket_metadata.h:72
google::cloud::storage::v1::CorsEntry::method
std::vector< std::string > method
Definition: bucket_metadata.h:99