// SaveOrgMember save or update organization member
762706
func (m *Manager) SaveOrgMember(organization *Organization, organizationID string) error {
	return m.collection.Update(
		bson.M{"globalid": organization.Globalid},
		bson.M{"$addToSet": bson.M{"orgmembers": organizationID}})
}
85816
func (org *Organization) UpdateUser(user UserChange) error {
	var (
		r userUpdateResponse
		b bytes.Buffer
	)
	err := json.NewEncoder(&b).Encode(user)
	if err != nil {
		return err
	}
	err = org.PPE.put(fmt.Sprintf("/orgs/%s/users/%s", org.PrimaryDomain, user.PrimaryEmail), &b, &r)
	if err != nil {
		return err
	}
	if r.ResultCode != 0 {
		return errors.New(r.Message)
	}
	return nil
}
64416
func (b *Builder) AddMember(fieldname string, typ dwarf.Offset, memberLoc []byte) dwarf.Offset {
	r := b.TagOpen(dwarf.TagMember, fieldname)
	b.Attr(dwarf.AttrType, typ)
	b.Attr(dwarf.AttrDataMemberLoc, memberLoc)
	b.TagClose()
	return r
}
719201
func (api OrganizationsAPI) RemoveOrganizationMember(w http.ResponseWriter, r *http.Request) {
	removeOrganizationMember(w, r, "member")
}
613134
func (c *Cluster) AddMember(member *Member) error {
	c.mu.Lock()
	defer c.mu.Unlock()

	if c.removed[member.RaftID] {
		return ErrIDRemoved
	}

	c.members[member.RaftID] = member

	c.broadcastUpdate()
	return nil
}
739746
func (s *OrganizationsService) RemoveMember(ctx context.Context, org, user string) (*Response, error) {
	u := fmt.Sprintf("orgs/%v/members/%v", org, user)
	req, err := s.client.NewRequest("DELETE", u, nil)
	if err != nil {
		return nil, err
	}

	return s.client.Do(ctx, req, nil)
}
153542
func isMember(requiredOrgs []string, userOrgs []*github.Organization) bool {
	for _, requiredOrg := range requiredOrgs {
		for _, userOrg := range userOrgs {
			if userOrg.Login != nil && *userOrg.Login == requiredOrg {
				return true
			}
		}
	}
	return false
}
75969
func Save(args *RequestArgs) error {
	user := args.User
	appName := args.AppName
	org := args.Organization

	stats_query := utils.M{
		"user":     user,
		"app_name": appName,
		"org":      org,
	}

	save_doc := utils.M{
		"user":      user,
		"app_name":  appName,
		"org":       org,
		"timestamp": utils.EpochNow(),
	}

	return db.Conn.Upsert(db.StatsCollection, stats_query, save_doc)
}
961290
func (s *Service) OrganizationInvitationCreate(ctx context.Context, organizationIdentity string, o OrganizationInvitationCreateOpts) (*OrganizationInvitation, error) {
	var organizationInvitation OrganizationInvitation
	return &organizationInvitation, s.Put(ctx, &organizationInvitation, fmt.Sprintf("/organizations/%v/invitations", organizationIdentity), o)
}
194816
func (s *Service) PutOrganization(ctx context.Context, o *influxdb.Organization) error {
	var err error
	return s.kv.Update(ctx, func(tx Tx) error {
		if pe := s.putOrganization(ctx, tx, o); pe != nil {
			err = pe
		}
		return err
	})
}
1196693
func (s *Service) OrganizationAppCollaboratorUpdate(ctx context.Context, organizationAppIdentity string, organizationAppCollaboratorIdentity string, o OrganizationAppCollaboratorUpdateOpts) (*OrganizationAppCollaborator, error) {
	var organizationAppCollaborator OrganizationAppCollaborator
	return &organizationAppCollaborator, s.Patch(ctx, &organizationAppCollaborator, fmt.Sprintf("/organizations/apps/%v/collaborators/%v", organizationAppIdentity, organizationAppCollaboratorIdentity), o)
}
150306
func (api *Client) HoldConferenceMember(id string, memberID string, hold bool) error{
	return api.UpdateConferenceMember(id, memberID, &UpdateConferenceMemberData{Hold: hold})
}
923452
func (m *Manager) Save(apikey *APIKey) (err error) {
	if apikey.ID == "" {
		// New Doc!
		apikey.ID = bson.NewObjectId()
		err = m.getCollection().Insert(apikey)
		return
	}
	_, err = m.getCollection().UpsertId(apikey.ID, apikey)
	return
}
222290
func (m *Manager) SaveEmail(username string, email EmailAddress) error {
	if err := m.RemoveEmail(username, email.Label); err != nil {
		return err
	}
	return m.getUserCollection().Update(
		bson.M{"username": username},
		bson.M{"$push": bson.M{"emailaddresses": email}})
}
135784
func (s *Service) TeamMemberCreateOrUpdate(ctx context.Context, teamIdentity string, o TeamMemberCreateOrUpdateOpts) (*TeamMember, error) {
	var teamMember TeamMember
	return &teamMember, s.Put(ctx, &teamMember, fmt.Sprintf("/teams/%v/members", teamIdentity), o)
}
1327139
func (m *Manager) IsMember(globalID, username string) (result bool, err error) {
	if !m.Exists(globalID) {
		return
	}
	result, err = m.isDirectMember(globalID, username)
	if result || err != nil {
		return
	}
	// If not a direct member, check the membership in the parent organization
	lastSubOrgSeperator := strings.LastIndex(globalID, ".")
	if lastSubOrgSeperator > 0 {
		result, err = m.IsMember(globalID[:lastSubOrgSeperator], username)
		if result || err != nil {
			return
		}
	}
	// If not a direct or inherited member, iterate through the list of member organizations
	var org Organization
	err = m.collection.Find(bson.M{"globalid": globalID}).Select(bson.M{"orgmembers": 1, "includesuborgsof": 1}).One(&org)
	if err != nil {
		if mgo.ErrNotFound == err {
			err = nil
		}
		return
	}
	excludelist := make(map[string]bool)
	excludelist[globalID] = true

	// Also get the suborganizations if they have been added
	var includesuborgs []string
	for _, member := range org.OrgMembers {
		for _, include := range org.IncludeSubOrgsOf {
			if member == include {
				includesuborgs = append(includesuborgs, include)
			}
		}
	}
	var subOrgs []Organization
	for _, subOrg := range includesuborgs {
		subOrganizations, err := m.GetSubOrganizations(subOrg)
		if err != nil && err != mgo.ErrNotFound {
			return false, err
		}
		subOrgs = append(subOrgs, subOrganizations...)
	}
	var orgs []string
	for _, suborganization := range subOrgs {
		orgs = append(orgs, suborganization.Globalid)
	}
	for _, owningOrganization := range append(org.OrgMembers, orgs...) {
		result, err = m.isOwnerOrMember(owningOrganization, username, excludelist)
		if result || err != nil {
			return
		}
	}

	return
}
848845
func (i *Index) SaveObject(object interface{}, opts ...interface{}) (res SaveObjectRes, err error) {
	path := i.path("")
	err = i.transport.Request(&res, http.MethodPost, path, object, call.Write, opts...)
	res.wait = i.WaitTask
	return
}