• Object Storage Service

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

GET Object acl

API Description

You can use this API to obtain the ACL of an object in a specified bucket.

Method Definition

ObsClient.getObjectAcl(bucketName, objectKey, versionId)

Request Parameter

Field

Type

Optional or Mandatory

Description

bucketName

str

Mandatory

Bucket name

objectKey

str

Mandatory

Object name

versionId

str

Optional

Object version ID

Returned Result

Type

Description

GetResult

SDK common result object

GetResult.body Type

Description

ACL

Object ACL

Sample Code

try:
    resp = obsClient.getObjectAcl('bucketname', 'objectkey') 
        
    if resp.status < 300: 
        print('requestId:', resp.requestId) 
        print('owner_id:', resp.body.owner.owner_id) 
        print('owner_name:', resp.body.owner.owner_name) 
         
        index = 1 
        for grant in resp.body.grants: 
            print('grant [' + str(index) + ']') 
            print('grantee_id:', grant.grantee.grantee_id) 
            print('grantee_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())