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

GET /v2/config/running_security_groups is not a paginated request #578

Closed
Zteve opened this issue Apr 18, 2016 · 5 comments
Closed

GET /v2/config/running_security_groups is not a paginated request #578

Zteve opened this issue Apr 18, 2016 · 5 comments

Comments

@Zteve
Copy link

Zteve commented Apr 18, 2016

Issue

GET /v2/config/running_security_groups

returns a paginated response (with pages) but the request is not documented as paginated. It is therefore apparently impossible to request page 2.

Context

CC API 2.53.0, version 234 (latest version). REST interface.

Steps to Reproduce

Simply issue a GET /v2/config/running_security_groups request. The response looks like this:

HTTP/1.1 200 OK
{
  "total_results": 3,
  "total_pages": 1,
  "prev_url": null,
  "next_url": null,
  "resources": [
    {
      "metadata": {
        "guid": "3ce91b0a-e0ca-4a36-9fc7-f7a7fbcbe84f",
        "url": "/v2/config/running_security_groups/3ce91b0a-e0ca-4a36-9fc7-f7a7fbcbe84f",
        ...
      },
      "entity": {
        "name": "public_networks",
        ...
      }
    },
    ...
  ]
}

which is a paginated response. To build a complete list of "running security groups" one would expect to issue a series of page requests, but the request has no payload and is not paginated.

Expected result

The result is fine, as far as it goes.

Current result

I currently lack the ability to request page 2.

Possible Fix

Extend the request to have a paginated request payload:

Name Description Valid Values
q Parameters used to filter the result set. Valid filters: name
page Page of results to fetch
results-per-page Number of results per page
order-direction Order of the results asc (default) or desc

or some such.

Notes

  • The same (apparent) problem exists for GET /v2/config/staging_security_groups.
  • This problem could be avoided by getting all security groups (GET /v2/security_groups) and filtering out the defaults ones, however the API description of the List all Security Groups request doesn't have any of the staging default or running default security groups in its example response, which implies they aren't returned. Please clarify this in your response.
@cf-gitbot
Copy link

We have created an issue in Pivotal Tracker to manage this. You can view the current status of your issue at: https://www.pivotaltracker.com/story/show/117802219.

@ameowlia
Copy link
Member

Hi @Zteve,

As a default, pages have results-per-page set to 50. So you can't get page 2 of your request because there is no page 2.

We have updated our docs, in the locations that you mentioned, to include the pagination query parameters you can use. Our CI will update them on the internet when our tests complete. So, I'll list them below, too.

param example
page /v2/config/running_security_groups?page=2
results-per-page /v2/config/running_security_groups?results-per-page=5
order-direction /v2/config/running_security_groups?order-direction=asc or /v2/config/running_security_groups?order-direction=desc

Thanks,
@adowns01 && @sax, CAPI Team Members

@Zteve
Copy link
Author

Zteve commented Apr 21, 2016

Thank you Amelia,
My problem is (apparently) not that I can't get page 2 but I cannot ask for it. In the test that I ran I specified results-per-page=1 (to force multiple pages) but this query parameter was ignored.

I'm hoping that, apart from updating the docs, you also update CF to use the page query parameters in the normal way.

I'll retry my test to check if I specified them correctly on my trial request.

@Zteve
Copy link
Author

Zteve commented Apr 21, 2016

As you were; CF recognizes the query parameters; typo in my test. Thank you for your efforts.

@ameowlia
Copy link
Member

It happens to the best of us 😄

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

No branches or pull requests

4 participants