// LabelsList fetches all labels
330860
func LabelsList(c web.C, w http.ResponseWriter, req *http.Request) {
	session := c.Env["token"].(*models.Token)

	cursor, err := env.Labels.GetTable().GetAllByIndex("nameOwnerBuiltin", []interface{}{
		"Spam",
		session.Owner,
		true,
	}, []interface{}{
		"Trash",
		session.Owner,
		true,
	}, []interface{}{
		"Sent",
		session.Owner,
		true,
	}).Run(env.Rethink)
	if err != nil {
		env.Log.WithFields(logrus.Fields{
			"error": err.Error(),
		}).Error("Unable to get account's specified labels")

		utils.JSONResponse(w, 500, &LabelsListResponse{
			Success: false,
			Message: err.Error(),
		})
		return
	}
	defer cursor.Close()
	var spamTrashSent []*models.Label
	if err := cursor.All(&spamTrashSent); err != nil {
		env.Log.WithFields(logrus.Fields{
			"error": err.Error(),
		}).Error("Unable to unmarshal account's specified labels")

		utils.JSONResponse(w, 500, &LabelsListResponse{
			Success: false,
			Message: err.Error(),
		})
		return
	}

	if len(spamTrashSent) != 3 {
		env.Log.WithFields(logrus.Fields{
			"count":   len(spamTrashSent),
			"account": session.Owner,
		}).Error("Invalid count of Trash, Sent and Spam labels")

		utils.JSONResponse(w, 500, &LabelsListResponse{
			Success: false,
			Message: "Misconfigured account",
		})
		return
	}

	cursor, err = env.Labels.GetTable().GetAllByIndex("owner", session.Owner).Map(func(label r.Term) r.Term {
		return label.Merge(map[string]interface{}{
			"total_threads_count": env.Threads.GetTable().GetAllByIndex("labels", label.Field("id")).Count(),
			"unread_threads_count": env.Threads.GetTable().GetAllByIndex("labels", label.Field("id")).Filter(func(thread r.Term) r.Term {
				return r.Not(thread.Field("is_read")).And(
					r.Not(
						thread.Field("labels").Contains(spamTrashSent[0].ID).Or(
							thread.Field("labels").Contains(spamTrashSent[1].ID).Or(
								thread.Field("labels").Contains(spamTrashSent[2].ID),
							),
						),
					),
				)
			}).Count(),
		})
	}).Run(env.Rethink)
	if err != nil {
		env.Log.WithFields(logrus.Fields{
			"error": err.Error(),
		}).Error("Unable to get account's all labels")

		utils.JSONResponse(w, 500, &LabelsListResponse{
			Success: false,
			Message: err.Error(),
		})
		return
	}
	defer cursor.Close()
	var labels []*models.Label
	if err := cursor.All(&labels); err != nil {
		env.Log.WithFields(logrus.Fields{
			"error": err.Error(),
		}).Error("Unable to unmarshal account's labels")

		utils.JSONResponse(w, 500, &LabelsListResponse{
			Success: false,
			Message: err.Error(),
		})
		return
	}

	utils.JSONResponse(w, 200, &LabelsListResponse{
		Success: true,
		Labels:  &labels,
	})
}
1251280
func (s *exampleLister) List(selector labels.Selector) (ret []*v1.Example, err error) {
	err = cache.ListAll(s.indexer, selector, func(m interface{}) {
		ret = append(ret, m.(*v1.Example))
	})
	return ret, err
}
1256217
func (c *WorkItemLabelsController) List(ctx *app.ListWorkItemLabelsContext) error {
	err := application.Transactional(c.db, func(appl application.Application) error {
		wi, err := appl.WorkItems().LoadByID(ctx, ctx.WiID)
		if err != nil {
			return goa.ErrNotFound(err.Error())
		}
		labelIDs := wi.Fields[workitem.SystemLabels].([]interface{})
		ls := make([]label.Label, 0, len(labelIDs))
		for _, lbl := range labelIDs {
			lblStr := lbl.(string)
			id, err := uuid.FromString(lblStr)
			if err != nil {
				log.Error(nil, map[string]interface{}{
					"label_id": lblStr,
					"err":      err,
				}, "error in converting string to UUID")
				return goa.ErrNotFound(err.Error())
			}
			l, err := appl.Labels().Load(ctx, id)
			if err != nil {
				log.Error(nil, map[string]interface{}{
					"label_id": id,
					"err":      err,
				}, "error in loading label")
				return err
			}
			ls = append(ls, *l)
		}

		return ctx.ConditionalEntities(ls, c.config.GetCacheControlLabels, func() error {
			res := &app.LabelList{}
			res.Data = ConvertLabels(appl, ctx.Request, ls)
			res.Meta = &app.WorkItemListResponseMeta{
				TotalCount: len(res.Data),
			}
			return ctx.OK(res)
		})
	})
	if err != nil {
		return jsonapi.JSONErrorResponse(ctx, err)
	}
	return nil
}
720093
func (m *GormLabelRepository) List(ctx context.Context, spaceID uuid.UUID) ([]Label, error) {
	defer goa.MeasureSince([]string{"goa", "db", "label", "query"}, time.Now())
	var objs []Label
	err := m.db.Where("space_id = ?", spaceID).Find(&objs).Error
	if err != nil && err != gorm.ErrRecordNotFound {
		return nil, err
	}
	return objs, nil
}
1004157
func (c *FakeFischers) List(opts v1.ListOptions) (result *v1alpha1.FischerList, err error) {
	obj, err := c.Fake.
		Invokes(testing.NewRootListAction(fischersResource, fischersKind, opts), &v1alpha1.FischerList{})
	if obj == nil {
		return nil, err
	}

	label, _, _ := testing.ExtractFromListOptions(opts)
	if label == nil {
		label = labels.Everything()
	}
	list := &v1alpha1.FischerList{ListMeta: obj.(*v1alpha1.FischerList).ListMeta}
	for _, item := range obj.(*v1alpha1.FischerList).Items {
		if label.Matches(labels.Set(item.Labels)) {
			list.Items = append(list.Items, item)
		}
	}
	return list, err
}
774278
func CreateDepListFromNameLabels(name types.ACIdentifier, labels types.Labels, ap ACIRegistry) (Images, error) {
	key, err := ap.GetACI(name, labels)
	if err != nil {
		return nil, err
	}
	return createDepList(key, ap)
}
490740
func (s *ciliumNetworkPolicyLister) List(selector labels.Selector) (ret []*v2.CiliumNetworkPolicy, err error) {
	err = cache.ListAll(s.indexer, selector, func(m interface{}) {
		ret = append(ret, m.(*v2.CiliumNetworkPolicy))
	})
	return ret, err
}
572317
func (s *endpointsLister) List(selector labels.Selector) (ret []*v1.Endpoints, err error) {
	err = cache.ListAll(s.indexer, selector, func(m interface{}) {
		ret = append(ret, m.(*v1.Endpoints))
	})
	return ret, err
}
120364
func (s exampleNamespaceLister) List(selector labels.Selector) (ret []*v1.Example, err error) {
	err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) {
		ret = append(ret, m.(*v1.Example))
	})
	return ret, err
}
417783
func (c *FakeClusters) List(opts v1.ListOptions) (result *v1alpha1.ClusterList, err error) {
	obj, err := c.Fake.
		Invokes(testing.NewListAction(clustersResource, clustersKind, c.ns, opts), &v1alpha1.ClusterList{})

	if obj == nil {
		return nil, err
	}

	label, _, _ := testing.ExtractFromListOptions(opts)
	if label == nil {
		label = labels.Everything()
	}
	list := &v1alpha1.ClusterList{ListMeta: obj.(*v1alpha1.ClusterList).ListMeta}
	for _, item := range obj.(*v1alpha1.ClusterList).Items {
		if label.Matches(labels.Set(item.Labels)) {
			list.Items = append(list.Items, item)
		}
	}
	return list, err
}
800732
func (s *StoreToPodLister) List(selector labels.Selector) (pods []*api.Pod, err error) {
	// TODO: it'd be great to just call
	// s.Pods(api.NamespaceAll).List(selector), however then we'd have to
	// remake the list.Items as a []*api.Pod. So leave this separate for
	// now.
	for _, m := range s.Store.List() {
		pod := m.(*api.Pod)
		if selector.Matches(labels.Set(pod.Labels)) {
			pods = append(pods, pod)
		}
	}
	return pods, nil
}
410061
func (s podPresetNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.PodPreset, err error) {
	err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) {
		ret = append(ret, m.(*v1alpha1.PodPreset))
	})
	return ret, err
}
1281411
func (ls LabelArray) Labels() Labels {
	lbls := Labels{}
	for _, l := range ls {
		lbls[l.Key] = l
	}
	return lbls
}
735159
func (c *FakeKeysets) List(opts v1.ListOptions) (result *v1alpha2.KeysetList, err error) {
	obj, err := c.Fake.
		Invokes(testing.NewListAction(keysetsResource, keysetsKind, c.ns, opts), &v1alpha2.KeysetList{})

	if obj == nil {
		return nil, err
	}

	label, _, _ := testing.ExtractFromListOptions(opts)
	if label == nil {
		label = labels.Everything()
	}
	list := &v1alpha2.KeysetList{ListMeta: obj.(*v1alpha2.KeysetList).ListMeta}
	for _, item := range obj.(*v1alpha2.KeysetList).Items {
		if label.Matches(labels.Set(item.Labels)) {
			list.Items = append(list.Items, item)
		}
	}
	return list, err
}
123196
func (p *Project) List() ([]types.Container, error) {
	filters := filters.NewArgs()
	for key, value := range p.Labels {
		filters.Add("label", fmt.Sprintf("%s=%s", key, value))
	}
	containers, err := p.Client.ContainerList(context.Background(), types.ContainerListOptions{
		Filters: filters,
	})
	if err != nil {
		return nil, err
	}
	return containers, nil
}
85478
func (c *FakeComponentStatuses) List(opts v1.ListOptions) (result *corev1.ComponentStatusList, err error) {
	obj, err := c.Fake.
		Invokes(testing.NewRootListAction(componentstatusesResource, componentstatusesKind, opts), &corev1.ComponentStatusList{})
	if obj == nil {
		return nil, err
	}

	label, _, _ := testing.ExtractFromListOptions(opts)
	if label == nil {
		label = labels.Everything()
	}
	list := &corev1.ComponentStatusList{ListMeta: obj.(*corev1.ComponentStatusList).ListMeta}
	for _, item := range obj.(*corev1.ComponentStatusList).Items {
		if label.Matches(labels.Set(item.Labels)) {
			list.Items = append(list.Items, item)
		}
	}
	return list, err
}
555781
func (s resourceQuotaNamespaceLister) List(selector labels.Selector) (ret []*v1.ResourceQuota, err error) {
	err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) {
		ret = append(ret, m.(*v1.ResourceQuota))
	})
	return ret, err
}