diff --git a/client.go b/client.go index 182de0ed..491befb3 100644 --- a/client.go +++ b/client.go @@ -336,13 +336,27 @@ func (c *Client) ListProject() (projectNames []string, err error) { // the region is related with the client's endpoint // ref https://www.alibabacloud.com/help/doc-detail/74955.htm func (c *Client) ListProjectV2(offset, size int) (projects []LogProject, count, total int, err error) { + return c.ListProjectV3(&ListProjectRequest{ + Offset: offset, + Size: size, + }) +} + +func (c *Client) ListProjectV3(req *ListProjectRequest) (projects []LogProject, count, total int, err error) { h := map[string]string{ "x-log-bodyrawsize": "0", } urlVal := url.Values{} - urlVal.Add("offset", strconv.Itoa(offset)) - urlVal.Add("size", strconv.Itoa(size)) + if req.Offset > 0 { + urlVal.Add("offset", strconv.Itoa(req.Offset)) + } + if req.Size > 0 { + urlVal.Add("size", strconv.Itoa(req.Size)) + } + if req.Description != "" { + urlVal.Add("description", req.Description) + } uri := fmt.Sprintf("/?%s", urlVal.Encode()) proj := convert(c, "") diff --git a/client_interface.go b/client_interface.go index 9f56c376..3aca9127 100644 --- a/client_interface.go +++ b/client_interface.go @@ -111,6 +111,7 @@ type ClientInterface interface { // the region is related with the client's endpoint // ref https://www.alibabacloud.com/help/doc-detail/74955.htm ListProjectV2(offset, size int) (projects []LogProject, count, total int, err error) + ListProjectV3(req *ListProjectRequest) (projects []LogProject, count, total int, err error) // CheckProjectExist check project exist or not CheckProjectExist(name string) (bool, error) // DeleteProject ... diff --git a/model.go b/model.go index 0b3f37a7..8502ad91 100644 --- a/model.go +++ b/model.go @@ -401,6 +401,12 @@ type ListStoreViewsResponse struct { StoreViews []string `json:"storeviews"` } +type ListProjectRequest struct { + Offset int `json:"offset"` + Size int `json:"size"` + Description string `json:"description,omitempty"` // use it to filter projects by description, support fuzzy search +} + // If cursor is unknown, returns empty string // If pullLogs with non-empty query or consumer with non-empty query, returns empty string func (l *LogGroup) GetCursor() string { diff --git a/token_auto_update_client.go b/token_auto_update_client.go index 99921077..8724e54f 100644 --- a/token_auto_update_client.go +++ b/token_auto_update_client.go @@ -2140,3 +2140,13 @@ func (c *TokenAutoUpdateClient) GetStoreViewIndex(project string, storeViewName } return } + +func (c *TokenAutoUpdateClient) ListProjectV3(req *ListProjectRequest) (projects []LogProject, count, total int, err error) { + for i := 0; i < c.maxTryTimes; i++ { + projects, count, total, err = c.logClient.ListProjectV3(req) + if !c.processError(err) { + return + } + } + return +}