Help Center> Object Storage Service> SDK Reference> Python> Initialization> Initializing a BucketClient Instance

Initializing a BucketClient Instance

API Description

Except ObsClient.listBuckets, ObsClient.createPostSignature, and ObsClient.createSignedUrl, BucketClient can implement the same APIs as ObsClient, without requiring the bucketName parameter.

Method Definition

obsClient.bucketClient(
    bucketName='*** Your Bucket Name ***'
)

Constructor Parameter Description

Field

Type

Optional or Mandatory

Description

bucket_name

str

Mandatory

Name of the bucket client to be created

Sample Code

# Import the module.
from obs import ObsClient

# Create an instance of ObsClient.
obsClient = ObsClient(
    access_key_id='*** Provide your Access Key ***',    
    secret_access_key='*** Provide your Secret Key ***',    
    server='https://your-endpoint'
)
# Create an instance of BucketClient.
bucketClient = obsClient.bucketClient('bucketname')
# Create a Bucket.
resp = bucketClient.createBucket()
if resp.status < 300:    
    print('requestId:', resp.requestId)
else:    
    print('errorCode:', resp.errorCode)
    print('errorMessage:', resp.errorMessage)

Except ObsClient.listBuckets, ObsClient.createPostSignature, and ObsClient.createSignedUrl, BucketClient can implement the same APIs as ObsClient, without requiring the bucketName parameter.