PutBucketLifecycle
更新时间:2022-07-26
接口描述
本接口用来创建生命周期管理规则。
注意:
- 只有bucket的owner且拥有FULL_CONTROL权限才能够进行此请求。
- PutBucketLifecycle会覆盖原有的生命周期规则, 如果需要在原有规则基础上新增, 需要在请求中携带所有新旧规则。
请求(Request)
-
请求语法
PUT /?lifecycle HTTP/1.1 Host: <BucketName>.bj.bcebos.com x-bce-date: date Content-Length: request-body length Content-Type: application/json; charset=utf-8 Authorization: AuthorizationString { "rule": [{ "id": "rule-id", "status": "enabled", "resource": [ "bucket/prefix/*" ], "condition": { "time": { "dateGreaterThan": "2016-09-07T00:00:00Z" } }, "action": { "name": "DeleteObject" } }] }
-
请求头域
无特殊参数
-
请求参数
规则项 描述 是否必须 备注 rule 规则的列表 是 所有规则的列表 +id 规则的标识符。 是 同一个bucket内规则id必须唯一,不能重复。如果用户不填系统会自动帮用户生成一个。 +status 规则的状态。 是 取值为 enabled
或disabled
,当规则处于disabled
时规则不生效。+resource 规则对哪些资源生效。 是 举例:对samplebucket里以prefix/为前缀的Object生效: samplebucket/prefix/*
;对samplebucket里所有Object生效:samplebucket/*
。+condition 规则依赖的条件。 是 目前只支持time形式,智能分层规则返回值为null +time 时间限制条件。 否 通过定义的 dateGreaterThan
实现。++dateGreaterThan 描述时间关系。 否 支持绝对时间date和相对时间days。绝对时间date格式为yyyy-mm-ddThh:mm:ssZ,eg. 2016-09-07T00:00:00Z。绝对时间为UTC时间, 必须以00:00:00(UTC 0点)结尾;相对时间days的描述遵循ISO8601, 支持的最小时间粒度为天,如: $(lastModified)+P7D表示的时间为object的last-modified之后7天。 action 对resource执行的操作动作。 是 - +name 执行的操作名称。 是 取值为 Transition
、DeleteObject
、AbortMultipartUpload
、IntelligentTiering
。+storageClass Object的存储类型 否 action为 Transition
时可以设定,非多AZ bucket的取值为STANDARD_IA
或COLD
或ARCHIVE
,表示从原存储类型转为低频存储或冷存储或归档存储;对于多AZ的bucket,取值只能为STANDARD_IA
,表示从原存储类型转为低频存储,智能分层规则返回null。
响应(Response)
基础生命周期管理请求示例
-
请求示例
PUT /?lifecycle HTTP/1.1 Host: bucket.bj.bcebos.com x-bce-date: 2016-08-16T08:23:49Z Content-Length :1324 Content-Type: application/json; charset=utf-8 Authorization: AuthorizationString { "rule": [ { "id": "sample-rule-delete-prefix", "status": "enabled", "resource": [ "bucket/prefix/*" ], "condition": { "time": { "dateGreaterThan": "2016-09-07T00:00:00Z" } }, "action": { "name": "DeleteObject" } }, { "id": "sample-rule-transition-prefix", "status": "enabled", "resource": [ "bucket/prefix/*" ], "condition": { "time": { "dateGreaterThan": "$(lastModified)+P7D" } }, "action": { "name": "Transition", "storageClass": "STANDARD_IA" } }, { "id": "sample-rule-abort-multiupload-prefix", "status": "enabled", "resource": [ "bucket/prefix/*" ], "condition": { "time": { "dateGreaterThan": "$(lastModified)+P7D" } }, "action": { "name": "AbortMultipartUpload" } } ] }
-
响应示例
HTTP/1.1 200 OK x-bce-request-id: 0A49CE4060975EAC Date: Wed, 12 Oct 2016 17:50:00 GMT Content-Length: 0 Connection: keep-alive Server: BceBos
智能分层管理请求示例
-
请求示例
PUT /?lifecycle HTTP/1.1 Host: bucket.bj.bcebos.com x-bce-date: 2022-07-26T17:18:55Z Content-Length: 576 Content-Type: application/json; charset=utf-8 Authorization: AuthorizationString { "rule": [ { "action": { "name": "IntelligentTiering" }, "id": "sample-rule-intelligent-tiering-prefix", "resource": [ "bucket/*" ], "status": "enabled" }, { "id": "sample-rule-delete-prefix", "status": "enabled", "resource": [ "bucket/prefix/*" ], "condition": { "time": { "dateGreaterThan": "2022-07-27T00:00:00Z" } }, "action": { "name": "DeleteObject" } }, { "id": "sample-rule-abort-multiupload-prefix", "status": "enabled", "resource": [ "bucket/prefix/*" ], "condition": { "time": { "dateGreaterThan": "$(lastModified)+P7D" } }, "action": { "name": "AbortMultipartUpload" } } ] }
-
响应示例
HTTP/1.1 200 OK x-bce-request-id: FSZ89ESW7DS6FA9 Date: Wed, Tue, 26 Jul 2022 05:01:28 GMT Content-Length: 0 Connection: keep-alive Server: BceBos