Cloud Storage Client - Class Acl (1.30.3)

Reference documentation and code samples for the Cloud Storage Client class Acl.

Google Cloud Storage uses access control lists (ACLs) to manage bucket and object access. ACLs are the mechanism you use to share objects with other users and allow other users to access your buckets and objects. For more information please see the overview on access-control.

Example:

use Google\Cloud\Storage\StorageClient;

$storage = new StorageClient();

$bucket = $storage->bucket('my-bucket');
$acl = $bucket->acl();

Methods

__construct

Parameters
NameDescription
connection Google\Cloud\Storage\Connection\ConnectionInterface

Represents a connection to Cloud Storage.

type string

The type of access control this instance applies to.

identity array

Represents which bucket, file, or generation this instance applies to.

delete

Delete access controls on a Google\Cloud\Storage\Bucket or Google\Cloud\Storage\StorageObject for a specified entity.

Example:

$acl->delete('allAuthenticatedUsers');
Parameters
NameDescription
entity string

The entity to delete.

options array

[optional] Configuration Options.

Returns
TypeDescription
void

get

Get access controls on a Google\Cloud\Storage\Bucket or Google\Cloud\Storage\StorageObject. By default this will return all available access controls. You may optionally specify a single entity to return details for as well.

Example:

$res = $acl->get(['entity' => 'allAuthenticatedUsers']);
Parameters
NameDescription
options array

Configuration options.

↳ entity string

The entity to fetch.

Returns
TypeDescription
array

add

Add access controls on a Google\Cloud\Storage\Bucket or Google\Cloud\Storage\StorageObject.

Example:

$acl->add('allAuthenticatedUsers', 'WRITER');
Parameters
NameDescription
entity string

The entity to add access controls to.

role string

The permissions to add for the specified entity. May be one of 'OWNER', 'READER', or 'WRITER'.

options array

[optional] Configuration Options.

Returns
TypeDescription
array

update

Update access controls on a Google\Cloud\Storage\Bucket or Google\Cloud\Storage\StorageObject.

Example:

$acl->update('allAuthenticatedUsers', 'READER');
Parameters
NameDescription
entity string

The entity to update access controls for.

role string

The permissions to update for the specified entity. May be one of 'OWNER', 'READER', or 'WRITER'.

options array

[optional] Configuration Options.

Returns
TypeDescription
array

Constants

ROLE_READER

Value: 'READER'

ROLE_WRITER

Value: 'WRITER'

ROLE_OWNER

Value: 'OWNER'