from src.ossConfig import ossConfig import Oss as Oss access_key = 'XXXXXXXXX' secret_key = 'XXXXXXXXXXXXXXXXXXX' endpoint_url = 'http://XXXXXXXXXXXXXXXXX.com' config = ossConfig(access_key,secret_key,endpoint_url) bucket_name = 'test' #生命周期规则 LifecycleConfig={ 'Rules': [ { 'Expiration': { 'Days': expired_days, }, 'Filter': { 'Prefix': prefix, }, 'ID': rule_name, 'Status': 'Enabled', 'Transitions': [ { 'Days': transition_days, 'StorageClass': transition_class, }, ], }, ], } #设置生命周期 if Oss.put_buckets_lifecycle(config, bucket_name,LifecycleConfig): print("set lifecycle done") else: print("error") #获取生命周期 response = Oss.get_bucket_lifecycle(config, bucket_name) print(response) #删除生命周期 if Oss.delete_bucket_lifecycle(config, bucket_name): print("delete bucket lifecycle complete") else: print("error")
|