github.com/aliyun/aliyun-oss-go-sdk@v3.0.2+incompatible/sample/bucket_info.go (about) 1 package sample 2 3 import ( 4 "fmt" 5 "github.com/aliyun/aliyun-oss-go-sdk/oss" 6 ) 7 8 // BucketInfoSample shows how to get the bucket info. 9 func BucketInfoSample() { 10 // New client 11 client, err := oss.New(endpoint, accessID, accessKey) 12 if err != nil { 13 HandleError(err) 14 } 15 // Get bucket info 16 res, err := client.GetBucketInfo(bucketName) 17 if err != nil { 18 HandleError(err) 19 } 20 fmt.Println("Bucket Info Name: ", res.BucketInfo.Name) 21 fmt.Println("Bucket Info AccessMonitor: ", res.BucketInfo.AccessMonitor) 22 fmt.Println("Bucket Info Location: ", res.BucketInfo.Location) 23 fmt.Println("Bucket Info CreationDate: ", res.BucketInfo.CreationDate) 24 fmt.Println("Bucket Info ACL: ", res.BucketInfo.ACL) 25 fmt.Println("Bucket Info Owner Id: ", res.BucketInfo.Owner.ID) 26 fmt.Println("Bucket Info Owner DisplayName: ", res.BucketInfo.Owner.DisplayName) 27 fmt.Println("Bucket Info StorageClass: ", res.BucketInfo.StorageClass) 28 fmt.Println("Bucket Info RedundancyType: ", res.BucketInfo.RedundancyType) 29 fmt.Println("Bucket Info ExtranetEndpoint: ", res.BucketInfo.ExtranetEndpoint) 30 fmt.Println("Bucket Info IntranetEndpoint: ", res.BucketInfo.IntranetEndpoint) 31 fmt.Println("Bucket Info CrossRegionReplication: ", res.BucketInfo.CrossRegionReplication) 32 if res.BucketInfo.Versioning != "" { 33 fmt.Println("Bucket Info Versioning: ", res.BucketInfo.Versioning) 34 } 35 if res.BucketInfo.SseRule.KMSDataEncryption != "" { 36 fmt.Println("Bucket Info SseRule KMSDataEncryption: ", res.BucketInfo.SseRule.KMSDataEncryption) 37 } 38 if res.BucketInfo.SseRule.KMSMasterKeyID != "" { 39 fmt.Println("Bucket Info SseRule KMSMasterKeyID: ", res.BucketInfo.SseRule.KMSMasterKeyID) 40 } 41 if res.BucketInfo.SseRule.SSEAlgorithm != "" { 42 fmt.Println("Bucket Info SseRule SSEAlgorithm: ", res.BucketInfo.SseRule.SSEAlgorithm) 43 } 44 45 }