@@ -3042,6 +3042,72 @@ def list_bucket_inventory_configurations(self, Bucket, ContinuationToken=None, *
30423042 data = xml_to_dict (rt .content )
30433043 return data
30443044
3045+ def post_bucket_inventory (self , Bucket , Id , InventoryConfiguration = {}, ** kwargs ):
3046+ """设置bucket的清单规则(一次性清单/即时清单)
3047+
3048+ :param Bucket(string): 存储桶名称.
3049+ :param Id(string): 清单规则名称.
3050+ :param InventoryConfiguration(dict): Bucket的清单规则.
3051+ :param kwargs(dict): 设置请求headers.
3052+ :return: None.
3053+
3054+ .. code-block:: python
3055+
3056+ config = CosConfig(Region=region, SecretId=secret_id, SecretKey=secret_key, Token=token) # 获取配置对象
3057+ client = CosS3Client(config)
3058+ # 设置bucket清单规则
3059+ inventory_config = {
3060+ 'Destination': {
3061+ 'COSBucketDestination': {
3062+ 'AccountId': '100000000001',
3063+ 'Bucket': 'qcs::cos:ap-guangzhou::examplebucket-1250000000',
3064+ 'Format': 'CSV',
3065+ 'Prefix': 'list1',
3066+ 'Encryption': {
3067+ 'SSECOS': {}
3068+ }
3069+ },
3070+ 'Filter': {
3071+ 'Prefix': 'filterPrefix'
3072+ },
3073+ 'IncludedObjectVersions':'All',
3074+ 'OptionalFields': {
3075+ 'Field': [
3076+ 'Size',
3077+ 'LastModifiedDate',
3078+ 'ETag',
3079+ 'StorageClass',
3080+ 'IsMultipartUploaded',
3081+ 'ReplicationStatus'
3082+ ]
3083+ },
3084+ }
3085+ response = client.put_bucket_inventory(
3086+ Bucket='bucket',
3087+ Id='list1',
3088+ InventoryConfiguration=inventory_config
3089+ )
3090+ """
3091+ InventoryConfiguration ['Id' ] = Id
3092+ xml_config = format_xml (data = InventoryConfiguration , root = 'InventoryConfiguration' )
3093+ headers = mapped (kwargs )
3094+ headers ['Content-MD5' ] = get_md5 (xml_config )
3095+ headers ['Content-Type' ] = 'application/xml'
3096+ params = {'inventory' : '' , 'id' : Id }
3097+ url = self ._conf .uri (bucket = Bucket )
3098+ logger .info ("post bucket inventory, url=:{url} ,headers=:{headers}" .format (
3099+ url = url ,
3100+ headers = headers ))
3101+ rt = self .send_request (
3102+ method = 'POST' ,
3103+ url = url ,
3104+ bucket = Bucket ,
3105+ data = xml_config ,
3106+ auth = CosS3Auth (self ._conf , params = params ),
3107+ headers = headers ,
3108+ params = params )
3109+ return None
3110+
30453111 def put_object_tagging (self , Bucket , Key , Tagging = {}, ** kwargs ):
30463112 """设置object的标签
30473113
0 commit comments