// ListAppsByQueryWithLimits queries totalPages app info. When totalPages is
// less and equal than 0, it queries all app info
// When there are no more than totalPages apps on server side, all apps info will be returned
979745
func (c *Client) ListAppsByQueryWithLimits(query url.Values, totalPages int) ([]App, error) {
	return c.listApps("/v2/apps?"+query.Encode(), totalPages)
}
823195
func (r *AppService) List() *AppListCall {
	c := &AppListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
	return c
}
234151
func (s *Action) listAll(ctx context.Context, l tree.Tree, limit int, flat, folders bool) error {
	if flat {
		listOver := l.List
		if folders {
			listOver = l.ListFolders
		}
		for _, e := range listOver(limit) {
			fmt.Fprintln(stdout, e)
		}
		return nil
	}

	// we may need to redirect stdout for the pager support
	so, buf := redirectPager(ctx, l)

	fmt.Fprintln(so, l.Format(limit))
	if buf != nil {
		if err := s.pager(ctx, buf); err != nil {
			return ExitError(ctx, ExitUnknown, err, "failed to invoke pager: %s", err)
		}
	}
	return nil
}
153053
func listingPage(q url.Values) (start string, limit int) {
	// if limit is not a valid integer (or blank string),
	// ignore the error and use the returned 0 value
	limit, _ = strconv.Atoi(q.Get("limit"))
	return q.Get("start"), limit
}
1217341
func (s *Service) AppList(ctx context.Context, lr *ListRange) (AppListResult, error) {
	var app AppListResult
	return app, s.Get(ctx, &app, fmt.Sprintf("/apps"), nil, lr)
}
1142445
func (d *Deployments) List(q *QueryOptions) ([]*Deployment, *QueryMeta, error) {
	var resp []*Deployment
	qm, err := d.client.query("/v1/deployments", &resp, q)
	if err != nil {
		return nil, nil, err
	}
	sort.Sort(DeploymentIndexSort(resp))
	return resp, qm, nil
}
588562
func (s *RedisApplicationStore) List(opts *storage.ListOptions) ([]*Application, error) {
	applicationsI, err := s.store.List("", opts)
	if err != nil {
		return nil, err
	}
	applications := make([]*Application, len(applicationsI))
	for i, applicationI := range applicationsI {
		if application, ok := applicationI.(Application); ok {
			applications[i] = &application
		}
	}
	return applications, nil
}
1322330
func (q *Quotas) ListUsage(qo *QueryOptions) ([]*QuotaUsage, *QueryMeta, error) {
	var resp []*QuotaUsage
	qm, err := q.client.query("/v1/quota-usages", &resp, qo)
	if err != nil {
		return nil, nil, err
	}
	sort.Sort(QuotaUsageIndexSort(resp))
	return resp, qm, nil
}
41142
func ListResponseWithInfo(keys []string, keyInfo map[string]interface{}) *Response {
	resp := ListResponse(keys)

	keyInfoData := make(map[string]interface{})
	for _, key := range keys {
		val, ok := keyInfo[key]
		if ok {
			keyInfoData[key] = val
		}
	}

	if len(keyInfoData) > 0 {
		resp.Data["key_info"] = keyInfoData
	}

	return resp
}
32949
func (c *PreparedQuery) List(q *QueryOptions) ([]*PreparedQueryDefinition, *QueryMeta, error) {
	var out []*PreparedQueryDefinition
	qm, err := c.c.query("/v1/query", &out, q)
	if err != nil {
		return nil, nil, err
	}
	return out, qm, nil
}
579242
func List(cmd *cli.Cmd) {
	var a []application.Application

	all := cmd.BoolOpt("a all", false, "List all applications, including archived")

	cmd.Action = func() {
		resp, body, errs := application.List()

		if errs != nil {
			log.Fatalf("Could not retrieve applications: %s", errs)
		}

		if resp.StatusCode != 200 {
			log.Fatalf("Could not retrieve applications: %s", resp.Status)
		}

		err := json.Unmarshal([]byte(body), &a)

		if err != nil {
			log.Fatal(err)
		}

		printAppBrief(a, *all)
	}
}
77418
func (c *Client) ListAppUsageEventsByQuery(query url.Values) ([]AppUsageEvent, error) {
	var appUsageEvents []AppUsageEvent
	requestURL := fmt.Sprintf("/v2/app_usage_events?%s", query.Encode())
	for {
		var appUsageEventsResponse AppUsageEventsResponse
		r := c.NewRequest("GET", requestURL)
		resp, err := c.DoRequest(r)
		if err != nil {
			return nil, errors.Wrap(err, "error requesting events")
		}
		defer resp.Body.Close()
		if err := json.NewDecoder(resp.Body).Decode(&appUsageEventsResponse); err != nil {
			return nil, errors.Wrap(err, "error unmarshaling events")
		}
		for _, e := range appUsageEventsResponse.Resources {
			e.Entity.GUID = e.Meta.Guid
			e.Entity.CreatedAt = e.Meta.CreatedAt
			e.Entity.c = c
			appUsageEvents = append(appUsageEvents, e.Entity)
		}
		requestURL = appUsageEventsResponse.NextURL
		if requestURL == "" {
			break
		}
	}
	return appUsageEvents, nil
}
196741
func (o *ListOAuth2ClientsParams) WithLimit(limit *int64) *ListOAuth2ClientsParams {
	o.SetLimit(limit)
	return o
}
196835
func (s *Server) List(ctx context.Context, q *ClusterQuery) (*appv1.ClusterList, error) {
	clusterList, err := s.db.ListClusters(ctx)
	if err != nil {
		return nil, err
	}
	clustersByServer := make(map[string][]appv1.Cluster)
	for _, clust := range clusterList.Items {
		if s.enf.Enforce(ctx.Value("claims"), rbacpolicy.ResourceClusters, rbacpolicy.ActionGet, clust.Server) {
			clustersByServer[clust.Server] = append(clustersByServer[clust.Server], clust)
		}
	}
	servers := make([]string, 0)
	for server := range clustersByServer {
		servers = append(servers, server)
	}

	items := make([]appv1.Cluster, len(servers))
	err = util.RunAllAsync(len(servers), func(i int) error {
		clusters := clustersByServer[servers[i]]
		clust := clusters[0]
		warningMessage := ""
		if len(clusters) > 1 {
			warningMessage = fmt.Sprintf("There are %d credentials configured this cluster.", len(clusters))
		}
		if clust.ConnectionState.Status == "" {
			clust.ConnectionState = s.getConnectionState(ctx, clust, warningMessage)
		}
		items[i] = *redact(&clust)
		return nil
	})
	if err != nil {
		return nil, err
	}

	clusterList.Items = items
	return clusterList, err
}
195944
func (c *Client) ListTasksByQuery(query url.Values) ([]Task, error) {
	return c.handleTasksApiCall("/v3/tasks", query)
}
863727
func (s *RedisDeviceStore) CountForApp(appID string) (int, error) {
	opts := new(storage.ListOptions)
	opts.UseCache(s.listResultCacheKey(appID), listCacheTTL)
	return s.store.Count(fmt.Sprintf("%s:*", appID), opts)
}
259096
func (query Query) Limit(limit int) Query {
	query.LimitResult = limit
	return query
}