// ListProjects fetches a list of projects
//
// Codeship API docs: https://apidocs.codeship.com/v2/projects/list-projects
352102
func (o *Organization) ListProjects(ctx context.Context, opts ...PaginationOption) (ProjectList, Response, error) {
	path, err := paginate(fmt.Sprintf("/organizations/%s/projects", o.UUID), opts...)
	if err != nil {
		return ProjectList{}, Response{}, errors.Wrap(err, "unable to list projects")
	}

	body, resp, err := o.client.request(ctx, "GET", path, nil)
	if err != nil {
		return ProjectList{}, resp, errors.Wrap(err, "unable to list projects")
	}

	var projects ProjectList
	if err = json.Unmarshal(body, &projects); err != nil {
		return ProjectList{}, resp, errors.Wrap(err, "unable to unmarshal response into ProjectList")
	}

	return projects, resp, nil
}
365919
func Projects(ids []uint64) []*Project {
	var projects []*Project
	for _, elem := range ids {
		project, _ := NewProject(elem)
		projects = append(projects, project)
	}
	return projects
}
698299
func (c *FakeEndpoints) List(opts v1.ListOptions) (result *corev1.EndpointsList, err error) {
	obj, err := c.Fake.
		Invokes(testing.NewListAction(endpointsResource, endpointsKind, c.ns, opts), &corev1.EndpointsList{})

	if obj == nil {
		return nil, err
	}

	label, _, _ := testing.ExtractFromListOptions(opts)
	if label == nil {
		label = labels.Everything()
	}
	list := &corev1.EndpointsList{ListMeta: obj.(*corev1.EndpointsList).ListMeta}
	for _, item := range obj.(*corev1.EndpointsList).Items {
		if label.Matches(labels.Set(item.Labels)) {
			list.Items = append(list.Items, item)
		}
	}
	return list, err
}
734811
func (e *engineImpl) GetAllProjects(c context.Context) ([]string, error) {
	q := ds.NewQuery("Job").
		Eq("Enabled", true).
		Project("ProjectID").
		Distinct(true)
	entities := []Job{}
	if err := ds.GetAll(c, q, &entities); err != nil {
		return nil, transient.Tag.Apply(err)
	}
	// Filter out duplicates, sort.
	projects := stringset.New(len(entities))
	for _, ent := range entities {
		projects.Add(ent.ProjectID)
	}
	out := projects.ToSlice()
	sort.Strings(out)
	return out, nil
}
323269
func (s *AccountService) NewListProjectAccountsParams(projectid string) *ListProjectAccountsParams {
	p := &ListProjectAccountsParams{}
	p.p = make(map[string]interface{})
	p.p["projectid"] = projectid
	return p
}
1211710
func (e *ApiClientService) ListKeys(clientName string) (data *ApiClientKeyListResult, err error) {
	url := fmt.Sprintf("clients/%s/keys", clientName)
	err = e.client.magicRequestDecoder("GET", url, nil, &data)
	return
}
1227457
func (s *ProjectsService) GetProject(projectName string) (*ProjectInfo, *Response, error) {
	u := fmt.Sprintf("projects/%s", url.QueryEscape(projectName))

	v := new(ProjectInfo)
	resp, err := s.client.Call("GET", u, nil, v)
	return v, resp, err
}
446656
func (s *ProjectService) NewListProjectsParams() *ListProjectsParams {
	p := &ListProjectsParams{}
	p.p = make(map[string]interface{})
	return p
}
595421
func (gce *Cloud) ListSslCertificates() (*compute.SslCertificateList, error) {
	// TODO: use PageToken to list all not just the first 500
	return gce.service.SslCertificates.List(gce.projectID).Do()
}
643811
func GetAppProject(spec *argoappv1.ApplicationSpec, projLister applicationsv1.AppProjectLister, ns string) (*argoappv1.AppProject, error) {
	return projLister.AppProjects(ns).Get(spec.GetProject())
}
1056745
func GetAllProjects(c context.Context) ([]Project, error) {
	q := datastore.NewQuery("Project")
	projs := []Project{}

	if err := datastore.GetAll(c, q, &projs); err != nil {
		return nil, errors.Annotate(err, "getting projects").Err()
	}
	result := []Project{}
	for _, proj := range projs {
		switch allowed, err := IsAllowed(c, proj.ID); {
		case err != nil:
			return nil, err
		case allowed:
			result = append(result, proj)
		}
	}
	return result, nil
}
1160922
func ListProjectPaths(projectDir string, include, exclude matcher.Matcher) ([]string, error) {
	wd, err := os.Getwd()
	if err != nil {
		return nil, errors.Wrapf(err, "failed to determine working directory")
	}
	if !filepath.IsAbs(projectDir) {
		projectDir = path.Join(wd, projectDir)
	}
	relPathPrefix, err := filepath.Rel(wd, projectDir)
	if err != nil {
		return nil, errors.Wrapf(err, "failed to determine relative path")
	}

	files, err := matcher.ListFiles(projectDir, include, exclude)
	if err != nil {
		return nil, err
	}
	if relPathPrefix != "" {
		for i, file := range files {
			files[i] = path.Join(relPathPrefix, file)
		}
	}
	return files, nil
}
201267
func (c *ClientBuildLister) List(label labels.Selector) ([]*buildv1.Build, error) {
	list, err := c.client.Builds(metav1.NamespaceAll).List(metav1.ListOptions{LabelSelector: label.String()})
	return buildListToPointerArray(list), err
}
681033
func (c *projects) List(opts v1.ListOptions) (result *project.ProjectList, err error) {
	var timeout time.Duration
	if opts.TimeoutSeconds != nil {
		timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
	}
	result = &project.ProjectList{}
	err = c.client.Get().
		Resource("projects").
		VersionedParams(&opts, scheme.ParameterCodec).
		Timeout(timeout).
		Do().
		Into(result)
	return
}
459691
func (c *ProductsClient) List(ctx context.Context, opts *ProductsListOpts) *ProductIter {
	iter := ProductIter{
		first: true,
		i:     -1,
	}

	p := "/products/"

	var q url.Values
	if opts != nil {
		q = make(url.Values)
		if opts.ProviderID != nil {
			b, err := opts.ProviderID.MarshalText()
			if err != nil {
				return &iter
			}
			q.Set("provider_id", string(b))
		}

		if opts.Label != nil {
			q.Set("label", *opts.Label)
		}
	}

	var req *http.Request
	req, iter.err = c.backend.NewRequest(http.MethodGet, p, q, nil)
	if iter.err != nil {
		return &iter
	}

	_, iter.err = c.backend.Do(ctx, req, &iter.page, func(code int) error {
		switch code {
		case 400, 500:
			return &Error{}
		default:
			return nil
		}
	})
	return &iter
}
433163
func (srv *Projects) List(c context.Context, req *projects.ListRequest) (*projects.ListResponse, error) {
	rsp := &projects.ListResponse{}
	// TODO(smut): Handle page tokens.
	if req.GetPageToken() != "" {
		return rsp, nil
	}
	srv.cfg.Range(func(_, val interface{}) bool {
		rsp.Projects = append(rsp.Projects, val.(*projects.Config))
		return true
	})
	return rsp, nil
}
1097847
func (s *ProjectsService) ListTags(projectName string, opt *ProjectBaseOptions) (*[]TagInfo, *Response, error) {
	u := fmt.Sprintf("projects/%s/tags/", url.QueryEscape(projectName))
	u, err := addOptions(u, opt)
	if err != nil {
		return nil, nil, err
	}

	req, err := s.client.NewRequest("GET", u, nil)
	if err != nil {
		return nil, nil, err
	}

	v := new([]TagInfo)
	resp, err := s.client.Do(req, v)
	if err != nil {
		return nil, resp, err
	}

	return v, resp, err
}