Skip to content

Commit

Permalink
add api of delete_bucket_referer
Browse files Browse the repository at this point in the history
  • Loading branch information
jayzhenghan committed Sep 16, 2020
1 parent 69ccc8f commit 6776c0e
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
32 changes: 32 additions & 0 deletions qcloud_cos/cos_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2798,6 +2798,38 @@ def get_bucket_referer(self, Bucket, **kwargs):
format_dict(data['DomainList'], ['Domain'])
return data

def delete_bucket_referer(self, Bucket, **kwargs):
"""获取bucket防盗链规则
:param Bucket(string): 存储桶名称.
:param kwargs(dict): 设置请求headers.
:return(dict): None.
.. code-block:: python
config = CosConfig(Region=region, SecretId=secret_id, SecretKey=secret_key, Token=token) # 获取配置对象
client = CosS3Client(config)
# 获取bucket标签
response = client.delete_bucket_referer(
Bucket='bucket'
)
"""
xml_config=''
headers = mapped(kwargs)
headers['Content-MD5'] = get_md5(xml_config)
headers['Content-Type'] = 'application/xml'
params = {'referer': ''}
url = self._conf.uri(bucket=Bucket)
rt = self.send_request(
method='PUT',
url=url,
bucket=Bucket,
data=xml_config,
auth=CosS3Auth(self._conf, params=params),
headers=headers,
params=params)
return None

# service interface begin
def list_buckets(self, **kwargs):
"""列出所有bucket
Expand Down
10 changes: 9 additions & 1 deletion ut/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1078,7 +1078,7 @@ def _test_put_get_delete_bucket_origin():
)


def test_put_get_bucket_referer():
def test_put_get_delete_bucket_referer():
"""测试设置获取bucket防盗链规则"""
referer_config = {
'Status': 'Enabled',
Expand All @@ -1099,6 +1099,14 @@ def test_put_get_bucket_referer():
response = client.get_bucket_referer(
Bucket=test_bucket,
)
response = client.delete_bucket_referer(
Bucket=test_bucker,
)
time.sleep(4)
response = client.get_bucker_referer(
Bucket=test_bucker,
)
assert len(response)==0


def test_put_get_traffic_limit():
Expand Down

0 comments on commit 6776c0e

Please sign in to comment.