// getBuilderHistories gets the recent histories for the builders in the given project.
555716
func getBuilderHistories(c context.Context, builders []string, project string, limit int) ([]*builderHistory, error) {
	// Populate the recent histories.
	hists := make([]*builderHistory, len(builders))
	err := parallel.WorkPool(16, func(ch chan<- func() error) {
		for i, builder := range builders {
			i := i
			builder := builder
			ch <- func() error {
				hist, err := getHistory(c, buildsource.BuilderID(builder), project, limit)
				if err != nil {
					return errors.Annotate(
						err, "error populating history for builder %s", builder).Err()
				}
				hists[i] = hist
				return nil
			}
		}
	})
	if err != nil {
		return nil, err
	}

	// for all buildbot builders, we don't have pending BuildSummary entities,
	// so load pending counts from buildstore.
	var buildbotBuilders []string // "<master>/<builder>" strings
	var buildbotHists []*builderHistory
	for _, h := range hists {
		backend, master, builder, err := h.BuilderID.Split()
		if backend == "buildbot" && err == nil {
			buildbotHists = append(buildbotHists, h)
			buildbotBuilders = append(buildbotBuilders, fmt.Sprintf("%s/%s", master, builder))
		}
	}
	if len(buildbotBuilders) > 0 {
		pendingCounts, err := buildstore.GetPendingCounts(c, buildbotBuilders)
		if err != nil {
			return nil, err
		}
		for i, count := range pendingCounts {
			buildbotHists[i].NumPending = count
		}
	}

	return hists, nil
}
308365
func (c *SearchCall) MaxBuilds(maxBuilds int64) *SearchCall {
	c.urlParams_.Set("max_builds", fmt.Sprint(maxBuilds))
	return c
}
921746
func (t *Template) GetAllAWSAppStreamImageBuilderResources() map[string]*resources.AWSAppStreamImageBuilder {
	results := map[string]*resources.AWSAppStreamImageBuilder{}
	for name, untyped := range t.Resources {
		switch resource := untyped.(type) {
		case *resources.AWSAppStreamImageBuilder:
			results[name] = resource
		}
	}
	return results
}
349641
func (mr *MockBuildsClientMockRecorder) GetBuild(ctx, in interface{}, opts ...interface{}) *gomock.Call {
	mr.mock.ctrl.T.Helper()
	varargs := append([]interface{}{ctx, in}, opts...)
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetBuild", reflect.TypeOf((*MockBuildsClient)(nil).GetBuild), varargs...)
}
996817
func (c *Client) GetProjectList(page string, pageSize string, projectOwner string) (result ProjectListResultModel, err error) {

	params := url.Values{}
	params.Add("Page", page)
	params.Add("PageSize", pageSize)

	if projectOwner != "" {
		params.Add("ProjectOwner", projectOwner)
	}

	paramsString := params.Encode()

	requestUrl := c.GetUrl("projects", "", "")
	requestPath := GetRequestPath("projects", "", "")

	responseResult, _ := c.GetResponseJson("GET", requestUrl+"?"+paramsString+"&resource", requestPath+"?"+paramsString+"&resource", "")

	err = json.Unmarshal([]byte(responseResult), &result)

	return result, err
}
1001934
func (c *ApiController) GetActiveBuilds() {
	// TODO(tobe): this is not implemented because nobody uses it yet.
	log.Info("Get active builds")

	result := "Not implemented"
	c.Ctx.WriteString(result)
}
1337888
func (r *baseCommandRun) retrieveBuildIDs(ctx context.Context, builds []string) (buildIDs []int64, err error) {
	return retrieveBuildIDs(builds, func(req *pb.BatchRequest) (*pb.BatchResponse, error) {
		return r.client.Batch(ctx, req)
	})
}
87704
func GetBuilds(c context.Context, q Query) (*QueryResult, error) {
	switch {
	case q.Master == "":
		return nil, errors.New("master is required")
	case q.Builder == "":
		return nil, errors.New("builder is required")
	}

	if !EmulationEnabled(c) {
		return getDatastoreBuilds(c, q, true)
	}

	var emulatedBuilds, buildbotBuilds []*buildbot.Build
	err := parallel.FanOutIn(func(work chan<- func() error) {
		work <- func() (err error) {
			res, err := getDatastoreBuilds(c, q, false)
			if res != nil {
				buildbotBuilds = res.Builds
			}
			return
		}
		work <- func() (err error) {
			emulatedBuilds, err = getEmulatedBuilds(c, q)
			return
		}
	})
	if err != nil {
		return nil, errors.Annotate(err, "could not load builds").Err()
	}

	mergedBuilds := mergeBuilds(emulatedBuilds, buildbotBuilds)
	if q.Limit > 0 && len(mergedBuilds) > q.Limit {
		mergedBuilds = mergedBuilds[:q.Limit]
	}
	return &QueryResult{Builds: mergedBuilds}, nil
}
7916
func (m *MockBuildsClient) GetBuild(ctx context.Context, in *GetBuildRequest, opts ...grpc.CallOption) (*Build, error) {
	m.ctrl.T.Helper()
	varargs := []interface{}{ctx, in}
	for _, a := range opts {
		varargs = append(varargs, a)
	}
	ret := m.ctrl.Call(m, "GetBuild", varargs...)
	ret0, _ := ret[0].(*Build)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}
421359
func (o *Organization) GetBuild(ctx context.Context, projectUUID, buildUUID string) (Build, Response, error) {
	path := fmt.Sprintf("/organizations/%s/projects/%s/builds/%s", o.UUID, projectUUID, buildUUID)

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

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

	return build.Build, resp, nil
}
351069
func (g *PagesService) PageBuilds(uri *Hyperlink, uriParams M) (builds []PageBuild,
	result *Result) {
	url, err := ExpandWithDefault(uri, &PagesBuildsURL, uriParams)
	if err != nil {
		return nil, &Result{Err: err}
	}
	result = g.client.get(url, &builds)
	return
}
555543
func getBuild(c context.Context, id buildbot.BuildID, fetchAnnotations, fetchChanges bool) (*buildbot.Build, error) {
	if !EmulationEnabled(c) {
		return getDatastoreBuild(c, id)
	}

	// Is it a LUCI build?
	build, err := getEmulatedBuild(c, id, fetchAnnotations, fetchChanges)
	switch {
	case err != nil:
		return nil, err
	case build != nil:
		// does not exist or experimental.
		return build, nil
	}

	// Is it a Buildbot build?
	build, err = getDatastoreBuild(c, id)
	switch {
	case err != nil:
		return nil, err
	case build == nil:
		return nil, nil
	case build.Experimental():
		return nil, nil
	default:
		return build, nil
	}
}
594418
func (s *BuildStore) get(ctx context.Context, tx *bolt.Tx) (chronograf.BuildInfo, error) {
	var build chronograf.BuildInfo
	defaultBuild := chronograf.BuildInfo{
		Version: "pre-1.4.0.0",
		Commit:  "",
	}

	if bucket := tx.Bucket(BuildBucket); bucket == nil {
		return defaultBuild, nil
	} else if v := bucket.Get(BuildKey); v == nil {
		return defaultBuild, nil
	} else if err := internal.UnmarshalBuild(v, &build); err != nil {
		return build, err
	}
	return build, nil
}
1209187
func GetRawBuild(c context.Context, address string) (*bbv1.ApiCommonBuildMessage, error) {
	host, err := getHost(c)
	if err != nil {
		return nil, err
	}

	client, err := newBuildbucketClient(c, host)
	if err != nil {
		return nil, err
	}
	// This runs a search RPC against BuildBucket, but it is optimized for speed.
	build, err := bbv1.GetByAddress(c, client, address)
	switch {
	case err != nil:
		return nil, errors.Annotate(err, "could not get build at %q", address).Err()
	case build == nil && auth.CurrentUser(c).Identity == identity.AnonymousIdentity:
		return nil, errors.Reason("not logged in").Tag(grpcutil.UnauthenticatedTag).Err()
	case build == nil:
		return nil, errors.Reason("build at %q not found", address).Tag(grpcutil.NotFoundTag).Err()
	default:
		return build, nil
	}
}
938205
func (cs *CommitsService) GetFromBuild(buildId uint) (*Commit, *http.Response, error) {
	u, err := urlWithOptions(fmt.Sprintf("/builds/%d", buildId), nil)
	if err != nil {
		return nil, nil, err
	}

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

	var buildResp getBuildResponse
	resp, err := cs.client.Do(req, &buildResp)
	if err != nil {
		return nil, resp, err
	}

	return &buildResp.Commit, resp, nil
}
781023
func (s *ReleaseServer) GetHistory(ctx context.Context, req *tpb.GetHistoryRequest) (*tpb.GetHistoryResponse, error) {
	if err := validateReleaseName(req.Name); err != nil {
		s.Log("getHistory: Release name is invalid: %s", req.Name)
		return nil, err
	}

	s.Log("getting history for release %s", req.Name)
	h, err := s.env.Releases.History(req.Name)
	if err != nil {
		return nil, err
	}

	relutil.Reverse(h, relutil.SortByRevision)

	var resp tpb.GetHistoryResponse
	for i := 0; i < min(len(h), int(req.Max)); i++ {
		resp.Releases = append(resp.Releases, h[i])
	}

	return &resp, nil
}
642994
func (u User) GetReferencedStructs() []jsonapi.MarshalIdentifier {
	result := []jsonapi.MarshalIdentifier{}
	for key := range u.Chocolates {
		result = append(result, u.Chocolates[key])
	}

	return result
}