Help Center> Object Storage Service> SDK Reference> Go> Bucket-Related APIs> Obtaining a Bucket's Encryption Configurations

Obtaining a Bucket's Encryption Configurations

API Description

You can use this API to obtain a bucket's encryption configurations.

Method Definition

func (obsClient ObsClient) GetBucketEncryption(bucketName string) (output *GetBucketEncryptionOutput, err error)

Method Definition If a Signed URL Is Used

func (obsClient ObsClient) GetBucketEncryptionWithSignedURL(signedURL string, actualSignedRequestHeaders http.Header) (output *GetBucketEncryptionOutput, err error)

Request Parameters

Field

Type

Optional or Mandatory

Description

bucketName

string

Mandatory

Bucket name

Returned Result

Field

Type

output

*GetBucketEncryptionOutput

err

error

Sample Code

var obsClient, _ = obs.New(ak, sk, endpoint, obs.WithSignature(obs.SignatureObs))

func main() 
       // Obtain the encryption configurations of the specified bucket.
       output, err := obsClient.GetBucketEncryption("bucketName")
       if err == nil {
                fmt.Printf("Encryption:%s\n", outputGet.SSEAlgorithm)
		fmt.Printf("KeyID:%s\n", outputGet.KMSMasterKeyID)
       } else {
              if obsError, ok := err.(obs.ObsError); ok {
                     fmt.Println(obsError.Code)
                     fmt.Println(obsError.Message)
              } else {
                     fmt.Println(err)
              }
       }
}