// AddAssignees adds the provided GitHub users as assignees to the issue.
//
// GitHub API docs: https://developer.github.com/v3/issues/assignees/#add-assignees-to-an-issue
348719
func (s *IssuesService) AddAssignees(ctx context.Context, owner, repo string, number int, assignees []string) (*Issue, *Response, error) {
	users := &struct {
		Assignees []string `json:"assignees,omitempty"`
	}{Assignees: assignees}
	u := fmt.Sprintf("repos/%v/%v/issues/%v/assignees", owner, repo, number)
	req, err := s.client.NewRequest("POST", u, users)
	if err != nil {
		return nil, nil, err
	}

	issue := &Issue{}
	resp, err := s.client.Do(ctx, req, issue)
	return issue, resp, err
}
1190600
func (h *localLoginHandlers) AddHandlers(mux *apiserverhttp.Mux) {
	var errorMapper httprequest.ErrorMapper = httpbakery.ErrorToResponse
	var handleJSON = errorMapper.HandleJSON
	makeHandler := func(h httprouter.Handle) http.Handler {
		return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
			h(w, req, nil)
		})
	}
	dischargeMux := http.NewServeMux()
	httpbakery.AddDischargeHandler(
		dischargeMux,
		localUserIdentityLocationPath,
		h.authCtxt.localUserThirdPartyBakeryService,
		h.checkThirdPartyCaveat,
	)
	dischargeMux.Handle(
		localUserIdentityLocationPath+"/login",
		makeHandler(handleJSON(h.serveLogin)),
	)
	dischargeMux.Handle(
		localUserIdentityLocationPath+"/wait",
		makeHandler(handleJSON(h.serveWait)),
	)
	mux.AddHandler("POST", localUserIdentityLocationPath+"/discharge", dischargeMux)
	mux.AddHandler("GET", localUserIdentityLocationPath+"/publickey", dischargeMux)
	mux.AddHandler("GET", localUserIdentityLocationPath+"/wait", dischargeMux)
	mux.AddHandler("GET", localUserIdentityLocationPath+"/login", dischargeMux)
	mux.AddHandler("POST", localUserIdentityLocationPath+"/login", dischargeMux)
}
1234259
func extendUnassignedReviewRequest(
	config *moduleConfig,
	owner string,
	repo string,
	issueNum int,
	commit *git.Commit,
	opts map[string]interface{},
) (*github.Issue, []*git.Commit, error) {

	// Fetch the issue.
	task := fmt.Sprintf("Fetch GitHub issue #%v", issueNum)
	log.Run(task)
	client := ghutil.NewClient(config.Token)
	issue, _, err := client.Issues.Get(owner, repo, issueNum)
	if err != nil {
		return nil, nil, errs.NewError(task, err)
	}

	// Extend the given review issue.
	return extendReviewRequest(config, owner, repo, issue, []*git.Commit{commit}, opts)
}
1063985
func (c *trustTagContext) Signers() string {
	sort.Strings(c.s.Signers)
	return strings.Join(c.s.Signers, ", ")
}
641269
func NewIssueUsers(repo *Repository, issue *Issue) (err error) {
	sess := x.NewSession()
	defer sess.Close()
	if err = sess.Begin(); err != nil {
		return err
	}

	if err = newIssueUsers(sess, repo, issue); err != nil {
		return err
	}

	return sess.Commit()
}
212033
func (h Handle) UnresolvedUsers() []keybase1.SocialAssertion {
	var unresolvedUsers []keybase1.SocialAssertion
	unresolvedUsers = append(unresolvedUsers, h.UnresolvedWriters...)
	unresolvedUsers = append(unresolvedUsers, h.UnresolvedReaders...)
	return unresolvedUsers
}
908961
func (hs *HTTPServer) AddTeamMember(c *m.ReqContext, cmd m.AddTeamMemberCommand) Response {
	cmd.OrgId = c.OrgId
	cmd.TeamId = c.ParamsInt64(":teamId")

	if err := teamguardian.CanAdmin(hs.Bus, cmd.OrgId, cmd.TeamId, c.SignedInUser); err != nil {
		return Error(403, "Not allowed to add team member", err)
	}

	if err := hs.Bus.Dispatch(&cmd); err != nil {
		if err == m.ErrTeamNotFound {
			return Error(404, "Team not found", nil)
		}

		if err == m.ErrTeamMemberAlreadyAdded {
			return Error(400, "User is already added to this team", nil)
		}

		return Error(500, "Failed to add Member to Team", err)
	}

	return JSON(200, &util.DynMap{
		"message": "Member added to Team",
	})
}
480148
func (repo *Repository) getAssignees(e Engine) (_ []*User, err error) {
	return repo.getUsersWithAccesMode(e, ACCESS_MODE_READ)
}
371750
func GetAssigneeByID(repo *Repository, userID int64) (*User, error) {
	has, err := HasAccess(userID, repo, ACCESS_MODE_READ)
	if err != nil {
		return nil, err
	} else if !has {
		return nil, errors.UserNotExist{userID, ""}
	}
	return GetUserByID(userID)
}
825454
func (s *Layer) SetAutoAssignPublicIps(v bool) *Layer {
	s.AutoAssignPublicIps = &v
	return s
}
837077
func (s *IssueService) UpdateAssignee(issueID string, assignee *User) (*Response, error) {
	apiEndPoint := fmt.Sprintf("rest/api/2/issue/%s/assignee", issueID)

	req, err := s.client.NewRequest("PUT", apiEndPoint, assignee)
	if err != nil {
		return nil, err
	}

	resp, err := s.client.Do(req, nil)
	if err != nil {
		err = NewJiraError(resp, err)
	}

	return resp, err
}
1049399
func (api *APIv5) AddUnits(args params.AddApplicationUnitsV5) (params.AddApplicationUnitsResults, error) {
	noDefinedPolicy := ""
	return api.APIBase.AddUnits(params.AddApplicationUnits{
		ApplicationName: args.ApplicationName,
		NumUnits:        args.NumUnits,
		Placement:       args.Placement,
		Policy:          noDefinedPolicy,
		AttachStorage:   args.AttachStorage,
	})
}
432199
func (r *keyring) Signers() ([]ssh.Signer, error) {
	r.mu.Lock()
	defer r.mu.Unlock()
	if r.locked {
		return nil, errLocked
	}

	s := make([]ssh.Signer, 0, len(r.keys))
	for _, k := range r.keys {
		s = append(s, k.signer)
	}
	return s, nil
}
1290495
func addHeaders(req *http.Request, headers map[string]interface{}) (bool, error) {
	for k, v := range headers {
		// Type assertion
		header, ok := v.(string)
		if ok {
			req.Header.Add(k, header)
		} else {
			return false, fmt.Errorf("invalid type for headers value")
		}
	}
	return true, nil
}
394587
func AddTeamMember(orgID, teamID, userID int64) error {
	if IsTeamMember(orgID, teamID, userID) {
		return nil
	}

	if err := AddOrgUser(orgID, userID); err != nil {
		return err
	}

	// Get team and its repositories.
	t, err := GetTeamByID(teamID)
	if err != nil {
		return err
	}
	t.NumMembers++

	if err = t.GetRepositories(); err != nil {
		return err
	}

	sess := x.NewSession()
	defer sess.Close()
	if err = sess.Begin(); err != nil {
		return err
	}

	tu := &TeamUser{
		UID:    userID,
		OrgID:  orgID,
		TeamID: teamID,
	}
	if _, err = sess.Insert(tu); err != nil {
		return err
	} else if _, err = sess.ID(t.ID).Update(t); err != nil {
		return err
	}

	// Give access to team repositories.
	for _, repo := range t.Repos {
		if err = repo.recalculateTeamAccesses(sess, 0); err != nil {
			return err
		}
	}

	// We make sure it exists before.
	ou := new(OrgUser)
	if _, err = sess.Where("uid = ?", userID).And("org_id = ?", orgID).Get(ou); err != nil {
		return err
	}
	ou.NumTeams++
	if t.IsOwnerTeam() {
		ou.IsOwner = true
	}
	if _, err = sess.ID(ou.ID).AllCols().Update(ou); err != nil {
		return err
	}

	return sess.Commit()
}
1033243
func (l *IssueLabelsService) Add(uri *Hyperlink, uriParams M, labelsToAdd []string) (labels []Label, result *Result) {
	url, err := ExpandWithDefault(uri, &IssueLabelsURL, uriParams)
	if err != nil {
		return nil, &Result{Err: err}
	}

	result = l.client.post(url, labelsToAdd, &labels)
	return
}
8143
func (pta *PassThroughAuth) AddAuthHeaders(req *http.Request) {
	req.Header.Set("Authorization", pta.AuthHeader)
}