Helper functions for API clients.
flatten_aggregated_list_results
(paged_results, item_key)[source]¶Flatten a split-up list as returned by GCE “aggregatedList” API.
The compute API’s aggregatedList methods return a structure in the form:
- {
- items: {
- $group_value_1: {
- $item_key: [$items]
}, $group_value_2: {
$item_key: [$items]}, $group_value_3: {
- “warning”: {
- message: “There are no results for …”
}
}, …, $group_value_n, {
$item_key: [$items]},
}
}
where each “$group_value_n” is a particular element in the aggregation, e.g. a particular zone or group or whatever, and “$item_key” is some type-specific resource name, e.g. “backendServices” for an aggregated list of backend services.
This method takes such a structure and yields a simple list of all $items across all of the groups.
Parameters: |
|
---|---|
Returns: | A list of items. |
Return type: | list |
flatten_list_results
(paged_results, item_key)[source]¶Flatten a split-up list as returned by list_next() API.
with one dictionary for each “page” of results. This method flattens that to a simple list of items.
Parameters: |
|
---|---|
Returns: | A list of items. |
Return type: | list |
get_delegated_credential
(delegated_account, scopes)[source]¶Build delegated credentials required for accessing the gsuite APIs.
Parameters: |
|
---|---|
Returns: | Credentials as built by google.oauth2.service_account. |
Return type: | service_account.Credentials |