-
Notifications
You must be signed in to change notification settings - Fork 91
/
bucket_encryption.go
52 lines (45 loc) · 1.39 KB
/
bucket_encryption.go
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
40
41
42
43
44
45
46
47
48
49
50
51
52
package cos
import (
"context"
"encoding/xml"
"net/http"
)
type BucketEncryptionConfiguration struct {
SSEAlgorithm string `xml:"SSEAlgorithm"`
KMSMasterKeyID string `xml:"KMSMasterKeyID,omitempty"`
}
type BucketPutEncryptionOptions struct {
XMLName xml.Name `xml:"ServerSideEncryptionConfiguration"`
Rule *BucketEncryptionConfiguration `xml:"Rule>ApplyServerSideEncryptionByDefault"`
}
type BucketGetEncryptionResult BucketPutEncryptionOptions
func (s *BucketService) PutEncryption(ctx context.Context, opt *BucketPutEncryptionOptions) (*Response, error) {
sendOpt := &sendOptions{
baseURL: s.client.BaseURL.BucketURL,
uri: "/?encryption",
method: http.MethodPut,
body: opt,
}
resp, err := s.client.doRetry(ctx, sendOpt)
return resp, err
}
func (s *BucketService) GetEncryption(ctx context.Context) (*BucketGetEncryptionResult, *Response, error) {
var res BucketGetEncryptionResult
sendOpt := &sendOptions{
baseURL: s.client.BaseURL.BucketURL,
uri: "/?encryption",
method: http.MethodGet,
result: &res,
}
resp, err := s.client.doRetry(ctx, sendOpt)
return &res, resp, err
}
func (s *BucketService) DeleteEncryption(ctx context.Context) (*Response, error) {
sendOpt := &sendOptions{
baseURL: s.client.BaseURL.BucketURL,
uri: "/?encryption",
method: http.MethodDelete,
}
resp, err := s.client.doRetry(ctx, sendOpt)
return resp, err
}