• Object Storage Service

obs
  1. Help Center
  2. Object Storage Service
  3. API Reference (Python SDK)
  4. Bucket-Related APIs
  5. GET Bucket logging

GET Bucket logging

API Description

You can use this API to obtain the access logging settings of a bucket.

Method Definition

ObsClient.getBucketLoggingConfiguration(bucketName)

Request Parameter

Field

Type

Optional or Mandatory

Description

bucketName

str

Mandatory

Bucket name

Returned Result

Type

Description

GetResult

SDK common result object

GetResult.body Type

Description

Logging

Log configuration information

Sample Code

try:
    resp = obsClient.getBucketLoggingConfiguration('bucketname') 
     
    if resp.status < 300: 
        print('requestId:', resp.requestId) 
        print('targetBucket:', resp.body.targetBucket) 
        print('targetPrefix:', resp.body.targetPrefix) 
         
        index = 1     
        for grant in resp.body.targetGrants: 
            print('grant [' + str(index) + ']') 
            print('grant_id:', grant.grantee.grantee_id)         
            print('grant_name:', grant.grantee.grantee_name)         
            print('group:', grant.grantee.group)        
            print('permission:', grant.permission) 
            index += 1 
    else: 
        print('errorCode:', resp.errorCode) 
        print('errorMessage:', resp.errorMessage)
except:
    import traceback
    print(traceback.format_exc())