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.

53 lines
1.5 KiB

  1. package cos
  2. import (
  3. "context"
  4. "encoding/xml"
  5. "net/http"
  6. )
  7. // Notice bucket logging function is testing, can not use.
  8. // BucketLoggingEnabled main struct of logging
  9. type BucketLoggingEnabled struct {
  10. TargetBucket string `xml:"TargetBucket"`
  11. TargetPrefix string `xml:"TargetPrefix"`
  12. }
  13. // BucketPutLoggingOptions is the options of PutBucketLogging
  14. type BucketPutLoggingOptions struct {
  15. XMLName xml.Name `xml:"BucketLoggingStatus"`
  16. LoggingEnabled *BucketLoggingEnabled `xml:"LoggingEnabled"`
  17. }
  18. // BucketGetLoggingResult is the result of GetBucketLogging
  19. type BucketGetLoggingResult struct {
  20. XMLName xml.Name `xml:"BucketLoggingStatus"`
  21. LoggingEnabled *BucketLoggingEnabled `xml:"LoggingEnabled"`
  22. }
  23. // PutBucketLogging https://cloud.tencent.com/document/product/436/17054
  24. func (s *BucketService) PutBucketLoggingTest(ctx context.Context, opt *BucketPutLoggingOptions) (*Response, error) {
  25. sendOpt := sendOptions{
  26. baseURL: s.client.BaseURL.BucketURL,
  27. uri: "/?logging",
  28. method: http.MethodPut,
  29. body: opt,
  30. }
  31. resp, err := s.client.send(ctx, &sendOpt)
  32. return resp, err
  33. }
  34. // GetBucketLogging https://cloud.tencent.com/document/product/436/17053
  35. func (s *BucketService) GetBucketLoggingTest(ctx context.Context) (*BucketGetLoggingResult, *Response, error) {
  36. var res BucketGetLoggingResult
  37. sendOpt := sendOptions{
  38. baseURL: s.client.BaseURL.BucketURL,
  39. uri: "/?logging",
  40. method: http.MethodGet,
  41. result: &res,
  42. }
  43. resp, err := s.client.send(ctx, &sendOpt)
  44. return &res, resp, err
  45. }