GetBucketLifecycle
調(diào)用GetBucketLifecycle接口查看存儲(chǔ)空間(Bucket)的生命周期規(guī)則(Lifecycle)。
注意事項(xiàng)
要查看Bucket的生命周期規(guī)則,您必須有oss:GetBucketLifecycle
權(quán)限。具體操作,請(qǐng)參見為RAM用戶授權(quán)自定義的權(quán)限策略。
請(qǐng)求語(yǔ)法
GET /?lifecycle HTTP/1.1
Host: BucketName.oss.aliyuncs.com
Date: GMT Date
Authorization: SignatureValue
當(dāng)您在OSS ON云盒中調(diào)用該接口時(shí),您需要將Host替換為云盒Endpoint。更多信息,請(qǐng)參見云盒Endpoint。
示例
請(qǐng)求示例
Get /?lifecycle HTTP/1.1
Host: oss-example.oss.aliyuncs.com
Date: Mon, 14 Apr 2014 01:17:29 GMT
Authorization: OSS qn6q**************:77Dv****************
返回示例
基于last modify time設(shè)置生命周期規(guī)則的返回示例
HTTP/1.1 200 x-oss-request-id: 534B371674E88A4D8906**** Date: Mon, 14 Apr 2014 01:17:29 GMT Connection: keep-alive Content-Length: 255 Server: AliyunOSS <?xml version="1.0" encoding="UTF-8"?> <LifecycleConfiguration> <Rule> <ID>delete after one day</ID> <Prefix>logs1/</Prefix> <Status>Enabled</Status> <Expiration> <Days>1</Days> </Expiration> </Rule> <Rule> <ID>mtime transition1</ID> <Prefix>logs2/</Prefix> <Status>Enabled</Status> <Transition> <Days>30</Days> <StorageClass>IA</StorageClass> </Transition> </Rule> <Rule> <ID>mtime transition2</ID> <Prefix>logs3/</Prefix> <Status>Enabled</Status> <Transition> <Days>30</Days> <StorageClass>IA</StorageClass> <IsAccessTime>false</IsAccessTime> </Transition> </Rule> </LifecycleConfiguration>
基于last access time設(shè)置生命周期規(guī)則的返回示例
說(shuō)明當(dāng)Bucket存在基于last access time匹配規(guī)則的生命周期規(guī)則時(shí),返回示例中會(huì)包含AtimeBase元素。該元素表示默認(rèn)last access time的時(shí)間戳(從1970-01-01 00:00:00 UTC計(jì)算起的秒數(shù)),即為Bucket開啟訪問(wèn)跟蹤時(shí)間點(diǎn)的時(shí)間戳。
HTTP/1.1 200 x-oss-request-id: **** Date: Mon, 26 Jul 2021 01:17:29 GMT Connection: keep-alive Content-Length: length Server: AliyunOSS <?xml version="1.0" encoding="UTF-8"?> <LifecycleConfiguration> <Rule> <ID>atime transition1</ID> <Prefix>logs1/</Prefix> <Status>Enabled</Status> <Transition> <Days>30</Days> <StorageClass>IA</StorageClass> <IsAccessTime>true</IsAccessTime> <ReturnToStdWhenVisit>false</ReturnToStdWhenVisit> </Transition> <AtimeBase>1631698332</AtimeBase> </Rule> <Rule> <ID>atime transition2</ID> <Prefix>logs2/</Prefix> <Status>Enabled</Status> <NoncurrentVersionTransition> <NoncurrentDays>10</NoncurrentDays> <StorageClass>IA</StorageClass> <IsAccessTime>true</IsAccessTime> <ReturnToStdWhenVisit>false</ReturnToStdWhenVisit> </NoncurrentVersionTransition> <AtimeBase>1631698332</AtimeBase> </Rule> </LifecycleConfiguration>
未設(shè)置生命周期規(guī)則的返回示例
HTTP/1.1 404 x-oss-request-id: 534B371674E88A4D8906**** Date: Mon, 14 Apr 2014 01:17:29 GMT Connection: keep-alive Content-Length: 278 Server: AliyunOSS <?xml version="1.0" encoding="UTF-8"?> <Error> <BucketName>oss-example</BucketName> <Code>NoSuchLifecycle</Code> <Message>No Row found in Lifecycle Table.</Message> <RequestId>534B372974E88A4D8906****</RequestId> <HostId> BucketName.oss.example.com</HostId> </Error>
SDK
此接口對(duì)應(yīng)的各語(yǔ)言SDK如下:
錯(cuò)誤碼
錯(cuò)誤碼 | HTTP狀態(tài)碼 | 描述 |
AccessDenied | 403 Forbidden | 沒(méi)有權(quán)限查看Bucket的生命周期規(guī)則。只有Bucket的擁有者才能查看Bucket的生命周期規(guī)則。 |
NoSuchBucket或NoSuchLifecycle | 404 Not Found | Bucket不存在或沒(méi)有配置生命周期規(guī)則。 |