Gcloud::Storage::Bucket::Acl

Bucket Access Control List

Represents a Bucket's Access Control List.

require "gcloud"

gcloud = Gcloud.new
storage = gcloud.storage

bucket = storage.bucket "my-bucket"

bucket.acl.readers.each { |reader| puts reader }

Methods

Public Instance Methods

add_owner(entity)

Grants owner permission to the bucket.

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

Examples

Access to a bucket 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"

email = "heidi@example.net"
bucket.acl.add_owner "user-#{email}"

Access to a bucket 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"

email = "authors@example.net"
bucket.acl.add_owner "group-#{email}"

add_reader(entity)

Grants reader permission to the bucket.

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

Examples

Access to a bucket 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"

email = "heidi@example.net"
bucket.acl.add_reader "user-#{email}"

Access to a bucket 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"

email = "authors@example.net"
bucket.acl.add_reader "group-#{email}"

add_writer(entity)

Grants writer permission to the bucket.

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

Examples

Access to a bucket 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"

email = "heidi@example.net"
bucket.acl.add_writer "user-#{email}"

Access to a bucket 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"

email = "authors@example.net"
bucket.acl.add_writer "group-#{email}"

auth!()

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

Example

require "gcloud"

gcloud = Gcloud.new
storage = gcloud.storage

bucket = storage.bucket "my-bucket"

bucket.acl.auth!

auth_read!()

Alias for: auth!

authenticated!()

Alias for: auth!

authenticatedRead!()

Alias for: auth!

authenticated_read!()

Alias for: auth!

delete(entity)

Permenently deletes the entity from the bucket'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

Example

require "gcloud"

gcloud = Gcloud.new
storage = gcloud.storage

bucket = storage.bucket "my-bucket"

email = "heidi@example.net"
bucket.acl.delete "user-#{email}"

owners()

Lists the owners of the bucket.

Returns

Array of Strings

Example

require "gcloud"

gcloud = Gcloud.new
storage = gcloud.storage

bucket = storage.bucket "my-bucket"

bucket.acl.owners.each { |owner| puts owner }

private!()

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

Example

require "gcloud"

gcloud = Gcloud.new
storage = gcloud.storage

bucket = storage.bucket "my-bucket"

bucket.acl.private!

projectPrivate!()

Alias for: project_private!

project_private!()

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

Example

require "gcloud"

gcloud = Gcloud.new
storage = gcloud.storage

bucket = storage.bucket "my-bucket"

bucket.acl.project_private!
Also aliased as: projectPrivate!

public!()

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

Example

require "gcloud"

gcloud = Gcloud.new
storage = gcloud.storage

bucket = storage.bucket "my-bucket"

bucket.acl.public!
Also aliased as: publicRead!, public_read!

publicRead!()

Alias for: public!

publicReadWrite!()

Alias for: public_write!

public_read!()

Alias for: public!

public_write!()

Convenience method to apply the publicReadWrite predefined ACL rule to the bucket.

Example

require "gcloud"

gcloud = Gcloud.new
storage = gcloud.storage

bucket = storage.bucket "my-bucket"

bucket.acl.public_write!
Also aliased as: publicReadWrite!

readers()

Lists the readers of the bucket.

Returns

Array of Strings

Example

require "gcloud"

gcloud = Gcloud.new
storage = gcloud.storage

bucket = storage.bucket "my-bucket"

bucket.acl.readers.each { |reader| puts reader }

refresh!()

Reloads all Access Control List data for the bucket.

Example

require "gcloud"

gcloud = Gcloud.new
storage = gcloud.storage

bucket = storage.bucket "my-bucket"

bucket.acl.refresh!

writers()

Lists the owners of the bucket.

Returns

Array of Strings

Example

require "gcloud"

gcloud = Gcloud.new
storage = gcloud.storage

bucket = storage.bucket "my-bucket"

bucket.acl.writers.each { |writer| puts writer }