// listKVMs returns a slice of KVMs in the database.
491406
func listKVMs(c context.Context, req *crimson.ListKVMsRequest) ([]*crimson.KVM, error) {
	ipv4s, err := parseIPv4s(req.Ipv4S)
	if err != nil {
		return nil, err
	}
	mac48s, err := parseMAC48s(req.MacAddresses)
	if err != nil {
		return nil, err
	}

	stmt := squirrel.Select(
		"h.name",
		"h.vlan_id",
		"p.name",
		"r.name",
		"d.name",
		"k.description",
		"k.mac_address",
		"i.ipv4",
		"k.state",
	)
	stmt = stmt.From("kvms k, hostnames h, platforms p, racks r, datacenters d, ips i").
		Where("k.hostname_id = h.id").
		Where("k.platform_id = p.id").
		Where("k.rack_id = r.id").
		Where("r.datacenter_id = d.id").
		Where("i.hostname_id = h.id")
	stmt = selectInInt64(stmt, "h.vlan_id", req.Vlans)
	stmt = selectInString(stmt, "h.name", req.Names)
	stmt = selectInString(stmt, "p.name", req.Platforms)
	stmt = selectInString(stmt, "d.name", req.Datacenters)
	stmt = selectInString(stmt, "r.name", req.Racks)
	stmt = selectInUint64(stmt, "k.mac_address", mac48s)
	stmt = selectInInt64(stmt, "i.ipv4", ipv4s)
	stmt = selectInState(stmt, "k.state", req.States)
	query, args, err := stmt.ToSql()
	if err != nil {
		return nil, errors.Annotate(err, "failed to generate statement").Err()
	}

	db := database.Get(c)
	rows, err := db.QueryContext(c, query, args...)
	if err != nil {
		return nil, errors.Annotate(err, "failed to fetch KVMs").Err()
	}
	defer rows.Close()

	var kvms []*crimson.KVM
	for rows.Next() {
		k := &crimson.KVM{}
		var ipv4 common.IPv4
		var mac48 common.MAC48
		if err = rows.Scan(
			&k.Name,
			&k.Vlan,
			&k.Platform,
			&k.Rack,
			&k.Datacenter,
			&k.Description,
			&mac48,
			&ipv4,
			&k.State,
		); err != nil {
			return nil, errors.Annotate(err, "failed to fetch KVM").Err()
		}
		k.MacAddress = mac48.String()
		k.Ipv4 = ipv4.String()
		kvms = append(kvms, k)
	}
	return kvms, nil
}
744201
func (c *Client) ListKeys() ([]Key, error) {
	var resp []Key
	req := request{
		method: client.GET,
		url:    apiKeys,
		resp:   &resp,
	}
	if _, err := c.sendRequest(req); err != nil {
		return nil, errors.Newf(err, "failed to get list of keys")
	}
	return resp, nil
}
251322
func KVListFromMap(m map[string]string) KVList {
	keys := make([]string, 0, len(m))
	for k := range m {
		keys = append(keys, k)
	}
	sort.Strings(keys)
	kvList := make([]KV, len(keys))
	for i, k := range keys {
		kvList[i] = KV{
			Key:   k,
			Value: m[k],
		}
	}
	return kvList
}
200301
func (s *SnapshotService) ListVMSnapshot(p *ListVMSnapshotParams) (*ListVMSnapshotResponse, error) {
	resp, err := s.cs.newRequest("listVMSnapshot", p.toURLValues())
	if err != nil {
		return nil, err
	}

	var r ListVMSnapshotResponse
	if err := json.Unmarshal(resp, &r); err != nil {
		return nil, err
	}

	return &r, nil
}
1173384
func listKeys(db keyval.ProtoBroker) {
	resp, err := db.ListKeys(phonebook.EtcdPath())
	if err != nil {
		log.Fatal(err)
	}

	fmt.Println("list keys:")
	for {
		key, _, stop := resp.GetNext()
		if stop {
			break
		}

		fmt.Printf("- %s\n", key)

	}
}
813215
func (k *ksonnetApp) ListParams(environment string) ([]*v1alpha1.KsonnetParameter, error) {
	args := []string{"param", "list", "--output", "json"}
	if environment != "" {
		args = append(args, "--env", environment)
	}
	out, err := k.ksCmd(args...)
	if err != nil {
		return nil, err
	}
	// Auxiliary data to hold unmarshaled JSON output, which may use different field names
	var ksParams struct {
		Data []struct {
			Component string `json:"component"`
			Key       string `json:"param"`
			Value     string `json:"value"`
		} `json:"data"`
	}
	if err := json.Unmarshal([]byte(out), &ksParams); err != nil {
		return nil, err
	}
	var params []*v1alpha1.KsonnetParameter
	for _, ksParam := range ksParams.Data {
		value := strings.Trim(ksParam.Value, `'"`)
		params = append(params, &v1alpha1.KsonnetParameter{
			Component: ksParam.Component,
			Name:      ksParam.Key,
			Value:     value,
		})
	}
	return params, nil
}
870309
func (s *serviceCache) ListKeys() []string {
	s.mu.Lock()
	defer s.mu.Unlock()
	keys := make([]string, 0, len(s.serviceMap))
	for k := range s.serviceMap {
		keys = append(keys, k)
	}
	return keys
}
6266
func (db *db) ListClusters(ctx context.Context) (*appv1.ClusterList, error) {
	clusterSecrets, err := db.listClusterSecrets()
	if err != nil {
		return nil, err
	}
	clusterList := appv1.ClusterList{
		Items: make([]appv1.Cluster, len(clusterSecrets)),
	}
	hasInClusterCredentials := false
	for i, clusterSecret := range clusterSecrets {
		cluster := *secretToCluster(clusterSecret)
		clusterList.Items[i] = cluster
		if cluster.Server == common.KubernetesInternalAPIServerAddr {
			hasInClusterCredentials = true
		}
	}
	if !hasInClusterCredentials {
		clusterList.Items = append(clusterList.Items, localCluster)
	}
	return &clusterList, nil
}
202272
func (c *Client) ListVolumes(machines []string) ([]params.VolumeDetailsListResult, error) {
	filters := make([]params.VolumeFilter, len(machines))
	for i, machine := range machines {
		filters[i].Machines = []string{names.NewMachineTag(machine).String()}
	}
	if len(filters) == 0 {
		filters = []params.VolumeFilter{{}}
	}
	args := params.VolumeFilters{filters}
	var results params.VolumeDetailsListResults
	if err := c.facade.FacadeCall("ListVolumes", args, &results); err != nil {
		return nil, errors.Trace(err)
	}
	if len(results.Results) != len(filters) {
		return nil, errors.Errorf(
			"expected %d result(s), got %d",
			len(filters), len(results.Results),
		)
	}
	return results.Results, nil
}
326603
func (pdb *BrokerWatcher) ListKeys(prefix string) (keyval.BytesKeyIterator, error) {
	keys, qm, err := pdb.client.KV().Keys(pdb.prefixKey(prefix), "", nil)
	if err != nil {
		return nil, err
	}

	return &bytesKeyIterator{len: len(keys), keys: keys, prefix: pdb.prefix, lastIndex: qm.LastIndex}, nil
}
639728
func (c *Client) List(prefix string) (*KVMeta, KVPairs, error) {
	return c.getRecurse(prefix, true, 0)
}
396938
func (f *FakeCustomStore) ListKeys() []string {
	if f.ListKeysFunc != nil {
		return f.ListKeysFunc()
	}
	return nil
}
350117
func (k *KVS) List(args *structs.KeyRequest, reply *structs.IndexedDirEntries) error {
	if done, err := k.srv.forward("KVS.List", args, args, reply); done {
		return err
	}

	aclToken, err := k.srv.ResolveToken(args.Token)
	if err != nil {
		return err
	}

	if aclToken != nil && k.srv.config.ACLEnableKeyListPolicy && !aclToken.KeyList(args.Key) {
		return acl.ErrPermissionDenied
	}

	return k.srv.blockingQuery(
		&args.QueryOptions,
		&reply.QueryMeta,
		func(ws memdb.WatchSet, state *state.Store) error {
			index, ent, err := state.KVSList(ws, args.Key)
			if err != nil {
				return err
			}
			if aclToken != nil {
				ent = FilterDirEnt(aclToken, ent)
			}

			if len(ent) == 0 {
				// Must provide non-zero index to prevent blocking
				// Index 1 is impossible anyways (due to Raft internals)
				if index == 0 {
					reply.Index = 1
				} else {
					reply.Index = index
				}
				reply.Entries = nil
			} else {
				reply.Index = index
				reply.Entries = ent
			}
			return nil
		})
}
1134225
func (c CloudstackClient) ListVirtualMachines(id string) (ListVirtualMachinesResponse, error) {
	var resp ListVirtualMachinesResponse
	params := url.Values{}
	params.Set("id", id)
	response, err := NewRequest(c, "listVirtualMachines", params)
	if err != nil {
		return resp, err
	}
	resp = response.(ListVirtualMachinesResponse)
	return resp, err
}
1004120
func (h HeaderMap) ListKeys() []string {
	keys := make([]string, 0, len(h))
	for k := range h {
		keys = append(keys, k)
	}
	return keys
}
563602
func (db *BytesConnectionEtcd) ListValues(key string) (keyval.BytesKeyValIterator, error) {
	return listValuesInternal(db.Logger, db.etcdClient, db.opTimeout, key)
}
163504
func (f *RemoteRuntime) ListContainers(ctx context.Context, req *kubeapi.ListContainersRequest) (*kubeapi.ListContainersResponse, error) {
	items, err := f.RuntimeService.ListContainers(req.Filter)
	if err != nil {
		return nil, err
	}

	return &kubeapi.ListContainersResponse{Containers: items}, nil
}