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

Add Pagination to API Server #286

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Catharsis68
Copy link
Contributor

@Catharsis68 Catharsis68 commented Jan 16, 2024

Improved by adding pagination capabilities to api-server API

  • The feature can be enabled via PAGINATION: "true"
  • users SP
  • users account
  • users admin
  • accounts
  • accounts - api_keys
  • accounts - applications
  • accounts - voip carriers
  • /:sid/Accounts/Availability
  • applications
  • service_providers
  • service_providers - voip carriers
  • service_providers - phone numbers
  • service_providers - applications
  • service_providers - accounts
  • service_providers - api_keys
  • LCR routes
  • Added new swagger-pagination file

How to test

Please describe the individual steps on how a peer can test your change.

Precondition: Run api-server locally, set PAGINATION: "true"

  1. Login via {{base_url}}/v1/login
  2. Copy the token for all upcoming requests
  3. Bearer
GET 

{{base_url}}/v1/Accounts?limit=25&page=1
{{base_url}}/v1/Accounts/:account_sid/ApiKeys?limit=25&page=1
{{base_url}}/v1/Accounts/:account_sid/Applications?limit=25&page=1
{{base_url}}/v1/Accounts/:account_sid/VoipCarriers?limit=2&page=1

{{base_url}}/v1/Applications?limit=25&page=1

{{base_url}}/v1/PhoneNumbers?limit=25&page=1

{{base_url}}/v1/lcrs?limit=25&page=1
{{base_url}}/v1/LcrRoutes?limit=25&page=1&lcr_sid=<lcr_sid>

{{base_url}}/v1/ServiceProviders?limit=25&page=1
{{base_url}}/v1/ServiceProviders/:serviceProviderSid/Accounts?limit=25&page=1
{{base_url}}/v1/ServiceProviders/:serviceProviderSid/ApiKeys?limit=25&page=1
{{base_url}}/v1/ServiceProviders/:serviceProviderSid/Applications?limit=25&page=1
{{base_url}}/v1/ServiceProviders/:serviceProviderSid/PhoneNumbers?limit=25&page=1
{{base_url}}/v1/ServiceProviders/:serviceProviderSid/VoipCarriers?limit=25&page=1

{{base_url}}/v1/Users?limit=25&page=1

{{base_url}}/v1/VoipCarriers?limit=25&page=1

{{base_url}}/swagger

@davehorton
Copy link
Contributor

@Catharsis68 these changes are backwards-compatible?

@Catharsis68
Copy link
Contributor Author

@davehorton what do you exatly mean by "backwards-compatible" ?
So the behavior in general is the following:

As soon as the environment variable PAGINATION: "true" and there is a query.limit + query.page - the result is in the paginated response structure

Otherwise the "actual" non-paginated response is sent

@davehorton
Copy link
Contributor

right, just wanted to confirm that if the environment variable is not set then pre-existing apis remain the same

@EgleHelms EgleHelms requested review from xquanluu and davehorton and removed request for xquanluu January 23, 2024 12:40
@EgleHelms
Copy link
Contributor

@davehorton any news on this?

This feature was proposed as a solution to the pentest outcome. Requests with large amounts of data can cause longer response times and peak loads on the web and database server. This could be used for so-called low and slow-distributed denial of service attacks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants