Skip to content

Commit 38b6c1a

Browse files
committed
fix error with more than 10 file systems
1 parent 0dbc928 commit 38b6c1a

File tree

1 file changed

+23
-8
lines changed

1 file changed

+23
-8
lines changed

internal/rest-client/filesystems_perf.go

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package client
22

3+
import "strings"
4+
35
type FileSystemsPerformanceList struct {
46
CntToken string `json:"continuation_token"`
57
TotalItemCnt int `json:"total_item_count"`
@@ -11,18 +13,31 @@ func (fb *FBClient) GetFileSystemsPerformance(f *FileSystemsList,
1113
protocol string) *FileSystemsPerformanceList {
1214
uri := "/file-systems/performance"
1315
result := new(FileSystemsPerformanceList)
16+
const chunkSize = 10
17+
1418
switch protocol {
1519
case "all", "NFS", "SMB":
16-
res, _ := fb.RestClient.R().
17-
SetResult(&result).
18-
SetQueryParam("protocol", protocol).
19-
Get(uri)
20-
if res.StatusCode() == 401 {
21-
fb.RefreshSession()
22-
fb.RestClient.R().
23-
SetResult(&result).
20+
for i := 0; i < len(f.Items); i += chunkSize {
21+
names := make([]string, 0, chunkSize)
22+
for _, fs := range f.Items[i:min(i+chunkSize, len(f.Items))] {
23+
names = append(names, fs.Name)
24+
}
25+
n := strings.Join(names, ",")
26+
temp := new(FileSystemsPerformanceList)
27+
res, _ := fb.RestClient.R().
28+
SetResult(&temp).
29+
SetQueryParam("names", n).
2430
SetQueryParam("protocol", protocol).
2531
Get(uri)
32+
if res.StatusCode() == 401 {
33+
fb.RefreshSession()
34+
fb.RestClient.R().
35+
SetResult(&temp).
36+
SetQueryParam("names", n).
37+
SetQueryParam("protocol", protocol).
38+
Get(uri)
39+
}
40+
result.Items = append(result.Items, temp.Items...)
2641
}
2742
}
2843
return result

0 commit comments

Comments
 (0)