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

containers_list_read() does not respect query parameters for ?limit=1 (or any number) #181

Open
fivetran-bradbeggs opened this issue Sep 11, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@fivetran-bradbeggs
Copy link

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

Your Environment

@fivetran-bradbeggs fivetran-bradbeggs added the bug Something isn't working label Sep 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant