@@ -2861,6 +2861,7 @@ def delete_bucket_referer(self, Bucket, **kwargs):
28612861 Bucket='bucket'
28622862 )
28632863 """
2864+
28642865 xml_config = ''
28652866 headers = mapped (kwargs )
28662867 headers ['Content-MD5' ] = get_md5 (xml_config )
@@ -2877,6 +2878,78 @@ def delete_bucket_referer(self, Bucket, **kwargs):
28772878 params = params )
28782879 return None
28792880
2881+ def put_bucket_intelligenttiering (self , Bucket , IntelligentTieringConfiguration = None , ** kwargs ):
2882+ """设置存储桶智能分层配置
2883+
2884+ :param Bucket(string): 存储桶名称.
2885+ :param IntelligentTieringConfiguration(dict): 只能分层配置
2886+ :param kwargs(dict): 设置请求headers.
2887+ :return: None.
2888+
2889+ .. code-block:: python
2890+
2891+ config = CosConfig(Region=region, SecretId=secret_id, SecretKey=secret_key, Token=token) # 获取配置对象
2892+ client = CosS3Client(config)
2893+
2894+ intelligent_tiering_conf = {
2895+ 'Status': 'Enable',
2896+ 'Transition': {
2897+ 'Days': '30|60|90',
2898+ 'RequestFrequent': '1'
2899+ }
2900+ }
2901+ client.put_bucket_intelligenttiering(Bucket="bucket", IntelligentTieringConfiguration=intelligent_tiering_conf)
2902+ """
2903+
2904+ if IntelligentTieringConfiguration is None :
2905+ IntelligentTieringConfiguration = {}
2906+ xml_config = format_xml (data = IntelligentTieringConfiguration , root = 'IntelligentTieringConfiguration' )
2907+ headers = mapped (kwargs )
2908+ headers ['Content-Type' ] = 'application/xml'
2909+ params = {'intelligenttiering' : '' }
2910+ url = self ._conf .uri (bucket = Bucket )
2911+ logger .info ("put bucket intelligenttiering, url=:{url} ,headers=:{headers}" .format (
2912+ url = url ,
2913+ headers = headers ))
2914+ rt = self .send_request (
2915+ method = 'PUT' ,
2916+ url = url ,
2917+ bucket = Bucket ,
2918+ data = xml_config ,
2919+ auth = CosS3Auth (self ._conf , params = params ),
2920+ headers = headers ,
2921+ params = params )
2922+ return None
2923+
2924+ def get_bucket_intelligenttiering (self , Bucket , ** kwargs ):
2925+ """获取存储桶智能分层配置
2926+ :param Bucket(string): 存储桶名称.
2927+ :param IntelligentTieringConfiguration(dict): 只能分层配置
2928+ :param kwargs(dict): 设置请求headers.
2929+ :return(dict): 智能分层配置.
2930+
2931+ .. code-block:: python
2932+ config = CosConfig(Region=region, SecretId=secret_id, SecretKey=secret_key, Token=token) # 获取配置对象
2933+ client = CosS3Client(config)
2934+ client.get_bucket_intelligenttiering(Bucket='bucket')
2935+ """
2936+
2937+ headers = mapped (kwargs )
2938+ params = {'intelligenttiering' : '' }
2939+ url = self ._conf .uri (bucket = Bucket )
2940+ logger .info ("get bucket intelligenttiering, url=:{url} ,headers=:{headers}" .format (
2941+ url = url ,
2942+ headers = headers ))
2943+ rt = self .send_request (
2944+ method = 'GET' ,
2945+ url = url ,
2946+ bucket = Bucket ,
2947+ auth = CosS3Auth (self ._conf , params = params ),
2948+ headers = headers ,
2949+ params = params )
2950+ data = xml_to_dict (rt .content )
2951+ return data
2952+
28802953 # service interface begin
28812954 def list_buckets (self , ** kwargs ):
28822955 """列出所有bucket
0 commit comments