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.

45 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 struct {
  14. XMLName xml.Name `xml:"VersioningConfiguration"`
  15. Status string `xml:"Status"`
  16. }
  17. // PutVersion https://cloud.tencent.com/document/product/436/19889
  18. // Status has Suspended\Enabled
  19. func (s *BucketService) PutVersioning(ctx context.Context, opt *BucketPutVersionOptions) (*Response, error) {
  20. sendOpt := sendOptions{
  21. baseURL: s.client.BaseURL.BucketURL,
  22. uri: "/?versioning",
  23. method: http.MethodPut,
  24. body: opt,
  25. }
  26. resp, err := s.client.send(ctx, &sendOpt)
  27. return resp, err
  28. }
  29. // GetVersion https://cloud.tencent.com/document/product/436/19888
  30. func (s *BucketService) GetVersioning(ctx context.Context) (*BucketGetVersionResult, *Response, error) {
  31. var res BucketGetVersionResult
  32. sendOpt := sendOptions{
  33. baseURL: s.client.BaseURL.BucketURL,
  34. uri: "/?versioning",
  35. method: http.MethodGet,
  36. result: &res,
  37. }
  38. resp, err := s.client.send(ctx, &sendOpt)
  39. return &res, resp, err
  40. }