@@ -2797,6 +2797,76 @@ def get_bucket_referer(self, Bucket, **kwargs):
27972797 format_dict (data ['DomainList' ], ['Domain' ])
27982798 return data
27992799
2800+ def put_bucket_intelligenttiering (self , Bucket , IntelligentTieringConfiguration = {}, ** kwargs ):
2801+ """设置存储桶智能分层配置
2802+
2803+ :param Bucket(string): 存储桶名称.
2804+ :param IntelligentTieringConfiguration(dict): 只能分层配置
2805+ :param kwargs(dict): 设置请求headers.
2806+ :return: None.
2807+
2808+ .. code-block:: python
2809+
2810+ config = CosConfig(Region=region, SecretId=secret_id, SecretKey=secret_key, Token=token) # 获取配置对象
2811+ client = CosS3Client(config)
2812+
2813+ intelligent_tiering_conf = {
2814+ 'Status': 'Enable',
2815+ 'Transition': {
2816+ 'Days': '30|60|90',
2817+ 'RequestFrequent': '1'
2818+ }
2819+ }
2820+ client.put_bucket_intelligenttiering(Bucket="bucket", IntelligentTieringConfiguration=intelligent_tiering_conf)
2821+ """
2822+
2823+ xml_config = format_xml (data = IntelligentTieringConfiguration , root = 'IntelligentTieringConfiguration' )
2824+ headers = mapped (kwargs )
2825+ headers ['Content-Type' ] = 'application/xml'
2826+ params = {'intelligenttiering' : '' }
2827+ url = self ._conf .uri (bucket = Bucket )
2828+ logger .info ("put bucket intelligenttiering, url=:{url} ,headers=:{headers}" .format (
2829+ url = url ,
2830+ headers = headers ))
2831+ rt = self .send_request (
2832+ method = 'PUT' ,
2833+ url = url ,
2834+ bucket = Bucket ,
2835+ data = xml_config ,
2836+ auth = CosS3Auth (self ._conf , params = params ),
2837+ headers = headers ,
2838+ params = params )
2839+ return None
2840+
2841+ def get_bucket_intelligenttiering (self , Bucket , ** kwargs ):
2842+ """获取存储桶智能分层配置
2843+ :param Bucket(string): 存储桶名称.
2844+ :param IntelligentTieringConfiguration(dict): 只能分层配置
2845+ :param kwargs(dict): 设置请求headers.
2846+ :return(dict): 智能分层配置.
2847+
2848+ .. code-block:: python
2849+ config = CosConfig(Region=region, SecretId=secret_id, SecretKey=secret_key, Token=token) # 获取配置对象
2850+ client = CosS3Client(config)
2851+ client.get_bucket_intelligenttiering(Bucket='bucket')
2852+ """
2853+
2854+ headers = mapped (kwargs )
2855+ params = {'intelligenttiering' : '' }
2856+ url = self ._conf .uri (bucket = Bucket )
2857+ logger .info ("get bucket intelligenttiering, url=:{url} ,headers=:{headers}" .format (
2858+ url = url ,
2859+ headers = headers ))
2860+ rt = self .send_request (
2861+ method = 'GET' ,
2862+ url = url ,
2863+ bucket = Bucket ,
2864+ auth = CosS3Auth (self ._conf , params = params ),
2865+ headers = headers ,
2866+ params = params )
2867+ data = xml_to_dict (rt .content )
2868+ return data
2869+
28002870 # service interface begin
28012871 def list_buckets (self , ** kwargs ):
28022872 """列出所有bucket
0 commit comments