-func SdkListResponseContainsAllAvailableItems(response map[string]interface{}) (containsAll bool, numContained int, numAvailable int) {
- if value, ok := response["items"]; ok {
- items := value.([]interface{})
- {
- var itemsAvailable interface{}
- if itemsAvailable, ok = response["items_available"]; !ok {
- // TODO(misha): Consider returning an error here (and above if
- // we can't find items) so that callers can recover.
- log.Fatalf("API server did not return the number of items available")
- }
- numContained = len(items)
- numAvailable = int(itemsAvailable.(float64))
- // If we never entered this block, allAvailable would be false by
- // default, which is what we want
- containsAll = numContained == numAvailable
- }
+// 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"`