-
Notifications
You must be signed in to change notification settings - Fork 363
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5fa6886
commit 6b24a72
Showing
5 changed files
with
99 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
import os | ||
import oss2 | ||
|
||
# 以下代码展示了set_bucket_storage_capacity的的用法。 | ||
|
||
# 首先初始化AccessKeyId、AccessKeySecret、Endpoint等信息。 | ||
# 通过环境变量获取,或者把诸如“<你的AccessKeyId>”替换成真实的AccessKeyId等。 | ||
access_key_id = os.getenv('OSS_TEST_ACCESS_KEY_ID', '<你的AccessKeyId>') | ||
access_key_secret = os.getenv('OSS_TEST_ACCESS_KEY_SECRET', '<你的AccessKeySecret>') | ||
bucket_name = os.getenv('OSS_TEST_BUCKET', '<你的Bucket>') | ||
endpoint = os.getenv('OSS_TEST_ENDPOINT', '<你的访问域名>') | ||
|
||
# 确认上面的参数都填写正确了 | ||
for param in (access_key_id, access_key_secret, bucket_name, endpoint): | ||
assert '<' not in param, '请设置参数:' + param | ||
|
||
# 创建Bucket对象,所有Object相关的接口都可以通过Bucket对象来进行 | ||
bucket = oss2.Bucket(oss2.Auth(access_key_id, access_key_secret), endpoint, bucket_name) | ||
|
||
# 设置bucket容量为100GB | ||
user_qos = oss2.models.BucketUserQos(100) | ||
resp = bucket.set_bucket_storage_capacity(user_qos) | ||
|
||
# 获取容量信息 | ||
result = bucket.get_bucket_storage_capacity() | ||
print("bucket_qos_capacity:" + result.storage_capacity) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters