- 2.19.0 (latest)
- 2.17.0
- 2.16.0
- 2.15.0
- 2.14.0
- 2.13.0
- 2.12.0
- 2.11.0
- 2.10.0
- 2.9.0
- 2.8.0
- 2.7.0
- 2.6.0
- 2.5.0
- 2.4.0
- 2.3.0
- 2.2.1
- 2.1.0
- 2.0.0
- 1.44.0
- 1.43.0
- 1.42.3
- 1.41.1
- 1.40.0
- 1.39.0
- 1.38.0
- 1.37.1
- 1.36.2
- 1.35.1
- 1.34.0
- 1.33.0
- 1.32.0
- 1.31.2
- 1.30.0
- 1.29.0
- 1.28.1
- 1.27.0
- 1.26.0
- 1.25.0
- 1.24.1
- 1.23.0
- 1.22.0
- 1.21.0
- 1.20.0
- 1.19.0
- 1.18.0
- 1.17.0
Manipulate access control lists that Cloud Storage provides.
Bucket has a getting method that creates an ACL object under the hood, and you can interact with that using acl:
.. literalinclude:: snippets.py :start-after: [START client_bucket_acl] :end-before: [END client_bucket_acl] :dedent: 4
Adding and removing permissions can be done with the following methods (in increasing order of granularity):
ACL.all
corresponds to access for all users.ACL.all_authenticated
corresponds to access for all users that are signed into a Google account.ACL.domain
corresponds to access on a per Google Apps domain (ie,example.com
).ACL.group
corresponds to access on a per group basis (either by ID or e-mail address).ACL.user
corresponds to access on a per user basis (either by ID or e-mail address).
And you are able to grant
and revoke
the following roles:
- Reading:
_ACLEntity.grant_read
and_ACLEntity.revoke_read
- Writing:
_ACLEntity.grant_write
and_ACLEntity.revoke_write
- Owning:
_ACLEntity.grant_owner
and_ACLEntity.revoke_owner
You can use any of these like any other factory method (these happen to
be _ACLEntity
factories):
.. literalinclude:: snippets.py :start-after: [START acl_user_settings] :end-before: [END acl_user_settings] :dedent: 4
After that, you can save any changes you make with the save method:
.. literalinclude:: snippets.py :start-after: [START acl_save] :end-before: [END acl_save] :dedent: 4
You can alternatively save any existing ACL object (whether it was created by a factory method or not) from a Bucket:
.. literalinclude:: snippets.py :start-after: [START acl_save_bucket] :end-before: [END acl_save_bucket] :dedent: 4
To get the list of entity
and role
for each unique pair, the
ACL
class is iterable:
.. literalinclude:: snippets.py :start-after: [START acl_print] :end-before: [END acl_print] :dedent: 4
This list of tuples can be used as the entity
and role
fields
when sending metadata for ACLs to the API.
Classes
ACL
ACL()
Container class representing a list of access controls.
BucketACL
BucketACL(bucket)
An ACL specifically for a bucket.
Parameter | |
---|---|
Name | Description |
bucket |
Bucket
The bucket to which this ACL relates. |
DefaultObjectACL
DefaultObjectACL(bucket)
A class representing the default object ACL for a bucket.
ObjectACL
ObjectACL(blob)
An ACL specifically for a Cloud Storage object / blob.
Parameter | |
---|---|
Name | Description |
blob |
Blob
The blob that this ACL corresponds to. |