-
Notifications
You must be signed in to change notification settings - Fork 5
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
Plan listings don't react on page
and per_page
#69
Comments
page
and per_page
example check: curl -H "X-Auth-Token: $METAL_AUTH_TOKEN" "https://api.equinix.com/metal/v1/plans?per_page=90" | jq ".plans | length" |
Page doesn't change: Page doesn't change
curl -H "X-Auth-Token: $METAL_AUTH_TOKEN" "https://api.equinix.com/metal/v1/plans?page=2" | md5sum -
curl -H "X-Auth-Token: $METAL_AUTH_TOKEN" "https://api.equinix.com/metal/v1/plans?page=1" | md5sum - |
curl -s -H "X-Auth-Token: $METAL_AUTH_TOKEN" "https://api.equinix.com/metal/v1/plans?type=standard" | jq ".plans | length"
15 |
I only get 63 plans, which indicates that I'm getting all plans back; it's possible that the same is happening in your case, and there really are exactly 100 plans available to you. I also see that the API is not responding to pagination params, but on closer inspection, according to the spec, that endpoint doesn't support pagination parameters and the response schema doesn't include pagination metadata. For curl -H "X-Auth-Token: $METAL_AUTH_TOKEN" "https://api.equinix.com/metal/v1/plans?categories[]=storage" | jq ".plans | length" |
Oh I see what's going on there for me. I get duplicate entries in the plans listing, two entries are the same, they differ only in slug: Duplicate 0: {"id": "b2c4d757-d9b9-58cd-8380-393e0f4a16cb", "slug": "w3tintel.8358.512.6080",...} Duplicate 1: {"id": "b2c4d757-d9b9-58cd-8380-393e0f4a16cb", "slug": "w3tintel.8358.512.6080.x86",...} There's 68 unique entries for me. I put python script that verifies this in next comment. |
#!/usr/bin/env python3
import json
with open("plans.json") as f:
plans = json.load(f)['plans']
print("Number of plans:", len(plans))
ids = [p['id'] for p in plans]
print("Number of unique plans IDs:", len(set(ids)))
last_id = ids[-1]
dupes = [p for p in plans if p['id'] == last_id]
print("Number of plans with ID %s: %d" % (last_id, len(dupes)))
for i, d in enumerate(dupes):
print("Duplicate %d:" % i)
print(d)
print()
for k in dupes[0]:
v0 = dupes[0][k]
v1 = dupes[1][k]
if v0 != v1:
print("Same-ID plans differ in \"%s\": \"%s\" != \"%s\"" % (k, v0, v1))
print()
d = {}
for i in set(ids):
ps = [p for p in plans if p['id'] == i]
n = len(ps)
d[ps[0]['slug']] = n
print("Number of plans in listing per slug:")
print("===================================")
for k, v in d.items():
print(k, v) |
Considering how unconventional this syntax is for the EM API, this may be an upstream defect. Another reason to question these results is that only one plan takes advantage of
|
This PR changes name of plans listing param `categories` to `categories[]`. discovered by @ctreatma #69 (comment) related to #69 I wonder if we should this also for devices lookup. @ctreatma has this been fixed in metal-go?
Listing all plans returns 100 items. API does not respond to
page
orper_page
query parameters.Found while developing an ansible collection,
equinix/ansible-collection-equinix#146
The text was updated successfully, but these errors were encountered: