ak = os.getenv('TOS_ACCESS_KEY')
sk = os.getenv('TOS_SECRET_KEY')
endpoint = "your endpoint"
client = tos.TosClientV2(ak, sk, endpoint, region)
resp = client.list_buckets()
for bucket in resp.buckets:
print("name:{}".format(bucket.name))
print("location:{}".format(bucket.location))
print("extranet_endpoint:{}".format(bucket.extranet_endpoint))
print("intranet_endpoint:{}".format(bucket.intranet_endpoint))
print("creation_date:{}".format(bucket.creation_date))
except tos.exceptions.TosClientError as e:
print('fail with client error, message:{}, cause: {}'.format(e.message, e.cause))
except tos.exceptions.TosServerError as e:
print('fail with server error, code: {}'.format(e.code))
print('error with request id: {}'.format(e.request_id))
print('error with message: {}'.format(e.message))
print('error with http code: {}'.format(e.status_code))
print('error with ec: {}'.format(e.ec))
print('error with request url: {}'.format(e.request_url))
print('fail with unknown error: {}'.format(e))