@@ -3464,6 +3464,49 @@ def delete_bucket_referer(self, Bucket, **kwargs):
34643464 params = params )
34653465 return None
34663466
3467+ def put_bucket_intelligenttiering_v2 (self , Bucket , IntelligentTieringConfiguration = None , Id = None , ** kwargs ):
3468+ """设置存储桶智能分层配置
3469+
3470+ :param Bucket(string): 存储桶名称.
3471+ :param IntelligentTieringConfiguration(dict): 智能分层配置
3472+ :param kwargs(dict): 设置请求headers.
3473+ :return: None.
3474+
3475+ .. code-block:: python
3476+
3477+ config = CosConfig(Region=region, SecretId=secret_id, SecretKey=secret_key, Token=token) # 获取配置对象
3478+ client = CosS3Client(config)
3479+
3480+ intelligent_tiering_conf = {
3481+ 'Status': 'Enable',
3482+ 'Transition': {
3483+ 'Days': '30|60|90',
3484+ 'RequestFrequent': '1'
3485+ }
3486+ }
3487+ client.put_bucket_intelligenttiering(Bucket="bucket", IntelligentTieringConfiguration=intelligent_tiering_conf)
3488+ """
3489+
3490+ if IntelligentTieringConfiguration is None :
3491+ IntelligentTieringConfiguration = {}
3492+ xml_config = format_xml (data = IntelligentTieringConfiguration , root = 'IntelligentTieringConfiguration' )
3493+ headers = mapped (kwargs )
3494+ headers ['Content-Type' ] = 'application/xml'
3495+ params = {'id' : Id }
3496+ url = self ._conf .uri (bucket = Bucket ) + '?intelligent-tiering'
3497+ logger .info ("put bucket intelligenttiering, url=:{url} ,headers=:{headers}" .format (
3498+ url = url ,
3499+ headers = headers ))
3500+ rt = self .send_request (
3501+ method = 'PUT' ,
3502+ url = url ,
3503+ bucket = Bucket ,
3504+ data = xml_config ,
3505+ auth = CosS3Auth (self ._conf , params = params ),
3506+ headers = headers ,
3507+ params = params )
3508+ return None
3509+
34673510 def put_bucket_intelligenttiering (self , Bucket , IntelligentTieringConfiguration = None , ** kwargs ):
34683511 """设置存储桶智能分层配置
34693512
@@ -3537,7 +3580,7 @@ def get_bucket_intelligenttiering(self, Bucket, **kwargs):
35373580
35383581 def get_bucket_intelligenttiering_v2 (self , Bucket , Id , ** kwargs ):
35393582 """获取存储桶智能分层配置
3540-
3583+
35413584 :param Bucket(string): 存储桶名称.
35423585 :param Id(string) 智能分层规则Id.
35433586 :param kwargs(dict): 设置请求headers.
@@ -3564,6 +3607,35 @@ def get_bucket_intelligenttiering_v2(self, Bucket, Id, **kwargs):
35643607 params = params )
35653608 data = xml_to_dict (rt .content )
35663609 return data
3610+
3611+ def list_bucket_intelligenttiering_configurations (self , Bucket , ** kwargs ):
3612+ """列举存储桶中的所有智能分层配置
3613+
3614+ :param Bucket(string): 存储桶名称.
3615+ :param kwargs(dict): 设置请求headers.
3616+ :return(dict): 所有的智能分层配置.
3617+
3618+ .. code-block:: python
3619+ config = CosConfig(Region=region, SecretId=secret_id, SecretKey=secret_key, Token=token) # 获取配置对象
3620+ client = CosS3Client(config)
3621+ client.list_bucket_intelligenttiering_configurations(Bucket='bucket')
3622+ """
3623+
3624+ headers = mapped (kwargs )
3625+ params = {}
3626+ url = self ._conf .uri (bucket = Bucket ) + "?intelligent-tiering"
3627+ logger .info ("list bucket intelligenttiering configurations, url=:{url} ,headers=:{headers}" .format (
3628+ url = url ,
3629+ headers = headers ))
3630+ rt = self .send_request (
3631+ method = 'GET' ,
3632+ url = url ,
3633+ bucket = Bucket ,
3634+ auth = CosS3Auth (self ._conf , params = params ),
3635+ headers = headers ,
3636+ params = params )
3637+ data = xml_to_dict (rt .content )
3638+ return data
35673639
35683640 def put_bucket_object_lock (self , Bucket , ObjectLockConfiguration = {}, ** kwargs ):
35693641 """设置存储桶对象锁定配置
@@ -3678,7 +3750,7 @@ def _head_bucket_wrapper(Bucket, **kwargs):
36783750 else :
36793751 data .update ({'MAZ' : False })
36803752 data .update ({"Location" : resp ['x-cos-bucket-region' ]})
3681- url = self ._conf .uri (bucket = Bucket )
3753+ url = self ._conf .uri (bucket = Bucket ). strip ( '/' )
36823754 data .update ({'BucketUrl' : url })
36833755 pool .add_task (_head_bucket_wrapper , Bucket , ** kwargs )
36843756
@@ -3764,13 +3836,13 @@ def _get_bucket_versioning_wrapper(Bucket, **kwargs):
37643836 pool .add_task (_get_bucket_versioning_wrapper , Bucket , ** kwargs )
37653837
37663838 # IntelligentTiering
3767- def _get_bucket_intelligenttiering_v2_wrapper (Bucket , Id , ** kwargs ):
3839+ def _list_bucket_intelligenttiering_conf_wrapper (Bucket , ** kwargs ):
37683840 try :
3769- resp = self .get_bucket_intelligenttiering_v2 (Bucket , Id , ** kwargs )
3841+ resp = self .list_bucket_intelligenttiering_configurations (Bucket , ** kwargs )
37703842 data .update ({'IntelligentTiering' : resp })
37713843 except CosServiceError as e :
37723844 logger .debug ("get_bucket_meta failed to get intelligenttiering conf:{}" .format (e ))
3773- pool .add_task (_get_bucket_intelligenttiering_v2_wrapper , Bucket , "default" , ** kwargs )
3845+ pool .add_task (_list_bucket_intelligenttiering_conf_wrapper , Bucket , ** kwargs )
37743846
37753847 # Tagging
37763848 def _get_bucket_tagging_wrapper (Bucket , ** kwargs ):
0 commit comments