forked from tencentyun/cos-go-sdk-v5
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bucket_version.go
42 lines (37 loc) · 1.17 KB
/
bucket_version.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
package cos
import (
"context"
"encoding/xml"
"net/http"
)
// BucketPutVersionOptions is the options of PutBucketVersioning
type BucketPutVersionOptions struct {
XMLName xml.Name `xml:"VersioningConfiguration"`
Status string `xml:"Status"`
}
// BucketGetVersionResult is the result of GetBucketVersioning
type BucketGetVersionResult BucketPutVersionOptions
// PutVersion https://cloud.tencent.com/document/product/436/19889
// Status has Suspended\Enabled
func (s *BucketService) PutVersioning(ctx context.Context, opt *BucketPutVersionOptions) (*Response, error) {
sendOpt := sendOptions{
baseURL: s.client.BaseURL.BucketURL,
uri: "/?versioning",
method: http.MethodPut,
body: opt,
}
resp, err := s.client.doRetry(ctx, &sendOpt)
return resp, err
}
// GetVersion https://cloud.tencent.com/document/product/436/19888
func (s *BucketService) GetVersioning(ctx context.Context) (*BucketGetVersionResult, *Response, error) {
var res BucketGetVersionResult
sendOpt := sendOptions{
baseURL: s.client.BaseURL.BucketURL,
uri: "/?versioning",
method: http.MethodGet,
result: &res,
}
resp, err := s.client.doRetry(ctx, &sendOpt)
return &res, resp, err
}