Class: Google::Cloud::Storage::File::Acl
- Inherits:
 - 
      Object
      
        
- Object
 - Google::Cloud::Storage::File::Acl
 
 
- Defined in:
 - lib/google/cloud/storage/file/acl.rb
 
Overview
File Access Control List
Represents a File's Access Control List.
Instance Attribute Summary collapse
- 
  
    
      #user_project  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    
A boolean value or a project ID string to indicate the project to be billed for operations on the bucket and its files.
 
Instance Method Summary collapse
- 
  
    
      #add_owner(entity, generation: nil)  ⇒ String 
    
    
  
  
  
  
  
  
  
  
  
    
Grants owner permission to the file.
 - 
  
    
      #add_reader(entity, generation: nil)  ⇒ String 
    
    
  
  
  
  
  
  
  
  
  
    
Grants reader permission to the file.
 - 
  
    
      #auth!  ⇒ Object 
    
    
      (also: #authenticatedRead!, #auth_read!, #authenticated!, #authenticated_read!)
    
  
  
  
  
  
  
  
  
  
    
Convenience method to apply the
authenticatedReadpredefined ACL rule to the file. - 
  
    
      #delete(entity, generation: nil)  ⇒ Boolean 
    
    
  
  
  
  
  
  
  
  
  
    
Permanently deletes the entity from the file's access control list.
 - 
  
    
      #owner_full!  ⇒ Object 
    
    
      (also: #bucketOwnerFullControl!)
    
  
  
  
  
  
  
  
  
  
    
Convenience method to apply the
bucketOwnerFullControlpredefined ACL rule to the file. - 
  
    
      #owner_read!  ⇒ Object 
    
    
      (also: #bucketOwnerRead!)
    
  
  
  
  
  
  
  
  
  
    
Convenience method to apply the
bucketOwnerReadpredefined ACL rule to the file. - 
  
    
      #owners  ⇒ Array<String> 
    
    
  
  
  
  
  
  
  
  
  
    
Lists the owners of the file.
 - 
  
    
      #private!  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Convenience method to apply the
privatepredefined ACL rule to the file. - 
  
    
      #project_private!  ⇒ Object 
    
    
      (also: #projectPrivate!)
    
  
  
  
  
  
  
  
  
  
    
Convenience method to apply the
projectPrivatepredefined ACL rule to the file. - 
  
    
      #public!  ⇒ Object 
    
    
      (also: #publicRead!, #public_read!)
    
  
  
  
  
  
  
  
  
  
    
Convenience method to apply the
publicReadpredefined ACL rule to the file. - 
  
    
      #readers  ⇒ Array<String> 
    
    
  
  
  
  
  
  
  
  
  
    
Lists the readers of the file.
 - 
  
    
      #reload!  ⇒ Object 
    
    
      (also: #refresh!)
    
  
  
  
  
  
  
  
  
  
    
Reloads all Access Control List data for the file.
 
Instance Attribute Details
#user_project ⇒ Object
A boolean value or a project ID string to indicate the project to
be billed for operations on the bucket and its files. If this
attribute is set to true, transit costs for operations on the
bucket will be billed to the current project for this client. (See
Project#project for the ID of the current project.) If this
attribute is set to a project ID, and that project is authorized for
the currently authenticated service account, transit costs will be
billed to that project. This attribute is required with requester
pays-enabled buckets. The default is nil.
In general, this attribute should be set when first retrieving the
owning bucket by providing the user_project option to
Project#bucket.
See also Bucket#requester_pays= and Bucket#requester_pays.
      70 71 72  | 
    
      # File 'lib/google/cloud/storage/file/acl.rb', line 70 def user_project @user_project end  | 
  
Instance Method Details
#add_owner(entity, generation: nil) ⇒ String
Grants owner permission to the file.
      188 189 190 191 192 193 194 195  | 
    
      # File 'lib/google/cloud/storage/file/acl.rb', line 188 def add_owner entity, generation: nil gapi = @service.insert_file_acl @bucket, @file, entity, "OWNER", generation: generation, user_project: user_project entity = gapi.entity @owners.push entity unless @owners.nil? entity end  | 
  
#add_reader(entity, generation: nil) ⇒ String
Grants reader permission to the file.
      239 240 241 242 243 244 245 246  | 
    
      # File 'lib/google/cloud/storage/file/acl.rb', line 239 def add_reader entity, generation: nil gapi = @service.insert_file_acl @bucket, @file, entity, "READER", generation: generation, user_project: user_project 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 authenticatedRead predefined ACL
rule to the file.
      310 311 312  | 
    
      # File 'lib/google/cloud/storage/file/acl.rb', line 310 def auth! update_predefined_acl! "authenticatedRead" end  | 
  
#delete(entity, generation: nil) ⇒ Boolean
Permanently deletes the entity from the file's access control list.
      280 281 282 283 284 285 286 287  | 
    
      # File 'lib/google/cloud/storage/file/acl.rb', line 280 def delete entity, generation: nil @service.delete_file_acl \ @bucket, @file, entity, generation: generation, user_project: user_project @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 bucketOwnerFullControl predefined
ACL rule to the file.
      332 333 334  | 
    
      # File 'lib/google/cloud/storage/file/acl.rb', line 332 def owner_full! update_predefined_acl! "bucketOwnerFullControl" end  | 
  
#owner_read! ⇒ Object Also known as: bucketOwnerRead!
Convenience method to apply the bucketOwnerRead predefined ACL
rule to the file.
      351 352 353  | 
    
      # File 'lib/google/cloud/storage/file/acl.rb', line 351 def owner_read! update_predefined_acl! "bucketOwnerRead" end  | 
  
#owners ⇒ Array<String>
Lists the owners of the file.
      121 122 123 124  | 
    
      # File 'lib/google/cloud/storage/file/acl.rb', line 121 def owners reload! if @owners.nil? @owners end  | 
  
#private! ⇒ Object
Convenience method to apply the private predefined ACL
rule to the file.
      370 371 372  | 
    
      # File 'lib/google/cloud/storage/file/acl.rb', line 370 def private! update_predefined_acl! "private" end  | 
  
#project_private! ⇒ Object Also known as: projectPrivate!
Convenience method to apply the projectPrivate predefined ACL
rule to the file.
      388 389 390  | 
    
      # File 'lib/google/cloud/storage/file/acl.rb', line 388 def project_private! update_predefined_acl! "projectPrivate" end  | 
  
#public! ⇒ Object Also known as: publicRead!, public_read!
Convenience method to apply the publicRead predefined ACL
rule to the file.
      407 408 409  | 
    
      # File 'lib/google/cloud/storage/file/acl.rb', line 407 def public! update_predefined_acl! "publicRead" end  | 
  
#readers ⇒ Array<String>
Lists the readers of the file.
      141 142 143 144  | 
    
      # File 'lib/google/cloud/storage/file/acl.rb', line 141 def readers reload! if @readers.nil? @readers end  | 
  
#reload! ⇒ Object Also known as: refresh!
Reloads all Access Control List data for the file.
      97 98 99 100 101 102 103  | 
    
      # File 'lib/google/cloud/storage/file/acl.rb', line 97 def reload! gapi = @service.list_file_acls @bucket, @file, user_project: user_project acls = Array(gapi.items) @owners = entities_from_acls acls, "OWNER" @readers = entities_from_acls acls, "READER" end  |