Google Cloud Storage C++ Client  1.24.0
A C++ Client Library for Google Cloud Storage
bucket_access_control.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_ACCESS_CONTROL_H
16 #define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_STORAGE_BUCKET_ACCESS_CONTROL_H
17 
18 #include "google/cloud/storage/internal/access_control_common.h"
19 #include "google/cloud/storage/internal/patch_builder.h"
21 #include "google/cloud/status_or.h"
22 
23 namespace google {
24 namespace cloud {
25 namespace storage {
26 inline namespace STORAGE_CLIENT_NS {
27 namespace internal {
28 struct BucketAccessControlParser;
29 } // namespace internal
30 
41 class BucketAccessControl : private internal::AccessControlCommon {
42  public:
43  BucketAccessControl() = default;
44 
45  using AccessControlCommon::ROLE_OWNER;
46  using AccessControlCommon::ROLE_READER;
47  using AccessControlCommon::TEAM_EDITORS;
48  using AccessControlCommon::TEAM_OWNERS;
49  using AccessControlCommon::TEAM_VIEWERS;
50 
51  using AccessControlCommon::bucket;
52  using AccessControlCommon::domain;
53  using AccessControlCommon::email;
54 
55  using AccessControlCommon::entity;
56  BucketAccessControl& set_entity(std::string v) {
57  AccessControlCommon::set_entity(std::move(v));
58  return *this;
59  }
60 
61  using AccessControlCommon::entity_id;
62  using AccessControlCommon::etag;
63  using AccessControlCommon::has_project_team;
64  using AccessControlCommon::id;
65  using AccessControlCommon::kind;
66  using AccessControlCommon::project_team;
67 
68  using AccessControlCommon::role;
69  BucketAccessControl& set_role(std::string v) {
70  AccessControlCommon::set_role(std::move(v));
71  return *this;
72  }
73 
74  using AccessControlCommon::self_link;
75 
76  friend bool operator==(BucketAccessControl const& lhs,
77  BucketAccessControl const& rhs);
78  friend bool operator!=(BucketAccessControl const& lhs,
79  BucketAccessControl const& rhs) {
80  return !(lhs == rhs);
81  }
82 
83  friend struct internal::BucketAccessControlParser;
84  friend class internal::GrpcClient;
85 };
86 
87 std::ostream& operator<<(std::ostream& os, BucketAccessControl const& rhs);
88 
104  public:
106 
107  std::string BuildPatch() const { return impl_.ToString(); }
108 
110  impl_.SetStringField("entity", v);
111  return *this;
112  }
113 
115  impl_.RemoveField("entity");
116  return *this;
117  }
118 
119  BucketAccessControlPatchBuilder& set_role(std::string const& v) {
120  impl_.SetStringField("role", v);
121  return *this;
122  }
123 
125  impl_.RemoveField("role");
126  return *this;
127  }
128 
129  private:
130  internal::PatchBuilder impl_;
131 };
132 
133 } // namespace STORAGE_CLIENT_NS
134 } // namespace storage
135 } // namespace cloud
136 } // namespace google
137 
138 #endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_STORAGE_BUCKET_ACCESS_CONTROL_H
google::cloud::storage::v1::BucketAccessControl::BucketAccessControl
BucketAccessControl()=default
status_or.h
google::cloud::storage::v1::BucketAccessControlPatchBuilder::BuildPatch
std::string BuildPatch() const
Definition: bucket_access_control.h:107
google::cloud::storage::v1::operator<<
std::ostream & operator<<(std::ostream &os, BucketAccessControl const &rhs)
Definition: bucket_access_control.cc:27
google::cloud::storage::v1::BucketAccessControlPatchBuilder
Prepares a patch for a BucketAccessControl resource.
Definition: bucket_access_control.h:103
version.h
google::cloud::storage::v1::BucketAccessControlPatchBuilder::BucketAccessControlPatchBuilder
BucketAccessControlPatchBuilder()=default
google::cloud::storage::v1::BucketAccessControl::operator!=
friend bool operator!=(BucketAccessControl const &lhs, BucketAccessControl const &rhs)
Definition: bucket_access_control.h:78
google::cloud::storage::v1::BucketAccessControl::set_role
BucketAccessControl & set_role(std::string v)
Definition: bucket_access_control.h:69
google::cloud::storage::v1::BucketAccessControl::set_entity
BucketAccessControl & set_entity(std::string v)
Definition: bucket_access_control.h:56
google::cloud::storage::v1::BucketAccessControlPatchBuilder::set_entity
BucketAccessControlPatchBuilder & set_entity(std::string const &v)
Definition: bucket_access_control.h:109
google::cloud::storage::v1::BucketAccessControlPatchBuilder::set_role
BucketAccessControlPatchBuilder & set_role(std::string const &v)
Definition: bucket_access_control.h:119
google::cloud::storage::v1::BucketAccessControlPatchBuilder::delete_entity
BucketAccessControlPatchBuilder & delete_entity()
Definition: bucket_access_control.h:114
STORAGE_CLIENT_NS
#define STORAGE_CLIENT_NS
Definition: version.h:22
google::cloud::storage::v1::operator==
bool operator==(BucketAccessControl const &lhs, BucketAccessControl const &rhs)
Definition: bucket_access_control.cc:22
google::cloud::storage::v1::BucketAccessControl
Wraps the bucketAccessControl resource in Google Cloud Storage.
Definition: bucket_access_control.h:41
google::cloud::storage::v1::BucketAccessControlPatchBuilder::delete_role
BucketAccessControlPatchBuilder & delete_role()
Definition: bucket_access_control.h:124
google