• Object Storage Service

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

GET Bucket website

API Description

You can use this API to obtain the website hosting settings of a bucket.

Method Definition

ObsClient.getBucketWebsiteConfiguration(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

WebsiteConfiguration

Website hosting settings of the bucket

Sample Code

try:
    resp = obsClient.getBucketWebsiteConfiguration('bucketname') 
      
    if resp.status < 300: 
        print('requestId:', resp.requestId) 
        if resp.body.redirectAllRequestTo: 
            print('redirectAllRequestTo.hostName:', resp.body.redirectAllRequestTo.hostName, ',redirectAllRequestTo.protocol:', resp.body.redirectAllRequestTo.protocol) 
        if resp.body.indexDocument: 
            print('indexDocument.suffix:', resp.body.indexDocument.suffix) 
        if resp.body.errorDocument: 
            print('errorDocument.key:', resp.body.errorDocument.key) 
        if resp.body.routingRules: 
            index = 1 
            for rout in resp.body.routingRules: 
                print('routingRule[', index, ']:') 
                index += 1 
                print('condition.keyPrefixEquals:', rout.condition.keyPrefixEquals, ',condition.httpErrorCodeReturnedEquals:', rout.condition.httpErrorCodeReturnedEquals) 
                print('redirect.protocol:', rout.redirect.protocol, ',redirect.hostName:', rout.redirect.hostName, ',redirect.replaceKeyPrefixWith:', rout.redirect.replaceKeyPrefixWith, ',redirect.replaceKeyWith:', rout.redirect.replaceKeyWith, ',redirect.httpRedirectCode:', rout.redirect.httpRedirectCode) 
    else: 
        print('errorCode:', resp.errorCode) 
        print('errorMessage:', resp.errorMessage)
except:
    import traceback
    print(traceback.format_exc())