-
Notifications
You must be signed in to change notification settings - Fork 92
/
bucket_logging.go
50 lines (42 loc) · 1.41 KB
/
bucket_logging.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
package cos
import (
"context"
"encoding/xml"
"net/http"
)
// Notice bucket logging function is testing, can not use.
// BucketLoggingEnabled main struct of logging
type BucketLoggingEnabled struct {
TargetBucket string `xml:"TargetBucket"`
TargetPrefix string `xml:"TargetPrefix"`
}
// BucketPutLoggingOptions is the options of PutBucketLogging
type BucketPutLoggingOptions struct {
XMLName xml.Name `xml:"BucketLoggingStatus"`
LoggingEnabled *BucketLoggingEnabled `xml:"LoggingEnabled,omitempty"`
}
// BucketGetLoggingResult is the result of GetBucketLogging
type BucketGetLoggingResult BucketPutLoggingOptions
// PutBucketLogging https://cloud.tencent.com/document/product/436/17054
func (s *BucketService) PutLogging(ctx context.Context, opt *BucketPutLoggingOptions) (*Response, error) {
sendOpt := sendOptions{
baseURL: s.client.BaseURL.BucketURL,
uri: "/?logging",
method: http.MethodPut,
body: opt,
}
resp, err := s.client.doRetry(ctx, &sendOpt)
return resp, err
}
// GetBucketLogging https://cloud.tencent.com/document/product/436/17053
func (s *BucketService) GetLogging(ctx context.Context) (*BucketGetLoggingResult, *Response, error) {
var res BucketGetLoggingResult
sendOpt := sendOptions{
baseURL: s.client.BaseURL.BucketURL,
uri: "/?logging",
method: http.MethodGet,
result: &res,
}
resp, err := s.client.doRetry(ctx, &sendOpt)
return &res, resp, err
}