123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335 |
- using System;
- using System.Collections.Generic;
- using System.Xml.Serialization;
- using System.Text;
- namespace COSXML.Model.Tag
- {
- [XmlRoot("LifecycleConfiguration")]
- public sealed class LifecycleConfiguration
- {
- /// <summary>
- /// 规则描述
- /// <see href="Rule"/>
- /// </summary>
- [XmlElement("Rule")]
- public List<Rule> rules;
- public string GetInfo()
- {
- StringBuilder stringBuilder = new StringBuilder("{LifecycleConfiguration:\n");
- if (rules != null)
- {
- foreach (Rule rule in rules)
- {
- if (rule != null)
- {
- stringBuilder.Append(rule.GetInfo()).Append("\n");
- }
- }
- }
- stringBuilder.Append("}");
- return stringBuilder.ToString();
- }
- public sealed class Rule
- {
- /// <summary>
- /// 用于唯一标识规则,长度不能超过 255 个字符
- /// </summary>
- [XmlElement("ID")]
- public string id;
- /// <summary>
- /// Filter 用于描述规则影响的 Object 集合
- /// <see href="Filter"/>
- /// </summary>
- [XmlElement("Filter")]
- public Filter filter;
- /// <summary>
- /// 指明规则是否启用,枚举值:Enabled,Disabled
- /// </summary>
- [XmlElement("Status")]
- public string status;
- /// <summary>
- /// 规则转换属性,对象何时转换为 Standard_IA 或 Archive
- /// <see href="Transition"/>
- /// </summary>
- [XmlElement("Transition")]
- public Transition transition;
- /// <summary>
- /// 规则过期属性
- /// <see href="Expiration"/>
- /// </summary>
- [XmlElement("Expiration")]
- public Expiration expiration;
- /// <summary>
- /// 指明非当前版本对象何时过期
- /// <see href="NoncurrentVersionExpiration"/>
- /// </summary>
- [XmlElement("NoncurrentVersionExpiration")]
- public NoncurrentVersionExpiration noncurrentVersionExpiration;
- /// <summary>
- /// 指明非当前版本对象何时转换为 STANDARD_IA 或 ARCHIVE
- /// <see href="NoncurrentVersionTransition"/>
- /// </summary>
- [XmlElement("NoncurrentVersionTransition")]
- public NoncurrentVersionTransition noncurrentVersionTransition;
- /// <summary>
- /// 设置允许分片上传保持运行的最长时间
- /// <see href="AbortIncompleteMultiUpload"/>
- /// </summary>
- [XmlElement("AbortIncompleteMultipartUpload")]
- public AbortIncompleteMultiUpload abortIncompleteMultiUpload;
- public string GetInfo()
- {
- StringBuilder stringBuilder = new StringBuilder("{Rule:\n");
- stringBuilder.Append("Id:").Append(id).Append("\n");
- if (filter != null)
- {
- stringBuilder.Append(filter.GetInfo()).Append("\n");
- }
- stringBuilder.Append("Status:").Append(status).Append("\n");
- if (transition != null)
- {
- stringBuilder.Append(transition.GetInfo()).Append("\n");
- }
- if (expiration != null)
- {
- stringBuilder.Append(expiration.GetInfo()).Append("\n");
- }
- if (noncurrentVersionExpiration != null)
- {
- stringBuilder.Append(noncurrentVersionExpiration.GetInfo()).Append("\n");
- }
- if (noncurrentVersionTransition != null)
- {
- stringBuilder.Append(noncurrentVersionTransition.GetInfo()).Append("\n");
- }
- if (abortIncompleteMultiUpload != null)
- {
- stringBuilder.Append(abortIncompleteMultiUpload.GetInfo()).Append("\n");
- }
- stringBuilder.Append("}");
- return stringBuilder.ToString();
- }
- }
- public sealed class Filter
- {
- /// <summary>
- /// 指定规则所适用的前缀。匹配前缀的对象受该规则影响,Prefix 最多只能有一个
- /// </summary>
- [XmlElement("Prefix")]
- public string prefix;
- [XmlElement("And")]
- public FilterAnd filterAnd;
- public string GetInfo()
- {
- StringBuilder stringBuilder = new StringBuilder("{Filter:\n");
- stringBuilder.Append("Prefix:").Append(prefix).Append("\n");
- if (filterAnd != null)
- {
- stringBuilder.Append(filterAnd.GetInfo()).Append("\n");
- }
- stringBuilder.Append("}");
- return stringBuilder.ToString();
- }
- }
- public sealed class FilterAnd
- {
- [XmlElement("Prefix")]
- public string prefix;
- [XmlElement("Tag")]
- public List<Tagging.Tag> tags;
- public string GetInfo()
- {
- StringBuilder stringBuilder = new StringBuilder("{And:\n");
- stringBuilder.Append("Prefix:").Append(prefix).Append("\n");
- stringBuilder.Append("}");
- return stringBuilder.ToString();
- }
- }
- public sealed class Transition
- {
- /// <summary>
- /// 指明规则对应的动作在对象最后的修改日期过后多少天操作
- /// </summary>
- [XmlElement("Days")]
- public int days;
- /// <summary>
- /// 指明规则对应的动作在何时操作
- /// </summary>
- [XmlElement("Date")]
- public string date;
- /// <summary>
- /// 指定 Object 转储到的目标存储类型,枚举值: STANDARD_IA, ARCHIVE
- /// <see href="COSXML.Common.CosStorageClass"/>
- /// </summary>
- [XmlElement("StorageClass")]
- public string storageClass;
- public string GetInfo()
- {
- StringBuilder stringBuilder = new StringBuilder("{Transition:\n");
- stringBuilder.Append("Days:").Append(days).Append("\n");
- stringBuilder.Append("Date:").Append(date).Append("\n");
- stringBuilder.Append("StorageClass:").Append(storageClass).Append("\n");
- stringBuilder.Append("}");
- return stringBuilder.ToString();
- }
- public bool ShouldSerializedays()
- {
- return days > 0;
- }
- }
- public sealed class Expiration
- {
- /// <summary>
- /// 指明规则对应的动作在何时操作
- /// </summary>
- [XmlElement("Date")]
- public string date;
- /// <summary>
- /// 指明规则对应的动作在对象最后的修改日期过后多少天操作
- /// </summary>
- [XmlElement("Days")]
- public int days;
- /// <summary>
- /// 删除过期对象删除标记,取值为 true,false
- /// </summary>
- [XmlElement("ExpiredObjectDeleteMarker")]
- public bool expiredObjectDeleteMarker;
- public string GetInfo()
- {
- StringBuilder stringBuilder = new StringBuilder("{Expiration:\n");
- stringBuilder.Append("Days:").Append(days).Append("\n");
- stringBuilder.Append("Date:").Append(date).Append("\n");
- stringBuilder.Append("ExpiredObjectDeleteMarker:").Append(expiredObjectDeleteMarker).Append("\n");
- stringBuilder.Append("}");
- return stringBuilder.ToString();
- }
- public bool ShouldSerializedays()
- {
- return days > 0;
- }
- public bool ShouldSerializeexpiredObjectDeleteMarker()
- {
- return expiredObjectDeleteMarker;
- }
- }
- public sealed class NoncurrentVersionExpiration
- {
- /// <summary>
- /// 指明规则对应的动作在对象变成非当前版本多少天后执行
- /// </summary>
- [XmlElement("NoncurrentDays")]
- public int noncurrentDays;
- public string GetInfo()
- {
- StringBuilder stringBuilder = new StringBuilder("{NoncurrentVersionExpiration:\n");
- stringBuilder.Append("NoncurrentDays:").Append(noncurrentDays).Append("\n");
- stringBuilder.Append("}");
- return stringBuilder.ToString();
- }
- }
- public sealed class NoncurrentVersionTransition
- {
- /// <summary>
- /// 指明规则对应的动作在对象变成非当前版本多少天后执行
- /// </summary>
- [XmlElement("NoncurrentDays")]
- public int noncurrentDays;
- /// <summary>
- /// 指定 Object 转储到的目标存储类型
- /// <see href="COSXML.Common.CosStorageClass"/>
- /// </summary>
- [XmlElement("StorageClass")]
- public string storageClass;
- public string GetInfo()
- {
- StringBuilder stringBuilder = new StringBuilder("{NoncurrentVersionTransition:\n");
- stringBuilder.Append("NoncurrentDays:").Append(noncurrentDays).Append("\n");
- stringBuilder.Append("StorageClass:").Append(storageClass).Append("\n");
- stringBuilder.Append("}");
- return stringBuilder.ToString();
- }
- }
- public sealed class AbortIncompleteMultiUpload
- {
- /// <summary>
- /// 指明分片上传开始后多少天内必须完成上传
- /// </summary>
- [XmlElement("DaysAfterInitiation")]
- public int daysAfterInitiation;
- public string GetInfo()
- {
- StringBuilder stringBuilder = new StringBuilder("{AbortIncompleteMultiUpload:\n");
- stringBuilder.Append("DaysAfterInitiation:").Append(daysAfterInitiation).Append("\n");
- stringBuilder.Append("}");
- return stringBuilder.ToString();
- }
- }
- }
- }
|