Gcloud::Storage::File::Acl

File Access Control List

Represents a File's Access Control List.

require "gcloud"

gcloud = Gcloud.new
storage = gcloud.storage

bucket = storage.bucket "my-bucket"

file = bucket.file "path/to/my-file.ext"
file.acl.readers.each { |reader| puts reader }

Methods

Public Instance Methods

add_owner(entity, options = {})

Grants owner permission to the file.

Parameters

entity

The entity holding the permission, in one of the following forms: (String)

  • user-userId

  • user-email

  • group-groupId

  • group-email

  • domain-domain

  • project-team-projectId

  • allUsers

  • allAuthenticatedUsers

options

An optional Hash for controlling additional behavior. (Hash)

options[:generation]

When present, selects a specific revision of this object. Default is the latest version. (Integer)

Examples

Access to a file can be granted to a user by appending +“user-”+ to the email address:

require "gcloud"

gcloud = Gcloud.new
storage = gcloud.storage

bucket = storage.bucket "my-bucket"

file = bucket.file "path/to/my-file.ext"
email = "heidi@example.net"
file.acl.add_owner "user-#{email}"

Access to a file can be granted to a group by appending +“group-”+ to the email address:

require "gcloud"

gcloud = Gcloud.new
storage = gcloud.storage

bucket = storage.bucket "my-bucket"

file = bucket.file "path/to/my-file.ext"
email = "authors@example.net"
file.acl.add_owner "group-#{email}"

add_reader(entity, options = {})

Grants reader permission to the file.

Parameters

entity

The entity holding the permission, in one of the following forms: (String)

  • user-userId

  • user-email

  • group-groupId

  • group-email

  • domain-domain

  • project-team-projectId

  • allUsers

  • allAuthenticatedUsers

options

An optional Hash for controlling additional behavior. (Hash)

options[:generation]

When present, selects a specific revision of this object. Default is the latest version. (Integer)

Examples

Access to a file can be granted to a user by appending +“user-”+ to the email address:

require "gcloud"

gcloud = Gcloud.new
storage = gcloud.storage

bucket = storage.bucket "my-bucket"

file = bucket.file "path/to/my-file.ext"
email = "heidi@example.net"
file.acl.add_reader "user-#{email}"

Access to a file can be granted to a group by appending +“group-”+ to the email address:

require "gcloud"

gcloud = Gcloud.new
storage = gcloud.storage

bucket = storage.bucket "my-bucket"

file = bucket.file "path/to/my-file.ext"
email = "authors@example.net"
file.acl.add_reader "group-#{email}"

add_writer(entity, options = {})

Grants writer permission to the file.

Parameters

entity

The entity holding the permission, in one of the following forms: (String)

  • user-userId

  • user-email

  • group-groupId

  • group-email

  • domain-domain

  • project-team-projectId

  • allUsers

  • allAuthenticatedUsers

options

An optional Hash for controlling additional behavior. (Hash)

options[:generation]

When present, selects a specific revision of this object. Default is the latest version. (Integer)

Examples

Access to a file can be granted to a user by appending +“user-”+ to the email address:

require "gcloud"

gcloud = Gcloud.new
storage = gcloud.storage

bucket = storage.bucket "my-bucket"

file = bucket.file "path/to/my-file.ext"
email = "heidi@example.net"
file.acl.add_writer "user-#{email}"

Access to a file can be granted to a group by appending +“group-”+ to the email address:

require "gcloud"

gcloud = Gcloud.new
storage = gcloud.storage

bucket = storage.bucket "my-bucket"

file = bucket.file "path/to/my-file.ext"
email = "authors@example.net"
file.acl.add_writer "group-#{email}"

auth!()

Convenience method to apply the authenticatedRead predefined ACL rule to the file.

Example

require "gcloud"

gcloud = Gcloud.new
storage = gcloud.storage

bucket = storage.bucket "my-bucket"

file = bucket.file "path/to/my-file.ext"
file.acl.auth!

auth_read!()

Alias for: auth!

authenticated!()

Alias for: auth!

authenticatedRead!()

Alias for: auth!

authenticated_read!()

Alias for: auth!

bucketOwnerFullControl!()

Alias for: owner_full!

bucketOwnerRead!()

Alias for: owner_read!

delete(entity, options = {})

Permenently deletes the entity from the file's access control list.

Parameters

entity

The entity holding the permission, in one of the following forms: (String)

  • user-userId

  • user-email

  • group-groupId

  • group-email

  • domain-domain

  • project-team-projectId

  • allUsers

  • allAuthenticatedUsers

options

An optional Hash for controlling additional behavior. (Hash)

options[:generation]

When present, selects a specific revision of this object. Default is the latest version. (Integer)

Example

require "gcloud"

gcloud = Gcloud.new
storage = gcloud.storage

bucket = storage.bucket "my-bucket"

file = bucket.file "path/to/my-file.ext"
email = "heidi@example.net"
file.acl.delete "user-#{email}"

owner_full!()

Convenience method to apply the bucketOwnerFullControl predefined ACL rule to the file.

Example

require "gcloud"

gcloud = Gcloud.new
storage = gcloud.storage

bucket = storage.bucket "my-bucket"

file = bucket.file "path/to/my-file.ext"
file.acl.owner_full!
Also aliased as: bucketOwnerFullControl!

owner_read!()

Convenience method to apply the bucketOwnerRead predefined ACL rule to the file.

Example

require "gcloud"

gcloud = Gcloud.new
storage = gcloud.storage

bucket = storage.bucket "my-bucket"

file = bucket.file "path/to/my-file.ext"
file.acl.owner_read!
Also aliased as: bucketOwnerRead!

owners()

Lists the owners of the file.

Returns

Array of Strings

Example

require "gcloud"

gcloud = Gcloud.new
storage = gcloud.storage

bucket = storage.bucket "my-bucket"

file = bucket.file "path/to/my-file.ext"
file.acl.owners.each { |owner| puts owner }

private!()

Convenience method to apply the private predefined ACL rule to the file.

Example

require "gcloud"

gcloud = Gcloud.new
storage = gcloud.storage

bucket = storage.bucket "my-bucket"

file = bucket.file "path/to/my-file.ext"
file.acl.private!

projectPrivate!()

Alias for: project_private!

project_private!()

Convenience method to apply the projectPrivate predefined ACL rule to the file.

Example

require "gcloud"

gcloud = Gcloud.new
storage = gcloud.storage

bucket = storage.bucket "my-bucket"

file = bucket.file "path/to/my-file.ext"
file.acl.project_private!
Also aliased as: projectPrivate!

public!()

Convenience method to apply the publicRead predefined ACL rule to the file.

Example

require "gcloud"

gcloud = Gcloud.new
storage = gcloud.storage

bucket = storage.bucket "my-bucket"

file = bucket.file "path/to/my-file.ext"
file.acl.public!
Also aliased as: publicRead!, public_read!

publicRead!()

Alias for: public!

public_read!()

Alias for: public!

readers()

Lists the readers of the file.

Returns

Array of Strings

Example

require "gcloud"

gcloud = Gcloud.new
storage = gcloud.storage

bucket = storage.bucket "my-bucket"

file = bucket.file "path/to/my-file.ext"
file.acl.readers.each { |reader| puts reader }

refresh!()

Reloads all Access Control List data for the file.

Example

require "gcloud"

gcloud = Gcloud.new
storage = gcloud.storage

bucket = storage.bucket "my-bucket"

file = bucket.file "path/to/my-file.ext"
file.acl.refresh!

writers()

Lists the owners of the file.

Returns

Array of Strings

Example

require "gcloud"

gcloud = Gcloud.new
storage = gcloud.storage

bucket = storage.bucket "my-bucket"

file = bucket.file "path/to/my-file.ext"
file.acl.writers.each { |writer| puts writer }