Class: Gcloud::Storage::Bucket::DefaultAcl
- Inherits:
-
Object
- Object
- Gcloud::Storage::Bucket::DefaultAcl
- Defined in:
- lib/gcloud/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.
-
#add_writer(entity) ⇒ Object
Grants default writer 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.
-
#writers ⇒ Array<String>
Lists the default writers for files in the bucket.
Constructor Details
#initialize(bucket) ⇒ DefaultAcl
Must provide a valid Bucket object.
487 488 489 490 491 492 493 |
# File 'lib/gcloud/storage/bucket/acl.rb', line 487 def initialize bucket @bucket = bucket.name @connection = bucket.connection @owners = nil @writers = nil @readers = nil end |
Class Method Details
.predefined_rule_for(rule_name) ⇒ Object
757 758 759 |
# File 'lib/gcloud/storage/bucket/acl.rb', line 757 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.
614 615 616 617 618 619 620 621 622 |
# File 'lib/gcloud/storage/bucket/acl.rb', line 614 def add_owner entity resp = @connection.insert_default_acl @bucket, entity, "OWNER" if resp.success? entity = resp.data["entity"] @owners.push entity unless @owners.nil? return entity end nil end |
#add_reader(entity) ⇒ Object
Grants default reader permission to files in the bucket.
708 709 710 711 712 713 714 715 716 |
# File 'lib/gcloud/storage/bucket/acl.rb', line 708 def add_reader entity resp = @connection.insert_default_acl @bucket, entity, "READER" if resp.success? entity = resp.data["entity"] @readers.push entity unless @readers.nil? return entity end nil end |
#add_writer(entity) ⇒ Object
Grants default writer permission to files in the bucket.
661 662 663 664 665 666 667 668 669 |
# File 'lib/gcloud/storage/bucket/acl.rb', line 661 def add_writer entity resp = @connection.insert_default_acl @bucket, entity, "WRITER" if resp.success? entity = resp.data["entity"] @writers.push entity unless @writers.nil? return entity end nil 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.
777 778 779 |
# File 'lib/gcloud/storage/bucket/acl.rb', line 777 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.
745 746 747 748 749 750 751 752 753 754 |
# File 'lib/gcloud/storage/bucket/acl.rb', line 745 def delete entity resp = @connection.delete_default_acl @bucket, entity if resp.success? @owners.delete entity unless @owners.nil? @writers.delete entity unless @writers.nil? @readers.delete entity unless @readers.nil? return true end false end |
#owner_full! ⇒ Object Also known as: bucketOwnerFullControl!
Convenience method to apply the default ‘bucketOwnerFullControl` predefined ACL rule to files in the bucket.
799 800 801 |
# File 'lib/gcloud/storage/bucket/acl.rb', line 799 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.
818 819 820 |
# File 'lib/gcloud/storage/bucket/acl.rb', line 818 def owner_read! update_predefined_default_acl! "bucketOwnerRead" end |
#owners ⇒ Array<String>
Lists the default owners for files in the bucket.
532 533 534 535 |
# File 'lib/gcloud/storage/bucket/acl.rb', line 532 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.
837 838 839 |
# File 'lib/gcloud/storage/bucket/acl.rb', line 837 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.
855 856 857 |
# File 'lib/gcloud/storage/bucket/acl.rb', line 855 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.
874 875 876 |
# File 'lib/gcloud/storage/bucket/acl.rb', line 874 def public! update_predefined_default_acl! "publicRead" end |
#readers ⇒ Array<String>
Lists the default readers for files in the bucket.
572 573 574 575 |
# File 'lib/gcloud/storage/bucket/acl.rb', line 572 def readers reload! if @readers.nil? @readers end |
#reload! ⇒ Object Also known as: refresh!
Reloads all Default Access Control List data for the bucket.
508 509 510 511 512 513 514 |
# File 'lib/gcloud/storage/bucket/acl.rb', line 508 def reload! resp = @connection.list_default_acls @bucket acls = resp.data["items"] @owners = entities_from_acls acls, "OWNER" @writers = entities_from_acls acls, "WRITER" @readers = entities_from_acls acls, "READER" end |
#writers ⇒ Array<String>
Lists the default writers for files in the bucket.
552 553 554 555 |
# File 'lib/gcloud/storage/bucket/acl.rb', line 552 def writers reload! if @writers.nil? @writers end |