Google Cloud Storage C++ Client  1.25.0
A C++ Client Library for Google Cloud Storage
object_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_OBJECT_ACCESS_CONTROL_H
16 #define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_STORAGE_OBJECT_ACCESS_CONTROL_H
17 
18 #include "google/cloud/storage/internal/access_control_common.h"
19 #include "google/cloud/storage/internal/common_metadata.h"
20 #include "google/cloud/storage/internal/patch_builder.h"
22 #include "google/cloud/status_or.h"
23 
24 namespace google {
25 namespace cloud {
26 namespace storage {
27 inline namespace STORAGE_CLIENT_NS {
28 namespace internal {
29 struct ObjectAccessControlParser;
30 class GrpcClient;
31 } // namespace internal
32 
43 class ObjectAccessControl : private internal::AccessControlCommon {
44  public:
45  ObjectAccessControl() = default;
46 
47  using AccessControlCommon::ROLE_OWNER;
48  using AccessControlCommon::ROLE_READER;
49  using AccessControlCommon::TEAM_EDITORS;
50  using AccessControlCommon::TEAM_OWNERS;
51  using AccessControlCommon::TEAM_VIEWERS;
52 
53  using AccessControlCommon::bucket;
54  using AccessControlCommon::domain;
55  using AccessControlCommon::email;
56 
57  using AccessControlCommon::entity;
58  ObjectAccessControl& set_entity(std::string v) {
59  AccessControlCommon::set_entity(std::move(v));
60  return *this;
61  }
62 
63  using AccessControlCommon::entity_id;
64  using AccessControlCommon::etag;
65  using AccessControlCommon::has_project_team;
66  using AccessControlCommon::id;
67  using AccessControlCommon::kind;
68  using AccessControlCommon::project_team;
69  using AccessControlCommon::project_team_as_optional;
70 
71  using AccessControlCommon::role;
72  ObjectAccessControl& set_role(std::string v) {
73  AccessControlCommon::set_role(std::move(v));
74  return *this;
75  }
76 
77  using AccessControlCommon::self_link;
78 
79  std::int64_t generation() const { return generation_; }
80  std::string const& object() const { return object_; }
81 
82  friend bool operator==(ObjectAccessControl const& lhs,
83  ObjectAccessControl const& rhs);
84  friend bool operator!=(ObjectAccessControl const& lhs,
85  ObjectAccessControl const& rhs) {
86  return !(lhs == rhs);
87  }
88 
89  private:
90  friend struct internal::ObjectAccessControlParser;
91  friend class internal::GrpcClient;
92 
93  std::int64_t generation_ = 0;
94  std::string object_;
95 };
96 
97 std::ostream& operator<<(std::ostream& os, ObjectAccessControl const& rhs);
98 
114  public:
116 
117  std::string BuildPatch() const { return impl_.ToString(); }
118 
120  impl_.SetStringField("entity", v);
121  return *this;
122  }
123 
125  impl_.RemoveField("entity");
126  return *this;
127  }
128 
129  ObjectAccessControlPatchBuilder& set_role(std::string const& v) {
130  impl_.SetStringField("role", v);
131  return *this;
132  }
133 
135  impl_.RemoveField("role");
136  return *this;
137  }
138 
139  private:
140  internal::PatchBuilder impl_;
141 };
142 
143 } // namespace STORAGE_CLIENT_NS
144 } // namespace storage
145 } // namespace cloud
146 } // namespace google
147 
148 #endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_STORAGE_OBJECT_ACCESS_CONTROL_H
status_or.h
google::cloud::storage::v1::operator<<
std::ostream & operator<<(std::ostream &os, BucketAccessControl const &rhs)
Definition: bucket_access_control.cc:27
google::cloud::storage::v1::ObjectAccessControlPatchBuilder::set_entity
ObjectAccessControlPatchBuilder & set_entity(std::string const &v)
Definition: object_access_control.h:119
google::cloud::storage::v1::ObjectAccessControlPatchBuilder::set_role
ObjectAccessControlPatchBuilder & set_role(std::string const &v)
Definition: object_access_control.h:129
google::cloud::storage::v1::ObjectAccessControlPatchBuilder::BuildPatch
std::string BuildPatch() const
Definition: object_access_control.h:117
google::cloud::storage::v1::ObjectAccessControl::operator!=
friend bool operator!=(ObjectAccessControl const &lhs, ObjectAccessControl const &rhs)
Definition: object_access_control.h:84
google::cloud::storage::v1::ObjectAccessControl::generation
std::int64_t generation() const
Definition: object_access_control.h:79
version.h
google::cloud::storage::v1::ObjectAccessControl::set_role
ObjectAccessControl & set_role(std::string v)
Definition: object_access_control.h:72
STORAGE_CLIENT_NS
#define STORAGE_CLIENT_NS
Definition: version.h:30
google::cloud::storage::v1::ObjectAccessControl::object
std::string const & object() const
Definition: object_access_control.h:80
google::cloud::storage::v1::operator==
bool operator==(BucketAccessControl const &lhs, BucketAccessControl const &rhs)
Definition: bucket_access_control.cc:22
google::cloud::storage::v1::ObjectAccessControl
Wraps the objectAccessControl resource in Google Cloud Storage.
Definition: object_access_control.h:43
google::cloud::storage::v1::ObjectAccessControl::ObjectAccessControl
ObjectAccessControl()=default
google::cloud::storage::v1::ObjectAccessControlPatchBuilder
Prepares a patch for an ObjectAccessControl resource.
Definition: object_access_control.h:113
google::cloud::storage::v1::ObjectAccessControlPatchBuilder::ObjectAccessControlPatchBuilder
ObjectAccessControlPatchBuilder()=default
google::cloud::storage::v1::ObjectAccessControlPatchBuilder::delete_entity
ObjectAccessControlPatchBuilder & delete_entity()
Definition: object_access_control.h:124
google
google::cloud::storage::v1::ObjectAccessControlPatchBuilder::delete_role
ObjectAccessControlPatchBuilder & delete_role()
Definition: object_access_control.h:134
google::cloud::storage::v1::ObjectAccessControl::set_entity
ObjectAccessControl & set_entity(std::string v)
Definition: object_access_control.h:58