def _flatten_list_results(project_id, paged_results, item_key):
"""Flatten results and handle exceptions.
Args:
project_id (str): The project id the results are for.
paged_results (list): A list of paged API response objects.
[{page 1 results}, {page 2 results}, {page 3 results}, ...]
item_key (str): The name of the key within the inner "items" lists
containing the objects of interest.
Returns:
list: A list of items.
Raises:
ApiNotEnabledError: Raised if the API is not enabled for the project.
ApiExecutionError: Raised if there is another error while calling the
API method.
"""
try:
return api_helpers.flatten_list_results(paged_results, item_key)
except (errors.HttpError, HttpLib2Error) as e:
api_not_enabled, details = _api_not_enabled(e)
if api_not_enabled:
raise api_errors.ApiNotEnabledError(details, e)
raise api_errors.ApiExecutionError(project_id, e)
# pylint: disable=too-many-instance-attributes
评论列表
文章目录