How to use delete_bucket_lifecycle method in localstack

Best Python code snippet using localstack_python

test_bucket.py

Source:test_bucket.py Github

copy

Full Screen

...118 expiration=LifecycleExpiration(days=356))119 lifecycle = BucketLifecycle([rule])120 self.bucket.put_bucket_lifecycle(lifecycle)121 self.retry_assert(lambda: self.same_lifecycle(rule, self.bucket))122 self.bucket.delete_bucket_lifecycle()123 self.bucket.delete_bucket_lifecycle()124 self.assertRaises(oss2.exceptions.NoSuchLifecycle, self.bucket.get_bucket_lifecycle)125 def test_put_lifecycle_days_less_than_transition_days(self):126 from oss2.models import LifecycleExpiration, LifecycleRule, BucketLifecycle127 rule = LifecycleRule(random_string(10), '中文前缀/',128 status=LifecycleRule.ENABLED,129 expiration=LifecycleExpiration(days=3))130 rule.storage_transitions = [oss2.models.StorageTransition(days=4, storage_class=oss2.BUCKET_STORAGE_CLASS_IA)]131 self.assertRaises(oss2.exceptions.InvalidArgument, self.bucket.put_bucket_lifecycle, BucketLifecycle([rule]))132 def test_put_lifecycle_invalid_transitions(self):133 from oss2.models import LifecycleExpiration, LifecycleRule, BucketLifecycle134 rule = LifecycleRule(random_string(10), '中文前缀/',135 status=LifecycleRule.ENABLED,136 expiration=LifecycleExpiration(days=6))137 # 转储为ARCHIVE的天数小于转储为IA138 rule.storage_transitions = [oss2.models.StorageTransition(days=5,139 storage_class=oss2.BUCKET_STORAGE_CLASS_IA),140 oss2.models.StorageTransition(days=2,141 storage_class=oss2.BUCKET_STORAGE_CLASS_ARCHIVE)]142 self.assertRaises(oss2.exceptions.InvalidArgument, self.bucket.put_bucket_lifecycle, BucketLifecycle([rule]))143 # 转储为IA(天数大于object过期时间)144 rule.storage_transitions = [oss2.models.StorageTransition(days=7,145 storage_class=oss2.BUCKET_STORAGE_CLASS_IA)]146 self.assertRaises(oss2.exceptions.InvalidArgument, self.bucket.put_bucket_lifecycle, BucketLifecycle([rule]))147 # 转储为STANDARD148 rule.storage_transitions = [oss2.models.StorageTransition(days=5,149 storage_class=oss2.BUCKET_STORAGE_CLASS_STANDARD)]150 self.assertRaises(oss2.exceptions.InvalidArgument, self.bucket.put_bucket_lifecycle, BucketLifecycle([rule]))151 def test_lifecycle_date(self):152 from oss2.models import LifecycleExpiration, LifecycleRule, BucketLifecycle153 rule = LifecycleRule(random_string(10), '中文前缀/',154 status=LifecycleRule.ENABLED,155 expiration=LifecycleExpiration(date=datetime.date(2016, 12, 25)))156 lifecycle = BucketLifecycle([rule])157 self.bucket.put_bucket_lifecycle(lifecycle)158 self.retry_assert(lambda: self.same_lifecycle(rule, self.bucket))159 self.bucket.delete_bucket_lifecycle()160 def test_lifecycle_created_before_date(self):161 from oss2.models import LifecycleExpiration, LifecycleRule, BucketLifecycle162 rule = LifecycleRule(random_string(10), '中文前缀/',163 status=LifecycleRule.ENABLED,164 expiration=LifecycleExpiration(created_before_date=datetime.date(2016, 12, 25)))165 lifecycle = BucketLifecycle([rule])166 self.bucket.put_bucket_lifecycle(lifecycle)167 self.retry_assert(lambda: self.same_lifecycle(rule, self.bucket))168 self.bucket.delete_bucket_lifecycle()169 def test_lifecycle_abort_multipart_upload_days(self):170 from oss2.models import LifecycleExpiration, LifecycleRule, BucketLifecycle, AbortMultipartUpload171 rule = LifecycleRule(random_string(10), '中文前缀/',172 status=LifecycleRule.ENABLED,173 expiration=LifecycleExpiration(created_before_date=datetime.date(2016, 12, 25)))174 rule.abort_multipart_upload = AbortMultipartUpload(days=356)175 lifecycle = BucketLifecycle([rule])176 self.bucket.put_bucket_lifecycle(lifecycle)177 self.retry_assert(lambda: self.same_lifecycle(rule, self.bucket))178 result = self.bucket.get_bucket_lifecycle()179 self.assertEqual(1, len(result.rules))180 self.assertEqual(356, result.rules[0].abort_multipart_upload.days)181 self.assertTrue(result.rules[0].tagging is None)182 self.bucket.delete_bucket_lifecycle()183 def test_lifecycle_abort_multipart_upload_date(self):184 from oss2.models import LifecycleExpiration, LifecycleRule, BucketLifecycle, AbortMultipartUpload185 rule = LifecycleRule(random_string(10), '中文前缀/',186 status=LifecycleRule.ENABLED,187 expiration=LifecycleExpiration(created_before_date=datetime.date(2016, 12, 25)))188 rule.abort_multipart_upload = AbortMultipartUpload(created_before_date=datetime.date(2016, 12, 20))189 lifecycle = BucketLifecycle([rule])190 self.bucket.put_bucket_lifecycle(lifecycle)191 wait_meta_sync()192 result = self.bucket.get_bucket_lifecycle()193 self.assertEqual(1, len(result.rules))194 self.assertEqual(datetime.date(2016, 12, 20), result.rules[0].abort_multipart_upload.created_before_date)195 196 self.assertTrue(result.rules[0].tagging is None)197 self.bucket.delete_bucket_lifecycle()198 def test_lifecycle_storage_transitions_mixed(self):199 from oss2.models import LifecycleExpiration, LifecycleRule, BucketLifecycle, StorageTransition200 rule = LifecycleRule(random_string(10), '中文前缀/',201 status=LifecycleRule.ENABLED,202 expiration=LifecycleExpiration(created_before_date=datetime.date(2016, 12, 25)))203 rule.storage_transitions = [StorageTransition(days=356, storage_class=oss2.BUCKET_STORAGE_CLASS_IA)]204 lifecycle = BucketLifecycle([rule])205 self.assertRaises(oss2.exceptions.InvalidRequest, self.bucket.put_bucket_lifecycle, lifecycle)206 def test_lifecycle_storage_transitions_days(self):207 from oss2.models import LifecycleExpiration, LifecycleRule, BucketLifecycle, StorageTransition208 rule = LifecycleRule(random_string(10), '中文前缀/',209 status=LifecycleRule.ENABLED,210 expiration=LifecycleExpiration(days=357))211 rule.storage_transitions = [StorageTransition(days=356, storage_class=oss2.BUCKET_STORAGE_CLASS_IA)]212 lifecycle = BucketLifecycle([rule])213 self.bucket.put_bucket_lifecycle(lifecycle)214 wait_meta_sync()215 result = self.bucket.get_bucket_lifecycle()216 self.assertEqual(1, len(result.rules))217 self.assertEqual(1, len(result.rules[0].storage_transitions))218 self.assertEqual(356, result.rules[0].storage_transitions[0].days)219 self.assertTrue(result.rules[0].tagging is None)220 self.bucket.delete_bucket_lifecycle()221 def test_lifecycle_storage_transitions_more_days(self):222 from oss2.models import LifecycleExpiration, LifecycleRule, BucketLifecycle, StorageTransition223 rule = LifecycleRule(random_string(10), '中文前缀/',224 status=LifecycleRule.ENABLED,225 expiration=LifecycleExpiration(days=357))226 rule.storage_transitions = [StorageTransition(days=355, storage_class=oss2.BUCKET_STORAGE_CLASS_IA),227 StorageTransition(days=356, storage_class=oss2.BUCKET_STORAGE_CLASS_ARCHIVE)]228 lifecycle = BucketLifecycle([rule])229 self.bucket.put_bucket_lifecycle(lifecycle)230 wait_meta_sync()231 result = self.bucket.get_bucket_lifecycle()232 self.assertEqual(1, len(result.rules))233 self.assertEqual(2, len(result.rules[0].storage_transitions))234 self.assertTrue(result.rules[0].tagging is None)235 if result.rules[0].storage_transitions[0].storage_class == oss2.BUCKET_STORAGE_CLASS_IA:236 self.assertEqual(355, result.rules[0].storage_transitions[0].days)237 self.assertEqual(356, result.rules[0].storage_transitions[1].days)238 self.assertEqual(oss2.BUCKET_STORAGE_CLASS_ARCHIVE, result.rules[0].storage_transitions[1].storage_class)239 else:240 self.assertEqual(356, result.rules[0].storage_transitions[0].days)241 self.assertEqual(356, result.rules[0].storage_transitions[1].days)242 self.assertEqual(oss2.BUCKET_STORAGE_CLASS_IA, result.rules[0].storage_transitions[1].storage_class)243 self.bucket.delete_bucket_lifecycle()244 def test_lifecycle_storage_transitions_date(self):245 from oss2.models import LifecycleExpiration, LifecycleRule, BucketLifecycle, StorageTransition246 rule = LifecycleRule(random_string(10), '中文前缀/',247 status=LifecycleRule.ENABLED,248 expiration=LifecycleExpiration(created_before_date=datetime.date(2016, 12, 25)))249 rule.storage_transitions = [StorageTransition(created_before_date=datetime.date(2016, 12, 20),250 storage_class=oss2.BUCKET_STORAGE_CLASS_IA)]251 lifecycle = BucketLifecycle([rule])252 self.bucket.put_bucket_lifecycle(lifecycle)253 wait_meta_sync()254 result = self.bucket.get_bucket_lifecycle()255 self.assertEqual(1, len(result.rules))256 self.assertEqual(1, len(result.rules[0].storage_transitions))257 self.assertEqual(datetime.date(2016, 12, 20), result.rules[0].storage_transitions[0].created_before_date)258 self.assertTrue(result.rules[0].tagging is None)259 self.bucket.delete_bucket_lifecycle()260 def test_lifecycle_object_tagging(self):261 from oss2.models import LifecycleExpiration, LifecycleRule, BucketLifecycle, StorageTransition, Tagging, TaggingRule262 rule = LifecycleRule(random_string(10), 'aaaaaaaaaaa/',263 status=LifecycleRule.ENABLED,264 expiration=LifecycleExpiration(created_before_date=datetime.date(2016, 12, 25)))265 rule.storage_transitions = [StorageTransition(created_before_date=datetime.date(2016, 12, 20),266 storage_class=oss2.BUCKET_STORAGE_CLASS_IA)]267 tagging_rule = TaggingRule()268 tagging_rule.add('test_key', 'test_value')269 tagging = Tagging(tagging_rule)270 rule.tagging = tagging271 lifecycle = BucketLifecycle([rule])272 self.bucket.put_bucket_lifecycle(lifecycle)273 wait_meta_sync()274 result = self.bucket.get_bucket_lifecycle()275 self.assertEqual(1, len(result.rules))276 self.assertEqual(1, len(result.rules[0].storage_transitions))277 self.assertEqual(datetime.date(2016, 12, 20), result.rules[0].storage_transitions[0].created_before_date)278 self.assertEqual(1, result.rules[0].tagging.tag_set.len())279 self.assertEqual('test_value', result.rules[0].tagging.tag_set.tagging_rule['test_key'])280 self.bucket.delete_bucket_lifecycle()281 def test_lifecycle_all_without_object_expiration(self):282 from oss2.models import LifecycleRule, BucketLifecycle, AbortMultipartUpload, StorageTransition283 rule = LifecycleRule(random_string(10), '中文前缀/',284 status=LifecycleRule.ENABLED)285 rule.abort_multipart_upload = AbortMultipartUpload(days=356)286 rule.storage_transitions = [StorageTransition(days=356, storage_class=oss2.BUCKET_STORAGE_CLASS_IA)]287 lifecycle = BucketLifecycle([rule])288 self.bucket.put_bucket_lifecycle(lifecycle)289 wait_meta_sync()290 result = self.bucket.get_bucket_lifecycle()291 self.assertEqual(1, len(result.rules))292 self.assertEqual(356, result.rules[0].abort_multipart_upload.days)293 self.assertEqual(1, len(result.rules[0].storage_transitions))294 self.assertEqual(356, result.rules[0].storage_transitions[0].days)295 self.bucket.delete_bucket_lifecycle()296 def test_lifecycle_all(self):297 from oss2.models import LifecycleExpiration, LifecycleRule, BucketLifecycle, AbortMultipartUpload, StorageTransition298 rule = LifecycleRule(random_string(10), '中文前缀/',299 status=LifecycleRule.ENABLED,300 expiration=LifecycleExpiration(days=357))301 self.assertRaises(oss2.exceptions.ClientError,302 LifecycleExpiration, days=356, created_before_date=datetime.date(2016, 12, 25))303 self.assertRaises(oss2.exceptions.ClientError,304 AbortMultipartUpload, days=356, created_before_date=datetime.date(2016, 12, 25))305 self.assertRaises(oss2.exceptions.ClientError,306 StorageTransition, days=356, created_before_date=datetime.date(2016, 12, 25))307 rule.abort_multipart_upload = AbortMultipartUpload(days=356)308 rule.storage_transitions = [StorageTransition(days=356, storage_class=oss2.BUCKET_STORAGE_CLASS_IA)]309 lifecycle = BucketLifecycle([rule])310 self.bucket.put_bucket_lifecycle(lifecycle)311 result = self.bucket.get_bucket_lifecycle()312 self.assertEqual(1, len(result.rules))313 self.assertEqual(356, result.rules[0].abort_multipart_upload.days)314 self.assertEqual(1, len(result.rules[0].storage_transitions))315 self.assertEqual(356, result.rules[0].storage_transitions[0].days)316 self.bucket.delete_bucket_lifecycle()317 def test_lifecycle_object_tagging_exceptions_wrong_key(self):318 from oss2.models import LifecycleExpiration, LifecycleRule, BucketLifecycle, StorageTransition, Tagging, TaggingRule319 rule = LifecycleRule(random_string(10), '中文前缀/',320 status=LifecycleRule.ENABLED,321 expiration=LifecycleExpiration(created_before_date=datetime.date(2016, 12, 25)))322 rule.storage_transitions = [StorageTransition(created_before_date=datetime.date(2016, 12, 20),323 storage_class=oss2.BUCKET_STORAGE_CLASS_IA)]324 tagging = Tagging()325 326 tagging.tag_set.tagging_rule[129*'a'] = 'test'327 rule.tagging = tagging328 lifecycle = BucketLifecycle([rule])329 330 try:...

Full Screen

Full Screen

lifecycleModule_tests.py

Source:lifecycleModule_tests.py Github

copy

Full Screen

...33 print reply34 except:35 print "Expect to fail"36 #case 437 response = s3.delete_bucket_lifecycle(Bucket='mvensky-single-level')38 reply = lifecycleModule.main('mvensky-single-level', "one", 30, None, "False")39 try:40 assert reply['glacierOnly']41 print "Glacier only passed"42 print "Case 4"43 print reply44 except:45 pass46 #case 547 response = s3.delete_bucket_lifecycle(Bucket='mvensky-single-level')48 reply = lifecycleModule.main('mvensky-single-level', "one", 30, None, "True")49 try:50 assert reply['glacierOnly']51 print "Glacier only passed"52 print "Case 5"53 print reply54 except:55 pass56 #case 6 57 response = s3.delete_bucket_lifecycle(Bucket='mvenskybucketoregon')58 reply = lifecycleModule.main('mvenskybucketoregon', "one", 30, 365, "True")59 try:60 assert reply['glacierAndExpire']61 print "Expire and glacier passed"62 print "Case 6"63 print reply64 except:65 print reply66 # case 767 reply = lifecycleModule.main('mvensky-second', "one", 30, None, "True")68 try:69 assert reply['glacierOnly']70 print "Glacier only passed"71 print "Case 7"72 print reply73 except:74 pass75 # case 876 response = s3.delete_bucket_lifecycle(Bucket='mvenskybucketoregon')77 reply = lifecycleModule.main('mvenskybucketoregon', "one", 30, 365, "False")78 try:79 assert reply['glacierAndExpire']80 print "Expire and glacier passed"81 print "Case 8"82 print reply83 except:84 pass85 # case 986 # check for tooMany87 reply = lifecycleModule.main('mvensky-many-folders', "two", 30, 365, "False")88 try:89 assert reply['glacierAndExpire']90 print "Expire and glacier passed"...

Full Screen

Full Screen

bucket_lifecycle.py

Source:bucket_lifecycle.py Github

copy

Full Screen

...48 )49 50 #.cssg-snippet-body-end51# 删除存储桶生命周期52def delete_bucket_lifecycle():53 #.cssg-snippet-body-start:[delete-bucket-lifecycle]54 response = client.delete_bucket_lifecycle(55 Bucket='examplebucket-1250000000',56 )57 58 #.cssg-snippet-body-end59#.cssg-methods-pragma60# 设置存储桶生命周期61put_bucket_lifecycle()62# 获取存储桶生命周期63get_bucket_lifecycle()64# 删除存储桶生命周期65delete_bucket_lifecycle()...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run localstack automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful