功能说明
PutBucketLifecycle接口用于设置存储桶的生命周期规则。启用生命周期规则后,ZOS将按配置的规则对存储桶中匹配规则的对象进行转换存储类型或删除。
注意事项
每个桶的生命周期配置不能有重复的规则,两个规则重复是指两个规则的prefix、status、expiration、noncur_expiration、mp_expiration、transitions、noncur_transitions、dm_expiration均相同 。
请求消息样式
PUT /{Bucket}?lifecycle HTTP/1.1
Host: xxx.zos.ctyun.cn
Date: Date
Content-Length: ContentLength
Content-MD5: ContentMD5
X-Amz-Content-SHA256: Content-SHA256
Authorization: string
<?xml version="1.0" encoding="UTF-8"?>
<LifecycleConfiguration>
<Rule>
<AbortIncompleteMultipartUpload>
<DaysAfterInitiation>integer</DaysAfterInitiation>
</AbortIncompleteMultipartUpload>
<Expiration>
<Date>timestamp</Date>
<Days>integer</Days>
<ExpiredObjectDeleteMarker>boolean</ExpiredObjectDeleteMarker>
</Expiration>
<Filter>
<And>
<Prefix>string</Prefix>
<Tag>
<Key>string</Key>
<Value>string</Value>
</Tag>
...
</And>
<Prefix>string</Prefix>
<Tag>
<Key>string</Key>
<Value>string</Value>
</Tag>
</Filter>
<ID>string</ID>
<NoncurrentVersionExpiration>
<NoncurrentDays>integer</NoncurrentDays>
</NoncurrentVersionExpiration>
<NoncurrentVersionTransition>
<NoncurrentDays>integer</NoncurrentDays>
<StorageClass>string</StorageClass>
</NoncurrentVersionTransition>
...
<Prefix>string</Prefix>
<Status>string</Status>
<Transition>
<Date>timestamp</Date>
<Days>integer</Days>
<StorageClass>string</StorageClass>
</Transition>
...
</Rule>
...
</LifecycleConfiguration>请求消息参数
| 参数名称 | 参数描述 | 参数类型 | 是否必须 |
|---|---|---|---|
| Bucket | 参数解释: 指定存储桶名称。 | String | 是 |
请求消息头
| 参数名称 | 参数描述 | 参数类型 | 是否必须 |
|---|---|---|---|
| Content-MD5 | 参数解释: LifecycleConfiguration对应的md5值。 | String | 是 |
请求消息元素
| 参数名称 | 参数描述 | 参数类型 | 是否必须 |
|---|---|---|---|
| LifecycleConfiguration | 参数解释: 生命周期规则的容器,最多容纳1000条规则。 | Container | 是 |
表 LifecycleConfiguration
| 参数名称 | 参数描述 | 参数类型 | 是否必须 |
|---|---|---|---|
| LifecycleConfiguration | 参数解释: 生命周期规则的容器,最多容纳1000条规则。 | Container | 是 |
| Rule | 参数解释: 生命周期规则。 | Container | 是 |
| Expiration | 参数解释: 用日期或天数指定对象的过期时间。 | Container | 否 |
| Date | 参数解释: 标识对象的过期日期。 取值范围: 日期为ISO8601格式,必须为UTC午夜0时。 | Date | Date与Days二选一 |
| Days | 参数解释: 标识对象受规则约束的天数。 | Long | Date与Days二选一 |
| ID | 参数解释: 标识唯一的规则。 | String | 否,建议指定,如不指定,自动生成ID |
| Filter | 参数解释: 过滤应用规则的对象。 | Container | 否 |
| Prefix | 参数解释: 标识应用规则的对象前缀。 | String | 是 |
| Tag | 参数解释: 应用规则到拥有指定标签的对象。 | Container | 否 |
| Key | 参数解释: 标签的名称。 | String | 否 |
| Value | 参数解释: 标签的值。 | String | 否 |
| Status | 参数解释: 标识是否应用规则 。 取值范围: - Enabled - Disabled | String | 是 |
| Transtions | 参数解释: 标识对象何时转存到指定的Storage Class。 | Container | 否 |
| StorageClass | 参数解释: 标识要转存储到哪种存储类别。 取值范围: - STANDARD_IA(低频存储) - GLACIER(归档存储) | String | 如设置转存储规则,该字段必选 |
| NoncurrentVersionTransitions | 参数解释: 标识历史版本的转存储规则。 | Container | 否 |
| NoncurrentDays | 参数解释: 标识对象的历史版本受规则约束的天数。 | Long | 否 |
| NoncurrentVersionExpiration | 参数解释: 标识历史版本的过期规则。 | Container | 否 |
| AbortIncompleteMultipartUpload | 参数解释: 标识未完成的分段上传的过期属性。 | Container | 否 |
| DaysAfterInitiation | 参数解释: 标识为完成的分段的过期时间。 | Long | 否 |
| ExpiredObjectDeleteMarker | 参数解释: 标记多版本桶,是否要删除DeleteMarker。 取值范围: - true 约束限制: 不可设置为false | Boolen | 否 |
表 Rule
| 参数名称 | 参数描述 | 参数类型 | 是否必须 |
|---|---|---|---|
| ID | 参数解释: 标识唯一的规则。 | String | 否 |
| Filter | 参数解释: 过滤应用规则的对象。 | Container | 否 |
| Status | 参数解释: 标识是否应用规则。 取值范围: - Enabled - Disabled | String | 是 |
| Prefix | 参数解释: 标识应用规则的对象前缀。 | String | 是 |
| Expiration | 参数解释: 用日期或天数指定对象的过期时间。 | Container | 否 |
| Transtions | 参数解释: 标识对象何时转存到指定的 Storage Class。 | Container | 否 |
| NoncurrentVersionExpiration | 参数解释: 标识历史版本的过期规则。 | Container | 否 |
| NoncurrentVersionTransitions | 参数解释: 标识历史版本的转存储规则。 | Container | 否 |
| AbortIncompleteMultipartUpload | 参数解释: 标识未完成的分段上传的过期属性。 | Container | 否 |
表 Expiration
| 参数名称 | 参数描述 | 参数类型 | 是否必须 |
|---|---|---|---|
| Date | 参数解释: 标识对象的过期日期 。 取值范围: 日期为 ISO8601 格式,必须为 UTC 午夜 0 时。 | Date | 否 |
| Days | 参数解释: 标识对象受规则约束的天数。 | Long | 否 |
| ExpiredObjectDeleteMarker | 参数解释: 标记多版本桶,是否要删除 DeleteMarker。 取值范围: - true 约束限制: 不可设置为 false | Boolen | 否 |
表 Filter
| 参数名称 | 参数描述 | 参数类型 | 是否必须 |
|---|---|---|---|
| And | 参数解释: And 标签条件的容器,用于指定多个条件。 | Container | 否 |
| Prefix | 参数解释: 标识应用规则的对象前缀。 | String | 否 |
| Tag | 参数解释: 应用规则到拥有指定标签的对象。 | Container | 否 |
表 And
| 参数名称 | 参数描述 | 参数类型 | 是否必须 |
|---|---|---|---|
| Prefix | 参数解释: 标识应用规则的对象前缀。 | String | 否 |
| Tag | 参数解释: 应用规则到拥有指定标签的对象。 | Container | 否 |
表 Tag
| 参数名称 | 参数描述 | 参数类型 | 是否必须 |
|---|---|---|---|
| Key | 参数解释: 标签的名称。 | String | 否 |
| Value | 参数解释: 标签的值。 | String | 否 |
表 Transition
| 参数名称 | 参数描述 | 参数类型 | 是否必须 |
|---|---|---|---|
| Date | 参数解释: 标识对象的转存日期。 取值范围: 日期为 ISO8601 格式,必须为 UTC 午夜 0 时。 | Date | 否 |
| Days | 参数解释: 标识对象受规则约束的天数。 | Long | 否 |
| StorageClass | 参数解释: 标识要转存储到哪种存储类别。 取值范围: - STANDARD_IA(低频存储) - GLACIER(归档存储) | String | 否 |
表 NoncurrentVersionTransition
| 参数名称 | 参数描述 | 参数类型 | 是否必须 |
|---|---|---|---|
| NoncurrentDays | 参数解释: 标识对象的历史版本受规则约束的天数。 | Long | 否 |
| StorageClass | 参数解释: 标识要转存储到哪种存储类别。 取值范围: - STANDARD_IA(低频存储) - GLACIER(归档存储) | String | 否 |
表 NoncurrentVersionExpiration
| 参数名称 | 参数描述 | 参数类型 | 是否必须 |
|---|---|---|---|
| NoncurrentDays | 参数解释: 标识对象的历史版本受规则约束的天数。 | Long | 否 |
表 AbortIncompleteMultipartUpload
| 参数名称 | 参数描述 | 参数类型 | 是否必须 |
|---|---|---|---|
| DaysAfterInitiation | 参数解释: 标识为完成的分段的过期时间。 | Long | 否 |
响应消息样式
HTTP/1.1 Status Code
x-amz-request-id: tx00000000000000000002e-00624e4358-1217b-default
Content-Type: application/xml
Content-Length: 0
Date: Thu, 07 Apr 2022 01:50:16 GMT
Connection: Keep-Alive响应消息头
该请求的响应消息使用公共的响应消息头,请参见如何调用API-响应结果-响应消息头。
响应消息元素
该请求的响应中不带有响应元素。
错误码
请参见调用前必知-错误码-全局错误码。