MCPcopy Create free account
hub / github.com/auth0/auth0-cli / getWithPagination

Function getWithPagination

internal/cli/organizations.go:857–894  ·  view source on GitHub ↗
(
	limit int,
	api func(opts ...management.RequestOption) (result []interface{}, hasNext bool, err error),
)

Source from the content-addressed store, hash-verified

855}
856
857func getWithPagination(
858 limit int,
859 api func(opts ...management.RequestOption) (result []interface{}, hasNext bool, err error),
860) ([]interface{}, error) {
861 var list []interface{}
862 if err := ansi.Waiting(func() error {
863 pageSize := defaultPageSize
864 page := 0
865 for {
866 if limit > 0 {
867 // Determine page size to avoid getting unwanted elements.
868 want := limit - len(list)
869 if want == 0 {
870 return nil
871 }
872 if want < defaultPageSize {
873 pageSize = want
874 } else {
875 pageSize = defaultPageSize
876 }
877 }
878 res, hasNext, err := api(
879 management.PerPage(pageSize),
880 management.Page(page))
881 if err != nil {
882 return err
883 }
884 page++
885 list = append(list, res...)
886 if len(list) == limit || !hasNext {
887 return nil
888 }
889 }
890 }); err != nil {
891 return nil, err
892 }
893 return list, nil
894}
895
896func (c *cli) getOrgMembers(
897 context context.Context,

Callers 10

FetchDataMethod · 0.85
listRolePermissionsCmdFunction · 0.85
searchUsersCmdFunction · 0.85
showUserRolesCmdFunction · 0.85
listAppsCmdFunction · 0.85
listApisCmdFunction · 0.85
listOrganizationsCmdFunction · 0.85
getOrgMembersMethod · 0.85
getOrgInvitationsMethod · 0.85
listRolesCmdFunction · 0.85

Calls 1

WaitingFunction · 0.92

Tested by

no test coverage detected