diff --git a/client_interface.go b/client_interface.go index 585ae211..6676c88b 100644 --- a/client_interface.go +++ b/client_interface.go @@ -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 diff --git a/client_project_test.go b/client_project_test.go new file mode 100644 index 00000000..57db1e1d --- /dev/null +++ b/client_project_test.go @@ -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) +} diff --git a/token_auto_update_client.go b/token_auto_update_client.go index b0b6edac..6d41baa3 100644 --- a/token_auto_update_client.go +++ b/token_auto_update_client.go @@ -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)