예제 #1
0
        private static async Task LifecycleConfigAsync()
        {
            client = new AmazonS3Client(bucketRegion);
            string input = Console.ReadLine();

            try
            {
                int action = Convert.ToInt32(input);
                var lifeCycleConfiguration = new LifecycleConfiguration();
                switch (action)
                {
                case 1:
                    await AddUpdateDeleteLifecycleConfigAsync();

                    break;

                case 2:
                    lifeCycleConfiguration = await RetrieveLifecycleConfigAsync(client);

                    foreach (var rule in lifeCycleConfiguration.Rules)
                    {
                        Console.WriteLine("Rule Id {0} with status of {1} and expiration Days is ", rule.Id, rule.Status, rule.Expiration != null ? rule.Expiration.Days: 0);
                        Console.WriteLine("Transition");
                        foreach (var trans in rule.Transitions)
                        {
                            Console.WriteLine("Storage class {0}  and expiration Days is ", trans.StorageClass, trans.Days);
                        }
                        Console.WriteLine("Filter");
                        if (rule.Filter.LifecycleFilterPredicate is LifecyclePrefixPredicate)
                        {
                            LifecyclePrefixPredicate prefix = rule.Filter.LifecycleFilterPredicate as LifecyclePrefixPredicate;
                            Console.WriteLine("Filter Prefix {0}  and expiration Days is ", prefix.Prefix);
                        }
                        if (rule.Filter.LifecycleFilterPredicate is LifecycleTagPredicate)
                        {
                            LifecycleTagPredicate tags = rule.Filter.LifecycleFilterPredicate as LifecycleTagPredicate;
                            Console.WriteLine("Filter Tag Key {0}  and value ", tags.Tag.Key, tags.Tag.Value);
                        }
                        Console.WriteLine("*************************************");
                    }
                    break;

                case 3:
                    await RemoveLifecycleConfigAsync(client);

                    break;

                default:
                    break;
                }
            }
            catch (Exception e)
            {
                ErrorUtility.LogError(e, GApplication.Unknown, string.Format("Error: Lifecycle Error: " + e.Message));
            }
        }
 public void Visit(LifecycleTagPredicate lifecycleTagPredicate)
 {
     xmlWriter.WriteStartElement("Tag", "");
     if (lifecycleTagPredicate.IsSetTag())
     {
         xmlWriter.WriteElementString("Key", "", S3Transforms.ToXmlStringValue(lifecycleTagPredicate.Tag.Key));
         xmlWriter.WriteElementString("Value", "", S3Transforms.ToXmlStringValue(lifecycleTagPredicate.Tag.Value));
     }
     xmlWriter.WriteEndElement();
 }
예제 #3
0
 public void Visit(LifecycleTagPredicate lifecycleTagPredicate)
 {
     xmlWriter.WriteStartElement("Tag", "");
         if (lifecycleTagPredicate.IsSetTag())
         {
             xmlWriter.WriteElementString("Key", "", S3Transforms.ToXmlStringValue(lifecycleTagPredicate.Tag.Key));
             xmlWriter.WriteElementString("Value", "", S3Transforms.ToXmlStringValue(lifecycleTagPredicate.Tag.Value));
         }
     xmlWriter.WriteEndElement();
 }