Make tower_api a generic GET'er

This commit is contained in:
John Westcott IV
2020-06-11 13:34:40 -04:00
parent 44a3057d16
commit f4454a6c93
3 changed files with 33 additions and 22 deletions

View File

@@ -274,7 +274,10 @@ class TowerModule(AnsibleModule):
def get_all_endpoint(self, endpoint, *args, **kwargs):
response = self.get_endpoint(endpoint, *args, **kwargs)
if 'next' not in response['json']:
raise RuntimeError('Expected list from API at {0}, got: {1}'.format(endpoint, response))
if not 'none_is_not_fatal' in kwargs or not kwargs['none_is_not_fatal']:
raise RuntimeError('Expected list from API at {0}, got: {1}'.format(endpoint, response))
else:
return response
next_page = response['json']['next']
if response['json']['count'] > 10000: