Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions qcloud_cos/cos_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2263,6 +2263,37 @@ def get_bucket_policy(self, Bucket, **kwargs):
data = {'Policy': json.dumps(rt.json())}
return data

def delete_bucket_policy(self, Bucket, **kwargs):
"""删除bucket policy

:param Bucket(string): 存储桶名称.
:param kwargs(dict): 设置请求headers.
:return: None.

.. code-block:: python

config = CosConfig(Region=region, SecretId=secret_id, SecretKey=secret_key, Token=token) # 获取配置对象
client = CosS3Client(config)
# 删除bucket policy服务配置
response = client.delete_bucket_policy(
Bucket=bucket
)
"""
headers = mapped(kwargs)
params = {'policy': ''}
url = self._conf.uri(bucket=Bucket)
logger.info("delete bucket policy, url=:{url} ,headers=:{headers}".format(
url=url,
headers=headers))
rt = self.send_request(
method='DELETE',
url=url,
bucket=Bucket,
auth=CosS3Auth(self._conf, params=params),
headers=headers,
params=params)
return None

def put_bucket_domain(self, Bucket, DomainConfiguration={}, **kwargs):
"""设置bucket的自定义域名

Expand Down
2 changes: 1 addition & 1 deletion qcloud_cos/version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@

__version__ = '5.1.9.4'
__version__ = '5.1.9.5'
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def long_description():

setup(
name='cos-python-sdk-v5',
version='1.9.4',
version='1.9.5',
url='https://www.qcloud.com/',
license='MIT',
author='tiedu, lewzylu, channingliu',
Expand Down
7 changes: 5 additions & 2 deletions ut/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -862,8 +862,8 @@ def test_bucket_exists():
assert status is True


def test_put_get_bucket_policy():
"""设置获取bucket的policy配置"""
def test_put_get_delete_bucket_policy():
"""设置获取删除bucket的policy配置"""
resource = "qcs::cos:" + REGION + ":uid/" + APPID + ":" + test_bucket + "/*"
resource_list = [resource]
policy = {
Expand Down Expand Up @@ -891,6 +891,9 @@ def test_put_get_bucket_policy():
response = client.get_bucket_policy(
Bucket=test_bucket,
)
response = client.delete_bucket_policy(
Bucket=test_bucket,
)


def test_put_file_like_object():
Expand Down