Obtaining Website Hosting Settings of a Bucket
API Description
You can use this API to obtain the website hosting settings of a bucket.
Method Definition
ObsClient.getBucketWebsite(bucketName)
Request Parameters
|
Field |
Type |
Optional or Mandatory |
Description |
|---|---|---|---|
|
bucketName |
str |
Mandatory |
Bucket name |
Returned Results
|
Type |
Description |
|---|---|
|
SDK common result object |
|
GetResult.body Type |
Description |
|---|---|
|
Website hosting settings of a bucket |
Sample Code
try:
resp = obsClient.getBucketWebsite('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())
Last Article: Configuring Website Hosting for a Bucket
Next Article: Deleting Website Hosting Settings of a Bucket
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.