You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1.4 KiB

  1. package cos
  2. import (
  3. "context"
  4. "encoding/xml"
  5. "net/http"
  6. )
  7. type BucketIntelligentTieringTransition struct {
  8. Days int `xml:"Days,omitempty"`
  9. RequestFrequent int `xml:"RequestFrequent,omitempty"`
  10. }
  11. type BucketPutIntelligentTieringOptions struct {
  12. XMLName xml.Name `xml:"IntelligentTieringConfiguration"`
  13. Status string `xml:"Status,omitempty"`
  14. Transition *BucketIntelligentTieringTransition `xml:"Transition,omitempty"`
  15. }
  16. type BucketGetIntelligentTieringResult BucketPutIntelligentTieringOptions
  17. func (s *BucketService) PutIntelligentTiering(ctx context.Context, opt *BucketPutIntelligentTieringOptions) (*Response, error) {
  18. if opt != nil && opt.Transition != nil {
  19. opt.Transition.RequestFrequent = 1
  20. }
  21. sendOpt := sendOptions{
  22. baseURL: s.client.BaseURL.BucketURL,
  23. uri: "/?intelligenttiering",
  24. method: http.MethodPut,
  25. body: opt,
  26. }
  27. resp, err := s.client.doRetry(ctx, &sendOpt)
  28. return resp, err
  29. }
  30. func (s *BucketService) GetIntelligentTiering(ctx context.Context) (*BucketGetIntelligentTieringResult, *Response, error) {
  31. var res BucketGetIntelligentTieringResult
  32. sendOpt := sendOptions{
  33. baseURL: s.client.BaseURL.BucketURL,
  34. uri: "/?intelligenttiering",
  35. method: http.MethodGet,
  36. result: &res,
  37. }
  38. resp, err := s.client.doRetry(ctx, &sendOpt)
  39. return &res, resp, err
  40. }