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.

42 lines
1.2 KiB

  1. package cos
  2. import (
  3. "context"
  4. "encoding/xml"
  5. "net/http"
  6. )
  7. // BucketPutVersionOptions is the options of PutBucketVersioning
  8. type BucketPutVersionOptions struct {
  9. XMLName xml.Name `xml:"VersioningConfiguration"`
  10. Status string `xml:"Status"`
  11. }
  12. // BucketGetVersionResult is the result of GetBucketVersioning
  13. type BucketGetVersionResult BucketPutVersionOptions
  14. // PutVersion https://cloud.tencent.com/document/product/436/19889
  15. // Status has Suspended\Enabled
  16. func (s *BucketService) PutVersioning(ctx context.Context, opt *BucketPutVersionOptions) (*Response, error) {
  17. sendOpt := sendOptions{
  18. baseURL: s.client.BaseURL.BucketURL,
  19. uri: "/?versioning",
  20. method: http.MethodPut,
  21. body: opt,
  22. }
  23. resp, err := s.client.doRetry(ctx, &sendOpt)
  24. return resp, err
  25. }
  26. // GetVersion https://cloud.tencent.com/document/product/436/19888
  27. func (s *BucketService) GetVersioning(ctx context.Context) (*BucketGetVersionResult, *Response, error) {
  28. var res BucketGetVersionResult
  29. sendOpt := sendOptions{
  30. baseURL: s.client.BaseURL.BucketURL,
  31. uri: "/?versioning",
  32. method: http.MethodGet,
  33. result: &res,
  34. }
  35. resp, err := s.client.doRetry(ctx, &sendOpt)
  36. return &res, resp, err
  37. }