15 #ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_IAM_BINDINGS_H_ 16 #define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_IAM_BINDINGS_H_ 18 #include "google/cloud/iam_binding.h" 19 #include "google/cloud/version.h" 40 for (
auto& it : bindings) {
45 IamBindings(std::string
const& role, std::set<std::string>
const& members) {
46 bindings_.insert({std::move(role), std::move(members)});
49 using iterator = std::map<std::string, std::set<std::string>>::const_iterator;
55 iterator
begin()
const {
return bindings_.begin(); }
61 iterator
end()
const {
return bindings_.end(); }
68 bool empty()
const {
return bindings_.empty(); }
75 std::size_t
size()
const {
return bindings_.size(); }
77 std::map<std::string, std::set<std::string>>
const&
bindings()
const {
84 iterator
find(std::string
const& role)
const {
return bindings_.find(role); }
87 std::set<std::string>
at(std::string
const& role)
const {
88 auto loc = bindings_.find(role);
89 if (loc == bindings_.end()) {
103 void AddMember(std::string
const& role, std::string member);
123 std::set<std::string>
const& members);
133 void RemoveMember(std::string
const& role, std::string
const& member);
151 std::set<std::string>
const& members);
154 return bindings_ == rhs.bindings_;
158 return bindings_ < rhs.bindings_;
162 return std::rel_ops::operator!=(*
this, rhs);
166 return std::rel_ops::operator>(*
this, rhs);
170 return std::rel_ops::operator<=(*
this, rhs);
174 return std::rel_ops::operator>=(*
this, rhs);
178 std::map<std::string, std::set<std::string>> bindings_;
181 std::ostream& operator<<(std::ostream& os,
IamBindings const& rhs);
void AddMembers(google::cloud::IamBinding const &iam_binding)
Adds a new key-value pair of role and members to the container if there is none for the role of given...
#define GOOGLE_CLOUD_CPP_NS
Contains all the Google Cloud C++ Library APIs.
bool operator<(IamBindings const &rhs) const
void AddMembers(std::string const &role, std::set< std::string > const &members)
Adds a new key-value pair of role and members to the container if there no existing for given role el...
void RemoveMembers(std::string const &role, std::set< std::string > const &members)
Removes the given members from given role's member set if there exists one in container.
IamBindings(std::vector< IamBinding > bindings)
std::set< std::string > at(std::string const &role) const
Returns the members for a role.
bool operator>(IamBindings const &rhs) const
void AddMember(std::string const &role, std::string member)
Adds a new member if a binding exists with given role otherwise inserts a new key-value pair of role ...
std::size_t size() const
Return number of Bindings in container.
void RemoveMembers(google::cloud::IamBinding const &iam_binding)
Removes the given binding's member from the given binding's role's member set if there exists one in ...
iterator end() const
Returns an iterator referring to the past-the-end element in IamBindings container.
void RemoveMember(std::string const &role, std::string const &member)
Removes the given member from the given role's member set if there exists one in container.
IamBindings(std::string const &role, std::set< std::string > const &members)
std::map< std::string, std::set< std::string > > const & bindings() const
bool empty() const
Returns whether the Bindings container is empty.
bool operator>=(IamBindings const &rhs) const
std::set< std::string > const & members() const
iterator find(std::string const &role) const
Finds the members for a role.
std::string const & role() const
bool operator<=(IamBindings const &rhs) const
Represents a container for providing users with a handful of operation to users which they can use to...
iterator begin() const
Returns an iterator referring to the first element in IamBindings container.
bool operator!=(IamBindings const &rhs) const
bool operator==(IamBindings const &rhs) const
Represents a Binding which associates a member with a particular role which can be used for Identity ...