Cloud Storage API - Class Google::Cloud::Storage::Bucket::DefaultAcl (v1.47.0)

Reference documentation and code samples for the Cloud Storage API class Google::Cloud::Storage::Bucket::DefaultAcl.

Bucket Default Access Control List

Represents a Bucket's Default Access Control List.

Inherits

  • Object

Example

require "google/cloud/storage"

storage = Google::Cloud::Storage.new

bucket = storage.bucket "my-bucket"

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

Methods

#add_owner

def add_owner(entity)

Grants default owner permission to files in the bucket.

Parameter
  • entity (String) —

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

    • user-userId
    • user-email
    • group-groupId
    • group-email
    • domain-domain
    • project-team-projectId
    • allUsers
    • allAuthenticatedUsers
Examples

Grant access to a user by prepending "user-" to an email:

require "google/cloud/storage"

storage = Google::Cloud::Storage.new

bucket = storage.bucket "my-bucket"

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

Grant access to a group by prepending "group-" to email:

require "google/cloud/storage"

storage = Google::Cloud::Storage.new

bucket = storage.bucket "my-bucket"

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

#add_reader

def add_reader(entity)

Grants default reader permission to files in the bucket.

Parameter
  • entity (String) —

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

    • user-userId
    • user-email
    • group-groupId
    • group-email
    • domain-domain
    • project-team-projectId
    • allUsers
    • allAuthenticatedUsers
Examples

Grant access to a user by prepending "user-" to an email:

require "google/cloud/storage"

storage = Google::Cloud::Storage.new

bucket = storage.bucket "my-bucket"

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

Grant access to a group by prepending "group-" to email:

require "google/cloud/storage"

storage = Google::Cloud::Storage.new

bucket = storage.bucket "my-bucket"

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

#auth!

def auth!(if_metageneration_match: nil)

Convenience method to apply the default authenticatedRead predefined ACL rule to files in the bucket.

Example
require "google/cloud/storage"

storage = Google::Cloud::Storage.new

bucket = storage.bucket "my-bucket"

bucket.default_acl.auth!

#auth_read!

def auth_read!(if_metageneration_match: nil)
Alias Of: #auth!

Convenience method to apply the default authenticatedRead predefined ACL rule to files in the bucket.

Example
require "google/cloud/storage"

storage = Google::Cloud::Storage.new

bucket = storage.bucket "my-bucket"

bucket.default_acl.auth!

#authenticated!

def authenticated!(if_metageneration_match: nil)
Alias Of: #auth!

Convenience method to apply the default authenticatedRead predefined ACL rule to files in the bucket.

Example
require "google/cloud/storage"

storage = Google::Cloud::Storage.new

bucket = storage.bucket "my-bucket"

bucket.default_acl.auth!

#authenticatedRead!

def authenticatedRead!(if_metageneration_match: nil)
Alias Of: #auth!

Convenience method to apply the default authenticatedRead predefined ACL rule to files in the bucket.

Example
require "google/cloud/storage"

storage = Google::Cloud::Storage.new

bucket = storage.bucket "my-bucket"

bucket.default_acl.auth!

#authenticated_read!

def authenticated_read!(if_metageneration_match: nil)
Alias Of: #auth!

Convenience method to apply the default authenticatedRead predefined ACL rule to files in the bucket.

Example
require "google/cloud/storage"

storage = Google::Cloud::Storage.new

bucket = storage.bucket "my-bucket"

bucket.default_acl.auth!

#bucketOwnerFullControl!

def bucketOwnerFullControl!(if_metageneration_match: nil)
Alias Of: #owner_full!

Convenience method to apply the default bucketOwnerFullControl predefined ACL rule to files in the bucket.

Example
require "google/cloud/storage"

storage = Google::Cloud::Storage.new

bucket = storage.bucket "my-bucket"

bucket.default_acl.owner_full!

#bucketOwnerRead!

def bucketOwnerRead!(if_metageneration_match: nil)
Alias Of: #owner_read!

Convenience method to apply the default bucketOwnerRead predefined ACL rule to files in the bucket.

Example
require "google/cloud/storage"

storage = Google::Cloud::Storage.new

bucket = storage.bucket "my-bucket"

bucket.default_acl.owner_read!

#delete

def delete(entity)

Permanently deletes the entity from the bucket's default access control list for files.

Parameter
  • entity (String) —

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

    • user-userId
    • user-email
    • group-groupId
    • group-email
    • domain-domain
    • project-team-projectId
    • allUsers
    • allAuthenticatedUsers
Example
require "google/cloud/storage"

storage = Google::Cloud::Storage.new

bucket = storage.bucket "my-bucket"

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

#owner_full!

def owner_full!(if_metageneration_match: nil)

Convenience method to apply the default bucketOwnerFullControl predefined ACL rule to files in the bucket.

Example
require "google/cloud/storage"

storage = Google::Cloud::Storage.new

bucket = storage.bucket "my-bucket"

bucket.default_acl.owner_full!

#owner_read!

def owner_read!(if_metageneration_match: nil)

Convenience method to apply the default bucketOwnerRead predefined ACL rule to files in the bucket.

Example
require "google/cloud/storage"

storage = Google::Cloud::Storage.new

bucket = storage.bucket "my-bucket"

bucket.default_acl.owner_read!

#owners

def owners() -> Array<String>

Lists the default owners for files in the bucket.

Returns
  • (Array<String>)
Example
require "google/cloud/storage"

storage = Google::Cloud::Storage.new

bucket = storage.bucket "my-bucket"

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

#private!

def private!(if_metageneration_match: nil)

Convenience method to apply the default private predefined ACL rule to files in the bucket.

Example
require "google/cloud/storage"

storage = Google::Cloud::Storage.new

bucket = storage.bucket "my-bucket"

bucket.default_acl.private!

#projectPrivate!

def projectPrivate!(if_metageneration_match: nil)
Alias Of: #project_private!

Convenience method to apply the default projectPrivate predefined ACL rule to files in the bucket.

Example
require "google/cloud/storage"

storage = Google::Cloud::Storage.new

bucket = storage.bucket "my-bucket"

bucket.default_acl.project_private!

#project_private!

def project_private!(if_metageneration_match: nil)

Convenience method to apply the default projectPrivate predefined ACL rule to files in the bucket.

Example
require "google/cloud/storage"

storage = Google::Cloud::Storage.new

bucket = storage.bucket "my-bucket"

bucket.default_acl.project_private!

#public!

def public!(if_metageneration_match: nil)

Convenience method to apply the default publicRead predefined ACL rule to files in the bucket.

Example
require "google/cloud/storage"

storage = Google::Cloud::Storage.new

bucket = storage.bucket "my-bucket"

bucket.default_acl.public!

#publicRead!

def publicRead!(if_metageneration_match: nil)
Alias Of: #public!

Convenience method to apply the default publicRead predefined ACL rule to files in the bucket.

Example
require "google/cloud/storage"

storage = Google::Cloud::Storage.new

bucket = storage.bucket "my-bucket"

bucket.default_acl.public!

#public_read!

def public_read!(if_metageneration_match: nil)
Alias Of: #public!

Convenience method to apply the default publicRead predefined ACL rule to files in the bucket.

Example
require "google/cloud/storage"

storage = Google::Cloud::Storage.new

bucket = storage.bucket "my-bucket"

bucket.default_acl.public!

#readers

def readers() -> Array<String>

Lists the default readers for files in the bucket.

Returns
  • (Array<String>)
Example
require "google/cloud/storage"

storage = Google::Cloud::Storage.new

bucket = storage.bucket "my-bucket"

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

#refresh!

def refresh!()
Alias Of: #reload!

Reloads all Default Access Control List data for the bucket.

Example
require "google/cloud/storage"

storage = Google::Cloud::Storage.new

bucket = storage.bucket "my-bucket"

bucket.default_acl.reload!

#reload!

def reload!()
Aliases

Reloads all Default Access Control List data for the bucket.

Example
require "google/cloud/storage"

storage = Google::Cloud::Storage.new

bucket = storage.bucket "my-bucket"

bucket.default_acl.reload!

#user_project

def user_project()

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 #requester_pays= and #requester_pays.

#user_project=

def user_project=(value)

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 #requester_pays= and #requester_pays.