Skip to content

Commit e915d00

Browse files
authored
Merge pull request #466 from NHSDigital/apm-4806-api-catalogue-fix-and-workaround
APM-4806: Fix for pagination, and workaround to disable API catalogue entry creation in NHSD-NONPROD
2 parents 379b3a4 + 4fe668b commit e915d00

2 files changed

Lines changed: 22 additions & 6 deletions

File tree

  • ansible/collections/ansible_collections/nhsd/apigee

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

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,27 @@ def get_all_apidocs(organization, access_token, task_vars=None, refresh=False):
100100
task_vars = {}
101101
apidocs = task_vars.get("APIGEE_APIDOCS")
102102
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})
103+
all_results = []
104+
105+
params = {
106+
"pageSize" : 100
107+
}
108+
scan = True
109+
110+
while scan:
111+
apidocs_request = get(constants.portal_uri(organization), access_token, params=params)
112+
if apidocs_request.get("failed"):
113+
return apidocs_request
114+
115+
next_page_token = apidocs_request["response"]["body"]["next_page_token"]
116+
all_results += apidocs_request["response"]["body"]["data"]
117+
118+
if next_page_token != "":
119+
params["pageToken"] = next_page_token
120+
else:
121+
scan = False
122+
123+
task_vars.update({"APIGEE_APIDOCS": all_results})
108124
return task_vars
109125

110126

ansible/collections/ansible_collections/nhsd/apigee/roles/deploy_manifest/tasks/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,4 @@
7272
# See comment on product loop control. (I believe APIDocs
7373
# actually can reference products that don't exist. But this is
7474
# cleaner.)
75-
when: item.edgeAPIProductName | regex_search('^' + SERVICE_NAME + '-' + PULL_REQUEST | default(APIGEE_ENVIRONMENT))
75+
when: APIGEE_ORGANIZATION == 'nhsd-prod' and item.edgeAPIProductName | regex_search('^' + SERVICE_NAME + '-' + PULL_REQUEST | default(APIGEE_ENVIRONMENT))

0 commit comments

Comments
 (0)