更新时间:2024-06-21 GMT+08:00
        
          
          
        
      
      
      
      
      
      
      
      
  
      
      
      
        
删除桶加密配置(Go SDK)
功能介绍
桶的加密配置功能,支持在该桶中上传对象时,采用对应加密配置对数据进行加密,数据会在服务端被加密成密文后存储,用户下载加密对象时,存储的密文会先在服务端解密为明文,再提供给用户。
调用删除桶加密配置接口,您可以删除指定桶的加密配置信息。
接口约束
- 您必须是桶拥有者或拥有删除桶加密配置的权限,才能删除桶加密配置。建议使用IAM或桶策略进行授权,如果使用IAM则需授予obs:bucket:PutEncryptionConfiguration权限,如果使用桶策略则需授予PutEncryptionConfiguration权限。相关授权方式介绍可参见OBS权限控制概述,配置方式详见使用IAM自定义策略、自定义创建桶策略。
 - OBS支持的Region与Endpoint的对应关系,详细信息请参见地区与终端节点。
 
方法定义
func (obsClient ObsClient) DeleteBucketEncryption(bucketName string) (output *BaseModel, err error)
请求参数说明
| 
        参数名称  | 
      
        参数类型  | 
      
        是否必选  | 
      
        描述  | 
     
|---|---|---|---|
| 
        bucketName  | 
      
        string  | 
      
        必选  | 
      
        参数解释: 桶名。 约束限制: 
 默认取值: 无  | 
     
返回结果说明
| 
        参数名称  | 
      
        参数类型  | 
      
        描述  | 
     
|---|---|---|
| 
        StatusCode  | 
      
        int  | 
      
        参数解释: HTTP状态码。 取值范围: 状态码是一组从2xx(成功)到4xx或5xx(错误)的数字代码,状态码表示了请求响应的状态。完整的状态码列表请参见状态码。 默认取值: 无  | 
     
| 
        RequestId  | 
      
        string  | 
      
        参数解释: OBS服务端返回的请求ID。 默认取值: 无  | 
     
| 
        ResponseHeaders  | 
      
        map[string][]string  | 
      
        参数解释: HTTP响应头信息。 默认取值: 无  | 
     
代码示例
本示例用于删除名为examplebucket桶的加密配置
        1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39  | 
       
        package main import ( "fmt" "os" obs "github.com/huaweicloud/huaweicloud-sdk-go-obs/obs" ) func main() { //推荐通过环境变量获取AKSK,这里也可以使用其他外部引入方式传入,如果使用硬编码可能会存在泄露风险。 //您可以登录访问管理控制台获取访问密钥AK/SK,获取方式请参见https://support.huaweicloud.com/intl/zh-cn/usermanual-ca/ca_01_0003.html。 ak := os.Getenv("AccessKeyID") sk := os.Getenv("SecretAccessKey") // 【可选】如果使用临时AK/SK和SecurityToken访问OBS,同样建议您尽量避免使用硬编码,以降低信息泄露风险。您可以通过环境变量获取访问密钥AK/SK,也可以使用其他外部引入方式传入。 // securityToken := os.Getenv("SecurityToken") // endpoint填写Bucket对应的Endpoint, 这里以中国-香港为例,其他地区请按实际情况填写。 endPoint := "https://obs.ap-southeast-1.myhuaweicloud.com" // 创建obsClient实例 // 如果使用临时AKSK和SecurityToken访问OBS,需要在创建实例时通过obs.WithSecurityToken方法指定securityToken值。 obsClient, err := obs.New(ak, sk, endPoint/*, obs.WithSecurityToken(securityToken)*/) if err != nil { fmt.Printf("Create obsClient error, errMsg: %s", err.Error()) } // 指定存储桶名称 bucketname := "examplebucket" // 删除桶的加密配置 output, err := obsClient.DeleteBucketEncryption(bucketname) if err == nil { fmt.Printf("Delete bucket(%s)'s encryption configuration successful!\n", bucketname) fmt.Printf("RequestId:%s\n", output.RequestId) return } fmt.Printf("Delete bucket(%s)'s encryption configuration fail!\n", bucketname) if obsError, ok := err.(obs.ObsError); ok { fmt.Println("An ObsError was found, which means your request sent to OBS was rejected with an error response.") fmt.Println(obsError.Error()) } else { fmt.Println("An Exception was found, which means the client encountered an internal problem when attempting to communicate with OBS, for example, the client was unable to access the network.") fmt.Println(err) } }  | 
      
   父主题: 桶相关接口(Go SDK)