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.

39 lines
1.1 KiB

  1. package cos
  2. import (
  3. "context"
  4. "encoding/xml"
  5. "net/http"
  6. )
  7. type BucketPutDomainOptions struct {
  8. XMLName xml.Name `xml:"DomainConfiguration"`
  9. Status string `xml:"DomainRule>Status"`
  10. Name string `xml:"DomainRule>Name"`
  11. Type string `xml:"DomainRule>Type"`
  12. ForcedReplacement string `xml:"DomainRule>ForcedReplacement,omitempty"`
  13. }
  14. type BucketGetDomainResult BucketPutDomainOptions
  15. func (s *BucketService) PutDomain(ctx context.Context, opt *BucketPutDomainOptions) (*Response, error) {
  16. sendOpt := &sendOptions{
  17. baseURL: s.client.BaseURL.BucketURL,
  18. uri: "/?domain",
  19. method: http.MethodPut,
  20. body: opt,
  21. }
  22. resp, err := s.client.send(ctx, sendOpt)
  23. return resp, err
  24. }
  25. func (s *BucketService) GetDomain(ctx context.Context) (*BucketGetDomainResult, *Response, error) {
  26. var res BucketGetDomainResult
  27. sendOpt := &sendOptions{
  28. baseURL: s.client.BaseURL.BucketURL,
  29. uri: "/?domain",
  30. method: http.MethodGet,
  31. result: &res,
  32. }
  33. resp, err := s.client.send(ctx, sendOpt)
  34. return &res, resp, err
  35. }