/*
* Copyright (C) Alibaba Cloud Computing
* All rights reserved.
*
* 版权所有 (C)阿里云计算有限公司
*/
using System;
using System.Collections.Generic;
using Aliyun.OSS.Util;
namespace Aliyun.OSS
{
///
/// 设置存储空间生命周期的请求
///
public class SetBucketLifecycleRequest
{
private IList _lifecycleRules = new List();
///
/// 获取所在的名称。
///
public string BucketName { get; private set; }
///
/// Lifecycle规则列表,每个bucket最多允许1000条规则。
///
public IList LifecycleRules
{
get { return ((List)_lifecycleRules).AsReadOnly(); }
set
{
if (value == null)
throw new ArgumentException("LifecycleRule list should not be null.");
if (value.Count > OssUtils.LifecycleRuleLimit)
throw new ArgumentException("One bucket not allow exceed one thousand items of LifecycleRules.");
_lifecycleRules = value;
}
}
///
/// 构造一个新的实例。
///
/// 所在的名称
public SetBucketLifecycleRequest(string bucketName)
{
BucketName = bucketName;
}
///
/// 添加一条LifecycleRule。
///
///
public void AddLifecycleRule(LifecycleRule lifecycleRule)
{
if (lifecycleRule == null)
throw new ArgumentException("lifecycleRule should not be null or empty.");
if (_lifecycleRules.Count >= OssUtils.LifecycleRuleLimit)
throw new ArgumentException("One bucket not allow exceed one thousand item of LifecycleRules.");
if ((!lifecycleRule.ExpirationTime.HasValue && !lifecycleRule.ExpriationDays.HasValue)
|| (lifecycleRule.ExpirationTime.HasValue && lifecycleRule.ExpriationDays.HasValue))
{
throw new ArgumentException("Only one expiration property should be specified.");
}
_lifecycleRules.Add(lifecycleRule);
}
}
}