-
Notifications
You must be signed in to change notification settings - Fork 92
/
bucket_intelligenttiering.go
142 lines (125 loc) · 4.81 KB
/
bucket_intelligenttiering.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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
package cos
import (
"context"
"encoding/xml"
"errors"
"net/http"
)
type BucketIntelligentTieringFilterAnd struct {
Prefix string `xml:"Prefix,omitempty" header:"-"`
Tag []*BucketTaggingTag `xml:"Tag,omitempty" header:"-"`
}
type BucketIntelligentTieringFilter struct {
And *BucketIntelligentTieringFilterAnd `xml:"And,omitempty" header:"-"`
Prefix string `xml:"Prefix,omitempty" header:"-"`
Tag []*BucketTaggingTag `xml:"Tag,omitempty" header:"-"`
}
type BucketIntelligentTieringTransition struct {
AccessTier string `xml:"AccessTier,omitempty" header:"-"`
Days int `xml:"Days,omitempty" header:"-"`
RequestFrequent int `xml:"RequestFrequent,omitempty" header:"-"`
}
type BucketPutIntelligentTieringOptions struct {
XMLName xml.Name `xml:"IntelligentTieringConfiguration" header:"-"`
Status string `xml:"Status,omitempty" header:"-"`
Transition *BucketIntelligentTieringTransition `xml:"Transition,omitempty" header:"-"`
// V2
Id string `xml:"Id,omitempty" header:"-"`
Tiering []*BucketIntelligentTieringTransition `xml:"Tiering,omitempty" header:"-"`
Filter *BucketIntelligentTieringFilter `xml:"Filter,omitempty" header:"-"`
XOptionHeader *http.Header `header:"-,omitempty" url:"-" xml:"-"`
}
type BucketGetIntelligentTieringResult BucketPutIntelligentTieringOptions
type BucketGetIntelligentTieringOptions struct {
XOptionHeader *http.Header `header:"-,omitempty" url:"-" xml:"-"`
}
type IntelligentTieringConfiguration struct {
Id string `xml:"Id"`
Status string `xml:"Status"`
Tiering []*BucketIntelligentTieringTransition `xml:"Tiering"`
Filter *BucketIntelligentTieringFilter `xml:"Filter,omitempty"`
}
type ListIntelligentTieringConfigurations struct {
XMLName xml.Name `xml:"ListBucketIntelligentTieringConfigurationsOutput"`
Configurations []*IntelligentTieringConfiguration `xml:"IntelligentTieringConfiguration,omitempty"`
}
func (s *BucketService) PutIntelligentTiering(ctx context.Context, opt *BucketPutIntelligentTieringOptions) (*Response, error) {
if opt != nil && opt.Transition != nil {
opt.Transition.RequestFrequent = 1
}
sendOpt := sendOptions{
baseURL: s.client.BaseURL.BucketURL,
uri: "/?intelligenttiering",
method: http.MethodPut,
optHeader: opt,
body: opt,
}
resp, err := s.client.doRetry(ctx, &sendOpt)
return resp, err
}
func (s *BucketService) GetIntelligentTiering(ctx context.Context, opt ...*BucketGetIntelligentTieringOptions) (*BucketGetIntelligentTieringResult, *Response, error) {
var optHeader *BucketGetIntelligentTieringOptions
if len(opt) > 0 {
optHeader = opt[0]
}
var res BucketGetIntelligentTieringResult
sendOpt := sendOptions{
baseURL: s.client.BaseURL.BucketURL,
uri: "/?intelligenttiering",
method: http.MethodGet,
optHeader: optHeader,
result: &res,
}
resp, err := s.client.doRetry(ctx, &sendOpt)
return &res, resp, err
}
func (s *BucketService) PutIntelligentTieringV2(ctx context.Context, opt *BucketPutIntelligentTieringOptions) (*Response, error) {
if opt == nil || opt.Id == "" {
return nil, errors.New("id is empty")
}
sendOpt := sendOptions{
baseURL: s.client.BaseURL.BucketURL,
uri: "/?intelligent-tiering&id=" + opt.Id,
method: http.MethodPut,
optHeader: opt,
body: opt,
}
resp, err := s.client.doRetry(ctx, &sendOpt)
return resp, err
}
func (s *BucketService) GetIntelligentTieringV2(ctx context.Context, id string, opt ...*BucketGetIntelligentTieringOptions) (*BucketGetIntelligentTieringResult, *Response, error) {
var optHeader *BucketGetIntelligentTieringOptions
if len(opt) > 0 {
optHeader = opt[0]
}
var res BucketGetIntelligentTieringResult
sendOpt := sendOptions{
baseURL: s.client.BaseURL.BucketURL,
uri: "/?intelligent-tiering&id=" + id,
method: http.MethodGet,
optHeader: optHeader,
result: &res,
}
resp, err := s.client.doRetry(ctx, &sendOpt)
return &res, resp, err
}
func (s *BucketService) ListIntelligentTiering(ctx context.Context) (*ListIntelligentTieringConfigurations, *Response, error) {
var res ListIntelligentTieringConfigurations
sendOpt := sendOptions{
baseURL: s.client.BaseURL.BucketURL,
uri: "/?intelligent-tiering",
method: http.MethodGet,
result: &res,
}
resp, err := s.client.doRetry(ctx, &sendOpt)
return &res, resp, err
}
func (s *BucketService) DeleteIntelligentTiering(ctx context.Context, id string) (*Response, error) {
sendOpt := sendOptions{
baseURL: s.client.BaseURL.BucketURL,
uri: "/?intelligent-tiering&id=" + id,
method: http.MethodDelete,
}
resp, err := s.client.doRetry(ctx, &sendOpt)
return resp, err
}