// AuthUserGroupByID retrieves a row from 'django.auth_user_groups' as a AuthUserGroup.
//
// Generated from index 'auth_user_groups_id_pkey'.
19132
func AuthUserGroupByID(db XODB, id int) (*AuthUserGroup, error) {
	var err error

	// sql query
	const sqlstr = `SELECT ` +
		`id, user_id, group_id ` +
		`FROM django.auth_user_groups ` +
		`WHERE id = ?`

	// run query
	XOLog(sqlstr, id)
	aug := AuthUserGroup{
		_exists: true,
	}

	err = db.QueryRow(sqlstr, id).Scan(&aug.ID, &aug.UserID, &aug.GroupID)
	if err != nil {
		return nil, err
	}

	return &aug, nil
}
676585
func (u *UniterAPIV5) RelationById(args params.RelationIds) (params.RelationResultsV5, error) {
	v6Results, err := u.UniterAPI.RelationById(args)
	if err != nil {
		return params.RelationResultsV5{}, errors.Trace(err)
	}
	return relationResultsToV5(v6Results), nil
}
632784
func AuthGroupPermissionsByPermissionID(db XODB, permissionID int) ([]*AuthGroupPermission, error) {
	var err error

	// sql query
	const sqlstr = `SELECT ` +
		`id, group_id, permission_id ` +
		`FROM django.auth_group_permissions ` +
		`WHERE permission_id = ?`

	// run query
	XOLog(sqlstr, permissionID)
	q, err := db.Query(sqlstr, permissionID)
	if err != nil {
		return nil, err
	}
	defer q.Close()

	// load results
	res := []*AuthGroupPermission{}
	for q.Next() {
		agp := AuthGroupPermission{
			_exists: true,
		}

		// scan
		err = q.Scan(&agp.ID, &agp.GroupID, &agp.PermissionID)
		if err != nil {
			return nil, err
		}

		res = append(res, &agp)
	}

	return res, nil
}
353041
func AuthUserUserPermissionByID(db XODB, id int) (*AuthUserUserPermission, error) {
	var err error

	// sql query
	const sqlstr = `SELECT ` +
		`id, user_id, permission_id ` +
		`FROM public.auth_user_user_permissions ` +
		`WHERE id = $1`

	// run query
	XOLog(sqlstr, id)
	auup := AuthUserUserPermission{
		_exists: true,
	}

	err = db.QueryRow(sqlstr, id).Scan(&auup.ID, &auup.UserID, &auup.PermissionID)
	if err != nil {
		return nil, err
	}

	return &auup, nil
}
1169750
func AuthGroupPermissionByID(db XODB, id int) (*AuthGroupPermission, error) {
	var err error

	// sql query
	const sqlstr = `SELECT ` +
		`id, group_id, permission_id ` +
		`FROM public.auth_group_permissions ` +
		`WHERE id = $1`

	// run query
	XOLog(sqlstr, id)
	agp := AuthGroupPermission{
		_exists: true,
	}

	err = db.QueryRow(sqlstr, id).Scan(&agp.ID, &agp.GroupID, &agp.PermissionID)
	if err != nil {
		return nil, err
	}

	return &agp, nil
}
113918
func (s *OrgService) FindOrganizationByID(ctx context.Context, id influxdb.ID) (*influxdb.Organization, error) {
	if err := authorizeReadOrg(ctx, id); err != nil {
		return nil, err
	}

	return s.s.FindOrganizationByID(ctx, id)
}
288533
func (info Info) GetGroupByID(groupID string) *Group {
	for _, group := range info.Groups {
		if group.ID == groupID {
			return &group
		}
	}
	return nil
}
223432
func (aug *AuthUserGroup) AuthGroup(db XODB) (*AuthGroup, error) {
	return AuthGroupByID(db, aug.GroupID)
}
1188285
func (p Protos) AuthUser(username string, password string) (auth.UserInfo, error) {
	userInfo := auth.UserInfo{}
	url := p.createURL("user/auth")
	login := struct {
		Username string `json:"username"`
		Password string `json:"password"`
	}{
		Username: username,
		Password: password,
	}
	loginJSON, err := json.Marshal(login)
	if err != nil {
		return userInfo, err
	}

	req, err := http.NewRequest("GET", url, bytes.NewBuffer(loginJSON))
	if err != nil {
		return userInfo, err
	}
	req.Header.Set("Content-Type", "application/json")

	res, err := p.makeRequest(req)
	if err != nil {
		return userInfo, err
	}

	err = json.Unmarshal(res, &userInfo)
	if err != nil {
		return userInfo, err
	}
	return userInfo, nil
}
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)
}
143569
func (res RPCResponses) GetByID(id int) *RPCResponse {
	for _, r := range res {
		if r.ID == id {
			return r
		}
	}

	return nil
}
38786
func (s *AuthorizationService) FindAuthorizationByID(ctx context.Context, id platform.ID) (*platform.Authorization, error) {
	u, err := newURL(s.Addr, authorizationIDPath(id))
	if err != nil {
		return nil, err
	}

	req, err := http.NewRequest("GET", u.String(), nil)
	if err != nil {
		return nil, err
	}
	SetToken(s.Token, req)

	hc := newClient(u.Scheme, s.InsecureSkipVerify)
	resp, err := hc.Do(req)
	if err != nil {
		return nil, err
	}
	defer resp.Body.Close()

	if err := CheckError(resp); err != nil {
		return nil, err
	}

	var b platform.Authorization
	if err := json.NewDecoder(resp.Body).Decode(&b); err != nil {
		return nil, err
	}

	return &b, nil
}
856292
func (s *VMGroupService) GetInstanceGroupByID(id string, opts ...OptionFunc) (*InstanceGroup, int, error) {
	p := &ListInstanceGroupsParams{}
	p.p = make(map[string]interface{})

	p.p["id"] = id

	for _, fn := range append(s.cs.options, opts...) {
		if err := fn(s.cs, p); err != nil {
			return nil, -1, err
		}
	}

	l, err := s.ListInstanceGroups(p)
	if err != nil {
		if strings.Contains(err.Error(), fmt.Sprintf(
			"Invalid parameter id value=%s due to incorrect long value format, "+
				"or entity does not exist", id)) {
			return nil, 0, fmt.Errorf("No match found for %s: %+v", id, l)
		}
		return nil, -1, err
	}

	if l.Count == 0 {
		return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l)
	}

	if l.Count == 1 {
		return l.InstanceGroups[0], l.Count, nil
	}
	return nil, l.Count, fmt.Errorf("There is more then one result for InstanceGroup UUID: %s!", id)
}
834026
func (s *UsersService) GetByID(ctx context.Context, id int64) (*User, *Response, error) {
	u := fmt.Sprintf("user/%d", id)
	req, err := s.client.NewRequest("GET", u, nil)
	if err != nil {
		return nil, nil, err
	}

	user := new(User)
	resp, err := s.client.Do(ctx, req, user)
	if err != nil {
		return nil, resp, err
	}

	return user, resp, nil
}
256808
func (mc MongoClient) IntervalById(id string) (contract.Interval, error) {
	s := mc.getSessionCopy()
	defer s.Close()

	query, err := idToBsonM(id)
	if err != nil {
		return contract.Interval{}, err
	}

	var interval models.Interval
	if err := s.DB(mc.database.Name).C(db.Interval).Find(query).One(&interval); err != nil {
		return contract.Interval{}, errorMap(err)
	}
	return interval.ToContract(), nil
}
837951
func AuthGroupsByName(db XODB, name string) ([]*AuthGroup, error) {
	var err error

	// sql query
	const sqlstr = `SELECT ` +
		`id, name ` +
		`FROM public.auth_group ` +
		`WHERE name = $1`

	// run query
	XOLog(sqlstr, name)
	q, err := db.Query(sqlstr, name)
	if err != nil {
		return nil, err
	}
	defer q.Close()

	// load results
	res := []*AuthGroup{}
	for q.Next() {
		ag := AuthGroup{
			_exists: true,
		}

		// scan
		err = q.Scan(&ag.ID, &ag.Name)
		if err != nil {
			return nil, err
		}

		res = append(res, &ag)
	}

	return res, nil
}
342708
func (s *UserService) FindUserByID(ctx context.Context, id influxdb.ID) (*influxdb.User, error) {
	if err := authorizeReadUser(ctx, id); err != nil {
		return nil, err
	}

	return s.s.FindUserByID(ctx, id)
}