Skip to content

Commit

Permalink
feat: add ListLogStoreV2 (#305)
Browse files Browse the repository at this point in the history
* feat: add ListLogStoreV2

* test: add test for list logstore v2
  • Loading branch information
crimson-gao authored Nov 29, 2024
1 parent 8e36402 commit 833cf4b
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
3 changes: 3 additions & 0 deletions client_interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ type ClientInterface interface {
// #################### Logstore Operations #####################
// ListLogStore returns all logstore names of project p.
ListLogStore(project string) ([]string, error)
// ListLogStoresV2 returns all logstore names of project p with pagination.
// @param telemetryType: telemetry type, "None" for all logstore and metricStore, "Metrics" for metricStore
ListLogStoreV2(project string, offset, size int, telemetryType string) ([]string, error)
// GetLogStore returns logstore according by logstore name.
GetLogStore(project string, logstore string) (*LogStore, error)
// CreateLogStore creates a new logstore in SLS
Expand Down
19 changes: 19 additions & 0 deletions client_project_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package sls

import (
"fmt"
"os"
"testing"

"github.com/stretchr/testify/assert"
)

func TestListLogStoreV2(t *testing.T) {
client := CreateNormalInterfaceV2(os.Getenv("LOG_TEST_ENDPOINT"), NewStaticCredentialsProvider(
os.Getenv("LOG_TEST_ACCESS_KEY_ID"),
os.Getenv("LOG_TEST_ACCESS_KEY_SECRET"), ""))
logstores, err := client.ListLogStoreV2(os.Getenv("LOG_TEST_PROJECT"), 0, 100, "")
assert.NoError(t, err)
assert.LessOrEqual(t, len(logstores), 100)
fmt.Println(logstores)
}
10 changes: 10 additions & 0 deletions token_auto_update_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,16 @@ func (c *TokenAutoUpdateClient) ListLogStore(project string) (logstoreList []str
return
}

func (c *TokenAutoUpdateClient) ListLogStoreV2(project string, offset, size int, telemetryType string) (logstoreList []string, err error) {
for i := 0; i < c.maxTryTimes; i++ {
logstoreList, err = c.logClient.ListLogStoreV2(project, offset, size, telemetryType)
if !c.processError(err) {
return
}
}
return
}

func (c *TokenAutoUpdateClient) GetLogStore(project string, logstore string) (logstoreRst *LogStore, err error) {
for i := 0; i < c.maxTryTimes; i++ {
logstoreRst, err = c.logClient.GetLogStore(project, logstore)
Expand Down

0 comments on commit 833cf4b

Please sign in to comment.