Google Cloud Storage C++ Client  1.25.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 <map>
27 #include <tuple>
28 #include <utility>
29 
30 namespace google {
31 namespace cloud {
32 namespace storage {
33 inline namespace STORAGE_CLIENT_NS {
34 namespace internal {
35 struct BucketMetadataParser;
36 class GrpcClient;
37 } // namespace internal
38 
45 struct BucketBilling {
46  BucketBilling() = default;
47  // NOLINTNEXTLINE(google-explicit-constructor)
48  BucketBilling(bool v) : requester_pays(v) {}
49 
50  bool requester_pays{false};
51 };
52 
53 inline bool operator==(BucketBilling const& lhs, BucketBilling const& rhs) {
54  return lhs.requester_pays == rhs.requester_pays;
55 }
56 
57 inline bool operator<(BucketBilling const& lhs, BucketBilling const& rhs) {
58  return !lhs.requester_pays && rhs.requester_pays;
59 }
60 
61 inline bool operator!=(BucketBilling const& lhs, BucketBilling const& rhs) {
62  return std::rel_ops::operator!=(lhs, rhs);
63 }
64 
65 inline bool operator>(BucketBilling const& lhs, BucketBilling const& rhs) {
66  return std::rel_ops::operator>(lhs, rhs);
67 }
68 
69 inline bool operator<=(BucketBilling const& lhs, BucketBilling const& rhs) {
70  return std::rel_ops::operator<=(lhs, rhs);
71 }
72 
73 inline bool operator>=(BucketBilling const& lhs, BucketBilling const& rhs) {
74  return std::rel_ops::operator>=(lhs, rhs);
75 }
76 
94 struct CorsEntry {
95  absl::optional<std::int64_t> max_age_seconds;
96  std::vector<std::string> method;
97  std::vector<std::string> origin;
98  std::vector<std::string> response_header;
99 };
100 
102 inline bool operator==(CorsEntry const& lhs, CorsEntry const& rhs) {
104  return std::tie(lhs.max_age_seconds, lhs.method, lhs.origin,
105  lhs.response_header) == std::tie(rhs.max_age_seconds,
106  rhs.method, rhs.origin,
107  rhs.response_header);
108 }
109 
110 inline bool operator<(CorsEntry const& lhs, CorsEntry const& rhs) {
111  return std::tie(lhs.max_age_seconds, lhs.method, lhs.origin,
112  lhs.response_header) < std::tie(rhs.max_age_seconds,
113  rhs.method, rhs.origin,
114  rhs.response_header);
115 }
116 
117 inline bool operator!=(CorsEntry const& lhs, CorsEntry const& rhs) {
118  return std::rel_ops::operator!=(lhs, rhs);
119 }
120 
121 inline bool operator>(CorsEntry const& lhs, CorsEntry const& rhs) {
122  return std::rel_ops::operator>(lhs, rhs);
123 }
124 
125 inline bool operator<=(CorsEntry const& lhs, CorsEntry const& rhs) {
126  return std::rel_ops::operator<=(lhs, rhs);
127 }
128 
129 inline bool operator>=(CorsEntry const& lhs, CorsEntry const& rhs) {
130  return std::rel_ops::operator>=(lhs, rhs);
131 }
133 
134 std::ostream& operator<<(std::ostream& os, CorsEntry const& rhs);
135 
149  bool enabled;
150  std::chrono::system_clock::time_point locked_time;
151 };
153 
155 inline bool operator==(UniformBucketLevelAccess const& lhs,
157  UniformBucketLevelAccess const& rhs) {
158  return std::tie(lhs.enabled, lhs.locked_time) ==
159  std::tie(rhs.enabled, rhs.locked_time);
160 }
161 
162 inline bool operator<(UniformBucketLevelAccess const& lhs,
163  UniformBucketLevelAccess const& rhs) {
164  return std::tie(lhs.enabled, lhs.locked_time) <
165  std::tie(rhs.enabled, rhs.locked_time);
166 }
167 
168 inline bool operator!=(UniformBucketLevelAccess const& lhs,
169  UniformBucketLevelAccess const& rhs) {
170  return std::rel_ops::operator!=(lhs, rhs);
171 }
172 
173 inline bool operator>(UniformBucketLevelAccess const& lhs,
174  UniformBucketLevelAccess const& rhs) {
175  return std::rel_ops::operator>(lhs, rhs);
176 }
177 
178 inline bool operator<=(UniformBucketLevelAccess const& lhs,
179  UniformBucketLevelAccess const& rhs) {
180  return std::rel_ops::operator<=(lhs, rhs);
181 }
182 
183 inline bool operator>=(UniformBucketLevelAccess const& lhs,
184  UniformBucketLevelAccess const& rhs) {
185  return std::rel_ops::operator>=(lhs, rhs);
186 }
188 
189 std::ostream& operator<<(std::ostream& os, UniformBucketLevelAccess const& rhs);
190 
207  absl::optional<UniformBucketLevelAccess> uniform_bucket_level_access;
208 };
209 
211 inline bool operator==(BucketIamConfiguration const& lhs,
213  BucketIamConfiguration const& rhs) {
215 }
216 
217 inline bool operator<(BucketIamConfiguration const& lhs,
218  BucketIamConfiguration const& rhs) {
220 }
221 
222 inline bool operator!=(BucketIamConfiguration const& lhs,
223  BucketIamConfiguration const& rhs) {
224  return std::rel_ops::operator!=(lhs, rhs);
225 }
226 
227 inline bool operator>(BucketIamConfiguration const& lhs,
228  BucketIamConfiguration const& rhs) {
229  return std::rel_ops::operator>(lhs, rhs);
230 }
231 
232 inline bool operator<=(BucketIamConfiguration const& lhs,
233  BucketIamConfiguration const& rhs) {
234  return std::rel_ops::operator<=(lhs, rhs);
235 }
236 
237 inline bool operator>=(BucketIamConfiguration const& lhs,
238  BucketIamConfiguration const& rhs) {
239  return std::rel_ops::operator>=(lhs, rhs);
240 }
242 
243 std::ostream& operator<<(std::ostream& os, BucketIamConfiguration const& rhs);
244 
252  std::vector<LifecycleRule> rule;
253 };
254 
256 inline bool operator==(BucketLifecycle const& lhs, BucketLifecycle const& rhs) {
258  return lhs.rule == rhs.rule;
259 }
260 
261 inline bool operator<(BucketLifecycle const& lhs, BucketLifecycle const& rhs) {
262  return lhs.rule < rhs.rule;
263 }
264 
265 inline bool operator!=(BucketLifecycle const& lhs, BucketLifecycle const& rhs) {
266  return std::rel_ops::operator!=(lhs, rhs);
267 }
268 
269 inline bool operator>(BucketLifecycle const& lhs, BucketLifecycle const& rhs) {
270  return std::rel_ops::operator>(lhs, rhs);
271 }
272 
273 inline bool operator<=(BucketLifecycle const& lhs, BucketLifecycle const& rhs) {
274  return std::rel_ops::operator<=(lhs, rhs);
275 }
276 
277 inline bool operator>=(BucketLifecycle const& lhs, BucketLifecycle const& rhs) {
278  return std::rel_ops::operator>=(lhs, rhs);
279 }
281 
289  std::string log_bucket;
290  std::string log_object_prefix;
291 };
292 
293 inline bool operator==(BucketLogging const& lhs, BucketLogging const& rhs) {
294  return std::tie(lhs.log_bucket, lhs.log_object_prefix) ==
295  std::tie(rhs.log_bucket, rhs.log_object_prefix);
296 }
297 
298 inline bool operator<(BucketLogging const& lhs, BucketLogging const& rhs) {
299  return std::tie(lhs.log_bucket, lhs.log_object_prefix) <
300  std::tie(rhs.log_bucket, rhs.log_object_prefix);
301 }
302 
303 inline bool operator!=(BucketLogging const& lhs, BucketLogging const& rhs) {
304  return std::rel_ops::operator!=(lhs, rhs);
305 }
306 
307 inline bool operator>(BucketLogging const& lhs, BucketLogging const& rhs) {
308  return std::rel_ops::operator>(lhs, rhs);
309 }
310 
311 inline bool operator<=(BucketLogging const& lhs, BucketLogging const& rhs) {
312  return std::rel_ops::operator<=(lhs, rhs);
313 }
314 
315 inline bool operator>=(BucketLogging const& lhs, BucketLogging const& rhs) {
316  return std::rel_ops::operator>=(lhs, rhs);
317 }
318 
319 std::ostream& operator<<(std::ostream& os, BucketLogging const& rhs);
320 
334  std::string default_kms_key_name;
335 };
336 
337 inline bool operator==(BucketEncryption const& lhs,
338  BucketEncryption const& rhs) {
339  return lhs.default_kms_key_name == rhs.default_kms_key_name;
340 }
341 
342 inline bool operator<(BucketEncryption const& lhs,
343  BucketEncryption const& rhs) {
345 }
346 
347 inline bool operator!=(BucketEncryption const& lhs,
348  BucketEncryption const& rhs) {
349  return std::rel_ops::operator!=(lhs, rhs);
350 }
351 
352 inline bool operator>(BucketEncryption const& lhs,
353  BucketEncryption const& rhs) {
354  return std::rel_ops::operator>(lhs, rhs);
355 }
356 
357 inline bool operator<=(BucketEncryption const& lhs,
358  BucketEncryption const& rhs) {
359  return std::rel_ops::operator<=(lhs, rhs);
360 }
361 
362 inline bool operator>=(BucketEncryption const& lhs,
363  BucketEncryption const& rhs) {
364  return std::rel_ops::operator>=(lhs, rhs);
365 }
366 
380  std::chrono::seconds retention_period;
381  std::chrono::system_clock::time_point effective_time;
382  bool is_locked;
383 };
384 
385 inline bool operator==(BucketRetentionPolicy const& lhs,
386  BucketRetentionPolicy const& rhs) {
387  return std::tie(lhs.retention_period, lhs.effective_time, lhs.is_locked) ==
388  std::tie(rhs.retention_period, rhs.effective_time, rhs.is_locked);
389 }
390 
391 inline bool operator<(BucketRetentionPolicy const& lhs,
392  BucketRetentionPolicy const& rhs) {
393  return std::tie(lhs.retention_period, lhs.effective_time, lhs.is_locked) <
394  std::tie(rhs.retention_period, rhs.effective_time, rhs.is_locked);
395 }
396 
397 inline bool operator!=(BucketRetentionPolicy const& lhs,
398  BucketRetentionPolicy const& rhs) {
399  return std::rel_ops::operator!=(lhs, rhs);
400 }
401 
402 inline bool operator>(BucketRetentionPolicy const& lhs,
403  BucketRetentionPolicy const& rhs) {
404  return std::rel_ops::operator>(lhs, rhs);
405 }
406 
407 inline bool operator<=(BucketRetentionPolicy const& lhs,
408  BucketRetentionPolicy const& rhs) {
409  return std::rel_ops::operator<=(lhs, rhs);
410 }
411 
412 inline bool operator>=(BucketRetentionPolicy const& lhs,
413  BucketRetentionPolicy const& rhs) {
414  return std::rel_ops::operator>=(lhs, rhs);
415 }
416 
417 std::ostream& operator<<(std::ostream& os, BucketRetentionPolicy const& rhs);
418 
426  BucketVersioning() = default;
427  explicit BucketVersioning(bool flag) : enabled(flag) {}
428 
429  bool enabled{true};
430 };
431 
432 inline bool operator==(BucketVersioning const& lhs,
433  BucketVersioning const& rhs) {
434  return lhs.enabled == rhs.enabled;
435 }
436 
437 inline bool operator<(BucketVersioning const& lhs,
438  BucketVersioning const& rhs) {
439  return !lhs.enabled && rhs.enabled;
440 }
441 
442 inline bool operator!=(BucketVersioning const& lhs,
443  BucketVersioning const& rhs) {
444  return std::rel_ops::operator!=(lhs, rhs);
445 }
446 
447 inline bool operator>(BucketVersioning const& lhs,
448  BucketVersioning const& rhs) {
449  return std::rel_ops::operator>(lhs, rhs);
450 }
451 
452 inline bool operator<=(BucketVersioning const& lhs,
453  BucketVersioning const& rhs) {
454  return std::rel_ops::operator<=(lhs, rhs);
455 }
456 
457 inline bool operator>=(BucketVersioning const& lhs,
458  BucketVersioning const& rhs) {
459  return std::rel_ops::operator>=(lhs, rhs);
460 }
461 
469  std::string main_page_suffix;
470  std::string not_found_page;
471 };
472 
473 inline bool operator==(BucketWebsite const& lhs, BucketWebsite const& rhs) {
474  return std::tie(lhs.main_page_suffix, lhs.not_found_page) ==
475  std::tie(rhs.main_page_suffix, rhs.not_found_page);
476 }
477 
478 inline bool operator<(BucketWebsite const& lhs, BucketWebsite const& rhs) {
479  return std::tie(lhs.main_page_suffix, lhs.not_found_page) <
480  std::tie(rhs.main_page_suffix, rhs.not_found_page);
481 }
482 
483 inline bool operator!=(BucketWebsite const& lhs, BucketWebsite const& rhs) {
484  return std::rel_ops::operator!=(lhs, rhs);
485 }
486 
487 inline bool operator>(BucketWebsite const& lhs, BucketWebsite const& rhs) {
488  return std::rel_ops::operator>(lhs, rhs);
489 }
490 
491 inline bool operator<=(BucketWebsite const& lhs, BucketWebsite const& rhs) {
492  return std::rel_ops::operator<=(lhs, rhs);
493 }
494 
495 inline bool operator>=(BucketWebsite const& lhs, BucketWebsite const& rhs) {
496  return std::rel_ops::operator>=(lhs, rhs);
497 }
498 
502 class BucketMetadata : private internal::CommonMetadata<BucketMetadata> {
503  public:
504  BucketMetadata() = default;
505 
506  // Please keep these in alphabetical order, that make it easier to verify we
507  // have actually implemented all of them.
509 
514  std::vector<BucketAccessControl> const& acl() const { return acl_; }
515  std::vector<BucketAccessControl>& mutable_acl() { return acl_; }
516  BucketMetadata& set_acl(std::vector<BucketAccessControl> acl) {
517  acl_ = std::move(acl);
518  return *this;
519  }
521 
523 
528  bool has_billing() const { return billing_.has_value(); }
529  BucketBilling const& billing() const { return *billing_; }
530  absl::optional<BucketBilling> const& billing_as_optional() const {
531  return billing_;
532  }
534  billing_ = v;
535  return *this;
536  }
538  billing_.reset();
539  return *this;
540  }
542 
544 
561  bool default_event_based_hold() const { return default_event_based_hold_; }
563  default_event_based_hold_ = v;
564  return *this;
565  }
567 
569 
581  std::vector<CorsEntry> const& cors() const { return cors_; }
582  std::vector<CorsEntry>& mutable_cors() { return cors_; }
583  BucketMetadata& set_cors(std::vector<CorsEntry> cors) {
584  cors_ = std::move(cors);
585  return *this;
586  }
588 
590 
600  std::vector<ObjectAccessControl> const& default_acl() const {
601  return default_acl_;
602  }
603  std::vector<ObjectAccessControl>& mutable_default_acl() {
604  return default_acl_;
605  }
606  BucketMetadata& set_default_acl(std::vector<ObjectAccessControl> acl) {
607  default_acl_ = std::move(acl);
608  return *this;
609  }
611 
613 
623  bool has_encryption() const { return encryption_.has_value(); }
624  BucketEncryption const& encryption() const { return *encryption_; }
625  absl::optional<BucketEncryption> const& encryption_as_optional() const {
626  return encryption_;
627  }
629  encryption_ = std::move(v);
630  return *this;
631  }
633  encryption_.reset();
634  return *this;
635  }
637 
638  using CommonMetadata::etag;
639 
641 
653  bool has_iam_configuration() const { return iam_configuration_.has_value(); }
655  return *iam_configuration_;
656  }
657  absl::optional<BucketIamConfiguration> const& iam_configuration_as_optional()
658  const {
659  return iam_configuration_;
660  }
662  iam_configuration_ = std::move(v);
663  return *this;
664  }
666  iam_configuration_.reset();
667  return *this;
668  }
670 
671  using CommonMetadata::id;
672  using CommonMetadata::kind;
673 
675  bool has_label(std::string const& key) const {
677  return labels_.end() != labels_.find(key);
678  }
679  std::string const& label(std::string const& key) const {
680  return labels_.at(key);
681  }
683  BucketMetadata& delete_label(std::string const& key) {
684  auto i = labels_.find(key);
685  if (i == labels_.end()) {
686  return *this;
687  }
688  labels_.erase(i);
689  return *this;
690  }
691 
693  BucketMetadata& upsert_label(std::string key, std::string value) {
694  auto i = labels_.lower_bound(key);
695  if (i == labels_.end() || i->first != key) {
696  labels_.emplace_hint(i, std::move(key), std::move(value));
697  } else {
698  i->second = std::move(value);
699  }
700  return *this;
701  }
702 
703  std::map<std::string, std::string> const& labels() const { return labels_; }
704  std::map<std::string, std::string>& mutable_labels() { return labels_; }
706 
708 
714  bool has_lifecycle() const { return lifecycle_.has_value(); }
715  BucketLifecycle const& lifecycle() const { return *lifecycle_; }
716  absl::optional<BucketLifecycle> const& lifecycle_as_optional() const {
717  return lifecycle_;
718  }
720  lifecycle_ = std::move(v);
721  return *this;
722  }
724  lifecycle_.reset();
725  return *this;
726  }
728 
729  std::string const& location() const { return location_; }
730  BucketMetadata& set_location(std::string v) {
731  location_ = std::move(v);
732  return *this;
733  }
734 
735  std::string const& location_type() const { return location_type_; }
736 
738  bool has_logging() const { return logging_.has_value(); }
740  BucketLogging const& logging() const { return *logging_; }
741  absl::optional<BucketLogging> const& logging_as_optional() const {
742  return logging_;
743  }
745  logging_ = std::move(v);
746  return *this;
747  }
749  logging_.reset();
750  return *this;
751  }
753 
754  using CommonMetadata::metageneration;
755  using CommonMetadata::name;
756  BucketMetadata& set_name(std::string v) {
757  CommonMetadata::set_name(std::move(v));
758  return *this;
759  }
760 
761  using CommonMetadata::has_owner;
762  using CommonMetadata::owner;
763 
764  std::int64_t const& project_number() const { return project_number_; }
765 
766  using CommonMetadata::self_link;
767 
769  bool has_retention_policy() const { return retention_policy_.has_value(); }
772  return *retention_policy_;
773  }
774  absl::optional<BucketRetentionPolicy> const& retention_policy_as_optional()
775  const {
776  return retention_policy_;
777  }
779  retention_policy_ = std::move(v);
780  return *this;
781  }
782 
790  BucketMetadata& set_retention_policy(std::chrono::seconds retention_period) {
791  return set_retention_policy(BucketRetentionPolicy{
792  retention_period, std::chrono::system_clock::time_point{}, false});
793  }
794 
796  retention_policy_.reset();
797  return *this;
798  }
800 
801  using CommonMetadata::storage_class;
803  CommonMetadata::set_storage_class(std::move(v));
804  return *this;
805  }
806 
807  using CommonMetadata::time_created;
808  using CommonMetadata::updated;
809 
811  absl::optional<BucketVersioning> const& versioning() const {
813  return versioning_;
814  }
815  bool has_versioning() const { return versioning_.has_value(); }
817  versioning_.emplace(BucketVersioning{true});
818  return *this;
819  }
821  versioning_.emplace(BucketVersioning{false});
822  return *this;
823  }
825  versioning_.reset();
826  return *this;
827  }
828  BucketMetadata& set_versioning(absl::optional<BucketVersioning> v) {
829  versioning_ = std::move(v);
830  return *this;
831  }
833 
835  bool has_website() const { return website_.has_value(); }
837  BucketWebsite const& website() const { return *website_; }
838  absl::optional<BucketWebsite> const& website_as_optional() const {
839  return website_;
840  }
842  website_ = std::move(v);
843  return *this;
844  }
846  website_.reset();
847  return *this;
848  }
850 
851  friend bool operator==(BucketMetadata const& lhs, BucketMetadata const& rhs);
852  friend bool operator!=(BucketMetadata const& lhs, BucketMetadata const& rhs) {
853  return !(lhs == rhs);
854  }
855 
856  private:
857  friend struct internal::BucketMetadataParser;
858  friend class internal::GrpcClient;
859 
860  friend std::ostream& operator<<(std::ostream& os, BucketMetadata const& rhs);
861  // Keep the fields in alphabetical order.
862  std::vector<BucketAccessControl> acl_;
863  absl::optional<BucketBilling> billing_;
864  std::vector<CorsEntry> cors_;
865  bool default_event_based_hold_ = false;
866  std::vector<ObjectAccessControl> default_acl_;
867  absl::optional<BucketEncryption> encryption_;
868  absl::optional<BucketIamConfiguration> iam_configuration_;
869  std::map<std::string, std::string> labels_;
870  absl::optional<BucketLifecycle> lifecycle_;
871  std::string location_;
872  std::string location_type_;
873  absl::optional<BucketLogging> logging_;
874  std::int64_t project_number_ = 0;
875  absl::optional<BucketRetentionPolicy> retention_policy_;
876  absl::optional<BucketVersioning> versioning_;
877  absl::optional<BucketWebsite> website_;
878 };
879 
880 std::ostream& operator<<(std::ostream& os, BucketMetadata const& rhs);
881 
895  public:
897 
898  std::string BuildPatch() const;
899 
900  BucketMetadataPatchBuilder& SetAcl(std::vector<BucketAccessControl> const& v);
901 
907  BucketMetadataPatchBuilder& ResetAcl();
908 
909  BucketMetadataPatchBuilder& SetBilling(BucketBilling const& v);
910  BucketMetadataPatchBuilder& ResetBilling();
911 
912  BucketMetadataPatchBuilder& SetCors(std::vector<CorsEntry> const& v);
913  BucketMetadataPatchBuilder& ResetCors();
914 
915  BucketMetadataPatchBuilder& SetDefaultEventBasedHold(bool v);
916  BucketMetadataPatchBuilder& ResetDefaultEventBasedHold();
917 
918  BucketMetadataPatchBuilder& SetDefaultAcl(
919  std::vector<ObjectAccessControl> const& v);
920 
926  BucketMetadataPatchBuilder& ResetDefaultAcl();
927 
928  BucketMetadataPatchBuilder& SetIamConfiguration(
929  BucketIamConfiguration const& v);
930  BucketMetadataPatchBuilder& ResetIamConfiguration();
931 
932  BucketMetadataPatchBuilder& SetEncryption(BucketEncryption const& v);
933  BucketMetadataPatchBuilder& ResetEncryption();
934 
935  BucketMetadataPatchBuilder& SetLabel(std::string const& label,
936  std::string const& value);
937  BucketMetadataPatchBuilder& ResetLabel(std::string const& label);
938  BucketMetadataPatchBuilder& ResetLabels();
939 
940  BucketMetadataPatchBuilder& SetLifecycle(BucketLifecycle const& v);
941  BucketMetadataPatchBuilder& ResetLifecycle();
942 
943  BucketMetadataPatchBuilder& SetLogging(BucketLogging const& v);
944  BucketMetadataPatchBuilder& ResetLogging();
945 
946  BucketMetadataPatchBuilder& SetName(std::string const& v);
947  BucketMetadataPatchBuilder& ResetName();
948 
949  BucketMetadataPatchBuilder& SetRetentionPolicy(
950  BucketRetentionPolicy const& v);
952  std::chrono::seconds retention_period) {
953  // This is the only parameter that the application can set, so make it easy
954  // for them to set it.
955  return SetRetentionPolicy(BucketRetentionPolicy{
956  retention_period, std::chrono::system_clock::time_point{}, false});
957  }
958  BucketMetadataPatchBuilder& ResetRetentionPolicy();
959 
960  BucketMetadataPatchBuilder& SetStorageClass(std::string const& v);
961  BucketMetadataPatchBuilder& ResetStorageClass();
962 
963  BucketMetadataPatchBuilder& SetVersioning(BucketVersioning const& v);
964  BucketMetadataPatchBuilder& ResetVersioning();
965 
966  BucketMetadataPatchBuilder& SetWebsite(BucketWebsite const& v);
967  BucketMetadataPatchBuilder& ResetWebsite();
968 
969  private:
970  internal::PatchBuilder impl_;
971  bool labels_subpatch_dirty_{false};
972  internal::PatchBuilder labels_subpatch_;
973 };
974 
975 } // namespace STORAGE_CLIENT_NS
976 } // namespace storage
977 } // namespace cloud
978 } // namespace google
979 
980 #endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_STORAGE_BUCKET_METADATA_H
google::cloud::storage::v1::BucketMetadata::reset_versioning
BucketMetadata & reset_versioning()
Definition: bucket_metadata.h:824
google::cloud::storage::v1::UniformBucketLevelAccess::enabled
bool enabled
Definition: bucket_metadata.h:149
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:693
google::cloud::storage::v1::BucketLogging::log_bucket
std::string log_bucket
Definition: bucket_metadata.h:289
google::cloud::storage::v1::BucketMetadata::billing
BucketBilling const & billing() const
Definition: bucket_metadata.h:529
google::cloud::storage::v1::BucketMetadata::has_encryption
bool has_encryption() const
Definition: bucket_metadata.h:623
google::cloud::storage::v1::BucketVersioning::enabled
bool enabled
Definition: bucket_metadata.h:429
google::cloud::storage::v1::BucketMetadata::reset_retention_policy
BucketMetadata & reset_retention_policy()
Sets the retention period.
Definition: bucket_metadata.h:795
google::cloud::storage::v1::BucketBilling::BucketBilling
BucketBilling(bool v)
Definition: bucket_metadata.h:48
google::cloud::storage::v1::BucketMetadata::iam_configuration_as_optional
absl::optional< BucketIamConfiguration > const & iam_configuration_as_optional() const
Definition: bucket_metadata.h:657
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:703
google::cloud::storage::v1::BucketWebsite
The website configuration for a Bucket.
Definition: bucket_metadata.h:468
google::cloud::storage::v1::BucketMetadata::project_number
std::int64_t const & project_number() const
Definition: bucket_metadata.h:764
google::cloud::storage::v1::BucketLogging
The Logging configuration for a Bucket.
Definition: bucket_metadata.h:288
google::cloud::storage::v1::operator<
bool operator<(BucketBilling const &lhs, BucketBilling const &rhs)
Definition: bucket_metadata.h:57
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:735
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:790
optional.h
google::cloud::storage::v1::BucketMetadata::set_website
BucketMetadata & set_website(BucketWebsite v)
Definition: bucket_metadata.h:841
google::cloud::storage::v1::BucketVersioning::BucketVersioning
BucketVersioning(bool flag)
Definition: bucket_metadata.h:427
google::cloud::storage::v1::operator>
bool operator>(BucketWebsite const &lhs, BucketWebsite const &rhs)
Definition: bucket_metadata.h:487
google::cloud::storage::v1::BucketMetadata::location
std::string const & location() const
Definition: bucket_metadata.h:729
google::cloud::storage::v1::BucketMetadata::cors
std::vector< CorsEntry > const & cors() const
Definition: bucket_metadata.h:581
google::cloud::storage::v1::BucketMetadata::website_as_optional
absl::optional< BucketWebsite > const & website_as_optional() const
Definition: bucket_metadata.h:838
google::cloud::storage::v1::operator>=
bool operator>=(BucketWebsite const &lhs, BucketWebsite const &rhs)
Definition: bucket_metadata.h:495
google::cloud::storage::v1::BucketMetadata::set_acl
BucketMetadata & set_acl(std::vector< BucketAccessControl > acl)
Definition: bucket_metadata.h:516
google::cloud::storage::v1::operator>
bool operator>(BucketBilling const &lhs, BucketBilling const &rhs)
Definition: bucket_metadata.h:65
google::cloud::storage::v1::BucketVersioning::BucketVersioning
BucketVersioning()=default
google::cloud::storage::v1::BucketMetadata::reset_billing
BucketMetadata & reset_billing()
Definition: bucket_metadata.h:537
google::cloud::storage::v1::BucketMetadata::encryption_as_optional
absl::optional< BucketEncryption > const & encryption_as_optional() const
Definition: bucket_metadata.h:625
google::cloud::storage::v1::BucketMetadata::enable_versioning
BucketMetadata & enable_versioning()
Definition: bucket_metadata.h:816
version.h
google::cloud::storage::v1::BucketMetadata::logging
BucketLogging const & logging() const
Definition: bucket_metadata.h:740
object_access_control.h
google::cloud::storage::v1::BucketMetadata::mutable_acl
std::vector< BucketAccessControl > & mutable_acl()
Definition: bucket_metadata.h:515
google::cloud::storage::v1::BucketRetentionPolicy::effective_time
std::chrono::system_clock::time_point effective_time
Definition: bucket_metadata.h:381
google::cloud::storage::v1::BucketMetadata::mutable_default_acl
std::vector< ObjectAccessControl > & mutable_default_acl()
Definition: bucket_metadata.h:603
google::cloud::storage::v1::BucketRetentionPolicy::retention_period
std::chrono::seconds retention_period
Definition: bucket_metadata.h:380
google::cloud::storage::v1::operator!=
bool operator!=(BucketBilling const &lhs, BucketBilling const &rhs)
Definition: bucket_metadata.h:61
google::cloud::storage::v1::BucketLogging::log_object_prefix
std::string log_object_prefix
Definition: bucket_metadata.h:290
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:679
google::cloud::storage::v1::BucketMetadata::retention_policy
BucketRetentionPolicy const & retention_policy() const
Sets the retention period.
Definition: bucket_metadata.h:771
google::cloud::storage::v1::BucketMetadata::website
BucketWebsite const & website() const
Definition: bucket_metadata.h:837
google::cloud::storage::v1::BucketEncryption
Describes the default customer managed encryption key for a bucket.
Definition: bucket_metadata.h:333
google::cloud::storage::v1::BucketMetadata::operator!=
friend bool operator!=(BucketMetadata const &lhs, BucketMetadata const &rhs)
Definition: bucket_metadata.h:852
google::cloud::storage::v1::BucketMetadata::default_acl
std::vector< ObjectAccessControl > const & default_acl() const
Definition: bucket_metadata.h:600
google::cloud::storage::v1::BucketMetadata::lifecycle_as_optional
absl::optional< BucketLifecycle > const & lifecycle_as_optional() const
Definition: bucket_metadata.h:716
google::cloud::storage::v1::BucketMetadata::has_billing
bool has_billing() const
Definition: bucket_metadata.h:528
google::cloud::storage::v1::BucketIamConfiguration
The IAM configuration for a Bucket.
Definition: bucket_metadata.h:206
google::cloud::storage::v1::BucketVersioning
The versioning configuration for a Bucket.
Definition: bucket_metadata.h:425
google::cloud::storage::v1::BucketMetadata::default_event_based_hold
bool default_event_based_hold() const
Definition: bucket_metadata.h:561
google::cloud::storage::v1::BucketMetadata::BucketMetadata
BucketMetadata()=default
google::cloud::storage::v1::BucketMetadata::set_logging
BucketMetadata & set_logging(BucketLogging v)
Definition: bucket_metadata.h:744
google::cloud::storage::v1::BucketMetadata::reset_website
BucketMetadata & reset_website()
Definition: bucket_metadata.h:845
google::cloud::storage::v1::BucketMetadata::set_lifecycle
BucketMetadata & set_lifecycle(BucketLifecycle v)
Definition: bucket_metadata.h:719
google::cloud::storage::v1::BucketMetadata
Represents a Google Cloud Storage Bucket Metadata object.
Definition: bucket_metadata.h:502
google::cloud::storage::v1::operator<=
bool operator<=(BucketWebsite const &lhs, BucketWebsite const &rhs)
Definition: bucket_metadata.h:491
google::cloud::storage::v1::BucketEncryption::default_kms_key_name
std::string default_kms_key_name
Definition: bucket_metadata.h:334
google::cloud::storage::v1::operator!=
bool operator!=(BucketWebsite const &lhs, BucketWebsite const &rhs)
Definition: bucket_metadata.h:483
google::cloud::storage::v1::BucketMetadata::mutable_cors
std::vector< CorsEntry > & mutable_cors()
Definition: bucket_metadata.h:582
google::cloud::storage::v1::BucketMetadataPatchBuilder
Prepares a patch for the Bucket resource.
Definition: bucket_metadata.h:894
google::cloud::storage::v1::BucketLifecycle
The Object Lifecycle configuration for a Bucket.
Definition: bucket_metadata.h:251
google::cloud::storage::v1::CorsEntry::max_age_seconds
absl::optional< std::int64_t > max_age_seconds
Definition: bucket_metadata.h:95
google::cloud::storage::v1::BucketWebsite::not_found_page
std::string not_found_page
Definition: bucket_metadata.h:470
google::cloud::storage::v1::BucketMetadata::reset_encryption
BucketMetadata & reset_encryption()
Definition: bucket_metadata.h:632
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:774
google::cloud::storage::v1::BucketMetadataPatchBuilder::SetRetentionPolicy
BucketMetadataPatchBuilder & SetRetentionPolicy(std::chrono::seconds retention_period)
Definition: bucket_metadata.h:951
google::cloud::storage::v1::BucketBilling::requester_pays
bool requester_pays
Definition: bucket_metadata.h:50
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:715
google::cloud::storage::v1::BucketMetadata::has_versioning
bool has_versioning() const
Definition: bucket_metadata.h:815
google::cloud::storage::v1::BucketMetadata::disable_versioning
BucketMetadata & disable_versioning()
Definition: bucket_metadata.h:820
google::cloud::storage::v1::BucketMetadata::set_encryption
BucketMetadata & set_encryption(BucketEncryption v)
Definition: bucket_metadata.h:628
google::cloud::storage::v1::BucketMetadata::reset_iam_configuration
BucketMetadata & reset_iam_configuration()
Definition: bucket_metadata.h:665
google::cloud::storage::v1::BucketBilling
The billing configuration for a Bucket.
Definition: bucket_metadata.h:45
google::cloud::storage::v1::BucketMetadata::set_versioning
BucketMetadata & set_versioning(absl::optional< BucketVersioning > v)
Definition: bucket_metadata.h:828
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:624
lifecycle_rule.h
google::cloud::storage::v1::CorsEntry
An entry in the CORS list.
Definition: bucket_metadata.h:94
google::cloud::storage::v1::BucketMetadata::set_location
BucketMetadata & set_location(std::string v)
Definition: bucket_metadata.h:730
google::cloud::storage::v1::CorsEntry::origin
std::vector< std::string > origin
Definition: bucket_metadata.h:97
google::cloud::storage::v1::BucketRetentionPolicy::is_locked
bool is_locked
Definition: bucket_metadata.h:382
google::cloud::storage::v1::BucketMetadata::set_default_event_based_hold
BucketMetadata & set_default_event_based_hold(bool v)
Definition: bucket_metadata.h:562
google::cloud::storage::v1::BucketMetadata::set_billing
BucketMetadata & set_billing(BucketBilling const &v)
Definition: bucket_metadata.h:533
google::cloud::storage::v1::BucketMetadata::set_storage_class
BucketMetadata & set_storage_class(std::string v)
Sets the retention period.
Definition: bucket_metadata.h:802
google::cloud::storage::v1::BucketMetadata::set_cors
BucketMetadata & set_cors(std::vector< CorsEntry > cors)
Definition: bucket_metadata.h:583
google::cloud::storage::v1::BucketMetadata::billing_as_optional
absl::optional< BucketBilling > const & billing_as_optional() const
Definition: bucket_metadata.h:530
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:704
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:683
google::cloud::storage::v1::BucketMetadata::reset_lifecycle
BucketMetadata & reset_lifecycle()
Definition: bucket_metadata.h:723
google::cloud::storage::v1::BucketMetadata::set_retention_policy
BucketMetadata & set_retention_policy(BucketRetentionPolicy v)
Sets the retention period.
Definition: bucket_metadata.h:778
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:73
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:207
google::cloud::storage::v1::BucketMetadata::set_name
BucketMetadata & set_name(std::string v)
Definition: bucket_metadata.h:756
google::cloud::storage::v1::UniformBucketLevelAccess::locked_time
std::chrono::system_clock::time_point locked_time
Definition: bucket_metadata.h:150
google::cloud::storage::v1::BucketLifecycle::rule
std::vector< LifecycleRule > rule
Definition: bucket_metadata.h:252
google::cloud::storage::v1::BucketMetadata::reset_logging
BucketMetadata & reset_logging()
Definition: bucket_metadata.h:748
google::cloud::storage::v1::BucketMetadata::iam_configuration
BucketIamConfiguration const & iam_configuration() const
Definition: bucket_metadata.h:654
google::cloud::storage::v1::BucketMetadata::set_default_acl
BucketMetadata & set_default_acl(std::vector< ObjectAccessControl > acl)
Definition: bucket_metadata.h:606
google::cloud::storage::v1::BucketMetadata::has_lifecycle
bool has_lifecycle() const
Definition: bucket_metadata.h:714
google::cloud::storage::v1::BucketRetentionPolicy
The retention policy for a bucket.
Definition: bucket_metadata.h:379
google::cloud::storage::v1::CorsEntry::response_header
std::vector< std::string > response_header
Definition: bucket_metadata.h:98
google::cloud::storage::v1::UniformBucketLevelAccess
Configure if only the IAM policies are used for access control.
Definition: bucket_metadata.h:148
google::cloud::storage::v1::BucketMetadata::acl
std::vector< BucketAccessControl > const & acl() const
Definition: bucket_metadata.h:514
google::cloud::storage::v1::BucketMetadata::set_iam_configuration
BucketMetadata & set_iam_configuration(BucketIamConfiguration v)
Definition: bucket_metadata.h:661
google::cloud::storage::v1::BucketMetadata::has_iam_configuration
bool has_iam_configuration() const
Definition: bucket_metadata.h:653
google::cloud::storage::v1::BucketMetadata::logging_as_optional
absl::optional< BucketLogging > const & logging_as_optional() const
Definition: bucket_metadata.h:741
google
google::cloud::storage::v1::BucketWebsite::main_page_suffix
std::string main_page_suffix
Definition: bucket_metadata.h:469
google::cloud::storage::v1::operator<=
bool operator<=(BucketBilling const &lhs, BucketBilling const &rhs)
Definition: bucket_metadata.h:69
google::cloud::storage::v1::CorsEntry::method
std::vector< std::string > method
Definition: bucket_metadata.h:96