-
-
Notifications
You must be signed in to change notification settings - Fork 26
/
bucket_tagging.go
93 lines (83 loc) · 2.41 KB
/
bucket_tagging.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
package cos
import (
"context"
"encoding/xml"
"net/http"
)
// BucketTaggingTag ...
type BucketTaggingTag struct {
Key string
Value string
}
// BucketGetTaggingResult ...
type BucketGetTaggingResult struct {
XMLName xml.Name `xml:"Tagging"`
TagSet []BucketTaggingTag `xml:"TagSet>Tag,omitempty"`
}
// MethodGetTagging method name of Bucket.GetTagging
const MethodGetTagging MethodName = "Bucket.GetTagging"
// GetTagging ...
//
// Get Bucket Tagging接口实现获取指定Bucket的标签。
//
// https://www.qcloud.com/document/product/436/8277
func (s *BucketService) GetTagging(ctx context.Context) (*BucketGetTaggingResult, *Response, error) {
var res BucketGetTaggingResult
sendOpt := sendOptions{
baseURL: s.client.BaseURL.BucketURL,
uri: "/?tagging",
method: http.MethodGet,
result: &res,
caller: Caller{
Method: MethodGetTagging,
},
}
resp, err := s.client.send(ctx, &sendOpt)
return &res, resp, err
}
// BucketPutTaggingOptions ...
type BucketPutTaggingOptions struct {
XMLName xml.Name `xml:"Tagging"`
TagSet []BucketTaggingTag `xml:"TagSet>Tag,omitempty"`
}
// MethodPutTagging method name of Bucket.PutTagging
const MethodPutTagging MethodName = "Bucket.PutTagging"
// PutTagging ...
//
// Put Bucket Tagging接口实现给用指定Bucket打标签。用来组织和管理相关Bucket。
//
// 当该请求设置相同Key名称,不同Value时,会返回400。请求成功,则返回204。
//
// https://www.qcloud.com/document/product/436/8281
func (s *BucketService) PutTagging(ctx context.Context, opt *BucketPutTaggingOptions) (*Response, error) {
sendOpt := sendOptions{
baseURL: s.client.BaseURL.BucketURL,
uri: "/?tagging",
method: http.MethodPut,
body: opt,
caller: Caller{
Method: MethodPutTagging,
},
}
resp, err := s.client.send(ctx, &sendOpt)
return resp, err
}
// MethodDeleteTagging method name of Bucket.DeleteTagging
const MethodDeleteTagging MethodName = "Bucket.DeleteTagging"
// DeleteTagging ...
//
// Delete Bucket Tagging接口实现删除指定Bucket的标签。
//
// https://www.qcloud.com/document/product/436/8286
func (s *BucketService) DeleteTagging(ctx context.Context) (*Response, error) {
sendOpt := sendOptions{
baseURL: s.client.BaseURL.BucketURL,
uri: "/?tagging",
method: http.MethodDelete,
caller: Caller{
Method: MethodDeleteTagging,
},
}
resp, err := s.client.send(ctx, &sendOpt)
return resp, err
}