execute_sql_log.go 946 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package client
  2. import (
  3. "fmt"
  4. "net/url"
  5. "strconv"
  6. )
  7. const (
  8. getExecuteSqlLogsUrl = "/ds/api/v1/sql/exec/log/query"
  9. )
  10. func (c *Client) GetExecuteSqlLogs(token string, baseUrl string, namespace string, dataSource string,
  11. executor string, startExecuteTime string, endExecuteTime string, pageNo int, pageSize int) ([]ExecuteSqlLogInfo, error) {
  12. fullUrl, err := url.JoinPath(baseUrl, getExecuteSqlLogsUrl)
  13. if err != nil {
  14. return nil, err
  15. }
  16. resp := new(InfosResponse[ExecuteSqlLogInfo])
  17. err = c.get(token, fullUrl, map[string]string{
  18. "namespace": namespace,
  19. "dataSource": dataSource,
  20. "executor": executor,
  21. "startExecuteTime": startExecuteTime,
  22. "endExecuteTime": endExecuteTime,
  23. "pageNo": strconv.Itoa(pageNo),
  24. "pageSize": strconv.Itoa(pageSize),
  25. }, resp)
  26. if err != nil {
  27. return nil, err
  28. }
  29. if !resp.Success {
  30. return nil, fmt.Errorf(resp.Msg)
  31. }
  32. return resp.Infos, nil
  33. }