Setting a Bucket ACL
API Description
You can use this API to set a bucket ACL.
Method Definition
ObsClient.setBucketAcl(bucketName, acl, aclControl)
Request Parameters
|
Field |
Type |
Optional or Mandatory |
Description |
|---|---|---|---|
|
bucketName |
str |
Mandatory |
Bucket name |
|
acl |
Optional |
Bucket access control list (ACL) |
|
|
aclControl |
str |
Optional |
acl and aclControl are mutually exclusive.
Returned Results
|
Type |
Description |
|---|---|
|
SDK common result object |
Sample Code
try:
from obs import ACL
from obs import Owner
from obs import Grantee
from obs import Grant
from obs import Group
from obs import Permission
owner = Owner(owner_id='ownerid')
grantee1 = Grantee(grantee_id='userid')
grantee2 = Grantee(group=Group.ALL_USERS)
grant1 = Grant(grantee=grantee1, permission=Permission.READ)
grant2 = Grant(grantee=grantee1, permission=Permission.WRITE)
grant3 = Grant(grantee=grantee2, permission=Permission.WRITE)
grant4 = Grant(grantee=grantee2, permission=Permission.READ_ACP)
acl = ACL(owner=owner, grants=[grant1, grant2, grant3, grant4])
resp = obsClient.setBucketAcl('bucketname', acl)
if resp.status < 300:
print('requestId:', resp.requestId)
else:
print('errorCode:', resp.errorCode)
print('errorMessage:', resp.errorMessage)
except:
import traceback
print(traceback.format_exc())
Last Article: Obtaining the Storage Class of a Bucket
Next Article: Obtaining a Bucket ACL
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.