GetBucketLifecycle
更新时间:2024-03-29
接口描述
此接口用于获取定义的生命周期管理规则详细信息。
请求(Request)
-
请求语法
Plain Text1GET /?lifecycle HTTP/1.1 2Host: <BucketName>.bj.bcebos.com 3Date: date 4Authorization: AuthorizationString
-
请求头域
无特殊参数
-
请求参数
无特殊参数
响应(Response)
-
请求参数
规则项 描述 是否必填 备注 rule 规则的列表 必填 所有规则的列表 +id 规则的标识符。 必填 同一个bucket内规则id必须唯一,不能重复。如果用户不填系统会自动帮用户生成一个。 +status 规则的状态。 必填 取值为 enabled
或disabled
,当规则处于disabled
时规则不生效。+resource 规则对哪些资源生效。 必填 举例:对samplebucket里以prefix/为前缀的Object生效: samplebucket/prefix/*
;对samplebucket里所有Object生效:samplebucket/*
。+condition 规则依赖的条件。 选填 目前只支持time形式,基础生命周期规则下为必填项。 +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
。+storageClass Object的存储类型 可选 action为 Transition
时可以设定,取值为STANDARD_IA
或COLD
或ARCHIVE
,表示从原存储类型转为低频存储或冷存储或归档存储。 -
响应元素
无特殊元素
-
响应头域
无特殊头域
注意事项
- 如果请求的源Bucket不存在,返回404错误,错误码为NoSuchBucket。
- 如果请求的源Bucket没有配置lifecycle,返回404错误,错误码为NoLifecycleConfiguration。
基础生命周期请求示例
-
请求示例
Plain Text1 GET /?lifecycle HTTP/1.1 2 Host: <BucketName>.bj.bcebos.com 3 Date: Thu, 15 Sep 2016 00:16:26 GMT 4 Authorization: AuthorizationString
-
响应示例
Plain Text1 HTTP/1.1 200 OK 2 Date: Thu, 15 Sep 2016 00:17:23 GMT 3 Server: BceBos 4 x-bce-request-id: 1a5fd81e-626b-45b3-a885-15fff9cd106c 5 Connection: keep-alive 6 Content-Length: 358 7 8 { 9 "rule": [ 10 { 11 "id": "sample-rule-delete-prefix", 12 "status": "enabled", 13 "resource": [ 14 "bucket/prefix/*" 15 ], 16 "condition": { 17 "time": { 18 "dateGreaterThan": "2016-09-07T00:00:00Z" 19 } 20 }, 21 "action": { 22 "name": "DeleteObject" 23 } 24 }, 25 { 26 "id": "sample-rule-transition-prefix", 27 "status": "enabled", 28 "resource": [ 29 "bucket/prefix/*" 30 ], 31 "condition": { 32 "time": { 33 "dateGreaterThan": "$(lastModified)+P7D" 34 } 35 }, 36 "action": { 37 "name": "Transition", 38 "storageClass": "STANDARD_IA" 39 } 40 }, 41 { 42 "id": "sample-rule-abort-multiupload-prefix", 43 "status": "enabled", 44 "resource": [ 45 "bucket/prefix/*" 46 ], 47 "condition": { 48 "time": { 49 "dateGreaterThan": "$(lastModified)+P7D" 50 } 51 }, 52 "action": { 53 "name": "AbortMultipartUpload" 54 } 55 } 56 ] 57 }
智能分层请求示例
-
请求语法
Plain Text1 GET /?lifecycle HTTP/1.1 2 Host: <BucketName>.bj.bcebos.com 3 Date: Tue, 26 Jul 2022 05:01:28 GMT 4 Authorization: AuthorizationString
-
响应示例
Plain Text1HTTP/1.1 200 OK 2Date: Tue, 26 Jul 2022 09:41:29 GMT 3Server: BceBos 4x-bce-request-id: ac07037d-f40e-45e0-b126-e38adc238cad 5Connection: keep-alive 6Content-Length: 740 7 8{ 9 "rule": [ 10 { 11 "id": "sample-rule-intelligent-tiering-prefix", 12 "status": "enabled", 13 "resource": [ 14 "bucket/*" 15 ], 16 "action": { 17 "name": "IntelligentTiering" 18 } 19 }, 20 { 21 "id": "sample-rule-delete-prefix", 22 "status": "enabled", 23 "resource": [ 24 "bucket/*" 25 ], 26 "condition": { 27 "time": { 28 "dateGreaterThan": "$(lastModified)+P365D" 29 } 30 }, 31 "action": { 32 "name": "DeleteObject" 33 } 34 }, 35 { 36 "id": "sample-rule-abort-multiupload-prefix", 37 "status": "enabled", 38 "resource": [ 39 "bucket/*" 40 ], 41 "condition": { 42 "time": { 43 "dateGreaterThan": "$(lastModified)+P7D" 44 } 45 }, 46 "action": { 47 "name": "AbortMultipartUpload" 48 } 49 } 50 ] 51}