src/google-classroom-extractor/edfi_google_classroom_extractor/api/api_caller.py
def _call_api_recursive(
    resource_method: Callable,
    resource_parameters: Dict[str, str],
    response_property: str,
    results: Optional[List[Dict[str, str]]] = None,
) -> List[Dict[str, str]]:
    """
    Call a Google Classroom/Admin SDK API

    Parameters
    ----------
    resource_method: function
        is the get/list SDK function to call
    resource_parameters: dict
        is the parameters for get/list
    response_property: string
        is the property in the API response we want
    results: list
        is the list of dicts of the API response accumulated across pages

    Returns
    -------
    list
        a list of dicts of the API response property requested
    """

    current_results: List[Dict[str, str]] = [] if results is None else results
    response = _execute(resource_method(**resource_parameters))
    try:
        current_results.extend(response.get(response_property, []))
    except (IOError, RequestException, GoogleApiError):
        logger.exception("Error during API call after retries.  Will try to continue.")
        return current_results

    next_page_token = response.get("nextPageToken", None)
    if not next_page_token:
        return current_results
    resource_parameters["pageToken"] = next_page_token
    return cast(
        List[Dict[str, str]],
        _call_api_recursive.tail_call(
            resource_method, resource_parameters, response_property, current_results
        ),
    )

    Call a Google Classroom/Admin SDK API

    Parameters
    ----------
    resource_method: function
        is the get/list SDK function to call
    resource_parameters: dict
        is the parameters for get/list
    response_property: string
        is the property in the API response we want
    results: list
        is the list of dicts of the API response accumulated across pages

    Returns
    -------
    list
        a list of dicts of the API response property requested
    
Call a Google Classroom/Admin SDK API
Parameters

function
is the get/list SDK function to call
resource_parameters: dict
is the parameters for get/list
response_property: string
is the property in the API response we want
results: list
is the list of dicts of the API response accumulated across pages

Returns

list
a list of dicts of the API response property requested
Call a Google Classroom / Admin SDK API Parameters function is the get / list SDK function to call resource_parameters : dict is the parameters for get / list response_property : string is the property in the API response we want results : list is the list of dicts of the API response accumulated across pages Returns list a list of dicts of the API response property requested
def _call_api_recursive(
    resource_method: Callable,
    resource_parameters: Dict[str, str],
    response_property: str,
    results: Optional[List[Dict[str, str]]] = None,
) -> List[Dict[str, str]]:
    current_results: List[Dict[str, str]] = [] if results is None else results
    response = _execute(resource_method(**resource_parameters))
    try:
        current_results.extend(response.get(response_property, []))
    except (IOError, RequestException, GoogleApiError):
        logger.exception("Error during API call after retries.  Will try to continue.")
        return current_results
    next_page_token = response.get("nextPageToken", None)
    if not next_page_token:
        return current_results
    resource_parameters["pageToken"] = next_page_token
    return cast(
        List[Dict[str, str]],
        _call_api_recursive.tail_call(
            resource_method, resource_parameters, response_property, current_results
        ),
    )
def _call_api_recursive ( resource_method : Callable , resource_parameters : Dict [ str , str ] , response_property : str , results : Optional [ List [ Dict [ str , str ] ] ] = None , ) -> List [ Dict [ str , str ] ] : current_results : List [ Dict [ str , str ] ] = [ ] if results is None else results response = _execute ( resource_method ( ** resource_parameters ) ) try : current_results . extend ( response . get ( response_property , [ ] ) ) except ( IOError , RequestException , GoogleApiError ) : logger . exception ( "Error during API call after retries.  Will try to continue." ) return current_results next_page_token = response . get ( "nextPageToken" , None ) if not next_page_token : return current_results resource_parameters [ "pageToken" ] = next_page_token return cast ( List [ Dict [ str , str ] ] , _call_api_recursive . tail_call ( resource_method , resource_parameters , response_property , current_results ) , )
Call a Google Classroom/Admin SDK API
Parameters
Call a Google Classroom / Admin SDK API Parameters
"""
    Call a Google Classroom/Admin SDK API

    Parameters
    ----------
    resource_method: function
        is the get/list SDK function to call
    resource_parameters: dict
        is the parameters for get/list
    response_property: string
        is the property in the API response we want
    results: list
        is the list of dicts of the API response accumulated across pages

    Returns
    -------
    list
        a list of dicts of the API response property requested
    """
resource_method
Callable
resource_parameters
Dict[str, str]
response_property
str
results
Optional[List[Dict[str, str]]]