コード例 #1
0
ファイル: util.go プロジェクト: WangZhenfei/arvados
// Returns the total count of a particular type of resource
//
//   resource - the arvados resource to count
// return
//   count - the number of items of type resource the api server reports, if no error
//   err - error accessing the resource, or nil if no error
func NumberItemsAvailable(client arvadosclient.ArvadosClient, resource string) (count int, err error) {
	var response struct {
		ItemsAvailable int `json:"items_available"`
	}
	sdkParams := arvadosclient.Dict{"limit": 0}
	err = client.List(resource, sdkParams, &response)
	if err == nil {
		count = response.ItemsAvailable
	}
	return
}