// Gets a list of the (up to limit) most played artists of a user within a Period.
//
// See http://www.last.fm/api/show/user.getTopArtists.
181169
func (lfm *LastFM) GetUserTopArtists(user string, period Period, limit int) (top *TopArtists, err error) {
	method := "user.getTopArtists"
	query := map[string]string{
		"user":   user,
		"period": periodStringMap[period],
		"limit":  strconv.Itoa(limit)}

	if data, err := lfm.cacheGet(method, query); data != nil {
		switch v := data.(type) {
		case TopArtists:
			return &v, err
		case *TopArtists:
			return v, err
		}
	} else if err != nil {
		return nil, err
	}

	body, hdr, err := lfm.doQuery(method, query)
	if err != nil {
		return
	}
	defer body.Close()

	status := lfmStatus{}
	err = xml.NewDecoder(body).Decode(&status)
	if err != nil {
		return
	}
	if status.Error.Code != 0 {
		err = &status.Error
		go lfm.cacheSet(method, query, err, hdr)
		return
	}

	top = &status.TopArtists
	err = top.unmarshalHelper()
	if err == nil {
		go lfm.cacheSet(method, query, top, hdr)
	}
	return
}
581317
func (c *Client) PreviousPlaylistResults(s *SearchResult) error {
	if s.Playlists == nil || s.Playlists.Previous == "" {
		return ErrNoMorePages
	}
	return c.get(s.Playlists.Previous, s)
}
834715
func (l Players) GetPlayer(name string) *player.Player {
	l.RLock()
	defer l.RUnlock()
	return l.list[name]
}
462401
func (api chartApi) GetTopTracks(args map[string]interface{}) (result ChartGetTopTracks, err error) {
	defer func() { appendCaller(err, "lastfm.Chart.GetTopTracks") }()
	err = callGet("chart.gettoptracks", api.params, args, &result, P{
		"plain": []string{"page", "limit"},
	})
	return
}
1289097
func (api libraryApi) GetArtists(args map[string]interface{}) (result LibraryGetArtists, err error) {
	defer func() { appendCaller(err, "lastfm.Library.GetArtists") }()
	err = callGet("library.getartists", api.params, args, &result, P{
		"plain": []string{"user", "limit", "page"},
	})
	return
}
1170280
func (adm *AdminClient) ListUsers() (map[string]UserInfo, error) {
	reqData := requestData{
		relPath: "/v1/list-users",
	}

	// Execute GET on /minio/admin/v1/list-users
	resp, err := adm.executeMethod("GET", reqData)

	defer closeResponse(resp)
	if err != nil {
		return nil, err
	}

	if resp.StatusCode != http.StatusOK {
		return nil, httpRespToErrorResponse(resp)
	}

	data, err := DecryptData(adm.secretAccessKey, resp.Body)
	if err != nil {
		return nil, err
	}

	var users = make(map[string]UserInfo)
	if err = json.Unmarshal(data, &users); err != nil {
		return nil, err
	}

	return users, nil
}
1023852
func (api artistApi) GetSimilar(args map[string]interface{}) (result ArtistGetSimilar, err error) {
	defer func() { appendCaller(err, "lastfm.Artist.GetSimilar") }()
	err = callGet("artist.getsimilar", api.params, args, &result, P{
		"plain": []string{"limit", "artist", "autocorrect", "mbid"},
	})
	return
}
514499
func (p *MediaPlaylist) last() uint {
	if p.tail == 0 {
		return p.capacity - 1
	}
	return p.tail - 1
}
536351
func (provider *SoundcloudProvider) GetUser(creds *common.Credentials) (common.User, error) {

	profileData, err := provider.Get(creds, soundcloudEndpointProfile)

	if err != nil {
		return nil, err
	}

	// build user
	user := NewUser(profileData, creds, provider)

	return user, nil
}
1062816
func (r *usersResource) getAllUsers(request *restful.Request, response *restful.Response, user schema.User) (error, interface{}) {
	users, err := r.users.GetAll()
	return err, users
}
1065516
func (u *User) GetTotalPrivateRepos() int {
	if u == nil || u.TotalPrivateRepos == nil {
		return 0
	}
	return *u.TotalPrivateRepos
}
1246883
func (r Notification_Occurrence_Event) GetImpactedUsers() (resp []datatypes.Notification_Occurrence_User, err error) {
	err = r.Session.DoRequest("SoftLayer_Notification_Occurrence_Event", "getImpactedUsers", nil, &r.Options, &resp)
	return
}
947261
func (u *UserStats) GetTotalUsers() int {
	if u == nil || u.TotalUsers == nil {
		return 0
	}
	return *u.TotalUsers
}
504288
func GetUsers() []User {
	var userPagesResponse struct {
		NextURL   *string `json:"next_url"`
		Resources []struct {
			Metadata struct {
				GUID      string    `json:"guid"`
				CreatedAt time.Time `json:"created_at"`
			} `json:"metadata"`
			Entity struct {
				Username string `json:"username"`
			} `json:"entity"`
		} `json:"resources"`
	}

	var allUsers []User
	nextURL := "/v2/users?results-per-page=50"

	for {
		session := CF("curl", nextURL)
		Eventually(session).Should(Exit(0))

		err := json.Unmarshal(session.Out.Contents(), &userPagesResponse)
		Expect(err).NotTo(HaveOccurred())
		for _, resource := range userPagesResponse.Resources {
			allUsers = append(allUsers, User{
				GUID:      resource.Metadata.GUID,
				CreatedAt: resource.Metadata.CreatedAt,
				Username:  resource.Entity.Username,
			})
		}

		if userPagesResponse.NextURL == nil {
			break
		}
		nextURL = *userPagesResponse.NextURL
	}

	return allUsers
}
240466
func (db *usersDB) GetAll() ([]schema.User, error) {
	defer db.mutex.RUnlock()
	db.mutex.RLock()

	users := make([]schema.User, 0, len(db.users))
	i := 0
	for _, user := range db.users {
		users = append(users, user)
		i++
	}
	return users, nil
}
880433
func (api tagApi) GetTopTags(args map[string]interface{}) (result TagGetTopTags, err error) {
	defer func() { appendCaller(err, "lastfm.Tag.GetTopTags") }()
	err = callGet("tag.gettoptags", api.params, args, &result, P{})
	return
}
33032
func (api userApi) GetTopTags(args map[string]interface{}) (result UserGetTopTags, err error) {
	defer func() { appendCaller(err, "lastfm.User.GetTopTags") }()
	err = callGet("user.gettoptags", api.params, args, &result, P{
		"plain": []string{"user", "limit"},
	})
	return
}