Skip to content

Commit 28e4ebd

Browse files
author
Philip Skinner
committed
Attempts to fix API deployments
1 parent 0150551 commit 28e4ebd

1 file changed

Lines changed: 23 additions & 5 deletions

File tree

  • ansible/collections/ansible_collections/nhsd/apigee/plugins/module_utils

ansible/collections/ansible_collections/nhsd/apigee/plugins/module_utils/utils.py

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,31 @@ def get_all_apidocs(organization, access_token, task_vars=None, refresh=False):
9898
"""
9999
if task_vars is None:
100100
task_vars = {}
101+
101102
apidocs = task_vars.get("APIGEE_APIDOCS")
103+
102104
if refresh or not apidocs:
103-
apidocs_request = get(constants.portal_uri(organization), access_token)
104-
if apidocs_request.get("failed"):
105-
return apidocs_request
106-
apidocs = apidocs_request["response"]["body"]["data"]
107-
task_vars.update({"APIGEE_APIDOCS": apidocs})
105+
all_results = []
106+
107+
params = {
108+
"pageSize" : 100
109+
}
110+
scan = True
111+
112+
while scan:
113+
apidocs_request = get(constants.portal_uri(organization), access_token, params=params)
114+
if apidocs_request.get("failed"):
115+
return apidocs_request
116+
117+
next_page_token = apidocs_request["response"]["body"]["next_page_token"]
118+
all_results += apidocs_request["response"]["body"]["data"]
119+
120+
if next_page_token != "":
121+
params["pageToken"] = next_page_token
122+
else:
123+
scan = False
124+
125+
task_vars.update({"APIGEE_APIDOCS": all_results})
108126
return task_vars
109127

110128

0 commit comments

Comments
 (0)