Class: Google::Cloud::Storage::Bucket::DefaultAcl
- Inherits:
-
Object
- Object
- Google::Cloud::Storage::Bucket::DefaultAcl
- Defined in:
- lib/google/cloud/storage/bucket/acl.rb
Overview
# Bucket Default Access Control List
Represents a Bucket’s Default Access Control List.
Constant Summary collapse
- RULES =
{ "authenticatedRead" => "authenticatedRead", "auth" => "authenticatedRead", "auth_read" => "authenticatedRead", "authenticated" => "authenticatedRead", "authenticated_read" => "authenticatedRead", "bucketOwnerFullControl" => "bucketOwnerFullControl", "owner_full" => "bucketOwnerFullControl", "bucketOwnerRead" => "bucketOwnerRead", "owner_read" => "bucketOwnerRead", "private" => "private", "projectPrivate" => "projectPrivate", "project_private" => "projectPrivate", "publicRead" => "publicRead", "public" => "publicRead", "public_read" => "publicRead" }
Class Method Summary collapse
Instance Method Summary collapse
-
#add_owner(entity) ⇒ Object
Grants default owner permission to files in the bucket.
-
#add_reader(entity) ⇒ Object
Grants default reader permission to files in the bucket.
-
#auth! ⇒ Object
(also: #authenticatedRead!, #auth_read!, #authenticated!, #authenticated_read!)
Convenience method to apply the default ‘authenticatedRead` predefined ACL rule to files in the bucket.
-
#delete(entity) ⇒ Object
Permanently deletes the entity from the bucket’s default access control list for files.
-
#initialize(bucket) ⇒ DefaultAcl
constructor
Must provide a valid Bucket object.
-
#owner_full! ⇒ Object
(also: #bucketOwnerFullControl!)
Convenience method to apply the default ‘bucketOwnerFullControl` predefined ACL rule to files in the bucket.
-
#owner_read! ⇒ Object
(also: #bucketOwnerRead!)
Convenience method to apply the default ‘bucketOwnerRead` predefined ACL rule to files in the bucket.
-
#owners ⇒ Array<String>
Lists the default owners for files in the bucket.
-
#private! ⇒ Object
Convenience method to apply the default ‘private` predefined ACL rule to files in the bucket.
-
#project_private! ⇒ Object
(also: #projectPrivate!)
Convenience method to apply the default ‘projectPrivate` predefined ACL rule to files in the bucket.
-
#public! ⇒ Object
(also: #publicRead!, #public_read!)
Convenience method to apply the default ‘publicRead` predefined ACL rule to files in the bucket.
-
#readers ⇒ Array<String>
Lists the default readers for files in the bucket.
-
#reload! ⇒ Object
(also: #refresh!)
Reloads all Default Access Control List data for the bucket.
Constructor Details
#initialize(bucket) ⇒ DefaultAcl
Must provide a valid Bucket object.
455 456 457 458 459 460 |
# File 'lib/google/cloud/storage/bucket/acl.rb', line 455 def initialize bucket @bucket = bucket.name @service = bucket.service @owners = nil @readers = nil end |
Class Method Details
.predefined_rule_for(rule_name) ⇒ Object
642 643 644 |
# File 'lib/google/cloud/storage/bucket/acl.rb', line 642 def self.predefined_rule_for rule_name RULES[rule_name.to_s] end |
Instance Method Details
#add_owner(entity) ⇒ Object
Grants default owner permission to files in the bucket.
559 560 561 562 563 564 |
# File 'lib/google/cloud/storage/bucket/acl.rb', line 559 def add_owner entity gapi = @service.insert_default_acl @bucket, entity, "OWNER" entity = gapi.entity @owners.push entity unless @owners.nil? entity end |
#add_reader(entity) ⇒ Object
Grants default reader permission to files in the bucket.
601 602 603 604 605 606 |
# File 'lib/google/cloud/storage/bucket/acl.rb', line 601 def add_reader entity gapi = @service.insert_default_acl @bucket, entity, "READER" entity = gapi.entity @readers.push entity unless @readers.nil? entity end |
#auth! ⇒ Object Also known as: authenticatedRead!, auth_read!, authenticated!, authenticated_read!
Convenience method to apply the default ‘authenticatedRead` predefined ACL rule to files in the bucket.
661 662 663 |
# File 'lib/google/cloud/storage/bucket/acl.rb', line 661 def auth! update_predefined_default_acl! "authenticatedRead" end |
#delete(entity) ⇒ Object
Permanently deletes the entity from the bucket’s default access control list for files.
634 635 636 637 638 639 |
# File 'lib/google/cloud/storage/bucket/acl.rb', line 634 def delete entity @service.delete_default_acl @bucket, entity @owners.delete entity unless @owners.nil? @readers.delete entity unless @readers.nil? true end |
#owner_full! ⇒ Object Also known as: bucketOwnerFullControl!
Convenience method to apply the default ‘bucketOwnerFullControl` predefined ACL rule to files in the bucket.
682 683 684 |
# File 'lib/google/cloud/storage/bucket/acl.rb', line 682 def owner_full! update_predefined_default_acl! "bucketOwnerFullControl" end |
#owner_read! ⇒ Object Also known as: bucketOwnerRead!
Convenience method to apply the default ‘bucketOwnerRead` predefined ACL rule to files in the bucket.
700 701 702 |
# File 'lib/google/cloud/storage/bucket/acl.rb', line 700 def owner_read! update_predefined_default_acl! "bucketOwnerRead" end |
#owners ⇒ Array<String>
Lists the default owners for files in the bucket.
500 501 502 503 |
# File 'lib/google/cloud/storage/bucket/acl.rb', line 500 def owners reload! if @owners.nil? @owners end |
#private! ⇒ Object
Convenience method to apply the default ‘private` predefined ACL rule to files in the bucket.
718 719 720 |
# File 'lib/google/cloud/storage/bucket/acl.rb', line 718 def private! update_predefined_default_acl! "private" end |
#project_private! ⇒ Object Also known as: projectPrivate!
Convenience method to apply the default ‘projectPrivate` predefined ACL rule to files in the bucket.
735 736 737 |
# File 'lib/google/cloud/storage/bucket/acl.rb', line 735 def project_private! update_predefined_default_acl! "projectPrivate" end |
#public! ⇒ Object Also known as: publicRead!, public_read!
Convenience method to apply the default ‘publicRead` predefined ACL rule to files in the bucket.
753 754 755 |
# File 'lib/google/cloud/storage/bucket/acl.rb', line 753 def public! update_predefined_default_acl! "publicRead" end |
#readers ⇒ Array<String>
Lists the default readers for files in the bucket.
519 520 521 522 |
# File 'lib/google/cloud/storage/bucket/acl.rb', line 519 def readers reload! if @readers.nil? @readers end |
#reload! ⇒ Object Also known as: refresh!
Reloads all Default Access Control List data for the bucket.
474 475 476 477 478 479 480 481 482 483 |
# File 'lib/google/cloud/storage/bucket/acl.rb', line 474 def reload! gapi = @service.list_default_acls @bucket acls = Array(gapi.items).map do |acl| next acl if acl.is_a? Google::Apis::StorageV1::ObjectAccessControl fail "Unknown ACL format: #{acl.class}" unless acl.is_a? Hash Google::Apis::StorageV1::ObjectAccessControl.from_json acl.to_json end @owners = entities_from_acls acls, "OWNER" @readers = entities_from_acls acls, "READER" end |