Hi,
I think API v2 GET /hosts pagination can handles with “count” and “page” query parameters.
I have jq installed on Linux for a simple example.
It's a 3-host small lab, and NTNX-xxxxxxxx-A is AHV host name.
Linux$ curl -ks -u $CRED "https://$PRISM:9440/PrismGateway/services/rest/v2.0/hosts" |
jq -r '.entitiesr].name, .metadata'
NTNX-1345a952-A
NTNX-0a648466-A
NTNX-739ee780-A
{
"grand_total_entities": 3,
"total_entities": 3,
"filter_criteria": "",
"sort_criteria": "",
"page": 1,
"count": 3,
"start_index": 1,
"end_index": 3
}
1 host per page by “?count=1&page=1” query parameters. Then page 1 is displayed.
Linux$ curl -ks -u $CRED "https://$PRISM:9440/PrismGateway/services/rest/v2.0/hosts?count=1&page=1" | jq -r '.entities|].name, .metadata'
NTNX-1345a952-A
{
"grand_total_entities": 3,
"total_entities": 3,
"filter_criteria": "",
"sort_criteria": "",
"page": 1,
"count": 1,
"start_index": 1,
"end_index": 1
}
By setting to “page=3”, the host on the 3rd page is displayed.
Linux$ curl -ks -u $CRED "https://$PRISM:9440/PrismGateway/services/rest/v2.0/hosts?count=1&page=3" | jq -r '.entitiese].name, .metadata'
NTNX-739ee780-A
{
"grand_total_entities": 3,
"total_entities": 3,
"filter_criteria": "",
"sort_criteria": "",
"page": 3,
"count": 1,
"start_index": 3,
"end_index": 3
}
The API reference can be found in Prism's API Explorer, but explanation may be insufficient...
https://$PRISM:9440/api/nutanix/v2/api_explorer/
Thanks @go.watanabe03-72705 !
@dragon222 - Does the code sample from Go Watanabe above accomplish what you’re looking for? Please advise, thanks!