public < T extends CanvasReader > T getReader ( Class < T > type , OauthToken oauthToken , Integer paginationPageSize ) { LOG . debug ( "Factory call to instantiate class: " + type . getName ( ) ) ; RestClient restClient = new RefreshingRestClient ( ) ; @ SuppressWarnings ( "unchecked" ) Class < T > concreteClass = ( Class < T > ) readerMap . get ( type ) ; if ( concreteClass == null ) { throw new UnsupportedOperationException ( "No implementation for requested interface found: " + type . getName ( ) ) ; } LOG . debug ( "got class: " + concreteClass ) ; try { Constructor < T > constructor = concreteClass . getConstructor ( String . class , Integer . class , OauthToken . class , RestClient . class , Integer . TYPE , Integer . TYPE , Integer . class , Boolean . class ) ; return constructor . newInstance ( canvasBaseUrl , CANVAS_API_VERSION , oauthToken , restClient , connectTimeout , readTimeout , paginationPageSize , false ) ; } catch ( NoSuchMethodException | InvocationTargetException | IllegalAccessException | InstantiationException e ) { throw new UnsupportedOperationException ( "Unknown error instantiating the concrete API class: " + type . getName ( ) , e ) ; } }
Get a reader implementation class to perform API calls with while specifying an explicit page size for paginated API calls . This gets translated to a per_page = parameter on API requests . Note that Canvas does not guarantee it will honor this page size request . There is an explicit maximum page size on the server side which could change . The default page size is 10 which can be limiting when for example trying to get all users in a 800 person course .