-
Notifications
You must be signed in to change notification settings - Fork 60
Description
Describe the bug
When using containers_list_read(query_params), the function will default to limit=50 via execute_compute() method, though I pass in a limit of 1.
query_params = {"limit":1}
Expected behavior
I would expect containers_list_read(query_params) to have limit set from from the provided input and not default to 50.
Current behavior
Currently, containers_list_read() calls execute_compute() like this self.execute_compute('GET', 'api/v1/containers?', query_params=query_params, paginated=True) , which defaults to setting the url with a hardcoded limit of 50:
if paginated:
url = 'https://%s/%s?limit=%s&offset=%s' % (self.api_compute, endpoint, limit, offset)
And it returns a paginated list of 50 items until a 429 response is received (which is a separate issue)
Possible solution
limit = int(query_params.get("limit", "50")) if query_params.get("limit", "").isdigit() and 0 < int(query_params.get("limit", "50")) <= 50 else 50
The code needs to handle if query_param["limit"] is passed as an int or str.
Steps to reproduce
Instantiate a connection to your Prisma Console URL and call containers_list_read(query_parms)
pc_api.containers_list_read(query_params=query_params)
API Code Method:
https://github.com/PaloAltoNetworks/prismacloud-api-python/blob/main/prismacloud/api/cwpp/cwpp.py#L28
Line in quesetion
https://github.com/PaloAltoNetworks/prismacloud-api-python/blob/main/prismacloud/api/cwpp/cwpp.py#L50
Screenshots
Due to the nature of the results, no screenshots are provided.
Context
I can not use the SDK since I need a limit of 1 for some calls and a limit of 50 for more gets a 429 error