Configuring Logging for a Bucket
API Description
You can use this API to configure the logging function for a bucket.
Method Definition
ObsClient.setBucketLogging(bucketName, logstatus)
Request Parameters
|
Field |
Type |
Optional or Mandatory |
Description |
|---|---|---|---|
|
bucketName |
str |
Mandatory |
Bucket name |
|
logstatus |
Optional |
Logging configuration information |
Returned Results
|
Type |
Description |
|---|---|
|
SDK common result object |
Sample Code
try:
from obs import Grantee
from obs import Grant
from obs import Logging
from obs import Group
from obs import Permission
grantee1 = Grantee(grantee_id='userid', group=None)
grantee2 = Grantee(group=Group.ALL_USERS)
grant1 = Grant(grantee=grantee1, permission=Permission.READ)
grant2 = Grant(grantee=grantee2, permission=Permission.READ)
grantList = [grant1, grant2]
logstatus = Logging(targetBucket='targetbucketname', targetPrefix='prefix', targetGrants=grantList, agency='your agency')
resp = obsClient.setBucketLogging('bucketname', logstatus)
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 a Bucket ACL
Next Article: Obtaining Logging Configuration of a Bucket
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.