获取桶的生命周期配置
更新时间: 2019-03-13 10:30
功能说明
获取桶的生命周期规则。
方法定义
- func (obsClient ObsClient) GetBucketLifecycleConfiguration(bucketName string) (output *GetBucketLifecycleConfigurationOutput, err error)
使用带授权信息URL的方法定义
- func (obsClient ObsClient) GetBucketLifecycleConfigurationWithSignedUrl(signedUrl string, actualSignedRequestHeaders http.Header) (output *GetBucketLifecycleConfigurationOutput, err error)
请求参数
参数名 | 类型 | 约束 | 说明 |
---|---|---|---|
bucketName | string | 必选 | 桶名。 |
返回结果
参数名 | 类型 |
---|---|
output | *GetBucketPolicyOutput |
err | error |
代码样例
- func main() {
- output, err := obsClient.GetBucketLifecycleConfiguration("bucketname")
- if err == nil {
- fmt.Printf("RequestId:%s\n", output.RequestId)
- for index, lifecycleRule := range output.LifecycleRules {
- fmt.Printf("LifecycleRule[%d]:\n", index)
- fmt.Printf("ID:%s, Prefix:%s, Status:%s\n", lifecycleRule.ID, lifecycleRule.Prefix, lifecycleRule.Status)
- date := ""
- for _, transition := range lifecycleRule.Transitions {
- if !transition.Date.IsZero() {
- date = transition.Date.String()
- }
- fmt.Printf("transition.StorageClass:%s, Transition.Date:%s, Transition.Days:%d\n", transition.StorageClass, date, transition.Days)
- }
- date = ""
- if !lifecycleRule.Expiration.Date.IsZero() {
- date = lifecycleRule.Expiration.Date.String()
- }
- fmt.Printf("Expiration.Date:%s, Expiration.Days:%d\n", lifecycleRule.Expiration.Date, lifecycleRule.Expiration.Days)
- for _, noncurrentVersionTransition := range lifecycleRule.NoncurrentVersionTransitions {
- fmt.Printf("noncurrentVersionTransition.StorageClass:%s, noncurrentVersionTransition.NoncurrentDays:%d\n",
- noncurrentVersionTransition.StorageClass, noncurrentVersionTransition.NoncurrentDays)
- }
- fmt.Printf("NoncurrentVersionExpiration.NoncurrentDays:%d\n", lifecycleRule.NoncurrentVersionExpiration.NoncurrentDays)
- }
- } else {
- if obsError, ok := err.(obs.ObsError); ok {
- fmt.Println(obsError.Code)
- fmt.Println(obsError.Message)
- } else {
- fmt.Println(err)
- }
- }
- }
父主题:桶相关接口