示例#1
0
        private string MarshallRequest(LifecycleFilter filter, string prefix = null)
        {
            var request = new PutLifecycleConfigurationRequest()
            {
                BucketName    = "bucket",
                Configuration = new LifecycleConfiguration()
                {
                    Rules = new List <LifecycleRule>()
                    {
                        new LifecycleRule()
                        {
                            Prefix      = prefix,
                            Filter      = filter,
                            Transitions = new List <LifecycleTransition>()
                            {
                                new LifecycleTransition()
                                {
                                    Days         = 1,
                                    StorageClass = S3StorageClass.Glacier
                                }
                            }
                        }
                    }
                }
            };

            return(Encoding.UTF8.GetString(new PutLifecycleConfigurationRequestMarshaller().Marshall(request).Content));
        }
示例#2
0
 private static void AssertFiltersAreEqual(LifecycleFilter expected, LifecycleFilter actual)
 {
     if (expected == null)
     {
         Assert.IsNull(actual);
     }
     else
     {
         AssertPredicatesAreEqual(expected.LifecycleFilterPredicate, actual.LifecycleFilterPredicate);
     }
 }
示例#3
0
        private static void TestLifecycleFilterPredicate(LifecycleFilterPredicate predicate, AmazonS3Client client = null)
        {
            var filter = new LifecycleFilter()
            {
                LifecycleFilterPredicate = predicate
            };

            var rule = new LifecycleRule
            {
                Filter      = filter,
                Status      = LifecycleRuleStatus.Enabled,
                Transitions = new List <LifecycleTransition>()
                {
                    new LifecycleTransition
                    {
                        Days         = 1,
                        StorageClass = S3StorageClass.Glacier
                    }
                }
            };

            if (client == null)
            {
                client = Client;
            }

            client.PutLifecycleConfiguration(new PutLifecycleConfigurationRequest
            {
                BucketName    = bucketName,
                Configuration = new LifecycleConfiguration
                {
                    Rules = new List <LifecycleRule>
                    {
                        rule
                    }
                }
            });

            var actualConfig = S3TestUtils.WaitForConsistency(() =>
            {
                var res = client.GetLifecycleConfiguration(bucketName);
                return(res.Configuration?.Rules?.Count == 1 ? res.Configuration : null);
            });

            Assert.IsNotNull(actualConfig);
            Assert.IsNotNull(actualConfig.Rules);
            Assert.AreEqual(1, actualConfig.Rules.Count);
            AssertRulesAreEqual(rule, actualConfig.Rules[0]);
        }