mirror of
https://github.com/GAM-team/GAM.git
synced 2026-07-03 12:21:35 +00:00
updates to allow listing/setting extension policy
This commit is contained in:
@@ -281,6 +281,7 @@ def get_all_pages(service,
|
|||||||
soft_errors=False,
|
soft_errors=False,
|
||||||
throw_reasons=None,
|
throw_reasons=None,
|
||||||
retry_reasons=None,
|
retry_reasons=None,
|
||||||
|
page_args_in_body=False,
|
||||||
**kwargs):
|
**kwargs):
|
||||||
"""Aggregates and returns all pages of a Google service function response.
|
"""Aggregates and returns all pages of a Google service function response.
|
||||||
|
|
||||||
@@ -311,15 +312,21 @@ def get_all_pages(service,
|
|||||||
retry_reasons: A list of Google HTTP error reason strings indicating which
|
retry_reasons: A list of Google HTTP error reason strings indicating which
|
||||||
error should be retried, using exponential backoff techniques, when the
|
error should be retried, using exponential backoff techniques, when the
|
||||||
error reason is encountered.
|
error reason is encountered.
|
||||||
|
page_args_in_body: Some APIs like Chrome Policy want pageToken and pageSize
|
||||||
|
in the body.
|
||||||
**kwargs: Additional params to pass to the request method.
|
**kwargs: Additional params to pass to the request method.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
A list of all items received from all paged responses.
|
A list of all items received from all paged responses.
|
||||||
"""
|
"""
|
||||||
if 'maxResults' not in kwargs and 'pageSize' not in kwargs:
|
if 'maxResults' not in kwargs and 'pageSize' not in kwargs and 'pageSize' not in kwargs.get('body', {}):
|
||||||
page_key = _get_max_page_size_for_api_call(service, function, **kwargs)
|
page_key = _get_max_page_size_for_api_call(service, function, **kwargs)
|
||||||
if page_key:
|
if page_key:
|
||||||
kwargs.update(page_key)
|
if page_args_in_body:
|
||||||
|
kwargs['body'] = kwargs.get('body', {})
|
||||||
|
kwargs['body'].update(page_key)
|
||||||
|
else:
|
||||||
|
kwargs.update(page_key)
|
||||||
all_items = []
|
all_items = []
|
||||||
page_token = None
|
page_token = None
|
||||||
total_items = 0
|
total_items = 0
|
||||||
@@ -334,7 +341,10 @@ def get_all_pages(service,
|
|||||||
if not page_token:
|
if not page_token:
|
||||||
finalize_page_message(page_message)
|
finalize_page_message(page_message)
|
||||||
return all_items
|
return all_items
|
||||||
kwargs['pageToken'] = page_token
|
if page_args_in_body:
|
||||||
|
kwargs['body']['pageToken'] = page_token
|
||||||
|
else:
|
||||||
|
kwargs['pageToken'] = page_token
|
||||||
|
|
||||||
|
|
||||||
# TODO: Make this private once all execution related items that use this method
|
# TODO: Make this private once all execution related items that use this method
|
||||||
|
|||||||
@@ -89,7 +89,8 @@ def printshow_policies():
|
|||||||
items='resolvedPolicies',
|
items='resolvedPolicies',
|
||||||
throw_reasons=throw_reasons,
|
throw_reasons=throw_reasons,
|
||||||
customer=customer,
|
customer=customer,
|
||||||
body=body)
|
body=body,
|
||||||
|
page_args_in_body=True)
|
||||||
except googleapiclient.errors.HttpError:
|
except googleapiclient.errors.HttpError:
|
||||||
policies = []
|
policies = []
|
||||||
# sort policies first by app/printer id then by schema name
|
# sort policies first by app/printer id then by schema name
|
||||||
|
|||||||
Reference in New Issue
Block a user