Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolving pagination issue in custom_config script #2734

Open
wants to merge 1 commit into
base: eng
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions python/avi/migrationtools/custom_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,23 @@ def login_api():
global api_results
api_query = ['NetworkSecurityPolicy', 'HTTPPolicySet', 'VSDataScriptSet']
for q in api_query:
resp = api.get(q.lower()+"?include_name")
api_results[q] = resp.json()["results"]
api_results[q]=[]
# make api call with page_size and page # and then we loop through pages
page=1
page_end = False
while page_end is not True:
resp = api.get(f'{q.lower()}?include_name&page_size=200&page={page}')
if resp is None or resp.status_code != 200:
print(f"Failed to retrieve {q}!")
exit(1)
else:
resp = resp.json()
api_results[q].extend(resp["results"])

if "next" in resp.keys():
page +=1
else:
page_end = True
# return api_results[q]


Expand Down