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