| 1234567891011121314151617181920212223242526272829303132333435363738394041 |
- package client
- import (
- "fmt"
- "net/url"
- "strconv"
- )
- const (
- getNamespacesUrl = "/ds/api/v1/namespace/query"
- )
- func (c *Client) GetNamespaces(token string, baseUrl string, name string, pageNo int, pageSize int) ([]NamespaceInfo, error) {
- fullUrl, err := url.JoinPath(baseUrl, getNamespacesUrl)
- if err != nil {
- return nil, err
- }
- resp := new(struct {
- Success bool `json:"success"`
- Msg string `json:"msg"`
- Infos []NamespaceInfo `json:"infos"`
- TotalCount int64 `json:"totalCount"`
- PageNo int64 `json:"pageNo"`
- })
- err = c.get(token, fullUrl, map[string]string{
- "name": name,
- "pageNo": strconv.Itoa(pageNo),
- "pageSize": strconv.Itoa(pageSize),
- }, resp)
- if err != nil {
- return nil, err
- }
- if !resp.Success {
- return nil, fmt.Errorf(resp.Msg)
- }
- return resp.Infos, nil
- }
|