@@ -44,7 +44,7 @@ def __init__(self, Appid=None, Region=None, SecretId=None, SecretKey=None, Token
4444 Access_id = None , Access_key = None , Secret_id = None , Secret_key = None , Endpoint = None , IP = None , Port = None ,
4545 Anonymous = None , UA = None , Proxies = None , Domain = None , ServiceDomain = None , KeepAlive = True , PoolConnections = 10 ,
4646 PoolMaxSize = 10 , AllowRedirects = False , SignHost = True , EndpointCi = None , EndpointPic = None , EnableOldDomain = True , EnableInternalDomain = True , SignParams = True ,
47- AutoSwitchDomainOnRetry = True ):
47+ AutoSwitchDomainOnRetry = False ):
4848 """初始化,保存用户的信息
4949
5050 :param Appid(string): 用户APPID.
@@ -1635,7 +1635,7 @@ def head_bucket(self, Bucket, **kwargs):
16351635 bucket = Bucket ,
16361636 auth = CosS3Auth (self ._conf ),
16371637 headers = headers )
1638- return None
1638+ return rt . headers
16391639
16401640 def put_bucket_acl (self , Bucket , AccessControlPolicy = {}, ** kwargs ):
16411641 """设置bucket ACL
@@ -2926,7 +2926,7 @@ def get_bucket_inventory(self, Bucket, Id, **kwargs):
29262926 return data
29272927
29282928 def delete_bucket_inventory (self , Bucket , Id , ** kwargs ):
2929- """删除bucket 回源配置
2929+ """删除bucket清单规则
29302930
29312931 :param Bucket(string): 存储桶名称.
29322932 :param Id(string): 清单规则名称.
@@ -2957,6 +2957,52 @@ def delete_bucket_inventory(self, Bucket, Id, **kwargs):
29572957 params = params )
29582958 return None
29592959
2960+ def list_bucket_inventory_configurations (self , Bucket , ContinuationToken = None , ** kwargs ):
2961+ """列举存储桶清单规则
2962+
2963+ :param Bucket(string): 存储桶名称
2964+ :param ContinuationToken(string): 分页参数, 用以获取下一页信息
2965+ :param kwargs(dict): 设置请求headers.
2966+ :return(dict): 存储桶清单规则列表
2967+
2968+ .. code-block:: python
2969+
2970+ config = CosConfig(Region=region, SecretId=secret_id, SecretKey=secret_key, Token=token) # 获取配置对象
2971+ client = CosS3Client(config)
2972+ # 分页列举bucket清单规则
2973+ continuation_token = ''
2974+ while True:
2975+ resp = client.list_bucket_inventory_configurations(
2976+ Bucket=bucket,
2977+ ContinuationToken=continuation_token,
2978+ )
2979+ if 'InventoryConfiguration' in resp:
2980+ for conf in resp['InventoryConfiguration']:
2981+ id = 'ID-{}'.format(i)
2982+ if resp['IsTruncated'] == 'true':
2983+ continuation_token = resp['NextContinuationToken']
2984+ else:
2985+ break
2986+ """
2987+ headers = mapped (kwargs )
2988+ params = {'inventory' : '' }
2989+ if ContinuationToken is not None :
2990+ params ['continuation-token' ] = ContinuationToken
2991+ url = self ._conf .uri (bucket = Bucket )
2992+ logger .info ("list bucket inventory configurations, url={url}, headers={headers}" .format (
2993+ url = url ,
2994+ headers = headers ,
2995+ ))
2996+ rt = self .send_request (
2997+ method = 'GET' ,
2998+ url = url ,
2999+ bucket = Bucket ,
3000+ auth = CosS3Auth (self ._conf , params = params ),
3001+ headers = headers ,
3002+ params = params )
3003+ data = xml_to_dict (rt .content )
3004+ return data
3005+
29603006 def put_object_tagging (self , Bucket , Key , Tagging = {}, ** kwargs ):
29613007 """设置object的标签
29623008
0 commit comments