Skip to content

Commit ee26d1a

Browse files
authored
fix list storeview size not work, add storeType (#342)
* fix list storeview size not work, add storeType * add model type
1 parent 8f2486e commit ee26d1a

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

client_store_view.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import (
44
"encoding/json"
55
"fmt"
66
"io/ioutil"
7+
"net/url"
8+
"strconv"
79
)
810

911
func (c *Client) CreateStoreView(project string, storeView *StoreView) error {
@@ -84,7 +86,16 @@ func (c *Client) ListStoreViews(project string, req *ListStoreViewsRequest) (*Li
8486
"Content-Type": "application/json",
8587
"x-log-bodyrawsize": "0",
8688
}
87-
uri := fmt.Sprintf("/storeviews?offset=%d&line=%d", req.Offset, req.Size)
89+
urlVal := url.Values{}
90+
urlVal.Add("offset", strconv.Itoa(req.Offset))
91+
if req.Size > 0 {
92+
urlVal.Add("size", strconv.Itoa(req.Size))
93+
}
94+
if req.StoreType != "" {
95+
urlVal.Add("storeType", req.StoreType)
96+
}
97+
uri := fmt.Sprintf("/storeviews?%s", urlVal.Encode())
98+
8899
r, err := c.request(project, "GET", uri, h, nil)
89100
if err != nil {
90101
return nil, err

model.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -389,8 +389,9 @@ type StoreViewErrors struct {
389389
}
390390

391391
type ListStoreViewsRequest struct {
392-
Offset int `json:"offset"`
393-
Size int `json:"size"`
392+
Offset int `json:"offset"`
393+
Size int `json:"size"`
394+
StoreType string `json:"storeType,omitempty"` // logstore or metricstore, or empty for both
394395
}
395396

396397
type ListStoreViewsResponse struct {

0 commit comments

Comments
 (0)