class Google::Cloud::Storage::PolicyV3
end
})
}
expression: expr
description: “description of condition”,
title: “my-condition”,
condition: {
members: [“user:owner@example.com”],
role: “roles/storage.admin”,
p.bindings.insert({
expr = “resource.name.startsWith("projects/_/buckets/bucket-name/objects/prefix-a-")”
p.version = 3 # Must be explicitly set to opt-in to support for conditions.
bucket.policy requested_policy_version: 3 do |p|
bucket.uniform_bucket_level_access? # true
bucket = storage.bucket “my-bucket”
storage = Google::Cloud::Storage.new
require “google/cloud/storage”
@example Using Policy version 3:
end
})
}
expression: expr
description: “description of condition”,
title: “my-condition”,
condition: {
members: [“user:owner@example.com”],
role: “roles/storage.admin”,
p.bindings.insert({
expr = “resource.name.startsWith("projects/_/buckets/bucket-name/objects/prefix-a-")”
p.version = 3
p.version # the value is 1
bucket.policy requested_policy_version: 3 do |p|
bucket.uniform_bucket_level_access = true
bucket = storage.bucket “my-bucket”
storage = Google::Cloud::Storage.new
require “google/cloud/storage”
@example Updating Policy version 1 to version 3:
for a listing of values and patterns for members.
setIamPolicy](cloud.google.com/storage/docs/json_api/v1/buckets/setIamPolicy)
listing of primitive and curated roles. See [Buckets:
[Understanding Roles](cloud.google.com/iam/docs/understanding-roles) for a
an array of members. Conditions can be configured on the {Binding} object. See
@attr [Bindings] bindings Returns the Policy’s bindings object that associate roles with
with ‘requested_policy_version: 3`.
syntax. To obtain instances of this class, call {Google::Cloud::Storage::Bucket#policy}
error. This class may be used to update the Policy version and add bindings with a newer
and {version=}. Attempts to call {#roles} and relate helpers will raise a runtime
A subclass of {Google::Cloud::Storage::Policy} that supports access to {#bindings}
#
def self.from_gapi gapi
- Private: - New Policy from a
def self.from_gapi gapi new gapi.etag, gapi.version, Array(gapi.bindings).map(&:to_h) end
def add(*)
-
(RuntimeError)
- If called on this class.
Other tags:
- Private: - Illegal operation in PolicyV3. Use {#bindings} instead.
def add(*) raise "Illegal operation when using PolicyV1. Use Policy#bindings instead." end
def deep_dup
-
(RuntimeError)
- If called on this class.
Other tags:
- Private: - Illegal operation in PolicyV3. Deprecated in PolicyV1.
def deep_dup raise "Illegal operation when using PolicyV3. Deprecated in PolicyV1." end
def initialize etag, version, bindings
- Private: - Creates a PolicyV3 object.
def initialize etag, version, bindings super etag, version @bindings = Bindings.new @bindings.insert(*bindings) end
def remove(*)
-
(RuntimeError)
- If called on this class.
Other tags:
- Private: - Illegal operation in PolicyV3. Use {#bindings} instead.
def remove(*) raise "Illegal operation when using PolicyV1. Use Policy#bindings instead." end
def role(*)
-
(RuntimeError)
- If called on this class.
Other tags:
- Private: - Illegal operation in PolicyV3. Use {#bindings} instead.
def role(*) raise "Illegal operation when using PolicyV1. Use Policy#bindings instead." end
def roles
-
(RuntimeError)
- If called on this class.
Other tags:
- Private: - Illegal operation in PolicyV3. Use {#bindings} instead.
def roles raise "Illegal operation when using PolicyV1. Use Policy#bindings instead." end
def to_gapi
- Private: - Convert the PolicyV3 to a
def to_gapi Google::Apis::StorageV1::Policy.new( etag: etag, version: version, bindings: bindings.to_gapi ) end
def version= new_version
- Example: Updating Policy version 1 to version 3: -
Other tags:
- See: https://cloud.google.com/iam/docs/policies#versions - Policy versions
Parameters:
-
new_version
(Integer
) -- The syntax schema version of the policy.
def version= new_version if new_version < version raise "new_version (#{new_version}) cannot be less than the current version (#{version})." end @version = new_version end