// ListShards returns shard id list of this logstore.

ListShards returns shard id list of this logstore.
// ListShards returns shard id list of this logstore .
func (s *LogStore) ListShards() (shardIDs []int, err error) {
	h := map[string]string{
		"x-sls-bodyrawsize": "0",
	}
	uri := fmt.Sprintf("/logstores/%v/shards", s.Name)
	r, err := request(s.project, "GET", uri, h, nil)
	if err != nil {
		return
	}
	buf, err := ioutil.ReadAll(r.Body)
	if err != nil {
		return
	}
	if r.StatusCode != http.StatusOK {
		errMsg := &errorMessage{}
		err = json.Unmarshal(buf, errMsg)
		if err != nil {
			err = fmt.Errorf("failed to list logstore")
			dump, _ := httputil.DumpResponse(r, true)
			fmt.Println(dump)
			return
		}
		err = fmt.Errorf("%v:%v", errMsg.Code, errMsg.Message)
		return
	}
	var shards []*Shard
	err = json.Unmarshal(buf, &shards)
	if err != nil {
		return
	}
	for _, v := range shards {
		shardIDs = append(shardIDs, v.ShardID)
	}
	return
}
func ( s * LogStore ) ListShards ( ) ( shardIDs [ ] int , err error ) { h := map [ string ] string { " " : " " , } uri := fmt . Sprintf ( " " , s . Name ) r , err := request ( s . project , " " , uri , h , nil ) if err != nil { return } buf , err := ioutil . ReadAll ( r . Body ) if err != nil { return } if r . StatusCode != http . StatusOK { errMsg := & errorMessage { } err = json . Unmarshal ( buf , errMsg ) if err != nil { err = fmt . Errorf ( " " ) dump , _ := httputil . DumpResponse ( r , true ) fmt . Println ( dump ) return } err = fmt . Errorf ( " " , errMsg . Code , errMsg . Message ) return } var shards [ ] * Shard err = json . Unmarshal ( buf , & shards ) if err != nil { return } for _ , v := range shards { shardIDs = append ( shardIDs , v . ShardID ) } return }
ListShards returns shard id list of this logstore.
ListShards returns shard id list of this logstore .