Class: Google::Cloud::Bigtable::Policy
- Inherits:
-
Object
- Object
- Google::Cloud::Bigtable::Policy
- Defined in:
- lib/google/cloud/bigtable/policy.rb
Overview
Policy
Represents a Cloud IAM Policy for the Bigtable instance resources.
A common pattern for updating a resource's metadata, such as its Policy,
is to read the current data from the service, update the data locally,
and then send the modified data for writing. This pattern may result in
a conflict if two or more processes attempt the sequence simultaneously.
IAM solves this problem with the #etag
property, which is used to verify whether the policy has changed since
the last request. When you make a request to with an etag
value, Cloud
IAM compares the etag
value in the request with the existing etag
value associated with the policy. It writes the policy only if the
etag
values match.
Instance Attribute Summary collapse
-
#etag ⇒ String
Used to verify whether the policy has changed since the last request.
-
#roles ⇒ Hash{String => Array<String>}
The bindings that associate roles with an array of members.
Instance Method Summary collapse
-
#add(role_name, member) ⇒ Object
Convenience method for adding a member to a binding on this policy.
-
#initialize(etag, roles = nil) ⇒ Policy
constructor
Creates a Policy instance.
-
#remove(role_name, member) ⇒ Object
Convenience method for removing a member from a binding on this policy.
-
#role(role_name) ⇒ Array<String>
Convenience method returning the array of members bound to a role in this policy, or an empty array if no value is present for the role in #roles.
Constructor Details
#initialize(etag, roles = nil) ⇒ Policy
Creates a Policy instance.
61 62 63 64 |
# File 'lib/google/cloud/bigtable/policy.rb', line 61 def initialize etag, roles = nil @etag = etag @roles = roles end |
Instance Attribute Details
#etag ⇒ String
Used to verify whether the policy has changed since
the last request. The policy will be written only if the etag
values
match.
55 56 57 |
# File 'lib/google/cloud/bigtable/policy.rb', line 55 def etag @etag end |
#roles ⇒ Hash{String => Array<String>}
The bindings that associate roles with an array of members. See Understanding Roles for a listing of primitive and curated roles.
55 56 57 |
# File 'lib/google/cloud/bigtable/policy.rb', line 55 def roles @roles end |
Instance Method Details
#add(role_name, member) ⇒ Object
Convenience method for adding a member to a binding on this policy. See Understanding Roles for a listing of primitive and curated roles. See Binding for a listing of values and patterns for members.
87 88 89 |
# File 'lib/google/cloud/bigtable/policy.rb', line 87 def add role_name, member role(role_name) << member end |
#remove(role_name, member) ⇒ Object
Convenience method for removing a member from a binding on this policy. See Understanding Roles for a listing of primitive and curated roles.See Binding for a listing of values and patterns for members.
112 113 114 |
# File 'lib/google/cloud/bigtable/policy.rb', line 112 def remove role_name, member role(role_name).delete member end |
#role(role_name) ⇒ Array<String>
Convenience method returning the array of members bound to a role in this policy, or an empty array if no value is present for the role in #roles. See Understanding Roles for a listing of primitive and curated roles. See Binding for a listing of values and patterns for members.
135 136 137 |
# File 'lib/google/cloud/bigtable/policy.rb', line 135 def role role_name roles[role_name] ||= [] end |